Originally, USB/IP transmits requests and response PDUs for preparation
to transfer URBs in user space, after the preparation, URBs are
transmitted in kernel space.
To make easy to introduce application network protocols like WebSocket
and so on, the driver, usbip_ux.ko, forwards URBs to USB/IP user space
utilities. It's just like fuse driver for user space file system.
Then, utilities transfer URBs in user space.
To do so, usbip_trx_ops makes send/receive functions pluggable.
kernel_sendmsg() and kernel_recvmsg() for kernel mode transfer can be
substituted by read/write methods to user space utilities.
In the absence of usbip_ux.ko, original kernel space transferring is
valid. usbip_ux.ko replaces usbip_trx_ops in its init routine.
A) Original - kernel space URBs transfer
User+---+ 1) import/export +---+
space |uspipd,||usbip, |
|usbip | |usbipa |
+---+---+ +---+---+
| |
2)Set sockfd| |2)Set sockfd
thru sysfs| | thru sysfs
V V
Kernel +---+4)URBs+---+
space |usbip ||vhci |
|host.ko| |hcd.ko |
+---+ +---+
3)link to kernel trx_ops 3)link to kernel trx_ops
B) New - user space URBs transfer
User+---+1)import/export +---+
space |uspipd,||usbip, |
+---|usbip ||usbipa |---+
2)Set sockfd|+--+---+6)URBs+---+--+|2)Set sockfd
thru ioctl|| ^ ^ || thru ioctl
(right) || |5)read/write 5)read/write| || (left)
3)Set sockfd|| +---+ +--+ ||3)Set Sockfd
thru sysfs|+---+ | /dev/usbip-ux| +---+| thru sysfs
(left)VV V V VV (right)
Kernel +---+ +---+ +---+ +---+
space |usbip |-|usbip | |usbip |-|vhci |
|host.ko|5)send |ux.ko | |ux.ko |5)send |hcd.ko |
+---+ recv +---+ +---+ recv +---+
4)link to user trx_ops 4)link to user trx_ops
Kernel module configuration for the driver will be shown as below.
USB/IP support USBIP_CORE
+-- USB/IP userspace URB transmission USBIP_UX
+-- VHCI hcdUSBIP_HCD
+-- Debug messages for USB/IP USBIP_DEBUG
The reason why the userspace transmission oter than usbfs is needed.
a) Application(vhci_hcd)-side is needed
Usbfs provides functions to control device. So it can be applied to
device(usbip_host)-side but not to application(vhci_hcd)-side.
b) Use existing kernel modules as-is
To implement same functionality in userspace with interface like usbfs,
almost same code to kernel modules must be copied to userspcae. Also
interfaces between kernel modules and utiities (sysfs) should be
changed to new one. So utilities must be modified according to the new
interface too. Modifications to existing code by this patch is small
and usbip_ux.c handles major part of userspace transmission.
To get diff include/uapi/linux/usbip_ux.h, I used modified dontdiff.txt.
Signed-off-by: Nobuo Iwata nobuo.iw...@fujixerox.co.jp
---
drivers/usb/usbip/Kconfig| 10 +
drivers/usb/usbip/Makefile | 3 +
drivers/usb/usbip/stub_dev.c | 16 +-
drivers/usb/usbip/stub_rx.c | 3 +-
drivers/usb/usbip/stub_tx.c | 5 +-
drivers/usb/usbip/usbip_common.c | 79 +++-
drivers/usb/usbip/usbip_common.h | 29 +-
drivers/usb/usbip/usbip_ux.c | 602 +++
drivers/usb/usbip/usbip_ux.h | 82 +
drivers/usb/usbip/vhci_hcd.c | 9 +-
drivers/usb/usbip/vhci_rx.c | 3 +-
drivers/usb/usbip/vhci_sysfs.c | 40 +-
drivers/usb/usbip/vhci_tx.c | 6 +-
include/uapi/linux/usbip_ux.h| 39 ++
14 files changed, 869 insertions(+), 57 deletions(-)
diff --git a/drivers/usb/usbip/Kconfig b/drivers/usb/usbip/Kconfig
index bd99e9e..e847d06 100644
--- a/drivers/usb/usbip/Kconfig
+++ b/drivers/usb/usbip/Kconfig
@@ -14,6 +14,16 @@ config USBIP_CORE
If unsure, say N.
+config USBIP_UX
+ tristate USB/IP userspace URB transmission
+ depends on USBIP_CORE
+ ---help---
+ This moves USB/IP URB transmission to userspace
+ to apply SSL, WebSocket and etc.
+
+ To compile this driver as a module, choose M here: the
+ module will be called usbip-ux.
+
config USBIP_VHCI_HCD
tristate VHCI hcd
depends on