rndis_host.c 18 KB

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