]>
Commit | Line | Data |
---|---|---|
4324fd49 DB |
1 | /* |
2 | * CDC Ethernet based networking peripherals | |
3 | * Copyright (C) 2003-2005 by David Brownell | |
ad55d71a | 4 | * Copyright (C) 2006 by Ole Andre Vadla Ravnas (ActiveSync) |
4324fd49 DB |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 | */ | |
20 | ||
21 | // #define DEBUG // error path messages, extra info | |
22 | // #define VERBOSE // more; success messages | |
23 | ||
4324fd49 | 24 | #include <linux/module.h> |
4324fd49 DB |
25 | #include <linux/init.h> |
26 | #include <linux/netdevice.h> | |
27 | #include <linux/etherdevice.h> | |
4324fd49 DB |
28 | #include <linux/ethtool.h> |
29 | #include <linux/workqueue.h> | |
30 | #include <linux/mii.h> | |
31 | #include <linux/usb.h> | |
a8c28f23 | 32 | #include <linux/usb/cdc.h> |
3692e94f | 33 | #include <linux/usb/usbnet.h> |
4324fd49 DB |
34 | |
35 | ||
8857ec28 | 36 | #if IS_ENABLED(CONFIG_USB_NET_RNDIS_HOST) |
ad55d71a OAVR |
37 | |
38 | static int is_rndis(struct usb_interface_descriptor *desc) | |
39 | { | |
8e95a202 JP |
40 | return (desc->bInterfaceClass == USB_CLASS_COMM && |
41 | desc->bInterfaceSubClass == 2 && | |
42 | desc->bInterfaceProtocol == 0xff); | |
ad55d71a OAVR |
43 | } |
44 | ||
45 | static int is_activesync(struct usb_interface_descriptor *desc) | |
46 | { | |
8e95a202 JP |
47 | return (desc->bInterfaceClass == USB_CLASS_MISC && |
48 | desc->bInterfaceSubClass == 1 && | |
49 | desc->bInterfaceProtocol == 1); | |
ad55d71a OAVR |
50 | } |
51 | ||
7e99eedd TB |
52 | static int is_wireless_rndis(struct usb_interface_descriptor *desc) |
53 | { | |
8e95a202 JP |
54 | return (desc->bInterfaceClass == USB_CLASS_WIRELESS_CONTROLLER && |
55 | desc->bInterfaceSubClass == 1 && | |
56 | desc->bInterfaceProtocol == 3); | |
7e99eedd TB |
57 | } |
58 | ||
ad55d71a OAVR |
59 | #else |
60 | ||
61 | #define is_rndis(desc) 0 | |
62 | #define is_activesync(desc) 0 | |
7e99eedd | 63 | #define is_wireless_rndis(desc) 0 |
ad55d71a OAVR |
64 | |
65 | #endif | |
66 | ||
21851264 JS |
67 | static const u8 mbm_guid[16] = { |
68 | 0xa3, 0x17, 0xa8, 0x8b, 0x04, 0x5e, 0x4f, 0x01, | |
69 | 0xa6, 0x07, 0xc0, 0xff, 0xcb, 0x7e, 0x39, 0x2a, | |
70 | }; | |
71 | ||
8857ec28 | 72 | /* probes control interface, claims data interface, collects the bulk |
4324fd49 DB |
73 | * endpoints, activates data interface (if needed), maybe sets MTU. |
74 | * all pure cdc, except for certain firmware workarounds, and knowing | |
75 | * that rndis uses one different rule. | |
76 | */ | |
77 | int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf) | |
78 | { | |
79 | u8 *buf = intf->cur_altsetting->extra; | |
80 | int len = intf->cur_altsetting->extralen; | |
81 | struct usb_interface_descriptor *d; | |
82 | struct cdc_state *info = (void *) &dev->data; | |
83 | int status; | |
84 | int rndis; | |
6eddcb4c | 85 | bool android_rndis_quirk = false; |
4324fd49 | 86 | struct usb_driver *driver = driver_of(intf); |
21851264 JS |
87 | struct usb_cdc_mdlm_desc *desc = NULL; |
88 | struct usb_cdc_mdlm_detail_desc *detail = NULL; | |
4324fd49 | 89 | |
8857ec28 | 90 | if (sizeof(dev->data) < sizeof(*info)) |
4324fd49 DB |
91 | return -EDOM; |
92 | ||
93 | /* expect strict spec conformance for the descriptors, but | |
94 | * cope with firmware which stores them in the wrong place | |
95 | */ | |
96 | if (len == 0 && dev->udev->actconfig->extralen) { | |
97 | /* Motorola SB4100 (and others: Brad Hards says it's | |
98 | * from a Broadcom design) put CDC descriptors here | |
99 | */ | |
100 | buf = dev->udev->actconfig->extra; | |
101 | len = dev->udev->actconfig->extralen; | |
f5260f02 | 102 | dev_dbg(&intf->dev, "CDC descriptors on config\n"); |
4324fd49 DB |
103 | } |
104 | ||
4149b72e DB |
105 | /* Maybe CDC descriptors are after the endpoint? This bug has |
106 | * been seen on some 2Wire Inc RNDIS-ish products. | |
107 | */ | |
108 | if (len == 0) { | |
109 | struct usb_host_endpoint *hep; | |
110 | ||
111 | hep = intf->cur_altsetting->endpoint; | |
112 | if (hep) { | |
113 | buf = hep->extra; | |
114 | len = hep->extralen; | |
115 | } | |
116 | if (len) | |
117 | dev_dbg(&intf->dev, | |
118 | "CDC descriptors on endpoint\n"); | |
119 | } | |
120 | ||
4324fd49 DB |
121 | /* this assumes that if there's a non-RNDIS vendor variant |
122 | * of cdc-acm, it'll fail RNDIS requests cleanly. | |
123 | */ | |
8e95a202 JP |
124 | rndis = (is_rndis(&intf->cur_altsetting->desc) || |
125 | is_activesync(&intf->cur_altsetting->desc) || | |
126 | is_wireless_rndis(&intf->cur_altsetting->desc)); | |
4324fd49 | 127 | |
8857ec28 | 128 | memset(info, 0, sizeof(*info)); |
4324fd49 DB |
129 | info->control = intf; |
130 | while (len > 3) { | |
8857ec28 | 131 | if (buf[1] != USB_DT_CS_INTERFACE) |
4324fd49 DB |
132 | goto next_desc; |
133 | ||
134 | /* use bDescriptorSubType to identify the CDC descriptors. | |
135 | * We expect devices with CDC header and union descriptors. | |
136 | * For CDC Ethernet we need the ethernet descriptor. | |
137 | * For RNDIS, ignore two (pointless) CDC modem descriptors | |
138 | * in favor of a complicated OID-based RPC scheme doing what | |
139 | * CDC Ethernet achieves with a simple descriptor. | |
140 | */ | |
8857ec28 | 141 | switch (buf[2]) { |
4324fd49 DB |
142 | case USB_CDC_HEADER_TYPE: |
143 | if (info->header) { | |
144 | dev_dbg(&intf->dev, "extra CDC header\n"); | |
145 | goto bad_desc; | |
146 | } | |
147 | info->header = (void *) buf; | |
8857ec28 | 148 | if (info->header->bLength != sizeof(*info->header)) { |
4324fd49 DB |
149 | dev_dbg(&intf->dev, "CDC header len %u\n", |
150 | info->header->bLength); | |
151 | goto bad_desc; | |
152 | } | |
153 | break; | |
ad55d71a OAVR |
154 | case USB_CDC_ACM_TYPE: |
155 | /* paranoia: disambiguate a "real" vendor-specific | |
156 | * modem interface from an RNDIS non-modem. | |
157 | */ | |
158 | if (rndis) { | |
afaee82c | 159 | struct usb_cdc_acm_descriptor *acm; |
ad55d71a | 160 | |
afaee82c DB |
161 | acm = (void *) buf; |
162 | if (acm->bmCapabilities) { | |
ad55d71a OAVR |
163 | dev_dbg(&intf->dev, |
164 | "ACM capabilities %02x, " | |
165 | "not really RNDIS?\n", | |
afaee82c | 166 | acm->bmCapabilities); |
ad55d71a OAVR |
167 | goto bad_desc; |
168 | } | |
169 | } | |
170 | break; | |
4324fd49 DB |
171 | case USB_CDC_UNION_TYPE: |
172 | if (info->u) { | |
173 | dev_dbg(&intf->dev, "extra CDC union\n"); | |
174 | goto bad_desc; | |
175 | } | |
176 | info->u = (void *) buf; | |
8857ec28 | 177 | if (info->u->bLength != sizeof(*info->u)) { |
4324fd49 DB |
178 | dev_dbg(&intf->dev, "CDC union len %u\n", |
179 | info->u->bLength); | |
180 | goto bad_desc; | |
181 | } | |
182 | ||
183 | /* we need a master/control interface (what we're | |
184 | * probed with) and a slave/data interface; union | |
185 | * descriptors sort this all out. | |
186 | */ | |
187 | info->control = usb_ifnum_to_if(dev->udev, | |
188 | info->u->bMasterInterface0); | |
189 | info->data = usb_ifnum_to_if(dev->udev, | |
190 | info->u->bSlaveInterface0); | |
191 | if (!info->control || !info->data) { | |
192 | dev_dbg(&intf->dev, | |
193 | "master #%u/%p slave #%u/%p\n", | |
194 | info->u->bMasterInterface0, | |
195 | info->control, | |
196 | info->u->bSlaveInterface0, | |
197 | info->data); | |
6eddcb4c BM |
198 | /* fall back to hard-wiring for RNDIS */ |
199 | if (rndis) { | |
200 | android_rndis_quirk = true; | |
201 | goto next_desc; | |
202 | } | |
4324fd49 DB |
203 | goto bad_desc; |
204 | } | |
205 | if (info->control != intf) { | |
206 | dev_dbg(&intf->dev, "bogus CDC Union\n"); | |
207 | /* Ambit USB Cable Modem (and maybe others) | |
208 | * interchanges master and slave interface. | |
209 | */ | |
210 | if (info->data == intf) { | |
211 | info->data = info->control; | |
212 | info->control = intf; | |
213 | } else | |
214 | goto bad_desc; | |
215 | } | |
216 | ||
1fc4c84d BM |
217 | /* some devices merge these - skip class check */ |
218 | if (info->control == info->data) | |
219 | goto next_desc; | |
220 | ||
4324fd49 DB |
221 | /* a data interface altsetting does the real i/o */ |
222 | d = &info->data->cur_altsetting->desc; | |
223 | if (d->bInterfaceClass != USB_CLASS_CDC_DATA) { | |
224 | dev_dbg(&intf->dev, "slave class %u\n", | |
225 | d->bInterfaceClass); | |
226 | goto bad_desc; | |
227 | } | |
228 | break; | |
229 | case USB_CDC_ETHERNET_TYPE: | |
230 | if (info->ether) { | |
231 | dev_dbg(&intf->dev, "extra CDC ether\n"); | |
232 | goto bad_desc; | |
233 | } | |
234 | info->ether = (void *) buf; | |
8857ec28 | 235 | if (info->ether->bLength != sizeof(*info->ether)) { |
4324fd49 DB |
236 | dev_dbg(&intf->dev, "CDC ether len %u\n", |
237 | info->ether->bLength); | |
238 | goto bad_desc; | |
239 | } | |
240 | dev->hard_mtu = le16_to_cpu( | |
241 | info->ether->wMaxSegmentSize); | |
242 | /* because of Zaurus, we may be ignoring the host | |
243 | * side link address we were given. | |
244 | */ | |
245 | break; | |
21851264 JS |
246 | case USB_CDC_MDLM_TYPE: |
247 | if (desc) { | |
248 | dev_dbg(&intf->dev, "extra MDLM descriptor\n"); | |
249 | goto bad_desc; | |
250 | } | |
251 | ||
252 | desc = (void *)buf; | |
253 | ||
254 | if (desc->bLength != sizeof(*desc)) | |
255 | goto bad_desc; | |
256 | ||
257 | if (memcmp(&desc->bGUID, mbm_guid, 16)) | |
258 | goto bad_desc; | |
259 | break; | |
260 | case USB_CDC_MDLM_DETAIL_TYPE: | |
261 | if (detail) { | |
262 | dev_dbg(&intf->dev, "extra MDLM detail descriptor\n"); | |
263 | goto bad_desc; | |
264 | } | |
265 | ||
266 | detail = (void *)buf; | |
267 | ||
268 | if (detail->bGuidDescriptorType == 0) { | |
269 | if (detail->bLength < (sizeof(*detail) + 1)) | |
270 | goto bad_desc; | |
271 | } else | |
272 | goto bad_desc; | |
273 | break; | |
4324fd49 DB |
274 | } |
275 | next_desc: | |
8857ec28 FP |
276 | len -= buf[0]; /* bLength */ |
277 | buf += buf[0]; | |
4324fd49 DB |
278 | } |
279 | ||
786e3dfb BD |
280 | /* Microsoft ActiveSync based and some regular RNDIS devices lack the |
281 | * CDC descriptors, so we'll hard-wire the interfaces and not check | |
282 | * for descriptors. | |
6eddcb4c BM |
283 | * |
284 | * Some Android RNDIS devices have a CDC Union descriptor pointing | |
285 | * to non-existing interfaces. Ignore that and attempt the same | |
286 | * hard-wired 0 and 1 interfaces. | |
ad55d71a | 287 | */ |
6eddcb4c | 288 | if (rndis && (!info->u || android_rndis_quirk)) { |
ad55d71a OAVR |
289 | info->control = usb_ifnum_to_if(dev->udev, 0); |
290 | info->data = usb_ifnum_to_if(dev->udev, 1); | |
6eddcb4c | 291 | if (!info->control || !info->data || info->control != intf) { |
ad55d71a | 292 | dev_dbg(&intf->dev, |
786e3dfb | 293 | "rndis: master #0/%p slave #1/%p\n", |
ad55d71a OAVR |
294 | info->control, |
295 | info->data); | |
296 | goto bad_desc; | |
297 | } | |
298 | ||
299 | } else if (!info->header || !info->u || (!rndis && !info->ether)) { | |
4324fd49 DB |
300 | dev_dbg(&intf->dev, "missing cdc %s%s%sdescriptor\n", |
301 | info->header ? "" : "header ", | |
302 | info->u ? "" : "union ", | |
303 | info->ether ? "" : "ether "); | |
304 | goto bad_desc; | |
305 | } | |
306 | ||
307 | /* claim data interface and set it up ... with side effects. | |
308 | * network traffic can't flow until an altsetting is enabled. | |
309 | */ | |
1fc4c84d BM |
310 | if (info->data != info->control) { |
311 | status = usb_driver_claim_interface(driver, info->data, dev); | |
312 | if (status < 0) | |
313 | return status; | |
314 | } | |
4324fd49 DB |
315 | status = usbnet_get_endpoints(dev, info->data); |
316 | if (status < 0) { | |
317 | /* ensure immediate exit from usbnet_disconnect */ | |
318 | usb_set_intfdata(info->data, NULL); | |
1fc4c84d BM |
319 | if (info->data != info->control) |
320 | usb_driver_release_interface(driver, info->data); | |
4324fd49 DB |
321 | return status; |
322 | } | |
323 | ||
324 | /* status endpoint: optional for CDC Ethernet, not RNDIS (or ACM) */ | |
1fc4c84d BM |
325 | if (info->data != info->control) |
326 | dev->status = NULL; | |
4324fd49 DB |
327 | if (info->control->cur_altsetting->desc.bNumEndpoints == 1) { |
328 | struct usb_endpoint_descriptor *desc; | |
329 | ||
330 | dev->status = &info->control->cur_altsetting->endpoint [0]; | |
331 | desc = &dev->status->desc; | |
8e95a202 JP |
332 | if (!usb_endpoint_is_int_in(desc) || |
333 | (le16_to_cpu(desc->wMaxPacketSize) | |
334 | < sizeof(struct usb_cdc_notification)) || | |
335 | !desc->bInterval) { | |
4324fd49 DB |
336 | dev_dbg(&intf->dev, "bad notification endpoint\n"); |
337 | dev->status = NULL; | |
338 | } | |
339 | } | |
340 | if (rndis && !dev->status) { | |
341 | dev_dbg(&intf->dev, "missing RNDIS status endpoint\n"); | |
342 | usb_set_intfdata(info->data, NULL); | |
343 | usb_driver_release_interface(driver, info->data); | |
344 | return -ENODEV; | |
345 | } | |
346 | return 0; | |
347 | ||
348 | bad_desc: | |
349 | dev_info(&dev->udev->dev, "bad CDC descriptors\n"); | |
350 | return -ENODEV; | |
351 | } | |
352 | EXPORT_SYMBOL_GPL(usbnet_generic_cdc_bind); | |
353 | ||
354 | void usbnet_cdc_unbind(struct usbnet *dev, struct usb_interface *intf) | |
355 | { | |
356 | struct cdc_state *info = (void *) &dev->data; | |
357 | struct usb_driver *driver = driver_of(intf); | |
358 | ||
1fc4c84d BM |
359 | /* combined interface - nothing to do */ |
360 | if (info->data == info->control) | |
361 | return; | |
362 | ||
4324fd49 DB |
363 | /* disconnect master --> disconnect slave */ |
364 | if (intf == info->control && info->data) { | |
365 | /* ensure immediate exit from usbnet_disconnect */ | |
366 | usb_set_intfdata(info->data, NULL); | |
367 | usb_driver_release_interface(driver, info->data); | |
368 | info->data = NULL; | |
369 | } | |
370 | ||
371 | /* and vice versa (just in case) */ | |
372 | else if (intf == info->data && info->control) { | |
373 | /* ensure immediate exit from usbnet_disconnect */ | |
374 | usb_set_intfdata(info->control, NULL); | |
375 | usb_driver_release_interface(driver, info->control); | |
376 | info->control = NULL; | |
377 | } | |
378 | } | |
379 | EXPORT_SYMBOL_GPL(usbnet_cdc_unbind); | |
380 | ||
8857ec28 | 381 | /* Communications Device Class, Ethernet Control model |
4324fd49 DB |
382 | * |
383 | * Takes two interfaces. The DATA interface is inactive till an altsetting | |
384 | * is selected. Configuration data includes class descriptors. There's | |
385 | * an optional status endpoint on the control interface. | |
386 | * | |
387 | * This should interop with whatever the 2.4 "CDCEther.c" driver | |
388 | * (by Brad Hards) talked with, with more functionality. | |
8857ec28 | 389 | */ |
4324fd49 DB |
390 | |
391 | static void dumpspeed(struct usbnet *dev, __le32 *speeds) | |
392 | { | |
a475f603 JP |
393 | netif_info(dev, timer, dev->net, |
394 | "link speeds: %u kbps up, %u kbps down\n", | |
395 | __le32_to_cpu(speeds[0]) / 1000, | |
396 | __le32_to_cpu(speeds[1]) / 1000); | |
4324fd49 DB |
397 | } |
398 | ||
7a635ea9 | 399 | void usbnet_cdc_status(struct usbnet *dev, struct urb *urb) |
4324fd49 DB |
400 | { |
401 | struct usb_cdc_notification *event; | |
402 | ||
8857ec28 | 403 | if (urb->actual_length < sizeof(*event)) |
4324fd49 DB |
404 | return; |
405 | ||
406 | /* SPEED_CHANGE can get split into two 8-byte packets */ | |
407 | if (test_and_clear_bit(EVENT_STS_SPLIT, &dev->flags)) { | |
408 | dumpspeed(dev, (__le32 *) urb->transfer_buffer); | |
409 | return; | |
410 | } | |
411 | ||
412 | event = urb->transfer_buffer; | |
413 | switch (event->bNotificationType) { | |
414 | case USB_CDC_NOTIFY_NETWORK_CONNECTION: | |
a475f603 JP |
415 | netif_dbg(dev, timer, dev->net, "CDC: carrier %s\n", |
416 | event->wValue ? "on" : "off"); | |
a6bda459 | 417 | usbnet_link_change(dev, !!event->wValue, 0); |
4324fd49 DB |
418 | break; |
419 | case USB_CDC_NOTIFY_SPEED_CHANGE: /* tx/rx rates */ | |
a475f603 JP |
420 | netif_dbg(dev, timer, dev->net, "CDC: speed change (len %d)\n", |
421 | urb->actual_length); | |
8857ec28 | 422 | if (urb->actual_length != (sizeof(*event) + 8)) |
4324fd49 DB |
423 | set_bit(EVENT_STS_SPLIT, &dev->flags); |
424 | else | |
425 | dumpspeed(dev, (__le32 *) &event[1]); | |
426 | break; | |
427 | /* USB_CDC_NOTIFY_RESPONSE_AVAILABLE can happen too (e.g. RNDIS), | |
428 | * but there are no standard formats for the response data. | |
429 | */ | |
430 | default: | |
60b86755 JP |
431 | netdev_err(dev->net, "CDC: unexpected notification %02x!\n", |
432 | event->bNotificationType); | |
4324fd49 DB |
433 | break; |
434 | } | |
435 | } | |
7a635ea9 | 436 | EXPORT_SYMBOL_GPL(usbnet_cdc_status); |
4324fd49 | 437 | |
7a635ea9 | 438 | int usbnet_cdc_bind(struct usbnet *dev, struct usb_interface *intf) |
4324fd49 DB |
439 | { |
440 | int status; | |
441 | struct cdc_state *info = (void *) &dev->data; | |
442 | ||
d632eb1b GKH |
443 | BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data) |
444 | < sizeof(struct cdc_state))); | |
445 | ||
4324fd49 DB |
446 | status = usbnet_generic_cdc_bind(dev, intf); |
447 | if (status < 0) | |
448 | return status; | |
449 | ||
03ad032b | 450 | status = usbnet_get_ethernet_addr(dev, info->ether->iMACAddress); |
4324fd49 DB |
451 | if (status < 0) { |
452 | usb_set_intfdata(info->data, NULL); | |
453 | usb_driver_release_interface(driver_of(intf), info->data); | |
454 | return status; | |
455 | } | |
456 | ||
457 | /* FIXME cdc-ether has some multicast code too, though it complains | |
458 | * in routine cases. info->ether describes the multicast support. | |
459 | * Implement that here, manipulating the cdc filter as needed. | |
460 | */ | |
461 | return 0; | |
462 | } | |
7a635ea9 | 463 | EXPORT_SYMBOL_GPL(usbnet_cdc_bind); |
4324fd49 DB |
464 | |
465 | static const struct driver_info cdc_info = { | |
466 | .description = "CDC Ethernet Device", | |
c261344d | 467 | .flags = FLAG_ETHER | FLAG_POINTTOPOINT, |
7a635ea9 | 468 | .bind = usbnet_cdc_bind, |
4324fd49 | 469 | .unbind = usbnet_cdc_unbind, |
7a635ea9 | 470 | .status = usbnet_cdc_status, |
a5e40708 | 471 | .manage_power = usbnet_manage_power, |
4324fd49 DB |
472 | }; |
473 | ||
b3c914aa | 474 | static const struct driver_info wwan_info = { |
e1e499ee MH |
475 | .description = "Mobile Broadband Network Device", |
476 | .flags = FLAG_WWAN, | |
7a635ea9 | 477 | .bind = usbnet_cdc_bind, |
e1e499ee | 478 | .unbind = usbnet_cdc_unbind, |
7a635ea9 | 479 | .status = usbnet_cdc_status, |
a5e40708 | 480 | .manage_power = usbnet_manage_power, |
e1e499ee MH |
481 | }; |
482 | ||
4324fd49 DB |
483 | /*-------------------------------------------------------------------------*/ |
484 | ||
b3c914aa | 485 | #define HUAWEI_VENDOR_ID 0x12D1 |
4e6304b8 | 486 | #define NOVATEL_VENDOR_ID 0x1410 |
68d8318b | 487 | #define ZTE_VENDOR_ID 0x19D2 |
0370acd4 | 488 | #define DELL_VENDOR_ID 0x413C |
ac718b69 | 489 | #define REALTEK_VENDOR_ID 0x0bda |
4324fd49 | 490 | |
8857ec28 FP |
491 | static const struct usb_device_id products[] = { |
492 | /* BLACKLIST !! | |
4324fd49 DB |
493 | * |
494 | * First blacklist any products that are egregiously nonconformant | |
495 | * with the CDC Ethernet specs. Minor braindamage we cope with; when | |
496 | * they're not even trying, needing a separate driver is only the first | |
497 | * of the differences to show up. | |
498 | */ | |
499 | ||
500 | #define ZAURUS_MASTER_INTERFACE \ | |
501 | .bInterfaceClass = USB_CLASS_COMM, \ | |
502 | .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, \ | |
503 | .bInterfaceProtocol = USB_CDC_PROTO_NONE | |
504 | ||
505 | /* SA-1100 based Sharp Zaurus ("collie"), or compatible; | |
506 | * wire-incompatible with true CDC Ethernet implementations. | |
507 | * (And, it seems, needlessly so...) | |
508 | */ | |
509 | { | |
510 | .match_flags = USB_DEVICE_ID_MATCH_INT_INFO | |
511 | | USB_DEVICE_ID_MATCH_DEVICE, | |
512 | .idVendor = 0x04DD, | |
513 | .idProduct = 0x8004, | |
514 | ZAURUS_MASTER_INTERFACE, | |
515 | .driver_info = 0, | |
516 | }, | |
517 | ||
518 | /* PXA-25x based Sharp Zaurii. Note that it seems some of these | |
519 | * (later models especially) may have shipped only with firmware | |
520 | * advertising false "CDC MDLM" compatibility ... but we're not | |
521 | * clear which models did that, so for now let's assume the worst. | |
522 | */ | |
523 | { | |
524 | .match_flags = USB_DEVICE_ID_MATCH_INT_INFO | |
525 | | USB_DEVICE_ID_MATCH_DEVICE, | |
526 | .idVendor = 0x04DD, | |
527 | .idProduct = 0x8005, /* A-300 */ | |
528 | ZAURUS_MASTER_INTERFACE, | |
529 | .driver_info = 0, | |
530 | }, { | |
531 | .match_flags = USB_DEVICE_ID_MATCH_INT_INFO | |
532 | | USB_DEVICE_ID_MATCH_DEVICE, | |
533 | .idVendor = 0x04DD, | |
534 | .idProduct = 0x8006, /* B-500/SL-5600 */ | |
535 | ZAURUS_MASTER_INTERFACE, | |
536 | .driver_info = 0, | |
537 | }, { | |
538 | .match_flags = USB_DEVICE_ID_MATCH_INT_INFO | |
8857ec28 | 539 | | USB_DEVICE_ID_MATCH_DEVICE, |
4324fd49 DB |
540 | .idVendor = 0x04DD, |
541 | .idProduct = 0x8007, /* C-700 */ | |
542 | ZAURUS_MASTER_INTERFACE, | |
543 | .driver_info = 0, | |
544 | }, { | |
545 | .match_flags = USB_DEVICE_ID_MATCH_INT_INFO | |
546 | | USB_DEVICE_ID_MATCH_DEVICE, | |
547 | .idVendor = 0x04DD, | |
548 | .idProduct = 0x9031, /* C-750 C-760 */ | |
549 | ZAURUS_MASTER_INTERFACE, | |
550 | .driver_info = 0, | |
551 | }, { | |
552 | .match_flags = USB_DEVICE_ID_MATCH_INT_INFO | |
553 | | USB_DEVICE_ID_MATCH_DEVICE, | |
554 | .idVendor = 0x04DD, | |
555 | .idProduct = 0x9032, /* SL-6000 */ | |
556 | ZAURUS_MASTER_INTERFACE, | |
557 | .driver_info = 0, | |
558 | }, { | |
559 | .match_flags = USB_DEVICE_ID_MATCH_INT_INFO | |
560 | | USB_DEVICE_ID_MATCH_DEVICE, | |
561 | .idVendor = 0x04DD, | |
562 | /* reported with some C860 units */ | |
563 | .idProduct = 0x9050, /* C-860 */ | |
564 | ZAURUS_MASTER_INTERFACE, | |
565 | .driver_info = 0, | |
566 | }, | |
567 | ||
efcaa205 DB |
568 | /* Olympus has some models with a Zaurus-compatible option. |
569 | * R-1000 uses a FreeScale i.MXL cpu (ARMv4T) | |
570 | */ | |
571 | { | |
572 | .match_flags = USB_DEVICE_ID_MATCH_INT_INFO | |
573 | | USB_DEVICE_ID_MATCH_DEVICE, | |
574 | .idVendor = 0x07B4, | |
575 | .idProduct = 0x0F02, /* R-1000 */ | |
576 | ZAURUS_MASTER_INTERFACE, | |
577 | .driver_info = 0, | |
578 | }, | |
579 | ||
7a635ea9 AZ |
580 | /* LG Electronics VL600 wants additional headers on every frame */ |
581 | { | |
582 | USB_DEVICE_AND_INTERFACE_INFO(0x1004, 0x61aa, USB_CLASS_COMM, | |
583 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), | |
6d74eb94 | 584 | .driver_info = 0, |
7a635ea9 AZ |
585 | }, |
586 | ||
ee932bf9 ST |
587 | /* Logitech Harmony 900 - uses the pseudo-MDLM (BLAN) driver */ |
588 | { | |
589 | USB_DEVICE_AND_INTERFACE_INFO(0x046d, 0xc11f, USB_CLASS_COMM, | |
590 | USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), | |
591 | .driver_info = 0, | |
592 | }, | |
593 | ||
f8295ec2 DW |
594 | /* Novatel USB551L and MC551 - handled by qmi_wwan */ |
595 | { | |
c39ba1c2 DW |
596 | USB_DEVICE_AND_INTERFACE_INFO(NOVATEL_VENDOR_ID, 0xB001, USB_CLASS_COMM, |
597 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), | |
f8295ec2 DW |
598 | .driver_info = 0, |
599 | }, | |
600 | ||
601 | /* Novatel E362 - handled by qmi_wwan */ | |
602 | { | |
c39ba1c2 DW |
603 | USB_DEVICE_AND_INTERFACE_INFO(NOVATEL_VENDOR_ID, 0x9010, USB_CLASS_COMM, |
604 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), | |
f8295ec2 DW |
605 | .driver_info = 0, |
606 | }, | |
607 | ||
0370acd4 DW |
608 | /* Dell Wireless 5800 (Novatel E362) - handled by qmi_wwan */ |
609 | { | |
610 | USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, 0x8195, USB_CLASS_COMM, | |
611 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), | |
612 | .driver_info = 0, | |
613 | }, | |
614 | ||
615 | /* Dell Wireless 5800 (Novatel E362) - handled by qmi_wwan */ | |
616 | { | |
617 | USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, 0x8196, USB_CLASS_COMM, | |
618 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), | |
619 | .driver_info = 0, | |
620 | }, | |
621 | ||
7fdb7846 DW |
622 | /* Dell Wireless 5804 (Novatel E371) - handled by qmi_wwan */ |
623 | { | |
624 | USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, 0x819b, USB_CLASS_COMM, | |
625 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), | |
626 | .driver_info = 0, | |
627 | }, | |
628 | ||
45d213f5 DW |
629 | /* AnyDATA ADU960S - handled by qmi_wwan */ |
630 | { | |
631 | USB_DEVICE_AND_INTERFACE_INFO(0x16d5, 0x650a, USB_CLASS_COMM, | |
632 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), | |
633 | .driver_info = 0, | |
634 | }, | |
635 | ||
c2020be3 BM |
636 | /* Huawei E1820 - handled by qmi_wwan */ |
637 | { | |
638 | USB_DEVICE_INTERFACE_NUMBER(HUAWEI_VENDOR_ID, 0x14ac, 1), | |
639 | .driver_info = 0, | |
640 | }, | |
641 | ||
ac718b69 | 642 | /* Realtek RTL8152 Based USB 2.0 Ethernet Adapters */ |
ac718b69 | 643 | { |
644 | USB_DEVICE_AND_INTERFACE_INFO(REALTEK_VENDOR_ID, 0x8152, USB_CLASS_COMM, | |
645 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), | |
646 | .driver_info = 0, | |
647 | }, | |
c073f666 | 648 | |
649 | /* Realtek RTL8153 Based USB 3.0 Ethernet Adapters */ | |
650 | { | |
651 | USB_DEVICE_AND_INTERFACE_INFO(REALTEK_VENDOR_ID, 0x8153, USB_CLASS_COMM, | |
652 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), | |
653 | .driver_info = 0, | |
654 | }, | |
ac718b69 | 655 | |
8857ec28 | 656 | /* WHITELIST!!! |
4324fd49 DB |
657 | * |
658 | * CDC Ether uses two interfaces, not necessarily consecutive. | |
659 | * We match the main interface, ignoring the optional device | |
660 | * class so we could handle devices that aren't exclusively | |
661 | * CDC ether. | |
662 | * | |
663 | * NOTE: this match must come AFTER entries blacklisting devices | |
664 | * because of bugs/quirks in a given product (like Zaurus, above). | |
665 | */ | |
666 | { | |
68d8318b ABSS |
667 | /* ZTE (Vodafone) K3805-Z */ |
668 | .match_flags = USB_DEVICE_ID_MATCH_VENDOR | |
669 | | USB_DEVICE_ID_MATCH_PRODUCT | |
670 | | USB_DEVICE_ID_MATCH_INT_INFO, | |
671 | .idVendor = ZTE_VENDOR_ID, | |
672 | .idProduct = 0x1003, | |
673 | .bInterfaceClass = USB_CLASS_COMM, | |
674 | .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, | |
675 | .bInterfaceProtocol = USB_CDC_PROTO_NONE, | |
676 | .driver_info = (unsigned long)&wwan_info, | |
677 | }, { | |
678 | /* ZTE (Vodafone) K3806-Z */ | |
679 | .match_flags = USB_DEVICE_ID_MATCH_VENDOR | |
680 | | USB_DEVICE_ID_MATCH_PRODUCT | |
681 | | USB_DEVICE_ID_MATCH_INT_INFO, | |
682 | .idVendor = ZTE_VENDOR_ID, | |
683 | .idProduct = 0x1015, | |
684 | .bInterfaceClass = USB_CLASS_COMM, | |
685 | .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, | |
686 | .bInterfaceProtocol = USB_CDC_PROTO_NONE, | |
687 | .driver_info = (unsigned long)&wwan_info, | |
688 | }, { | |
689 | /* ZTE (Vodafone) K4510-Z */ | |
690 | .match_flags = USB_DEVICE_ID_MATCH_VENDOR | |
691 | | USB_DEVICE_ID_MATCH_PRODUCT | |
692 | | USB_DEVICE_ID_MATCH_INT_INFO, | |
693 | .idVendor = ZTE_VENDOR_ID, | |
694 | .idProduct = 0x1173, | |
695 | .bInterfaceClass = USB_CLASS_COMM, | |
696 | .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, | |
697 | .bInterfaceProtocol = USB_CDC_PROTO_NONE, | |
698 | .driver_info = (unsigned long)&wwan_info, | |
699 | }, { | |
700 | /* ZTE (Vodafone) K3770-Z */ | |
701 | .match_flags = USB_DEVICE_ID_MATCH_VENDOR | |
702 | | USB_DEVICE_ID_MATCH_PRODUCT | |
703 | | USB_DEVICE_ID_MATCH_INT_INFO, | |
704 | .idVendor = ZTE_VENDOR_ID, | |
705 | .idProduct = 0x1177, | |
706 | .bInterfaceClass = USB_CLASS_COMM, | |
707 | .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, | |
708 | .bInterfaceProtocol = USB_CDC_PROTO_NONE, | |
709 | .driver_info = (unsigned long)&wwan_info, | |
710 | }, { | |
711 | /* ZTE (Vodafone) K3772-Z */ | |
712 | .match_flags = USB_DEVICE_ID_MATCH_VENDOR | |
713 | | USB_DEVICE_ID_MATCH_PRODUCT | |
714 | | USB_DEVICE_ID_MATCH_INT_INFO, | |
715 | .idVendor = ZTE_VENDOR_ID, | |
716 | .idProduct = 0x1181, | |
717 | .bInterfaceClass = USB_CLASS_COMM, | |
718 | .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, | |
719 | .bInterfaceProtocol = USB_CDC_PROTO_NONE, | |
720 | .driver_info = (unsigned long)&wwan_info, | |
00928204 FP |
721 | }, { |
722 | /* Telit modules */ | |
723 | USB_VENDOR_AND_INTERFACE_INFO(0x1bc7, USB_CLASS_COMM, | |
724 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), | |
725 | .driver_info = (kernel_ulong_t) &wwan_info, | |
4e6304b8 | 726 | }, { |
4324fd49 DB |
727 | USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ETHERNET, |
728 | USB_CDC_PROTO_NONE), | |
729 | .driver_info = (unsigned long) &cdc_info, | |
cac477e8 | 730 | }, { |
21851264 JS |
731 | USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MDLM, |
732 | USB_CDC_PROTO_NONE), | |
b3c914aa | 733 | .driver_info = (unsigned long)&wwan_info, |
21851264 | 734 | |
b3c914aa DW |
735 | }, { |
736 | /* Various Huawei modems with a network port like the UMG1831 */ | |
737 | .match_flags = USB_DEVICE_ID_MATCH_VENDOR | |
738 | | USB_DEVICE_ID_MATCH_INT_INFO, | |
739 | .idVendor = HUAWEI_VENDOR_ID, | |
740 | .bInterfaceClass = USB_CLASS_COMM, | |
741 | .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, | |
742 | .bInterfaceProtocol = 255, | |
743 | .driver_info = (unsigned long)&wwan_info, | |
4324fd49 | 744 | }, |
8857ec28 | 745 | { }, /* END */ |
4324fd49 DB |
746 | }; |
747 | MODULE_DEVICE_TABLE(usb, products); | |
748 | ||
749 | static struct usb_driver cdc_driver = { | |
4324fd49 DB |
750 | .name = "cdc_ether", |
751 | .id_table = products, | |
752 | .probe = usbnet_probe, | |
753 | .disconnect = usbnet_disconnect, | |
754 | .suspend = usbnet_suspend, | |
755 | .resume = usbnet_resume, | |
7f515790 | 756 | .reset_resume = usbnet_resume, |
69ee472f | 757 | .supports_autosuspend = 1, |
e1f12eb6 | 758 | .disable_hub_initiated_lpm = 1, |
4324fd49 DB |
759 | }; |
760 | ||
d632eb1b | 761 | module_usb_driver(cdc_driver); |
4324fd49 DB |
762 | |
763 | MODULE_AUTHOR("David Brownell"); | |
764 | MODULE_DESCRIPTION("USB CDC Ethernet devices"); | |
765 | MODULE_LICENSE("GPL"); |