cdc_ether.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  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 > 0) {
  114. if ((len < buf [0]) || (buf [0] < 3)) {
  115. dev_dbg(&intf->dev, "invalid descriptor buffer length\n");
  116. goto bad_desc;
  117. }
  118. if (buf [1] != USB_DT_CS_INTERFACE)
  119. goto next_desc;
  120. /* use bDescriptorSubType to identify the CDC descriptors.
  121. * We expect devices with CDC header and union descriptors.
  122. * For CDC Ethernet we need the ethernet descriptor.
  123. * For RNDIS, ignore two (pointless) CDC modem descriptors
  124. * in favor of a complicated OID-based RPC scheme doing what
  125. * CDC Ethernet achieves with a simple descriptor.
  126. */
  127. switch (buf [2]) {
  128. case USB_CDC_HEADER_TYPE:
  129. if (info->header) {
  130. dev_dbg(&intf->dev, "extra CDC header\n");
  131. goto bad_desc;
  132. }
  133. info->header = (void *) buf;
  134. if (info->header->bLength != sizeof *info->header) {
  135. dev_dbg(&intf->dev, "CDC header len %u\n",
  136. info->header->bLength);
  137. goto bad_desc;
  138. }
  139. break;
  140. case USB_CDC_ACM_TYPE:
  141. /* paranoia: disambiguate a "real" vendor-specific
  142. * modem interface from an RNDIS non-modem.
  143. */
  144. if (rndis) {
  145. struct usb_cdc_acm_descriptor *acm;
  146. acm = (void *) buf;
  147. if (acm->bmCapabilities) {
  148. dev_dbg(&intf->dev,
  149. "ACM capabilities %02x, "
  150. "not really RNDIS?\n",
  151. acm->bmCapabilities);
  152. goto bad_desc;
  153. }
  154. }
  155. break;
  156. case USB_CDC_UNION_TYPE:
  157. if (info->u) {
  158. dev_dbg(&intf->dev, "extra CDC union\n");
  159. goto bad_desc;
  160. }
  161. info->u = (void *) buf;
  162. if (info->u->bLength != sizeof *info->u) {
  163. dev_dbg(&intf->dev, "CDC union len %u\n",
  164. info->u->bLength);
  165. goto bad_desc;
  166. }
  167. /* we need a master/control interface (what we're
  168. * probed with) and a slave/data interface; union
  169. * descriptors sort this all out.
  170. */
  171. info->control = usb_ifnum_to_if(dev->udev,
  172. info->u->bMasterInterface0);
  173. info->data = usb_ifnum_to_if(dev->udev,
  174. info->u->bSlaveInterface0);
  175. if (!info->control || !info->data) {
  176. dev_dbg(&intf->dev,
  177. "master #%u/%pK slave #%u/%pK\n",
  178. info->u->bMasterInterface0,
  179. info->control,
  180. info->u->bSlaveInterface0,
  181. info->data);
  182. /* fall back to hard-wiring for RNDIS */
  183. if (rndis) {
  184. android_rndis_quirk = true;
  185. goto next_desc;
  186. }
  187. goto bad_desc;
  188. }
  189. if (info->control != intf) {
  190. dev_dbg(&intf->dev, "bogus CDC Union\n");
  191. /* Ambit USB Cable Modem (and maybe others)
  192. * interchanges master and slave interface.
  193. */
  194. if (info->data == intf) {
  195. info->data = info->control;
  196. info->control = intf;
  197. } else
  198. goto bad_desc;
  199. }
  200. /* a data interface altsetting does the real i/o */
  201. d = &info->data->cur_altsetting->desc;
  202. if (d->bInterfaceClass != USB_CLASS_CDC_DATA) {
  203. dev_dbg(&intf->dev, "slave class %u\n",
  204. d->bInterfaceClass);
  205. goto bad_desc;
  206. }
  207. break;
  208. case USB_CDC_ETHERNET_TYPE:
  209. if (info->ether) {
  210. dev_dbg(&intf->dev, "extra CDC ether\n");
  211. goto bad_desc;
  212. }
  213. info->ether = (void *) buf;
  214. if (info->ether->bLength != sizeof *info->ether) {
  215. dev_dbg(&intf->dev, "CDC ether len %u\n",
  216. info->ether->bLength);
  217. goto bad_desc;
  218. }
  219. dev->hard_mtu = le16_to_cpu(
  220. info->ether->wMaxSegmentSize);
  221. /* because of Zaurus, we may be ignoring the host
  222. * side link address we were given.
  223. */
  224. break;
  225. case USB_CDC_MDLM_TYPE:
  226. if (desc) {
  227. dev_dbg(&intf->dev, "extra MDLM descriptor\n");
  228. goto bad_desc;
  229. }
  230. desc = (void *)buf;
  231. if (desc->bLength != sizeof(*desc))
  232. goto bad_desc;
  233. if (memcmp(&desc->bGUID, mbm_guid, 16))
  234. goto bad_desc;
  235. break;
  236. case USB_CDC_MDLM_DETAIL_TYPE:
  237. if (detail) {
  238. dev_dbg(&intf->dev, "extra MDLM detail descriptor\n");
  239. goto bad_desc;
  240. }
  241. detail = (void *)buf;
  242. if (detail->bGuidDescriptorType == 0) {
  243. if (detail->bLength < (sizeof(*detail) + 1))
  244. goto bad_desc;
  245. } else
  246. goto bad_desc;
  247. break;
  248. }
  249. next_desc:
  250. len -= buf [0]; /* bLength */
  251. buf += buf [0];
  252. }
  253. /* Microsoft ActiveSync based and some regular RNDIS devices lack the
  254. * CDC descriptors, so we'll hard-wire the interfaces and not check
  255. * for descriptors.
  256. *
  257. * Some Android RNDIS devices have a CDC Union descriptor pointing
  258. * to non-existing interfaces. Ignore that and attempt the same
  259. * hard-wired 0 and 1 interfaces.
  260. */
  261. if (rndis && (!info->u || android_rndis_quirk)) {
  262. info->control = usb_ifnum_to_if(dev->udev, 0);
  263. info->data = usb_ifnum_to_if(dev->udev, 1);
  264. if (!info->control || !info->data || info->control != intf) {
  265. dev_dbg(&intf->dev,
  266. "rndis: master #0/%pK slave #1/%pK\n",
  267. info->control,
  268. info->data);
  269. goto bad_desc;
  270. }
  271. } else if (!info->header || !info->u || (!rndis && !info->ether)) {
  272. dev_dbg(&intf->dev, "missing cdc %s%s%sdescriptor\n",
  273. info->header ? "" : "header ",
  274. info->u ? "" : "union ",
  275. info->ether ? "" : "ether ");
  276. goto bad_desc;
  277. }
  278. /* claim data interface and set it up ... with side effects.
  279. * network traffic can't flow until an altsetting is enabled.
  280. */
  281. status = usb_driver_claim_interface(driver, info->data, dev);
  282. if (status < 0)
  283. return status;
  284. status = usbnet_get_endpoints(dev, info->data);
  285. if (status < 0) {
  286. /* ensure immediate exit from usbnet_disconnect */
  287. usb_set_intfdata(info->data, NULL);
  288. usb_driver_release_interface(driver, info->data);
  289. return status;
  290. }
  291. /* status endpoint: optional for CDC Ethernet, not RNDIS (or ACM) */
  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. /* disconnect master --> disconnect slave */
  322. if (intf == info->control && info->data) {
  323. /* ensure immediate exit from usbnet_disconnect */
  324. usb_set_intfdata(info->data, NULL);
  325. usb_driver_release_interface(driver, info->data);
  326. info->data = NULL;
  327. }
  328. /* and vice versa (just in case) */
  329. else if (intf == info->data && info->control) {
  330. /* ensure immediate exit from usbnet_disconnect */
  331. usb_set_intfdata(info->control, NULL);
  332. usb_driver_release_interface(driver, info->control);
  333. info->control = NULL;
  334. }
  335. }
  336. EXPORT_SYMBOL_GPL(usbnet_cdc_unbind);
  337. /*-------------------------------------------------------------------------
  338. *
  339. * Communications Device Class, Ethernet Control model
  340. *
  341. * Takes two interfaces. The DATA interface is inactive till an altsetting
  342. * is selected. Configuration data includes class descriptors. There's
  343. * an optional status endpoint on the control interface.
  344. *
  345. * This should interop with whatever the 2.4 "CDCEther.c" driver
  346. * (by Brad Hards) talked with, with more functionality.
  347. *
  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. if (event->wValue)
  372. netif_carrier_on(dev->net);
  373. else
  374. netif_carrier_off(dev->net);
  375. break;
  376. case USB_CDC_NOTIFY_SPEED_CHANGE: /* tx/rx rates */
  377. netif_dbg(dev, timer, dev->net, "CDC: speed change (len %d)\n",
  378. urb->actual_length);
  379. if (urb->actual_length != (sizeof *event + 8))
  380. set_bit(EVENT_STS_SPLIT, &dev->flags);
  381. else
  382. dumpspeed(dev, (__le32 *) &event[1]);
  383. break;
  384. /* USB_CDC_NOTIFY_RESPONSE_AVAILABLE can happen too (e.g. RNDIS),
  385. * but there are no standard formats for the response data.
  386. */
  387. default:
  388. netdev_err(dev->net, "CDC: unexpected notification %02x!\n",
  389. event->bNotificationType);
  390. break;
  391. }
  392. }
  393. EXPORT_SYMBOL_GPL(usbnet_cdc_status);
  394. int usbnet_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
  395. {
  396. int status;
  397. struct cdc_state *info = (void *) &dev->data;
  398. BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data)
  399. < sizeof(struct cdc_state)));
  400. status = usbnet_generic_cdc_bind(dev, intf);
  401. if (status < 0)
  402. return status;
  403. status = usbnet_get_ethernet_addr(dev, info->ether->iMACAddress);
  404. if (status < 0) {
  405. usb_set_intfdata(info->data, NULL);
  406. usb_driver_release_interface(driver_of(intf), info->data);
  407. return status;
  408. }
  409. /* FIXME cdc-ether has some multicast code too, though it complains
  410. * in routine cases. info->ether describes the multicast support.
  411. * Implement that here, manipulating the cdc filter as needed.
  412. */
  413. return 0;
  414. }
  415. EXPORT_SYMBOL_GPL(usbnet_cdc_bind);
  416. static int cdc_manage_power(struct usbnet *dev, int on)
  417. {
  418. dev->intf->needs_remote_wakeup = on;
  419. return 0;
  420. }
  421. static const struct driver_info cdc_info = {
  422. .description = "CDC Ethernet Device",
  423. .flags = FLAG_ETHER | FLAG_POINTTOPOINT,
  424. // .check_connect = cdc_check_connect,
  425. .bind = usbnet_cdc_bind,
  426. .unbind = usbnet_cdc_unbind,
  427. .status = usbnet_cdc_status,
  428. .manage_power = cdc_manage_power,
  429. };
  430. static const struct driver_info wwan_info = {
  431. .description = "Mobile Broadband Network Device",
  432. .flags = FLAG_WWAN,
  433. .bind = usbnet_cdc_bind,
  434. .unbind = usbnet_cdc_unbind,
  435. .status = usbnet_cdc_status,
  436. .manage_power = cdc_manage_power,
  437. };
  438. /*-------------------------------------------------------------------------*/
  439. #define HUAWEI_VENDOR_ID 0x12D1
  440. #define NOVATEL_VENDOR_ID 0x1410
  441. static const struct usb_device_id products [] = {
  442. /*
  443. * BLACKLIST !!
  444. *
  445. * First blacklist any products that are egregiously nonconformant
  446. * with the CDC Ethernet specs. Minor braindamage we cope with; when
  447. * they're not even trying, needing a separate driver is only the first
  448. * of the differences to show up.
  449. */
  450. #define ZAURUS_MASTER_INTERFACE \
  451. .bInterfaceClass = USB_CLASS_COMM, \
  452. .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, \
  453. .bInterfaceProtocol = USB_CDC_PROTO_NONE
  454. /* SA-1100 based Sharp Zaurus ("collie"), or compatible;
  455. * wire-incompatible with true CDC Ethernet implementations.
  456. * (And, it seems, needlessly so...)
  457. */
  458. {
  459. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  460. | USB_DEVICE_ID_MATCH_DEVICE,
  461. .idVendor = 0x04DD,
  462. .idProduct = 0x8004,
  463. ZAURUS_MASTER_INTERFACE,
  464. .driver_info = 0,
  465. },
  466. /* PXA-25x based Sharp Zaurii. Note that it seems some of these
  467. * (later models especially) may have shipped only with firmware
  468. * advertising false "CDC MDLM" compatibility ... but we're not
  469. * clear which models did that, so for now let's assume the worst.
  470. */
  471. {
  472. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  473. | USB_DEVICE_ID_MATCH_DEVICE,
  474. .idVendor = 0x04DD,
  475. .idProduct = 0x8005, /* A-300 */
  476. ZAURUS_MASTER_INTERFACE,
  477. .driver_info = 0,
  478. }, {
  479. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  480. | USB_DEVICE_ID_MATCH_DEVICE,
  481. .idVendor = 0x04DD,
  482. .idProduct = 0x8006, /* B-500/SL-5600 */
  483. ZAURUS_MASTER_INTERFACE,
  484. .driver_info = 0,
  485. }, {
  486. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  487. | USB_DEVICE_ID_MATCH_DEVICE,
  488. .idVendor = 0x04DD,
  489. .idProduct = 0x8007, /* C-700 */
  490. ZAURUS_MASTER_INTERFACE,
  491. .driver_info = 0,
  492. }, {
  493. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  494. | USB_DEVICE_ID_MATCH_DEVICE,
  495. .idVendor = 0x04DD,
  496. .idProduct = 0x9031, /* C-750 C-760 */
  497. ZAURUS_MASTER_INTERFACE,
  498. .driver_info = 0,
  499. }, {
  500. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  501. | USB_DEVICE_ID_MATCH_DEVICE,
  502. .idVendor = 0x04DD,
  503. .idProduct = 0x9032, /* SL-6000 */
  504. ZAURUS_MASTER_INTERFACE,
  505. .driver_info = 0,
  506. }, {
  507. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  508. | USB_DEVICE_ID_MATCH_DEVICE,
  509. .idVendor = 0x04DD,
  510. /* reported with some C860 units */
  511. .idProduct = 0x9050, /* C-860 */
  512. ZAURUS_MASTER_INTERFACE,
  513. .driver_info = 0,
  514. },
  515. /* Olympus has some models with a Zaurus-compatible option.
  516. * R-1000 uses a FreeScale i.MXL cpu (ARMv4T)
  517. */
  518. {
  519. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  520. | USB_DEVICE_ID_MATCH_DEVICE,
  521. .idVendor = 0x07B4,
  522. .idProduct = 0x0F02, /* R-1000 */
  523. ZAURUS_MASTER_INTERFACE,
  524. .driver_info = 0,
  525. },
  526. /* LG Electronics VL600 wants additional headers on every frame */
  527. {
  528. USB_DEVICE_AND_INTERFACE_INFO(0x1004, 0x61aa, USB_CLASS_COMM,
  529. USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
  530. .driver_info = 0,
  531. },
  532. /* Logitech Harmony 900 - uses the pseudo-MDLM (BLAN) driver */
  533. {
  534. USB_DEVICE_AND_INTERFACE_INFO(0x046d, 0xc11f, USB_CLASS_COMM,
  535. USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
  536. .driver_info = 0,
  537. },
  538. /*
  539. * WHITELIST!!!
  540. *
  541. * CDC Ether uses two interfaces, not necessarily consecutive.
  542. * We match the main interface, ignoring the optional device
  543. * class so we could handle devices that aren't exclusively
  544. * CDC ether.
  545. *
  546. * NOTE: this match must come AFTER entries blacklisting devices
  547. * because of bugs/quirks in a given product (like Zaurus, above).
  548. */
  549. {
  550. /* Novatel USB551L */
  551. /* This match must come *before* the generic CDC-ETHER match so that
  552. * we get FLAG_WWAN set on the device, since it's descriptors are
  553. * generic CDC-ETHER.
  554. */
  555. .match_flags = USB_DEVICE_ID_MATCH_VENDOR
  556. | USB_DEVICE_ID_MATCH_PRODUCT
  557. | USB_DEVICE_ID_MATCH_INT_INFO,
  558. .idVendor = NOVATEL_VENDOR_ID,
  559. .idProduct = 0xB001,
  560. .bInterfaceClass = USB_CLASS_COMM,
  561. .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET,
  562. .bInterfaceProtocol = USB_CDC_PROTO_NONE,
  563. .driver_info = (unsigned long)&wwan_info,
  564. }, {
  565. /* Telit modules */
  566. USB_VENDOR_AND_INTERFACE_INFO(0x1bc7, USB_CLASS_COMM,
  567. USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
  568. .driver_info = (kernel_ulong_t) &wwan_info,
  569. }, {
  570. USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ETHERNET,
  571. USB_CDC_PROTO_NONE),
  572. .driver_info = (unsigned long) &cdc_info,
  573. }, {
  574. USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MDLM,
  575. USB_CDC_PROTO_NONE),
  576. .driver_info = (unsigned long)&wwan_info,
  577. }, {
  578. /* Various Huawei modems with a network port like the UMG1831 */
  579. .match_flags = USB_DEVICE_ID_MATCH_VENDOR
  580. | USB_DEVICE_ID_MATCH_INT_INFO,
  581. .idVendor = HUAWEI_VENDOR_ID,
  582. .bInterfaceClass = USB_CLASS_COMM,
  583. .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET,
  584. .bInterfaceProtocol = 255,
  585. .driver_info = (unsigned long)&wwan_info,
  586. },
  587. { }, // END
  588. };
  589. MODULE_DEVICE_TABLE(usb, products);
  590. static struct usb_driver cdc_driver = {
  591. .name = "cdc_ether",
  592. .id_table = products,
  593. .probe = usbnet_probe,
  594. .disconnect = usbnet_disconnect,
  595. .suspend = usbnet_suspend,
  596. .resume = usbnet_resume,
  597. .reset_resume = usbnet_resume,
  598. .supports_autosuspend = 1,
  599. };
  600. module_usb_driver(cdc_driver);
  601. MODULE_AUTHOR("David Brownell");
  602. MODULE_DESCRIPTION("USB CDC Ethernet devices");
  603. MODULE_LICENSE("GPL");