15b2fc499SJeff Garzik /* 25b2fc499SJeff Garzik * Host Side support for RNDIS Networking Links 35b2fc499SJeff Garzik * Copyright (C) 2005 by David Brownell 45b2fc499SJeff Garzik * 55b2fc499SJeff Garzik * This program is free software; you can redistribute it and/or modify 65b2fc499SJeff Garzik * it under the terms of the GNU General Public License as published by 75b2fc499SJeff Garzik * the Free Software Foundation; either version 2 of the License, or 85b2fc499SJeff Garzik * (at your option) any later version. 95b2fc499SJeff Garzik * 105b2fc499SJeff Garzik * This program is distributed in the hope that it will be useful, 115b2fc499SJeff Garzik * but WITHOUT ANY WARRANTY; without even the implied warranty of 125b2fc499SJeff Garzik * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 135b2fc499SJeff Garzik * GNU General Public License for more details. 145b2fc499SJeff Garzik * 155b2fc499SJeff Garzik * You should have received a copy of the GNU General Public License 165b2fc499SJeff Garzik * along with this program; if not, write to the Free Software 175b2fc499SJeff Garzik * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 185b2fc499SJeff Garzik */ 195b2fc499SJeff Garzik 205b2fc499SJeff Garzik // #define DEBUG // error path messages, extra info 215b2fc499SJeff Garzik // #define VERBOSE // more; success messages 225b2fc499SJeff Garzik 235b2fc499SJeff Garzik #include <linux/module.h> 245b2fc499SJeff Garzik #include <linux/init.h> 255b2fc499SJeff Garzik #include <linux/netdevice.h> 265b2fc499SJeff Garzik #include <linux/etherdevice.h> 275b2fc499SJeff Garzik #include <linux/ethtool.h> 285b2fc499SJeff Garzik #include <linux/workqueue.h> 295b2fc499SJeff Garzik #include <linux/mii.h> 305b2fc499SJeff Garzik #include <linux/usb.h> 315b2fc499SJeff Garzik #include <linux/usb/cdc.h> 325b2fc499SJeff Garzik 335b2fc499SJeff Garzik #include "usbnet.h" 345b2fc499SJeff Garzik 355b2fc499SJeff Garzik 365b2fc499SJeff Garzik /* 375b2fc499SJeff Garzik * RNDIS is NDIS remoted over USB. It's a MSFT variant of CDC ACM ... of 385b2fc499SJeff Garzik * course ACM was intended for modems, not Ethernet links! USB's standard 395b2fc499SJeff Garzik * for Ethernet links is "CDC Ethernet", which is significantly simpler. 405b2fc499SJeff Garzik * 415b2fc499SJeff Garzik * NOTE that Microsoft's "RNDIS 1.0" specification is incomplete. Issues 425b2fc499SJeff Garzik * include: 435b2fc499SJeff Garzik * - Power management in particular relies on information that's scattered 445b2fc499SJeff Garzik * through other documentation, and which is incomplete or incorrect even 455b2fc499SJeff Garzik * there. 465b2fc499SJeff Garzik * - There are various undocumented protocol requirements, such as the 475b2fc499SJeff Garzik * need to send unused garbage in control-OUT messages. 485b2fc499SJeff Garzik * - In some cases, MS-Windows will emit undocumented requests; this 495b2fc499SJeff Garzik * matters more to peripheral implementations than host ones. 505b2fc499SJeff Garzik * 515b2fc499SJeff Garzik * Moreover there's a no-open-specs variant of RNDIS called "ActiveSync". 525b2fc499SJeff Garzik * 535b2fc499SJeff Garzik * For these reasons and others, ** USE OF RNDIS IS STRONGLY DISCOURAGED ** in 545b2fc499SJeff Garzik * favor of such non-proprietary alternatives as CDC Ethernet or the newer (and 555b2fc499SJeff Garzik * currently rare) "Ethernet Emulation Model" (EEM). 565b2fc499SJeff Garzik */ 575b2fc499SJeff Garzik 585b2fc499SJeff Garzik /* 595b2fc499SJeff Garzik * CONTROL uses CDC "encapsulated commands" with funky notifications. 605b2fc499SJeff Garzik * - control-out: SEND_ENCAPSULATED 615b2fc499SJeff Garzik * - interrupt-in: RESPONSE_AVAILABLE 625b2fc499SJeff Garzik * - control-in: GET_ENCAPSULATED 635b2fc499SJeff Garzik * 645b2fc499SJeff Garzik * We'll try to ignore the RESPONSE_AVAILABLE notifications. 655b2fc499SJeff Garzik * 665b2fc499SJeff Garzik * REVISIT some RNDIS implementations seem to have curious issues still 675b2fc499SJeff Garzik * to be resolved. 685b2fc499SJeff Garzik */ 695b2fc499SJeff Garzik struct rndis_msg_hdr { 705b2fc499SJeff Garzik __le32 msg_type; /* RNDIS_MSG_* */ 715b2fc499SJeff Garzik __le32 msg_len; 725b2fc499SJeff Garzik // followed by data that varies between messages 735b2fc499SJeff Garzik __le32 request_id; 745b2fc499SJeff Garzik __le32 status; 755b2fc499SJeff Garzik // ... and more 765b2fc499SJeff Garzik } __attribute__ ((packed)); 775b2fc499SJeff Garzik 785b2fc499SJeff Garzik /* MS-Windows uses this strange size, but RNDIS spec says 1024 minimum */ 795b2fc499SJeff Garzik #define CONTROL_BUFFER_SIZE 1025 805b2fc499SJeff Garzik 815b2fc499SJeff Garzik /* RNDIS defines an (absurdly huge) 10 second control timeout, 825b2fc499SJeff Garzik * but ActiveSync seems to use a more usual 5 second timeout 835b2fc499SJeff Garzik * (which matches the USB 2.0 spec). 845b2fc499SJeff Garzik */ 855b2fc499SJeff Garzik #define RNDIS_CONTROL_TIMEOUT_MS (5 * 1000) 865b2fc499SJeff Garzik 875b2fc499SJeff Garzik 885b2fc499SJeff Garzik #define ccpu2 __constant_cpu_to_le32 895b2fc499SJeff Garzik 905b2fc499SJeff Garzik #define RNDIS_MSG_COMPLETION ccpu2(0x80000000) 915b2fc499SJeff Garzik 925b2fc499SJeff Garzik /* codes for "msg_type" field of rndis messages; 935b2fc499SJeff Garzik * only the data channel uses packet messages (maybe batched); 945b2fc499SJeff Garzik * everything else goes on the control channel. 955b2fc499SJeff Garzik */ 965b2fc499SJeff Garzik #define RNDIS_MSG_PACKET ccpu2(0x00000001) /* 1-N packets */ 975b2fc499SJeff Garzik #define RNDIS_MSG_INIT ccpu2(0x00000002) 985b2fc499SJeff Garzik #define RNDIS_MSG_INIT_C (RNDIS_MSG_INIT|RNDIS_MSG_COMPLETION) 995b2fc499SJeff Garzik #define RNDIS_MSG_HALT ccpu2(0x00000003) 1005b2fc499SJeff Garzik #define RNDIS_MSG_QUERY ccpu2(0x00000004) 1015b2fc499SJeff Garzik #define RNDIS_MSG_QUERY_C (RNDIS_MSG_QUERY|RNDIS_MSG_COMPLETION) 1025b2fc499SJeff Garzik #define RNDIS_MSG_SET ccpu2(0x00000005) 1035b2fc499SJeff Garzik #define RNDIS_MSG_SET_C (RNDIS_MSG_SET|RNDIS_MSG_COMPLETION) 1045b2fc499SJeff Garzik #define RNDIS_MSG_RESET ccpu2(0x00000006) 1055b2fc499SJeff Garzik #define RNDIS_MSG_RESET_C (RNDIS_MSG_RESET|RNDIS_MSG_COMPLETION) 1065b2fc499SJeff Garzik #define RNDIS_MSG_INDICATE ccpu2(0x00000007) 1075b2fc499SJeff Garzik #define RNDIS_MSG_KEEPALIVE ccpu2(0x00000008) 1085b2fc499SJeff Garzik #define RNDIS_MSG_KEEPALIVE_C (RNDIS_MSG_KEEPALIVE|RNDIS_MSG_COMPLETION) 1095b2fc499SJeff Garzik 1105b2fc499SJeff Garzik /* codes for "status" field of completion messages */ 1115b2fc499SJeff Garzik #define RNDIS_STATUS_SUCCESS ccpu2(0x00000000) 1125b2fc499SJeff Garzik #define RNDIS_STATUS_FAILURE ccpu2(0xc0000001) 1135b2fc499SJeff Garzik #define RNDIS_STATUS_INVALID_DATA ccpu2(0xc0010015) 1145b2fc499SJeff Garzik #define RNDIS_STATUS_NOT_SUPPORTED ccpu2(0xc00000bb) 1155b2fc499SJeff Garzik #define RNDIS_STATUS_MEDIA_CONNECT ccpu2(0x4001000b) 1165b2fc499SJeff Garzik #define RNDIS_STATUS_MEDIA_DISCONNECT ccpu2(0x4001000c) 1175b2fc499SJeff Garzik 1185b2fc499SJeff Garzik 1195b2fc499SJeff Garzik struct rndis_data_hdr { 1205b2fc499SJeff Garzik __le32 msg_type; /* RNDIS_MSG_PACKET */ 1215b2fc499SJeff Garzik __le32 msg_len; // rndis_data_hdr + data_len + pad 1225b2fc499SJeff Garzik __le32 data_offset; // 36 -- right after header 1235b2fc499SJeff Garzik __le32 data_len; // ... real packet size 1245b2fc499SJeff Garzik 1255b2fc499SJeff Garzik __le32 oob_data_offset; // zero 1265b2fc499SJeff Garzik __le32 oob_data_len; // zero 1275b2fc499SJeff Garzik __le32 num_oob; // zero 1285b2fc499SJeff Garzik __le32 packet_data_offset; // zero 1295b2fc499SJeff Garzik 1305b2fc499SJeff Garzik __le32 packet_data_len; // zero 1315b2fc499SJeff Garzik __le32 vc_handle; // zero 1325b2fc499SJeff Garzik __le32 reserved; // zero 1335b2fc499SJeff Garzik } __attribute__ ((packed)); 1345b2fc499SJeff Garzik 1355b2fc499SJeff Garzik struct rndis_init { /* OUT */ 1365b2fc499SJeff Garzik // header and: 1375b2fc499SJeff Garzik __le32 msg_type; /* RNDIS_MSG_INIT */ 1385b2fc499SJeff Garzik __le32 msg_len; // 24 1395b2fc499SJeff Garzik __le32 request_id; 1405b2fc499SJeff Garzik __le32 major_version; // of rndis (1.0) 1415b2fc499SJeff Garzik __le32 minor_version; 1425b2fc499SJeff Garzik __le32 max_transfer_size; 1435b2fc499SJeff Garzik } __attribute__ ((packed)); 1445b2fc499SJeff Garzik 1455b2fc499SJeff Garzik struct rndis_init_c { /* IN */ 1465b2fc499SJeff Garzik // header and: 1475b2fc499SJeff Garzik __le32 msg_type; /* RNDIS_MSG_INIT_C */ 1485b2fc499SJeff Garzik __le32 msg_len; 1495b2fc499SJeff Garzik __le32 request_id; 1505b2fc499SJeff Garzik __le32 status; 1515b2fc499SJeff Garzik __le32 major_version; // of rndis (1.0) 1525b2fc499SJeff Garzik __le32 minor_version; 1535b2fc499SJeff Garzik __le32 device_flags; 1545b2fc499SJeff Garzik __le32 medium; // zero == 802.3 1555b2fc499SJeff Garzik __le32 max_packets_per_message; 1565b2fc499SJeff Garzik __le32 max_transfer_size; 1575b2fc499SJeff Garzik __le32 packet_alignment; // max 7; (1<<n) bytes 1585b2fc499SJeff Garzik __le32 af_list_offset; // zero 1595b2fc499SJeff Garzik __le32 af_list_size; // zero 1605b2fc499SJeff Garzik } __attribute__ ((packed)); 1615b2fc499SJeff Garzik 1625b2fc499SJeff Garzik struct rndis_halt { /* OUT (no reply) */ 1635b2fc499SJeff Garzik // header and: 1645b2fc499SJeff Garzik __le32 msg_type; /* RNDIS_MSG_HALT */ 1655b2fc499SJeff Garzik __le32 msg_len; 1665b2fc499SJeff Garzik __le32 request_id; 1675b2fc499SJeff Garzik } __attribute__ ((packed)); 1685b2fc499SJeff Garzik 1695b2fc499SJeff Garzik struct rndis_query { /* OUT */ 1705b2fc499SJeff Garzik // header and: 1715b2fc499SJeff Garzik __le32 msg_type; /* RNDIS_MSG_QUERY */ 1725b2fc499SJeff Garzik __le32 msg_len; 1735b2fc499SJeff Garzik __le32 request_id; 1745b2fc499SJeff Garzik __le32 oid; 1755b2fc499SJeff Garzik __le32 len; 1765b2fc499SJeff Garzik __le32 offset; 1775b2fc499SJeff Garzik /*?*/ __le32 handle; // zero 1785b2fc499SJeff Garzik } __attribute__ ((packed)); 1795b2fc499SJeff Garzik 1805b2fc499SJeff Garzik struct rndis_query_c { /* IN */ 1815b2fc499SJeff Garzik // header and: 1825b2fc499SJeff Garzik __le32 msg_type; /* RNDIS_MSG_QUERY_C */ 1835b2fc499SJeff Garzik __le32 msg_len; 1845b2fc499SJeff Garzik __le32 request_id; 1855b2fc499SJeff Garzik __le32 status; 1865b2fc499SJeff Garzik __le32 len; 1875b2fc499SJeff Garzik __le32 offset; 1885b2fc499SJeff Garzik } __attribute__ ((packed)); 1895b2fc499SJeff Garzik 1905b2fc499SJeff Garzik struct rndis_set { /* OUT */ 1915b2fc499SJeff Garzik // header and: 1925b2fc499SJeff Garzik __le32 msg_type; /* RNDIS_MSG_SET */ 1935b2fc499SJeff Garzik __le32 msg_len; 1945b2fc499SJeff Garzik __le32 request_id; 1955b2fc499SJeff Garzik __le32 oid; 1965b2fc499SJeff Garzik __le32 len; 1975b2fc499SJeff Garzik __le32 offset; 1985b2fc499SJeff Garzik /*?*/ __le32 handle; // zero 1995b2fc499SJeff Garzik } __attribute__ ((packed)); 2005b2fc499SJeff Garzik 2015b2fc499SJeff Garzik struct rndis_set_c { /* IN */ 2025b2fc499SJeff Garzik // header and: 2035b2fc499SJeff Garzik __le32 msg_type; /* RNDIS_MSG_SET_C */ 2045b2fc499SJeff Garzik __le32 msg_len; 2055b2fc499SJeff Garzik __le32 request_id; 2065b2fc499SJeff Garzik __le32 status; 2075b2fc499SJeff Garzik } __attribute__ ((packed)); 2085b2fc499SJeff Garzik 2095b2fc499SJeff Garzik struct rndis_reset { /* IN */ 2105b2fc499SJeff Garzik // header and: 2115b2fc499SJeff Garzik __le32 msg_type; /* RNDIS_MSG_RESET */ 2125b2fc499SJeff Garzik __le32 msg_len; 2135b2fc499SJeff Garzik __le32 reserved; 2145b2fc499SJeff Garzik } __attribute__ ((packed)); 2155b2fc499SJeff Garzik 2165b2fc499SJeff Garzik struct rndis_reset_c { /* OUT */ 2175b2fc499SJeff Garzik // header and: 2185b2fc499SJeff Garzik __le32 msg_type; /* RNDIS_MSG_RESET_C */ 2195b2fc499SJeff Garzik __le32 msg_len; 2205b2fc499SJeff Garzik __le32 status; 2215b2fc499SJeff Garzik __le32 addressing_lost; 2225b2fc499SJeff Garzik } __attribute__ ((packed)); 2235b2fc499SJeff Garzik 2245b2fc499SJeff Garzik struct rndis_indicate { /* IN (unrequested) */ 2255b2fc499SJeff Garzik // header and: 2265b2fc499SJeff Garzik __le32 msg_type; /* RNDIS_MSG_INDICATE */ 2275b2fc499SJeff Garzik __le32 msg_len; 2285b2fc499SJeff Garzik __le32 status; 2295b2fc499SJeff Garzik __le32 length; 2305b2fc499SJeff Garzik __le32 offset; 2315b2fc499SJeff Garzik /**/ __le32 diag_status; 2325b2fc499SJeff Garzik __le32 error_offset; 2335b2fc499SJeff Garzik /**/ __le32 message; 2345b2fc499SJeff Garzik } __attribute__ ((packed)); 2355b2fc499SJeff Garzik 2365b2fc499SJeff Garzik struct rndis_keepalive { /* OUT (optionally IN) */ 2375b2fc499SJeff Garzik // header and: 2385b2fc499SJeff Garzik __le32 msg_type; /* RNDIS_MSG_KEEPALIVE */ 2395b2fc499SJeff Garzik __le32 msg_len; 2405b2fc499SJeff Garzik __le32 request_id; 2415b2fc499SJeff Garzik } __attribute__ ((packed)); 2425b2fc499SJeff Garzik 2435b2fc499SJeff Garzik struct rndis_keepalive_c { /* IN (optionally OUT) */ 2445b2fc499SJeff Garzik // header and: 2455b2fc499SJeff Garzik __le32 msg_type; /* RNDIS_MSG_KEEPALIVE_C */ 2465b2fc499SJeff Garzik __le32 msg_len; 2475b2fc499SJeff Garzik __le32 request_id; 2485b2fc499SJeff Garzik __le32 status; 2495b2fc499SJeff Garzik } __attribute__ ((packed)); 2505b2fc499SJeff Garzik 2515b2fc499SJeff Garzik /* NOTE: about 30 OIDs are "mandatory" for peripherals to support ... and 2525b2fc499SJeff Garzik * there are gobs more that may optionally be supported. We'll avoid as much 2535b2fc499SJeff Garzik * of that mess as possible. 2545b2fc499SJeff Garzik */ 2555b2fc499SJeff Garzik #define OID_802_3_PERMANENT_ADDRESS ccpu2(0x01010101) 2565b2fc499SJeff Garzik #define OID_GEN_MAXIMUM_FRAME_SIZE ccpu2(0x00010106) 2575b2fc499SJeff Garzik #define OID_GEN_CURRENT_PACKET_FILTER ccpu2(0x0001010e) 2585b2fc499SJeff Garzik 2595b2fc499SJeff Garzik /* 2605b2fc499SJeff Garzik * RNDIS notifications from device: command completion; "reverse" 2615b2fc499SJeff Garzik * keepalives; etc 2625b2fc499SJeff Garzik */ 2635b2fc499SJeff Garzik static void rndis_status(struct usbnet *dev, struct urb *urb) 2645b2fc499SJeff Garzik { 2655b2fc499SJeff Garzik devdbg(dev, "rndis status urb, len %d stat %d", 2665b2fc499SJeff Garzik urb->actual_length, urb->status); 2675b2fc499SJeff Garzik // FIXME for keepalives, respond immediately (asynchronously) 2685b2fc499SJeff Garzik // if not an RNDIS status, do like cdc_status(dev,urb) does 2695b2fc499SJeff Garzik } 2705b2fc499SJeff Garzik 2715b2fc499SJeff Garzik /* 2725b2fc499SJeff Garzik * RPC done RNDIS-style. Caller guarantees: 2735b2fc499SJeff Garzik * - message is properly byteswapped 2745b2fc499SJeff Garzik * - there's no other request pending 2755b2fc499SJeff Garzik * - buf can hold up to 1KB response (required by RNDIS spec) 2765b2fc499SJeff Garzik * On return, the first few entries are already byteswapped. 2775b2fc499SJeff Garzik * 2785b2fc499SJeff Garzik * Call context is likely probe(), before interface name is known, 2795b2fc499SJeff Garzik * which is why we won't try to use it in the diagnostics. 2805b2fc499SJeff Garzik */ 2815b2fc499SJeff Garzik static int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf) 2825b2fc499SJeff Garzik { 2835b2fc499SJeff Garzik struct cdc_state *info = (void *) &dev->data; 2845b2fc499SJeff Garzik int master_ifnum; 2855b2fc499SJeff Garzik int retval; 2865b2fc499SJeff Garzik unsigned count; 2875b2fc499SJeff Garzik __le32 rsp; 2885b2fc499SJeff Garzik u32 xid = 0, msg_len, request_id; 2895b2fc499SJeff Garzik 2905b2fc499SJeff Garzik /* REVISIT when this gets called from contexts other than probe() or 2915b2fc499SJeff Garzik * disconnect(): either serialize, or dispatch responses on xid 2925b2fc499SJeff Garzik */ 2935b2fc499SJeff Garzik 2945b2fc499SJeff Garzik /* Issue the request; xid is unique, don't bother byteswapping it */ 2955b2fc499SJeff Garzik if (likely(buf->msg_type != RNDIS_MSG_HALT 2965b2fc499SJeff Garzik && buf->msg_type != RNDIS_MSG_RESET)) { 2975b2fc499SJeff Garzik xid = dev->xid++; 2985b2fc499SJeff Garzik if (!xid) 2995b2fc499SJeff Garzik xid = dev->xid++; 3005b2fc499SJeff Garzik buf->request_id = (__force __le32) xid; 3015b2fc499SJeff Garzik } 3025b2fc499SJeff Garzik master_ifnum = info->control->cur_altsetting->desc.bInterfaceNumber; 3035b2fc499SJeff Garzik retval = usb_control_msg(dev->udev, 3045b2fc499SJeff Garzik usb_sndctrlpipe(dev->udev, 0), 3055b2fc499SJeff Garzik USB_CDC_SEND_ENCAPSULATED_COMMAND, 3065b2fc499SJeff Garzik USB_TYPE_CLASS | USB_RECIP_INTERFACE, 3075b2fc499SJeff Garzik 0, master_ifnum, 3085b2fc499SJeff Garzik buf, le32_to_cpu(buf->msg_len), 3095b2fc499SJeff Garzik RNDIS_CONTROL_TIMEOUT_MS); 3105b2fc499SJeff Garzik if (unlikely(retval < 0 || xid == 0)) 3115b2fc499SJeff Garzik return retval; 3125b2fc499SJeff Garzik 3135b2fc499SJeff Garzik // FIXME Seems like some devices discard responses when 3145b2fc499SJeff Garzik // we time out and cancel our "get response" requests... 3155b2fc499SJeff Garzik // so, this is fragile. Probably need to poll for status. 3165b2fc499SJeff Garzik 3175b2fc499SJeff Garzik /* ignore status endpoint, just poll the control channel; 3185b2fc499SJeff Garzik * the request probably completed immediately 3195b2fc499SJeff Garzik */ 3205b2fc499SJeff Garzik rsp = buf->msg_type | RNDIS_MSG_COMPLETION; 3215b2fc499SJeff Garzik for (count = 0; count < 10; count++) { 3225b2fc499SJeff Garzik memset(buf, 0, CONTROL_BUFFER_SIZE); 3235b2fc499SJeff Garzik retval = usb_control_msg(dev->udev, 3245b2fc499SJeff Garzik usb_rcvctrlpipe(dev->udev, 0), 3255b2fc499SJeff Garzik USB_CDC_GET_ENCAPSULATED_RESPONSE, 3265b2fc499SJeff Garzik USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 3275b2fc499SJeff Garzik 0, master_ifnum, 3285b2fc499SJeff Garzik buf, CONTROL_BUFFER_SIZE, 3295b2fc499SJeff Garzik RNDIS_CONTROL_TIMEOUT_MS); 3305b2fc499SJeff Garzik if (likely(retval >= 8)) { 3315b2fc499SJeff Garzik msg_len = le32_to_cpu(buf->msg_len); 3325b2fc499SJeff Garzik request_id = (__force u32) buf->request_id; 3335b2fc499SJeff Garzik if (likely(buf->msg_type == rsp)) { 3345b2fc499SJeff Garzik if (likely(request_id == xid)) { 3355b2fc499SJeff Garzik if (unlikely(rsp == RNDIS_MSG_RESET_C)) 3365b2fc499SJeff Garzik return 0; 3375b2fc499SJeff Garzik if (likely(RNDIS_STATUS_SUCCESS 3385b2fc499SJeff Garzik == buf->status)) 3395b2fc499SJeff Garzik return 0; 3405b2fc499SJeff Garzik dev_dbg(&info->control->dev, 3415b2fc499SJeff Garzik "rndis reply status %08x\n", 3425b2fc499SJeff Garzik le32_to_cpu(buf->status)); 3435b2fc499SJeff Garzik return -EL3RST; 3445b2fc499SJeff Garzik } 3455b2fc499SJeff Garzik dev_dbg(&info->control->dev, 3465b2fc499SJeff Garzik "rndis reply id %d expected %d\n", 3475b2fc499SJeff Garzik request_id, xid); 3485b2fc499SJeff Garzik /* then likely retry */ 3495b2fc499SJeff Garzik } else switch (buf->msg_type) { 3505b2fc499SJeff Garzik case RNDIS_MSG_INDICATE: { /* fault */ 3515b2fc499SJeff Garzik // struct rndis_indicate *msg = (void *)buf; 3525b2fc499SJeff Garzik dev_info(&info->control->dev, 3535b2fc499SJeff Garzik "rndis fault indication\n"); 3545b2fc499SJeff Garzik } 3555b2fc499SJeff Garzik break; 3565b2fc499SJeff Garzik case RNDIS_MSG_KEEPALIVE: { /* ping */ 3575b2fc499SJeff Garzik struct rndis_keepalive_c *msg = (void *)buf; 3585b2fc499SJeff Garzik 3595b2fc499SJeff Garzik msg->msg_type = RNDIS_MSG_KEEPALIVE_C; 3605b2fc499SJeff Garzik msg->msg_len = ccpu2(sizeof *msg); 3615b2fc499SJeff Garzik msg->status = RNDIS_STATUS_SUCCESS; 3625b2fc499SJeff Garzik retval = usb_control_msg(dev->udev, 3635b2fc499SJeff Garzik usb_sndctrlpipe(dev->udev, 0), 3645b2fc499SJeff Garzik USB_CDC_SEND_ENCAPSULATED_COMMAND, 3655b2fc499SJeff Garzik USB_TYPE_CLASS | USB_RECIP_INTERFACE, 3665b2fc499SJeff Garzik 0, master_ifnum, 3675b2fc499SJeff Garzik msg, sizeof *msg, 3685b2fc499SJeff Garzik RNDIS_CONTROL_TIMEOUT_MS); 3695b2fc499SJeff Garzik if (unlikely(retval < 0)) 3705b2fc499SJeff Garzik dev_dbg(&info->control->dev, 3715b2fc499SJeff Garzik "rndis keepalive err %d\n", 3725b2fc499SJeff Garzik retval); 3735b2fc499SJeff Garzik } 3745b2fc499SJeff Garzik break; 3755b2fc499SJeff Garzik default: 3765b2fc499SJeff Garzik dev_dbg(&info->control->dev, 3775b2fc499SJeff Garzik "unexpected rndis msg %08x len %d\n", 3785b2fc499SJeff Garzik le32_to_cpu(buf->msg_type), msg_len); 3795b2fc499SJeff Garzik } 3805b2fc499SJeff Garzik } else { 3815b2fc499SJeff Garzik /* device probably issued a protocol stall; ignore */ 3825b2fc499SJeff Garzik dev_dbg(&info->control->dev, 3835b2fc499SJeff Garzik "rndis response error, code %d\n", retval); 3845b2fc499SJeff Garzik } 3855b2fc499SJeff Garzik msleep(2); 3865b2fc499SJeff Garzik } 3875b2fc499SJeff Garzik dev_dbg(&info->control->dev, "rndis response timeout\n"); 3885b2fc499SJeff Garzik return -ETIMEDOUT; 3895b2fc499SJeff Garzik } 3905b2fc499SJeff Garzik 3915b2fc499SJeff Garzik /* 3925b2fc499SJeff Garzik * rndis_query: 3935b2fc499SJeff Garzik * 3945b2fc499SJeff Garzik * Performs a query for @oid along with 0 or more bytes of payload as 3955b2fc499SJeff Garzik * specified by @in_len. If @reply_len is not set to -1 then the reply 3965b2fc499SJeff Garzik * length is checked against this value, resulting in an error if it 3975b2fc499SJeff Garzik * doesn't match. 3985b2fc499SJeff Garzik * 3995b2fc499SJeff Garzik * NOTE: Adding a payload exactly or greater than the size of the expected 4005b2fc499SJeff Garzik * response payload is an evident requirement MSFT added for ActiveSync. 4015b2fc499SJeff Garzik * 4025b2fc499SJeff Garzik * The only exception is for OIDs that return a variably sized response, 4035b2fc499SJeff Garzik * in which case no payload should be added. This undocumented (and 4045b2fc499SJeff Garzik * nonsensical!) issue was found by sniffing protocol requests from the 4055b2fc499SJeff Garzik * ActiveSync 4.1 Windows driver. 4065b2fc499SJeff Garzik */ 4075b2fc499SJeff Garzik static int rndis_query(struct usbnet *dev, struct usb_interface *intf, 4085b2fc499SJeff Garzik void *buf, u32 oid, u32 in_len, 4095b2fc499SJeff Garzik void **reply, int *reply_len) 4105b2fc499SJeff Garzik { 4115b2fc499SJeff Garzik int retval; 4125b2fc499SJeff Garzik union { 4135b2fc499SJeff Garzik void *buf; 4145b2fc499SJeff Garzik struct rndis_msg_hdr *header; 4155b2fc499SJeff Garzik struct rndis_query *get; 4165b2fc499SJeff Garzik struct rndis_query_c *get_c; 4175b2fc499SJeff Garzik } u; 4185b2fc499SJeff Garzik u32 off, len; 4195b2fc499SJeff Garzik 4205b2fc499SJeff Garzik u.buf = buf; 4215b2fc499SJeff Garzik 4225b2fc499SJeff Garzik memset(u.get, 0, sizeof *u.get + in_len); 4235b2fc499SJeff Garzik u.get->msg_type = RNDIS_MSG_QUERY; 4245b2fc499SJeff Garzik u.get->msg_len = cpu_to_le32(sizeof *u.get + in_len); 4255b2fc499SJeff Garzik u.get->oid = oid; 4265b2fc499SJeff Garzik u.get->len = cpu_to_le32(in_len); 4275b2fc499SJeff Garzik u.get->offset = ccpu2(20); 4285b2fc499SJeff Garzik 4295b2fc499SJeff Garzik retval = rndis_command(dev, u.header); 4305b2fc499SJeff Garzik if (unlikely(retval < 0)) { 4315b2fc499SJeff Garzik dev_err(&intf->dev, "RNDIS_MSG_QUERY(0x%08x) failed, %d\n", 4325b2fc499SJeff Garzik oid, retval); 4335b2fc499SJeff Garzik return retval; 4345b2fc499SJeff Garzik } 4355b2fc499SJeff Garzik 4365b2fc499SJeff Garzik off = le32_to_cpu(u.get_c->offset); 4375b2fc499SJeff Garzik len = le32_to_cpu(u.get_c->len); 4385b2fc499SJeff Garzik if (unlikely((8 + off + len) > CONTROL_BUFFER_SIZE)) 4395b2fc499SJeff Garzik goto response_error; 4405b2fc499SJeff Garzik 4415b2fc499SJeff Garzik if (*reply_len != -1 && len != *reply_len) 4425b2fc499SJeff Garzik goto response_error; 4435b2fc499SJeff Garzik 4445b2fc499SJeff Garzik *reply = (unsigned char *) &u.get_c->request_id + off; 4455b2fc499SJeff Garzik *reply_len = len; 4465b2fc499SJeff Garzik 4475b2fc499SJeff Garzik return retval; 4485b2fc499SJeff Garzik 4495b2fc499SJeff Garzik response_error: 4505b2fc499SJeff Garzik dev_err(&intf->dev, "RNDIS_MSG_QUERY(0x%08x) " 4515b2fc499SJeff Garzik "invalid response - off %d len %d\n", 4525b2fc499SJeff Garzik oid, off, len); 4535b2fc499SJeff Garzik return -EDOM; 4545b2fc499SJeff Garzik } 4555b2fc499SJeff Garzik 4565b2fc499SJeff Garzik static int rndis_bind(struct usbnet *dev, struct usb_interface *intf) 4575b2fc499SJeff Garzik { 4585b2fc499SJeff Garzik int retval; 4595b2fc499SJeff Garzik struct net_device *net = dev->net; 4605b2fc499SJeff Garzik struct cdc_state *info = (void *) &dev->data; 4615b2fc499SJeff Garzik union { 4625b2fc499SJeff Garzik void *buf; 4635b2fc499SJeff Garzik struct rndis_msg_hdr *header; 4645b2fc499SJeff Garzik struct rndis_init *init; 4655b2fc499SJeff Garzik struct rndis_init_c *init_c; 4665b2fc499SJeff Garzik struct rndis_query *get; 4675b2fc499SJeff Garzik struct rndis_query_c *get_c; 4685b2fc499SJeff Garzik struct rndis_set *set; 4695b2fc499SJeff Garzik struct rndis_set_c *set_c; 4705b2fc499SJeff Garzik } u; 4715b2fc499SJeff Garzik u32 tmp; 4725b2fc499SJeff Garzik int reply_len; 4735b2fc499SJeff Garzik unsigned char *bp; 4745b2fc499SJeff Garzik 4755b2fc499SJeff Garzik /* we can't rely on i/o from stack working, or stack allocation */ 4765b2fc499SJeff Garzik u.buf = kmalloc(CONTROL_BUFFER_SIZE, GFP_KERNEL); 4775b2fc499SJeff Garzik if (!u.buf) 4785b2fc499SJeff Garzik return -ENOMEM; 4795b2fc499SJeff Garzik retval = usbnet_generic_cdc_bind(dev, intf); 4805b2fc499SJeff Garzik if (retval < 0) 4815b2fc499SJeff Garzik goto fail; 4825b2fc499SJeff Garzik 4835b2fc499SJeff Garzik u.init->msg_type = RNDIS_MSG_INIT; 4845b2fc499SJeff Garzik u.init->msg_len = ccpu2(sizeof *u.init); 4855b2fc499SJeff Garzik u.init->major_version = ccpu2(1); 4865b2fc499SJeff Garzik u.init->minor_version = ccpu2(0); 4875b2fc499SJeff Garzik 4885b2fc499SJeff Garzik /* max transfer (in spec) is 0x4000 at full speed, but for 4895b2fc499SJeff Garzik * TX we'll stick to one Ethernet packet plus RNDIS framing. 4905b2fc499SJeff Garzik * For RX we handle drivers that zero-pad to end-of-packet. 4915b2fc499SJeff Garzik * Don't let userspace change these settings. 4925b2fc499SJeff Garzik * 4935b2fc499SJeff Garzik * NOTE: there still seems to be wierdness here, as if we need 4945b2fc499SJeff Garzik * to do some more things to make sure WinCE targets accept this. 4955b2fc499SJeff Garzik * They default to jumbograms of 8KB or 16KB, which is absurd 4965b2fc499SJeff Garzik * for such low data rates and which is also more than Linux 4975b2fc499SJeff Garzik * can usually expect to allocate for SKB data... 4985b2fc499SJeff Garzik */ 4995b2fc499SJeff Garzik net->hard_header_len += sizeof (struct rndis_data_hdr); 5005b2fc499SJeff Garzik dev->hard_mtu = net->mtu + net->hard_header_len; 5015b2fc499SJeff Garzik 5025b2fc499SJeff Garzik dev->rx_urb_size = dev->hard_mtu + (dev->maxpacket + 1); 5035b2fc499SJeff Garzik dev->rx_urb_size &= ~(dev->maxpacket - 1); 5045b2fc499SJeff Garzik u.init->max_transfer_size = cpu_to_le32(dev->rx_urb_size); 5055b2fc499SJeff Garzik 5065b2fc499SJeff Garzik net->change_mtu = NULL; 5075b2fc499SJeff Garzik retval = rndis_command(dev, u.header); 5085b2fc499SJeff Garzik if (unlikely(retval < 0)) { 5095b2fc499SJeff Garzik /* it might not even be an RNDIS device!! */ 5105b2fc499SJeff Garzik dev_err(&intf->dev, "RNDIS init failed, %d\n", retval); 5115b2fc499SJeff Garzik goto fail_and_release; 5125b2fc499SJeff Garzik } 5135b2fc499SJeff Garzik tmp = le32_to_cpu(u.init_c->max_transfer_size); 5145b2fc499SJeff Garzik if (tmp < dev->hard_mtu) { 515500d2c2fSThomas Sailer if (tmp <= net->hard_header_len) { 5165b2fc499SJeff Garzik dev_err(&intf->dev, 5175b2fc499SJeff Garzik "dev can't take %u byte packets (max %u)\n", 5185b2fc499SJeff Garzik dev->hard_mtu, tmp); 5194149b72eSDavid Brownell retval = -EINVAL; 5205b2fc499SJeff Garzik goto fail_and_release; 5215b2fc499SJeff Garzik } 522500d2c2fSThomas Sailer dev->hard_mtu = tmp; 523500d2c2fSThomas Sailer net->mtu = dev->hard_mtu - net->hard_header_len; 524500d2c2fSThomas Sailer dev_warn(&intf->dev, 525500d2c2fSThomas Sailer "dev can't take %u byte packets (max %u), " 526500d2c2fSThomas Sailer "adjusting MTU to %u\n", 527500d2c2fSThomas Sailer dev->hard_mtu, tmp, net->mtu); 528500d2c2fSThomas Sailer } 5295b2fc499SJeff Garzik 5305b2fc499SJeff Garzik /* REVISIT: peripheral "alignment" request is ignored ... */ 5315b2fc499SJeff Garzik dev_dbg(&intf->dev, 5325b2fc499SJeff Garzik "hard mtu %u (%u from dev), rx buflen %Zu, align %d\n", 5335b2fc499SJeff Garzik dev->hard_mtu, tmp, dev->rx_urb_size, 5345b2fc499SJeff Garzik 1 << le32_to_cpu(u.init_c->packet_alignment)); 5355b2fc499SJeff Garzik 5365b2fc499SJeff Garzik /* Get designated host ethernet address */ 5375b2fc499SJeff Garzik reply_len = ETH_ALEN; 5385b2fc499SJeff Garzik retval = rndis_query(dev, intf, u.buf, OID_802_3_PERMANENT_ADDRESS, 5395b2fc499SJeff Garzik 48, (void **) &bp, &reply_len); 5405b2fc499SJeff Garzik if (unlikely(retval< 0)) { 5415b2fc499SJeff Garzik dev_err(&intf->dev, "rndis get ethaddr, %d\n", retval); 5425b2fc499SJeff Garzik goto fail_and_release; 5435b2fc499SJeff Garzik } 5445b2fc499SJeff Garzik memcpy(net->dev_addr, bp, ETH_ALEN); 5455b2fc499SJeff Garzik 5465b2fc499SJeff Garzik /* set a nonzero filter to enable data transfers */ 5475b2fc499SJeff Garzik memset(u.set, 0, sizeof *u.set); 5485b2fc499SJeff Garzik u.set->msg_type = RNDIS_MSG_SET; 5495b2fc499SJeff Garzik u.set->msg_len = ccpu2(4 + sizeof *u.set); 5505b2fc499SJeff Garzik u.set->oid = OID_GEN_CURRENT_PACKET_FILTER; 5515b2fc499SJeff Garzik u.set->len = ccpu2(4); 5525b2fc499SJeff Garzik u.set->offset = ccpu2((sizeof *u.set) - 8); 5535b2fc499SJeff Garzik *(__le32 *)(u.buf + sizeof *u.set) = ccpu2(DEFAULT_FILTER); 5545b2fc499SJeff Garzik 5555b2fc499SJeff Garzik retval = rndis_command(dev, u.header); 5565b2fc499SJeff Garzik if (unlikely(retval < 0)) { 5575b2fc499SJeff Garzik dev_err(&intf->dev, "rndis set packet filter, %d\n", retval); 5585b2fc499SJeff Garzik goto fail_and_release; 5595b2fc499SJeff Garzik } 5605b2fc499SJeff Garzik 5615b2fc499SJeff Garzik retval = 0; 5625b2fc499SJeff Garzik 5635b2fc499SJeff Garzik kfree(u.buf); 5645b2fc499SJeff Garzik return retval; 5655b2fc499SJeff Garzik 5665b2fc499SJeff Garzik fail_and_release: 5675b2fc499SJeff Garzik usb_set_intfdata(info->data, NULL); 5685b2fc499SJeff Garzik usb_driver_release_interface(driver_of(intf), info->data); 5695b2fc499SJeff Garzik info->data = NULL; 5705b2fc499SJeff Garzik fail: 5715b2fc499SJeff Garzik kfree(u.buf); 5725b2fc499SJeff Garzik return retval; 5735b2fc499SJeff Garzik } 5745b2fc499SJeff Garzik 5755b2fc499SJeff Garzik static void rndis_unbind(struct usbnet *dev, struct usb_interface *intf) 5765b2fc499SJeff Garzik { 5775b2fc499SJeff Garzik struct rndis_halt *halt; 5785b2fc499SJeff Garzik 5795b2fc499SJeff Garzik /* try to clear any rndis state/activity (no i/o from stack!) */ 580*04c3c01aSJussi Kivilinna halt = kzalloc(CONTROL_BUFFER_SIZE, GFP_KERNEL); 5815b2fc499SJeff Garzik if (halt) { 5825b2fc499SJeff Garzik halt->msg_type = RNDIS_MSG_HALT; 5835b2fc499SJeff Garzik halt->msg_len = ccpu2(sizeof *halt); 5845b2fc499SJeff Garzik (void) rndis_command(dev, (void *)halt); 5855b2fc499SJeff Garzik kfree(halt); 5865b2fc499SJeff Garzik } 5875b2fc499SJeff Garzik 5882bfa2e1fSBjorge Dijkstra usbnet_cdc_unbind(dev, intf); 5895b2fc499SJeff Garzik } 5905b2fc499SJeff Garzik 5915b2fc499SJeff Garzik /* 5925b2fc499SJeff Garzik * DATA -- host must not write zlps 5935b2fc499SJeff Garzik */ 5945b2fc499SJeff Garzik static int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb) 5955b2fc499SJeff Garzik { 5965b2fc499SJeff Garzik /* peripheral may have batched packets to us... */ 5975b2fc499SJeff Garzik while (likely(skb->len)) { 5985b2fc499SJeff Garzik struct rndis_data_hdr *hdr = (void *)skb->data; 5995b2fc499SJeff Garzik struct sk_buff *skb2; 6005b2fc499SJeff Garzik u32 msg_len, data_offset, data_len; 6015b2fc499SJeff Garzik 6025b2fc499SJeff Garzik msg_len = le32_to_cpu(hdr->msg_len); 6035b2fc499SJeff Garzik data_offset = le32_to_cpu(hdr->data_offset); 6045b2fc499SJeff Garzik data_len = le32_to_cpu(hdr->data_len); 6055b2fc499SJeff Garzik 6065b2fc499SJeff Garzik /* don't choke if we see oob, per-packet data, etc */ 6075b2fc499SJeff Garzik if (unlikely(hdr->msg_type != RNDIS_MSG_PACKET 6085b2fc499SJeff Garzik || skb->len < msg_len 6095b2fc499SJeff Garzik || (data_offset + data_len + 8) > msg_len)) { 6105b2fc499SJeff Garzik dev->stats.rx_frame_errors++; 6115b2fc499SJeff Garzik devdbg(dev, "bad rndis message %d/%d/%d/%d, len %d", 6125b2fc499SJeff Garzik le32_to_cpu(hdr->msg_type), 6135b2fc499SJeff Garzik msg_len, data_offset, data_len, skb->len); 6145b2fc499SJeff Garzik return 0; 6155b2fc499SJeff Garzik } 6165b2fc499SJeff Garzik skb_pull(skb, 8 + data_offset); 6175b2fc499SJeff Garzik 6185b2fc499SJeff Garzik /* at most one packet left? */ 6195b2fc499SJeff Garzik if (likely((data_len - skb->len) <= sizeof *hdr)) { 6205b2fc499SJeff Garzik skb_trim(skb, data_len); 6215b2fc499SJeff Garzik break; 6225b2fc499SJeff Garzik } 6235b2fc499SJeff Garzik 6245b2fc499SJeff Garzik /* try to return all the packets in the batch */ 6255b2fc499SJeff Garzik skb2 = skb_clone(skb, GFP_ATOMIC); 6265b2fc499SJeff Garzik if (unlikely(!skb2)) 6275b2fc499SJeff Garzik break; 6285b2fc499SJeff Garzik skb_pull(skb, msg_len - sizeof *hdr); 6295b2fc499SJeff Garzik skb_trim(skb2, data_len); 6305b2fc499SJeff Garzik usbnet_skb_return(dev, skb2); 6315b2fc499SJeff Garzik } 6325b2fc499SJeff Garzik 6335b2fc499SJeff Garzik /* caller will usbnet_skb_return the remaining packet */ 6345b2fc499SJeff Garzik return 1; 6355b2fc499SJeff Garzik } 6365b2fc499SJeff Garzik 6375b2fc499SJeff Garzik static struct sk_buff * 6385b2fc499SJeff Garzik rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) 6395b2fc499SJeff Garzik { 6405b2fc499SJeff Garzik struct rndis_data_hdr *hdr; 6415b2fc499SJeff Garzik struct sk_buff *skb2; 6425b2fc499SJeff Garzik unsigned len = skb->len; 6435b2fc499SJeff Garzik 6445b2fc499SJeff Garzik if (likely(!skb_cloned(skb))) { 6455b2fc499SJeff Garzik int room = skb_headroom(skb); 6465b2fc499SJeff Garzik 6475b2fc499SJeff Garzik /* enough head room as-is? */ 6485b2fc499SJeff Garzik if (unlikely((sizeof *hdr) <= room)) 6495b2fc499SJeff Garzik goto fill; 6505b2fc499SJeff Garzik 6515b2fc499SJeff Garzik /* enough room, but needs to be readjusted? */ 6525b2fc499SJeff Garzik room += skb_tailroom(skb); 6535b2fc499SJeff Garzik if (likely((sizeof *hdr) <= room)) { 6545b2fc499SJeff Garzik skb->data = memmove(skb->head + sizeof *hdr, 6555b2fc499SJeff Garzik skb->data, len); 6565b2fc499SJeff Garzik skb_set_tail_pointer(skb, len); 6575b2fc499SJeff Garzik goto fill; 6585b2fc499SJeff Garzik } 6595b2fc499SJeff Garzik } 6605b2fc499SJeff Garzik 6615b2fc499SJeff Garzik /* create a new skb, with the correct size (and tailpad) */ 6625b2fc499SJeff Garzik skb2 = skb_copy_expand(skb, sizeof *hdr, 1, flags); 6635b2fc499SJeff Garzik dev_kfree_skb_any(skb); 6645b2fc499SJeff Garzik if (unlikely(!skb2)) 6655b2fc499SJeff Garzik return skb2; 6665b2fc499SJeff Garzik skb = skb2; 6675b2fc499SJeff Garzik 6685b2fc499SJeff Garzik /* fill out the RNDIS header. we won't bother trying to batch 6695b2fc499SJeff Garzik * packets; Linux minimizes wasted bandwidth through tx queues. 6705b2fc499SJeff Garzik */ 6715b2fc499SJeff Garzik fill: 6725b2fc499SJeff Garzik hdr = (void *) __skb_push(skb, sizeof *hdr); 6735b2fc499SJeff Garzik memset(hdr, 0, sizeof *hdr); 6745b2fc499SJeff Garzik hdr->msg_type = RNDIS_MSG_PACKET; 6755b2fc499SJeff Garzik hdr->msg_len = cpu_to_le32(skb->len); 6765b2fc499SJeff Garzik hdr->data_offset = ccpu2(sizeof(*hdr) - 8); 6775b2fc499SJeff Garzik hdr->data_len = cpu_to_le32(len); 6785b2fc499SJeff Garzik 6795b2fc499SJeff Garzik /* FIXME make the last packet always be short ... */ 6805b2fc499SJeff Garzik return skb; 6815b2fc499SJeff Garzik } 6825b2fc499SJeff Garzik 6835b2fc499SJeff Garzik 6845b2fc499SJeff Garzik static const struct driver_info rndis_info = { 6855b2fc499SJeff Garzik .description = "RNDIS device", 6865b2fc499SJeff Garzik .flags = FLAG_ETHER | FLAG_FRAMING_RN | FLAG_NO_SETINT, 6875b2fc499SJeff Garzik .bind = rndis_bind, 6885b2fc499SJeff Garzik .unbind = rndis_unbind, 6895b2fc499SJeff Garzik .status = rndis_status, 6905b2fc499SJeff Garzik .rx_fixup = rndis_rx_fixup, 6915b2fc499SJeff Garzik .tx_fixup = rndis_tx_fixup, 6925b2fc499SJeff Garzik }; 6935b2fc499SJeff Garzik 6945b2fc499SJeff Garzik #undef ccpu2 6955b2fc499SJeff Garzik 6965b2fc499SJeff Garzik 6975b2fc499SJeff Garzik /*-------------------------------------------------------------------------*/ 6985b2fc499SJeff Garzik 6995b2fc499SJeff Garzik static const struct usb_device_id products [] = { 7005b2fc499SJeff Garzik { 7015b2fc499SJeff Garzik /* RNDIS is MSFT's un-official variant of CDC ACM */ 7025b2fc499SJeff Garzik USB_INTERFACE_INFO(USB_CLASS_COMM, 2 /* ACM */, 0x0ff), 7035b2fc499SJeff Garzik .driver_info = (unsigned long) &rndis_info, 7045b2fc499SJeff Garzik }, { 7055b2fc499SJeff Garzik /* "ActiveSync" is an undocumented variant of RNDIS, used in WM5 */ 7065b2fc499SJeff Garzik USB_INTERFACE_INFO(USB_CLASS_MISC, 1, 1), 7075b2fc499SJeff Garzik .driver_info = (unsigned long) &rndis_info, 7085b2fc499SJeff Garzik }, 7095b2fc499SJeff Garzik { }, // END 7105b2fc499SJeff Garzik }; 7115b2fc499SJeff Garzik MODULE_DEVICE_TABLE(usb, products); 7125b2fc499SJeff Garzik 7135b2fc499SJeff Garzik static struct usb_driver rndis_driver = { 7145b2fc499SJeff Garzik .name = "rndis_host", 7155b2fc499SJeff Garzik .id_table = products, 7165b2fc499SJeff Garzik .probe = usbnet_probe, 7175b2fc499SJeff Garzik .disconnect = usbnet_disconnect, 7185b2fc499SJeff Garzik .suspend = usbnet_suspend, 7195b2fc499SJeff Garzik .resume = usbnet_resume, 7205b2fc499SJeff Garzik }; 7215b2fc499SJeff Garzik 7225b2fc499SJeff Garzik static int __init rndis_init(void) 7235b2fc499SJeff Garzik { 7245b2fc499SJeff Garzik return usb_register(&rndis_driver); 7255b2fc499SJeff Garzik } 7265b2fc499SJeff Garzik module_init(rndis_init); 7275b2fc499SJeff Garzik 7285b2fc499SJeff Garzik static void __exit rndis_exit(void) 7295b2fc499SJeff Garzik { 7305b2fc499SJeff Garzik usb_deregister(&rndis_driver); 7315b2fc499SJeff Garzik } 7325b2fc499SJeff Garzik module_exit(rndis_exit); 7335b2fc499SJeff Garzik 7345b2fc499SJeff Garzik MODULE_AUTHOR("David Brownell"); 7355b2fc499SJeff Garzik MODULE_DESCRIPTION("USB Host side RNDIS driver"); 7365b2fc499SJeff Garzik MODULE_LICENSE("GPL"); 737