cdc_ether.c 21 KB

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