Skip to contentSkip to conversation

igbvf: add new driver to support 82576 virtual functions

DISCUSSION David Miller 4 participants 6 messages Mar 25, 2009

Subsystems (4)
lore
Share & tools
lore

David Miller

author maintainer
#0 lore raw

This breaks the build:

drivers/net/igbvf/ethtool.c: In function 'igbvf_set_ringparam':
drivers/net/igbvf/ethtool.c:299: error: implicit declaration of function 'vmalloc' drivers/net/igbvf/ethtool.c:299: warning: assignment makes pointer from integer without a cast drivers/net/igbvf/ethtool.c:346: error: implicit declaration of function 'vfree'

#1 lore raw
Quoted 8 lines · David Miller

This breaks the build:

drivers/net/igbvf/ethtool.c: In function 'igbvf_set_ringparam':
drivers/net/igbvf/ethtool.c:299: error: implicit declaration of function 'vmalloc' drivers/net/igbvf/ethtool.c:299: warning: assignment makes pointer from integer without a cast drivers/net/igbvf/ethtool.c:346: error: implicit declaration of function 'vfree' --

Sorry Dave, I thought this was called out earlier, but I see it was not. The igbvf driver requires the following patches applied to your tree to have them compile. Last I heard, these SR-IOV patches were accepted for 2.6.30, in the PCI tree.

Yu, can you confirm that these patches have been accepted for 2.6.30?

Summary:
http://marc.info/?l=linux-kernel&m=123751955907397&w=2
Patches:
http://marc.info/?l=linux-kernel&m=123751956107417&w=2
http://marc.info/?l=linux-kernel&m=123751956207423&w=2
http://marc.info/?l=linux-kernel&m=123751981407629&w=2
http://marc.info/?l=linux-kernel&m=123751981507632&w=2
http://marc.info/?l=linux-kernel&m=123751981707644&w=2
http://marc.info/?l=linux-kernel&m=123751981607635&w=2
http://marc.info/?l=linux-kernel&m=123751981607638&w=2
http://marc.info/?l=linux-kernel&m=123751981707641&w=2

Signature · 2 lines
Cheers,
Jeff

From f477163648953229f477ed14c5bfe8b90602ec1a Mon Sep 17 00:00:00 2001

From: Yu Zhao <[email protected]>

Subject: [PATCH] PCI: save and restore PCIe 2.0 registers

---

 drivers/pci/pci.c        |   11 ++++++++++-
 include/linux/pci_regs.h |    2 ++
 2 files changed, 12 insertions(+), 1 deletions(-)
drivers/pci/pci.c +10 -1
index 8e21912..d849668 100644
@@ -645,6 +645,8 @@ pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state)
 
 EXPORT_SYMBOL(pci_choose_state);
 
+#define PCI_EXP_SAVE_REGS	7
+
 static int pci_save_pcie_state(struct pci_dev *dev)
 {
 	int pos, i = 0;
@@ -666,6 +668,9 @@ static int pci_save_pcie_state(struct pci_dev *dev)
 	pci_read_config_word(dev, pos + PCI_EXP_LNKCTL, &cap[i++]);
 	pci_read_config_word(dev, pos + PCI_EXP_SLTCTL, &cap[i++]);
 	pci_read_config_word(dev, pos + PCI_EXP_RTCTL, &cap[i++]);
+	pci_read_config_word(dev, pos + PCI_EXP_DEVCTL2, &cap[i++]);
+	pci_read_config_word(dev, pos + PCI_EXP_LNKCTL2, &cap[i++]);
+	pci_read_config_word(dev, pos + PCI_EXP_SLTCTL2, &cap[i++]);
 
 	return 0;
 }
@@ -686,6 +691,9 @@ static void pci_restore_pcie_state(struct pci_dev *dev)
 	pci_write_config_word(dev, pos + PCI_EXP_LNKCTL, cap[i++]);
 	pci_write_config_word(dev, pos + PCI_EXP_SLTCTL, cap[i++]);
 	pci_write_config_word(dev, pos + PCI_EXP_RTCTL, cap[i++]);
+	pci_write_config_word(dev, pos + PCI_EXP_DEVCTL2, cap[i++]);
+	pci_write_config_word(dev, pos + PCI_EXP_LNKCTL2, cap[i++]);
+	pci_write_config_word(dev, pos + PCI_EXP_SLTCTL2, cap[i++]);
 }
 
 
@@ -1370,7 +1378,8 @@ void pci_allocate_cap_save_buffers(struct pci_dev *dev)
 {
 	int error;
 
-	error = pci_add_cap_save_buffer(dev, PCI_CAP_ID_EXP, 4 * sizeof(u16));
+	error = pci_add_cap_save_buffer(dev, PCI_CAP_ID_EXP,
+					PCI_EXP_SAVE_REGS * sizeof(u16));
 	if (error)
 		dev_err(&dev->dev,
 			"unable to preallocate PCI Express save buffer\n");
include/linux/pci_regs.h +2 -0
index 4ce5eb0..196e202 100644
@@ -488,6 +488,8 @@
 #define  PCI_EXP_DEVCAP2_ARI	0x20	/* Alternative Routing-ID */
 #define PCI_EXP_DEVCTL2		40	/* Device Control 2 */
 #define  PCI_EXP_DEVCTL2_ARI	0x20	/* Alternative Routing-ID */
+#define PCI_EXP_LNKCTL2		48	/* Link Control 2 */
+#define PCI_EXP_SLTCTL2		56	/* Slot Control 2 */
 
 /* Extended Capabilities (PCI-X 2.0 and Express) */
 #define PCI_EXT_CAP_ID(header)		(header & 0x0000ffff)

From aca164666d7d1acdc93438d2289e59df7b49f41d Mon Sep 17 00:00:00 2001

From: Yu Zhao <[email protected]>

Subject: [PATCH v10 1/7] PCI: initialize and release SR-IOV capability

---

 drivers/pci/Kconfig      |   13 +++
 drivers/pci/Makefile     |    3 +
 drivers/pci/iov.c        |  181 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/pci/pci.c        |    7 ++
 drivers/pci/pci.h        |   37 +++++++++
 drivers/pci/probe.c      |    4 +
 include/linux/pci.h      |    8 ++
 include/linux/pci_regs.h |   33 ++++++++
 8 files changed, 286 insertions(+), 0 deletions(-)
 create mode 100644 drivers/pci/iov.c
drivers/pci/Kconfig +13 -0
index 2a4501d..e8ea3e8 100644
@@ -59,3 +59,16 @@ config HT_IRQ
 	   This allows native hypertransport devices to use interrupts.
 
 	   If unsure say Y.
+
+config PCI_IOV
+	bool "PCI IOV support"
+	depends on PCI
+	select PCI_MSI
+	default n
+	help
+	  PCI-SIG I/O Virtualization (IOV) Specifications support.
+	  Single Root IOV: allows the Physical Function driver to enable
+	  the hardware capability, so the Virtual Function is accessible
+	  via the PCI Configuration Space using its own Bus, Device and
+	  Function Numbers. Each Virtual Function also has the PCI Memory
+	  Space to map the device specific register set.
drivers/pci/Makefile +3 -0
index 3d07ce2..ba99282 100644
@@ -29,6 +29,9 @@ obj-$(CONFIG_DMAR) += dmar.o iova.o intel-iommu.o
 
 obj-$(CONFIG_INTR_REMAP) += dmar.o intr_remapping.o
 
+# PCI IOV support
+obj-$(CONFIG_PCI_IOV) += iov.o
+
 #
 # Some architectures use the generic PCI setup functions
 #
drivers/pci/iov.c new file +181 -0

181 lines not on this page · raw message

drivers/pci/pci.c +7 -0
index 6d61200..2eba2a5 100644
@@ -2346,12 +2346,19 @@ int pci_select_bars(struct pci_dev *dev, unsigned long flags)
  */
 int pci_resource_bar(struct pci_dev *dev, int resno, enum pci_bar_type *type)
 {
+	int reg;
+
 	if (resno < PCI_ROM_RESOURCE) {
 		*type = pci_bar_unknown;
 		return PCI_BASE_ADDRESS_0 + 4 * resno;
 	} else if (resno == PCI_ROM_RESOURCE) {
 		*type = pci_bar_mem32;
 		return dev->rom_base_reg;
+	} else if (resno < PCI_BRIDGE_RESOURCES) {
+		/* device specific resource */
+		reg = pci_iov_resource_bar(dev, resno, type);
+		if (reg)
+			return reg;
 	}
 
 	dev_err(&dev->dev, "BAR: invalid resource #%d\n", resno);
drivers/pci/pci.h +37 -0
index 07c0aa5..451db74 100644
@@ -195,4 +195,41 @@ static inline int pci_ari_enabled(struct pci_bus *bus)
 	return bus->self && bus->self->ari_enabled;
 }
 
+/* Single Root I/O Virtualization */
+struct pci_sriov {
+	int pos;		/* capability position */
+	int nres;		/* number of resources */
+	u32 cap;		/* SR-IOV Capabilities */
+	u16 ctrl;		/* SR-IOV Control */
+	u16 total;		/* total VFs associated with the PF */
+	u16 offset;		/* first VF Routing ID offset */
+	u16 stride;		/* following VF stride */
+	u32 pgsz;		/* page size for BAR alignment */
+	u8 link;		/* Function Dependency Link */
+	struct pci_dev *pdev;	/* lowest numbered PF */
+	struct pci_dev *self;	/* this PF */
+	struct mutex lock;	/* lock for VF bus */
+};
+
+#ifdef CONFIG_PCI_IOV
+extern int pci_iov_init(struct pci_dev *dev);
+extern void pci_iov_release(struct pci_dev *dev);
+extern int pci_iov_resource_bar(struct pci_dev *dev, int resno,
+				enum pci_bar_type *type);
+#else
+static inline int pci_iov_init(struct pci_dev *dev)
+{
+	return -ENODEV;
+}
+static inline void pci_iov_release(struct pci_dev *dev)
+
+{
+}
+static inline int pci_iov_resource_bar(struct pci_dev *dev, int resno,
+				       enum pci_bar_type *type)
+{
+	return 0;
+}
+#endif /* CONFIG_PCI_IOV */
+
 #endif /* DRIVERS_PCI_H */
drivers/pci/probe.c +4 -0
index 55ec44a..03b6f29 100644
@@ -785,6 +785,7 @@ static int pci_setup_device(struct pci_dev * dev)
 static void pci_release_capabilities(struct pci_dev *dev)
 {
 	pci_vpd_release(dev);
+	pci_iov_release(dev);
 }
 
 /**
@@ -972,6 +973,9 @@ static void pci_init_capabilities(struct pci_dev *dev)
 
 	/* Alternative Routing-ID Forwarding */
 	pci_enable_ari(dev);
+
+	/* Single Root I/O Virtualization */
+	pci_iov_init(dev);
 }
 
 void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
include/linux/pci.h +8 -0
index 7bd624b..f4d740e 100644
@@ -93,6 +93,12 @@ enum {
 	/* #6: expansion ROM resource */
 	PCI_ROM_RESOURCE,
 
+	/* device specific resources */
+#ifdef CONFIG_PCI_IOV
+	PCI_SRIOV_RESOURCES,
+	PCI_SRIOV_RESOURCE_END = PCI_SRIOV_RESOURCES + PCI_SRIOV_NUM_BARS - 1,
+#endif
+
 	/* resources assigned to buses behind the bridge */
 #define PCI_BRIDGE_RESOURCE_NUM 4
 
@@ -180,6 +186,7 @@ struct pci_cap_saved_state {
 
 struct pcie_link_state;
 struct pci_vpd;
+struct pci_sriov;
 
 /*
  * The pci_dev structure is used to describe PCI devices.
@@ -270,6 +277,7 @@ struct pci_dev {
 	struct list_head msi_list;
 #endif
 	struct pci_vpd *vpd;
+	struct pci_sriov *sriov;	/* SR-IOV capability related */
 };
 
 extern struct pci_dev *alloc_pci_dev(void);
include/linux/pci_regs.h +33 -0
index 027815b..4ce5eb0 100644
@@ -375,6 +375,7 @@
 #define  PCI_EXP_TYPE_UPSTREAM	0x5	/* Upstream Port */
 #define  PCI_EXP_TYPE_DOWNSTREAM 0x6	/* Downstream Port */
 #define  PCI_EXP_TYPE_PCI_BRIDGE 0x7	/* PCI/PCI-X Bridge */
+#define  PCI_EXP_TYPE_RC_END	0x9	/* Root Complex Integrated Endpoint */
 #define PCI_EXP_FLAGS_SLOT	0x0100	/* Slot implemented */
 #define PCI_EXP_FLAGS_IRQ	0x3e00	/* Interrupt message number */
 #define PCI_EXP_DEVCAP		4	/* Device capabilities */
@@ -498,6 +499,7 @@
 #define PCI_EXT_CAP_ID_DSN	3
 #define PCI_EXT_CAP_ID_PWR	4
 #define PCI_EXT_CAP_ID_ARI	14
+#define PCI_EXT_CAP_ID_SRIOV	16
 
 /* Advanced Error Reporting */
 #define PCI_ERR_UNCOR_STATUS	4	/* Uncorrectable Error Status */
@@ -615,4 +617,35 @@
 #define  PCI_ARI_CTRL_ACS	0x0002	/* ACS Function Groups Enable */
 #define  PCI_ARI_CTRL_FG(x)	(((x) >> 4) & 7) /* Function Group */
 
+/* Single Root I/O Virtualization */
+#define PCI_SRIOV_CAP		0x04	/* SR-IOV Capabilities */
+#define  PCI_SRIOV_CAP_VFM	0x01	/* VF Migration Capable */
+#define  PCI_SRIOV_CAP_INTR(x)	((x) >> 21) /* Interrupt Message Number */
+#define PCI_SRIOV_CTRL		0x08	/* SR-IOV Control */
+#define  PCI_SRIOV_CTRL_VFE	0x01	/* VF Enable */
+#define  PCI_SRIOV_CTRL_VFM	0x02	/* VF Migration Enable */
+#define  PCI_SRIOV_CTRL_INTR	0x04	/* VF Migration Interrupt Enable */
+#define  PCI_SRIOV_CTRL_MSE	0x08	/* VF Memory Space Enable */
+#define  PCI_SRIOV_CTRL_ARI	0x10	/* ARI Capable Hierarchy */
+#define PCI_SRIOV_STATUS	0x0a	/* SR-IOV Status */
+#define  PCI_SRIOV_STATUS_VFM	0x01	/* VF Migration Status */
+#define PCI_SRIOV_INITIAL_VF	0x0c	/* Initial VFs */
+#define PCI_SRIOV_TOTAL_VF	0x0e	/* Total VFs */
+#define PCI_SRIOV_NUM_VF	0x10	/* Number of VFs */
+#define PCI_SRIOV_FUNC_LINK	0x12	/* Function Dependency Link */
+#define PCI_SRIOV_VF_OFFSET	0x14	/* First VF Offset */
+#define PCI_SRIOV_VF_STRIDE	0x16	/* Following VF Stride */
+#define PCI_SRIOV_VF_DID	0x1a	/* VF Device ID */
+#define PCI_SRIOV_SUP_PGSIZE	0x1c	/* Supported Page Sizes */
+#define PCI_SRIOV_SYS_PGSIZE	0x20	/* System Page Size */
+#define PCI_SRIOV_BAR		0x24	/* VF BAR0 */
+#define  PCI_SRIOV_NUM_BARS	6	/* Number of VF BARs */
+#define PCI_SRIOV_VFM		0x3c	/* VF Migration State Array Offset*/
+#define  PCI_SRIOV_VFM_BIR(x)	((x) & 7)	/* State BIR */
+#define  PCI_SRIOV_VFM_OFFSET(x) ((x) & ~7)	/* State Offset */
+#define  PCI_SRIOV_VFM_UA	0x0	/* Inactive.Unavailable */
+#define  PCI_SRIOV_VFM_MI	0x1	/* Dormant.MigrateIn */
+#define  PCI_SRIOV_VFM_MO	0x2	/* Active.MigrateOut */
+#define  PCI_SRIOV_VFM_AV	0x3	/* Active.Available */
+
 #endif /* LINUX_PCI_REGS_H */

From eb89221b31c2812626f505bdde4f19116c5a8773 Mon Sep 17 00:00:00 2001

From: Yu Zhao <[email protected]>

Subject: [PATCH v10 2/7] PCI: restore saved SR-IOV state

---

 drivers/pci/iov.c |   29 +++++++++++++++++++++++++++++
 drivers/pci/pci.c |    1 +
 drivers/pci/pci.h |    4 ++++
 3 files changed, 34 insertions(+), 0 deletions(-)
drivers/pci/iov.c +29 -0
index e6736d4..3bca8f8 100644
@@ -128,6 +128,25 @@ static void sriov_release(struct pci_dev *dev)
 	dev->sriov = NULL;
 }
 
+static void sriov_restore_state(struct pci_dev *dev)
+{
+	int i;
+	u16 ctrl;
+	struct pci_sriov *iov = dev->sriov;
+
+	pci_read_config_word(dev, iov->pos + PCI_SRIOV_CTRL, &ctrl);
+	if (ctrl & PCI_SRIOV_CTRL_VFE)
+		return;
+
+	for (i = PCI_SRIOV_RESOURCES; i <= PCI_SRIOV_RESOURCE_END; i++)
+		pci_update_resource(dev, i);
+
+	pci_write_config_dword(dev, iov->pos + PCI_SRIOV_SYS_PGSIZE, iov->pgsz);
+	pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl);
+	if (iov->ctrl & PCI_SRIOV_CTRL_VFE)
+		msleep(100);
+}
+
 /**
  * pci_iov_init - initialize the IOV capability
  * @dev: the PCI device
@@ -179,3 +198,13 @@ int pci_iov_resource_bar(struct pci_dev *dev, int resno,
 	return dev->sriov->pos + PCI_SRIOV_BAR +
 		4 * (resno - PCI_SRIOV_RESOURCES);
 }
+
+/**
+ * pci_restore_iov_state - restore the state of the IOV capability
+ * @dev: the PCI device
+ */
+void pci_restore_iov_state(struct pci_dev *dev)
+{
+	if (dev->sriov)
+		sriov_restore_state(dev);
+}
drivers/pci/pci.c +1 -0
index 2eba2a5..8e21912 100644
@@ -773,6 +773,7 @@ pci_restore_state(struct pci_dev *dev)
 	}
 	pci_restore_pcix_state(dev);
 	pci_restore_msi_state(dev);
+	pci_restore_iov_state(dev);
 
 	return 0;
 }
drivers/pci/pci.h +4 -0
index 451db74..b24c9e2 100644
@@ -216,6 +216,7 @@ extern int pci_iov_init(struct pci_dev *dev);
 extern void pci_iov_release(struct pci_dev *dev);
 extern int pci_iov_resource_bar(struct pci_dev *dev, int resno,
 				enum pci_bar_type *type);
+extern void pci_restore_iov_state(struct pci_dev *dev);
 #else
 static inline int pci_iov_init(struct pci_dev *dev)
 {
@@ -230,6 +231,9 @@ static inline int pci_iov_resource_bar(struct pci_dev *dev, int resno,
 {
 	return 0;
 }
+static inline void pci_restore_iov_state(struct pci_dev *dev)
+{
+}
 #endif /* CONFIG_PCI_IOV */
 
 #endif /* DRIVERS_PCI_H */

From 2bb6c4c8e0f4b6603b3415c95c1ed37d58bdcfc5 Mon Sep 17 00:00:00 2001

From: Yu Zhao <[email protected]>

Subject: [PATCH v10 3/7] PCI: reserve bus range for SR-IOV device

---

 drivers/pci/iov.c   |   34 ++++++++++++++++++++++++++++++++++
 drivers/pci/pci.h   |    5 +++++
 drivers/pci/probe.c |    3 +++
 3 files changed, 42 insertions(+), 0 deletions(-)
drivers/pci/iov.c +34 -0
index 3bca8f8..0b80437 100644
@@ -14,6 +14,16 @@
 #include "pci.h"
 
 
+static inline void virtfn_bdf(struct pci_dev *dev, int id, u8 *busnr, u8 *devfn)
+{
+	u16 bdf;
+
+	bdf = (dev->bus->number << 8) + dev->devfn +
+	      dev->sriov->offset + dev->sriov->stride * id;
+	*busnr = bdf >> 8;
+	*devfn = bdf & 0xff;
+}
+
 static int sriov_init(struct pci_dev *dev, int pos)
 {
 	int i;
@@ -208,3 +218,27 @@ void pci_restore_iov_state(struct pci_dev *dev)
 	if (dev->sriov)
 		sriov_restore_state(dev);
 }
+
+/**
+ * pci_iov_bus_range - find bus range used by Virtual Function
+ * @bus: the PCI bus
+ *
+ * Returns max number of buses (exclude current one) used by Virtual
+ * Functions.
+ */
+int pci_iov_bus_range(struct pci_bus *bus)
+{
+	int max = 0;
+	u8 busnr, devfn;
+	struct pci_dev *dev;
+
+	list_for_each_entry(dev, &bus->devices, bus_list) {
+		if (!dev->sriov)
+			continue;
+		virtfn_bdf(dev, dev->sriov->total - 1, &busnr, &devfn);
+		if (busnr > max)
+			max = busnr;
+	}
+
+	return max ? max - bus->number : 0;
+}
drivers/pci/pci.h +5 -0
index b24c9e2..2cf32f5 100644
@@ -217,6 +217,7 @@ extern void pci_iov_release(struct pci_dev *dev);
 extern int pci_iov_resource_bar(struct pci_dev *dev, int resno,
 				enum pci_bar_type *type);
 extern void pci_restore_iov_state(struct pci_dev *dev);
+extern int pci_iov_bus_range(struct pci_bus *bus);
 #else
 static inline int pci_iov_init(struct pci_dev *dev)
 {
@@ -234,6 +235,10 @@ static inline int pci_iov_resource_bar(struct pci_dev *dev, int resno,
 static inline void pci_restore_iov_state(struct pci_dev *dev)
 {
 }
+static inline int pci_iov_bus_range(struct pci_bus *bus)
+{
+	return 0;
+}
 #endif /* CONFIG_PCI_IOV */
 
 #endif /* DRIVERS_PCI_H */
drivers/pci/probe.c +3 -0
index 03b6f29..4c8abd0 100644
@@ -1078,6 +1078,9 @@ unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus)
 	for (devfn = 0; devfn < 0x100; devfn += 8)
 		pci_scan_slot(bus, devfn);
 
+	/* Reserve buses for SR-IOV capability. */
+	max += pci_iov_bus_range(bus);
+
 	/*
 	 * After performing arch-dependent fixup of the bus, look behind
 	 * all PCI-to-PCI bridges on this bus.

From 44373ec4e7aa847e1a605b68fda3267a953691df Mon Sep 17 00:00:00 2001

From: Yu Zhao <[email protected]>

Subject: [PATCH v10 4/7] PCI: add SR-IOV API for Physical Function driver

---

 drivers/pci/iov.c   |  348 +++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/pci/pci.h   |    3 
 include/linux/pci.h |   14 ++
 3 files changed, 365 insertions(+), 0 deletions(-)
drivers/pci/iov.c +348 -0

375 lines not on this page · raw message

drivers/pci/pci.h +3 -0
index 2cf32f5..9bbf868 100644
@@ -202,6 +202,8 @@ struct pci_sriov {
 	u32 cap;		/* SR-IOV Capabilities */
 	u16 ctrl;		/* SR-IOV Control */
 	u16 total;		/* total VFs associated with the PF */
+	u16 initial;		/* initial VFs associated with the PF */
+	u16 nr_virtfn;		/* number of VFs available */
 	u16 offset;		/* first VF Routing ID offset */
 	u16 stride;		/* following VF stride */
 	u32 pgsz;		/* page size for BAR alignment */
@@ -209,6 +211,7 @@ struct pci_sriov {
 	struct pci_dev *pdev;	/* lowest numbered PF */
 	struct pci_dev *self;	/* this PF */
 	struct mutex lock;	/* lock for VF bus */
+	struct device dev;
 };
 
 #ifdef CONFIG_PCI_IOV
include/linux/pci.h +14 -0
index f4d740e..3a24ff5 100644
@@ -278,6 +278,7 @@ struct pci_dev {
 #endif
 	struct pci_vpd *vpd;
 	struct pci_sriov *sriov;	/* SR-IOV capability related */
+	struct pci_dev *physfn;	/* Physical Function the device belongs to */
 };
 
 extern struct pci_dev *alloc_pci_dev(void);
@@ -1202,5 +1203,18 @@ int pci_ext_cfg_avail(struct pci_dev *dev);
 
 void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar);
 
+#ifdef CONFIG_PCI_IOV
+extern int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn);
+extern void pci_disable_sriov(struct pci_dev *dev);
+#else
+static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn)
+{
+	return -ENODEV;
+}
+static inline void pci_disable_sriov(struct pci_dev *dev)
+{
+}
+#endif
+
 #endif /* __KERNEL__ */
 #endif /* LINUX_PCI_H */

From f5a91ff00d6fe96733f07d40d139ab2e581056c6 Mon Sep 17 00:00:00 2001

From: Yu Zhao <[email protected]>

Subject: [PATCH v10 5/7] PCI: handle SR-IOV Virtual Function Migration

---

 drivers/pci/iov.c   |  119 +++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/pci/pci.h   |    4 ++
 include/linux/pci.h |    6 +++
 3 files changed, 129 insertions(+), 0 deletions(-)
drivers/pci/iov.c +119 -0

140 lines not on this page · raw message

drivers/pci/pci.h +4 -0
index 9bbf868..6764f02 100644
@@ -1,6 +1,8 @@
 #ifndef DRIVERS_PCI_H
 #define DRIVERS_PCI_H
 
+#include <linux/workqueue.h>
+
 #define PCI_CFG_SPACE_SIZE	256
 #define PCI_CFG_SPACE_EXP_SIZE	4096
 
@@ -211,6 +213,8 @@ struct pci_sriov {
 	struct pci_dev *pdev;	/* lowest numbered PF */
 	struct pci_dev *self;	/* this PF */
 	struct mutex lock;	/* lock for VF bus */
+	struct work_struct mtask; /* VF Migration task */
+	u8 __iomem *mstate;	/* VF Migration State Array */
 	struct device dev;
 };
 
include/linux/pci.h +6 -0
index 3a24ff5..d16b913 100644
@@ -52,6 +52,7 @@
 #include <asm/atomic.h>
 #include <linux/device.h>
 #include <linux/io.h>
+#include <linux/irqreturn.h>
 
 /* Include the ID list */
 #include <linux/pci_ids.h>
@@ -1206,6 +1207,7 @@ void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar);
 #ifdef CONFIG_PCI_IOV
 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);
 #else
 static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn)
 {
@@ -1214,6 +1216,10 @@ static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn)
 static inline void pci_disable_sriov(struct pci_dev *dev)
 {
 }
+static inline irqreturn_t pci_sriov_migration(struct pci_dev *dev)
+{
+	return IRQ_NONE;
+}
 #endif
 
 #endif /* __KERNEL__ */

From 0357beb9d669f4a7d88e95d66714cd48fb5b0693 Mon Sep 17 00:00:00 2001

From: Yu Zhao <[email protected]>

Subject: [PATCH v10 6/7] PCI: document SR-IOV sysfs entries

---

 Documentation/ABI/testing/sysfs-bus-pci |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)
Documentation/ABI/testing/sysfs-bus-pci +27 -0
index e638e15..a0a052c 100644
@@ -52,3 +52,30 @@ Description:
 		that some devices may have malformatted data.  If the
 		underlying VPD has a writable section then the
 		corresponding section of this file will be writable.
+
+What:		/sys/bus/pci/devices/.../virtfn/N
+Date:		February 2009
+Contact:	Yu Zhao <[email protected]>
+Description:
+		This symbol link appears when hardware supports SR-IOV
+		capability and Physical Function driver has enabled it.
+		The symbol link points to the PCI device sysfs entry of
+		Virtual Function whose index is N (0...MaxVFs-1).
+
+What:		/sys/bus/pci/devices/.../virtfn/dep_link
+Date:		February 2009
+Contact:	Yu Zhao <[email protected]>
+Description:
+		This symbol link appears when hardware supports SR-IOV
+		capability and Physical Function driver has enabled it,
+		and this device has vendor specific dependencies with
+		others. The symbol link points to the PCI device sysfs
+		entry of Physical Function this device depends on.
+
+What:		/sys/bus/pci/devices/.../physfn
+Date:		February 2009
+Contact:	Yu Zhao <[email protected]>
+Description:
+		This symbol link appears when a device is Virtual Function.
+		The symbol link points to the PCI device sysfs entry of
+		Physical Function this device associates with.

From 4f465dcb76e2c125357f2524cf62bf50a7546ce3 Mon Sep 17 00:00:00 2001

From: Yu Zhao <[email protected]>

Subject: [PATCH v10 7/7] PCI: manual for SR-IOV user and driver developer

---

 Documentation/DocBook/kernel-api.tmpl |    1 
 Documentation/PCI/pci-iov-howto.txt   |   99 +++++++++++++++++++++++++++++++++
 2 files changed, 100 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/PCI/pci-iov-howto.txt
Documentation/DocBook/kernel-api.tmpl +1 -0
index bc962cd..58c1945 100644
@@ -199,6 +199,7 @@ X!Edrivers/pci/hotplug.c
 -->
 !Edrivers/pci/probe.c
 !Edrivers/pci/rom.c
+!Edrivers/pci/iov.c
      </sect1>
      <sect1><title>PCI Hotplug Support Library</title>
 !Edrivers/pci/hotplug/pci_hotplug_core.c
Documentation/PCI/pci-iov-howto.txt new file +99 -0

99 lines not on this page · raw message

#2 lore raw
Quoted 17 lines · Jeff Kirsher
Quoted 8 lines · David Miller

This breaks the build:

drivers/net/igbvf/ethtool.c: In function 'igbvf_set_ringparam':
drivers/net/igbvf/ethtool.c:299: error: implicit declaration of function 'vmalloc' drivers/net/igbvf/ethtool.c:299: warning: assignment makes pointer from integer without a cast drivers/net/igbvf/ethtool.c:346: error: implicit declaration of function 'vfree' --

Sorry Dave, I thought this was called out earlier, but I see it was not.  The igbvf driver requires the following patches applied to your tree to have them compile.  Last I heard, these SR-IOV patches were accepted for 2.6.30, in the PCI tree.

Yu, can you confirm that these patches have been accepted for 2.6.30?

Quoted 11 lines

Summary:
http://marc.info/?l=linux-kernel&m=123751955907397&w=2
Patches:
http://marc.info/?l=linux-kernel&m=123751956107417&w=2
http://marc.info/?l=linux-kernel&m=123751956207423&w=2
http://marc.info/?l=linux-kernel&m=123751981407629&w=2
http://marc.info/?l=linux-kernel&m=123751981507632&w=2
http://marc.info/?l=linux-kernel&m=123751981707644&w=2
http://marc.info/?l=linux-kernel&m=123751981607635&w=2
http://marc.info/?l=linux-kernel&m=123751981607638&w=2
http://marc.info/?l=linux-kernel&m=123751981707641&w=2

I confirmed that Jesse Barnes has these SR-IOV patches queued up for 2.6.30.
http://marc.info/?l=linux-kernel&m=123757169806111&w=2

Signature · 2 lines
Cheers,
Jeff
#3 lore raw
Quoted 31 lines · Jeffrey T
Quoted 17 lines · Jeff Kirsher
Quoted 8 lines · David Miller

This breaks the build:

drivers/net/igbvf/ethtool.c: In function 'igbvf_set_ringparam':
drivers/net/igbvf/ethtool.c:299: error: implicit declaration of function 'vmalloc' drivers/net/igbvf/ethtool.c:299: warning: assignment makes pointer from integer without a cast drivers/net/igbvf/ethtool.c:346: error: implicit declaration of function 'vfree' --

Sorry Dave, I thought this was called out earlier, but I see it was not.  The igbvf driver requires the following patches applied to your tree to have them compile.  Last I heard, these SR-IOV patches were accepted for 2.6.30, in the PCI tree.

Yu, can you confirm that these patches have been accepted for 2.6.30?

Quoted 11 lines

Summary:
http://marc.info/?l=linux-kernel&m=123751955907397&w=2
Patches:
http://marc.info/?l=linux-kernel&m=123751956107417&w=2
http://marc.info/?l=linux-kernel&m=123751956207423&w=2
http://marc.info/?l=linux-kernel&m=123751981407629&w=2
http://marc.info/?l=linux-kernel&m=123751981507632&w=2
http://marc.info/?l=linux-kernel&m=123751981707644&w=2
http://marc.info/?l=linux-kernel&m=123751981607635&w=2
http://marc.info/?l=linux-kernel&m=123751981607638&w=2
http://marc.info/?l=linux-kernel&m=123751981707641&w=2

Quoted 2 lines

I confirmed that Jesse Barnes has these SR-IOV patches queued up for 2.6.30.
http://marc.info/?l=linux-kernel&m=123757169806111&w=2

Yes, it's in Jesse's linux-next branch:
http://git.kernel.org/?p=linux/kernel/git/jbarnes/pci-2.6.git;a=shortlog;h=linux-next

Thanks,
Yu

#4 lore raw
Quoted 29 lines · Yu
Quoted 28 lines · Jeffrey T
Quoted 26 lines · Jeff Kirsher
Quoted 7 lines · David Miller

This breaks the build:

drivers/net/igbvf/ethtool.c: In function 'igbvf_set_ringparam':
drivers/net/igbvf/ethtool.c:299: error: implicit declaration of function 'vmalloc' drivers/net/igbvf/ethtool.c:299: warning: assignment makes pointer from integer without a cast drivers/net/igbvf/ethtool.c:346: error: implicit declaration of function 'vfree' --

Sorry Dave, I thought this was called out earlier, but I see it was not. The igbvf driver requires the following patches applied to your tree to have them compile. Last I heard, these SR-IOV patches were accepted for 2.6.30, in the PCI tree.

Yu, can you confirm that these patches have been accepted for 2.6.30?

Summary:
http://marc.info/?l=linux-kernel&m=123751955907397&w=2
Patches:
http://marc.info/?l=linux-kernel&m=123751956107417&w=2
http://marc.info/?l=linux-kernel&m=123751956207423&w=2
http://marc.info/?l=linux-kernel&m=123751981407629&w=2
http://marc.info/?l=linux-kernel&m=123751981507632&w=2
http://marc.info/?l=linux-kernel&m=123751981707644&w=2
http://marc.info/?l=linux-kernel&m=123751981607635&w=2
http://marc.info/?l=linux-kernel&m=123751981607638&w=2
http://marc.info/?l=linux-kernel&m=123751981707641&w=2

Quoted 8 lines
Quoted 2 lines

I confirmed that Jesse Barnes has these SR-IOV patches queued up for 2.6.30.
http://marc.info/?l=linux-kernel&m=123757169806111&w=2

Yes, it's in Jesse's linux-next branch:
http://git.kernel.org/?p=linux/kernel/git/jbarnes/pci-2.6.git;a=shortlog;h=linux-next

Thanks,
Yu

The problem isn't the SR-IOV patches it is a difference in architectures. The x86/x86_64 architecture lets you be a bit more sloppy when it comes to including vmalloc. I've seen it in the past with igb, and I suspect that is why we didn't catch this in testing. We just need to add a #include of vmalloc.h in ethtool.c and the issue should be fixed.

Thanks,

Alex

author maintainer
#5 lore raw

From: Alexander Duyck <[email protected]>
Date: Wed, 25 Mar 2009 09:10:48 -0700

Quoted 6 lines

The problem isn't the SR-IOV patches it is a difference in architectures. The x86/x86_64 architecture lets you be a bit more sloppy when it comes to including vmalloc. I've seen it in the past with igb, and I suspect that is why we didn't catch this in testing. We just need to add a #include of vmalloc.h in ethtool.c and the issue should be fixed.

Yes, that was the problem.

I thought it was dead obvious from the build failure message. What else could a lack of visible vmalloc() declaration mean? :-/