rndis_host.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. /*
  2. * Host Side support for RNDIS Networking Links
  3. * Copyright (C) 2005 by David Brownell
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. // #define DEBUG // error path messages, extra info
  20. // #define VERBOSE // more; success messages
  21. #include <linux/module.h>
  22. #include <linux/init.h>
  23. #include <linux/netdevice.h>
  24. #include <linux/etherdevice.h>
  25. #include <linux/ethtool.h>
  26. #include <linux/workqueue.h>
  27. #include <linux/mii.h>
  28. #include <linux/usb.h>
  29. #include <linux/usb/cdc.h>
  30. #include <linux/usb/usbnet.h>
  31. #include <linux/usb/rndis_host.h>
  32. /*
  33. * RNDIS is NDIS remoted over USB. It's a MSFT variant of CDC ACM ... of
  34. * course ACM was intended for modems, not Ethernet links! USB's standard
  35. * for Ethernet links is "CDC Ethernet", which is significantly simpler.
  36. *
  37. * NOTE that Microsoft's "RNDIS 1.0" specification is incomplete. Issues
  38. * include:
  39. * - Power management in particular relies on information that's scattered
  40. * through other documentation, and which is incomplete or incorrect even
  41. * there.
  42. * - There are various undocumented protocol requirements, such as the
  43. * need to send unused garbage in control-OUT messages.
  44. * - In some cases, MS-Windows will emit undocumented requests; this
  45. * matters more to peripheral implementations than host ones.
  46. *
  47. * Moreover there's a no-open-specs variant of RNDIS called "ActiveSync".
  48. *
  49. * For these reasons and others, ** USE OF RNDIS IS STRONGLY DISCOURAGED ** in
  50. * favor of such non-proprietary alternatives as CDC Ethernet or the newer (and
  51. * currently rare) "Ethernet Emulation Model" (EEM).
  52. */
  53. /*
  54. * RNDIS notifications from device: command completion; "reverse"
  55. * keepalives; etc
  56. */
  57. void rndis_status(struct usbnet *dev, struct urb *urb)
  58. {
  59. devdbg(dev, "rndis status urb, len %d stat %d",
  60. urb->actual_length, urb->status);
  61. // FIXME for keepalives, respond immediately (asynchronously)
  62. // if not an RNDIS status, do like cdc_status(dev,urb) does
  63. }
  64. EXPORT_SYMBOL_GPL(rndis_status);
  65. /*
  66. * RPC done RNDIS-style. Caller guarantees:
  67. * - message is properly byteswapped
  68. * - there's no other request pending
  69. * - buf can hold up to 1KB response (required by RNDIS spec)
  70. * On return, the first few entries are already byteswapped.
  71. *
  72. * Call context is likely probe(), before interface name is known,
  73. * which is why we won't try to use it in the diagnostics.
  74. */
  75. int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf)
  76. {
  77. struct cdc_state *info = (void *) &dev->data;
  78. int master_ifnum;
  79. int retval;
  80. unsigned count;
  81. __le32 rsp;
  82. u32 xid = 0, msg_len, request_id;
  83. /* REVISIT when this gets called from contexts other than probe() or
  84. * disconnect(): either serialize, or dispatch responses on xid
  85. */
  86. /* Issue the request; xid is unique, don't bother byteswapping it */
  87. if (likely(buf->msg_type != RNDIS_MSG_HALT
  88. && buf->msg_type != RNDIS_MSG_RESET)) {
  89. xid = dev->xid++;
  90. if (!xid)
  91. xid = dev->xid++;
  92. buf->request_id = (__force __le32) xid;
  93. }
  94. master_ifnum = info->control->cur_altsetting->desc.bInterfaceNumber;
  95. retval = usb_control_msg(dev->udev,
  96. usb_sndctrlpipe(dev->udev, 0),
  97. USB_CDC_SEND_ENCAPSULATED_COMMAND,
  98. USB_TYPE_CLASS | USB_RECIP_INTERFACE,
  99. 0, master_ifnum,
  100. buf, le32_to_cpu(buf->msg_len),
  101. RNDIS_CONTROL_TIMEOUT_MS);
  102. if (unlikely(retval < 0 || xid == 0))
  103. return retval;
  104. // FIXME Seems like some devices discard responses when
  105. // we time out and cancel our "get response" requests...
  106. // so, this is fragile. Probably need to poll for status.
  107. /* ignore status endpoint, just poll the control channel;
  108. * the request probably completed immediately
  109. */
  110. rsp = buf->msg_type | RNDIS_MSG_COMPLETION;
  111. for (count = 0; count < 10; count++) {
  112. memset(buf, 0, CONTROL_BUFFER_SIZE);
  113. retval = usb_control_msg(dev->udev,
  114. usb_rcvctrlpipe(dev->udev, 0),
  115. USB_CDC_GET_ENCAPSULATED_RESPONSE,
  116. USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
  117. 0, master_ifnum,
  118. buf, CONTROL_BUFFER_SIZE,
  119. RNDIS_CONTROL_TIMEOUT_MS);
  120. if (likely(retval >= 8)) {
  121. msg_len = le32_to_cpu(buf->msg_len);
  122. request_id = (__force u32) buf->request_id;
  123. if (likely(buf->msg_type == rsp)) {
  124. if (likely(request_id == xid)) {
  125. if (unlikely(rsp == RNDIS_MSG_RESET_C))
  126. return 0;
  127. if (likely(RNDIS_STATUS_SUCCESS
  128. == buf->status))
  129. return 0;
  130. dev_dbg(&info->control->dev,
  131. "rndis reply status %08x\n",
  132. le32_to_cpu(buf->status));
  133. return -EL3RST;
  134. }
  135. dev_dbg(&info->control->dev,
  136. "rndis reply id %d expected %d\n",
  137. request_id, xid);
  138. /* then likely retry */
  139. } else switch (buf->msg_type) {
  140. case RNDIS_MSG_INDICATE: { /* fault/event */
  141. struct rndis_indicate *msg = (void *)buf;
  142. int state = 0;
  143. switch (msg->status) {
  144. case RNDIS_STATUS_MEDIA_CONNECT:
  145. state = 1;
  146. case RNDIS_STATUS_MEDIA_DISCONNECT:
  147. dev_info(&info->control->dev,
  148. "rndis media %sconnect\n",
  149. !state?"dis":"");
  150. if (dev->driver_info->link_change)
  151. dev->driver_info->link_change(
  152. dev, state);
  153. break;
  154. default:
  155. dev_info(&info->control->dev,
  156. "rndis indication: 0x%08x\n",
  157. le32_to_cpu(msg->status));
  158. }
  159. }
  160. break;
  161. case RNDIS_MSG_KEEPALIVE: { /* ping */
  162. struct rndis_keepalive_c *msg = (void *)buf;
  163. msg->msg_type = RNDIS_MSG_KEEPALIVE_C;
  164. msg->msg_len = ccpu2(sizeof *msg);
  165. msg->status = RNDIS_STATUS_SUCCESS;
  166. retval = usb_control_msg(dev->udev,
  167. usb_sndctrlpipe(dev->udev, 0),
  168. USB_CDC_SEND_ENCAPSULATED_COMMAND,
  169. USB_TYPE_CLASS | USB_RECIP_INTERFACE,
  170. 0, master_ifnum,
  171. msg, sizeof *msg,
  172. RNDIS_CONTROL_TIMEOUT_MS);
  173. if (unlikely(retval < 0))
  174. dev_dbg(&info->control->dev,
  175. "rndis keepalive err %d\n",
  176. retval);
  177. }
  178. break;
  179. default:
  180. dev_dbg(&info->control->dev,
  181. "unexpected rndis msg %08x len %d\n",
  182. le32_to_cpu(buf->msg_type), msg_len);
  183. }
  184. } else {
  185. /* device probably issued a protocol stall; ignore */
  186. dev_dbg(&info->control->dev,
  187. "rndis response error, code %d\n", retval);
  188. }
  189. msleep(2);
  190. }
  191. dev_dbg(&info->control->dev, "rndis response timeout\n");
  192. return -ETIMEDOUT;
  193. }
  194. EXPORT_SYMBOL_GPL(rndis_command);
  195. /*
  196. * rndis_query:
  197. *
  198. * Performs a query for @oid along with 0 or more bytes of payload as
  199. * specified by @in_len. If @reply_len is not set to -1 then the reply
  200. * length is checked against this value, resulting in an error if it
  201. * doesn't match.
  202. *
  203. * NOTE: Adding a payload exactly or greater than the size of the expected
  204. * response payload is an evident requirement MSFT added for ActiveSync.
  205. *
  206. * The only exception is for OIDs that return a variably sized response,
  207. * in which case no payload should be added. This undocumented (and
  208. * nonsensical!) issue was found by sniffing protocol requests from the
  209. * ActiveSync 4.1 Windows driver.
  210. */
  211. static int rndis_query(struct usbnet *dev, struct usb_interface *intf,
  212. void *buf, u32 oid, u32 in_len,
  213. void **reply, int *reply_len)
  214. {
  215. int retval;
  216. union {
  217. void *buf;
  218. struct rndis_msg_hdr *header;
  219. struct rndis_query *get;
  220. struct rndis_query_c *get_c;
  221. } u;
  222. u32 off, len;
  223. u.buf = buf;
  224. memset(u.get, 0, sizeof *u.get + in_len);
  225. u.get->msg_type = RNDIS_MSG_QUERY;
  226. u.get->msg_len = cpu_to_le32(sizeof *u.get + in_len);
  227. u.get->oid = oid;
  228. u.get->len = cpu_to_le32(in_len);
  229. u.get->offset = ccpu2(20);
  230. retval = rndis_command(dev, u.header);
  231. if (unlikely(retval < 0)) {
  232. dev_err(&intf->dev, "RNDIS_MSG_QUERY(0x%08x) failed, %d\n",
  233. oid, retval);
  234. return retval;
  235. }
  236. off = le32_to_cpu(u.get_c->offset);
  237. len = le32_to_cpu(u.get_c->len);
  238. if (unlikely((8 + off + len) > CONTROL_BUFFER_SIZE))
  239. goto response_error;
  240. if (*reply_len != -1 && len != *reply_len)
  241. goto response_error;
  242. *reply = (unsigned char *) &u.get_c->request_id + off;
  243. *reply_len = len;
  244. return retval;
  245. response_error:
  246. dev_err(&intf->dev, "RNDIS_MSG_QUERY(0x%08x) "
  247. "invalid response - off %d len %d\n",
  248. oid, off, len);
  249. return -EDOM;
  250. }
  251. int
  252. generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags)
  253. {
  254. int retval;
  255. struct net_device *net = dev->net;
  256. struct cdc_state *info = (void *) &dev->data;
  257. union {
  258. void *buf;
  259. struct rndis_msg_hdr *header;
  260. struct rndis_init *init;
  261. struct rndis_init_c *init_c;
  262. struct rndis_query *get;
  263. struct rndis_query_c *get_c;
  264. struct rndis_set *set;
  265. struct rndis_set_c *set_c;
  266. struct rndis_halt *halt;
  267. } u;
  268. u32 tmp, *phym;
  269. int reply_len;
  270. unsigned char *bp;
  271. /* we can't rely on i/o from stack working, or stack allocation */
  272. u.buf = kmalloc(CONTROL_BUFFER_SIZE, GFP_KERNEL);
  273. if (!u.buf)
  274. return -ENOMEM;
  275. retval = usbnet_generic_cdc_bind(dev, intf);
  276. if (retval < 0)
  277. goto fail;
  278. u.init->msg_type = RNDIS_MSG_INIT;
  279. u.init->msg_len = ccpu2(sizeof *u.init);
  280. u.init->major_version = ccpu2(1);
  281. u.init->minor_version = ccpu2(0);
  282. /* max transfer (in spec) is 0x4000 at full speed, but for
  283. * TX we'll stick to one Ethernet packet plus RNDIS framing.
  284. * For RX we handle drivers that zero-pad to end-of-packet.
  285. * Don't let userspace change these settings.
  286. *
  287. * NOTE: there still seems to be wierdness here, as if we need
  288. * to do some more things to make sure WinCE targets accept this.
  289. * They default to jumbograms of 8KB or 16KB, which is absurd
  290. * for such low data rates and which is also more than Linux
  291. * can usually expect to allocate for SKB data...
  292. */
  293. net->hard_header_len += sizeof (struct rndis_data_hdr);
  294. dev->hard_mtu = net->mtu + net->hard_header_len;
  295. dev->rx_urb_size = dev->hard_mtu + (dev->maxpacket + 1);
  296. dev->rx_urb_size &= ~(dev->maxpacket - 1);
  297. u.init->max_transfer_size = cpu_to_le32(dev->rx_urb_size);
  298. net->change_mtu = NULL;
  299. retval = rndis_command(dev, u.header);
  300. if (unlikely(retval < 0)) {
  301. /* it might not even be an RNDIS device!! */
  302. dev_err(&intf->dev, "RNDIS init failed, %d\n", retval);
  303. goto fail_and_release;
  304. }
  305. tmp = le32_to_cpu(u.init_c->max_transfer_size);
  306. if (tmp < dev->hard_mtu) {
  307. if (tmp <= net->hard_header_len) {
  308. dev_err(&intf->dev,
  309. "dev can't take %u byte packets (max %u)\n",
  310. dev->hard_mtu, tmp);
  311. retval = -EINVAL;
  312. goto halt_fail_and_release;
  313. }
  314. dev->hard_mtu = tmp;
  315. net->mtu = dev->hard_mtu - net->hard_header_len;
  316. dev_warn(&intf->dev,
  317. "dev can't take %u byte packets (max %u), "
  318. "adjusting MTU to %u\n",
  319. dev->hard_mtu, tmp, net->mtu);
  320. }
  321. /* REVISIT: peripheral "alignment" request is ignored ... */
  322. dev_dbg(&intf->dev,
  323. "hard mtu %u (%u from dev), rx buflen %Zu, align %d\n",
  324. dev->hard_mtu, tmp, dev->rx_urb_size,
  325. 1 << le32_to_cpu(u.init_c->packet_alignment));
  326. /* module has some device initialization code needs to be done right
  327. * after RNDIS_INIT */
  328. if (dev->driver_info->early_init &&
  329. dev->driver_info->early_init(dev) != 0)
  330. goto halt_fail_and_release;
  331. /* Check physical medium */
  332. reply_len = sizeof *phym;
  333. retval = rndis_query(dev, intf, u.buf, OID_GEN_PHYSICAL_MEDIUM,
  334. 0, (void **) &phym, &reply_len);
  335. if (retval != 0)
  336. /* OID is optional so don't fail here. */
  337. *phym = RNDIS_PHYSICAL_MEDIUM_UNSPECIFIED;
  338. if ((flags & FLAG_RNDIS_PHYM_WIRELESS) &&
  339. *phym != RNDIS_PHYSICAL_MEDIUM_WIRELESS_LAN) {
  340. if (netif_msg_probe(dev))
  341. dev_dbg(&intf->dev, "driver requires wireless "
  342. "physical medium, but device is not.\n");
  343. retval = -ENODEV;
  344. goto halt_fail_and_release;
  345. }
  346. if ((flags & FLAG_RNDIS_PHYM_NOT_WIRELESS) &&
  347. *phym == RNDIS_PHYSICAL_MEDIUM_WIRELESS_LAN) {
  348. if (netif_msg_probe(dev))
  349. dev_dbg(&intf->dev, "driver requires non-wireless "
  350. "physical medium, but device is wireless.\n");
  351. retval = -ENODEV;
  352. goto halt_fail_and_release;
  353. }
  354. /* Get designated host ethernet address */
  355. reply_len = ETH_ALEN;
  356. retval = rndis_query(dev, intf, u.buf, OID_802_3_PERMANENT_ADDRESS,
  357. 48, (void **) &bp, &reply_len);
  358. if (unlikely(retval< 0)) {
  359. dev_err(&intf->dev, "rndis get ethaddr, %d\n", retval);
  360. goto halt_fail_and_release;
  361. }
  362. memcpy(net->dev_addr, bp, ETH_ALEN);
  363. /* set a nonzero filter to enable data transfers */
  364. memset(u.set, 0, sizeof *u.set);
  365. u.set->msg_type = RNDIS_MSG_SET;
  366. u.set->msg_len = ccpu2(4 + sizeof *u.set);
  367. u.set->oid = OID_GEN_CURRENT_PACKET_FILTER;
  368. u.set->len = ccpu2(4);
  369. u.set->offset = ccpu2((sizeof *u.set) - 8);
  370. *(__le32 *)(u.buf + sizeof *u.set) = RNDIS_DEFAULT_FILTER;
  371. retval = rndis_command(dev, u.header);
  372. if (unlikely(retval < 0)) {
  373. dev_err(&intf->dev, "rndis set packet filter, %d\n", retval);
  374. goto halt_fail_and_release;
  375. }
  376. retval = 0;
  377. kfree(u.buf);
  378. return retval;
  379. halt_fail_and_release:
  380. memset(u.halt, 0, sizeof *u.halt);
  381. u.halt->msg_type = RNDIS_MSG_HALT;
  382. u.halt->msg_len = ccpu2(sizeof *u.halt);
  383. (void) rndis_command(dev, (void *)u.halt);
  384. fail_and_release:
  385. usb_set_intfdata(info->data, NULL);
  386. usb_driver_release_interface(driver_of(intf), info->data);
  387. info->data = NULL;
  388. fail:
  389. kfree(u.buf);
  390. return retval;
  391. }
  392. EXPORT_SYMBOL_GPL(generic_rndis_bind);
  393. static int rndis_bind(struct usbnet *dev, struct usb_interface *intf)
  394. {
  395. return generic_rndis_bind(dev, intf, FLAG_RNDIS_PHYM_NOT_WIRELESS);
  396. }
  397. void rndis_unbind(struct usbnet *dev, struct usb_interface *intf)
  398. {
  399. struct rndis_halt *halt;
  400. /* try to clear any rndis state/activity (no i/o from stack!) */
  401. halt = kzalloc(CONTROL_BUFFER_SIZE, GFP_KERNEL);
  402. if (halt) {
  403. halt->msg_type = RNDIS_MSG_HALT;
  404. halt->msg_len = ccpu2(sizeof *halt);
  405. (void) rndis_command(dev, (void *)halt);
  406. kfree(halt);
  407. }
  408. usbnet_cdc_unbind(dev, intf);
  409. }
  410. EXPORT_SYMBOL_GPL(rndis_unbind);
  411. /*
  412. * DATA -- host must not write zlps
  413. */
  414. int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
  415. {
  416. /* peripheral may have batched packets to us... */
  417. while (likely(skb->len)) {
  418. struct rndis_data_hdr *hdr = (void *)skb->data;
  419. struct sk_buff *skb2;
  420. u32 msg_len, data_offset, data_len;
  421. msg_len = le32_to_cpu(hdr->msg_len);
  422. data_offset = le32_to_cpu(hdr->data_offset);
  423. data_len = le32_to_cpu(hdr->data_len);
  424. /* don't choke if we see oob, per-packet data, etc */
  425. if (unlikely(hdr->msg_type != RNDIS_MSG_PACKET
  426. || skb->len < msg_len
  427. || (data_offset + data_len + 8) > msg_len)) {
  428. dev->stats.rx_frame_errors++;
  429. devdbg(dev, "bad rndis message %d/%d/%d/%d, len %d",
  430. le32_to_cpu(hdr->msg_type),
  431. msg_len, data_offset, data_len, skb->len);
  432. return 0;
  433. }
  434. skb_pull(skb, 8 + data_offset);
  435. /* at most one packet left? */
  436. if (likely((data_len - skb->len) <= sizeof *hdr)) {
  437. skb_trim(skb, data_len);
  438. break;
  439. }
  440. /* try to return all the packets in the batch */
  441. skb2 = skb_clone(skb, GFP_ATOMIC);
  442. if (unlikely(!skb2))
  443. break;
  444. skb_pull(skb, msg_len - sizeof *hdr);
  445. skb_trim(skb2, data_len);
  446. usbnet_skb_return(dev, skb2);
  447. }
  448. /* caller will usbnet_skb_return the remaining packet */
  449. return 1;
  450. }
  451. EXPORT_SYMBOL_GPL(rndis_rx_fixup);
  452. struct sk_buff *
  453. rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
  454. {
  455. struct rndis_data_hdr *hdr;
  456. struct sk_buff *skb2;
  457. unsigned len = skb->len;
  458. if (likely(!skb_cloned(skb))) {
  459. int room = skb_headroom(skb);
  460. /* enough head room as-is? */
  461. if (unlikely((sizeof *hdr) <= room))
  462. goto fill;
  463. /* enough room, but needs to be readjusted? */
  464. room += skb_tailroom(skb);
  465. if (likely((sizeof *hdr) <= room)) {
  466. skb->data = memmove(skb->head + sizeof *hdr,
  467. skb->data, len);
  468. skb_set_tail_pointer(skb, len);
  469. goto fill;
  470. }
  471. }
  472. /* create a new skb, with the correct size (and tailpad) */
  473. skb2 = skb_copy_expand(skb, sizeof *hdr, 1, flags);
  474. dev_kfree_skb_any(skb);
  475. if (unlikely(!skb2))
  476. return skb2;
  477. skb = skb2;
  478. /* fill out the RNDIS header. we won't bother trying to batch
  479. * packets; Linux minimizes wasted bandwidth through tx queues.
  480. */
  481. fill:
  482. hdr = (void *) __skb_push(skb, sizeof *hdr);
  483. memset(hdr, 0, sizeof *hdr);
  484. hdr->msg_type = RNDIS_MSG_PACKET;
  485. hdr->msg_len = cpu_to_le32(skb->len);
  486. hdr->data_offset = ccpu2(sizeof(*hdr) - 8);
  487. hdr->data_len = cpu_to_le32(len);
  488. /* FIXME make the last packet always be short ... */
  489. return skb;
  490. }
  491. EXPORT_SYMBOL_GPL(rndis_tx_fixup);
  492. static const struct driver_info rndis_info = {
  493. .description = "RNDIS device",
  494. .flags = FLAG_ETHER | FLAG_FRAMING_RN | FLAG_NO_SETINT,
  495. .bind = rndis_bind,
  496. .unbind = rndis_unbind,
  497. .status = rndis_status,
  498. .rx_fixup = rndis_rx_fixup,
  499. .tx_fixup = rndis_tx_fixup,
  500. };
  501. #undef ccpu2
  502. /*-------------------------------------------------------------------------*/
  503. static const struct usb_device_id products [] = {
  504. {
  505. /* RNDIS is MSFT's un-official variant of CDC ACM */
  506. USB_INTERFACE_INFO(USB_CLASS_COMM, 2 /* ACM */, 0x0ff),
  507. .driver_info = (unsigned long) &rndis_info,
  508. }, {
  509. /* "ActiveSync" is an undocumented variant of RNDIS, used in WM5 */
  510. USB_INTERFACE_INFO(USB_CLASS_MISC, 1, 1),
  511. .driver_info = (unsigned long) &rndis_info,
  512. },
  513. { }, // END
  514. };
  515. MODULE_DEVICE_TABLE(usb, products);
  516. static struct usb_driver rndis_driver = {
  517. .name = "rndis_host",
  518. .id_table = products,
  519. .probe = usbnet_probe,
  520. .disconnect = usbnet_disconnect,
  521. .suspend = usbnet_suspend,
  522. .resume = usbnet_resume,
  523. };
  524. static int __init rndis_init(void)
  525. {
  526. return usb_register(&rndis_driver);
  527. }
  528. module_init(rndis_init);
  529. static void __exit rndis_exit(void)
  530. {
  531. usb_deregister(&rndis_driver);
  532. }
  533. module_exit(rndis_exit);
  534. MODULE_AUTHOR("David Brownell");
  535. MODULE_DESCRIPTION("USB Host side RNDIS driver");
  536. MODULE_LICENSE("GPL");