Merge tag 'stable/for-linus-3.13-rc0-tag' of git://git.kernel.org/pub/scm/linux/kerne...
[deliverable/linux.git] / drivers / net / usb / cdc_ether.c
1 /*
2 * CDC Ethernet based networking peripherals
3 * Copyright (C) 2003-2005 by David Brownell
4 * Copyright (C) 2006 by Ole Andre Vadla Ravnas (ActiveSync)
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
24 #include <linux/module.h>
25 #include <linux/init.h>
26 #include <linux/netdevice.h>
27 #include <linux/etherdevice.h>
28 #include <linux/ethtool.h>
29 #include <linux/workqueue.h>
30 #include <linux/mii.h>
31 #include <linux/usb.h>
32 #include <linux/usb/cdc.h>
33 #include <linux/usb/usbnet.h>
34
35
36 #if IS_ENABLED(CONFIG_USB_NET_RNDIS_HOST)
37
38 static int is_rndis(struct usb_interface_descriptor *desc)
39 {
40 return (desc->bInterfaceClass == USB_CLASS_COMM &&
41 desc->bInterfaceSubClass == 2 &&
42 desc->bInterfaceProtocol == 0xff);
43 }
44
45 static int is_activesync(struct usb_interface_descriptor *desc)
46 {
47 return (desc->bInterfaceClass == USB_CLASS_MISC &&
48 desc->bInterfaceSubClass == 1 &&
49 desc->bInterfaceProtocol == 1);
50 }
51
52 static int is_wireless_rndis(struct usb_interface_descriptor *desc)
53 {
54 return (desc->bInterfaceClass == USB_CLASS_WIRELESS_CONTROLLER &&
55 desc->bInterfaceSubClass == 1 &&
56 desc->bInterfaceProtocol == 3);
57 }
58
59 #else
60
61 #define is_rndis(desc) 0
62 #define is_activesync(desc) 0
63 #define is_wireless_rndis(desc) 0
64
65 #endif
66
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
72 /* probes control interface, claims data interface, collects the bulk
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;
85 bool android_rndis_quirk = false;
86 struct usb_driver *driver = driver_of(intf);
87 struct usb_cdc_mdlm_desc *desc = NULL;
88 struct usb_cdc_mdlm_detail_desc *detail = NULL;
89
90 if (sizeof(dev->data) < sizeof(*info))
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;
102 dev_dbg(&intf->dev, "CDC descriptors on config\n");
103 }
104
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
121 /* this assumes that if there's a non-RNDIS vendor variant
122 * of cdc-acm, it'll fail RNDIS requests cleanly.
123 */
124 rndis = (is_rndis(&intf->cur_altsetting->desc) ||
125 is_activesync(&intf->cur_altsetting->desc) ||
126 is_wireless_rndis(&intf->cur_altsetting->desc));
127
128 memset(info, 0, sizeof(*info));
129 info->control = intf;
130 while (len > 3) {
131 if (buf[1] != USB_DT_CS_INTERFACE)
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 */
141 switch (buf[2]) {
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;
148 if (info->header->bLength != sizeof(*info->header)) {
149 dev_dbg(&intf->dev, "CDC header len %u\n",
150 info->header->bLength);
151 goto bad_desc;
152 }
153 break;
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) {
159 struct usb_cdc_acm_descriptor *acm;
160
161 acm = (void *) buf;
162 if (acm->bmCapabilities) {
163 dev_dbg(&intf->dev,
164 "ACM capabilities %02x, "
165 "not really RNDIS?\n",
166 acm->bmCapabilities);
167 goto bad_desc;
168 }
169 }
170 break;
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;
177 if (info->u->bLength != sizeof(*info->u)) {
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);
198 /* fall back to hard-wiring for RNDIS */
199 if (rndis) {
200 android_rndis_quirk = true;
201 goto next_desc;
202 }
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
217 /* some devices merge these - skip class check */
218 if (info->control == info->data)
219 goto next_desc;
220
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;
235 if (info->ether->bLength != sizeof(*info->ether)) {
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;
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;
274 }
275 next_desc:
276 len -= buf[0]; /* bLength */
277 buf += buf[0];
278 }
279
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.
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.
287 */
288 if (rndis && (!info->u || android_rndis_quirk)) {
289 info->control = usb_ifnum_to_if(dev->udev, 0);
290 info->data = usb_ifnum_to_if(dev->udev, 1);
291 if (!info->control || !info->data || info->control != intf) {
292 dev_dbg(&intf->dev,
293 "rndis: master #0/%p slave #1/%p\n",
294 info->control,
295 info->data);
296 goto bad_desc;
297 }
298
299 } else if (!info->header || !info->u || (!rndis && !info->ether)) {
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 */
310 if (info->data != info->control) {
311 status = usb_driver_claim_interface(driver, info->data, dev);
312 if (status < 0)
313 return status;
314 }
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);
319 if (info->data != info->control)
320 usb_driver_release_interface(driver, info->data);
321 return status;
322 }
323
324 /* status endpoint: optional for CDC Ethernet, not RNDIS (or ACM) */
325 if (info->data != info->control)
326 dev->status = NULL;
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;
332 if (!usb_endpoint_is_int_in(desc) ||
333 (le16_to_cpu(desc->wMaxPacketSize)
334 < sizeof(struct usb_cdc_notification)) ||
335 !desc->bInterval) {
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
359 /* combined interface - nothing to do */
360 if (info->data == info->control)
361 return;
362
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
381 /* Communications Device Class, Ethernet Control model
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.
389 */
390
391 static void dumpspeed(struct usbnet *dev, __le32 *speeds)
392 {
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);
397 }
398
399 void usbnet_cdc_status(struct usbnet *dev, struct urb *urb)
400 {
401 struct usb_cdc_notification *event;
402
403 if (urb->actual_length < sizeof(*event))
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:
415 netif_dbg(dev, timer, dev->net, "CDC: carrier %s\n",
416 event->wValue ? "on" : "off");
417 usbnet_link_change(dev, !!event->wValue, 0);
418 break;
419 case USB_CDC_NOTIFY_SPEED_CHANGE: /* tx/rx rates */
420 netif_dbg(dev, timer, dev->net, "CDC: speed change (len %d)\n",
421 urb->actual_length);
422 if (urb->actual_length != (sizeof(*event) + 8))
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:
431 netdev_err(dev->net, "CDC: unexpected notification %02x!\n",
432 event->bNotificationType);
433 break;
434 }
435 }
436 EXPORT_SYMBOL_GPL(usbnet_cdc_status);
437
438 int usbnet_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
439 {
440 int status;
441 struct cdc_state *info = (void *) &dev->data;
442
443 BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data)
444 < sizeof(struct cdc_state)));
445
446 status = usbnet_generic_cdc_bind(dev, intf);
447 if (status < 0)
448 return status;
449
450 status = usbnet_get_ethernet_addr(dev, info->ether->iMACAddress);
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 }
463 EXPORT_SYMBOL_GPL(usbnet_cdc_bind);
464
465 static const struct driver_info cdc_info = {
466 .description = "CDC Ethernet Device",
467 .flags = FLAG_ETHER | FLAG_POINTTOPOINT,
468 .bind = usbnet_cdc_bind,
469 .unbind = usbnet_cdc_unbind,
470 .status = usbnet_cdc_status,
471 .manage_power = usbnet_manage_power,
472 };
473
474 static const struct driver_info wwan_info = {
475 .description = "Mobile Broadband Network Device",
476 .flags = FLAG_WWAN,
477 .bind = usbnet_cdc_bind,
478 .unbind = usbnet_cdc_unbind,
479 .status = usbnet_cdc_status,
480 .manage_power = usbnet_manage_power,
481 };
482
483 /*-------------------------------------------------------------------------*/
484
485 #define HUAWEI_VENDOR_ID 0x12D1
486 #define NOVATEL_VENDOR_ID 0x1410
487 #define ZTE_VENDOR_ID 0x19D2
488 #define DELL_VENDOR_ID 0x413C
489 #define REALTEK_VENDOR_ID 0x0bda
490
491 static const struct usb_device_id products[] = {
492 /* BLACKLIST !!
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
539 | USB_DEVICE_ID_MATCH_DEVICE,
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
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
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),
584 .driver_info = 0,
585 },
586
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
594 /* Novatel USB551L and MC551 - handled by qmi_wwan */
595 {
596 USB_DEVICE_AND_INTERFACE_INFO(NOVATEL_VENDOR_ID, 0xB001, USB_CLASS_COMM,
597 USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
598 .driver_info = 0,
599 },
600
601 /* Novatel E362 - handled by qmi_wwan */
602 {
603 USB_DEVICE_AND_INTERFACE_INFO(NOVATEL_VENDOR_ID, 0x9010, USB_CLASS_COMM,
604 USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
605 .driver_info = 0,
606 },
607
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
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
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
636 /* Huawei E1820 - handled by qmi_wwan */
637 {
638 USB_DEVICE_INTERFACE_NUMBER(HUAWEI_VENDOR_ID, 0x14ac, 1),
639 .driver_info = 0,
640 },
641
642 /* Realtek RTL8152 Based USB 2.0 Ethernet Adapters */
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 },
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 },
655
656 /* WHITELIST!!!
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 {
667 /* ZTE (Vodafone) K3805-Z */
668 USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1003, USB_CLASS_COMM,
669 USB_CDC_SUBCLASS_ETHERNET,
670 USB_CDC_PROTO_NONE),
671 .driver_info = (unsigned long)&wwan_info,
672 }, {
673 /* ZTE (Vodafone) K3806-Z */
674 USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1015, USB_CLASS_COMM,
675 USB_CDC_SUBCLASS_ETHERNET,
676 USB_CDC_PROTO_NONE),
677 .driver_info = (unsigned long)&wwan_info,
678 }, {
679 /* ZTE (Vodafone) K4510-Z */
680 USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1173, USB_CLASS_COMM,
681 USB_CDC_SUBCLASS_ETHERNET,
682 USB_CDC_PROTO_NONE),
683 .driver_info = (unsigned long)&wwan_info,
684 }, {
685 /* ZTE (Vodafone) K3770-Z */
686 USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1177, USB_CLASS_COMM,
687 USB_CDC_SUBCLASS_ETHERNET,
688 USB_CDC_PROTO_NONE),
689 .driver_info = (unsigned long)&wwan_info,
690 }, {
691 /* ZTE (Vodafone) K3772-Z */
692 USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1181, USB_CLASS_COMM,
693 USB_CDC_SUBCLASS_ETHERNET,
694 USB_CDC_PROTO_NONE),
695 .driver_info = (unsigned long)&wwan_info,
696 }, {
697 /* Telit modules */
698 USB_VENDOR_AND_INTERFACE_INFO(0x1bc7, USB_CLASS_COMM,
699 USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
700 .driver_info = (kernel_ulong_t) &wwan_info,
701 }, {
702 USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ETHERNET,
703 USB_CDC_PROTO_NONE),
704 .driver_info = (unsigned long) &cdc_info,
705 }, {
706 USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MDLM,
707 USB_CDC_PROTO_NONE),
708 .driver_info = (unsigned long)&wwan_info,
709
710 }, {
711 /* Various Huawei modems with a network port like the UMG1831 */
712 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_COMM,
713 USB_CDC_SUBCLASS_ETHERNET, 255),
714 .driver_info = (unsigned long)&wwan_info,
715 },
716 { }, /* END */
717 };
718 MODULE_DEVICE_TABLE(usb, products);
719
720 static struct usb_driver cdc_driver = {
721 .name = "cdc_ether",
722 .id_table = products,
723 .probe = usbnet_probe,
724 .disconnect = usbnet_disconnect,
725 .suspend = usbnet_suspend,
726 .resume = usbnet_resume,
727 .reset_resume = usbnet_resume,
728 .supports_autosuspend = 1,
729 .disable_hub_initiated_lpm = 1,
730 };
731
732 module_usb_driver(cdc_driver);
733
734 MODULE_AUTHOR("David Brownell");
735 MODULE_DESCRIPTION("USB CDC Ethernet devices");
736 MODULE_LICENSE("GPL");
This page took 0.067419 seconds and 5 git commands to generate.