cdc_ether.c 22 KB

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