cdc_ether.c 18 KB

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