aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-02-22 14:15:59 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-02-22 14:15:59 -0500
commit8ff546b801e5cca0337c0f0a7234795d0a6309a1 (patch)
treefbda2c8e8e5aa9b82d389091f7945e28cdb67418 /tools
parentca78d3173cff3503bcd15723b049757f75762d15 (diff)
parent0df8a3dbacb585bb9c8b2e55de43c6aac9d86488 (diff)
Merge tag 'usb-4.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB/PHY updates from Greg KH: "Here is the big USB and PHY driver updates for 4.11-rc1. Nothing major, just the normal amount of churn in the usb gadget and dwc and xhci controllers, new device ids, new phy drivers, a new usb-serial driver, and a few other minor changes in different USB drivers. All have been in linux-next for a long time with no reported issues" * tag 'usb-4.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (265 commits) usb: cdc-wdm: remove logically dead code USB: serial: keyspan: drop header file USB: serial: io_edgeport: drop io-tables header file usb: musb: add code comment for clarification usb: misc: add USB251xB/xBi Hi-Speed Hub Controller Driver usb: misc: usbtest: remove redundant check on retval < 0 USB: serial: upd78f0730: sort device ids USB: serial: upd78f0730: add ID for EVAL-ADXL362Z ohci-hub: fix typo in dbg_port macro usb: musb: dsps: Manage CPPI 4.1 DMA interrupt in DSPS usb: musb: tusb6010: Clean up tusb_omap_dma structure usb: musb: cppi_dma: Clean up cppi41_dma_controller structure usb: musb: cppi_dma: Clean up cppi structure usb: musb: cppi41: Detect aborted transfers in cppi41_dma_callback() usb: musb: dma: Add a DMA completion platform callback drivers: usb: usbip: Add missing break statement to switch usb: mtu3: remove redundant dev_err call in get_ssusb_rscs() USB: serial: mos7840: fix another NULL-deref at open USB: serial: console: clean up sanity checks USB: serial: console: fix uninitialised spinlock ...
Diffstat (limited to 'tools')
-rw-r--r--tools/usb/ffs-test.c52
-rw-r--r--tools/usb/usbip/README57
-rwxr-xr-xtools/usb/usbip/vudc/vudc_server_example.sh107
3 files changed, 213 insertions, 3 deletions
diff --git a/tools/usb/ffs-test.c b/tools/usb/ffs-test.c
index 88d5e71be044..95dd14648ba5 100644
--- a/tools/usb/ffs-test.c
+++ b/tools/usb/ffs-test.c
@@ -22,7 +22,7 @@
22/* $(CROSS_COMPILE)cc -Wall -Wextra -g -o ffs-test ffs-test.c -lpthread */ 22/* $(CROSS_COMPILE)cc -Wall -Wextra -g -o ffs-test ffs-test.c -lpthread */
23 23
24 24
25#define _BSD_SOURCE /* for endian.h */ 25#define _DEFAULT_SOURCE /* for endian.h */
26 26
27#include <endian.h> 27#include <endian.h>
28#include <errno.h> 28#include <errno.h>
@@ -110,16 +110,25 @@ static const struct {
110 struct usb_functionfs_descs_head_v2 header; 110 struct usb_functionfs_descs_head_v2 header;
111 __le32 fs_count; 111 __le32 fs_count;
112 __le32 hs_count; 112 __le32 hs_count;
113 __le32 ss_count;
113 struct { 114 struct {
114 struct usb_interface_descriptor intf; 115 struct usb_interface_descriptor intf;
115 struct usb_endpoint_descriptor_no_audio sink; 116 struct usb_endpoint_descriptor_no_audio sink;
116 struct usb_endpoint_descriptor_no_audio source; 117 struct usb_endpoint_descriptor_no_audio source;
117 } __attribute__((packed)) fs_descs, hs_descs; 118 } __attribute__((packed)) fs_descs, hs_descs;
119 struct {
120 struct usb_interface_descriptor intf;
121 struct usb_endpoint_descriptor_no_audio sink;
122 struct usb_ss_ep_comp_descriptor sink_comp;
123 struct usb_endpoint_descriptor_no_audio source;
124 struct usb_ss_ep_comp_descriptor source_comp;
125 } ss_descs;
118} __attribute__((packed)) descriptors = { 126} __attribute__((packed)) descriptors = {
119 .header = { 127 .header = {
120 .magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2), 128 .magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2),
121 .flags = cpu_to_le32(FUNCTIONFS_HAS_FS_DESC | 129 .flags = cpu_to_le32(FUNCTIONFS_HAS_FS_DESC |
122 FUNCTIONFS_HAS_HS_DESC), 130 FUNCTIONFS_HAS_HS_DESC |
131 FUNCTIONFS_HAS_SS_DESC),
123 .length = cpu_to_le32(sizeof descriptors), 132 .length = cpu_to_le32(sizeof descriptors),
124 }, 133 },
125 .fs_count = cpu_to_le32(3), 134 .fs_count = cpu_to_le32(3),
@@ -171,6 +180,45 @@ static const struct {
171 .bInterval = 1, /* NAK every 1 uframe */ 180 .bInterval = 1, /* NAK every 1 uframe */
172 }, 181 },
173 }, 182 },
183 .ss_count = cpu_to_le32(5),
184 .ss_descs = {
185 .intf = {
186 .bLength = sizeof descriptors.fs_descs.intf,
187 .bDescriptorType = USB_DT_INTERFACE,
188 .bNumEndpoints = 2,
189 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
190 .iInterface = 1,
191 },
192 .sink = {
193 .bLength = sizeof descriptors.hs_descs.sink,
194 .bDescriptorType = USB_DT_ENDPOINT,
195 .bEndpointAddress = 1 | USB_DIR_IN,
196 .bmAttributes = USB_ENDPOINT_XFER_BULK,
197 .wMaxPacketSize = cpu_to_le16(1024),
198 },
199 .sink_comp = {
200 .bLength = USB_DT_SS_EP_COMP_SIZE,
201 .bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
202 .bMaxBurst = 0,
203 .bmAttributes = 0,
204 .wBytesPerInterval = 0,
205 },
206 .source = {
207 .bLength = sizeof descriptors.hs_descs.source,
208 .bDescriptorType = USB_DT_ENDPOINT,
209 .bEndpointAddress = 2 | USB_DIR_OUT,
210 .bmAttributes = USB_ENDPOINT_XFER_BULK,
211 .wMaxPacketSize = cpu_to_le16(1024),
212 .bInterval = 1, /* NAK every 1 uframe */
213 },
214 .source_comp = {
215 .bLength = USB_DT_SS_EP_COMP_SIZE,
216 .bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
217 .bMaxBurst = 0,
218 .bmAttributes = 0,
219 .wBytesPerInterval = 0,
220 },
221 },
174}; 222};
175 223
176static size_t descs_to_legacy(void **legacy, const void *descriptors_v2) 224static size_t descs_to_legacy(void **legacy, const void *descriptors_v2)
diff --git a/tools/usb/usbip/README b/tools/usb/usbip/README
index 831f49fea3ce..5eb2b6c7722b 100644
--- a/tools/usb/usbip/README
+++ b/tools/usb/usbip/README
@@ -4,10 +4,33 @@
4# Copyright (C) 2011 matt mooney <mfm@muteddisk.com> 4# Copyright (C) 2011 matt mooney <mfm@muteddisk.com>
5# 2005-2008 Takahiro Hirofuchi 5# 2005-2008 Takahiro Hirofuchi
6 6
7[Overview]
8USB/IP protocol allows to pass USB device from server to client over the
9network. Server is a machine which provides (shares) a USB device. Client is
10a machine which uses USB device provided by server over the network.
11The USB device may be either physical device connected to a server or
12software entity created on a server using USB gadget subsystem.
13Whole project consists of four parts:
14
15 - usbip-vhci
16 A client side kernel module which provides a virtual USB Host Controller
17 and allows to import a USB device from a remote machine.
18
19 - usbip-host (stub driver)
20 A server side module which provides a USB device driver which can be
21 bound to a physical USB device to make it exportable.
22
23 - usbip-vudc
24 A server side module which provides a virtual USB Device Controller and allows
25 to export a USB device created using USB Gadget Subsystem.
26
27 - usbip-utils
28 A set of userspace tools used to handle connection and management.
29 Used on both sides.
7 30
8[Requirements] 31[Requirements]
9 - USB/IP device drivers 32 - USB/IP device drivers
10 Found in the staging directory of the Linux kernel. 33 Found in the drivers/usb/usbip/ directory of the Linux kernel tree.
11 34
12 - libudev >= 2.0 35 - libudev >= 2.0
13 libudev library 36 libudev library
@@ -36,6 +59,10 @@
36 59
37 60
38[Usage] 61[Usage]
62On a server side there are two entities which can be shared.
63First of them is physical usb device connected to the machine.
64To make it available below steps should be executed:
65
39 server:# (Physically attach your USB device.) 66 server:# (Physically attach your USB device.)
40 67
41 server:# insmod usbip-core.ko 68 server:# insmod usbip-core.ko
@@ -52,6 +79,30 @@
52 - The USB device 1-2 is now exportable to other hosts! 79 - The USB device 1-2 is now exportable to other hosts!
53 - Use `usbip unbind --busid 1-2' to stop exporting the device. 80 - Use `usbip unbind --busid 1-2' to stop exporting the device.
54 81
82Second of shareable entities is USB Gadget created using USB Gadget Subsystem
83on a server machine. To make it available below steps should be executed:
84
85 server:# (Create your USB gadget)
86 - Currently the most preferable way of creating a new USB gadget
87 is ConfigFS Composite Gadget. Please refer to its documentation
88 for details.
89 - See vudc_server_example.sh for a short example of USB gadget creation
90
91 server:# insmod usbip-core.ko
92 server:# insmod usbip-vudc.ko
93 - To create more than one instance of vudc use num module param
94
95 server:# (Bind gadget to one of available vudc)
96 - Assign your new gadget to USB/IP UDC
97 - Using ConfigFS interface you may do this simply by:
98 server:# cd /sys/kernel/config/usb_gadget/<gadget_name>
99 server:# echo "usbip-vudc.0" > UDC
100
101 server:# usbipd -D --device
102 - Start usbip daemon.
103
104To attach new device to client machine below commands should be used:
105
55 client:# insmod usbip-core.ko 106 client:# insmod usbip-core.ko
56 client:# insmod vhci-hcd.ko 107 client:# insmod vhci-hcd.ko
57 108
@@ -60,6 +111,8 @@
60 111
61 client:# usbip attach --remote <host> --busid 1-2 112 client:# usbip attach --remote <host> --busid 1-2
62 - Connect the remote USB device. 113 - Connect the remote USB device.
114 - When using vudc on a server side busid is really vudc instance name.
115 For example: usbip-vudc.0
63 116
64 client:# usbip port 117 client:# usbip port
65 - Show virtual port status. 118 - Show virtual port status.
@@ -192,6 +245,8 @@ Detach the imported device:
192 - http://usbip.wiki.sourceforge.net/how-to-debug-usbip 245 - http://usbip.wiki.sourceforge.net/how-to-debug-usbip
193 - usbip-host.ko must be bound to the target device. 246 - usbip-host.ko must be bound to the target device.
194 - See /proc/bus/usb/devices and find "Driver=..." lines of the device. 247 - See /proc/bus/usb/devices and find "Driver=..." lines of the device.
248 - Target USB gadget must be bound to vudc
249 (using USB gadget susbsys, not usbip bind command)
195 - Shutdown firewall. 250 - Shutdown firewall.
196 - usbip now uses TCP port 3240. 251 - usbip now uses TCP port 3240.
197 - Disable SELinux. 252 - Disable SELinux.
diff --git a/tools/usb/usbip/vudc/vudc_server_example.sh b/tools/usb/usbip/vudc/vudc_server_example.sh
new file mode 100755
index 000000000000..2736be64f203
--- /dev/null
+++ b/tools/usb/usbip/vudc/vudc_server_example.sh
@@ -0,0 +1,107 @@
1#!/bin/bash
2
3################################################################################
4# This is free and unencumbered software released into the public domain.
5#
6# Anyone is free to copy, modify, publish, use, compile, sell, or
7# distribute this software, either in source code form or as a compiled
8# binary, for any purpose, commercial or non-commercial, and by any
9# means.
10#
11# In jurisdictions that recognize copyright laws, the author or authors
12# of this software dedicate any and all copyright interest in the
13# software to the public domain. We make this dedication for the benefit
14# of the public at large and to the detriment of our heirs and
15# successors. We intend this dedication to be an overt act of
16# relinquishment in perpetuity of all present and future rights to this
17# software under copyright law.
18#
19# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25# OTHER DEALINGS IN THE SOFTWARE.
26#
27# For more information, please refer to <http://unlicense.org/>
28################################################################################
29
30################################################################################
31# This is a sample script which shows how to use vUDC with ConfigFS gadgets
32################################################################################
33
34# Stop script on error
35set -e
36
37################################################################################
38# Create your USB gadget
39# You may use bare ConfigFS interface (as below)
40# or libusbgx or gt toool
41# Instead of ConfigFS gadgets you may use any of legacy gadgets.
42################################################################################
43CONFIGFS_MOUNT_POINT="/sys/kernel/config"
44GADGET_NAME="g1"
45ID_VENDOR="0x1d6b"
46ID_PRODUCT="0x0104"
47
48cd ${CONFIGFS_MOUNT_POINT}/usb_gadget
49# Create a new USB gadget
50mkdir ${GADGET_NAME}
51cd ${GADGET_NAME}
52
53# This gadget contains one function - ACM (serial port over USB)
54FUNC_DIR="functions/acm.ser0"
55mkdir ${FUNC_DIR}
56
57# Just one configuration
58mkdir configs/c.1
59ln -s ${FUNC_DIR} configs/c.1
60
61# Set our gadget identity
62echo ${ID_VENDOR} > idVendor
63echo ${ID_PRODUCT} > idProduct
64
65################################################################################
66# Load vudc-module if vudc is not available
67# You may change value of num param to get more than one vUDC instance
68################################################################################
69[[ -d /sys/class/udc/usbip-vudc.0 ]] || modprobe usbip-vudc num=1
70
71################################################################################
72# Bind gadget to our vUDC
73# By default we bind to first one but you may change this if you would like
74# to use more than one instance
75################################################################################
76echo "usbip-vudc.0" > UDC
77
78################################################################################
79# Let's now run our usbip daemon in a USB device mode
80################################################################################
81usbipd --device &
82
83################################################################################
84# Now your USB gadget is available using USB/IP protocol.
85# To prepare your client, you should ensure that usbip-vhci module is inside
86# your kernel. If it's not then you can load it:
87#
88# $ modprobe usbip-vhci
89#
90# To check availability of your gadget you may try to list devices exported
91# on a remote server:
92#
93# $ modprobe usbip-vhci
94# $ usbip list -r $SERVER_IP
95# Exportable USB devices
96# ======================
97# usbipd: info: request 0x8005(6): complete
98# - 127.0.0.1
99# usbip-vudc.0: Linux Foundation : unknown product (1d6b:0104)
100# : /sys/devices/platform/usbip-vudc.0
101# : (Defined at Interface level) (00/00/00)
102#
103# To attach this device to your client you may use:
104#
105# $ usbip attach -r $SERVER_IP -d usbip-vudc.0
106#
107################################################################################