From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com ([143.182.124.21]:22689 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752645Ab3DVQNb (ORCPT ); Mon, 22 Apr 2013 12:13:31 -0400 Message-ID: <517561A6.6030506@intel.com> Date: Mon, 22 Apr 2013 09:13:26 -0700 From: Alexander Duyck MIME-Version: 1.0 To: Gavin Shan CC: Jeff Kirsher , davem@davemloft.net, Bjorn Helgaas , netdev@vger.kernel.org, gospo@redhat.com, sassmann@redhat.com, "linux-pci@vger.kernel.org" Subject: Re: [net-next 08/14] pci: Add SRIOV helper function to determine if VFs are assigned to guest References: <1366451353-24714-1-git-send-email-jeffrey.t.kirsher@intel.com> <1366451353-24714-9-git-send-email-jeffrey.t.kirsher@intel.com> <1366515088.2209.15.camel@jtkirshe-mobl> <20130421051423.GA4052@shangw.(null)> In-Reply-To: <20130421051423.GA4052@shangw.(null)> Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-pci-owner@vger.kernel.org List-ID: On 04/20/2013 10:14 PM, Gavin Shan wrote: > On Sat, Apr 20, 2013 at 08:31:28PM -0700, Jeff Kirsher wrote: >> On Sat, 2013-04-20 at 02:49 -0700, Jeff Kirsher wrote: >>> From: Alexander Duyck >>> >>> This function is meant to add a helper function that will determine if a PF >>> has any VFs that are currently assigned to a guest. We currently have been >>> implementing this function per driver, and going forward I would like to avoid >>> that by making this function generic and using this helper. >>> >>> Signed-off-by: Alexander Duyck >>> Signed-off-by: Jeff Kirsher >> Adding linux-pci mailing list and Bjorn to the CC. >> >> Bjorn- David Miller needs a signoff by PCI maintainer. >> >>> --- >>> drivers/pci/iov.c | 41 +++++++++++++++++++++++++++++++++++++++++ >>> include/linux/pci.h | 5 +++++ >>> 2 files changed, 46 insertions(+) >>> >>> diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c >>> index ee599f2..fd99720 100644 >>> --- a/drivers/pci/iov.c >>> +++ b/drivers/pci/iov.c >>> @@ -729,6 +729,47 @@ int pci_num_vf(struct pci_dev *dev) >>> EXPORT_SYMBOL_GPL(pci_num_vf); >>> >>> /** >>> + * pci_vfs_assigned - returns number of VFs are assigned to a guest >>> + * @dev: the PCI device >>> + * >>> + * Returns number of VFs belonging to this device that are assigned to a guest. >>> + * If device is not a physical function returns -ENODEV. >>> + */ >>> +int pci_vfs_assigned(struct pci_dev *dev) >>> +{ >>> + struct pci_dev *vfdev; >>> + unsigned int vfs_assigned = 0; >>> + unsigned short dev_id; >>> + >>> + /* only search if we are a PF */ >>> + if (!dev->is_physfn) >>> + return -ENODEV; > I think it's more reasonable to return zero here? I suppose that is true, it would be more in keeping with how pci_num_vf works so I will make that change. Thanks, Alex