aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-04-04 20:55:35 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-04-04 20:55:35 -0400
commitac9053d2dcb9e8c3fa35ce458dfca8fddc141680 (patch)
tree3ffa30d58dac22ee0a80e2dd32f41b71da91132b /tools
parentf9ca6a561d40115696a54f16085c4edb17effc74 (diff)
parent5267c5e09c25e2ee6242b37833a9bdf9d97f54a2 (diff)
Merge tag 'usb-4.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB/PHY updates from Greg KH: "Here is the big set of USB and PHY driver patches for 4.17-rc1. Lots of USB typeC work happened this round, with code moving from the staging directory into the "real" part of the kernel, as well as new infrastructure being added to be able to handle the different types of "roles" that typeC requires. There is also the normal huge set of USB gadget controller and driver updates, along with XHCI changes, and a raft of other tiny fixes all over the USB tree. And the PHY driver updates are merged in here as well as they interacted with the USB drivers in some places. All of these have been in linux-next for a while with no reported issues" * tag 'usb-4.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (250 commits) Revert "USB: serial: ftdi_sio: add Id for Physik Instrumente E-870" usb: musb: gadget: misplaced out of bounds check usb: chipidea: imx: Fix ULPI on imx53 usb: chipidea: imx: Cleanup ci_hdrc_imx_platform_flag usb: chipidea: usbmisc: small clean up usb: chipidea: usbmisc: evdo can be set e/o reset usb: chipidea: usbmisc: evdo is only specific to OTG port USB: serial: ftdi_sio: add Id for Physik Instrumente E-870 usb: dwc3: gadget: never call ->complete() from ->ep_queue() usb: gadget: udc: core: update usb_ep_queue() documentation usb: host: Remove the deprecated ATH79 USB host config options usb: roles: Fix return value check in intel_xhci_usb_probe() USB: gadget: f_midi: fixing a possible double-free in f_midi usb: core: Add USB_QUIRK_DELAY_CTRL_MSG to usbcore quirks usb: core: Copy parameter string correctly and remove superfluous null check USB: announce bcdDevice as well as idVendor, idProduct. USB:fix USB3 devices behind USB3 hubs not resuming at hibernate thaw usb: hub: Reduce warning to notice on power loss USB: serial: ftdi_sio: add support for Harman FirmwareHubEmulator USB: serial: cp210x: add ELDAT Easywave RX09 id ...
Diffstat (limited to 'tools')
-rw-r--r--tools/usb/usbip/libsrc/usbip_common.c23
-rw-r--r--tools/usb/usbip/libsrc/usbip_common.h11
-rw-r--r--tools/usb/usbip/libsrc/usbip_host_common.c5
-rw-r--r--tools/usb/usbip/src/usbip_attach.c10
-rw-r--r--tools/usb/usbip/src/usbip_list.c6
-rw-r--r--tools/usb/usbip/src/usbip_network.c10
-rw-r--r--tools/usb/usbip/src/usbip_network.h6
-rw-r--r--tools/usb/usbip/src/usbipd.c34
8 files changed, 80 insertions, 25 deletions
diff --git a/tools/usb/usbip/libsrc/usbip_common.c b/tools/usb/usbip/libsrc/usbip_common.c
index 001bb8e8f668..bb424638d75b 100644
--- a/tools/usb/usbip/libsrc/usbip_common.c
+++ b/tools/usb/usbip/libsrc/usbip_common.c
@@ -66,6 +66,29 @@ const char *usbip_speed_string(int num)
66 return "Unknown Speed"; 66 return "Unknown Speed";
67} 67}
68 68
69struct op_common_status_string {
70 int num;
71 char *desc;
72};
73
74static struct op_common_status_string op_common_status_strings[] = {
75 { ST_OK, "Request Completed Successfully" },
76 { ST_NA, "Request Failed" },
77 { ST_DEV_BUSY, "Device busy (exported)" },
78 { ST_DEV_ERR, "Device in error state" },
79 { ST_NODEV, "Device not found" },
80 { ST_ERROR, "Unexpected response" },
81 { 0, NULL}
82};
83
84const char *usbip_op_common_status_string(int status)
85{
86 for (int i = 0; op_common_status_strings[i].desc != NULL; i++)
87 if (op_common_status_strings[i].num == status)
88 return op_common_status_strings[i].desc;
89
90 return "Unknown Op Common Status";
91}
69 92
70#define DBG_UDEV_INTEGER(name)\ 93#define DBG_UDEV_INTEGER(name)\
71 dbg("%-20s = %x", to_string(name), (int) udev->name) 94 dbg("%-20s = %x", to_string(name), (int) udev->name)
diff --git a/tools/usb/usbip/libsrc/usbip_common.h b/tools/usb/usbip/libsrc/usbip_common.h
index e45ec9d2fdbc..73a367a7fa10 100644
--- a/tools/usb/usbip/libsrc/usbip_common.h
+++ b/tools/usb/usbip/libsrc/usbip_common.h
@@ -43,6 +43,16 @@
43#define SYSFS_PATH_MAX 256 43#define SYSFS_PATH_MAX 256
44#define SYSFS_BUS_ID_SIZE 32 44#define SYSFS_BUS_ID_SIZE 32
45 45
46/* Defines for op_code status in server/client op_common PDUs */
47#define ST_OK 0x00
48#define ST_NA 0x01
49 /* Device requested for import is not available */
50#define ST_DEV_BUSY 0x02
51 /* Device requested for import is in error state */
52#define ST_DEV_ERR 0x03
53#define ST_NODEV 0x04
54#define ST_ERROR 0x05
55
46extern int usbip_use_syslog; 56extern int usbip_use_syslog;
47extern int usbip_use_stderr; 57extern int usbip_use_stderr;
48extern int usbip_use_debug ; 58extern int usbip_use_debug ;
@@ -130,6 +140,7 @@ int read_usb_interface(struct usbip_usb_device *udev, int i,
130 140
131const char *usbip_speed_string(int num); 141const char *usbip_speed_string(int num);
132const char *usbip_status_string(int32_t status); 142const char *usbip_status_string(int32_t status);
143const char *usbip_op_common_status_string(int status);
133 144
134int usbip_names_init(char *); 145int usbip_names_init(char *);
135void usbip_names_free(void); 146void usbip_names_free(void);
diff --git a/tools/usb/usbip/libsrc/usbip_host_common.c b/tools/usb/usbip/libsrc/usbip_host_common.c
index 6ff7b601f854..dc93fadbee96 100644
--- a/tools/usb/usbip/libsrc/usbip_host_common.c
+++ b/tools/usb/usbip/libsrc/usbip_host_common.c
@@ -234,14 +234,17 @@ int usbip_export_device(struct usbip_exported_device *edev, int sockfd)
234 switch (edev->status) { 234 switch (edev->status) {
235 case SDEV_ST_ERROR: 235 case SDEV_ST_ERROR:
236 dbg("status SDEV_ST_ERROR"); 236 dbg("status SDEV_ST_ERROR");
237 ret = ST_DEV_ERR;
237 break; 238 break;
238 case SDEV_ST_USED: 239 case SDEV_ST_USED:
239 dbg("status SDEV_ST_USED"); 240 dbg("status SDEV_ST_USED");
241 ret = ST_DEV_BUSY;
240 break; 242 break;
241 default: 243 default:
242 dbg("status unknown: 0x%x", edev->status); 244 dbg("status unknown: 0x%x", edev->status);
245 ret = -1;
243 } 246 }
244 return -1; 247 return ret;
245 } 248 }
246 249
247 /* only the first interface is true */ 250 /* only the first interface is true */
diff --git a/tools/usb/usbip/src/usbip_attach.c b/tools/usb/usbip/src/usbip_attach.c
index 7f07b2d50f59..ba88728483ff 100644
--- a/tools/usb/usbip/src/usbip_attach.c
+++ b/tools/usb/usbip/src/usbip_attach.c
@@ -135,6 +135,7 @@ static int query_import_device(int sockfd, char *busid)
135 struct op_import_request request; 135 struct op_import_request request;
136 struct op_import_reply reply; 136 struct op_import_reply reply;
137 uint16_t code = OP_REP_IMPORT; 137 uint16_t code = OP_REP_IMPORT;
138 int status;
138 139
139 memset(&request, 0, sizeof(request)); 140 memset(&request, 0, sizeof(request));
140 memset(&reply, 0, sizeof(reply)); 141 memset(&reply, 0, sizeof(reply));
@@ -157,9 +158,10 @@ static int query_import_device(int sockfd, char *busid)
157 } 158 }
158 159
159 /* receive a reply */ 160 /* receive a reply */
160 rc = usbip_net_recv_op_common(sockfd, &code); 161 rc = usbip_net_recv_op_common(sockfd, &code, &status);
161 if (rc < 0) { 162 if (rc < 0) {
162 err("recv op_common"); 163 err("Attach Request for %s failed - %s\n",
164 busid, usbip_op_common_status_string(status));
163 return -1; 165 return -1;
164 } 166 }
165 167
@@ -194,10 +196,8 @@ static int attach_device(char *host, char *busid)
194 } 196 }
195 197
196 rhport = query_import_device(sockfd, busid); 198 rhport = query_import_device(sockfd, busid);
197 if (rhport < 0) { 199 if (rhport < 0)
198 err("query");
199 return -1; 200 return -1;
200 }
201 201
202 close(sockfd); 202 close(sockfd);
203 203
diff --git a/tools/usb/usbip/src/usbip_list.c b/tools/usb/usbip/src/usbip_list.c
index d65a9f444174..8d4ccf4b9480 100644
--- a/tools/usb/usbip/src/usbip_list.c
+++ b/tools/usb/usbip/src/usbip_list.c
@@ -62,6 +62,7 @@ static int get_exported_devices(char *host, int sockfd)
62 struct usbip_usb_interface uintf; 62 struct usbip_usb_interface uintf;
63 unsigned int i; 63 unsigned int i;
64 int rc, j; 64 int rc, j;
65 int status;
65 66
66 rc = usbip_net_send_op_common(sockfd, OP_REQ_DEVLIST, 0); 67 rc = usbip_net_send_op_common(sockfd, OP_REQ_DEVLIST, 0);
67 if (rc < 0) { 68 if (rc < 0) {
@@ -69,9 +70,10 @@ static int get_exported_devices(char *host, int sockfd)
69 return -1; 70 return -1;
70 } 71 }
71 72
72 rc = usbip_net_recv_op_common(sockfd, &code); 73 rc = usbip_net_recv_op_common(sockfd, &code, &status);
73 if (rc < 0) { 74 if (rc < 0) {
74 dbg("usbip_net_recv_op_common failed"); 75 err("Exported Device List Request failed - %s\n",
76 usbip_op_common_status_string(status));
75 return -1; 77 return -1;
76 } 78 }
77 79
diff --git a/tools/usb/usbip/src/usbip_network.c b/tools/usb/usbip/src/usbip_network.c
index b4c37e76a6e0..8ffcd47d9638 100644
--- a/tools/usb/usbip/src/usbip_network.c
+++ b/tools/usb/usbip/src/usbip_network.c
@@ -163,7 +163,7 @@ int usbip_net_send_op_common(int sockfd, uint32_t code, uint32_t status)
163 return 0; 163 return 0;
164} 164}
165 165
166int usbip_net_recv_op_common(int sockfd, uint16_t *code) 166int usbip_net_recv_op_common(int sockfd, uint16_t *code, int *status)
167{ 167{
168 struct op_common op_common; 168 struct op_common op_common;
169 int rc; 169 int rc;
@@ -179,8 +179,8 @@ int usbip_net_recv_op_common(int sockfd, uint16_t *code)
179 PACK_OP_COMMON(0, &op_common); 179 PACK_OP_COMMON(0, &op_common);
180 180
181 if (op_common.version != USBIP_VERSION) { 181 if (op_common.version != USBIP_VERSION) {
182 dbg("version mismatch: %d %d", op_common.version, 182 err("USBIP Kernel and tool version mismatch: %d %d:",
183 USBIP_VERSION); 183 op_common.version, USBIP_VERSION);
184 goto err; 184 goto err;
185 } 185 }
186 186
@@ -191,10 +191,14 @@ int usbip_net_recv_op_common(int sockfd, uint16_t *code)
191 if (op_common.code != *code) { 191 if (op_common.code != *code) {
192 dbg("unexpected pdu %#0x for %#0x", op_common.code, 192 dbg("unexpected pdu %#0x for %#0x", op_common.code,
193 *code); 193 *code);
194 /* return error status */
195 *status = ST_ERROR;
194 goto err; 196 goto err;
195 } 197 }
196 } 198 }
197 199
200 *status = op_common.status;
201
198 if (op_common.status != ST_OK) { 202 if (op_common.status != ST_OK) {
199 dbg("request failed at peer: %d", op_common.status); 203 dbg("request failed at peer: %d", op_common.status);
200 goto err; 204 goto err;
diff --git a/tools/usb/usbip/src/usbip_network.h b/tools/usb/usbip/src/usbip_network.h
index 7032687621d3..555215eae43e 100644
--- a/tools/usb/usbip/src/usbip_network.h
+++ b/tools/usb/usbip/src/usbip_network.h
@@ -27,9 +27,7 @@ struct op_common {
27#define OP_REPLY (0x00 << 8) 27#define OP_REPLY (0x00 << 8)
28 uint16_t code; 28 uint16_t code;
29 29
30 /* add more error code */ 30 /* status codes defined in usbip_common.h */
31#define ST_OK 0x00
32#define ST_NA 0x01
33 uint32_t status; /* op_code status (for reply) */ 31 uint32_t status; /* op_code status (for reply) */
34 32
35} __attribute__((packed)); 33} __attribute__((packed));
@@ -176,7 +174,7 @@ void usbip_net_pack_usb_interface(int pack, struct usbip_usb_interface *uinf);
176ssize_t usbip_net_recv(int sockfd, void *buff, size_t bufflen); 174ssize_t usbip_net_recv(int sockfd, void *buff, size_t bufflen);
177ssize_t usbip_net_send(int sockfd, void *buff, size_t bufflen); 175ssize_t usbip_net_send(int sockfd, void *buff, size_t bufflen);
178int usbip_net_send_op_common(int sockfd, uint32_t code, uint32_t status); 176int usbip_net_send_op_common(int sockfd, uint32_t code, uint32_t status);
179int usbip_net_recv_op_common(int sockfd, uint16_t *code); 177int usbip_net_recv_op_common(int sockfd, uint16_t *code, int *status);
180int usbip_net_set_reuseaddr(int sockfd); 178int usbip_net_set_reuseaddr(int sockfd);
181int usbip_net_set_nodelay(int sockfd); 179int usbip_net_set_nodelay(int sockfd);
182int usbip_net_set_keepalive(int sockfd); 180int usbip_net_set_keepalive(int sockfd);
diff --git a/tools/usb/usbip/src/usbipd.c b/tools/usb/usbip/src/usbipd.c
index c6dad2a13c80..32864c52942d 100644
--- a/tools/usb/usbip/src/usbipd.c
+++ b/tools/usb/usbip/src/usbipd.c
@@ -107,7 +107,7 @@ static int recv_request_import(int sockfd)
107 struct usbip_usb_device pdu_udev; 107 struct usbip_usb_device pdu_udev;
108 struct list_head *i; 108 struct list_head *i;
109 int found = 0; 109 int found = 0;
110 int error = 0; 110 int status = ST_OK;
111 int rc; 111 int rc;
112 112
113 memset(&req, 0, sizeof(req)); 113 memset(&req, 0, sizeof(req));
@@ -133,22 +133,21 @@ static int recv_request_import(int sockfd)
133 usbip_net_set_nodelay(sockfd); 133 usbip_net_set_nodelay(sockfd);
134 134
135 /* export device needs a TCP/IP socket descriptor */ 135 /* export device needs a TCP/IP socket descriptor */
136 rc = usbip_export_device(edev, sockfd); 136 status = usbip_export_device(edev, sockfd);
137 if (rc < 0) 137 if (status < 0)
138 error = 1; 138 status = ST_NA;
139 } else { 139 } else {
140 info("requested device not found: %s", req.busid); 140 info("requested device not found: %s", req.busid);
141 error = 1; 141 status = ST_NODEV;
142 } 142 }
143 143
144 rc = usbip_net_send_op_common(sockfd, OP_REP_IMPORT, 144 rc = usbip_net_send_op_common(sockfd, OP_REP_IMPORT, status);
145 (!error ? ST_OK : ST_NA));
146 if (rc < 0) { 145 if (rc < 0) {
147 dbg("usbip_net_send_op_common failed: %#0x", OP_REP_IMPORT); 146 dbg("usbip_net_send_op_common failed: %#0x", OP_REP_IMPORT);
148 return -1; 147 return -1;
149 } 148 }
150 149
151 if (error) { 150 if (status) {
152 dbg("import request busid %s: failed", req.busid); 151 dbg("import request busid %s: failed", req.busid);
153 return -1; 152 return -1;
154 } 153 }
@@ -176,10 +175,21 @@ static int send_reply_devlist(int connfd)
176 struct list_head *j; 175 struct list_head *j;
177 int rc, i; 176 int rc, i;
178 177
178 /*
179 * Exclude devices that are already exported to a client from
180 * the exportable device list to avoid:
181 * - import requests for devices that are exported only to
182 * fail the request.
183 * - revealing devices that are imported by a client to
184 * another client.
185 */
186
179 reply.ndev = 0; 187 reply.ndev = 0;
180 /* number of exported devices */ 188 /* number of exported devices */
181 list_for_each(j, &driver->edev_list) { 189 list_for_each(j, &driver->edev_list) {
182 reply.ndev += 1; 190 edev = list_entry(j, struct usbip_exported_device, node);
191 if (edev->status != SDEV_ST_USED)
192 reply.ndev += 1;
183 } 193 }
184 info("exportable devices: %d", reply.ndev); 194 info("exportable devices: %d", reply.ndev);
185 195
@@ -198,6 +208,9 @@ static int send_reply_devlist(int connfd)
198 208
199 list_for_each(j, &driver->edev_list) { 209 list_for_each(j, &driver->edev_list) {
200 edev = list_entry(j, struct usbip_exported_device, node); 210 edev = list_entry(j, struct usbip_exported_device, node);
211 if (edev->status == SDEV_ST_USED)
212 continue;
213
201 dump_usb_device(&edev->udev); 214 dump_usb_device(&edev->udev);
202 memcpy(&pdu_udev, &edev->udev, sizeof(pdu_udev)); 215 memcpy(&pdu_udev, &edev->udev, sizeof(pdu_udev));
203 usbip_net_pack_usb_device(1, &pdu_udev); 216 usbip_net_pack_usb_device(1, &pdu_udev);
@@ -251,8 +264,9 @@ static int recv_pdu(int connfd)
251{ 264{
252 uint16_t code = OP_UNSPEC; 265 uint16_t code = OP_UNSPEC;
253 int ret; 266 int ret;
267 int status;
254 268
255 ret = usbip_net_recv_op_common(connfd, &code); 269 ret = usbip_net_recv_op_common(connfd, &code, &status);
256 if (ret < 0) { 270 if (ret < 0) {
257 dbg("could not receive opcode: %#0x", code); 271 dbg("could not receive opcode: %#0x", code);
258 return -1; 272 return -1;