cdc_ether.c 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887
  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) {
  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. return 0;
  277. bad_desc:
  278. dev_info(&dev->udev->dev, "bad CDC descriptors\n");
  279. return -ENODEV;
  280. }
  281. EXPORT_SYMBOL_GPL(usbnet_generic_cdc_bind);
  282. /* like usbnet_generic_cdc_bind() but handles filter initialization
  283. * correctly
  284. */
  285. int usbnet_ether_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
  286. {
  287. int rv;
  288. rv = usbnet_generic_cdc_bind(dev, intf);
  289. if (rv < 0)
  290. goto bail_out;
  291. /* Some devices don't initialise properly. In particular
  292. * the packet filter is not reset. There are devices that
  293. * don't do reset all the way. So the packet filter should
  294. * be set to a sane initial value.
  295. */
  296. usbnet_cdc_update_filter(dev);
  297. bail_out:
  298. return rv;
  299. }
  300. EXPORT_SYMBOL_GPL(usbnet_ether_cdc_bind);
  301. void usbnet_cdc_unbind(struct usbnet *dev, struct usb_interface *intf)
  302. {
  303. struct cdc_state *info = (void *) &dev->data;
  304. struct usb_driver *driver = driver_of(intf);
  305. /* combined interface - nothing to do */
  306. if (info->data == info->control)
  307. return;
  308. /* disconnect master --> disconnect slave */
  309. if (intf == info->control && info->data) {
  310. /* ensure immediate exit from usbnet_disconnect */
  311. usb_set_intfdata(info->data, NULL);
  312. usb_driver_release_interface(driver, info->data);
  313. info->data = NULL;
  314. }
  315. /* and vice versa (just in case) */
  316. else if (intf == info->data && info->control) {
  317. /* ensure immediate exit from usbnet_disconnect */
  318. usb_set_intfdata(info->control, NULL);
  319. usb_driver_release_interface(driver, info->control);
  320. info->control = NULL;
  321. }
  322. }
  323. EXPORT_SYMBOL_GPL(usbnet_cdc_unbind);
  324. /* Communications Device Class, Ethernet Control model
  325. *
  326. * Takes two interfaces. The DATA interface is inactive till an altsetting
  327. * is selected. Configuration data includes class descriptors. There's
  328. * an optional status endpoint on the control interface.
  329. *
  330. * This should interop with whatever the 2.4 "CDCEther.c" driver
  331. * (by Brad Hards) talked with, with more functionality.
  332. */
  333. static void dumpspeed(struct usbnet *dev, __le32 *speeds)
  334. {
  335. netif_info(dev, timer, dev->net,
  336. "link speeds: %u kbps up, %u kbps down\n",
  337. __le32_to_cpu(speeds[0]) / 1000,
  338. __le32_to_cpu(speeds[1]) / 1000);
  339. }
  340. void usbnet_cdc_status(struct usbnet *dev, struct urb *urb)
  341. {
  342. struct usb_cdc_notification *event;
  343. if (urb->actual_length < sizeof(*event))
  344. return;
  345. /* SPEED_CHANGE can get split into two 8-byte packets */
  346. if (test_and_clear_bit(EVENT_STS_SPLIT, &dev->flags)) {
  347. dumpspeed(dev, (__le32 *) urb->transfer_buffer);
  348. return;
  349. }
  350. event = urb->transfer_buffer;
  351. switch (event->bNotificationType) {
  352. case USB_CDC_NOTIFY_NETWORK_CONNECTION:
  353. netif_dbg(dev, timer, dev->net, "CDC: carrier %s\n",
  354. event->wValue ? "on" : "off");
  355. usbnet_link_change(dev, !!event->wValue, 0);
  356. break;
  357. case USB_CDC_NOTIFY_SPEED_CHANGE: /* tx/rx rates */
  358. netif_dbg(dev, timer, dev->net, "CDC: speed change (len %d)\n",
  359. urb->actual_length);
  360. if (urb->actual_length != (sizeof(*event) + 8))
  361. set_bit(EVENT_STS_SPLIT, &dev->flags);
  362. else
  363. dumpspeed(dev, (__le32 *) &event[1]);
  364. break;
  365. /* USB_CDC_NOTIFY_RESPONSE_AVAILABLE can happen too (e.g. RNDIS),
  366. * but there are no standard formats for the response data.
  367. */
  368. default:
  369. netdev_err(dev->net, "CDC: unexpected notification %02x!\n",
  370. event->bNotificationType);
  371. break;
  372. }
  373. }
  374. EXPORT_SYMBOL_GPL(usbnet_cdc_status);
  375. int usbnet_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
  376. {
  377. int status;
  378. struct cdc_state *info = (void *) &dev->data;
  379. BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data)
  380. < sizeof(struct cdc_state)));
  381. status = usbnet_ether_cdc_bind(dev, intf);
  382. if (status < 0)
  383. return status;
  384. status = usbnet_get_ethernet_addr(dev, info->ether->iMACAddress);
  385. if (status < 0) {
  386. usb_set_intfdata(info->data, NULL);
  387. usb_driver_release_interface(driver_of(intf), info->data);
  388. return status;
  389. }
  390. return 0;
  391. }
  392. EXPORT_SYMBOL_GPL(usbnet_cdc_bind);
  393. static int usbnet_cdc_zte_bind(struct usbnet *dev, struct usb_interface *intf)
  394. {
  395. int status = usbnet_cdc_bind(dev, intf);
  396. if (!status && (dev->net->dev_addr[0] & 0x02))
  397. eth_hw_addr_random(dev->net);
  398. return status;
  399. }
  400. /* Make sure packets have correct destination MAC address
  401. *
  402. * A firmware bug observed on some devices (ZTE MF823/831/910) is that the
  403. * device sends packets with a static, bogus, random MAC address (event if
  404. * device MAC address has been updated). Always set MAC address to that of the
  405. * device.
  406. */
  407. static int usbnet_cdc_zte_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
  408. {
  409. if (skb->len < ETH_HLEN || !(skb->data[0] & 0x02))
  410. return 1;
  411. skb_reset_mac_header(skb);
  412. ether_addr_copy(eth_hdr(skb)->h_dest, dev->net->dev_addr);
  413. return 1;
  414. }
  415. /* Ensure correct link state
  416. *
  417. * Some devices (ZTE MF823/831/910) export two carrier on notifications when
  418. * connected. This causes the link state to be incorrect. Work around this by
  419. * always setting the state to off, then on.
  420. */
  421. static void usbnet_cdc_zte_status(struct usbnet *dev, struct urb *urb)
  422. {
  423. struct usb_cdc_notification *event;
  424. if (urb->actual_length < sizeof(*event))
  425. return;
  426. event = urb->transfer_buffer;
  427. if (event->bNotificationType != USB_CDC_NOTIFY_NETWORK_CONNECTION) {
  428. usbnet_cdc_status(dev, urb);
  429. return;
  430. }
  431. netif_dbg(dev, timer, dev->net, "CDC: carrier %s\n",
  432. event->wValue ? "on" : "off");
  433. if (event->wValue &&
  434. netif_carrier_ok(dev->net))
  435. netif_carrier_off(dev->net);
  436. usbnet_link_change(dev, !!event->wValue, 0);
  437. }
  438. static const struct driver_info cdc_info = {
  439. .description = "CDC Ethernet Device",
  440. .flags = FLAG_ETHER | FLAG_POINTTOPOINT,
  441. .bind = usbnet_cdc_bind,
  442. .unbind = usbnet_cdc_unbind,
  443. .status = usbnet_cdc_status,
  444. .set_rx_mode = usbnet_cdc_update_filter,
  445. .manage_power = usbnet_manage_power,
  446. };
  447. static const struct driver_info zte_cdc_info = {
  448. .description = "ZTE CDC Ethernet Device",
  449. .flags = FLAG_ETHER | FLAG_POINTTOPOINT,
  450. .bind = usbnet_cdc_zte_bind,
  451. .unbind = usbnet_cdc_unbind,
  452. .status = usbnet_cdc_zte_status,
  453. .set_rx_mode = usbnet_cdc_update_filter,
  454. .manage_power = usbnet_manage_power,
  455. .rx_fixup = usbnet_cdc_zte_rx_fixup,
  456. };
  457. static const struct driver_info wwan_info = {
  458. .description = "Mobile Broadband Network Device",
  459. .flags = FLAG_WWAN,
  460. .bind = usbnet_cdc_bind,
  461. .unbind = usbnet_cdc_unbind,
  462. .status = usbnet_cdc_status,
  463. .set_rx_mode = usbnet_cdc_update_filter,
  464. .manage_power = usbnet_manage_power,
  465. };
  466. /*-------------------------------------------------------------------------*/
  467. #define HUAWEI_VENDOR_ID 0x12D1
  468. #define NOVATEL_VENDOR_ID 0x1410
  469. #define ZTE_VENDOR_ID 0x19D2
  470. #define DELL_VENDOR_ID 0x413C
  471. #define REALTEK_VENDOR_ID 0x0bda
  472. #define SAMSUNG_VENDOR_ID 0x04e8
  473. #define LENOVO_VENDOR_ID 0x17ef
  474. #define NVIDIA_VENDOR_ID 0x0955
  475. #define HP_VENDOR_ID 0x03f0
  476. #define MICROSOFT_VENDOR_ID 0x045e
  477. static const struct usb_device_id products[] = {
  478. /* BLACKLIST !!
  479. *
  480. * First blacklist any products that are egregiously nonconformant
  481. * with the CDC Ethernet specs. Minor braindamage we cope with; when
  482. * they're not even trying, needing a separate driver is only the first
  483. * of the differences to show up.
  484. */
  485. #define ZAURUS_MASTER_INTERFACE \
  486. .bInterfaceClass = USB_CLASS_COMM, \
  487. .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, \
  488. .bInterfaceProtocol = USB_CDC_PROTO_NONE
  489. /* SA-1100 based Sharp Zaurus ("collie"), or compatible;
  490. * wire-incompatible with true CDC Ethernet implementations.
  491. * (And, it seems, needlessly so...)
  492. */
  493. {
  494. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  495. | USB_DEVICE_ID_MATCH_DEVICE,
  496. .idVendor = 0x04DD,
  497. .idProduct = 0x8004,
  498. ZAURUS_MASTER_INTERFACE,
  499. .driver_info = 0,
  500. },
  501. /* PXA-25x based Sharp Zaurii. Note that it seems some of these
  502. * (later models especially) may have shipped only with firmware
  503. * advertising false "CDC MDLM" compatibility ... but we're not
  504. * clear which models did that, so for now let's assume the worst.
  505. */
  506. {
  507. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  508. | USB_DEVICE_ID_MATCH_DEVICE,
  509. .idVendor = 0x04DD,
  510. .idProduct = 0x8005, /* A-300 */
  511. ZAURUS_MASTER_INTERFACE,
  512. .driver_info = 0,
  513. }, {
  514. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  515. | USB_DEVICE_ID_MATCH_DEVICE,
  516. .idVendor = 0x04DD,
  517. .idProduct = 0x8006, /* B-500/SL-5600 */
  518. ZAURUS_MASTER_INTERFACE,
  519. .driver_info = 0,
  520. }, {
  521. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  522. | USB_DEVICE_ID_MATCH_DEVICE,
  523. .idVendor = 0x04DD,
  524. .idProduct = 0x8007, /* C-700 */
  525. ZAURUS_MASTER_INTERFACE,
  526. .driver_info = 0,
  527. }, {
  528. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  529. | USB_DEVICE_ID_MATCH_DEVICE,
  530. .idVendor = 0x04DD,
  531. .idProduct = 0x9031, /* C-750 C-760 */
  532. ZAURUS_MASTER_INTERFACE,
  533. .driver_info = 0,
  534. }, {
  535. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  536. | USB_DEVICE_ID_MATCH_DEVICE,
  537. .idVendor = 0x04DD,
  538. .idProduct = 0x9032, /* SL-6000 */
  539. ZAURUS_MASTER_INTERFACE,
  540. .driver_info = 0,
  541. }, {
  542. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  543. | USB_DEVICE_ID_MATCH_DEVICE,
  544. .idVendor = 0x04DD,
  545. /* reported with some C860 units */
  546. .idProduct = 0x9050, /* C-860 */
  547. ZAURUS_MASTER_INTERFACE,
  548. .driver_info = 0,
  549. },
  550. /* Olympus has some models with a Zaurus-compatible option.
  551. * R-1000 uses a FreeScale i.MXL cpu (ARMv4T)
  552. */
  553. {
  554. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  555. | USB_DEVICE_ID_MATCH_DEVICE,
  556. .idVendor = 0x07B4,
  557. .idProduct = 0x0F02, /* R-1000 */
  558. ZAURUS_MASTER_INTERFACE,
  559. .driver_info = 0,
  560. },
  561. /* LG Electronics VL600 wants additional headers on every frame */
  562. {
  563. USB_DEVICE_AND_INTERFACE_INFO(0x1004, 0x61aa, USB_CLASS_COMM,
  564. USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
  565. .driver_info = 0,
  566. },
  567. /* Logitech Harmony 900 - uses the pseudo-MDLM (BLAN) driver */
  568. {
  569. USB_DEVICE_AND_INTERFACE_INFO(0x046d, 0xc11f, USB_CLASS_COMM,
  570. USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
  571. .driver_info = 0,
  572. },
  573. /* Novatel USB551L and MC551 - handled by qmi_wwan */
  574. {
  575. USB_DEVICE_AND_INTERFACE_INFO(NOVATEL_VENDOR_ID, 0xB001, USB_CLASS_COMM,
  576. USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
  577. .driver_info = 0,
  578. },
  579. /* Novatel E362 - handled by qmi_wwan */
  580. {
  581. USB_DEVICE_AND_INTERFACE_INFO(NOVATEL_VENDOR_ID, 0x9010, USB_CLASS_COMM,
  582. USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
  583. .driver_info = 0,
  584. },
  585. /* Dell Wireless 5800 (Novatel E362) - handled by qmi_wwan */
  586. {
  587. USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, 0x8195, USB_CLASS_COMM,
  588. USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
  589. .driver_info = 0,
  590. },
  591. /* Dell Wireless 5800 (Novatel E362) - handled by qmi_wwan */
  592. {
  593. USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, 0x8196, USB_CLASS_COMM,
  594. USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
  595. .driver_info = 0,
  596. },
  597. /* Dell Wireless 5804 (Novatel E371) - handled by qmi_wwan */
  598. {
  599. USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, 0x819b, USB_CLASS_COMM,
  600. USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
  601. .driver_info = 0,
  602. },
  603. /* Novatel Expedite E371 - handled by qmi_wwan */
  604. {
  605. USB_DEVICE_AND_INTERFACE_INFO(NOVATEL_VENDOR_ID, 0x9011, USB_CLASS_COMM,
  606. USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
  607. .driver_info = 0,
  608. },
  609. /* HP lt2523 (Novatel E371) - handled by qmi_wwan */
  610. {
  611. USB_DEVICE_AND_INTERFACE_INFO(HP_VENDOR_ID, 0x421d, USB_CLASS_COMM,
  612. USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
  613. .driver_info = 0,
  614. },
  615. /* AnyDATA ADU960S - handled by qmi_wwan */
  616. {
  617. USB_DEVICE_AND_INTERFACE_INFO(0x16d5, 0x650a, USB_CLASS_COMM,
  618. USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
  619. .driver_info = 0,
  620. },
  621. /* Huawei E1820 - handled by qmi_wwan */
  622. {
  623. USB_DEVICE_INTERFACE_NUMBER(HUAWEI_VENDOR_ID, 0x14ac, 1),
  624. .driver_info = 0,
  625. },
  626. /* Realtek RTL8152 Based USB 2.0 Ethernet Adapters */
  627. {
  628. USB_DEVICE_AND_INTERFACE_INFO(REALTEK_VENDOR_ID, 0x8152, USB_CLASS_COMM,
  629. USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
  630. .driver_info = 0,
  631. },
  632. /* Realtek RTL8153 Based USB 3.0 Ethernet Adapters */
  633. {
  634. USB_DEVICE_AND_INTERFACE_INFO(REALTEK_VENDOR_ID, 0x8153, USB_CLASS_COMM,
  635. USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
  636. .driver_info = 0,
  637. },
  638. /* Samsung USB Ethernet Adapters */
  639. {
  640. USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, 0xa101, USB_CLASS_COMM,
  641. USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
  642. .driver_info = 0,
  643. },
  644. /* ThinkPad USB-C Dock (based on Realtek RTL8153) */
  645. {
  646. USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x3062, USB_CLASS_COMM,
  647. USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
  648. .driver_info = 0,
  649. },
  650. /* ThinkPad Thunderbolt 3 Dock (based on Realtek RTL8153) */
  651. {
  652. USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x3069, USB_CLASS_COMM,
  653. USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
  654. .driver_info = 0,
  655. },
  656. /* Lenovo Thinkpad USB 3.0 Ethernet Adapters (based on Realtek RTL8153) */
  657. {
  658. USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x7205, USB_CLASS_COMM,
  659. USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
  660. .driver_info = 0,
  661. },
  662. /* Lenovo USB C to Ethernet Adapter (based on Realtek RTL8153) */
  663. {
  664. USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x720c, USB_CLASS_COMM,
  665. USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
  666. .driver_info = 0,
  667. },
  668. /* Lenovo USB-C Travel Hub (based on Realtek RTL8153) */
  669. {
  670. USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x7214, USB_CLASS_COMM,
  671. USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
  672. .driver_info = 0,
  673. },
  674. /* NVIDIA Tegra USB 3.0 Ethernet Adapters (based on Realtek RTL8153) */
  675. {
  676. USB_DEVICE_AND_INTERFACE_INFO(NVIDIA_VENDOR_ID, 0x09ff, USB_CLASS_COMM,
  677. USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
  678. .driver_info = 0,
  679. },
  680. /* Microsoft Surface 2 dock (based on Realtek RTL8152) */
  681. {
  682. USB_DEVICE_AND_INTERFACE_INFO(MICROSOFT_VENDOR_ID, 0x07ab, USB_CLASS_COMM,
  683. USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
  684. .driver_info = 0,
  685. },
  686. /* Microsoft Surface 3 dock (based on Realtek RTL8153) */
  687. {
  688. USB_DEVICE_AND_INTERFACE_INFO(MICROSOFT_VENDOR_ID, 0x07c6, USB_CLASS_COMM,
  689. USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
  690. .driver_info = 0,
  691. },
  692. /* WHITELIST!!!
  693. *
  694. * CDC Ether uses two interfaces, not necessarily consecutive.
  695. * We match the main interface, ignoring the optional device
  696. * class so we could handle devices that aren't exclusively
  697. * CDC ether.
  698. *
  699. * NOTE: this match must come AFTER entries blacklisting devices
  700. * because of bugs/quirks in a given product (like Zaurus, above).
  701. */
  702. {
  703. /* ZTE (Vodafone) K3805-Z */
  704. USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1003, USB_CLASS_COMM,
  705. USB_CDC_SUBCLASS_ETHERNET,
  706. USB_CDC_PROTO_NONE),
  707. .driver_info = (unsigned long)&wwan_info,
  708. }, {
  709. /* ZTE (Vodafone) K3806-Z */
  710. USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1015, USB_CLASS_COMM,
  711. USB_CDC_SUBCLASS_ETHERNET,
  712. USB_CDC_PROTO_NONE),
  713. .driver_info = (unsigned long)&wwan_info,
  714. }, {
  715. /* ZTE (Vodafone) K4510-Z */
  716. USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1173, USB_CLASS_COMM,
  717. USB_CDC_SUBCLASS_ETHERNET,
  718. USB_CDC_PROTO_NONE),
  719. .driver_info = (unsigned long)&wwan_info,
  720. }, {
  721. /* ZTE (Vodafone) K3770-Z */
  722. USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1177, USB_CLASS_COMM,
  723. USB_CDC_SUBCLASS_ETHERNET,
  724. USB_CDC_PROTO_NONE),
  725. .driver_info = (unsigned long)&wwan_info,
  726. }, {
  727. /* ZTE (Vodafone) K3772-Z */
  728. USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1181, USB_CLASS_COMM,
  729. USB_CDC_SUBCLASS_ETHERNET,
  730. USB_CDC_PROTO_NONE),
  731. .driver_info = (unsigned long)&wwan_info,
  732. }, {
  733. /* Telit modules */
  734. USB_VENDOR_AND_INTERFACE_INFO(0x1bc7, USB_CLASS_COMM,
  735. USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
  736. .driver_info = (kernel_ulong_t) &wwan_info,
  737. }, {
  738. /* Dell DW5580 modules */
  739. USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, 0x81ba, USB_CLASS_COMM,
  740. USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
  741. .driver_info = (kernel_ulong_t)&wwan_info,
  742. }, {
  743. /* ZTE modules */
  744. USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, USB_CLASS_COMM,
  745. USB_CDC_SUBCLASS_ETHERNET,
  746. USB_CDC_PROTO_NONE),
  747. .driver_info = (unsigned long)&zte_cdc_info,
  748. }, {
  749. USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ETHERNET,
  750. USB_CDC_PROTO_NONE),
  751. .driver_info = (unsigned long) &cdc_info,
  752. }, {
  753. USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MDLM,
  754. USB_CDC_PROTO_NONE),
  755. .driver_info = (unsigned long)&wwan_info,
  756. }, {
  757. /* Various Huawei modems with a network port like the UMG1831 */
  758. USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_COMM,
  759. USB_CDC_SUBCLASS_ETHERNET, 255),
  760. .driver_info = (unsigned long)&wwan_info,
  761. },
  762. { }, /* END */
  763. };
  764. MODULE_DEVICE_TABLE(usb, products);
  765. static struct usb_driver cdc_driver = {
  766. .name = "cdc_ether",
  767. .id_table = products,
  768. .probe = usbnet_probe,
  769. .disconnect = usbnet_disconnect,
  770. .suspend = usbnet_suspend,
  771. .resume = usbnet_resume,
  772. .reset_resume = usbnet_resume,
  773. .supports_autosuspend = 1,
  774. .disable_hub_initiated_lpm = 1,
  775. };
  776. module_usb_driver(cdc_driver);
  777. MODULE_AUTHOR("David Brownell");
  778. MODULE_DESCRIPTION("USB CDC Ethernet devices");
  779. MODULE_LICENSE("GPL");