cdc_ether.c 23 KB

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