From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48273) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoxnN-0001iP-NO for qemu-devel@nongnu.org; Wed, 21 Oct 2015 14:07:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZoxnJ-0001wR-Ml for qemu-devel@nongnu.org; Wed, 21 Oct 2015 14:07:29 -0400 Received: from mail-pa0-x22d.google.com ([2607:f8b0:400e:c03::22d]:36567) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoxnJ-0001wC-Gk for qemu-devel@nongnu.org; Wed, 21 Oct 2015 14:07:25 -0400 Received: by pacfv9 with SMTP id fv9so63793874pac.3 for ; Wed, 21 Oct 2015 11:07:24 -0700 (PDT) References: <1445445464-5056-1-git-send-email-tianyu.lan@intel.com> <1445445464-5056-2-git-send-email-tianyu.lan@intel.com> From: Alexander Duyck Message-ID: <5627D45A.4040502@gmail.com> Date: Wed, 21 Oct 2015 11:07:22 -0700 MIME-Version: 1.0 In-Reply-To: <1445445464-5056-2-git-send-email-tianyu.lan@intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC Patch 01/12] PCI: Add virtfn_index for struct pci_device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Lan Tianyu , bhelgaas@google.com, carolyn.wyborny@intel.com, donald.c.skidmore@intel.com, eddie.dong@intel.com, nrupal.jani@intel.com, yang.z.zhang@intel.com, agraf@suse.de, kvm@vger.kernel.org, pbonzini@redhat.com, qemu-devel@nongnu.org, emil.s.tantilov@intel.com, intel-wired-lan@lists.osuosl.org, jeffrey.t.kirsher@intel.com, jesse.brandeburg@intel.com, john.ronciak@intel.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, matthew.vick@intel.com, mitch.a.williams@intel.com, netdev@vger.kernel.org, shannon.nelson@intel.com On 10/21/2015 09:37 AM, Lan Tianyu wrote: > Add "virtfn_index" member in the struct pci_device to record VF sequence > of PF. This will be used in the VF sysfs node handle. > > Signed-off-by: Lan Tianyu > --- > drivers/pci/iov.c | 1 + > include/linux/pci.h | 1 + > 2 files changed, 2 insertions(+) > > diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c > index ee0ebff..065b6bb 100644 > --- a/drivers/pci/iov.c > +++ b/drivers/pci/iov.c > @@ -136,6 +136,7 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset) > virtfn->physfn = pci_dev_get(dev); > virtfn->is_virtfn = 1; > virtfn->multifunction = 0; > + virtfn->virtfn_index = id; > > for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) { > res = &dev->resource[i + PCI_IOV_RESOURCES]; > diff --git a/include/linux/pci.h b/include/linux/pci.h > index 353db8d..85c5531 100644 > --- a/include/linux/pci.h > +++ b/include/linux/pci.h > @@ -356,6 +356,7 @@ struct pci_dev { > unsigned int io_window_1k:1; /* Intel P2P bridge 1K I/O windows */ > unsigned int irq_managed:1; > pci_dev_flags_t dev_flags; > + unsigned int virtfn_index; > atomic_t enable_cnt; /* pci_enable_device has been called */ > > u32 saved_config_space[16]; /* config space saved at suspend time */ > Can't you just calculate the VF index based on the VF BDF number combined with the information in the PF BDF number and VF offset/stride? Seems kind of pointless to add a variable that is only used by one driver and is in a slowpath when you can just calculate it pretty quickly. - Alex