Skip to contentSkip to conversation

be2net: fix vfs enumeration

PATCH Applied Ivan Vecera 2 participants 2 messages Oct 1, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 be2net: fix vfs enumeration

Current VFs enumeration algorithm used in be_find_vfs does not take domain number into the match. The match found in igb/ixgbe is more elegant and safe.

This 2nd version uses pci_physfn instead of checking dev->physfn directly.

---
 drivers/net/ethernet/emulex/benet/be_main.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/emulex/benet/be_main.c +2 -4
index 6accb0c..8dd42b3 100644
@@ -1075,7 +1075,7 @@ static int be_set_vf_tx_rate(struct net_device *netdev,
 static int be_find_vfs(struct be_adapter *adapter, int vf_state)
 {
 	struct pci_dev *dev, *pdev = adapter->pdev;
-	int vfs = 0, assigned_vfs = 0, pos, vf_fn;
+	int vfs = 0, assigned_vfs = 0, pos;
 	u16 offset, stride;
 
 	pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_SRIOV);
@@ -1086,9 +1086,7 @@ static int be_find_vfs(struct be_adapter *adapter, int vf_state)
 
 	dev = pci_get_device(pdev->vendor, PCI_ANY_ID, NULL);
 	while (dev) {
-		vf_fn = (pdev->devfn + offset + stride * vfs) & 0xFFFF;
-		if (dev->is_virtfn && dev->devfn == vf_fn &&
-			dev->bus->number == pdev->bus->number) {
+		if (dev->is_virtfn && pci_physfn(dev) == pdev) {
 			vfs++;
 			if (dev->dev_flags & PCI_DEV_FLAGS_ASSIGNED)
 				assigned_vfs++;
Signature · 1 line
1.7.8.6
maintainer Applied
#1 lore raw

From: Ivan Vecera <[email protected]>
Date: Mon, 1 Oct 2012 13:56:55 +0200

Quoted 7 lines

Current VFs enumeration algorithm used in be_find_vfs does not take domain number into the match. The match found in igb/ixgbe is more elegant and safe.

This 2nd version uses pci_physfn instead of checking dev->physfn directly.

Applied.