[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <AANLkTimTm57fvumRXo9pegOY2M78mduBsClwYlmAOzpo@mail.gmail.com>
Date: Tue, 1 Jun 2010 13:05:25 +0800
From: Frank Pan <frankpzh@...il.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
Jesse Barnes <jbarnes@...tuousgeek.org>,
Kenji Kaneshige <kaneshige.kenji@...fujitsu.com>,
Yu Zhao <yu.zhao@...el.com>,
Chris Wright <chrisw@...s-sol.org>,
Mitch Williams <mitch.a.williams@...el.com>,
"Rafael J. Wysocki" <rjw@...k.pl>,
"David S. Miller" <davem@...emloft.net>,
Matt Carlson <mcarlson@...adcom.com>
Cc: linux-pci@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Add a helper function in PCI IOV to get VF device
Greetings,
The motivation is make VF device visible to PF driver. PF driver
may need this to access VF's PCI configuration.
Another use case is in sysfs symbolic linking. Some of VF's sysfs
entries are created by PF driver. For example, /sys/class/net/ethx/vfx
in Intel 82576 NIC driver. Makeing a symbolic link from VF's pci device
to this path also must be done in PF's driver.
Currently, there is no hint about VF's bus/devfn in PF's pci_dev.
The offset and stride entries(which are used to calculate bus/devfn
of VF devices) in VF's PCI configuration is also invisible in PF's
driver. So IMO this helper function is needed.
Any reply is appreciated, THX.
(ps: gmail will do line wrap/tab replace, use attachment instead to patch)
--
Frank Pan
Computer Science and Technology
Tsinghua University
Signed-off-by: Frank Pan <frankpzh@...il.com>
---
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index ce6a366..f15aa2a 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -722,6 +722,18 @@ int pci_num_vf(struct pci_dev *dev)
}
EXPORT_SYMBOL_GPL(pci_num_vf);
+/**
+ * pci_get_vf_dev - return the PCI device of a specific VF
+ * @dev: the PCI device
+ */
+struct pci_dev *pci_get_vf_dev(struct pci_dev *dev, int id)
+{
+ return pci_get_bus_and_slot(
+ virtfn_bus(dev, id),
+ virtfn_devfn(dev, id));
+}
+EXPORT_SYMBOL_GPL(pci_get_vf_dev);
+
static int ats_alloc_one(struct pci_dev *dev, int ps)
{
int pos;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index a327322..fb6010b 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1374,6 +1374,7 @@ extern int pci_enable_sriov(struct pci_dev *dev,
int nr_virtfn);
extern void pci_disable_sriov(struct pci_dev *dev);
extern irqreturn_t pci_sriov_migration(struct pci_dev *dev);
extern int pci_num_vf(struct pci_dev *dev);
+extern struct pci_dev *pci_get_vf_dev(struct pci_dev *dev, int id);
#else
static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn)
{
@@ -1390,6 +1391,10 @@ static inline int pci_num_vf(struct pci_dev *dev)
{
return 0;
}
+static inline struct pci_dev *pci_get_vf_dev(struct pci_dev *dev, int id)
+{
+ return NULL;
+}
#endif
#if defined(CONFIG_HOTPLUG_PCI) || defined(CONFIG_HOTPLUG_PCI_MODULE)
Download attachment "iov.patch" of type "application/octet-stream" (1423 bytes)
Powered by blists - more mailing lists