cdc_ether.c 21 KB

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