cdc_ether.c 23 KB

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