cdc_ether.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  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. if (event->wValue)
  368. netif_carrier_on(dev->net);
  369. else
  370. netif_carrier_off(dev->net);
  371. break;
  372. case USB_CDC_NOTIFY_SPEED_CHANGE: /* tx/rx rates */
  373. netif_dbg(dev, timer, dev->net, "CDC: speed change (len %d)\n",
  374. urb->actual_length);
  375. if (urb->actual_length != (sizeof *event + 8))
  376. set_bit(EVENT_STS_SPLIT, &dev->flags);
  377. else
  378. dumpspeed(dev, (__le32 *) &event[1]);
  379. break;
  380. /* USB_CDC_NOTIFY_RESPONSE_AVAILABLE can happen too (e.g. RNDIS),
  381. * but there are no standard formats for the response data.
  382. */
  383. default:
  384. netdev_err(dev->net, "CDC: unexpected notification %02x!\n",
  385. event->bNotificationType);
  386. break;
  387. }
  388. }
  389. EXPORT_SYMBOL_GPL(usbnet_cdc_status);
  390. int usbnet_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
  391. {
  392. int status;
  393. struct cdc_state *info = (void *) &dev->data;
  394. BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data)
  395. < sizeof(struct cdc_state)));
  396. status = usbnet_generic_cdc_bind(dev, intf);
  397. if (status < 0)
  398. return status;
  399. status = usbnet_get_ethernet_addr(dev, info->ether->iMACAddress);
  400. if (status < 0) {
  401. usb_set_intfdata(info->data, NULL);
  402. usb_driver_release_interface(driver_of(intf), info->data);
  403. return status;
  404. }
  405. /* FIXME cdc-ether has some multicast code too, though it complains
  406. * in routine cases. info->ether describes the multicast support.
  407. * Implement that here, manipulating the cdc filter as needed.
  408. */
  409. return 0;
  410. }
  411. EXPORT_SYMBOL_GPL(usbnet_cdc_bind);
  412. static int cdc_manage_power(struct usbnet *dev, int on)
  413. {
  414. dev->intf->needs_remote_wakeup = on;
  415. return 0;
  416. }
  417. static const struct driver_info cdc_info = {
  418. .description = "CDC Ethernet Device",
  419. .flags = FLAG_ETHER | FLAG_POINTTOPOINT,
  420. // .check_connect = cdc_check_connect,
  421. .bind = usbnet_cdc_bind,
  422. .unbind = usbnet_cdc_unbind,
  423. .status = usbnet_cdc_status,
  424. .manage_power = cdc_manage_power,
  425. };
  426. static const struct driver_info wwan_info = {
  427. .description = "Mobile Broadband Network Device",
  428. .flags = FLAG_WWAN,
  429. .bind = usbnet_cdc_bind,
  430. .unbind = usbnet_cdc_unbind,
  431. .status = usbnet_cdc_status,
  432. .manage_power = cdc_manage_power,
  433. };
  434. /*-------------------------------------------------------------------------*/
  435. #define HUAWEI_VENDOR_ID 0x12D1
  436. #define NOVATEL_VENDOR_ID 0x1410
  437. #define ZTE_VENDOR_ID 0x19D2
  438. static const struct usb_device_id products [] = {
  439. /*
  440. * BLACKLIST !!
  441. *
  442. * First blacklist any products that are egregiously nonconformant
  443. * with the CDC Ethernet specs. Minor braindamage we cope with; when
  444. * they're not even trying, needing a separate driver is only the first
  445. * of the differences to show up.
  446. */
  447. #define ZAURUS_MASTER_INTERFACE \
  448. .bInterfaceClass = USB_CLASS_COMM, \
  449. .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, \
  450. .bInterfaceProtocol = USB_CDC_PROTO_NONE
  451. /* SA-1100 based Sharp Zaurus ("collie"), or compatible;
  452. * wire-incompatible with true CDC Ethernet implementations.
  453. * (And, it seems, needlessly so...)
  454. */
  455. {
  456. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  457. | USB_DEVICE_ID_MATCH_DEVICE,
  458. .idVendor = 0x04DD,
  459. .idProduct = 0x8004,
  460. ZAURUS_MASTER_INTERFACE,
  461. .driver_info = 0,
  462. },
  463. /* PXA-25x based Sharp Zaurii. Note that it seems some of these
  464. * (later models especially) may have shipped only with firmware
  465. * advertising false "CDC MDLM" compatibility ... but we're not
  466. * clear which models did that, so for now let's assume the worst.
  467. */
  468. {
  469. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  470. | USB_DEVICE_ID_MATCH_DEVICE,
  471. .idVendor = 0x04DD,
  472. .idProduct = 0x8005, /* A-300 */
  473. ZAURUS_MASTER_INTERFACE,
  474. .driver_info = 0,
  475. }, {
  476. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  477. | USB_DEVICE_ID_MATCH_DEVICE,
  478. .idVendor = 0x04DD,
  479. .idProduct = 0x8006, /* B-500/SL-5600 */
  480. ZAURUS_MASTER_INTERFACE,
  481. .driver_info = 0,
  482. }, {
  483. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  484. | USB_DEVICE_ID_MATCH_DEVICE,
  485. .idVendor = 0x04DD,
  486. .idProduct = 0x8007, /* C-700 */
  487. ZAURUS_MASTER_INTERFACE,
  488. .driver_info = 0,
  489. }, {
  490. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  491. | USB_DEVICE_ID_MATCH_DEVICE,
  492. .idVendor = 0x04DD,
  493. .idProduct = 0x9031, /* C-750 C-760 */
  494. ZAURUS_MASTER_INTERFACE,
  495. .driver_info = 0,
  496. }, {
  497. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  498. | USB_DEVICE_ID_MATCH_DEVICE,
  499. .idVendor = 0x04DD,
  500. .idProduct = 0x9032, /* SL-6000 */
  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. /* reported with some C860 units */
  508. .idProduct = 0x9050, /* C-860 */
  509. ZAURUS_MASTER_INTERFACE,
  510. .driver_info = 0,
  511. },
  512. /* Olympus has some models with a Zaurus-compatible option.
  513. * R-1000 uses a FreeScale i.MXL cpu (ARMv4T)
  514. */
  515. {
  516. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  517. | USB_DEVICE_ID_MATCH_DEVICE,
  518. .idVendor = 0x07B4,
  519. .idProduct = 0x0F02, /* R-1000 */
  520. ZAURUS_MASTER_INTERFACE,
  521. .driver_info = 0,
  522. },
  523. /* LG Electronics VL600 wants additional headers on every frame */
  524. {
  525. USB_DEVICE_AND_INTERFACE_INFO(0x1004, 0x61aa, USB_CLASS_COMM,
  526. USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
  527. .driver_info = 0,
  528. },
  529. /* Logitech Harmony 900 - uses the pseudo-MDLM (BLAN) driver */
  530. {
  531. USB_DEVICE_AND_INTERFACE_INFO(0x046d, 0xc11f, USB_CLASS_COMM,
  532. USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
  533. .driver_info = 0,
  534. },
  535. /*
  536. * WHITELIST!!!
  537. *
  538. * CDC Ether uses two interfaces, not necessarily consecutive.
  539. * We match the main interface, ignoring the optional device
  540. * class so we could handle devices that aren't exclusively
  541. * CDC ether.
  542. *
  543. * NOTE: this match must come AFTER entries blacklisting devices
  544. * because of bugs/quirks in a given product (like Zaurus, above).
  545. */
  546. {
  547. /* Novatel USB551L */
  548. /* This match must come *before* the generic CDC-ETHER match so that
  549. * we get FLAG_WWAN set on the device, since it's descriptors are
  550. * generic CDC-ETHER.
  551. */
  552. .match_flags = USB_DEVICE_ID_MATCH_VENDOR
  553. | USB_DEVICE_ID_MATCH_PRODUCT
  554. | USB_DEVICE_ID_MATCH_INT_INFO,
  555. .idVendor = NOVATEL_VENDOR_ID,
  556. .idProduct = 0xB001,
  557. .bInterfaceClass = USB_CLASS_COMM,
  558. .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET,
  559. .bInterfaceProtocol = USB_CDC_PROTO_NONE,
  560. .driver_info = (unsigned long)&wwan_info,
  561. }, {
  562. /* ZTE (Vodafone) K3805-Z */
  563. .match_flags = USB_DEVICE_ID_MATCH_VENDOR
  564. | USB_DEVICE_ID_MATCH_PRODUCT
  565. | USB_DEVICE_ID_MATCH_INT_INFO,
  566. .idVendor = ZTE_VENDOR_ID,
  567. .idProduct = 0x1003,
  568. .bInterfaceClass = USB_CLASS_COMM,
  569. .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET,
  570. .bInterfaceProtocol = USB_CDC_PROTO_NONE,
  571. .driver_info = (unsigned long)&wwan_info,
  572. }, {
  573. /* ZTE (Vodafone) K3806-Z */
  574. .match_flags = USB_DEVICE_ID_MATCH_VENDOR
  575. | USB_DEVICE_ID_MATCH_PRODUCT
  576. | USB_DEVICE_ID_MATCH_INT_INFO,
  577. .idVendor = ZTE_VENDOR_ID,
  578. .idProduct = 0x1015,
  579. .bInterfaceClass = USB_CLASS_COMM,
  580. .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET,
  581. .bInterfaceProtocol = USB_CDC_PROTO_NONE,
  582. .driver_info = (unsigned long)&wwan_info,
  583. }, {
  584. /* ZTE (Vodafone) K4510-Z */
  585. .match_flags = USB_DEVICE_ID_MATCH_VENDOR
  586. | USB_DEVICE_ID_MATCH_PRODUCT
  587. | USB_DEVICE_ID_MATCH_INT_INFO,
  588. .idVendor = ZTE_VENDOR_ID,
  589. .idProduct = 0x1173,
  590. .bInterfaceClass = USB_CLASS_COMM,
  591. .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET,
  592. .bInterfaceProtocol = USB_CDC_PROTO_NONE,
  593. .driver_info = (unsigned long)&wwan_info,
  594. }, {
  595. /* ZTE (Vodafone) K3770-Z */
  596. .match_flags = USB_DEVICE_ID_MATCH_VENDOR
  597. | USB_DEVICE_ID_MATCH_PRODUCT
  598. | USB_DEVICE_ID_MATCH_INT_INFO,
  599. .idVendor = ZTE_VENDOR_ID,
  600. .idProduct = 0x1177,
  601. .bInterfaceClass = USB_CLASS_COMM,
  602. .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET,
  603. .bInterfaceProtocol = USB_CDC_PROTO_NONE,
  604. .driver_info = (unsigned long)&wwan_info,
  605. }, {
  606. /* ZTE (Vodafone) K3772-Z */
  607. .match_flags = USB_DEVICE_ID_MATCH_VENDOR
  608. | USB_DEVICE_ID_MATCH_PRODUCT
  609. | USB_DEVICE_ID_MATCH_INT_INFO,
  610. .idVendor = ZTE_VENDOR_ID,
  611. .idProduct = 0x1181,
  612. .bInterfaceClass = USB_CLASS_COMM,
  613. .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET,
  614. .bInterfaceProtocol = USB_CDC_PROTO_NONE,
  615. .driver_info = (unsigned long)&wwan_info,
  616. }, {
  617. USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ETHERNET,
  618. USB_CDC_PROTO_NONE),
  619. .driver_info = (unsigned long) &cdc_info,
  620. }, {
  621. USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MDLM,
  622. USB_CDC_PROTO_NONE),
  623. .driver_info = (unsigned long)&wwan_info,
  624. }, {
  625. /* Various Huawei modems with a network port like the UMG1831 */
  626. .match_flags = USB_DEVICE_ID_MATCH_VENDOR
  627. | USB_DEVICE_ID_MATCH_INT_INFO,
  628. .idVendor = HUAWEI_VENDOR_ID,
  629. .bInterfaceClass = USB_CLASS_COMM,
  630. .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET,
  631. .bInterfaceProtocol = 255,
  632. .driver_info = (unsigned long)&wwan_info,
  633. },
  634. { }, // END
  635. };
  636. MODULE_DEVICE_TABLE(usb, products);
  637. static struct usb_driver cdc_driver = {
  638. .name = "cdc_ether",
  639. .id_table = products,
  640. .probe = usbnet_probe,
  641. .disconnect = usbnet_disconnect,
  642. .suspend = usbnet_suspend,
  643. .resume = usbnet_resume,
  644. .reset_resume = usbnet_resume,
  645. .supports_autosuspend = 1,
  646. .disable_hub_initiated_lpm = 1,
  647. };
  648. module_usb_driver(cdc_driver);
  649. MODULE_AUTHOR("David Brownell");
  650. MODULE_DESCRIPTION("USB CDC Ethernet devices");
  651. MODULE_LICENSE("GPL");