cdc_ether.c 22 KB

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