USB virt
I ported the FE and BE to a new interdomain communication interface and the USB driver is mostly complete (the claim port interface needs to be fixed up and there is a state machine which needs to be fixed).
I'm about halfway through the implementation of the interdomain communication interface.
I defined a new interdomain communication interface because I wanted to decouple the driver from changes in the underlying infrastructure so I didn't have to rewrite it a fourth time for the next flavour of xenbus.
Also, I think the interdomain communication API I've written ought to be generally useful and save a lot of code if people reuse it in other drivers.
I've attached a patch of the current code. It compiles until it gets to some undefined references for functions I've not implemented yet.
I'm currently working on the endpoint object. This is going to be implemented in three layers: xenid_gnttab_channel, xenidc_xbgt_channel and a third layer not yet complete. The current endpoint implementation is crufty because I'm in the middle of factoring out the code into those three layers.
Feedback on the code would be welcome.
Harry.
Quoted 5 lines · Mark Williamson
Hi Harry,
Could you tell me what the status was on this? Is there any chance of getting a snapshot of the code online somewhere?
Quoted 8 lines
Regarding the implementation, it sounds like you've done a good job making it work with lots of USB devices. I am curious as to why you're defining a new interdomain communications interface, though - XenBus is meant to be there for the forseeable future ... ?
Thanks very much,
Mark
linux-2.6-xen-sparse/arch/xen/Kconfig +55 -0
@@ -38,6 +38,14 @@ (e.g., hard drives, network cards). This allows you to configure such devices and also includes some low-level support that is otherwise not compiled into the kernel. + +config XEN_IDC_TRACE + bool "Inter-domain communication code tracing" + default y + help + This option causes the IDC code to output a continual trace of its + activity. + Say N here unless you are trying to debug this code. config XEN_BLKDEV_BACKEND bool "Block-device backend driver"
@@ -69,6 +77,29 @@ The network-device backend driver allows the kernel to export its network devices to other guests via a high-performance shared-memory interface. + +config XEN_USBDEV_BACKEND + tristate "USB-device backend driver" + depends on XEN_PHYSDEV_ACCESS + select USB + default m + help + The USB-device backend driver allows the kernel to export USB + devices to USB-device frontend drivers running in other domains. + This is not required for USB device access in domain 0 or any domain + given exclusive control over a USB host controller device at the PCI + level. + Say Y or M if you want to use this kernel to export a USB device to + another domain running a USB-device frontend driver. + +config XEN_USBDEV_BACKEND_TRACE + bool "USB-device backend driver tracing" + depends on XEN_USBDEV_BACKEND + default y + help + This option causes the driver to output a continual trace of its + activity. + Say N here unless you are trying to debug the driver. config XEN_TPMDEV_FRONTEND bool "TPM-device frontend driver"
@@ -128,6 +159,30 @@ are unsure; or if you experience network hangs when this option is enabled; then you must say N here. +config XEN_USBDEV_FRONTEND + tristate "USB-device frontend driver" + select USB + default m + help + The USB-device frontend driver allows the kernel to access USB + devices exported by a USB-device backend driver running in another + domain. + This is not required for USB device access in domain 0 or any domain + given exclusive control over a USB host controller device at the PCI + level. + Say Y or M if you want to use a USB-device backend driver to export a + USB device from another domain to the domain which will run this + kernel. + +config XEN_USBDEV_FRONTEND_TRACE + bool "USB-device frontend driver tracing" + depends on XEN_USBDEV_FRONTEND + default y + help + This option causes the driver to output a continual trace of its + activity. + Say N here unless you are trying to debug the driver. + config XEN_BLKDEV_TAP bool "Block device tap driver" default n
linux-2.6-xen-sparse/drivers/xen/Makefile +3 -2
@@ -1,4 +1,3 @@ - obj-y += util.o obj-y += console/
@@ -6,12 +5,14 @@ obj-y += balloon/ obj-y += privcmd/ obj-y += xenbus/ +obj-y += xenidc/ obj-$(CONFIG_XEN_BLKDEV_BACKEND) += blkback/ obj-$(CONFIG_XEN_NETDEV_BACKEND) += netback/ +obj-$(CONFIG_XEN_USBDEV_BACKEND) += usbback/ obj-$(CONFIG_XEN_TPMDEV_BACKEND) += tpmback/ obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += blkfront/ obj-$(CONFIG_XEN_NETDEV_FRONTEND) += netfront/ +obj-$(CONFIG_XEN_USBDEV_FRONTEND) += usbfront/ obj-$(CONFIG_XEN_BLKDEV_TAP) += blktap/ obj-$(CONFIG_XEN_TPMDEV_FRONTEND) += tpmfront/ -
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c +1 -0
@@ -264,6 +264,7 @@ {return xenbus_register_driver_common (drv, &xenbus_backend); } +EXPORT_SYMBOL (xenbus_register_backend);void xenbus_unregister_driver (struct xenbus_driver *drv) {
tools/python/xen/xend/server/usbif.py +13 -4
@@ -22,8 +22,9 @@ """Support for virtual USB hubs. """ +from xen.xend import sxp + from xen.xend.server.DevController import DevController - class UsbifController(DevController): """USB device interface controller. Handles all USB devices
@@ -35,8 +36,16 @@ """ DevController.__init__(self, vm) - - def getDeviceDetails(self, _): + def getDeviceDetails(self, config): """@see DevController.getDeviceDetails""" - return (self.allocateDeviceID(), {}, {}) + path = sxp.child_value(config, 'path') + + devid = self.allocateDeviceID() + + back = { 'path' : path, + 'handle' : "%i" % devid } + + front = { 'handle' : "%i" % devid } + + return (devid, back, front)
tools/python/xen/xm/create.py +36 -6
81 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/usbback/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +obj-$(CONFIG_XEN_USBDEV_BACKEND) += usbback.o + +usbback-objs := \ +usbback_device.o \ +usbback_driver_backend.o \ +usbback_driver.o \ +usbback_driver_port.o \ +usbback_driver_port_resource.o \ +usbback_module.o
linux-2.6-xen-sparse/drivers/xen/usbback/usbback_assert.h new file +43 -0
43 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/usbback/usbback_device.c new file +411 -0
411 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/usbback/usbback_device.h new file +37 -0
@@ -0,0 +1,37 @@ +/*****************************************************************************/ +/* A device object representing the low-level connection to a single */ +/* front-end. */ +/* */ +/* Copyright (c) 2005 Harry Butterworth IBM Corporation */ +/* */ +/* This program is free software; you can redistribute it and/or modify it */ +/* under the terms of the GNU General Public License as published by the */ +/* Free Software Foundation; either version 2 of the License, or (at your */ +/* option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General */ +/* Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License along */ +/* with this program; if not, write to the Free Software Foundation, Inc., */ +/* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* */ +/*****************************************************************************/ + +#ifndef USBBACK_DEVICE_H +#define USBBACK_DEVICE_H + +extern int usbback_device_class_init (void ); + +extern void usbback_device_class_exit (void ); + +struct usbback_device ; + +extern void usbback_device_set_drvdata + (struct usbback_device * device,void * data ); + +extern void *usbback_device_get_drvdata (struct usbback_device * device ); + +#endif
linux-2.6-xen-sparse/drivers/xen/usbback/usbback_driver.c new file +249 -0
249 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/usbback/usbback_driver.h new file +54 -0
54 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/usbback/usbback_driver_backend.c new file +587 -0
587 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/usbback/usbback_driver_backend.h new file +63 -0
63 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/usbback/usbback_driver_port.c new file +1149 -0
1,149 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/usbback/usbback_driver_port.h new file +146 -0
146 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/usbback/usbback_driver_port_resource.c new file +1223 -0
43 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/usbback/usbback_driver_port_resource.h new file +87 -0
87 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/usbback/usbback_module.c new file +83 -0
83 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/usbback/usbback_trace.h new file +54 -0
54 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/usbfront/Makefile new file +7 -0
Lines of this file are not shown. View the raw message.
linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_assert.h new file +44 -0
44 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_device.c new file +1321 -0
1,321 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_device.h new file +82 -0
82 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_driver.c new file +880 -0
880 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_driver.h new file +35 -0
Lines of this file are not shown. View the raw message.
linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_hcd_resource.c new file +942 -0
942 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_hcd_resource.h new file +104 -0
104 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_module.c new file +92 -0
92 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_sll.h new file +133 -0
133 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_trace.h new file +53 -0
53 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/xenidc/Makefile new file +13 -0
Lines of this file are not shown. View the raw message.
linux-2.6-xen-sparse/drivers/xen/xenidc/xenidc_callback.c new file +61 -0
61 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/xenidc/xenidc_channel_ring.h new file +79 -0
79 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/xenidc/xenidc_concatenate.c new file +46 -0
46 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/xenidc/xenidc_endpoint.c new file +1164 -0
1,164 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/xenidc/xenidc_endpoint_initiator_resource.c new file +410 -0
410 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/xenidc/xenidc_endpoint_initiator_resource.h new file +95 -0
95 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/xenidc/xenidc_endpoint_target_resource.c new file +134 -0
134 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/xenidc/xenidc_endpoint_target_resource.h new file +58 -0
58 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/xenidc/xenidc_gnttab_channel.c new file +1297 -0
1,297 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/xenidc/xenidc_local_buffer_reference.c new file +55 -0
55 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/xenidc/xenidc_rbr_mapper_pool.c new file +80 -0
80 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/xenidc/xenidc_rbr_provider_pool.c new file +80 -0
80 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/xenidc/xenidc_trace.h new file +54 -0
54 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/xenidc/xenidc_vaddress.c new file +42 -0
42 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/xenidc/xenidc_work.c new file +110 -0
110 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/xenidc/xenidc_wrapping.c new file +47 -0
47 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/xenidc/xenidc_xbgt_channel.c new file +1732 -0
1,732 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/xenidc/xenidc_xbgt_channel_enumeration.dot new file +109 -0
109 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/xenidc/xenidc_xbgt_channel_enumeration.ps new file +2497 -0
2,497 lines not on this page · raw message
linux-2.6-xen-sparse/include/asm-xen/xenidc.h new file +681 -0
681 lines not on this page · raw message
linux-2.6-xen-sparse/include/asm-xen/xenidc_callback.h new file +166 -0
166 lines not on this page · raw message
linux-2.6-xen-sparse/include/asm-xen/xenidc_channel.h new file +143 -0
143 lines not on this page · raw message
linux-2.6-xen-sparse/include/asm-xen/xenidc_concatenate.h new file +47 -0
47 lines not on this page · raw message
linux-2.6-xen-sparse/include/asm-xen/xenidc_error.h new file +55 -0
55 lines not on this page · raw message
linux-2.6-xen-sparse/include/asm-xen/xenidc_gnttab_channel.h new file +193 -0
193 lines not on this page · raw message
linux-2.6-xen-sparse/include/asm-xen/xenidc_local_buffer_reference.h new file +103 -0
103 lines not on this page · raw message
linux-2.6-xen-sparse/include/asm-xen/xenidc_vaddress.h new file +30 -0
Lines of this file are not shown. View the raw message.
linux-2.6-xen-sparse/include/asm-xen/xenidc_work.h new file +160 -0
160 lines not on this page · raw message
linux-2.6-xen-sparse/include/asm-xen/xenidc_wrapping.h new file +48 -0
48 lines not on this page · raw message
linux-2.6-xen-sparse/include/asm-xen/xenidc_xbgt_channel.h new file +139 -0
139 lines not on this page · raw message
patches/linux-2.6.12/usb.patch new file +10 -0
Lines of this file are not shown. View the raw message.
xen/include/public/io/usbif.h new file +350 -0
350 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Part of the diff is not shown here. View the raw message.
Wow, 18k lines of code so far.
Just out of curiosity, a friend pointed me to
http://heanet.dl.sourceforge.net/sourceforge/usbip/usbip-0.1-2.6.13.tar.gz
which he was looking at for trying to find a way to do usb on Xen 2.0.
Would an approach like this be worth looking at?
-Sean
Signature · 9 lines
__________________________________________________________________ Sean Dague Mid-Hudson Valley sean at dague dot net Linux Users Group http://dague.net http://mhvlug.org There is no silver bullet. Plus, werewolves make better neighbors than zombies, and they tend to keep the vampire population down. __________________________________________________________________
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 9 lines · Sean Dague
Wow, 18k lines of code so far.
Just out of curiosity, a friend pointed me to
http://heanet.dl.sourceforge.net/sourceforge/usbip/usbip-0.1-2.6.13.tar.gz
which he was looking at for trying to find a way to do usb on Xen 2.0.Would an approach like this be worth looking at?
What an excellent idea. USB devices could keep working even after domain migration too :-)
Regards,
Anthony Liguori
Quoted 12 lines
-Sean
------------------------------------------------------------------------
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 1 line · Sean Dague
Wow, 18k lines of code so far.
Actually, the USB driver is only 8k raw lines, most of which is copyright comments. It's only 900 ";" of code which I think is pretty small.
Some of the rest of the code is duplicated because I'm in the middle of refactoring it.
The remainder of the rest of the code is the common code that is generally required to turn Xenbus and grant-tables into a useful inter-domain communication mechanism. This is the code that's currently replicated in all the other drivers. The reason that this portion of the code is bigger in my driver is because I'm coding a general solution which a) will work for device driver domains with driver restarts and loadable driver modules and b) is a service which can be used by new drivers in the future to save them from having yet another copy of the code.
Quoted 6 lines
Just out of curiosity, a friend pointed me to
http://heanet.dl.sourceforge.net/sourceforge/usbip/usbip-0.1-2.6.13.tar.gz
which he was looking at for trying to find a way to do usb on Xen 2.0.Would an approach like this be worth looking at?
The API of the inter-domain communication mechanism that I wrote the USB driver to is currently implemented using shared memory (grant-tables) for efficiency but is compatible with a network transparent implementation so could be extended to work through domain migration in the future. Naturally, if you extended the implementation of my interdomain communication API then any other drivers that had been written to use it would also benefit from the new functionality.
The difference between what I have done and the above IP based solution is that I have explicitly created a solution which can have an efficient shared memory implementation in the normal case when domains are resident on the same physical machine and my solution is intentionally available to any other drivers that might choose to use it.
Thanks for your input. I think I'll continue with what I was doing for the time being.
Harry.
Quoted 7 lines
-Sean
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel