Skip to contentSkip to conversation

xen, usb: support pvUSB drivers

PATCH Superseded Juergen Gross 9 participants 22 messages Feb 26, 2015 – Mar 6, 2015

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Juergen Gross

author maintainer
#0 lore raw

cover xen, usb: support pvUSB drivers

This series adds XEN pvUSB support. With pvUSB it is possible to use physical USB devices from a XEN domain.

The support consists of a backend in the privileged Domain-0 doing the real I/O and a frontend in the unprivileged domU passing I/O-requests to the backend.

The code is taken (and adapted) from the original pvUSB implementation done for Linux 2.6 in 2008 by Fujitsu.

Normal operation of USB devices by adding and removing them dynamically to/from a domain has been tested using various USB devices (USB 1.1, 2.0 and 3.0). Assignment of a USB device at domain creation via config file has been tested as well.

Tests have been performed with the xm toolset and with xl using patches from Chun Yan Liu which are not upstream yet.

Juergen Gross (4):
usb: Add Xen pvUSB protocol description
usb: Introduce Xen pvUSB frontend
usb: Introduce Xen pvUSB backend
xen: add Xen pvUSB maintainer

 MAINTAINERS                      |    8 +
 drivers/usb/Kconfig              |    2 +
 drivers/usb/Makefile             |    3 +
 drivers/usb/xen/Kconfig          |   20 +
 drivers/usb/xen/Makefile         |    6 +
 drivers/usb/xen/xen-usbback.c    | 1845 ++++++++++++++++++++++++++++++++++++++
 drivers/usb/xen/xen-usbfront.c   | 1634 +++++++++++++++++++++++++++++++++
 include/xen/interface/io/usbif.h |  220 +++++
 8 files changed, 3738 insertions(+)
 create mode 100644 drivers/usb/xen/Kconfig
 create mode 100644 drivers/usb/xen/Makefile
 create mode 100644 drivers/usb/xen/xen-usbback.c
 create mode 100644 drivers/usb/xen/xen-usbfront.c
 create mode 100644 include/xen/interface/io/usbif.h
Signature · 1 line
2.1.4
author maintainer
#1 lore raw

PATCH 1/4 usb: Add Xen pvUSB protocol description

Add the definition of pvUSB protocol used between the pvUSB frontend in a Xen domU and the pvUSB backend in a Xen driver domain (usually Dom0).

This header was originally provided by Fujitsu for Xen based on Linux 2.6.18.

Changes are:
- adapt to Linux style guide

---
 include/xen/interface/io/usbif.h | 220 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 220 insertions(+)
 create mode 100644 include/xen/interface/io/usbif.h
include/xen/interface/io/usbif.h new file +220 -0
new file mode 100644
index 0000000..29815e2
@@ -0,0 +1,220 @@
+/*
+ * usbif.h
+ *
+ * USB I/O interface for Xen guest OSes.
+ *
+ * Copyright (C) 2009, FUJITSU LABORATORIES LTD.
+ * Author: Noboru Iwamatsu <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef __XEN_PUBLIC_IO_USBIF_H__
+#define __XEN_PUBLIC_IO_USBIF_H__
+
+#include "ring.h"
+#include "../grant_table.h"
+
+/*
+ * Feature and Parameter Negotiation
+ * =================================
+ * The two halves of a Xen pvUSB driver utilize nodes within the XenStore to
+ * communicate capabilities and to negotiate operating parameters. This
+ * section enumerates these nodes which reside in the respective front and
+ * backend portions of the XenStore, following the XenBus convention.
+ *
+ * Any specified default value is in effect if the corresponding XenBus node
+ * is not present in the XenStore.
+ *
+ * XenStore nodes in sections marked "PRIVATE" are solely for use by the
+ * driver side whose XenBus tree contains them.
+ *
+ *****************************************************************************
+ *                            Backend XenBus Nodes
+ *****************************************************************************
+ *
+ *------------------ Backend Device Identification (PRIVATE) ------------------
+ *
+ * num-ports
+ *      Values:         unsigned [1...31]
+ *
+ *      Number of ports for this (virtual) USB host connector.
+ *
+ * usb-ver
+ *      Values:         unsigned [1...2]
+ *
+ *      USB version of this host connector: 1 = USB 1.1, 2 = USB 2.0.
+ *
+ * port/[1...31]
+ *      Values:         string
+ *
+ *      Physical USB device connected to the given port, e.g. "3-1.5".
+ *
+ *****************************************************************************
+ *                            Frontend XenBus Nodes
+ *****************************************************************************
+ *
+ *----------------------- Request Transport Parameters -----------------------
+ *
+ * event-channel
+ *      Values:         unsigned
+ *
+ *      The identifier of the Xen event channel used to signal activity
+ *      in the ring buffer.
+ *
+ * urb-ring-ref
+ *      Values:         unsigned
+ *
+ *      The Xen grant reference granting permission for the backend to map
+ *      the sole page in a single page sized ring buffer. This is the ring
+ *      buffer for urb requests.
+ *
+ * conn-ring-ref
+ *      Values:         unsigned
+ *
+ *      The Xen grant reference granting permission for the backend to map
+ *      the sole page in a single page sized ring buffer. This is the ring
+ *      buffer for connection/disconnection requests.
+ *
+ * protocol
+ *      Values:         string (XEN_IO_PROTO_ABI_*)
+ *      Default Value:  XEN_IO_PROTO_ABI_NATIVE
+ *
+ *      The machine ABI rules governing the format of all ring request and
+ *      response structures.
+ *
+ */
+
+enum usb_spec_version {
+	USB_VER_UNKNOWN = 0,
+	USB_VER_USB11,
+	USB_VER_USB20,
+	USB_VER_USB30,	/* not supported yet */
+};
+
+/*
+ *  USB pipe in usbif_request
+ *
+ *  bits 0-5 are specific bits for virtual USB driver.
+ *  bits 7-31 are standard urb pipe.
+ *
+ *  - port number(NEW):	bits 0-4
+ *				(USB_MAXCHILDREN is 31)
+ *
+ *  - operation flag(NEW):	bit 5
+ *				(0 = submit urb,
+ *				 1 = unlink urb)
+ *
+ *  - direction:		bit 7
+ *				(0 = Host-to-Device [Out]
+ *				 1 = Device-to-Host [In])
+ *
+ *  - device address:		bits 8-14
+ *
+ *  - endpoint:			bits 15-18
+ *
+ *  - pipe type:		bits 30-31
+ *				(00 = isochronous, 01 = interrupt,
+ *				 10 = control, 11 = bulk)
+ */
+#define usbif_pipeportnum(pipe) ((pipe) & 0x1f)
+#define usbif_setportnum_pipe(pipe, portnum) \
+	((pipe)|(portnum))
+
+#define usbif_pipeunlink(pipe) ((pipe) & 0x20)
+#define usbif_pipesubmit(pipe) (!usbif_pipeunlink(pipe))
+#define usbif_setunlink_pipe(pipe) ((pipe) | 0x20)
+
+#define USBIF_MAX_SEGMENTS_PER_REQUEST 16
+
+/*
+ * RING for transferring urbs.
+ */
+struct usbif_request_segment {
+	grant_ref_t gref;
+	uint16_t offset;
+	uint16_t length;
+};
+
+struct usbif_urb_request {
+	uint16_t id;			/* request id */
+	uint16_t nr_buffer_segs;	/* # of urb->transfer_buffer segments */
+
+	/* basic urb parameter */
+	uint32_t pipe;
+	uint16_t transfer_flags;
+	uint16_t buffer_length;
+	union {
+		uint8_t ctrl[8];		/* pipe type control */
+						/* setup packet */
+
+		struct {
+			uint16_t interval;	/* max (1024*8) in usb core */
+			uint16_t start_frame;		/* start frame */
+			uint16_t number_of_packets;	/* # of ISO packets */
+			uint16_t nr_frame_desc_segs;
+					/* # of iso_frame_desc segments */
+		} isoc;				/* pipe type isochronous */
+
+		struct {
+			uint16_t interval;	/* max (1024*8) in usb core */
+			uint16_t pad[3];
+		} intr;				/* pipe type interrupt */
+
+		struct {
+			uint16_t unlink_id;	/* unlink request id */
+			uint16_t pad[3];
+		} unlink;			/* pipe unlink */
+
+	} u;
+
+	/* urb data segments */
+	struct usbif_request_segment seg[USBIF_MAX_SEGMENTS_PER_REQUEST];
+};
+
+struct usbif_urb_response {
+	uint16_t id;		/* request id */
+	uint16_t start_frame;	/* start frame (ISO) */
+	int32_t status;		/* status (non-ISO) */
+	int32_t actual_length;	/* actual transfer length */
+	int32_t error_count;	/* number of ISO errors */
+};
+
+DEFINE_RING_TYPES(usbif_urb, struct usbif_urb_request,
+		  struct usbif_urb_response);
+#define USB_URB_RING_SIZE __CONST_RING_SIZE(usbif_urb, PAGE_SIZE)
+
+/*
+ * RING for notifying connect/disconnect events to frontend
+ */
+struct usbif_conn_request {
+	uint16_t id;
+};
+
+struct usbif_conn_response {
+	uint16_t id;		/* request id */
+	uint8_t portnum;	/* port number */
+	uint8_t speed;		/* usb_device_speed */
+};
+
+DEFINE_RING_TYPES(usbif_conn, struct usbif_conn_request,
+		  struct usbif_conn_response);
+#define USB_CONN_RING_SIZE __CONST_RING_SIZE(usbif_conn, PAGE_SIZE)
+
+#endif /* __XEN_PUBLIC_IO_USBIF_H__ */
Signature · 1 line
2.1.4
author maintainer
#2 lore raw

PATCH 2/4 usb: Introduce Xen pvUSB frontend

In reply to Juergen Gross

Introduces the Xen pvUSB frontend. With pvUSB it is possible for a Xen domU to communicate with a USB device assigned to that domU. The communication is all done via the pvUSB backend in a driver domain (usually Dom0) which is owner of the physical device.

The code is taken from the pvUSB implementation in Xen done by Fujitsu based on Linux kernel 2.6.18.

Changes from the original version are:
- port to upstream kernel
- put all code in just one source file
- move module to appropriate location in kernel tree
- adapt to Linux style guide
- minor code modifications to increase readability

---
 drivers/usb/Kconfig            |    2 +
 drivers/usb/Makefile           |    2 +
 drivers/usb/xen/Kconfig        |   10 +
 drivers/usb/xen/Makefile       |    5 +
 drivers/usb/xen/xen-usbfront.c | 1634 ++++++++++++++++++++++++++++++++++++++++
 5 files changed, 1653 insertions(+)
 create mode 100644 drivers/usb/xen/Kconfig
 create mode 100644 drivers/usb/xen/Makefile
 create mode 100644 drivers/usb/xen/xen-usbfront.c
drivers/usb/Kconfig +2 -0
index 8ed451d..de998f1 100644
@@ -94,6 +94,8 @@ source "drivers/usb/image/Kconfig"
 
 source "drivers/usb/usbip/Kconfig"
 
+source "drivers/usb/xen/Kconfig"
+
 endif
 
 source "drivers/usb/musb/Kconfig"
drivers/usb/Makefile +2 -0
index 2f1e2aa..2676ef6 100644
@@ -62,3 +62,5 @@ obj-$(CONFIG_USB_GADGET)	+= gadget/
 obj-$(CONFIG_USB_COMMON)	+= common/
 
 obj-$(CONFIG_USBIP_CORE)	+= usbip/
+
+obj-$(CONFIG_XEN_USB_FRONTEND)	+= xen/
drivers/usb/xen/Kconfig new file +10 -0
new file mode 100644
index 0000000..5d995477
@@ -0,0 +1,10 @@
+config XEN_USB_FRONTEND
+	tristate "Xen USB frontend driver"
+	depends on XEN
+	default m
+	select XEN_XENBUS_FRONTEND
+	help
+	  The Xen USB frontend driver allows the kernel to access USB Devices
+	  within another guest OS (usually Dom0).
+	  Only needed if the kernel is running in a Xen guest and generic
+	  access to a USB device is needed.
drivers/usb/xen/Makefile new file +5 -0
new file mode 100644
index 0000000..4568c26
@@ -0,0 +1,5 @@
+#
+# Makefile for Xen pvUSB drivers
+#
+
+obj-$(CONFIG_XEN_USB_FRONTEND)		+= xen-usbfront.o
drivers/usb/xen/xen-usbfront.c new file +1634 -0

1,634 lines not on this page · raw message

Signature · 1 line
2.1.4
#3 lore raw

Re: [PATCH 2/4] usb: Introduce Xen pvUSB frontend

Quoted 34 lines · Juergen Gross
drivers/usb/xen/xen-usbfront.c new file +3 -0
+
+               /* reset completion */
+               if ((info->ports[wIndex].status &

USB_PORT_STAT_RESET) != 0 &&
+ time_after_eq(jiffies,
info->ports[wIndex].timeout)) {

drivers/usb/xen/xen-usbfront.c new file +3 -0
+                       info->ports[wIndex].status |=
+                               USB_PORT_STAT_C_RESET << 16;
+                       info->ports[wIndex].status &=

~USB_PORT_STAT_RESET;

drivers/usb/xen/xen-usbfront.c new file +24 -0
+
+                       if (info->devices[wIndex].status !=
+                           USB_STATE_NOTATTACHED) {
+                               info->ports[wIndex].status |=
+                                       USB_PORT_STAT_ENABLE;
+                               info->devices[wIndex].status =
+                                       USB_STATE_DEFAULT;
+                       }
+
+                       switch (info->devices[wIndex].speed) {
+                       case USB_SPEED_LOW:
+                               info->ports[wIndex].status |=
+                                       USB_PORT_STAT_LOW_SPEED;
+                               break;
+                       case USB_SPEED_HIGH:
+                               info->ports[wIndex].status |=
+                                       USB_PORT_STAT_HIGH_SPEED;
+                               break;
+                       default:
+                               break;
+                       }
+               }
+
+               ((u16 *)buf)[0] =
Quoted 3 lines

cpu_to_le16(info->ports[wIndex].status);
+ ((u16 *)buf)[1] =
cpu_to_le16(info->ports[wIndex].status >> 16);

Why in two chunks?
Regards
Oliver

Quoted 1 line

+ break;

Signature · 1 line
Oliver Neukum <[email protected]>
author maintainer
#4 lore raw

PATCH 3/4 usb: Introduce Xen pvUSB backend

In reply to Juergen Gross

Introduces the Xen pvUSB backend. With pvUSB it is possible for a Xen domU to communicate with a USB device assigned to that domU. The communication is all done via the pvUSB backend in a driver domain (usually Dom0) which is owner of the physical device.

The code is taken from the pvUSB implementation in Xen done by Fujitsu based on Linux kernel 2.6.18.

Changes from the original version are:
- port to upstream kernel
- put all code in just one source file
- move module to appropriate location in kernel tree
- adapt to Linux style guide
- allocate resources dynamically
- use threaded irq
- correct sequence of state changes when assigning a device

---
 drivers/usb/Makefile          |    1 +
 drivers/usb/xen/Kconfig       |   10 +
 drivers/usb/xen/Makefile      |    1 +
 drivers/usb/xen/xen-usbback.c | 1845 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 1857 insertions(+)
 create mode 100644 drivers/usb/xen/xen-usbback.c
drivers/usb/Makefile +1 -0
index 2676ef6..41f7398 100644
@@ -64,3 +64,4 @@ obj-$(CONFIG_USB_COMMON)	+= common/
 obj-$(CONFIG_USBIP_CORE)	+= usbip/
 
 obj-$(CONFIG_XEN_USB_FRONTEND)	+= xen/
+obj-$(CONFIG_XEN_USB_BACKEND)	+= xen/
drivers/usb/xen/Kconfig +10 -0
index 5d995477..3414617 100644
@@ -8,3 +8,13 @@ config XEN_USB_FRONTEND
 	  within another guest OS (usually Dom0).
 	  Only needed if the kernel is running in a Xen guest and generic
 	  access to a USB device is needed.
+
+config XEN_USB_BACKEND
+	tristate "Xen USB backend driver"
+	depends on XEN_BACKEND
+	default m
+	help
+	  The USB backend driver allows the kernel to export its USB Devices
+	  to other guests via a high-performance shared-memory interface.
+	  Only needed for systems running as Xen driver domains (e.g. Dom0) and
+	  if guests need generic access to USB devices.
drivers/usb/xen/Makefile +1 -0
index 4568c26..c1a571065 100644
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_XEN_USB_FRONTEND)		+= xen-usbfront.o
+obj-$(CONFIG_XEN_USB_BACKEND)		+= xen-usbback.o
drivers/usb/xen/xen-usbback.c new file +1845 -0

1,845 lines not on this page · raw message

Signature · 1 line
2.1.4
#5 lore raw

Re: [Xen-devel] [PATCH 3/4] usb: Introduce Xen pvUSB backend

Quoted 4 lines · Juergen Gross

Introduces the Xen pvUSB backend. With pvUSB it is possible for a Xen domU to communicate with a USB device assigned to that domU. The communication is all done via the pvUSB backend in a driver domain (usually Dom0) which is owner of the physical device.

Why do we need a kernel usb backend instead of a user-space one using libusb?

Quoted 3 lines

Changes from the original version are:
- port to upstream kernel
- put all code in just one source file

?? I'm not sure that was an improvement. The resulting single file is too large IMO.

Quoted 1 line

- move module to appropriate location in kernel tree

drivers/xen/ is the correct location for this driver.

(I've not given the driver a detailed review yet.)

David

author maintainer
#6 lore raw

Re: [Xen-devel] [PATCH 3/4] usb: Introduce Xen pvUSB backend

Quoted 8 lines · David Vrabel
Quoted 4 lines · Juergen Gross

Introduces the Xen pvUSB backend. With pvUSB it is possible for a Xen domU to communicate with a USB device assigned to that domU. The communication is all done via the pvUSB backend in a driver domain (usually Dom0) which is owner of the physical device.

Why do we need a kernel usb backend instead of a user-space one using libusb?

Good question. At a first glance libusb seems to offer most/all needed interfaces. The main question is whether performance with libusb will be okay. There will be one additional copy of the I/O data needed if I've read the code in drivers/usb/core/devio.c correctly.

I haven't worked with user space backends yet. Do you recommend a special example I should start with?

Quoted 7 lines
Quoted 4 lines

Changes from the original version are:
- port to upstream kernel
- put all code in just one source file

?? I'm not sure that was an improvement. The resulting single file is too large IMO.

OTOH this reduces overall code size:

New file has 1845 lines, while old version had in sum 2243 lines with the largest file having 1217 lines. So the largest file is 50% larger, while overall size is 20% smaller.

Quoted 3 lines
Quoted 1 line

- move module to appropriate location in kernel tree

drivers/xen/ is the correct location for this driver.

Hmm, so you regard placement of xen-netback under drivers/net and xen-blkback under drivers/block as wrong? I've just followed these examples.

Juergen

#7 lore raw

Re: [Xen-devel] [PATCH 3/4] usb: Introduce Xen pvUSB backend

Quoted 7 lines · Juergen Gross
Quoted 3 lines
Quoted 1 line

- move module to appropriate location in kernel tree

drivers/xen/ is the correct location for this driver.

Hmm, so you regard placement of xen-netback under drivers/net and xen-blkback under drivers/block as wrong? I've just followed these examples.

At least in the case of netback it really is just a normal Ethernet driver as far as the kernel is concerned. The fact it happens to talk to a virtual device doesn't matter.

I don't know about other device types.

Ian.

author maintainer
#8 lore raw

Re: [Xen-devel] [PATCH 3/4] usb: Introduce Xen pvUSB backend

Quoted 9 lines · Ian Campbell
Quoted 7 lines · Juergen Gross
Quoted 3 lines
Quoted 1 line

- move module to appropriate location in kernel tree

drivers/xen/ is the correct location for this driver.

Hmm, so you regard placement of xen-netback under drivers/net and xen-blkback under drivers/block as wrong? I've just followed these examples.

Quoted 5 lines

At least in the case of netback it really is just a normal Ethernet driver as far as the kernel is concerned. The fact it happens to talk to a virtual device doesn't matter.

I don't know about other device types.

usbback is just a normal USB driver as far as the kernel is concerned. :-)

Juergen

#9 lore raw

Re: [Xen-devel] [PATCH 3/4] usb: Introduce Xen pvUSB backend

In reply to Juergen Gross
Quoted 10 lines · Juergen Gross
Quoted 8 lines · David Vrabel
Quoted 4 lines · Juergen Gross

Introduces the Xen pvUSB backend. With pvUSB it is possible for a Xen domU to communicate with a USB device assigned to that domU. The communication is all done via the pvUSB backend in a driver domain (usually Dom0) which is owner of the physical device.

Why do we need a kernel usb backend instead of a user-space one using libusb?

Quoted 7 lines

Good question. At a first glance libusb seems to offer most/all needed interfaces. The main question is whether performance with libusb will be okay. There will be one additional copy of the I/O data needed if I've read the code in drivers/usb/core/devio.c correctly.

I haven't worked with user space backends yet. Do you recommend a special example I should start with?

Perhaps the block backend in qemu?

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

Changes from the original version are:
- port to upstream kernel
- put all code in just one source file

Quoted 8 lines
Quoted 2 lines

?? I'm not sure that was an improvement. The resulting single file is too large IMO.

OTOH this reduces overall code size:

New file has 1845 lines, while old version had in sum 2243 lines with the largest file having 1217 lines. So the largest file is 50% larger, while overall size is 20% smaller.

I think I would have preferred the original large file split up (if there's a sensible functional grouping of the resulting bits).

If, after considering a userspace backend, you think that this kernel one is the way to go I'll give it another look and see if I can suggest a suitable split.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

- move module to appropriate location in kernel tree

drivers/xen/ is the correct location for this driver.

Hmm, so you regard placement of xen-netback under drivers/net and xen-blkback under drivers/block as wrong? I've just followed these examples.

usbback is just a regular USB device driver and most of these don't live under drivers/usb/ but in the subsystem for the type of device they're providing (which in this case is a Xen backend, hence drivers/xen/).

David

author maintainer
#10 lore raw

Re: [Xen-devel] [PATCH 3/4] usb: Introduce Xen pvUSB backend

Quoted 16 lines · David Vrabel
Quoted 15 lines · Juergen Gross
Quoted 8 lines · David Vrabel
Quoted 4 lines · Juergen Gross

Introduces the Xen pvUSB backend. With pvUSB it is possible for a Xen domU to communicate with a USB device assigned to that domU. The communication is all done via the pvUSB backend in a driver domain (usually Dom0) which is owner of the physical device.

Why do we need a kernel usb backend instead of a user-space one using libusb?

Good question. At a first glance libusb seems to offer most/all needed interfaces. The main question is whether performance with libusb will be okay. There will be one additional copy of the I/O data needed if I've read the code in drivers/usb/core/devio.c correctly.

Quoted 4 lines
Quoted 2 lines

I haven't worked with user space backends yet. Do you recommend a special example I should start with?

Perhaps the block backend in qemu?

Okay, so this would be driven by qemu then?

The main question whether it is worth to consider this alternative is the performance aspect. Does anyone have an idea which USB devices would typically be used via pvusb? I'd suspect memory sticks and USB disks and perhaps webcams being the most performance relevant ones. Is an additional copy operation of user data acceptable here?

Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

Changes from the original version are:
- port to upstream kernel
- put all code in just one source file

Quoted 8 lines
Quoted 2 lines

?? I'm not sure that was an improvement. The resulting single file is too large IMO.

OTOH this reduces overall code size:

New file has 1845 lines, while old version had in sum 2243 lines with the largest file having 1217 lines. So the largest file is 50% larger, while overall size is 20% smaller.

Quoted 6 lines

I think I would have preferred the original large file split up (if there's a sensible functional grouping of the resulting bits).

If, after considering a userspace backend, you think that this kernel one is the way to go I'll give it another look and see if I can suggest a suitable split.

I can split it up, if you really want.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

- move module to appropriate location in kernel tree

drivers/xen/ is the correct location for this driver.

Quoted 7 lines
Quoted 3 lines

Hmm, so you regard placement of xen-netback under drivers/net and xen-blkback under drivers/block as wrong? I've just followed these examples.

usbback is just a regular USB device driver and most of these don't live under drivers/usb/ but in the subsystem for the type of device they're providing (which in this case is a Xen backend, hence drivers/xen/).

Okay, I'll move it to drivers/xen.

Juergen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#11 lore raw

Re: [Xen-devel] [PATCH 3/4] usb: Introduce Xen pvUSB backend

Quoted 6 lines · Juergen Gross

The main question whether it is worth to consider this alternative is the performance aspect. Does anyone have an idea which USB devices would typically be used via pvusb? I'd suspect memory sticks and USB disks and perhaps webcams being the most performance relevant ones. Is an additional copy operation of user data acceptable here?

I have no idea. We (XenServer) have no use cases at all for USB device passthrough.

David
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#12 lore raw

Re: [Xen-devel] [PATCH 3/4] usb: Introduce Xen pvUSB backend

Quoted 10 lines · David Vrabel
Quoted 6 lines · Juergen Gross

The main question whether it is worth to consider this alternative is the performance aspect. Does anyone have an idea which USB devices would typically be used via pvusb? I'd suspect memory sticks and USB disks and perhaps webcams being the most performance relevant ones. Is an additional copy operation of user data acceptable here?

I have no idea. We (XenServer) have no use cases at all for USB device passthrough.

My gut feeling is that for USB 1 and 2 the bus itself isn't fast enough that anyone would care. qdisk has acceptable for disks, so it's probably ok for usb too.

For usb 3 onwards, well, maybe when we care about those we'll decide that a kernel space driver is needed, but for now it seems like userspace would be ok.

Ian.

author maintainer
#13 lore raw

Re: [Xen-devel] [PATCH 3/4] usb: Introduce Xen pvUSB backend

Quoted 9 lines · Ian Campbell
Quoted 8 lines · David Vrabel
Quoted 6 lines · Juergen Gross

The main question whether it is worth to consider this alternative is the performance aspect. Does anyone have an idea which USB devices would typically be used via pvusb? I'd suspect memory sticks and USB disks and perhaps webcams being the most performance relevant ones. Is an additional copy operation of user data acceptable here?

Quoted 6 lines
Quoted 2 lines

I have no idea. We (XenServer) have no use cases at all for USB device passthrough.

My gut feeling is that for USB 1 and 2 the bus itself isn't fast enough that anyone would care. qdisk has acceptable for disks, so it's probably ok for usb too.

While I can accept the bus speed reasoning, I doubt qdisk is copying data between user and kernel space under normal circumstances. I think disk I/Os are done using DMA to/from the user buffer directly.

Quoted 3 lines

For usb 3 onwards, well, maybe when we care about those we'll decide that a kernel space driver is needed, but for now it seems like userspace would be ok.

Do you have another feeling about the probability of a need to do usb 3? If it is already on the horizon I wouldn't want to do the user space backend now and the kernel one next year. :-)

Juergen

#14 lore raw

Re: [Xen-devel] [PATCH 3/4] usb: Introduce Xen pvUSB backend

Quoted 3 lines · Juergen Gross

Do you have another feeling about the probability of a need to do usb 3? If it is already on the horizon I wouldn't want to do the user space backend now and the kernel one next year. :-)

One year is pretty long in kernel time.

//Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#15 lore raw

Re: [Xen-devel] [PATCH 3/4] usb: Introduce Xen pvUSB backend

In reply to Juergen Gross
Quoted 13 lines · Juergen Gross
Quoted 12 lines · Ian Campbell
Quoted 10 lines · David Vrabel
Quoted 6 lines · Juergen Gross

The main question whether it is worth to consider this alternative is the performance aspect. Does anyone have an idea which USB devices would typically be used via pvusb? I'd suspect memory sticks and USB disks and perhaps webcams being the most performance relevant ones. Is an additional copy operation of user data acceptable here?

I have no idea. We (XenServer) have no use cases at all for USB device passthrough.

Quoted 7 lines
Quoted 3 lines

My gut feeling is that for USB 1 and 2 the bus itself isn't fast enough that anyone would care. qdisk has acceptable for disks, so it's probably ok for usb too.

While I can accept the bus speed reasoning, I doubt qdisk is copying data between user and kernel space under normal circumstances. I think disk I/Os are done using DMA to/from the user buffer directly.

I thought there was at least one copy on the datapath with qdisk, wherever it is. But I don't know for sure.

Quoted 7 lines
Quoted 3 lines

For usb 3 onwards, well, maybe when we care about those we'll decide that a kernel space driver is needed, but for now it seems like userspace would be ok.

Do you have another feeling about the probability of a need to do usb 3? If it is already on the horizon I wouldn't want to do the user space backend now and the kernel one next year. :-)

Well, what is *your* use case for USB passthru? I don't actually have one myself.

I'd speculate that people are more interested in passing in low/medium/high speed devices rather than the superfast usb3 disks etc. But I have no reason to back that up.

Ian.

#16 lore raw

Re: [Xen-devel] [PATCH 3/4] usb: Introduce Xen pvUSB backend

Quoted 11 lines · Ian Campbell
Quoted 10 lines · Juergen Gross
Quoted 9 lines · Ian Campbell
Quoted 8 lines · David Vrabel
Quoted 6 lines · Juergen Gross

The main question whether it is worth to consider this alternative is the performance aspect. Does anyone have an idea which USB devices would typically be used via pvusb? I'd suspect memory sticks and USB disks and perhaps webcams being the most performance relevant ones. Is an additional copy operation of user data acceptable here?

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

I have no idea. We (XenServer) have no use cases at all for USB device passthrough.

I've seen XenServer customers asking for USB passthru functionality on IRC channels..

Quoted 19 lines
Quoted 7 lines
Quoted 3 lines

My gut feeling is that for USB 1 and 2 the bus itself isn't fast enough that anyone would care. qdisk has acceptable for disks, so it's probably ok for usb too.

While I can accept the bus speed reasoning, I doubt qdisk is copying data between user and kernel space under normal circumstances. I think disk I/Os are done using DMA to/from the user buffer directly.

I thought there was at least one copy on the datapath with qdisk, wherever it is. But I don't know for sure.

Quoted 7 lines
Quoted 3 lines

For usb 3 onwards, well, maybe when we care about those we'll decide that a kernel space driver is needed, but for now it seems like userspace would be ok.

Do you have another feeling about the probability of a need to do usb 3? If it is already on the horizon I wouldn't want to do the user space backend now and the kernel one next year. :-)

Quoted 7 lines

Well, what is *your* use case for USB passthru? I don't actually have one myself.

I'd speculate that people are more interested in passing in low/medium/high speed devices rather than the superfast usb3 disks etc. But I have no reason to back that up.

People seem to ask/need USB passthru support for various use cases including passing thru: webcams, video grabbers, printers, mobile broadband modems, copy protection dongles, gaming controllers, you name it..

-- Pasi

#17 lore raw

Re: [Xen-devel] [PATCH 3/4] usb: Introduce Xen pvUSB backend

In reply to Juergen Gross
Quoted 6 lines · Juergen Gross

The main question whether it is worth to consider this alternative is the performance aspect. Does anyone have an idea which USB devices would typically be used via pvusb? I'd suspect memory sticks and USB disks and perhaps webcams being the most performance relevant ones. Is an additional copy operation of user data acceptable here?

Biggest use-cases I can think of for USB pass-through would be hardware 'security' devices (fingerprint readers, Yubikeys, SafeNet dongles), webcams, and some of the more exotic input devices. Webcams and input devices are probably the most significant performance-wise.

maintainer
#18 lore raw

Re: [Xen-devel] [PATCH 3/4] usb: Introduce Xen pvUSB backend

In reply to Juergen Gross
Quoted 7 lines · Juergen Gross
Quoted 6 lines · David Vrabel
Quoted 4 lines · Juergen Gross

Introduces the Xen pvUSB backend. With pvUSB it is possible for a Xen domU to communicate with a USB device assigned to that domU. The communication is all done via the pvUSB backend in a driver domain (usually Dom0) which is owner of the physical device.

Quoted 7 lines
Quoted 2 lines

Why do we need a kernel usb backend instead of a user-space one using libusb?

Good question. At a first glance libusb seems to offer most/all needed interfaces. The main question is whether performance with libusb will be okay. There will be one additional copy of the I/O data needed if I've read the code in drivers/usb/core/devio.c correctly.

You can drive USB devices at line speed using libusb just fine. Try it out and see please, processors copy data _very_ fast these days.

thanks,

greg k-h

author maintainer
#19 lore raw

Re: [Xen-devel] [PATCH 3/4] usb: Introduce Xen pvUSB backend

Quoted 11 lines · Greg KH
Quoted 10 lines · Juergen Gross
Quoted 8 lines · David Vrabel
Quoted 4 lines · Juergen Gross

Introduces the Xen pvUSB backend. With pvUSB it is possible for a Xen domU to communicate with a USB device assigned to that domU. The communication is all done via the pvUSB backend in a driver domain (usually Dom0) which is owner of the physical device.

Why do we need a kernel usb backend instead of a user-space one using libusb?

Quoted 7 lines
Quoted 4 lines

Good question. At a first glance libusb seems to offer most/all needed interfaces. The main question is whether performance with libusb will be okay. There will be one additional copy of the I/O data needed if I've read the code in drivers/usb/core/devio.c correctly.

You can drive USB devices at line speed using libusb just fine. Try it out and see please, processors copy data _very_ fast these days.

Okay, thanks for the information.

I'll take this as a hint to try the user space variant. :-)

Juergen

author maintainer
#20 lore raw

PATCH 4/4 xen: add Xen pvUSB maintainer

In reply to Juergen Gross

Add myself as maintainer for the Xen pvUSB stuff.

---
 MAINTAINERS | 8 ++++++++
 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
index ddc5a8c..8ec1e1f 100644
@@ -10787,6 +10787,14 @@ F:	drivers/scsi/xen-scsifront.c
 F:	drivers/xen/xen-scsiback.c
 F:	include/xen/interface/io/vscsiif.h
 
+XEN PVUSB DRIVERS
+M:	Juergen Gross <[email protected]>
+L:	[email protected] (moderated for non-subscribers)
+L:	[email protected]
+S:	Supported
+F:	divers/usb/xen/
+F:	include/xen/interface/io/usbif.h
+
 XEN SWIOTLB SUBSYSTEM
 M:	Konrad Rzeszutek Wilk <[email protected]>
 L:	[email protected] (moderated for non-subscribers)
Signature · 1 line
2.1.4
Acked-by on v1 4/4
#21 lore raw

Re: [PATCH 4/4] xen: add Xen pvUSB maintainer

Quoted 15 lines · Juergen Gross

Add myself as maintainer for the Xen pvUSB stuff.

---
MAINTAINERS | 8 ++++++++

1 file changed, 8 insertions(+)
MAINTAINERS +0 -0
index ddc5a8c..8ec1e1f 100644
@@ -10787,6 +10787,14 @@ F:	drivers/scsi/xen-scsifront.c

F: drivers/xen/xen-scsiback.c
F: include/xen/interface/io/vscsiif.h

MAINTAINERS F: drivers/scsi/xen-scsifront.c · line 10796

Quoted 7 lines
MAINTAINERS +7 -0
+XEN PVUSB DRIVERS
+M:	Juergen Gross <[email protected]>
+L:	[email protected] (moderated for non-subscribers)
+L:	[email protected]
+S:	Supported
+F:	divers/usb/xen/
+F:	include/xen/interface/io/usbif.h

On the include/Xen/... part.

Quoted 4 lines

+
XEN SWIOTLB SUBSYSTEM
M: Konrad Rzeszutek Wilk <[email protected]>
L: [email protected] (moderated for non-subscribers)