cdc_ether.c 22 KB

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