Skip to contentSkip to conversation

pv-ops: register xen pci notifier

PATCH Superseded Weidong Han 2 participants 3 messages Jul 29, 2009 – Jul 30, 2009 Xen hypervisor interface

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 pv-ops: register xen pci notifier

Register the notifier to handle hot-plug devices and SR-IOV devices for Xen hypervisor. When a device is hot added or removed, it adds or removes it to Xen via hypercalls.

Changes in v2:
Remove inline #ifdef and the awkward dangling else/#endif construction, and rather than using memset, use variable declaration and initializer to assign the elements in xen_add_device.

---
 drivers/xen/Makefile            |    5 +-
 drivers/xen/pci.c               |  118 +++++++++++++++++++++++++++++++++++++++
 include/xen/interface/physdev.h |   21 +++++++
 3 files changed, 142 insertions(+), 2 deletions(-)
 create mode 100644 drivers/xen/pci.c
drivers/xen/Makefile +3 -2
index 007aa99..fd5c88c 100644
@@ -1,12 +1,13 @@
 obj-y	+= grant-table.o features.o events.o manage.o biomerge.o
 obj-y	+= xenbus/
 
+obj-$(CONFIG_PCI)			+= pci.o
 obj-$(CONFIG_HOTPLUG_CPU)		+= cpu_hotplug.o
 obj-$(CONFIG_XEN_XENCOMM)		+= xencomm.o
 obj-$(CONFIG_XEN_BALLOON)		+= balloon.o
 obj-$(CONFIG_XEN_DEV_EVTCHN)		+= evtchn.o
-obj-$(CONFIG_XEN_GNTDEV)	+= gntdev.o
+obj-$(CONFIG_XEN_GNTDEV)		+= gntdev.o
 obj-$(CONFIG_XEN_BLKDEV_BACKEND)	+= blkback/
 obj-$(CONFIG_XEN_NETDEV_BACKEND)	+= netback/
 obj-$(CONFIG_XENFS)			+= xenfs/
-obj-$(CONFIG_XEN_SYS_HYPERVISOR)	+= sys-hypervisor.o
\ No newline at end of file
+obj-$(CONFIG_XEN_SYS_HYPERVISOR)	+= sys-hypervisor.o
drivers/xen/pci.c new file +118 -0

118 lines not on this page · raw message

include/xen/interface/physdev.h +21 -0
index cd69391..dcae970 100644
@@ -106,6 +106,27 @@ struct physdev_irq {
 	uint32_t vector;
 };
 
+#define PHYSDEVOP_manage_pci_add         15
+#define PHYSDEVOP_manage_pci_remove      16
+struct physdev_manage_pci {
+	/* IN */
+	uint8_t bus;
+	uint8_t devfn;
+};
+
+#define PHYSDEVOP_manage_pci_add_ext     20
+struct physdev_manage_pci_ext {
+	/* IN */
+	uint8_t bus;
+	uint8_t devfn;
+	unsigned is_extfn;
+	unsigned is_virtfn;
+	struct {
+		uint8_t bus;
+		uint8_t devfn;
+	} physfn;
+};
+
 /*
  * Argument to physdev_op_compat() hypercall. Superceded by new physdev_op()
  * hypercall since 0x00030202.
Signature · 1 line
1.6.0.4
#1 lore raw
Quoted 9 lines · Weidong Han

Register the notifier to handle hot-plug devices and SR-IOV devices for Xen hypervisor. When a device is hot added or removed, it adds or removes it to Xen via hypercalls.

Changes in v2:
Remove inline #ifdef and the awkward dangling else/#endif construction, and rather than using memset, use variable declaration and initializer to assign the elements in xen_add_device.

That looks much better. Just one tiny nit:

Quoted 12 lines
drivers/xen/pci.c new file +11 -0
+
+	if (HANDLE_PCI_IOV && pci_dev->is_virtfn) {
+		struct physdev_manage_pci_ext manage_pci_ext = {
+			.bus		= pci_dev->bus->number,
+			.devfn		= pci_dev->devfn,
+			.is_extfn	= 0,
+			.is_virtfn 	= 1,
+			.physfn.bus	= pci_dev->physfn->bus->number,
+			.physfn.devfn	= pci_dev->physfn->devfn,
+		};
+

drivers/xen/pci.c line 56

Quoted 10 lines
drivers/xen/pci.c new file +10 -0
+		r = HYPERVISOR_physdev_op(PHYSDEVOP_manage_pci_add_ext,
+			&manage_pci_ext);
+	} else if (pci_ari_enabled(pci_dev->bus) && PCI_SLOT(pci_dev->devfn)) {
+		struct physdev_manage_pci_ext manage_pci_ext = {
+			.bus		= pci_dev->bus->number,
+			.devfn		= pci_dev->devfn,
+			.is_extfn	= 1,
+			.is_virtfn 	= 0,
+			.physfn.bus	= 0,
+			.physfn.devfn	= 0,

It isn't necessarily to explicitly initialize elements to 0; that will happen implicitly as a result of using an initializer.

Thanks,
J

#2 lore raw
Quoted 29 lines · Jeremy Fitzhardinge
Quoted 9 lines · Weidong Han

Register the notifier to handle hot-plug devices and SR-IOV devices for Xen hypervisor. When a device is hot added or removed, it adds or removes it to Xen via hypercalls.

Changes in v2:
Remove inline #ifdef and the awkward dangling else/#endif construction, and rather than using memset, use variable declaration and initializer to assign the elements in xen_add_device.

That looks much better. Just one tiny nit:

Quoted 16 lines
drivers/xen/pci.c new file +13 -0
+
+	if (HANDLE_PCI_IOV && pci_dev->is_virtfn) {
+		struct physdev_manage_pci_ext manage_pci_ext = {
+			.bus		= pci_dev->bus->number,
+			.devfn		= pci_dev->devfn,
+			.is_extfn	= 0,
+			.is_virtfn 	= 1,
+			.physfn.bus	= pci_dev->physfn->bus->number,
+			.physfn.devfn	= pci_dev->physfn->devfn,
+		};
+
+		r = HYPERVISOR_physdev_op(PHYSDEVOP_manage_pci_add_ext,
+			&manage_pci_ext); +	} else if (pci_ari_enabled(pci_dev->bus) &&

PCI_SLOT(pci_dev->devfn)) { + struct physdev_manage_pci_ext
manage_pci_ext = { + .bus = pci_dev->bus->number,

(quoted diff) +1 -0
+			.devfn		= pci_dev->devfn,
Quoted 9 lines

drivers/xen/pci.c line 56

Quoted 5 lines
drivers/xen/pci.c new file +4 -0
+			.is_extfn	= 1,
+			.is_virtfn 	= 0,
+			.physfn.bus	= 0,
+			.physfn.devfn	= 0,

It isn't necessarily to explicitly initialize elements to 0; that will happen implicitly as a result of using an initializer.

Will remove the unnecessary initialization, and send out the updated patch soon. Thanks.

Regards,
Weidong