rndis_host.c 17 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. // #define DEBUG // error path messages, extra info
  20. // #define VERBOSE // more; success messages
  21. #include <linux/config.h>
  22. #include <linux/module.h>
  23. #include <linux/sched.h>
  24. #include <linux/init.h>
  25. #include <linux/netdevice.h>
  26. #include <linux/etherdevice.h>
  27. #include <linux/ethtool.h>
  28. #include <linux/workqueue.h>
  29. #include <linux/mii.h>
  30. #include <linux/usb.h>
  31. #include <linux/usb_cdc.h>
  32. #include "usbnet.h"
  33. /*
  34. * RNDIS is NDIS remoted over USB. It's a MSFT variant of CDC ACM ... of
  35. * course ACM was intended for modems, not Ethernet links! USB's standard
  36. * for Ethernet links is "CDC Ethernet", which is significantly simpler.
  37. */
  38. /*
  39. * CONTROL uses CDC "encapsulated commands" with funky notifications.
  40. * - control-out: SEND_ENCAPSULATED
  41. * - interrupt-in: RESPONSE_AVAILABLE
  42. * - control-in: GET_ENCAPSULATED
  43. *
  44. * We'll try to ignore the RESPONSE_AVAILABLE notifications.
  45. */
  46. struct rndis_msg_hdr {
  47. __le32 msg_type; /* RNDIS_MSG_* */
  48. __le32 msg_len;
  49. // followed by data that varies between messages
  50. __le32 request_id;
  51. __le32 status;
  52. // ... and more
  53. } __attribute__ ((packed));
  54. /* RNDIS defines this (absurdly huge) control timeout */
  55. #define RNDIS_CONTROL_TIMEOUT_MS (10 * 1000)
  56. #define ccpu2 __constant_cpu_to_le32
  57. #define RNDIS_MSG_COMPLETION ccpu2(0x80000000)
  58. /* codes for "msg_type" field of rndis messages;
  59. * only the data channel uses packet messages (maybe batched);
  60. * everything else goes on the control channel.
  61. */
  62. #define RNDIS_MSG_PACKET ccpu2(0x00000001) /* 1-N packets */
  63. #define RNDIS_MSG_INIT ccpu2(0x00000002)
  64. #define RNDIS_MSG_INIT_C (RNDIS_MSG_INIT|RNDIS_MSG_COMPLETION)
  65. #define RNDIS_MSG_HALT ccpu2(0x00000003)
  66. #define RNDIS_MSG_QUERY ccpu2(0x00000004)
  67. #define RNDIS_MSG_QUERY_C (RNDIS_MSG_QUERY|RNDIS_MSG_COMPLETION)
  68. #define RNDIS_MSG_SET ccpu2(0x00000005)
  69. #define RNDIS_MSG_SET_C (RNDIS_MSG_SET|RNDIS_MSG_COMPLETION)
  70. #define RNDIS_MSG_RESET ccpu2(0x00000006)
  71. #define RNDIS_MSG_RESET_C (RNDIS_MSG_RESET|RNDIS_MSG_COMPLETION)
  72. #define RNDIS_MSG_INDICATE ccpu2(0x00000007)
  73. #define RNDIS_MSG_KEEPALIVE ccpu2(0x00000008)
  74. #define RNDIS_MSG_KEEPALIVE_C (RNDIS_MSG_KEEPALIVE|RNDIS_MSG_COMPLETION)
  75. /* codes for "status" field of completion messages */
  76. #define RNDIS_STATUS_SUCCESS ccpu2(0x00000000)
  77. #define RNDIS_STATUS_FAILURE ccpu2(0xc0000001)
  78. #define RNDIS_STATUS_INVALID_DATA ccpu2(0xc0010015)
  79. #define RNDIS_STATUS_NOT_SUPPORTED ccpu2(0xc00000bb)
  80. #define RNDIS_STATUS_MEDIA_CONNECT ccpu2(0x4001000b)
  81. #define RNDIS_STATUS_MEDIA_DISCONNECT ccpu2(0x4001000c)
  82. struct rndis_data_hdr {
  83. __le32 msg_type; /* RNDIS_MSG_PACKET */
  84. __le32 msg_len; // rndis_data_hdr + data_len + pad
  85. __le32 data_offset; // 36 -- right after header
  86. __le32 data_len; // ... real packet size
  87. __le32 oob_data_offset; // zero
  88. __le32 oob_data_len; // zero
  89. __le32 num_oob; // zero
  90. __le32 packet_data_offset; // zero
  91. __le32 packet_data_len; // zero
  92. __le32 vc_handle; // zero
  93. __le32 reserved; // zero
  94. } __attribute__ ((packed));
  95. struct rndis_init { /* OUT */
  96. // header and:
  97. __le32 msg_type; /* RNDIS_MSG_INIT */
  98. __le32 msg_len; // 24
  99. __le32 request_id;
  100. __le32 major_version; // of rndis (1.0)
  101. __le32 minor_version;
  102. __le32 max_transfer_size;
  103. } __attribute__ ((packed));
  104. struct rndis_init_c { /* IN */
  105. // header and:
  106. __le32 msg_type; /* RNDIS_MSG_INIT_C */
  107. __le32 msg_len;
  108. __le32 request_id;
  109. __le32 status;
  110. __le32 major_version; // of rndis (1.0)
  111. __le32 minor_version;
  112. __le32 device_flags;
  113. __le32 medium; // zero == 802.3
  114. __le32 max_packets_per_message;
  115. __le32 max_transfer_size;
  116. __le32 packet_alignment; // max 7; (1<<n) bytes
  117. __le32 af_list_offset; // zero
  118. __le32 af_list_size; // zero
  119. } __attribute__ ((packed));
  120. struct rndis_halt { /* OUT (no reply) */
  121. // header and:
  122. __le32 msg_type; /* RNDIS_MSG_HALT */
  123. __le32 msg_len;
  124. __le32 request_id;
  125. } __attribute__ ((packed));
  126. struct rndis_query { /* OUT */
  127. // header and:
  128. __le32 msg_type; /* RNDIS_MSG_QUERY */
  129. __le32 msg_len;
  130. __le32 request_id;
  131. __le32 oid;
  132. __le32 len;
  133. __le32 offset;
  134. /*?*/ __le32 handle; // zero
  135. } __attribute__ ((packed));
  136. struct rndis_query_c { /* IN */
  137. // header and:
  138. __le32 msg_type; /* RNDIS_MSG_QUERY_C */
  139. __le32 msg_len;
  140. __le32 request_id;
  141. __le32 status;
  142. __le32 len;
  143. __le32 offset;
  144. } __attribute__ ((packed));
  145. struct rndis_set { /* OUT */
  146. // header and:
  147. __le32 msg_type; /* RNDIS_MSG_SET */
  148. __le32 msg_len;
  149. __le32 request_id;
  150. __le32 oid;
  151. __le32 len;
  152. __le32 offset;
  153. /*?*/ __le32 handle; // zero
  154. } __attribute__ ((packed));
  155. struct rndis_set_c { /* IN */
  156. // header and:
  157. __le32 msg_type; /* RNDIS_MSG_SET_C */
  158. __le32 msg_len;
  159. __le32 request_id;
  160. __le32 status;
  161. } __attribute__ ((packed));
  162. struct rndis_reset { /* IN */
  163. // header and:
  164. __le32 msg_type; /* RNDIS_MSG_RESET */
  165. __le32 msg_len;
  166. __le32 reserved;
  167. } __attribute__ ((packed));
  168. struct rndis_reset_c { /* OUT */
  169. // header and:
  170. __le32 msg_type; /* RNDIS_MSG_RESET_C */
  171. __le32 msg_len;
  172. __le32 status;
  173. __le32 addressing_lost;
  174. } __attribute__ ((packed));
  175. struct rndis_indicate { /* IN (unrequested) */
  176. // header and:
  177. __le32 msg_type; /* RNDIS_MSG_INDICATE */
  178. __le32 msg_len;
  179. __le32 status;
  180. __le32 length;
  181. __le32 offset;
  182. /**/ __le32 diag_status;
  183. __le32 error_offset;
  184. /**/ __le32 message;
  185. } __attribute__ ((packed));
  186. struct rndis_keepalive { /* OUT (optionally IN) */
  187. // header and:
  188. __le32 msg_type; /* RNDIS_MSG_KEEPALIVE */
  189. __le32 msg_len;
  190. __le32 request_id;
  191. } __attribute__ ((packed));
  192. struct rndis_keepalive_c { /* IN (optionally OUT) */
  193. // header and:
  194. __le32 msg_type; /* RNDIS_MSG_KEEPALIVE_C */
  195. __le32 msg_len;
  196. __le32 request_id;
  197. __le32 status;
  198. } __attribute__ ((packed));
  199. /* NOTE: about 30 OIDs are "mandatory" for peripherals to support ... and
  200. * there are gobs more that may optionally be supported. We'll avoid as much
  201. * of that mess as possible.
  202. */
  203. #define OID_802_3_PERMANENT_ADDRESS ccpu2(0x01010101)
  204. #define OID_GEN_CURRENT_PACKET_FILTER ccpu2(0x0001010e)
  205. /*
  206. * RNDIS notifications from device: command completion; "reverse"
  207. * keepalives; etc
  208. */
  209. static void rndis_status(struct usbnet *dev, struct urb *urb)
  210. {
  211. devdbg(dev, "rndis status urb, len %d stat %d",
  212. urb->actual_length, urb->status);
  213. // FIXME for keepalives, respond immediately (asynchronously)
  214. // if not an RNDIS status, do like cdc_status(dev,urb) does
  215. }
  216. /*
  217. * RPC done RNDIS-style. Caller guarantees:
  218. * - message is properly byteswapped
  219. * - there's no other request pending
  220. * - buf can hold up to 1KB response (required by RNDIS spec)
  221. * On return, the first few entries are already byteswapped.
  222. *
  223. * Call context is likely probe(), before interface name is known,
  224. * which is why we won't try to use it in the diagnostics.
  225. */
  226. static int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf)
  227. {
  228. struct cdc_state *info = (void *) &dev->data;
  229. int retval;
  230. unsigned count;
  231. __le32 rsp;
  232. u32 xid = 0, msg_len, request_id;
  233. /* REVISIT when this gets called from contexts other than probe() or
  234. * disconnect(): either serialize, or dispatch responses on xid
  235. */
  236. /* Issue the request; don't bother byteswapping our xid */
  237. if (likely(buf->msg_type != RNDIS_MSG_HALT
  238. && buf->msg_type != RNDIS_MSG_RESET)) {
  239. xid = dev->xid++;
  240. if (!xid)
  241. xid = dev->xid++;
  242. buf->request_id = (__force __le32) xid;
  243. }
  244. retval = usb_control_msg(dev->udev,
  245. usb_sndctrlpipe(dev->udev, 0),
  246. USB_CDC_SEND_ENCAPSULATED_COMMAND,
  247. USB_TYPE_CLASS | USB_RECIP_INTERFACE,
  248. 0, info->u->bMasterInterface0,
  249. buf, le32_to_cpu(buf->msg_len),
  250. RNDIS_CONTROL_TIMEOUT_MS);
  251. if (unlikely(retval < 0 || xid == 0))
  252. return retval;
  253. // FIXME Seems like some devices discard responses when
  254. // we time out and cancel our "get response" requests...
  255. // so, this is fragile. Probably need to poll for status.
  256. /* ignore status endpoint, just poll the control channel;
  257. * the request probably completed immediately
  258. */
  259. rsp = buf->msg_type | RNDIS_MSG_COMPLETION;
  260. for (count = 0; count < 10; count++) {
  261. memset(buf, 0, 1024);
  262. retval = usb_control_msg(dev->udev,
  263. usb_rcvctrlpipe(dev->udev, 0),
  264. USB_CDC_GET_ENCAPSULATED_RESPONSE,
  265. USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
  266. 0, info->u->bMasterInterface0,
  267. buf, 1024,
  268. RNDIS_CONTROL_TIMEOUT_MS);
  269. if (likely(retval >= 8)) {
  270. msg_len = le32_to_cpu(buf->msg_len);
  271. request_id = (__force u32) buf->request_id;
  272. if (likely(buf->msg_type == rsp)) {
  273. if (likely(request_id == xid)) {
  274. if (unlikely(rsp == RNDIS_MSG_RESET_C))
  275. return 0;
  276. if (likely(RNDIS_STATUS_SUCCESS
  277. == buf->status))
  278. return 0;
  279. dev_dbg(&info->control->dev,
  280. "rndis reply status %08x\n",
  281. le32_to_cpu(buf->status));
  282. return -EL3RST;
  283. }
  284. dev_dbg(&info->control->dev,
  285. "rndis reply id %d expected %d\n",
  286. request_id, xid);
  287. /* then likely retry */
  288. } else switch (buf->msg_type) {
  289. case RNDIS_MSG_INDICATE: { /* fault */
  290. // struct rndis_indicate *msg = (void *)buf;
  291. dev_info(&info->control->dev,
  292. "rndis fault indication\n");
  293. }
  294. break;
  295. case RNDIS_MSG_KEEPALIVE: { /* ping */
  296. struct rndis_keepalive_c *msg = (void *)buf;
  297. msg->msg_type = RNDIS_MSG_KEEPALIVE_C;
  298. msg->msg_len = ccpu2(sizeof *msg);
  299. msg->status = RNDIS_STATUS_SUCCESS;
  300. retval = usb_control_msg(dev->udev,
  301. usb_sndctrlpipe(dev->udev, 0),
  302. USB_CDC_SEND_ENCAPSULATED_COMMAND,
  303. USB_TYPE_CLASS | USB_RECIP_INTERFACE,
  304. 0, info->u->bMasterInterface0,
  305. msg, sizeof *msg,
  306. RNDIS_CONTROL_TIMEOUT_MS);
  307. if (unlikely(retval < 0))
  308. dev_dbg(&info->control->dev,
  309. "rndis keepalive err %d\n",
  310. retval);
  311. }
  312. break;
  313. default:
  314. dev_dbg(&info->control->dev,
  315. "unexpected rndis msg %08x len %d\n",
  316. le32_to_cpu(buf->msg_type), msg_len);
  317. }
  318. } else {
  319. /* device probably issued a protocol stall; ignore */
  320. dev_dbg(&info->control->dev,
  321. "rndis response error, code %d\n", retval);
  322. }
  323. msleep(2);
  324. }
  325. dev_dbg(&info->control->dev, "rndis response timeout\n");
  326. return -ETIMEDOUT;
  327. }
  328. static int rndis_bind(struct usbnet *dev, struct usb_interface *intf)
  329. {
  330. int retval;
  331. struct net_device *net = dev->net;
  332. union {
  333. void *buf;
  334. struct rndis_msg_hdr *header;
  335. struct rndis_init *init;
  336. struct rndis_init_c *init_c;
  337. struct rndis_query *get;
  338. struct rndis_query_c *get_c;
  339. struct rndis_set *set;
  340. struct rndis_set_c *set_c;
  341. } u;
  342. u32 tmp;
  343. /* we can't rely on i/o from stack working, or stack allocation */
  344. u.buf = kmalloc(1024, GFP_KERNEL);
  345. if (!u.buf)
  346. return -ENOMEM;
  347. retval = usbnet_generic_cdc_bind(dev, intf);
  348. if (retval < 0)
  349. goto done;
  350. net->hard_header_len += sizeof (struct rndis_data_hdr);
  351. /* initialize; max transfer is 16KB at full speed */
  352. u.init->msg_type = RNDIS_MSG_INIT;
  353. u.init->msg_len = ccpu2(sizeof *u.init);
  354. u.init->major_version = ccpu2(1);
  355. u.init->minor_version = ccpu2(0);
  356. u.init->max_transfer_size = ccpu2(net->mtu + net->hard_header_len);
  357. retval = rndis_command(dev, u.header);
  358. if (unlikely(retval < 0)) {
  359. /* it might not even be an RNDIS device!! */
  360. dev_err(&intf->dev, "RNDIS init failed, %d\n", retval);
  361. fail:
  362. usb_driver_release_interface(driver_of(intf),
  363. ((struct cdc_state *)&(dev->data))->data);
  364. goto done;
  365. }
  366. dev->hard_mtu = le32_to_cpu(u.init_c->max_transfer_size);
  367. /* REVISIT: peripheral "alignment" request is ignored ... */
  368. dev_dbg(&intf->dev, "hard mtu %u, align %d\n", dev->hard_mtu,
  369. 1 << le32_to_cpu(u.init_c->packet_alignment));
  370. /* get designated host ethernet address */
  371. memset(u.get, 0, sizeof *u.get);
  372. u.get->msg_type = RNDIS_MSG_QUERY;
  373. u.get->msg_len = ccpu2(sizeof *u.get);
  374. u.get->oid = OID_802_3_PERMANENT_ADDRESS;
  375. retval = rndis_command(dev, u.header);
  376. if (unlikely(retval < 0)) {
  377. dev_err(&intf->dev, "rndis get ethaddr, %d\n", retval);
  378. goto fail;
  379. }
  380. tmp = le32_to_cpu(u.get_c->offset);
  381. if (unlikely((tmp + 8) > (1024 - ETH_ALEN)
  382. || u.get_c->len != ccpu2(ETH_ALEN))) {
  383. dev_err(&intf->dev, "rndis ethaddr off %d len %d ?\n",
  384. tmp, le32_to_cpu(u.get_c->len));
  385. retval = -EDOM;
  386. goto fail;
  387. }
  388. memcpy(net->dev_addr, tmp + (char *)&u.get_c->request_id, ETH_ALEN);
  389. /* set a nonzero filter to enable data transfers */
  390. memset(u.set, 0, sizeof *u.set);
  391. u.set->msg_type = RNDIS_MSG_SET;
  392. u.set->msg_len = ccpu2(4 + sizeof *u.set);
  393. u.set->oid = OID_GEN_CURRENT_PACKET_FILTER;
  394. u.set->len = ccpu2(4);
  395. u.set->offset = ccpu2((sizeof *u.set) - 8);
  396. *(__le32 *)(u.buf + sizeof *u.set) = ccpu2(DEFAULT_FILTER);
  397. retval = rndis_command(dev, u.header);
  398. if (unlikely(retval < 0)) {
  399. dev_err(&intf->dev, "rndis set packet filter, %d\n", retval);
  400. goto fail;
  401. }
  402. retval = 0;
  403. done:
  404. kfree(u.buf);
  405. return retval;
  406. }
  407. static void rndis_unbind(struct usbnet *dev, struct usb_interface *intf)
  408. {
  409. struct rndis_halt *halt;
  410. /* try to clear any rndis state/activity (no i/o from stack!) */
  411. halt = kcalloc(1, sizeof *halt, SLAB_KERNEL);
  412. if (halt) {
  413. halt->msg_type = RNDIS_MSG_HALT;
  414. halt->msg_len = ccpu2(sizeof *halt);
  415. (void) rndis_command(dev, (void *)halt);
  416. kfree(halt);
  417. }
  418. return usbnet_cdc_unbind(dev, intf);
  419. }
  420. /*
  421. * DATA -- host must not write zlps
  422. */
  423. static 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. static struct sk_buff *
  461. rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
  462. {
  463. struct rndis_data_hdr *hdr;
  464. struct sk_buff *skb2;
  465. unsigned len = skb->len;
  466. if (likely(!skb_cloned(skb))) {
  467. int room = skb_headroom(skb);
  468. /* enough head room as-is? */
  469. if (unlikely((sizeof *hdr) <= room))
  470. goto fill;
  471. /* enough room, but needs to be readjusted? */
  472. room += skb_tailroom(skb);
  473. if (likely((sizeof *hdr) <= room)) {
  474. skb->data = memmove(skb->head + sizeof *hdr,
  475. skb->data, len);
  476. skb->tail = skb->data + len;
  477. goto fill;
  478. }
  479. }
  480. /* create a new skb, with the correct size (and tailpad) */
  481. skb2 = skb_copy_expand(skb, sizeof *hdr, 1, flags);
  482. dev_kfree_skb_any(skb);
  483. if (unlikely(!skb2))
  484. return skb2;
  485. skb = skb2;
  486. /* fill out the RNDIS header. we won't bother trying to batch
  487. * packets; Linux minimizes wasted bandwidth through tx queues.
  488. */
  489. fill:
  490. hdr = (void *) __skb_push(skb, sizeof *hdr);
  491. memset(hdr, 0, sizeof *hdr);
  492. hdr->msg_type = RNDIS_MSG_PACKET;
  493. hdr->msg_len = cpu_to_le32(skb->len);
  494. hdr->data_offset = ccpu2(sizeof(*hdr) - 8);
  495. hdr->data_len = cpu_to_le32(len);
  496. /* FIXME make the last packet always be short ... */
  497. return skb;
  498. }
  499. static const struct driver_info rndis_info = {
  500. .description = "RNDIS device",
  501. .flags = FLAG_ETHER | FLAG_FRAMING_RN,
  502. .bind = rndis_bind,
  503. .unbind = rndis_unbind,
  504. .status = rndis_status,
  505. .rx_fixup = rndis_rx_fixup,
  506. .tx_fixup = rndis_tx_fixup,
  507. };
  508. #undef ccpu2
  509. /*-------------------------------------------------------------------------*/
  510. static const struct usb_device_id products [] = {
  511. {
  512. /* RNDIS is MSFT's un-official variant of CDC ACM */
  513. USB_INTERFACE_INFO(USB_CLASS_COMM, 2 /* ACM */, 0x0ff),
  514. .driver_info = (unsigned long) &rndis_info,
  515. },
  516. { }, // END
  517. };
  518. MODULE_DEVICE_TABLE(usb, products);
  519. static struct usb_driver rndis_driver = {
  520. .name = "rndis_host",
  521. .id_table = products,
  522. .probe = usbnet_probe,
  523. .disconnect = usbnet_disconnect,
  524. .suspend = usbnet_suspend,
  525. .resume = usbnet_resume,
  526. };
  527. static int __init rndis_init(void)
  528. {
  529. return usb_register(&rndis_driver);
  530. }
  531. module_init(rndis_init);
  532. static void __exit rndis_exit(void)
  533. {
  534. usb_deregister(&rndis_driver);
  535. }
  536. module_exit(rndis_exit);
  537. MODULE_AUTHOR("David Brownell");
  538. MODULE_DESCRIPTION("USB Host side RNDIS driver");
  539. MODULE_LICENSE("GPL");