Skip to contentSkip to conversation

Xen pciback for 2.6.40.

RFC PATCH New Konrad Rzeszutek Wilk 1 participant 2 messages Apr 18, 2011 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Xen pciback for 2.6.40.

This is an patch squashed in one for 2.6.40. This is an RFC patch.

The full tree is available at git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen.git
devel/xen-pciback-0.6

The driver is based of 2.6.18, upported to 2.6.32, and in 2.6.38 tree I took an axe and removed some of the code that is mostly IA64 specific. Also coalesced some of the configuration space code in one file.

Please take a look. I will soon have a nice description detailing what the driver does for folks not familiar with the Xen pci subsystem.

#1 lore raw

PATCH 1/1 xen-pciback: Initial copy of the xen-pciback driver.

This version of Xen-PCIBack is from
git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen.git devel/xen-pciback-0.6 all of the patches are squashed in one.

Xen PCI backend is backend driver that on behalf of the guest domain which has the Xen PCI frontend, allows the guest to:

- Read/write in the PCI configuration space.
- Setups a "fake" interrupt handler if the PCI device is shared on the interrupt line and has been passed to the guest.
- Takes care of passing in AER reporting to the guest.
- Sets up (and tears down) the MSI/MSI-X configuration.

The end result is that the guest has the interrupts (or vectors if MSI/MSI-X) routed directly to the guest. The backend deals with just setting up the PCI device so that it is initialized properly.

---
 drivers/xen/Kconfig                         |   44 +
 drivers/xen/Makefile                        |    1 +
 drivers/xen/pciback/Makefile                |   12 +
 drivers/xen/pciback/conf_space.c            |  437 +++++++++
 drivers/xen/pciback/conf_space.h            |  126 +++
 drivers/xen/pciback/conf_space_capability.c |  207 ++++
 drivers/xen/pciback/conf_space_header.c     |  385 ++++++++
 drivers/xen/pciback/conf_space_quirks.c     |  140 +++
 drivers/xen/pciback/conf_space_quirks.h     |   35 +
 drivers/xen/pciback/passthrough.c           |  178 ++++
 drivers/xen/pciback/pci_stub.c              | 1371 +++++++++++++++++++++++++++
 drivers/xen/pciback/pciback.h               |  128 +++
 drivers/xen/pciback/pciback_ops.c           |  375 ++++++++
 drivers/xen/pciback/vpci.c                  |  244 +++++
 drivers/xen/pciback/xenbus.c                |  726 ++++++++++++++
 15 files changed, 4409 insertions(+), 0 deletions(-)
 create mode 100644 drivers/xen/pciback/Makefile
 create mode 100644 drivers/xen/pciback/conf_space.c
 create mode 100644 drivers/xen/pciback/conf_space.h
 create mode 100644 drivers/xen/pciback/conf_space_capability.c
 create mode 100644 drivers/xen/pciback/conf_space_header.c
 create mode 100644 drivers/xen/pciback/conf_space_quirks.c
 create mode 100644 drivers/xen/pciback/conf_space_quirks.h
 create mode 100644 drivers/xen/pciback/passthrough.c
 create mode 100644 drivers/xen/pciback/pci_stub.c
 create mode 100644 drivers/xen/pciback/pciback.h
 create mode 100644 drivers/xen/pciback/pciback_ops.c
 create mode 100644 drivers/xen/pciback/vpci.c
 create mode 100644 drivers/xen/pciback/xenbus.c
drivers/xen/Kconfig +44 -0
index a59638b..a50fc77 100644
@@ -37,6 +37,50 @@ config XEN_BACKEND
 	  Support for backend device drivers that provide I/O services
 	  to other virtual machines.
 
+config XEN_PCIDEV_BACKEND
+	tristate "PCI-device backend driver"
+	depends on PCI
+	depends on XEN_BACKEND
+	help
+	  The PCI device backend driver allows the kernel to export arbitrary
+	  PCI devices to other guests. If you select this to be a module, you
+	  will need to make sure no other driver has bound to the device(s)
+	  you want to make visible to other guests.
+
+choice
+	prompt "PCI Backend Mode"
+	depends on XEN_PCIDEV_BACKEND
+
+config XEN_PCIDEV_BACKEND_VPCI
+	bool "Virtual PCI"
+	help
+	  This PCI Backend hides the true PCI topology and makes the frontend
+	  think there is a single PCI bus with only the exported devices on it.
+	  For example, a device at 03:05.0 will be re-assigned to 00:00.0. A
+	  second device at 02:1a.1 will be re-assigned to 00:01.1.
+
+config XEN_PCIDEV_BACKEND_PASS
+	bool "Passthrough"
+	help
+	  This PCI Backend provides a real view of the PCI topology to the
+	  frontend (for example, a device at 06:01.b will still appear at
+	  06:01.b to the frontend). This is similar to how Xen 2.0.x exposed
+	  PCI devices to its driver domains. This may be required for drivers
+	  which depend on finding their hardward in certain bus/slot
+	  locations.
+
+endchoice
+
+config XEN_PCIDEV_BE_DEBUG
+	bool "PCI Backend Debugging"
+	depends on XEN_PCIDEV_BACKEND
+	default n
+	help
+	  Allows to observe all of the traffic from the frontend/backend
+	  when reading and writting to the configuration registers.
+	  If in doubt, say no.
+
+
 config XENFS
 	tristate "Xen filesystem"
 	default y
drivers/xen/Makefile +1 -0
index f420f1f..0950596 100644
@@ -9,6 +9,7 @@ obj-$(CONFIG_HOTPLUG_CPU)	+= cpu_hotplug.o
 obj-$(CONFIG_XEN_XENCOMM)	+= xencomm.o
 obj-$(CONFIG_XEN_BALLOON)	+= xen-balloon.o
 obj-$(CONFIG_XEN_DEV_EVTCHN)	+= xen-evtchn.o
+obj-$(CONFIG_XEN_PCIDEV_BACKEND)	+= pciback/
 obj-$(CONFIG_XEN_GNTDEV)	+= xen-gntdev.o
 obj-$(CONFIG_XEN_GRANT_DEV_ALLOC)	+= xen-gntalloc.o
 obj-$(CONFIG_XENFS)		+= xenfs/
drivers/xen/pciback/Makefile new file +12 -0
new file mode 100644
index 0000000..e79c518
@@ -0,0 +1,12 @@
+obj-$(CONFIG_XEN_PCIDEV_BACKEND) += xen-pciback.o
+
+xen-pciback-y := pci_stub.o pciback_ops.o xenbus.o
+xen-pciback-y += conf_space.o conf_space_header.o \
+		 conf_space_capability.o \
+		 conf_space_quirks.o
+xen-pciback-$(CONFIG_XEN_PCIDEV_BACKEND_VPCI) += vpci.o
+xen-pciback-$(CONFIG_XEN_PCIDEV_BACKEND_PASS) += passthrough.o
+
+ifeq ($(CONFIG_XEN_PCIDEV_BE_DEBUG),y)
+EXTRA_CFLAGS += -DDEBUG
+endif
drivers/xen/pciback/conf_space.c new file +437 -0

437 lines not on this page · raw message

drivers/xen/pciback/conf_space.h new file +126 -0

126 lines not on this page · raw message

drivers/xen/pciback/conf_space_capability.c new file +207 -0

207 lines not on this page · raw message

drivers/xen/pciback/conf_space_header.c new file +385 -0

385 lines not on this page · raw message

drivers/xen/pciback/conf_space_quirks.c new file +140 -0

140 lines not on this page · raw message

drivers/xen/pciback/conf_space_quirks.h new file +35 -0
new file mode 100644
index 0000000..acd0e1a
@@ -0,0 +1,35 @@
+/*
+ * PCI Backend - Data structures for special overlays for broken devices.
+ *
+ * Ryan Wilson <[email protected]>
+ * Chris Bookholt <[email protected]>
+ */
+
+#ifndef __XEN_PCIBACK_CONF_SPACE_QUIRKS_H__
+#define __XEN_PCIBACK_CONF_SPACE_QUIRKS_H__
+
+#include <linux/pci.h>
+#include <linux/list.h>
+
+struct pciback_config_quirk {
+	struct list_head quirks_list;
+	struct pci_device_id devid;
+	struct pci_dev *pdev;
+};
+
+struct pciback_config_quirk *pciback_find_quirk(struct pci_dev *dev);
+
+int pciback_config_quirks_add_field(struct pci_dev *dev, struct config_field
+				    *field);
+
+int pciback_config_quirks_remove_field(struct pci_dev *dev, int reg);
+
+int pciback_config_quirks_init(struct pci_dev *dev);
+
+void pciback_config_field_free(struct config_field *field);
+
+int pciback_config_quirk_release(struct pci_dev *dev);
+
+int pciback_field_is_dup(struct pci_dev *dev, unsigned int reg);
+
+#endif
drivers/xen/pciback/passthrough.c new file +178 -0

178 lines not on this page · raw message

drivers/xen/pciback/pci_stub.c new file +1371 -0

1,371 lines not on this page · raw message

drivers/xen/pciback/pciback.h new file +128 -0

52 lines not on this page · raw message

drivers/xen/pciback/pciback_ops.c new file +375 -0

375 lines not on this page · raw message

drivers/xen/pciback/vpci.c new file +244 -0

244 lines not on this page · raw message

drivers/xen/pciback/xenbus.c new file +726 -0

726 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.1

Part of the diff is not shown here. View the raw message.