cdc_ether.c 22 KB

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