11ccea77eSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
25b2fc499SJeff Garzik /*
35b2fc499SJeff Garzik * Host Side support for RNDIS Networking Links
45b2fc499SJeff Garzik * Copyright (C) 2005 by David Brownell
55b2fc499SJeff Garzik */
65b2fc499SJeff Garzik #include <linux/module.h>
75b2fc499SJeff Garzik #include <linux/netdevice.h>
85b2fc499SJeff Garzik #include <linux/etherdevice.h>
95b2fc499SJeff Garzik #include <linux/ethtool.h>
105b2fc499SJeff Garzik #include <linux/workqueue.h>
115a0e3ad6STejun Heo #include <linux/slab.h>
125b2fc499SJeff Garzik #include <linux/mii.h>
135b2fc499SJeff Garzik #include <linux/usb.h>
145b2fc499SJeff Garzik #include <linux/usb/cdc.h>
153692e94fSJussi Kivilinna #include <linux/usb/usbnet.h>
163692e94fSJussi Kivilinna #include <linux/usb/rndis_host.h>
175b2fc499SJeff Garzik
185b2fc499SJeff Garzik
195b2fc499SJeff Garzik /*
205b2fc499SJeff Garzik * RNDIS is NDIS remoted over USB. It's a MSFT variant of CDC ACM ... of
215b2fc499SJeff Garzik * course ACM was intended for modems, not Ethernet links! USB's standard
225b2fc499SJeff Garzik * for Ethernet links is "CDC Ethernet", which is significantly simpler.
235b2fc499SJeff Garzik *
245b2fc499SJeff Garzik * NOTE that Microsoft's "RNDIS 1.0" specification is incomplete. Issues
255b2fc499SJeff Garzik * include:
265b2fc499SJeff Garzik * - Power management in particular relies on information that's scattered
275b2fc499SJeff Garzik * through other documentation, and which is incomplete or incorrect even
285b2fc499SJeff Garzik * there.
295b2fc499SJeff Garzik * - There are various undocumented protocol requirements, such as the
305b2fc499SJeff Garzik * need to send unused garbage in control-OUT messages.
315b2fc499SJeff Garzik * - In some cases, MS-Windows will emit undocumented requests; this
325b2fc499SJeff Garzik * matters more to peripheral implementations than host ones.
335b2fc499SJeff Garzik *
345b2fc499SJeff Garzik * Moreover there's a no-open-specs variant of RNDIS called "ActiveSync".
355b2fc499SJeff Garzik *
365b2fc499SJeff Garzik * For these reasons and others, ** USE OF RNDIS IS STRONGLY DISCOURAGED ** in
375b2fc499SJeff Garzik * favor of such non-proprietary alternatives as CDC Ethernet or the newer (and
385b2fc499SJeff Garzik * currently rare) "Ethernet Emulation Model" (EEM).
395b2fc499SJeff Garzik */
405b2fc499SJeff Garzik
415b2fc499SJeff Garzik /*
425b2fc499SJeff Garzik * RNDIS notifications from device: command completion; "reverse"
435b2fc499SJeff Garzik * keepalives; etc
445b2fc499SJeff Garzik */
rndis_status(struct usbnet * dev,struct urb * urb)455665998cSJussi Kivilinna void rndis_status(struct usbnet *dev, struct urb *urb)
465b2fc499SJeff Garzik {
4760b86755SJoe Perches netdev_dbg(dev->net, "rndis status urb, len %d stat %d\n",
485b2fc499SJeff Garzik urb->actual_length, urb->status);
495b2fc499SJeff Garzik // FIXME for keepalives, respond immediately (asynchronously)
505b2fc499SJeff Garzik // if not an RNDIS status, do like cdc_status(dev,urb) does
515b2fc499SJeff Garzik }
525665998cSJussi Kivilinna EXPORT_SYMBOL_GPL(rndis_status);
535b2fc499SJeff Garzik
545b2fc499SJeff Garzik /*
552a4901bcSJussi Kivilinna * RNDIS indicate messages.
562a4901bcSJussi Kivilinna */
rndis_msg_indicate(struct usbnet * dev,struct rndis_indicate * msg,int buflen)572a4901bcSJussi Kivilinna static void rndis_msg_indicate(struct usbnet *dev, struct rndis_indicate *msg,
582a4901bcSJussi Kivilinna int buflen)
592a4901bcSJussi Kivilinna {
602a4901bcSJussi Kivilinna struct cdc_state *info = (void *)&dev->data;
612a4901bcSJussi Kivilinna struct device *udev = &info->control->dev;
622a4901bcSJussi Kivilinna
632a4901bcSJussi Kivilinna if (dev->driver_info->indication) {
642a4901bcSJussi Kivilinna dev->driver_info->indication(dev, msg, buflen);
652a4901bcSJussi Kivilinna } else {
663eef3668SJussi Kivilinna u32 status = le32_to_cpu(msg->status);
673eef3668SJussi Kivilinna
683eef3668SJussi Kivilinna switch (status) {
693eef3668SJussi Kivilinna case RNDIS_STATUS_MEDIA_CONNECT:
702a4901bcSJussi Kivilinna dev_info(udev, "rndis media connect\n");
712a4901bcSJussi Kivilinna break;
723eef3668SJussi Kivilinna case RNDIS_STATUS_MEDIA_DISCONNECT:
732a4901bcSJussi Kivilinna dev_info(udev, "rndis media disconnect\n");
742a4901bcSJussi Kivilinna break;
752a4901bcSJussi Kivilinna default:
763eef3668SJussi Kivilinna dev_info(udev, "rndis indication: 0x%08x\n", status);
772a4901bcSJussi Kivilinna }
782a4901bcSJussi Kivilinna }
792a4901bcSJussi Kivilinna }
802a4901bcSJussi Kivilinna
812a4901bcSJussi Kivilinna /*
825b2fc499SJeff Garzik * RPC done RNDIS-style. Caller guarantees:
835b2fc499SJeff Garzik * - message is properly byteswapped
845b2fc499SJeff Garzik * - there's no other request pending
855b2fc499SJeff Garzik * - buf can hold up to 1KB response (required by RNDIS spec)
865b2fc499SJeff Garzik * On return, the first few entries are already byteswapped.
875b2fc499SJeff Garzik *
885b2fc499SJeff Garzik * Call context is likely probe(), before interface name is known,
895b2fc499SJeff Garzik * which is why we won't try to use it in the diagnostics.
905b2fc499SJeff Garzik */
rndis_command(struct usbnet * dev,struct rndis_msg_hdr * buf,int buflen)91818727baSJussi Kivilinna int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen)
925b2fc499SJeff Garzik {
935b2fc499SJeff Garzik struct cdc_state *info = (void *) &dev->data;
944d42d417SBen Hutchings struct usb_cdc_notification notification;
955b2fc499SJeff Garzik int master_ifnum;
965b2fc499SJeff Garzik int retval;
974d42d417SBen Hutchings int partial;
985b2fc499SJeff Garzik unsigned count;
993eef3668SJussi Kivilinna u32 xid = 0, msg_len, request_id, msg_type, rsp,
1003eef3668SJussi Kivilinna status;
1015b2fc499SJeff Garzik
1025b2fc499SJeff Garzik /* REVISIT when this gets called from contexts other than probe() or
1035b2fc499SJeff Garzik * disconnect(): either serialize, or dispatch responses on xid
1045b2fc499SJeff Garzik */
1055b2fc499SJeff Garzik
1063eef3668SJussi Kivilinna msg_type = le32_to_cpu(buf->msg_type);
1073eef3668SJussi Kivilinna
1085b2fc499SJeff Garzik /* Issue the request; xid is unique, don't bother byteswapping it */
1093eef3668SJussi Kivilinna if (likely(msg_type != RNDIS_MSG_HALT && msg_type != RNDIS_MSG_RESET)) {
1105b2fc499SJeff Garzik xid = dev->xid++;
1115b2fc499SJeff Garzik if (!xid)
1125b2fc499SJeff Garzik xid = dev->xid++;
1135b2fc499SJeff Garzik buf->request_id = (__force __le32) xid;
1145b2fc499SJeff Garzik }
1155b2fc499SJeff Garzik master_ifnum = info->control->cur_altsetting->desc.bInterfaceNumber;
1165b2fc499SJeff Garzik retval = usb_control_msg(dev->udev,
1175b2fc499SJeff Garzik usb_sndctrlpipe(dev->udev, 0),
1185b2fc499SJeff Garzik USB_CDC_SEND_ENCAPSULATED_COMMAND,
1195b2fc499SJeff Garzik USB_TYPE_CLASS | USB_RECIP_INTERFACE,
1205b2fc499SJeff Garzik 0, master_ifnum,
1215b2fc499SJeff Garzik buf, le32_to_cpu(buf->msg_len),
1225b2fc499SJeff Garzik RNDIS_CONTROL_TIMEOUT_MS);
1235b2fc499SJeff Garzik if (unlikely(retval < 0 || xid == 0))
1245b2fc499SJeff Garzik return retval;
1255b2fc499SJeff Garzik
1264d42d417SBen Hutchings /* Some devices don't respond on the control channel until
1274d42d417SBen Hutchings * polled on the status channel, so do that first. */
1284d42d417SBen Hutchings if (dev->driver_info->data & RNDIS_DRIVER_DATA_POLL_STATUS) {
1294d42d417SBen Hutchings retval = usb_interrupt_msg(
1304d42d417SBen Hutchings dev->udev,
1314d42d417SBen Hutchings usb_rcvintpipe(dev->udev,
1324d42d417SBen Hutchings dev->status->desc.bEndpointAddress),
1334d42d417SBen Hutchings ¬ification, sizeof(notification), &partial,
1344d42d417SBen Hutchings RNDIS_CONTROL_TIMEOUT_MS);
1354d42d417SBen Hutchings if (unlikely(retval < 0))
1364d42d417SBen Hutchings return retval;
1374d42d417SBen Hutchings }
1385b2fc499SJeff Garzik
1394d42d417SBen Hutchings /* Poll the control channel; the request probably completed immediately */
1403eef3668SJussi Kivilinna rsp = le32_to_cpu(buf->msg_type) | RNDIS_MSG_COMPLETION;
1415b2fc499SJeff Garzik for (count = 0; count < 10; count++) {
1425b2fc499SJeff Garzik memset(buf, 0, CONTROL_BUFFER_SIZE);
1435b2fc499SJeff Garzik retval = usb_control_msg(dev->udev,
1445b2fc499SJeff Garzik usb_rcvctrlpipe(dev->udev, 0),
1455b2fc499SJeff Garzik USB_CDC_GET_ENCAPSULATED_RESPONSE,
1465b2fc499SJeff Garzik USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
1475b2fc499SJeff Garzik 0, master_ifnum,
148818727baSJussi Kivilinna buf, buflen,
1495b2fc499SJeff Garzik RNDIS_CONTROL_TIMEOUT_MS);
1505b2fc499SJeff Garzik if (likely(retval >= 8)) {
1513eef3668SJussi Kivilinna msg_type = le32_to_cpu(buf->msg_type);
1525b2fc499SJeff Garzik msg_len = le32_to_cpu(buf->msg_len);
1533eef3668SJussi Kivilinna status = le32_to_cpu(buf->status);
1545b2fc499SJeff Garzik request_id = (__force u32) buf->request_id;
1553eef3668SJussi Kivilinna if (likely(msg_type == rsp)) {
1565b2fc499SJeff Garzik if (likely(request_id == xid)) {
1573eef3668SJussi Kivilinna if (unlikely(rsp == RNDIS_MSG_RESET_C))
1585b2fc499SJeff Garzik return 0;
1593eef3668SJussi Kivilinna if (likely(RNDIS_STATUS_SUCCESS ==
1603eef3668SJussi Kivilinna status))
1615b2fc499SJeff Garzik return 0;
1625b2fc499SJeff Garzik dev_dbg(&info->control->dev,
1635b2fc499SJeff Garzik "rndis reply status %08x\n",
1643eef3668SJussi Kivilinna status);
1655b2fc499SJeff Garzik return -EL3RST;
1665b2fc499SJeff Garzik }
1675b2fc499SJeff Garzik dev_dbg(&info->control->dev,
1685b2fc499SJeff Garzik "rndis reply id %d expected %d\n",
1695b2fc499SJeff Garzik request_id, xid);
1705b2fc499SJeff Garzik /* then likely retry */
1713eef3668SJussi Kivilinna } else switch (msg_type) {
1723eef3668SJussi Kivilinna case RNDIS_MSG_INDICATE: /* fault/event */
1732a4901bcSJussi Kivilinna rndis_msg_indicate(dev, (void *)buf, buflen);
1745b2fc499SJeff Garzik break;
1753eef3668SJussi Kivilinna case RNDIS_MSG_KEEPALIVE: { /* ping */
1765b2fc499SJeff Garzik struct rndis_keepalive_c *msg = (void *)buf;
1775b2fc499SJeff Garzik
1787390e8b0SLinus Walleij msg->msg_type = cpu_to_le32(RNDIS_MSG_KEEPALIVE_C);
17935c26c2cSHarvey Harrison msg->msg_len = cpu_to_le32(sizeof *msg);
1807390e8b0SLinus Walleij msg->status = cpu_to_le32(RNDIS_STATUS_SUCCESS);
1815b2fc499SJeff Garzik retval = usb_control_msg(dev->udev,
1825b2fc499SJeff Garzik usb_sndctrlpipe(dev->udev, 0),
1835b2fc499SJeff Garzik USB_CDC_SEND_ENCAPSULATED_COMMAND,
1845b2fc499SJeff Garzik USB_TYPE_CLASS | USB_RECIP_INTERFACE,
1855b2fc499SJeff Garzik 0, master_ifnum,
1865b2fc499SJeff Garzik msg, sizeof *msg,
1875b2fc499SJeff Garzik RNDIS_CONTROL_TIMEOUT_MS);
1885b2fc499SJeff Garzik if (unlikely(retval < 0))
1895b2fc499SJeff Garzik dev_dbg(&info->control->dev,
1905b2fc499SJeff Garzik "rndis keepalive err %d\n",
1915b2fc499SJeff Garzik retval);
1925b2fc499SJeff Garzik }
1935b2fc499SJeff Garzik break;
1945b2fc499SJeff Garzik default:
1955b2fc499SJeff Garzik dev_dbg(&info->control->dev,
1965b2fc499SJeff Garzik "unexpected rndis msg %08x len %d\n",
1975b2fc499SJeff Garzik le32_to_cpu(buf->msg_type), msg_len);
1985b2fc499SJeff Garzik }
1995b2fc499SJeff Garzik } else {
2005b2fc499SJeff Garzik /* device probably issued a protocol stall; ignore */
2015b2fc499SJeff Garzik dev_dbg(&info->control->dev,
2025b2fc499SJeff Garzik "rndis response error, code %d\n", retval);
2035b2fc499SJeff Garzik }
2044202c9fdSOlympia Giannou msleep(40);
2055b2fc499SJeff Garzik }
2065b2fc499SJeff Garzik dev_dbg(&info->control->dev, "rndis response timeout\n");
2075b2fc499SJeff Garzik return -ETIMEDOUT;
2085b2fc499SJeff Garzik }
2095665998cSJussi Kivilinna EXPORT_SYMBOL_GPL(rndis_command);
2105b2fc499SJeff Garzik
2115b2fc499SJeff Garzik /*
2125b2fc499SJeff Garzik * rndis_query:
2135b2fc499SJeff Garzik *
2145b2fc499SJeff Garzik * Performs a query for @oid along with 0 or more bytes of payload as
2155b2fc499SJeff Garzik * specified by @in_len. If @reply_len is not set to -1 then the reply
2165b2fc499SJeff Garzik * length is checked against this value, resulting in an error if it
2175b2fc499SJeff Garzik * doesn't match.
2185b2fc499SJeff Garzik *
2195b2fc499SJeff Garzik * NOTE: Adding a payload exactly or greater than the size of the expected
2205b2fc499SJeff Garzik * response payload is an evident requirement MSFT added for ActiveSync.
2215b2fc499SJeff Garzik *
2225b2fc499SJeff Garzik * The only exception is for OIDs that return a variably sized response,
2235b2fc499SJeff Garzik * in which case no payload should be added. This undocumented (and
2245b2fc499SJeff Garzik * nonsensical!) issue was found by sniffing protocol requests from the
2255b2fc499SJeff Garzik * ActiveSync 4.1 Windows driver.
2265b2fc499SJeff Garzik */
rndis_query(struct usbnet * dev,struct usb_interface * intf,void * buf,u32 oid,u32 in_len,void ** reply,int * reply_len)2275b2fc499SJeff Garzik static int rndis_query(struct usbnet *dev, struct usb_interface *intf,
2285432bdc0SJussi Kivilinna void *buf, u32 oid, u32 in_len,
2295b2fc499SJeff Garzik void **reply, int *reply_len)
2305b2fc499SJeff Garzik {
2315b2fc499SJeff Garzik int retval;
2325b2fc499SJeff Garzik union {
2335b2fc499SJeff Garzik void *buf;
2345b2fc499SJeff Garzik struct rndis_msg_hdr *header;
2355b2fc499SJeff Garzik struct rndis_query *get;
2365b2fc499SJeff Garzik struct rndis_query_c *get_c;
2375b2fc499SJeff Garzik } u;
2385b2fc499SJeff Garzik u32 off, len;
2395b2fc499SJeff Garzik
2405b2fc499SJeff Garzik u.buf = buf;
2415b2fc499SJeff Garzik
2425b2fc499SJeff Garzik memset(u.get, 0, sizeof *u.get + in_len);
2437390e8b0SLinus Walleij u.get->msg_type = cpu_to_le32(RNDIS_MSG_QUERY);
2445b2fc499SJeff Garzik u.get->msg_len = cpu_to_le32(sizeof *u.get + in_len);
2455432bdc0SJussi Kivilinna u.get->oid = cpu_to_le32(oid);
2465b2fc499SJeff Garzik u.get->len = cpu_to_le32(in_len);
24735c26c2cSHarvey Harrison u.get->offset = cpu_to_le32(20);
2485b2fc499SJeff Garzik
249818727baSJussi Kivilinna retval = rndis_command(dev, u.header, CONTROL_BUFFER_SIZE);
2505b2fc499SJeff Garzik if (unlikely(retval < 0)) {
2515b2fc499SJeff Garzik dev_err(&intf->dev, "RNDIS_MSG_QUERY(0x%08x) failed, %d\n",
2525b2fc499SJeff Garzik oid, retval);
2535b2fc499SJeff Garzik return retval;
2545b2fc499SJeff Garzik }
2555b2fc499SJeff Garzik
2565b2fc499SJeff Garzik off = le32_to_cpu(u.get_c->offset);
2575b2fc499SJeff Garzik len = le32_to_cpu(u.get_c->len);
258*c7dd1380SSzymon Heidrich if (unlikely((off > CONTROL_BUFFER_SIZE - 8) ||
259*c7dd1380SSzymon Heidrich (len > CONTROL_BUFFER_SIZE - 8 - off)))
2605b2fc499SJeff Garzik goto response_error;
2615b2fc499SJeff Garzik
2625b2fc499SJeff Garzik if (*reply_len != -1 && len != *reply_len)
2635b2fc499SJeff Garzik goto response_error;
2645b2fc499SJeff Garzik
2655b2fc499SJeff Garzik *reply = (unsigned char *) &u.get_c->request_id + off;
2665b2fc499SJeff Garzik *reply_len = len;
2675b2fc499SJeff Garzik
2685b2fc499SJeff Garzik return retval;
2695b2fc499SJeff Garzik
2705b2fc499SJeff Garzik response_error:
2715b2fc499SJeff Garzik dev_err(&intf->dev, "RNDIS_MSG_QUERY(0x%08x) "
2725b2fc499SJeff Garzik "invalid response - off %d len %d\n",
2735b2fc499SJeff Garzik oid, off, len);
2745b2fc499SJeff Garzik return -EDOM;
2755b2fc499SJeff Garzik }
2765b2fc499SJeff Garzik
2770f2166dfSStephen Hemminger /* same as usbnet_netdev_ops but MTU change not allowed */
2780f2166dfSStephen Hemminger static const struct net_device_ops rndis_netdev_ops = {
2790f2166dfSStephen Hemminger .ndo_open = usbnet_open,
2800f2166dfSStephen Hemminger .ndo_stop = usbnet_stop,
2810f2166dfSStephen Hemminger .ndo_start_xmit = usbnet_start_xmit,
2820f2166dfSStephen Hemminger .ndo_tx_timeout = usbnet_tx_timeout,
283323955a0SHeiner Kallweit .ndo_get_stats64 = dev_get_tstats64,
2840f2166dfSStephen Hemminger .ndo_set_mac_address = eth_mac_addr,
2850f2166dfSStephen Hemminger .ndo_validate_addr = eth_validate_addr,
2860f2166dfSStephen Hemminger };
2870f2166dfSStephen Hemminger
288039ee17dSJussi Kivilinna int
generic_rndis_bind(struct usbnet * dev,struct usb_interface * intf,int flags)289039ee17dSJussi Kivilinna generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags)
2905b2fc499SJeff Garzik {
2915b2fc499SJeff Garzik int retval;
2925b2fc499SJeff Garzik struct net_device *net = dev->net;
2935b2fc499SJeff Garzik struct cdc_state *info = (void *) &dev->data;
2945b2fc499SJeff Garzik union {
2955b2fc499SJeff Garzik void *buf;
2965b2fc499SJeff Garzik struct rndis_msg_hdr *header;
2975b2fc499SJeff Garzik struct rndis_init *init;
2985b2fc499SJeff Garzik struct rndis_init_c *init_c;
2995b2fc499SJeff Garzik struct rndis_query *get;
3005b2fc499SJeff Garzik struct rndis_query_c *get_c;
3015b2fc499SJeff Garzik struct rndis_set *set;
3025b2fc499SJeff Garzik struct rndis_set_c *set_c;
3039ff55874SJussi Kivilinna struct rndis_halt *halt;
3045b2fc499SJeff Garzik } u;
305d63ddcecSAl Viro u32 tmp;
306d63ddcecSAl Viro __le32 phym_unspec, *phym;
3075b2fc499SJeff Garzik int reply_len;
3085b2fc499SJeff Garzik unsigned char *bp;
3095b2fc499SJeff Garzik
3105b2fc499SJeff Garzik /* we can't rely on i/o from stack working, or stack allocation */
3115b2fc499SJeff Garzik u.buf = kmalloc(CONTROL_BUFFER_SIZE, GFP_KERNEL);
3125b2fc499SJeff Garzik if (!u.buf)
3135b2fc499SJeff Garzik return -ENOMEM;
3145b2fc499SJeff Garzik retval = usbnet_generic_cdc_bind(dev, intf);
3155b2fc499SJeff Garzik if (retval < 0)
3165b2fc499SJeff Garzik goto fail;
3175b2fc499SJeff Garzik
3187390e8b0SLinus Walleij u.init->msg_type = cpu_to_le32(RNDIS_MSG_INIT);
31935c26c2cSHarvey Harrison u.init->msg_len = cpu_to_le32(sizeof *u.init);
32035c26c2cSHarvey Harrison u.init->major_version = cpu_to_le32(1);
32135c26c2cSHarvey Harrison u.init->minor_version = cpu_to_le32(0);
3225b2fc499SJeff Garzik
3235b2fc499SJeff Garzik /* max transfer (in spec) is 0x4000 at full speed, but for
3245b2fc499SJeff Garzik * TX we'll stick to one Ethernet packet plus RNDIS framing.
3255b2fc499SJeff Garzik * For RX we handle drivers that zero-pad to end-of-packet.
3265b2fc499SJeff Garzik * Don't let userspace change these settings.
3275b2fc499SJeff Garzik *
328f62c4f38SZheng Yongjun * NOTE: there still seems to be weirdness here, as if we need
3295b2fc499SJeff Garzik * to do some more things to make sure WinCE targets accept this.
3305b2fc499SJeff Garzik * They default to jumbograms of 8KB or 16KB, which is absurd
3315b2fc499SJeff Garzik * for such low data rates and which is also more than Linux
3325b2fc499SJeff Garzik * can usually expect to allocate for SKB data...
3335b2fc499SJeff Garzik */
3345b2fc499SJeff Garzik net->hard_header_len += sizeof (struct rndis_data_hdr);
3355b2fc499SJeff Garzik dev->hard_mtu = net->mtu + net->hard_header_len;
3365b2fc499SJeff Garzik
337e13adbfaSVincent Mailhol dev->maxpacket = usb_maxpacket(dev->udev, dev->out);
33810d0f27cSJean-Christophe Dubois if (dev->maxpacket == 0) {
339a475f603SJoe Perches netif_dbg(dev, probe, dev->net,
340a475f603SJoe Perches "dev->maxpacket can't be 0\n");
34110d0f27cSJean-Christophe Dubois retval = -EINVAL;
34210d0f27cSJean-Christophe Dubois goto fail_and_release;
34310d0f27cSJean-Christophe Dubois }
34410d0f27cSJean-Christophe Dubois
3455b2fc499SJeff Garzik dev->rx_urb_size = dev->hard_mtu + (dev->maxpacket + 1);
3465b2fc499SJeff Garzik dev->rx_urb_size &= ~(dev->maxpacket - 1);
3475b2fc499SJeff Garzik u.init->max_transfer_size = cpu_to_le32(dev->rx_urb_size);
3485b2fc499SJeff Garzik
3490f2166dfSStephen Hemminger net->netdev_ops = &rndis_netdev_ops;
3500f2166dfSStephen Hemminger
351818727baSJussi Kivilinna retval = rndis_command(dev, u.header, CONTROL_BUFFER_SIZE);
3525b2fc499SJeff Garzik if (unlikely(retval < 0)) {
3535b2fc499SJeff Garzik /* it might not even be an RNDIS device!! */
3545b2fc499SJeff Garzik dev_err(&intf->dev, "RNDIS init failed, %d\n", retval);
3555b2fc499SJeff Garzik goto fail_and_release;
3565b2fc499SJeff Garzik }
3575b2fc499SJeff Garzik tmp = le32_to_cpu(u.init_c->max_transfer_size);
3585b2fc499SJeff Garzik if (tmp < dev->hard_mtu) {
359500d2c2fSThomas Sailer if (tmp <= net->hard_header_len) {
3605b2fc499SJeff Garzik dev_err(&intf->dev,
3615b2fc499SJeff Garzik "dev can't take %u byte packets (max %u)\n",
3625b2fc499SJeff Garzik dev->hard_mtu, tmp);
3634149b72eSDavid Brownell retval = -EINVAL;
3649ff55874SJussi Kivilinna goto halt_fail_and_release;
3655b2fc499SJeff Garzik }
366500d2c2fSThomas Sailer dev_warn(&intf->dev,
367500d2c2fSThomas Sailer "dev can't take %u byte packets (max %u), "
368500d2c2fSThomas Sailer "adjusting MTU to %u\n",
36940ac7b62SGeorge Nassar dev->hard_mtu, tmp, tmp - net->hard_header_len);
37040ac7b62SGeorge Nassar dev->hard_mtu = tmp;
37140ac7b62SGeorge Nassar net->mtu = dev->hard_mtu - net->hard_header_len;
372500d2c2fSThomas Sailer }
3735b2fc499SJeff Garzik
3745b2fc499SJeff Garzik /* REVISIT: peripheral "alignment" request is ignored ... */
3755b2fc499SJeff Garzik dev_dbg(&intf->dev,
3765b5e0928SAlexey Dobriyan "hard mtu %u (%u from dev), rx buflen %zu, align %d\n",
3775b2fc499SJeff Garzik dev->hard_mtu, tmp, dev->rx_urb_size,
3785b2fc499SJeff Garzik 1 << le32_to_cpu(u.init_c->packet_alignment));
3795b2fc499SJeff Garzik
3807c39e038SJussi Kivilinna /* module has some device initialization code needs to be done right
3817c39e038SJussi Kivilinna * after RNDIS_INIT */
3827c39e038SJussi Kivilinna if (dev->driver_info->early_init &&
3837c39e038SJussi Kivilinna dev->driver_info->early_init(dev) != 0)
3847c39e038SJussi Kivilinna goto halt_fail_and_release;
3857c39e038SJussi Kivilinna
386039ee17dSJussi Kivilinna /* Check physical medium */
3879f5e60ddSJussi Kivilinna phym = NULL;
388039ee17dSJussi Kivilinna reply_len = sizeof *phym;
3897390e8b0SLinus Walleij retval = rndis_query(dev, intf, u.buf,
3905432bdc0SJussi Kivilinna RNDIS_OID_GEN_PHYSICAL_MEDIUM,
391e56b3d94SAndrey Zhizhikin reply_len, (void **)&phym, &reply_len);
3929f5e60ddSJussi Kivilinna if (retval != 0 || !phym) {
393039ee17dSJussi Kivilinna /* OID is optional so don't fail here. */
3947390e8b0SLinus Walleij phym_unspec = cpu_to_le32(RNDIS_PHYSICAL_MEDIUM_UNSPECIFIED);
3959f5e60ddSJussi Kivilinna phym = &phym_unspec;
3969f5e60ddSJussi Kivilinna }
397039ee17dSJussi Kivilinna if ((flags & FLAG_RNDIS_PHYM_WIRELESS) &&
3983eef3668SJussi Kivilinna le32_to_cpup(phym) != RNDIS_PHYSICAL_MEDIUM_WIRELESS_LAN) {
399a475f603SJoe Perches netif_dbg(dev, probe, dev->net,
400a475f603SJoe Perches "driver requires wireless physical medium, but device is not\n");
401039ee17dSJussi Kivilinna retval = -ENODEV;
402039ee17dSJussi Kivilinna goto halt_fail_and_release;
403039ee17dSJussi Kivilinna }
404039ee17dSJussi Kivilinna if ((flags & FLAG_RNDIS_PHYM_NOT_WIRELESS) &&
4053eef3668SJussi Kivilinna le32_to_cpup(phym) == RNDIS_PHYSICAL_MEDIUM_WIRELESS_LAN) {
406a475f603SJoe Perches netif_dbg(dev, probe, dev->net,
407a475f603SJoe Perches "driver requires non-wireless physical medium, but device is wireless.\n");
408039ee17dSJussi Kivilinna retval = -ENODEV;
409039ee17dSJussi Kivilinna goto halt_fail_and_release;
410039ee17dSJussi Kivilinna }
411039ee17dSJussi Kivilinna
4125b2fc499SJeff Garzik /* Get designated host ethernet address */
4135b2fc499SJeff Garzik reply_len = ETH_ALEN;
4147390e8b0SLinus Walleij retval = rndis_query(dev, intf, u.buf,
4155432bdc0SJussi Kivilinna RNDIS_OID_802_3_PERMANENT_ADDRESS,
4165b2fc499SJeff Garzik 48, (void **) &bp, &reply_len);
4175b2fc499SJeff Garzik if (unlikely(retval< 0)) {
4185b2fc499SJeff Garzik dev_err(&intf->dev, "rndis get ethaddr, %d\n", retval);
4199ff55874SJussi Kivilinna goto halt_fail_and_release;
4205b2fc499SJeff Garzik }
421a5a18bdfSKristian Evensen
422af804e6dSJakub Kicinski eth_hw_addr_set(net, bp);
4235b2fc499SJeff Garzik
4245b2fc499SJeff Garzik /* set a nonzero filter to enable data transfers */
4255b2fc499SJeff Garzik memset(u.set, 0, sizeof *u.set);
4267390e8b0SLinus Walleij u.set->msg_type = cpu_to_le32(RNDIS_MSG_SET);
42735c26c2cSHarvey Harrison u.set->msg_len = cpu_to_le32(4 + sizeof *u.set);
4288cdddc3fSLinus Walleij u.set->oid = cpu_to_le32(RNDIS_OID_GEN_CURRENT_PACKET_FILTER);
42935c26c2cSHarvey Harrison u.set->len = cpu_to_le32(4);
43035c26c2cSHarvey Harrison u.set->offset = cpu_to_le32((sizeof *u.set) - 8);
4317390e8b0SLinus Walleij *(__le32 *)(u.buf + sizeof *u.set) = cpu_to_le32(RNDIS_DEFAULT_FILTER);
4325b2fc499SJeff Garzik
433818727baSJussi Kivilinna retval = rndis_command(dev, u.header, CONTROL_BUFFER_SIZE);
4345b2fc499SJeff Garzik if (unlikely(retval < 0)) {
4355b2fc499SJeff Garzik dev_err(&intf->dev, "rndis set packet filter, %d\n", retval);
4369ff55874SJussi Kivilinna goto halt_fail_and_release;
4375b2fc499SJeff Garzik }
4385b2fc499SJeff Garzik
4395b2fc499SJeff Garzik retval = 0;
4405b2fc499SJeff Garzik
4415b2fc499SJeff Garzik kfree(u.buf);
4425b2fc499SJeff Garzik return retval;
4435b2fc499SJeff Garzik
4449ff55874SJussi Kivilinna halt_fail_and_release:
4459ff55874SJussi Kivilinna memset(u.halt, 0, sizeof *u.halt);
4467390e8b0SLinus Walleij u.halt->msg_type = cpu_to_le32(RNDIS_MSG_HALT);
44735c26c2cSHarvey Harrison u.halt->msg_len = cpu_to_le32(sizeof *u.halt);
448818727baSJussi Kivilinna (void) rndis_command(dev, (void *)u.halt, CONTROL_BUFFER_SIZE);
4495b2fc499SJeff Garzik fail_and_release:
4505b2fc499SJeff Garzik usb_set_intfdata(info->data, NULL);
4515b2fc499SJeff Garzik usb_driver_release_interface(driver_of(intf), info->data);
4525b2fc499SJeff Garzik info->data = NULL;
4535b2fc499SJeff Garzik fail:
4545b2fc499SJeff Garzik kfree(u.buf);
4555b2fc499SJeff Garzik return retval;
4565b2fc499SJeff Garzik }
4575665998cSJussi Kivilinna EXPORT_SYMBOL_GPL(generic_rndis_bind);
4585b2fc499SJeff Garzik
rndis_bind(struct usbnet * dev,struct usb_interface * intf)459039ee17dSJussi Kivilinna static int rndis_bind(struct usbnet *dev, struct usb_interface *intf)
460039ee17dSJussi Kivilinna {
461039ee17dSJussi Kivilinna return generic_rndis_bind(dev, intf, FLAG_RNDIS_PHYM_NOT_WIRELESS);
462039ee17dSJussi Kivilinna }
463039ee17dSJussi Kivilinna
zte_rndis_bind(struct usbnet * dev,struct usb_interface * intf)464171cfae6SLech Perczak static int zte_rndis_bind(struct usbnet *dev, struct usb_interface *intf)
465171cfae6SLech Perczak {
466171cfae6SLech Perczak int status = rndis_bind(dev, intf);
467171cfae6SLech Perczak
468171cfae6SLech Perczak if (!status && (dev->net->dev_addr[0] & 0x02))
469171cfae6SLech Perczak eth_hw_addr_random(dev->net);
470171cfae6SLech Perczak
471171cfae6SLech Perczak return status;
472171cfae6SLech Perczak }
473171cfae6SLech Perczak
rndis_unbind(struct usbnet * dev,struct usb_interface * intf)4745665998cSJussi Kivilinna void rndis_unbind(struct usbnet *dev, struct usb_interface *intf)
4755b2fc499SJeff Garzik {
4765b2fc499SJeff Garzik struct rndis_halt *halt;
4775b2fc499SJeff Garzik
4785b2fc499SJeff Garzik /* try to clear any rndis state/activity (no i/o from stack!) */
47904c3c01aSJussi Kivilinna halt = kzalloc(CONTROL_BUFFER_SIZE, GFP_KERNEL);
4805b2fc499SJeff Garzik if (halt) {
4817390e8b0SLinus Walleij halt->msg_type = cpu_to_le32(RNDIS_MSG_HALT);
48235c26c2cSHarvey Harrison halt->msg_len = cpu_to_le32(sizeof *halt);
483818727baSJussi Kivilinna (void) rndis_command(dev, (void *)halt, CONTROL_BUFFER_SIZE);
4845b2fc499SJeff Garzik kfree(halt);
4855b2fc499SJeff Garzik }
4865b2fc499SJeff Garzik
4872bfa2e1fSBjorge Dijkstra usbnet_cdc_unbind(dev, intf);
4885b2fc499SJeff Garzik }
4895665998cSJussi Kivilinna EXPORT_SYMBOL_GPL(rndis_unbind);
4905b2fc499SJeff Garzik
4915b2fc499SJeff Garzik /*
4925b2fc499SJeff Garzik * DATA -- host must not write zlps
4935b2fc499SJeff Garzik */
rndis_rx_fixup(struct usbnet * dev,struct sk_buff * skb)4945665998cSJussi Kivilinna int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
4955b2fc499SJeff Garzik {
49636e74797SLech Perczak bool dst_mac_fixup;
49736e74797SLech Perczak
498eb85569fSEmil Goode /* This check is no longer done by usbnet */
499eb85569fSEmil Goode if (skb->len < dev->net->hard_header_len)
500eb85569fSEmil Goode return 0;
501eb85569fSEmil Goode
50236e74797SLech Perczak dst_mac_fixup = !!(dev->driver_info->data & RNDIS_DRIVER_DATA_DST_MAC_FIXUP);
50336e74797SLech Perczak
5045b2fc499SJeff Garzik /* peripheral may have batched packets to us... */
5055b2fc499SJeff Garzik while (likely(skb->len)) {
5065b2fc499SJeff Garzik struct rndis_data_hdr *hdr = (void *)skb->data;
5075b2fc499SJeff Garzik struct sk_buff *skb2;
5083eef3668SJussi Kivilinna u32 msg_type, msg_len, data_offset, data_len;
5095b2fc499SJeff Garzik
5103eef3668SJussi Kivilinna msg_type = le32_to_cpu(hdr->msg_type);
5115b2fc499SJeff Garzik msg_len = le32_to_cpu(hdr->msg_len);
5125b2fc499SJeff Garzik data_offset = le32_to_cpu(hdr->data_offset);
5135b2fc499SJeff Garzik data_len = le32_to_cpu(hdr->data_len);
5145b2fc499SJeff Garzik
5155b2fc499SJeff Garzik /* don't choke if we see oob, per-packet data, etc */
5163eef3668SJussi Kivilinna if (unlikely(msg_type != RNDIS_MSG_PACKET || skb->len < msg_len
5173eef3668SJussi Kivilinna || (data_offset + data_len + 8) > msg_len)) {
51858e2e7d5SHerbert Xu dev->net->stats.rx_frame_errors++;
51960b86755SJoe Perches netdev_dbg(dev->net, "bad rndis message %d/%d/%d/%d, len %d\n",
5205b2fc499SJeff Garzik le32_to_cpu(hdr->msg_type),
5215b2fc499SJeff Garzik msg_len, data_offset, data_len, skb->len);
5225b2fc499SJeff Garzik return 0;
5235b2fc499SJeff Garzik }
5245b2fc499SJeff Garzik skb_pull(skb, 8 + data_offset);
5255b2fc499SJeff Garzik
5265b2fc499SJeff Garzik /* at most one packet left? */
5275b2fc499SJeff Garzik if (likely((data_len - skb->len) <= sizeof *hdr)) {
5285b2fc499SJeff Garzik skb_trim(skb, data_len);
5295b2fc499SJeff Garzik break;
5305b2fc499SJeff Garzik }
5315b2fc499SJeff Garzik
5325b2fc499SJeff Garzik /* try to return all the packets in the batch */
5335b2fc499SJeff Garzik skb2 = skb_clone(skb, GFP_ATOMIC);
5345b2fc499SJeff Garzik if (unlikely(!skb2))
5355b2fc499SJeff Garzik break;
5365b2fc499SJeff Garzik skb_pull(skb, msg_len - sizeof *hdr);
5375b2fc499SJeff Garzik skb_trim(skb2, data_len);
53836e74797SLech Perczak
53936e74797SLech Perczak if (unlikely(dst_mac_fixup))
54036e74797SLech Perczak usbnet_cdc_zte_rx_fixup(dev, skb2);
54136e74797SLech Perczak
5425b2fc499SJeff Garzik usbnet_skb_return(dev, skb2);
5435b2fc499SJeff Garzik }
5445b2fc499SJeff Garzik
5455b2fc499SJeff Garzik /* caller will usbnet_skb_return the remaining packet */
54636e74797SLech Perczak if (unlikely(dst_mac_fixup))
54736e74797SLech Perczak usbnet_cdc_zte_rx_fixup(dev, skb);
54836e74797SLech Perczak
5495b2fc499SJeff Garzik return 1;
5505b2fc499SJeff Garzik }
5515665998cSJussi Kivilinna EXPORT_SYMBOL_GPL(rndis_rx_fixup);
5525b2fc499SJeff Garzik
5535665998cSJussi Kivilinna struct sk_buff *
rndis_tx_fixup(struct usbnet * dev,struct sk_buff * skb,gfp_t flags)5545b2fc499SJeff Garzik rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
5555b2fc499SJeff Garzik {
5565b2fc499SJeff Garzik struct rndis_data_hdr *hdr;
5575b2fc499SJeff Garzik struct sk_buff *skb2;
5585b2fc499SJeff Garzik unsigned len = skb->len;
5595b2fc499SJeff Garzik
5605b2fc499SJeff Garzik if (likely(!skb_cloned(skb))) {
5615b2fc499SJeff Garzik int room = skb_headroom(skb);
5625b2fc499SJeff Garzik
5635b2fc499SJeff Garzik /* enough head room as-is? */
5645b2fc499SJeff Garzik if (unlikely((sizeof *hdr) <= room))
5655b2fc499SJeff Garzik goto fill;
5665b2fc499SJeff Garzik
5675b2fc499SJeff Garzik /* enough room, but needs to be readjusted? */
5685b2fc499SJeff Garzik room += skb_tailroom(skb);
5695b2fc499SJeff Garzik if (likely((sizeof *hdr) <= room)) {
5705b2fc499SJeff Garzik skb->data = memmove(skb->head + sizeof *hdr,
5715b2fc499SJeff Garzik skb->data, len);
5725b2fc499SJeff Garzik skb_set_tail_pointer(skb, len);
5735b2fc499SJeff Garzik goto fill;
5745b2fc499SJeff Garzik }
5755b2fc499SJeff Garzik }
5765b2fc499SJeff Garzik
5775b2fc499SJeff Garzik /* create a new skb, with the correct size (and tailpad) */
5785b2fc499SJeff Garzik skb2 = skb_copy_expand(skb, sizeof *hdr, 1, flags);
5795b2fc499SJeff Garzik dev_kfree_skb_any(skb);
5805b2fc499SJeff Garzik if (unlikely(!skb2))
5815b2fc499SJeff Garzik return skb2;
5825b2fc499SJeff Garzik skb = skb2;
5835b2fc499SJeff Garzik
5845b2fc499SJeff Garzik /* fill out the RNDIS header. we won't bother trying to batch
5855b2fc499SJeff Garzik * packets; Linux minimizes wasted bandwidth through tx queues.
5865b2fc499SJeff Garzik */
5875b2fc499SJeff Garzik fill:
588d58ff351SJohannes Berg hdr = __skb_push(skb, sizeof *hdr);
5895b2fc499SJeff Garzik memset(hdr, 0, sizeof *hdr);
5907390e8b0SLinus Walleij hdr->msg_type = cpu_to_le32(RNDIS_MSG_PACKET);
5915b2fc499SJeff Garzik hdr->msg_len = cpu_to_le32(skb->len);
59235c26c2cSHarvey Harrison hdr->data_offset = cpu_to_le32(sizeof(*hdr) - 8);
5935b2fc499SJeff Garzik hdr->data_len = cpu_to_le32(len);
5945b2fc499SJeff Garzik
5955b2fc499SJeff Garzik /* FIXME make the last packet always be short ... */
5965b2fc499SJeff Garzik return skb;
5975b2fc499SJeff Garzik }
5985665998cSJussi Kivilinna EXPORT_SYMBOL_GPL(rndis_tx_fixup);
5995b2fc499SJeff Garzik
6005b2fc499SJeff Garzik
6015b2fc499SJeff Garzik static const struct driver_info rndis_info = {
6025b2fc499SJeff Garzik .description = "RNDIS device",
603c261344dSArnd Bergmann .flags = FLAG_ETHER | FLAG_POINTTOPOINT | FLAG_FRAMING_RN | FLAG_NO_SETINT,
604039ee17dSJussi Kivilinna .bind = rndis_bind,
6055b2fc499SJeff Garzik .unbind = rndis_unbind,
6065b2fc499SJeff Garzik .status = rndis_status,
6075b2fc499SJeff Garzik .rx_fixup = rndis_rx_fixup,
6085b2fc499SJeff Garzik .tx_fixup = rndis_tx_fixup,
6095b2fc499SJeff Garzik };
6105b2fc499SJeff Garzik
6114d42d417SBen Hutchings static const struct driver_info rndis_poll_status_info = {
6124d42d417SBen Hutchings .description = "RNDIS device (poll status before control)",
613eb8aa72dSBen Hutchings .flags = FLAG_ETHER | FLAG_POINTTOPOINT | FLAG_FRAMING_RN | FLAG_NO_SETINT,
6144d42d417SBen Hutchings .data = RNDIS_DRIVER_DATA_POLL_STATUS,
6154d42d417SBen Hutchings .bind = rndis_bind,
6164d42d417SBen Hutchings .unbind = rndis_unbind,
6174d42d417SBen Hutchings .status = rndis_status,
6184d42d417SBen Hutchings .rx_fixup = rndis_rx_fixup,
6194d42d417SBen Hutchings .tx_fixup = rndis_tx_fixup,
6204d42d417SBen Hutchings };
6214d42d417SBen Hutchings
62236e74797SLech Perczak static const struct driver_info zte_rndis_info = {
62336e74797SLech Perczak .description = "ZTE RNDIS device",
62436e74797SLech Perczak .flags = FLAG_ETHER | FLAG_POINTTOPOINT | FLAG_FRAMING_RN | FLAG_NO_SETINT,
62536e74797SLech Perczak .data = RNDIS_DRIVER_DATA_DST_MAC_FIXUP,
626171cfae6SLech Perczak .bind = zte_rndis_bind,
62736e74797SLech Perczak .unbind = rndis_unbind,
62836e74797SLech Perczak .status = rndis_status,
62936e74797SLech Perczak .rx_fixup = rndis_rx_fixup,
63036e74797SLech Perczak .tx_fixup = rndis_tx_fixup,
63136e74797SLech Perczak };
63236e74797SLech Perczak
6335b2fc499SJeff Garzik /*-------------------------------------------------------------------------*/
6345b2fc499SJeff Garzik
6355b2fc499SJeff Garzik static const struct usb_device_id products [] = {
6365b2fc499SJeff Garzik {
6374d42d417SBen Hutchings /* 2Wire HomePortal 1000SW */
6384d42d417SBen Hutchings USB_DEVICE_AND_INTERFACE_INFO(0x1630, 0x0042,
6394d42d417SBen Hutchings USB_CLASS_COMM, 2 /* ACM */, 0x0ff),
6404d42d417SBen Hutchings .driver_info = (unsigned long) &rndis_poll_status_info,
6414d42d417SBen Hutchings }, {
64229262e1fSThomas Toye /* Hytera Communications DMR radios' "Radio to PC Network" */
64329262e1fSThomas Toye USB_VENDOR_AND_INTERFACE_INFO(0x238b,
64429262e1fSThomas Toye USB_CLASS_COMM, 2 /* ACM */, 0x0ff),
64529262e1fSThomas Toye .driver_info = (unsigned long)&rndis_info,
64629262e1fSThomas Toye }, {
64736e74797SLech Perczak /* ZTE WWAN modules */
64836e74797SLech Perczak USB_VENDOR_AND_INTERFACE_INFO(0x19d2,
64936e74797SLech Perczak USB_CLASS_WIRELESS_CONTROLLER, 1, 3),
65036e74797SLech Perczak .driver_info = (unsigned long)&zte_rndis_info,
65136e74797SLech Perczak }, {
65236e74797SLech Perczak /* ZTE WWAN modules, ACM flavour */
65336e74797SLech Perczak USB_VENDOR_AND_INTERFACE_INFO(0x19d2,
65436e74797SLech Perczak USB_CLASS_COMM, 2 /* ACM */, 0x0ff),
65536e74797SLech Perczak .driver_info = (unsigned long)&zte_rndis_info,
65636e74797SLech Perczak }, {
6575b2fc499SJeff Garzik /* RNDIS is MSFT's un-official variant of CDC ACM */
6585b2fc499SJeff Garzik USB_INTERFACE_INFO(USB_CLASS_COMM, 2 /* ACM */, 0x0ff),
6595b2fc499SJeff Garzik .driver_info = (unsigned long) &rndis_info,
6605b2fc499SJeff Garzik }, {
6615b2fc499SJeff Garzik /* "ActiveSync" is an undocumented variant of RNDIS, used in WM5 */
6625b2fc499SJeff Garzik USB_INTERFACE_INFO(USB_CLASS_MISC, 1, 1),
6634d42d417SBen Hutchings .driver_info = (unsigned long) &rndis_poll_status_info,
6647e99eeddSThomas Backlund }, {
6657e99eeddSThomas Backlund /* RNDIS for tethering */
6667e99eeddSThomas Backlund USB_INTERFACE_INFO(USB_CLASS_WIRELESS_CONTROLLER, 1, 3),
6677e99eeddSThomas Backlund .driver_info = (unsigned long) &rndis_info,
66863ba395cSAleksander Morgado }, {
66963ba395cSAleksander Morgado /* Novatel Verizon USB730L */
67063ba395cSAleksander Morgado USB_INTERFACE_INFO(USB_CLASS_MISC, 4, 1),
67163ba395cSAleksander Morgado .driver_info = (unsigned long) &rndis_info,
6725b2fc499SJeff Garzik },
6735b2fc499SJeff Garzik { }, // END
6745b2fc499SJeff Garzik };
6755b2fc499SJeff Garzik MODULE_DEVICE_TABLE(usb, products);
6765b2fc499SJeff Garzik
6775b2fc499SJeff Garzik static struct usb_driver rndis_driver = {
6785b2fc499SJeff Garzik .name = "rndis_host",
6795b2fc499SJeff Garzik .id_table = products,
6805b2fc499SJeff Garzik .probe = usbnet_probe,
6815b2fc499SJeff Garzik .disconnect = usbnet_disconnect,
6825b2fc499SJeff Garzik .suspend = usbnet_suspend,
6835b2fc499SJeff Garzik .resume = usbnet_resume,
684e1f12eb6SSarah Sharp .disable_hub_initiated_lpm = 1,
6855b2fc499SJeff Garzik };
6865b2fc499SJeff Garzik
687d632eb1bSGreg Kroah-Hartman module_usb_driver(rndis_driver);
6885b2fc499SJeff Garzik
6895b2fc499SJeff Garzik MODULE_AUTHOR("David Brownell");
6905b2fc499SJeff Garzik MODULE_DESCRIPTION("USB Host side RNDIS driver");
6915b2fc499SJeff Garzik MODULE_LICENSE("GPL");
692