From patchwork Thu Dec 13 06:50:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen-chien Jesse Sung X-Patchwork-Id: 205771 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id CC2902C0086 for ; Thu, 13 Dec 2012 17:53:03 +1100 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1Tj2fA-0002CF-Gz; Thu, 13 Dec 2012 06:52:56 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1Tj2f5-00029J-CO for kernel-team@lists.ubuntu.com; Thu, 13 Dec 2012 06:52:51 +0000 Received: from [112.104.135.12] (helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1Tj2dY-0000NG-Rt; Thu, 13 Dec 2012 06:51:17 +0000 From: Jesse Sung To: kernel-team@lists.ubuntu.com Subject: [Quantal][PATCH 28/29] be2net: fix vfs enumeration Date: Thu, 13 Dec 2012 14:50:01 +0800 Message-Id: <1355381402-10497-28-git-send-email-jesse.sung@canonical.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1355381402-10497-1-git-send-email-jesse.sung@canonical.com> References: <1355381402-10497-1-git-send-email-jesse.sung@canonical.com> Cc: Ivan Vecera , Sarveshwar Bandi X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com From: Ivan Vecera BugLink: https://launchpad.net/bugs/1083088 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. Signed-off-by: Ivan Vecera Signed-off-by: David S. Miller (cherry picked from commit 2f6a02604e962295569749913081365ec9ec1372) Signed-off-by: Wen-chien Jesse Sung --- drivers/net/ethernet/emulex/benet/be_main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 11563c0..c4fcdb0 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -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++;