15fd54aceSGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0 200a2430fSAndrzej Pietrasiewicz /* 300a2430fSAndrzej Pietrasiewicz * RNDIS MSG parser 400a2430fSAndrzej Pietrasiewicz * 500a2430fSAndrzej Pietrasiewicz * Authors: Benedikt Spranger, Pengutronix 600a2430fSAndrzej Pietrasiewicz * Robert Schwebel, Pengutronix 700a2430fSAndrzej Pietrasiewicz * 800a2430fSAndrzej Pietrasiewicz * This software was originally developed in conformance with 900a2430fSAndrzej Pietrasiewicz * Microsoft's Remote NDIS Specification License Agreement. 1000a2430fSAndrzej Pietrasiewicz * 1100a2430fSAndrzej Pietrasiewicz * 03/12/2004 Kai-Uwe Bloem <linux-development@auerswald.de> 1200a2430fSAndrzej Pietrasiewicz * Fixed message length bug in init_response 1300a2430fSAndrzej Pietrasiewicz * 1400a2430fSAndrzej Pietrasiewicz * 03/25/2004 Kai-Uwe Bloem <linux-development@auerswald.de> 1500a2430fSAndrzej Pietrasiewicz * Fixed rndis_rm_hdr length bug. 1600a2430fSAndrzej Pietrasiewicz * 1700a2430fSAndrzej Pietrasiewicz * Copyright (C) 2004 by David Brownell 1800a2430fSAndrzej Pietrasiewicz * updates to merge with Linux 2.6, better match RNDIS spec 1900a2430fSAndrzej Pietrasiewicz */ 2000a2430fSAndrzej Pietrasiewicz 2100a2430fSAndrzej Pietrasiewicz #include <linux/module.h> 2200a2430fSAndrzej Pietrasiewicz #include <linux/moduleparam.h> 2300a2430fSAndrzej Pietrasiewicz #include <linux/kernel.h> 2400a2430fSAndrzej Pietrasiewicz #include <linux/errno.h> 25d6d22922SAndrzej Pietrasiewicz #include <linux/idr.h> 2600a2430fSAndrzej Pietrasiewicz #include <linux/list.h> 2700a2430fSAndrzej Pietrasiewicz #include <linux/proc_fs.h> 2800a2430fSAndrzej Pietrasiewicz #include <linux/slab.h> 2900a2430fSAndrzej Pietrasiewicz #include <linux/seq_file.h> 3000a2430fSAndrzej Pietrasiewicz #include <linux/netdevice.h> 3100a2430fSAndrzej Pietrasiewicz 3200a2430fSAndrzej Pietrasiewicz #include <asm/io.h> 3300a2430fSAndrzej Pietrasiewicz #include <asm/byteorder.h> 3400a2430fSAndrzej Pietrasiewicz #include <asm/unaligned.h> 3500a2430fSAndrzej Pietrasiewicz 3600a2430fSAndrzej Pietrasiewicz #include "u_rndis.h" 3700a2430fSAndrzej Pietrasiewicz 3800a2430fSAndrzej Pietrasiewicz #undef VERBOSE_DEBUG 3900a2430fSAndrzej Pietrasiewicz 4000a2430fSAndrzej Pietrasiewicz #include "rndis.h" 4100a2430fSAndrzej Pietrasiewicz 4200a2430fSAndrzej Pietrasiewicz 4300a2430fSAndrzej Pietrasiewicz /* The driver for your USB chip needs to support ep0 OUT to work with 4400a2430fSAndrzej Pietrasiewicz * RNDIS, plus all three CDC Ethernet endpoints (interrupt not optional). 4500a2430fSAndrzej Pietrasiewicz * 4600a2430fSAndrzej Pietrasiewicz * Windows hosts need an INF file like Documentation/usb/linux.inf 4700a2430fSAndrzej Pietrasiewicz * and will be happier if you provide the host_addr module parameter. 4800a2430fSAndrzej Pietrasiewicz */ 4900a2430fSAndrzej Pietrasiewicz 5000a2430fSAndrzej Pietrasiewicz #if 0 5100a2430fSAndrzej Pietrasiewicz static int rndis_debug = 0; 5200a2430fSAndrzej Pietrasiewicz module_param (rndis_debug, int, 0); 5300a2430fSAndrzej Pietrasiewicz MODULE_PARM_DESC (rndis_debug, "enable debugging"); 5400a2430fSAndrzej Pietrasiewicz #else 5500a2430fSAndrzej Pietrasiewicz #define rndis_debug 0 5600a2430fSAndrzej Pietrasiewicz #endif 5700a2430fSAndrzej Pietrasiewicz 58d6d22922SAndrzej Pietrasiewicz #ifdef CONFIG_USB_GADGET_DEBUG_FILES 5900a2430fSAndrzej Pietrasiewicz 60d6d22922SAndrzej Pietrasiewicz #define NAME_TEMPLATE "driver/rndis-%03d" 6100a2430fSAndrzej Pietrasiewicz 62d6d22922SAndrzej Pietrasiewicz #endif /* CONFIG_USB_GADGET_DEBUG_FILES */ 63d6d22922SAndrzej Pietrasiewicz 64d6d22922SAndrzej Pietrasiewicz static DEFINE_IDA(rndis_ida); 6500a2430fSAndrzej Pietrasiewicz 6600a2430fSAndrzej Pietrasiewicz /* Driver Version */ 6700a2430fSAndrzej Pietrasiewicz static const __le32 rndis_driver_version = cpu_to_le32(1); 6800a2430fSAndrzej Pietrasiewicz 6900a2430fSAndrzej Pietrasiewicz /* Function Prototypes */ 7083210e59SAndrzej Pietrasiewicz static rndis_resp_t *rndis_add_response(struct rndis_params *params, 7183210e59SAndrzej Pietrasiewicz u32 length); 7200a2430fSAndrzej Pietrasiewicz 73d6d22922SAndrzej Pietrasiewicz #ifdef CONFIG_USB_GADGET_DEBUG_FILES 74d6d22922SAndrzej Pietrasiewicz 7597a32539SAlexey Dobriyan static const struct proc_ops rndis_proc_ops; 76d6d22922SAndrzej Pietrasiewicz 77d6d22922SAndrzej Pietrasiewicz #endif /* CONFIG_USB_GADGET_DEBUG_FILES */ 7800a2430fSAndrzej Pietrasiewicz 7900a2430fSAndrzej Pietrasiewicz /* supported OIDs */ 8097f0117bSAnson Jacob static const u32 oid_supported_list[] = { 8100a2430fSAndrzej Pietrasiewicz /* the general stuff */ 8200a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_SUPPORTED_LIST, 8300a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_HARDWARE_STATUS, 8400a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_MEDIA_SUPPORTED, 8500a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_MEDIA_IN_USE, 8600a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE, 8700a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_LINK_SPEED, 8800a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_TRANSMIT_BLOCK_SIZE, 8900a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_RECEIVE_BLOCK_SIZE, 9000a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_VENDOR_ID, 9100a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_VENDOR_DESCRIPTION, 9200a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_VENDOR_DRIVER_VERSION, 9300a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_CURRENT_PACKET_FILTER, 9400a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_MAXIMUM_TOTAL_SIZE, 9500a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_MEDIA_CONNECT_STATUS, 9600a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_PHYSICAL_MEDIUM, 9700a2430fSAndrzej Pietrasiewicz 9800a2430fSAndrzej Pietrasiewicz /* the statistical stuff */ 9900a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_XMIT_OK, 10000a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_RCV_OK, 10100a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_XMIT_ERROR, 10200a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_RCV_ERROR, 10300a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_RCV_NO_BUFFER, 10400a2430fSAndrzej Pietrasiewicz #ifdef RNDIS_OPTIONAL_STATS 10500a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_DIRECTED_BYTES_XMIT, 10600a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_DIRECTED_FRAMES_XMIT, 10700a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_MULTICAST_BYTES_XMIT, 10800a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_MULTICAST_FRAMES_XMIT, 10900a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_BROADCAST_BYTES_XMIT, 11000a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_BROADCAST_FRAMES_XMIT, 11100a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_DIRECTED_BYTES_RCV, 11200a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_DIRECTED_FRAMES_RCV, 11300a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_MULTICAST_BYTES_RCV, 11400a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_MULTICAST_FRAMES_RCV, 11500a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_BROADCAST_BYTES_RCV, 11600a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_BROADCAST_FRAMES_RCV, 11700a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_RCV_CRC_ERROR, 11800a2430fSAndrzej Pietrasiewicz RNDIS_OID_GEN_TRANSMIT_QUEUE_LENGTH, 11900a2430fSAndrzej Pietrasiewicz #endif /* RNDIS_OPTIONAL_STATS */ 12000a2430fSAndrzej Pietrasiewicz 12100a2430fSAndrzej Pietrasiewicz /* mandatory 802.3 */ 12200a2430fSAndrzej Pietrasiewicz /* the general stuff */ 12300a2430fSAndrzej Pietrasiewicz RNDIS_OID_802_3_PERMANENT_ADDRESS, 12400a2430fSAndrzej Pietrasiewicz RNDIS_OID_802_3_CURRENT_ADDRESS, 12500a2430fSAndrzej Pietrasiewicz RNDIS_OID_802_3_MULTICAST_LIST, 12600a2430fSAndrzej Pietrasiewicz RNDIS_OID_802_3_MAC_OPTIONS, 12700a2430fSAndrzej Pietrasiewicz RNDIS_OID_802_3_MAXIMUM_LIST_SIZE, 12800a2430fSAndrzej Pietrasiewicz 12900a2430fSAndrzej Pietrasiewicz /* the statistical stuff */ 13000a2430fSAndrzej Pietrasiewicz RNDIS_OID_802_3_RCV_ERROR_ALIGNMENT, 13100a2430fSAndrzej Pietrasiewicz RNDIS_OID_802_3_XMIT_ONE_COLLISION, 13200a2430fSAndrzej Pietrasiewicz RNDIS_OID_802_3_XMIT_MORE_COLLISIONS, 13300a2430fSAndrzej Pietrasiewicz #ifdef RNDIS_OPTIONAL_STATS 13400a2430fSAndrzej Pietrasiewicz RNDIS_OID_802_3_XMIT_DEFERRED, 13500a2430fSAndrzej Pietrasiewicz RNDIS_OID_802_3_XMIT_MAX_COLLISIONS, 13600a2430fSAndrzej Pietrasiewicz RNDIS_OID_802_3_RCV_OVERRUN, 13700a2430fSAndrzej Pietrasiewicz RNDIS_OID_802_3_XMIT_UNDERRUN, 13800a2430fSAndrzej Pietrasiewicz RNDIS_OID_802_3_XMIT_HEARTBEAT_FAILURE, 13900a2430fSAndrzej Pietrasiewicz RNDIS_OID_802_3_XMIT_TIMES_CRS_LOST, 14000a2430fSAndrzej Pietrasiewicz RNDIS_OID_802_3_XMIT_LATE_COLLISIONS, 14100a2430fSAndrzej Pietrasiewicz #endif /* RNDIS_OPTIONAL_STATS */ 14200a2430fSAndrzej Pietrasiewicz 14300a2430fSAndrzej Pietrasiewicz #ifdef RNDIS_PM 14400a2430fSAndrzej Pietrasiewicz /* PM and wakeup are "mandatory" for USB, but the RNDIS specs 14500a2430fSAndrzej Pietrasiewicz * don't say what they mean ... and the NDIS specs are often 14600a2430fSAndrzej Pietrasiewicz * confusing and/or ambiguous in this context. (That is, more 14700a2430fSAndrzej Pietrasiewicz * so than their specs for the other OIDs.) 14800a2430fSAndrzej Pietrasiewicz * 14900a2430fSAndrzej Pietrasiewicz * FIXME someone who knows what these should do, please 15000a2430fSAndrzej Pietrasiewicz * implement them! 15100a2430fSAndrzej Pietrasiewicz */ 15200a2430fSAndrzej Pietrasiewicz 15300a2430fSAndrzej Pietrasiewicz /* power management */ 15400a2430fSAndrzej Pietrasiewicz OID_PNP_CAPABILITIES, 15500a2430fSAndrzej Pietrasiewicz OID_PNP_QUERY_POWER, 15600a2430fSAndrzej Pietrasiewicz OID_PNP_SET_POWER, 15700a2430fSAndrzej Pietrasiewicz 15800a2430fSAndrzej Pietrasiewicz #ifdef RNDIS_WAKEUP 15900a2430fSAndrzej Pietrasiewicz /* wake up host */ 16000a2430fSAndrzej Pietrasiewicz OID_PNP_ENABLE_WAKE_UP, 16100a2430fSAndrzej Pietrasiewicz OID_PNP_ADD_WAKE_UP_PATTERN, 16200a2430fSAndrzej Pietrasiewicz OID_PNP_REMOVE_WAKE_UP_PATTERN, 16300a2430fSAndrzej Pietrasiewicz #endif /* RNDIS_WAKEUP */ 16400a2430fSAndrzej Pietrasiewicz #endif /* RNDIS_PM */ 16500a2430fSAndrzej Pietrasiewicz }; 16600a2430fSAndrzej Pietrasiewicz 16700a2430fSAndrzej Pietrasiewicz 16800a2430fSAndrzej Pietrasiewicz /* NDIS Functions */ 16983210e59SAndrzej Pietrasiewicz static int gen_ndis_query_resp(struct rndis_params *params, u32 OID, u8 *buf, 17000a2430fSAndrzej Pietrasiewicz unsigned buf_len, rndis_resp_t *r) 17100a2430fSAndrzej Pietrasiewicz { 17200a2430fSAndrzej Pietrasiewicz int retval = -ENOTSUPP; 17300a2430fSAndrzej Pietrasiewicz u32 length = 4; /* usually */ 17400a2430fSAndrzej Pietrasiewicz __le32 *outbuf; 17500a2430fSAndrzej Pietrasiewicz int i, count; 17600a2430fSAndrzej Pietrasiewicz rndis_query_cmplt_type *resp; 17700a2430fSAndrzej Pietrasiewicz struct net_device *net; 17800a2430fSAndrzej Pietrasiewicz struct rtnl_link_stats64 temp; 17900a2430fSAndrzej Pietrasiewicz const struct rtnl_link_stats64 *stats; 18000a2430fSAndrzej Pietrasiewicz 18100a2430fSAndrzej Pietrasiewicz if (!r) return -ENOMEM; 18200a2430fSAndrzej Pietrasiewicz resp = (rndis_query_cmplt_type *)r->buf; 18300a2430fSAndrzej Pietrasiewicz 18400a2430fSAndrzej Pietrasiewicz if (!resp) return -ENOMEM; 18500a2430fSAndrzej Pietrasiewicz 18600a2430fSAndrzej Pietrasiewicz if (buf_len && rndis_debug > 1) { 18700a2430fSAndrzej Pietrasiewicz pr_debug("query OID %08x value, len %d:\n", OID, buf_len); 18800a2430fSAndrzej Pietrasiewicz for (i = 0; i < buf_len; i += 16) { 18900a2430fSAndrzej Pietrasiewicz pr_debug("%03d: %08x %08x %08x %08x\n", i, 19000a2430fSAndrzej Pietrasiewicz get_unaligned_le32(&buf[i]), 19100a2430fSAndrzej Pietrasiewicz get_unaligned_le32(&buf[i + 4]), 19200a2430fSAndrzej Pietrasiewicz get_unaligned_le32(&buf[i + 8]), 19300a2430fSAndrzej Pietrasiewicz get_unaligned_le32(&buf[i + 12])); 19400a2430fSAndrzej Pietrasiewicz } 19500a2430fSAndrzej Pietrasiewicz } 19600a2430fSAndrzej Pietrasiewicz 19700a2430fSAndrzej Pietrasiewicz /* response goes here, right after the header */ 19800a2430fSAndrzej Pietrasiewicz outbuf = (__le32 *)&resp[1]; 19900a2430fSAndrzej Pietrasiewicz resp->InformationBufferOffset = cpu_to_le32(16); 20000a2430fSAndrzej Pietrasiewicz 20183210e59SAndrzej Pietrasiewicz net = params->dev; 20200a2430fSAndrzej Pietrasiewicz stats = dev_get_stats(net, &temp); 20300a2430fSAndrzej Pietrasiewicz 20400a2430fSAndrzej Pietrasiewicz switch (OID) { 20500a2430fSAndrzej Pietrasiewicz 20600a2430fSAndrzej Pietrasiewicz /* general oids (table 4-1) */ 20700a2430fSAndrzej Pietrasiewicz 20800a2430fSAndrzej Pietrasiewicz /* mandatory */ 20900a2430fSAndrzej Pietrasiewicz case RNDIS_OID_GEN_SUPPORTED_LIST: 21000a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_GEN_SUPPORTED_LIST\n", __func__); 21100a2430fSAndrzej Pietrasiewicz length = sizeof(oid_supported_list); 21200a2430fSAndrzej Pietrasiewicz count = length / sizeof(u32); 21300a2430fSAndrzej Pietrasiewicz for (i = 0; i < count; i++) 21400a2430fSAndrzej Pietrasiewicz outbuf[i] = cpu_to_le32(oid_supported_list[i]); 21500a2430fSAndrzej Pietrasiewicz retval = 0; 21600a2430fSAndrzej Pietrasiewicz break; 21700a2430fSAndrzej Pietrasiewicz 21800a2430fSAndrzej Pietrasiewicz /* mandatory */ 21900a2430fSAndrzej Pietrasiewicz case RNDIS_OID_GEN_HARDWARE_STATUS: 22000a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_GEN_HARDWARE_STATUS\n", __func__); 22100a2430fSAndrzej Pietrasiewicz /* Bogus question! 22200a2430fSAndrzej Pietrasiewicz * Hardware must be ready to receive high level protocols. 22300a2430fSAndrzej Pietrasiewicz * BTW: 22400a2430fSAndrzej Pietrasiewicz * reddite ergo quae sunt Caesaris Caesari 22500a2430fSAndrzej Pietrasiewicz * et quae sunt Dei Deo! 22600a2430fSAndrzej Pietrasiewicz */ 22700a2430fSAndrzej Pietrasiewicz *outbuf = cpu_to_le32(0); 22800a2430fSAndrzej Pietrasiewicz retval = 0; 22900a2430fSAndrzej Pietrasiewicz break; 23000a2430fSAndrzej Pietrasiewicz 23100a2430fSAndrzej Pietrasiewicz /* mandatory */ 23200a2430fSAndrzej Pietrasiewicz case RNDIS_OID_GEN_MEDIA_SUPPORTED: 23300a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_GEN_MEDIA_SUPPORTED\n", __func__); 23483210e59SAndrzej Pietrasiewicz *outbuf = cpu_to_le32(params->medium); 23500a2430fSAndrzej Pietrasiewicz retval = 0; 23600a2430fSAndrzej Pietrasiewicz break; 23700a2430fSAndrzej Pietrasiewicz 23800a2430fSAndrzej Pietrasiewicz /* mandatory */ 23900a2430fSAndrzej Pietrasiewicz case RNDIS_OID_GEN_MEDIA_IN_USE: 24000a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_GEN_MEDIA_IN_USE\n", __func__); 24100a2430fSAndrzej Pietrasiewicz /* one medium, one transport... (maybe you do it better) */ 24283210e59SAndrzej Pietrasiewicz *outbuf = cpu_to_le32(params->medium); 24300a2430fSAndrzej Pietrasiewicz retval = 0; 24400a2430fSAndrzej Pietrasiewicz break; 24500a2430fSAndrzej Pietrasiewicz 24600a2430fSAndrzej Pietrasiewicz /* mandatory */ 24700a2430fSAndrzej Pietrasiewicz case RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE: 24800a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE\n", __func__); 24983210e59SAndrzej Pietrasiewicz if (params->dev) { 25083210e59SAndrzej Pietrasiewicz *outbuf = cpu_to_le32(params->dev->mtu); 25100a2430fSAndrzej Pietrasiewicz retval = 0; 25200a2430fSAndrzej Pietrasiewicz } 25300a2430fSAndrzej Pietrasiewicz break; 25400a2430fSAndrzej Pietrasiewicz 25500a2430fSAndrzej Pietrasiewicz /* mandatory */ 25600a2430fSAndrzej Pietrasiewicz case RNDIS_OID_GEN_LINK_SPEED: 25700a2430fSAndrzej Pietrasiewicz if (rndis_debug > 1) 25800a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_GEN_LINK_SPEED\n", __func__); 25983210e59SAndrzej Pietrasiewicz if (params->media_state == RNDIS_MEDIA_STATE_DISCONNECTED) 26000a2430fSAndrzej Pietrasiewicz *outbuf = cpu_to_le32(0); 26100a2430fSAndrzej Pietrasiewicz else 26283210e59SAndrzej Pietrasiewicz *outbuf = cpu_to_le32(params->speed); 26300a2430fSAndrzej Pietrasiewicz retval = 0; 26400a2430fSAndrzej Pietrasiewicz break; 26500a2430fSAndrzej Pietrasiewicz 26600a2430fSAndrzej Pietrasiewicz /* mandatory */ 26700a2430fSAndrzej Pietrasiewicz case RNDIS_OID_GEN_TRANSMIT_BLOCK_SIZE: 26800a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_GEN_TRANSMIT_BLOCK_SIZE\n", __func__); 26983210e59SAndrzej Pietrasiewicz if (params->dev) { 27083210e59SAndrzej Pietrasiewicz *outbuf = cpu_to_le32(params->dev->mtu); 27100a2430fSAndrzej Pietrasiewicz retval = 0; 27200a2430fSAndrzej Pietrasiewicz } 27300a2430fSAndrzej Pietrasiewicz break; 27400a2430fSAndrzej Pietrasiewicz 27500a2430fSAndrzej Pietrasiewicz /* mandatory */ 27600a2430fSAndrzej Pietrasiewicz case RNDIS_OID_GEN_RECEIVE_BLOCK_SIZE: 27700a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_GEN_RECEIVE_BLOCK_SIZE\n", __func__); 27883210e59SAndrzej Pietrasiewicz if (params->dev) { 27983210e59SAndrzej Pietrasiewicz *outbuf = cpu_to_le32(params->dev->mtu); 28000a2430fSAndrzej Pietrasiewicz retval = 0; 28100a2430fSAndrzej Pietrasiewicz } 28200a2430fSAndrzej Pietrasiewicz break; 28300a2430fSAndrzej Pietrasiewicz 28400a2430fSAndrzej Pietrasiewicz /* mandatory */ 28500a2430fSAndrzej Pietrasiewicz case RNDIS_OID_GEN_VENDOR_ID: 28600a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_GEN_VENDOR_ID\n", __func__); 28783210e59SAndrzej Pietrasiewicz *outbuf = cpu_to_le32(params->vendorID); 28800a2430fSAndrzej Pietrasiewicz retval = 0; 28900a2430fSAndrzej Pietrasiewicz break; 29000a2430fSAndrzej Pietrasiewicz 29100a2430fSAndrzej Pietrasiewicz /* mandatory */ 29200a2430fSAndrzej Pietrasiewicz case RNDIS_OID_GEN_VENDOR_DESCRIPTION: 29300a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_GEN_VENDOR_DESCRIPTION\n", __func__); 29483210e59SAndrzej Pietrasiewicz if (params->vendorDescr) { 29583210e59SAndrzej Pietrasiewicz length = strlen(params->vendorDescr); 29683210e59SAndrzej Pietrasiewicz memcpy(outbuf, params->vendorDescr, length); 29700a2430fSAndrzej Pietrasiewicz } else { 29800a2430fSAndrzej Pietrasiewicz outbuf[0] = 0; 29900a2430fSAndrzej Pietrasiewicz } 30000a2430fSAndrzej Pietrasiewicz retval = 0; 30100a2430fSAndrzej Pietrasiewicz break; 30200a2430fSAndrzej Pietrasiewicz 30300a2430fSAndrzej Pietrasiewicz case RNDIS_OID_GEN_VENDOR_DRIVER_VERSION: 30400a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_GEN_VENDOR_DRIVER_VERSION\n", __func__); 30500a2430fSAndrzej Pietrasiewicz /* Created as LE */ 30600a2430fSAndrzej Pietrasiewicz *outbuf = rndis_driver_version; 30700a2430fSAndrzej Pietrasiewicz retval = 0; 30800a2430fSAndrzej Pietrasiewicz break; 30900a2430fSAndrzej Pietrasiewicz 31000a2430fSAndrzej Pietrasiewicz /* mandatory */ 31100a2430fSAndrzej Pietrasiewicz case RNDIS_OID_GEN_CURRENT_PACKET_FILTER: 31200a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_GEN_CURRENT_PACKET_FILTER\n", __func__); 31383210e59SAndrzej Pietrasiewicz *outbuf = cpu_to_le32(*params->filter); 31400a2430fSAndrzej Pietrasiewicz retval = 0; 31500a2430fSAndrzej Pietrasiewicz break; 31600a2430fSAndrzej Pietrasiewicz 31700a2430fSAndrzej Pietrasiewicz /* mandatory */ 31800a2430fSAndrzej Pietrasiewicz case RNDIS_OID_GEN_MAXIMUM_TOTAL_SIZE: 31900a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_GEN_MAXIMUM_TOTAL_SIZE\n", __func__); 32000a2430fSAndrzej Pietrasiewicz *outbuf = cpu_to_le32(RNDIS_MAX_TOTAL_SIZE); 32100a2430fSAndrzej Pietrasiewicz retval = 0; 32200a2430fSAndrzej Pietrasiewicz break; 32300a2430fSAndrzej Pietrasiewicz 32400a2430fSAndrzej Pietrasiewicz /* mandatory */ 32500a2430fSAndrzej Pietrasiewicz case RNDIS_OID_GEN_MEDIA_CONNECT_STATUS: 32600a2430fSAndrzej Pietrasiewicz if (rndis_debug > 1) 32700a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_GEN_MEDIA_CONNECT_STATUS\n", __func__); 32883210e59SAndrzej Pietrasiewicz *outbuf = cpu_to_le32(params->media_state); 32900a2430fSAndrzej Pietrasiewicz retval = 0; 33000a2430fSAndrzej Pietrasiewicz break; 33100a2430fSAndrzej Pietrasiewicz 33200a2430fSAndrzej Pietrasiewicz case RNDIS_OID_GEN_PHYSICAL_MEDIUM: 33300a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_GEN_PHYSICAL_MEDIUM\n", __func__); 33400a2430fSAndrzej Pietrasiewicz *outbuf = cpu_to_le32(0); 33500a2430fSAndrzej Pietrasiewicz retval = 0; 33600a2430fSAndrzej Pietrasiewicz break; 33700a2430fSAndrzej Pietrasiewicz 33800a2430fSAndrzej Pietrasiewicz /* The RNDIS specification is incomplete/wrong. Some versions 33900a2430fSAndrzej Pietrasiewicz * of MS-Windows expect OIDs that aren't specified there. Other 34000a2430fSAndrzej Pietrasiewicz * versions emit undefined RNDIS messages. DOCUMENT ALL THESE! 34100a2430fSAndrzej Pietrasiewicz */ 34200a2430fSAndrzej Pietrasiewicz case RNDIS_OID_GEN_MAC_OPTIONS: /* from WinME */ 34300a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_GEN_MAC_OPTIONS\n", __func__); 34400a2430fSAndrzej Pietrasiewicz *outbuf = cpu_to_le32( 34500a2430fSAndrzej Pietrasiewicz RNDIS_MAC_OPTION_RECEIVE_SERIALIZED 34600a2430fSAndrzej Pietrasiewicz | RNDIS_MAC_OPTION_FULL_DUPLEX); 34700a2430fSAndrzej Pietrasiewicz retval = 0; 34800a2430fSAndrzej Pietrasiewicz break; 34900a2430fSAndrzej Pietrasiewicz 35000a2430fSAndrzej Pietrasiewicz /* statistics OIDs (table 4-2) */ 35100a2430fSAndrzej Pietrasiewicz 35200a2430fSAndrzej Pietrasiewicz /* mandatory */ 35300a2430fSAndrzej Pietrasiewicz case RNDIS_OID_GEN_XMIT_OK: 35400a2430fSAndrzej Pietrasiewicz if (rndis_debug > 1) 35500a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_GEN_XMIT_OK\n", __func__); 35600a2430fSAndrzej Pietrasiewicz if (stats) { 35700a2430fSAndrzej Pietrasiewicz *outbuf = cpu_to_le32(stats->tx_packets 35800a2430fSAndrzej Pietrasiewicz - stats->tx_errors - stats->tx_dropped); 35900a2430fSAndrzej Pietrasiewicz retval = 0; 36000a2430fSAndrzej Pietrasiewicz } 36100a2430fSAndrzej Pietrasiewicz break; 36200a2430fSAndrzej Pietrasiewicz 36300a2430fSAndrzej Pietrasiewicz /* mandatory */ 36400a2430fSAndrzej Pietrasiewicz case RNDIS_OID_GEN_RCV_OK: 36500a2430fSAndrzej Pietrasiewicz if (rndis_debug > 1) 36600a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_GEN_RCV_OK\n", __func__); 36700a2430fSAndrzej Pietrasiewicz if (stats) { 36800a2430fSAndrzej Pietrasiewicz *outbuf = cpu_to_le32(stats->rx_packets 36900a2430fSAndrzej Pietrasiewicz - stats->rx_errors - stats->rx_dropped); 37000a2430fSAndrzej Pietrasiewicz retval = 0; 37100a2430fSAndrzej Pietrasiewicz } 37200a2430fSAndrzej Pietrasiewicz break; 37300a2430fSAndrzej Pietrasiewicz 37400a2430fSAndrzej Pietrasiewicz /* mandatory */ 37500a2430fSAndrzej Pietrasiewicz case RNDIS_OID_GEN_XMIT_ERROR: 37600a2430fSAndrzej Pietrasiewicz if (rndis_debug > 1) 37700a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_GEN_XMIT_ERROR\n", __func__); 37800a2430fSAndrzej Pietrasiewicz if (stats) { 37900a2430fSAndrzej Pietrasiewicz *outbuf = cpu_to_le32(stats->tx_errors); 38000a2430fSAndrzej Pietrasiewicz retval = 0; 38100a2430fSAndrzej Pietrasiewicz } 38200a2430fSAndrzej Pietrasiewicz break; 38300a2430fSAndrzej Pietrasiewicz 38400a2430fSAndrzej Pietrasiewicz /* mandatory */ 38500a2430fSAndrzej Pietrasiewicz case RNDIS_OID_GEN_RCV_ERROR: 38600a2430fSAndrzej Pietrasiewicz if (rndis_debug > 1) 38700a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_GEN_RCV_ERROR\n", __func__); 38800a2430fSAndrzej Pietrasiewicz if (stats) { 38900a2430fSAndrzej Pietrasiewicz *outbuf = cpu_to_le32(stats->rx_errors); 39000a2430fSAndrzej Pietrasiewicz retval = 0; 39100a2430fSAndrzej Pietrasiewicz } 39200a2430fSAndrzej Pietrasiewicz break; 39300a2430fSAndrzej Pietrasiewicz 39400a2430fSAndrzej Pietrasiewicz /* mandatory */ 39500a2430fSAndrzej Pietrasiewicz case RNDIS_OID_GEN_RCV_NO_BUFFER: 39600a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_GEN_RCV_NO_BUFFER\n", __func__); 39700a2430fSAndrzej Pietrasiewicz if (stats) { 39800a2430fSAndrzej Pietrasiewicz *outbuf = cpu_to_le32(stats->rx_dropped); 39900a2430fSAndrzej Pietrasiewicz retval = 0; 40000a2430fSAndrzej Pietrasiewicz } 40100a2430fSAndrzej Pietrasiewicz break; 40200a2430fSAndrzej Pietrasiewicz 40300a2430fSAndrzej Pietrasiewicz /* ieee802.3 OIDs (table 4-3) */ 40400a2430fSAndrzej Pietrasiewicz 40500a2430fSAndrzej Pietrasiewicz /* mandatory */ 40600a2430fSAndrzej Pietrasiewicz case RNDIS_OID_802_3_PERMANENT_ADDRESS: 40700a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_802_3_PERMANENT_ADDRESS\n", __func__); 40883210e59SAndrzej Pietrasiewicz if (params->dev) { 40900a2430fSAndrzej Pietrasiewicz length = ETH_ALEN; 41083210e59SAndrzej Pietrasiewicz memcpy(outbuf, params->host_mac, length); 41100a2430fSAndrzej Pietrasiewicz retval = 0; 41200a2430fSAndrzej Pietrasiewicz } 41300a2430fSAndrzej Pietrasiewicz break; 41400a2430fSAndrzej Pietrasiewicz 41500a2430fSAndrzej Pietrasiewicz /* mandatory */ 41600a2430fSAndrzej Pietrasiewicz case RNDIS_OID_802_3_CURRENT_ADDRESS: 41700a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_802_3_CURRENT_ADDRESS\n", __func__); 41883210e59SAndrzej Pietrasiewicz if (params->dev) { 41900a2430fSAndrzej Pietrasiewicz length = ETH_ALEN; 42083210e59SAndrzej Pietrasiewicz memcpy(outbuf, params->host_mac, length); 42100a2430fSAndrzej Pietrasiewicz retval = 0; 42200a2430fSAndrzej Pietrasiewicz } 42300a2430fSAndrzej Pietrasiewicz break; 42400a2430fSAndrzej Pietrasiewicz 42500a2430fSAndrzej Pietrasiewicz /* mandatory */ 42600a2430fSAndrzej Pietrasiewicz case RNDIS_OID_802_3_MULTICAST_LIST: 42700a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_802_3_MULTICAST_LIST\n", __func__); 42800a2430fSAndrzej Pietrasiewicz /* Multicast base address only */ 42900a2430fSAndrzej Pietrasiewicz *outbuf = cpu_to_le32(0xE0000000); 43000a2430fSAndrzej Pietrasiewicz retval = 0; 43100a2430fSAndrzej Pietrasiewicz break; 43200a2430fSAndrzej Pietrasiewicz 43300a2430fSAndrzej Pietrasiewicz /* mandatory */ 43400a2430fSAndrzej Pietrasiewicz case RNDIS_OID_802_3_MAXIMUM_LIST_SIZE: 43500a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_802_3_MAXIMUM_LIST_SIZE\n", __func__); 43600a2430fSAndrzej Pietrasiewicz /* Multicast base address only */ 43700a2430fSAndrzej Pietrasiewicz *outbuf = cpu_to_le32(1); 43800a2430fSAndrzej Pietrasiewicz retval = 0; 43900a2430fSAndrzej Pietrasiewicz break; 44000a2430fSAndrzej Pietrasiewicz 44100a2430fSAndrzej Pietrasiewicz case RNDIS_OID_802_3_MAC_OPTIONS: 44200a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_802_3_MAC_OPTIONS\n", __func__); 44300a2430fSAndrzej Pietrasiewicz *outbuf = cpu_to_le32(0); 44400a2430fSAndrzej Pietrasiewicz retval = 0; 44500a2430fSAndrzej Pietrasiewicz break; 44600a2430fSAndrzej Pietrasiewicz 44700a2430fSAndrzej Pietrasiewicz /* ieee802.3 statistics OIDs (table 4-4) */ 44800a2430fSAndrzej Pietrasiewicz 44900a2430fSAndrzej Pietrasiewicz /* mandatory */ 45000a2430fSAndrzej Pietrasiewicz case RNDIS_OID_802_3_RCV_ERROR_ALIGNMENT: 45100a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_802_3_RCV_ERROR_ALIGNMENT\n", __func__); 45200a2430fSAndrzej Pietrasiewicz if (stats) { 45300a2430fSAndrzej Pietrasiewicz *outbuf = cpu_to_le32(stats->rx_frame_errors); 45400a2430fSAndrzej Pietrasiewicz retval = 0; 45500a2430fSAndrzej Pietrasiewicz } 45600a2430fSAndrzej Pietrasiewicz break; 45700a2430fSAndrzej Pietrasiewicz 45800a2430fSAndrzej Pietrasiewicz /* mandatory */ 45900a2430fSAndrzej Pietrasiewicz case RNDIS_OID_802_3_XMIT_ONE_COLLISION: 46000a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_802_3_XMIT_ONE_COLLISION\n", __func__); 46100a2430fSAndrzej Pietrasiewicz *outbuf = cpu_to_le32(0); 46200a2430fSAndrzej Pietrasiewicz retval = 0; 46300a2430fSAndrzej Pietrasiewicz break; 46400a2430fSAndrzej Pietrasiewicz 46500a2430fSAndrzej Pietrasiewicz /* mandatory */ 46600a2430fSAndrzej Pietrasiewicz case RNDIS_OID_802_3_XMIT_MORE_COLLISIONS: 46700a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_802_3_XMIT_MORE_COLLISIONS\n", __func__); 46800a2430fSAndrzej Pietrasiewicz *outbuf = cpu_to_le32(0); 46900a2430fSAndrzej Pietrasiewicz retval = 0; 47000a2430fSAndrzej Pietrasiewicz break; 47100a2430fSAndrzej Pietrasiewicz 47200a2430fSAndrzej Pietrasiewicz default: 4733f5ad864SJoe Perches pr_warn("%s: query unknown OID 0x%08X\n", __func__, OID); 47400a2430fSAndrzej Pietrasiewicz } 47500a2430fSAndrzej Pietrasiewicz if (retval < 0) 47600a2430fSAndrzej Pietrasiewicz length = 0; 47700a2430fSAndrzej Pietrasiewicz 47800a2430fSAndrzej Pietrasiewicz resp->InformationBufferLength = cpu_to_le32(length); 47900a2430fSAndrzej Pietrasiewicz r->length = length + sizeof(*resp); 48000a2430fSAndrzej Pietrasiewicz resp->MessageLength = cpu_to_le32(r->length); 48100a2430fSAndrzej Pietrasiewicz return retval; 48200a2430fSAndrzej Pietrasiewicz } 48300a2430fSAndrzej Pietrasiewicz 48483210e59SAndrzej Pietrasiewicz static int gen_ndis_set_resp(struct rndis_params *params, u32 OID, 48583210e59SAndrzej Pietrasiewicz u8 *buf, u32 buf_len, rndis_resp_t *r) 48600a2430fSAndrzej Pietrasiewicz { 48700a2430fSAndrzej Pietrasiewicz rndis_set_cmplt_type *resp; 48800a2430fSAndrzej Pietrasiewicz int i, retval = -ENOTSUPP; 48900a2430fSAndrzej Pietrasiewicz 49000a2430fSAndrzej Pietrasiewicz if (!r) 49100a2430fSAndrzej Pietrasiewicz return -ENOMEM; 49200a2430fSAndrzej Pietrasiewicz resp = (rndis_set_cmplt_type *)r->buf; 49300a2430fSAndrzej Pietrasiewicz if (!resp) 49400a2430fSAndrzej Pietrasiewicz return -ENOMEM; 49500a2430fSAndrzej Pietrasiewicz 49600a2430fSAndrzej Pietrasiewicz if (buf_len && rndis_debug > 1) { 49700a2430fSAndrzej Pietrasiewicz pr_debug("set OID %08x value, len %d:\n", OID, buf_len); 49800a2430fSAndrzej Pietrasiewicz for (i = 0; i < buf_len; i += 16) { 49900a2430fSAndrzej Pietrasiewicz pr_debug("%03d: %08x %08x %08x %08x\n", i, 50000a2430fSAndrzej Pietrasiewicz get_unaligned_le32(&buf[i]), 50100a2430fSAndrzej Pietrasiewicz get_unaligned_le32(&buf[i + 4]), 50200a2430fSAndrzej Pietrasiewicz get_unaligned_le32(&buf[i + 8]), 50300a2430fSAndrzej Pietrasiewicz get_unaligned_le32(&buf[i + 12])); 50400a2430fSAndrzej Pietrasiewicz } 50500a2430fSAndrzej Pietrasiewicz } 50600a2430fSAndrzej Pietrasiewicz 50700a2430fSAndrzej Pietrasiewicz switch (OID) { 50800a2430fSAndrzej Pietrasiewicz case RNDIS_OID_GEN_CURRENT_PACKET_FILTER: 50900a2430fSAndrzej Pietrasiewicz 51000a2430fSAndrzej Pietrasiewicz /* these NDIS_PACKET_TYPE_* bitflags are shared with 51100a2430fSAndrzej Pietrasiewicz * cdc_filter; it's not RNDIS-specific 51200a2430fSAndrzej Pietrasiewicz * NDIS_PACKET_TYPE_x == USB_CDC_PACKET_TYPE_x for x in: 51300a2430fSAndrzej Pietrasiewicz * PROMISCUOUS, DIRECTED, 51400a2430fSAndrzej Pietrasiewicz * MULTICAST, ALL_MULTICAST, BROADCAST 51500a2430fSAndrzej Pietrasiewicz */ 51600a2430fSAndrzej Pietrasiewicz *params->filter = (u16)get_unaligned_le32(buf); 51700a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_GEN_CURRENT_PACKET_FILTER %08x\n", 51800a2430fSAndrzej Pietrasiewicz __func__, *params->filter); 51900a2430fSAndrzej Pietrasiewicz 52000a2430fSAndrzej Pietrasiewicz /* this call has a significant side effect: it's 52100a2430fSAndrzej Pietrasiewicz * what makes the packet flow start and stop, like 52200a2430fSAndrzej Pietrasiewicz * activating the CDC Ethernet altsetting. 52300a2430fSAndrzej Pietrasiewicz */ 52400a2430fSAndrzej Pietrasiewicz retval = 0; 52500a2430fSAndrzej Pietrasiewicz if (*params->filter) { 52600a2430fSAndrzej Pietrasiewicz params->state = RNDIS_DATA_INITIALIZED; 52700a2430fSAndrzej Pietrasiewicz netif_carrier_on(params->dev); 52800a2430fSAndrzej Pietrasiewicz if (netif_running(params->dev)) 52900a2430fSAndrzej Pietrasiewicz netif_wake_queue(params->dev); 53000a2430fSAndrzej Pietrasiewicz } else { 53100a2430fSAndrzej Pietrasiewicz params->state = RNDIS_INITIALIZED; 53200a2430fSAndrzej Pietrasiewicz netif_carrier_off(params->dev); 53300a2430fSAndrzej Pietrasiewicz netif_stop_queue(params->dev); 53400a2430fSAndrzej Pietrasiewicz } 53500a2430fSAndrzej Pietrasiewicz break; 53600a2430fSAndrzej Pietrasiewicz 53700a2430fSAndrzej Pietrasiewicz case RNDIS_OID_802_3_MULTICAST_LIST: 53800a2430fSAndrzej Pietrasiewicz /* I think we can ignore this */ 53900a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_OID_802_3_MULTICAST_LIST\n", __func__); 54000a2430fSAndrzej Pietrasiewicz retval = 0; 54100a2430fSAndrzej Pietrasiewicz break; 54200a2430fSAndrzej Pietrasiewicz 54300a2430fSAndrzej Pietrasiewicz default: 5443f5ad864SJoe Perches pr_warn("%s: set unknown OID 0x%08X, size %d\n", 54500a2430fSAndrzej Pietrasiewicz __func__, OID, buf_len); 54600a2430fSAndrzej Pietrasiewicz } 54700a2430fSAndrzej Pietrasiewicz 54800a2430fSAndrzej Pietrasiewicz return retval; 54900a2430fSAndrzej Pietrasiewicz } 55000a2430fSAndrzej Pietrasiewicz 55100a2430fSAndrzej Pietrasiewicz /* 55200a2430fSAndrzej Pietrasiewicz * Response Functions 55300a2430fSAndrzej Pietrasiewicz */ 55400a2430fSAndrzej Pietrasiewicz 55583210e59SAndrzej Pietrasiewicz static int rndis_init_response(struct rndis_params *params, 55683210e59SAndrzej Pietrasiewicz rndis_init_msg_type *buf) 55700a2430fSAndrzej Pietrasiewicz { 55800a2430fSAndrzej Pietrasiewicz rndis_init_cmplt_type *resp; 55900a2430fSAndrzej Pietrasiewicz rndis_resp_t *r; 56000a2430fSAndrzej Pietrasiewicz 56100a2430fSAndrzej Pietrasiewicz if (!params->dev) 56200a2430fSAndrzej Pietrasiewicz return -ENOTSUPP; 56300a2430fSAndrzej Pietrasiewicz 56483210e59SAndrzej Pietrasiewicz r = rndis_add_response(params, sizeof(rndis_init_cmplt_type)); 56500a2430fSAndrzej Pietrasiewicz if (!r) 56600a2430fSAndrzej Pietrasiewicz return -ENOMEM; 56700a2430fSAndrzej Pietrasiewicz resp = (rndis_init_cmplt_type *)r->buf; 56800a2430fSAndrzej Pietrasiewicz 56900a2430fSAndrzej Pietrasiewicz resp->MessageType = cpu_to_le32(RNDIS_MSG_INIT_C); 57000a2430fSAndrzej Pietrasiewicz resp->MessageLength = cpu_to_le32(52); 57100a2430fSAndrzej Pietrasiewicz resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ 57200a2430fSAndrzej Pietrasiewicz resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS); 57300a2430fSAndrzej Pietrasiewicz resp->MajorVersion = cpu_to_le32(RNDIS_MAJOR_VERSION); 57400a2430fSAndrzej Pietrasiewicz resp->MinorVersion = cpu_to_le32(RNDIS_MINOR_VERSION); 57500a2430fSAndrzej Pietrasiewicz resp->DeviceFlags = cpu_to_le32(RNDIS_DF_CONNECTIONLESS); 57600a2430fSAndrzej Pietrasiewicz resp->Medium = cpu_to_le32(RNDIS_MEDIUM_802_3); 57700a2430fSAndrzej Pietrasiewicz resp->MaxPacketsPerTransfer = cpu_to_le32(1); 57800a2430fSAndrzej Pietrasiewicz resp->MaxTransferSize = cpu_to_le32( 57900a2430fSAndrzej Pietrasiewicz params->dev->mtu 58000a2430fSAndrzej Pietrasiewicz + sizeof(struct ethhdr) 58100a2430fSAndrzej Pietrasiewicz + sizeof(struct rndis_packet_msg_type) 58200a2430fSAndrzej Pietrasiewicz + 22); 58300a2430fSAndrzej Pietrasiewicz resp->PacketAlignmentFactor = cpu_to_le32(0); 58400a2430fSAndrzej Pietrasiewicz resp->AFListOffset = cpu_to_le32(0); 58500a2430fSAndrzej Pietrasiewicz resp->AFListSize = cpu_to_le32(0); 58600a2430fSAndrzej Pietrasiewicz 58700a2430fSAndrzej Pietrasiewicz params->resp_avail(params->v); 58800a2430fSAndrzej Pietrasiewicz return 0; 58900a2430fSAndrzej Pietrasiewicz } 59000a2430fSAndrzej Pietrasiewicz 59183210e59SAndrzej Pietrasiewicz static int rndis_query_response(struct rndis_params *params, 59283210e59SAndrzej Pietrasiewicz rndis_query_msg_type *buf) 59300a2430fSAndrzej Pietrasiewicz { 59400a2430fSAndrzej Pietrasiewicz rndis_query_cmplt_type *resp; 59500a2430fSAndrzej Pietrasiewicz rndis_resp_t *r; 59600a2430fSAndrzej Pietrasiewicz 59700a2430fSAndrzej Pietrasiewicz /* pr_debug("%s: OID = %08X\n", __func__, cpu_to_le32(buf->OID)); */ 59800a2430fSAndrzej Pietrasiewicz if (!params->dev) 59900a2430fSAndrzej Pietrasiewicz return -ENOTSUPP; 60000a2430fSAndrzej Pietrasiewicz 60100a2430fSAndrzej Pietrasiewicz /* 60200a2430fSAndrzej Pietrasiewicz * we need more memory: 60300a2430fSAndrzej Pietrasiewicz * gen_ndis_query_resp expects enough space for 60400a2430fSAndrzej Pietrasiewicz * rndis_query_cmplt_type followed by data. 60500a2430fSAndrzej Pietrasiewicz * oid_supported_list is the largest data reply 60600a2430fSAndrzej Pietrasiewicz */ 60783210e59SAndrzej Pietrasiewicz r = rndis_add_response(params, 60800a2430fSAndrzej Pietrasiewicz sizeof(oid_supported_list) + sizeof(rndis_query_cmplt_type)); 60900a2430fSAndrzej Pietrasiewicz if (!r) 61000a2430fSAndrzej Pietrasiewicz return -ENOMEM; 61100a2430fSAndrzej Pietrasiewicz resp = (rndis_query_cmplt_type *)r->buf; 61200a2430fSAndrzej Pietrasiewicz 61300a2430fSAndrzej Pietrasiewicz resp->MessageType = cpu_to_le32(RNDIS_MSG_QUERY_C); 61400a2430fSAndrzej Pietrasiewicz resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ 61500a2430fSAndrzej Pietrasiewicz 61683210e59SAndrzej Pietrasiewicz if (gen_ndis_query_resp(params, le32_to_cpu(buf->OID), 61700a2430fSAndrzej Pietrasiewicz le32_to_cpu(buf->InformationBufferOffset) 61800a2430fSAndrzej Pietrasiewicz + 8 + (u8 *)buf, 61900a2430fSAndrzej Pietrasiewicz le32_to_cpu(buf->InformationBufferLength), 62000a2430fSAndrzej Pietrasiewicz r)) { 62100a2430fSAndrzej Pietrasiewicz /* OID not supported */ 62200a2430fSAndrzej Pietrasiewicz resp->Status = cpu_to_le32(RNDIS_STATUS_NOT_SUPPORTED); 62300a2430fSAndrzej Pietrasiewicz resp->MessageLength = cpu_to_le32(sizeof *resp); 62400a2430fSAndrzej Pietrasiewicz resp->InformationBufferLength = cpu_to_le32(0); 62500a2430fSAndrzej Pietrasiewicz resp->InformationBufferOffset = cpu_to_le32(0); 62600a2430fSAndrzej Pietrasiewicz } else 62700a2430fSAndrzej Pietrasiewicz resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS); 62800a2430fSAndrzej Pietrasiewicz 62900a2430fSAndrzej Pietrasiewicz params->resp_avail(params->v); 63000a2430fSAndrzej Pietrasiewicz return 0; 63100a2430fSAndrzej Pietrasiewicz } 63200a2430fSAndrzej Pietrasiewicz 63383210e59SAndrzej Pietrasiewicz static int rndis_set_response(struct rndis_params *params, 63483210e59SAndrzej Pietrasiewicz rndis_set_msg_type *buf) 63500a2430fSAndrzej Pietrasiewicz { 63600a2430fSAndrzej Pietrasiewicz u32 BufLength, BufOffset; 63700a2430fSAndrzej Pietrasiewicz rndis_set_cmplt_type *resp; 63800a2430fSAndrzej Pietrasiewicz rndis_resp_t *r; 63900a2430fSAndrzej Pietrasiewicz 64038ea1eacSGreg Kroah-Hartman BufLength = le32_to_cpu(buf->InformationBufferLength); 64138ea1eacSGreg Kroah-Hartman BufOffset = le32_to_cpu(buf->InformationBufferOffset); 64238ea1eacSGreg Kroah-Hartman if ((BufLength > RNDIS_MAX_TOTAL_SIZE) || 643*65f3324fSDan Carpenter (BufOffset > RNDIS_MAX_TOTAL_SIZE) || 64438ea1eacSGreg Kroah-Hartman (BufOffset + 8 >= RNDIS_MAX_TOTAL_SIZE)) 64538ea1eacSGreg Kroah-Hartman return -EINVAL; 64638ea1eacSGreg Kroah-Hartman 64783210e59SAndrzej Pietrasiewicz r = rndis_add_response(params, sizeof(rndis_set_cmplt_type)); 64800a2430fSAndrzej Pietrasiewicz if (!r) 64900a2430fSAndrzej Pietrasiewicz return -ENOMEM; 65000a2430fSAndrzej Pietrasiewicz resp = (rndis_set_cmplt_type *)r->buf; 65100a2430fSAndrzej Pietrasiewicz 65200a2430fSAndrzej Pietrasiewicz #ifdef VERBOSE_DEBUG 65300a2430fSAndrzej Pietrasiewicz pr_debug("%s: Length: %d\n", __func__, BufLength); 65400a2430fSAndrzej Pietrasiewicz pr_debug("%s: Offset: %d\n", __func__, BufOffset); 65500a2430fSAndrzej Pietrasiewicz pr_debug("%s: InfoBuffer: ", __func__); 65600a2430fSAndrzej Pietrasiewicz 65700a2430fSAndrzej Pietrasiewicz for (i = 0; i < BufLength; i++) { 65800a2430fSAndrzej Pietrasiewicz pr_debug("%02x ", *(((u8 *) buf) + i + 8 + BufOffset)); 65900a2430fSAndrzej Pietrasiewicz } 66000a2430fSAndrzej Pietrasiewicz 66100a2430fSAndrzej Pietrasiewicz pr_debug("\n"); 66200a2430fSAndrzej Pietrasiewicz #endif 66300a2430fSAndrzej Pietrasiewicz 66400a2430fSAndrzej Pietrasiewicz resp->MessageType = cpu_to_le32(RNDIS_MSG_SET_C); 66500a2430fSAndrzej Pietrasiewicz resp->MessageLength = cpu_to_le32(16); 66600a2430fSAndrzej Pietrasiewicz resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ 66783210e59SAndrzej Pietrasiewicz if (gen_ndis_set_resp(params, le32_to_cpu(buf->OID), 66800a2430fSAndrzej Pietrasiewicz ((u8 *)buf) + 8 + BufOffset, BufLength, r)) 66900a2430fSAndrzej Pietrasiewicz resp->Status = cpu_to_le32(RNDIS_STATUS_NOT_SUPPORTED); 67000a2430fSAndrzej Pietrasiewicz else 67100a2430fSAndrzej Pietrasiewicz resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS); 67200a2430fSAndrzej Pietrasiewicz 67300a2430fSAndrzej Pietrasiewicz params->resp_avail(params->v); 67400a2430fSAndrzej Pietrasiewicz return 0; 67500a2430fSAndrzej Pietrasiewicz } 67600a2430fSAndrzej Pietrasiewicz 67783210e59SAndrzej Pietrasiewicz static int rndis_reset_response(struct rndis_params *params, 67883210e59SAndrzej Pietrasiewicz rndis_reset_msg_type *buf) 67900a2430fSAndrzej Pietrasiewicz { 68000a2430fSAndrzej Pietrasiewicz rndis_reset_cmplt_type *resp; 68100a2430fSAndrzej Pietrasiewicz rndis_resp_t *r; 682207707d8SXerox Lin u8 *xbuf; 683207707d8SXerox Lin u32 length; 684207707d8SXerox Lin 685207707d8SXerox Lin /* drain the response queue */ 686207707d8SXerox Lin while ((xbuf = rndis_get_next_response(params, &length))) 687207707d8SXerox Lin rndis_free_response(params, xbuf); 68800a2430fSAndrzej Pietrasiewicz 68983210e59SAndrzej Pietrasiewicz r = rndis_add_response(params, sizeof(rndis_reset_cmplt_type)); 69000a2430fSAndrzej Pietrasiewicz if (!r) 69100a2430fSAndrzej Pietrasiewicz return -ENOMEM; 69200a2430fSAndrzej Pietrasiewicz resp = (rndis_reset_cmplt_type *)r->buf; 69300a2430fSAndrzej Pietrasiewicz 69400a2430fSAndrzej Pietrasiewicz resp->MessageType = cpu_to_le32(RNDIS_MSG_RESET_C); 69500a2430fSAndrzej Pietrasiewicz resp->MessageLength = cpu_to_le32(16); 69600a2430fSAndrzej Pietrasiewicz resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS); 69700a2430fSAndrzej Pietrasiewicz /* resent information */ 69800a2430fSAndrzej Pietrasiewicz resp->AddressingReset = cpu_to_le32(1); 69900a2430fSAndrzej Pietrasiewicz 70000a2430fSAndrzej Pietrasiewicz params->resp_avail(params->v); 70100a2430fSAndrzej Pietrasiewicz return 0; 70200a2430fSAndrzej Pietrasiewicz } 70300a2430fSAndrzej Pietrasiewicz 70483210e59SAndrzej Pietrasiewicz static int rndis_keepalive_response(struct rndis_params *params, 70500a2430fSAndrzej Pietrasiewicz rndis_keepalive_msg_type *buf) 70600a2430fSAndrzej Pietrasiewicz { 70700a2430fSAndrzej Pietrasiewicz rndis_keepalive_cmplt_type *resp; 70800a2430fSAndrzej Pietrasiewicz rndis_resp_t *r; 70900a2430fSAndrzej Pietrasiewicz 71000a2430fSAndrzej Pietrasiewicz /* host "should" check only in RNDIS_DATA_INITIALIZED state */ 71100a2430fSAndrzej Pietrasiewicz 71283210e59SAndrzej Pietrasiewicz r = rndis_add_response(params, sizeof(rndis_keepalive_cmplt_type)); 71300a2430fSAndrzej Pietrasiewicz if (!r) 71400a2430fSAndrzej Pietrasiewicz return -ENOMEM; 71500a2430fSAndrzej Pietrasiewicz resp = (rndis_keepalive_cmplt_type *)r->buf; 71600a2430fSAndrzej Pietrasiewicz 71700a2430fSAndrzej Pietrasiewicz resp->MessageType = cpu_to_le32(RNDIS_MSG_KEEPALIVE_C); 71800a2430fSAndrzej Pietrasiewicz resp->MessageLength = cpu_to_le32(16); 71900a2430fSAndrzej Pietrasiewicz resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ 72000a2430fSAndrzej Pietrasiewicz resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS); 72100a2430fSAndrzej Pietrasiewicz 72200a2430fSAndrzej Pietrasiewicz params->resp_avail(params->v); 72300a2430fSAndrzej Pietrasiewicz return 0; 72400a2430fSAndrzej Pietrasiewicz } 72500a2430fSAndrzej Pietrasiewicz 72600a2430fSAndrzej Pietrasiewicz 72700a2430fSAndrzej Pietrasiewicz /* 72800a2430fSAndrzej Pietrasiewicz * Device to Host Comunication 72900a2430fSAndrzej Pietrasiewicz */ 73083210e59SAndrzej Pietrasiewicz static int rndis_indicate_status_msg(struct rndis_params *params, u32 status) 73100a2430fSAndrzej Pietrasiewicz { 73200a2430fSAndrzej Pietrasiewicz rndis_indicate_status_msg_type *resp; 73300a2430fSAndrzej Pietrasiewicz rndis_resp_t *r; 73400a2430fSAndrzej Pietrasiewicz 73500a2430fSAndrzej Pietrasiewicz if (params->state == RNDIS_UNINITIALIZED) 73600a2430fSAndrzej Pietrasiewicz return -ENOTSUPP; 73700a2430fSAndrzej Pietrasiewicz 73883210e59SAndrzej Pietrasiewicz r = rndis_add_response(params, sizeof(rndis_indicate_status_msg_type)); 73900a2430fSAndrzej Pietrasiewicz if (!r) 74000a2430fSAndrzej Pietrasiewicz return -ENOMEM; 74100a2430fSAndrzej Pietrasiewicz resp = (rndis_indicate_status_msg_type *)r->buf; 74200a2430fSAndrzej Pietrasiewicz 74300a2430fSAndrzej Pietrasiewicz resp->MessageType = cpu_to_le32(RNDIS_MSG_INDICATE); 74400a2430fSAndrzej Pietrasiewicz resp->MessageLength = cpu_to_le32(20); 74500a2430fSAndrzej Pietrasiewicz resp->Status = cpu_to_le32(status); 74600a2430fSAndrzej Pietrasiewicz resp->StatusBufferLength = cpu_to_le32(0); 74700a2430fSAndrzej Pietrasiewicz resp->StatusBufferOffset = cpu_to_le32(0); 74800a2430fSAndrzej Pietrasiewicz 74900a2430fSAndrzej Pietrasiewicz params->resp_avail(params->v); 75000a2430fSAndrzej Pietrasiewicz return 0; 75100a2430fSAndrzej Pietrasiewicz } 75200a2430fSAndrzej Pietrasiewicz 75383210e59SAndrzej Pietrasiewicz int rndis_signal_connect(struct rndis_params *params) 75400a2430fSAndrzej Pietrasiewicz { 75583210e59SAndrzej Pietrasiewicz params->media_state = RNDIS_MEDIA_STATE_CONNECTED; 75683210e59SAndrzej Pietrasiewicz return rndis_indicate_status_msg(params, RNDIS_STATUS_MEDIA_CONNECT); 75700a2430fSAndrzej Pietrasiewicz } 75800a2430fSAndrzej Pietrasiewicz EXPORT_SYMBOL_GPL(rndis_signal_connect); 75900a2430fSAndrzej Pietrasiewicz 76083210e59SAndrzej Pietrasiewicz int rndis_signal_disconnect(struct rndis_params *params) 76100a2430fSAndrzej Pietrasiewicz { 76283210e59SAndrzej Pietrasiewicz params->media_state = RNDIS_MEDIA_STATE_DISCONNECTED; 76383210e59SAndrzej Pietrasiewicz return rndis_indicate_status_msg(params, RNDIS_STATUS_MEDIA_DISCONNECT); 76400a2430fSAndrzej Pietrasiewicz } 76500a2430fSAndrzej Pietrasiewicz EXPORT_SYMBOL_GPL(rndis_signal_disconnect); 76600a2430fSAndrzej Pietrasiewicz 76783210e59SAndrzej Pietrasiewicz void rndis_uninit(struct rndis_params *params) 76800a2430fSAndrzej Pietrasiewicz { 76900a2430fSAndrzej Pietrasiewicz u8 *buf; 77000a2430fSAndrzej Pietrasiewicz u32 length; 77100a2430fSAndrzej Pietrasiewicz 77283210e59SAndrzej Pietrasiewicz if (!params) 77300a2430fSAndrzej Pietrasiewicz return; 77483210e59SAndrzej Pietrasiewicz params->state = RNDIS_UNINITIALIZED; 77500a2430fSAndrzej Pietrasiewicz 77600a2430fSAndrzej Pietrasiewicz /* drain the response queue */ 77783210e59SAndrzej Pietrasiewicz while ((buf = rndis_get_next_response(params, &length))) 77883210e59SAndrzej Pietrasiewicz rndis_free_response(params, buf); 77900a2430fSAndrzej Pietrasiewicz } 78000a2430fSAndrzej Pietrasiewicz EXPORT_SYMBOL_GPL(rndis_uninit); 78100a2430fSAndrzej Pietrasiewicz 78283210e59SAndrzej Pietrasiewicz void rndis_set_host_mac(struct rndis_params *params, const u8 *addr) 78300a2430fSAndrzej Pietrasiewicz { 78483210e59SAndrzej Pietrasiewicz params->host_mac = addr; 78500a2430fSAndrzej Pietrasiewicz } 78600a2430fSAndrzej Pietrasiewicz EXPORT_SYMBOL_GPL(rndis_set_host_mac); 78700a2430fSAndrzej Pietrasiewicz 78800a2430fSAndrzej Pietrasiewicz /* 78900a2430fSAndrzej Pietrasiewicz * Message Parser 79000a2430fSAndrzej Pietrasiewicz */ 79183210e59SAndrzej Pietrasiewicz int rndis_msg_parser(struct rndis_params *params, u8 *buf) 79200a2430fSAndrzej Pietrasiewicz { 79300a2430fSAndrzej Pietrasiewicz u32 MsgType, MsgLength; 79400a2430fSAndrzej Pietrasiewicz __le32 *tmp; 79500a2430fSAndrzej Pietrasiewicz 79600a2430fSAndrzej Pietrasiewicz if (!buf) 79700a2430fSAndrzej Pietrasiewicz return -ENOMEM; 79800a2430fSAndrzej Pietrasiewicz 79900a2430fSAndrzej Pietrasiewicz tmp = (__le32 *)buf; 80000a2430fSAndrzej Pietrasiewicz MsgType = get_unaligned_le32(tmp++); 80100a2430fSAndrzej Pietrasiewicz MsgLength = get_unaligned_le32(tmp++); 80200a2430fSAndrzej Pietrasiewicz 80383210e59SAndrzej Pietrasiewicz if (!params) 80400a2430fSAndrzej Pietrasiewicz return -ENOTSUPP; 80500a2430fSAndrzej Pietrasiewicz 80600a2430fSAndrzej Pietrasiewicz /* NOTE: RNDIS is *EXTREMELY* chatty ... Windows constantly polls for 80700a2430fSAndrzej Pietrasiewicz * rx/tx statistics and link status, in addition to KEEPALIVE traffic 80800a2430fSAndrzej Pietrasiewicz * and normal HC level polling to see if there's any IN traffic. 80900a2430fSAndrzej Pietrasiewicz */ 81000a2430fSAndrzej Pietrasiewicz 81100a2430fSAndrzej Pietrasiewicz /* For USB: responses may take up to 10 seconds */ 81200a2430fSAndrzej Pietrasiewicz switch (MsgType) { 81300a2430fSAndrzej Pietrasiewicz case RNDIS_MSG_INIT: 81400a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_MSG_INIT\n", 81500a2430fSAndrzej Pietrasiewicz __func__); 81600a2430fSAndrzej Pietrasiewicz params->state = RNDIS_INITIALIZED; 81783210e59SAndrzej Pietrasiewicz return rndis_init_response(params, (rndis_init_msg_type *)buf); 81800a2430fSAndrzej Pietrasiewicz 81900a2430fSAndrzej Pietrasiewicz case RNDIS_MSG_HALT: 82000a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_MSG_HALT\n", 82100a2430fSAndrzej Pietrasiewicz __func__); 82200a2430fSAndrzej Pietrasiewicz params->state = RNDIS_UNINITIALIZED; 82300a2430fSAndrzej Pietrasiewicz if (params->dev) { 82400a2430fSAndrzej Pietrasiewicz netif_carrier_off(params->dev); 82500a2430fSAndrzej Pietrasiewicz netif_stop_queue(params->dev); 82600a2430fSAndrzej Pietrasiewicz } 82700a2430fSAndrzej Pietrasiewicz return 0; 82800a2430fSAndrzej Pietrasiewicz 82900a2430fSAndrzej Pietrasiewicz case RNDIS_MSG_QUERY: 83083210e59SAndrzej Pietrasiewicz return rndis_query_response(params, 83100a2430fSAndrzej Pietrasiewicz (rndis_query_msg_type *)buf); 83200a2430fSAndrzej Pietrasiewicz 83300a2430fSAndrzej Pietrasiewicz case RNDIS_MSG_SET: 83483210e59SAndrzej Pietrasiewicz return rndis_set_response(params, (rndis_set_msg_type *)buf); 83500a2430fSAndrzej Pietrasiewicz 83600a2430fSAndrzej Pietrasiewicz case RNDIS_MSG_RESET: 83700a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_MSG_RESET\n", 83800a2430fSAndrzej Pietrasiewicz __func__); 83983210e59SAndrzej Pietrasiewicz return rndis_reset_response(params, 84000a2430fSAndrzej Pietrasiewicz (rndis_reset_msg_type *)buf); 84100a2430fSAndrzej Pietrasiewicz 84200a2430fSAndrzej Pietrasiewicz case RNDIS_MSG_KEEPALIVE: 84300a2430fSAndrzej Pietrasiewicz /* For USB: host does this every 5 seconds */ 84400a2430fSAndrzej Pietrasiewicz if (rndis_debug > 1) 84500a2430fSAndrzej Pietrasiewicz pr_debug("%s: RNDIS_MSG_KEEPALIVE\n", 84600a2430fSAndrzej Pietrasiewicz __func__); 84783210e59SAndrzej Pietrasiewicz return rndis_keepalive_response(params, 84800a2430fSAndrzej Pietrasiewicz (rndis_keepalive_msg_type *) 84900a2430fSAndrzej Pietrasiewicz buf); 85000a2430fSAndrzej Pietrasiewicz 85100a2430fSAndrzej Pietrasiewicz default: 85200a2430fSAndrzej Pietrasiewicz /* At least Windows XP emits some undefined RNDIS messages. 85300a2430fSAndrzej Pietrasiewicz * In one case those messages seemed to relate to the host 85400a2430fSAndrzej Pietrasiewicz * suspending itself. 85500a2430fSAndrzej Pietrasiewicz */ 8563f5ad864SJoe Perches pr_warn("%s: unknown RNDIS message 0x%08X len %d\n", 85700a2430fSAndrzej Pietrasiewicz __func__, MsgType, MsgLength); 8581ca532e9SMichel Pollet /* Garbled message can be huge, so limit what we display */ 8591ca532e9SMichel Pollet if (MsgLength > 16) 8601ca532e9SMichel Pollet MsgLength = 16; 86100a2430fSAndrzej Pietrasiewicz print_hex_dump_bytes(__func__, DUMP_PREFIX_OFFSET, 86200a2430fSAndrzej Pietrasiewicz buf, MsgLength); 86300a2430fSAndrzej Pietrasiewicz break; 86400a2430fSAndrzej Pietrasiewicz } 86500a2430fSAndrzej Pietrasiewicz 86600a2430fSAndrzej Pietrasiewicz return -ENOTSUPP; 86700a2430fSAndrzej Pietrasiewicz } 86800a2430fSAndrzej Pietrasiewicz EXPORT_SYMBOL_GPL(rndis_msg_parser); 86900a2430fSAndrzej Pietrasiewicz 870d6d22922SAndrzej Pietrasiewicz static inline int rndis_get_nr(void) 871d6d22922SAndrzej Pietrasiewicz { 872d6d22922SAndrzej Pietrasiewicz return ida_simple_get(&rndis_ida, 0, 0, GFP_KERNEL); 873d6d22922SAndrzej Pietrasiewicz } 874d6d22922SAndrzej Pietrasiewicz 875d6d22922SAndrzej Pietrasiewicz static inline void rndis_put_nr(int nr) 876d6d22922SAndrzej Pietrasiewicz { 877d6d22922SAndrzej Pietrasiewicz ida_simple_remove(&rndis_ida, nr); 878d6d22922SAndrzej Pietrasiewicz } 879d6d22922SAndrzej Pietrasiewicz 88083210e59SAndrzej Pietrasiewicz struct rndis_params *rndis_register(void (*resp_avail)(void *v), void *v) 88100a2430fSAndrzej Pietrasiewicz { 882d6d22922SAndrzej Pietrasiewicz struct rndis_params *params; 88381dff869SAndrzej Pietrasiewicz int i; 88400a2430fSAndrzej Pietrasiewicz 88500a2430fSAndrzej Pietrasiewicz if (!resp_avail) 88683210e59SAndrzej Pietrasiewicz return ERR_PTR(-EINVAL); 88700a2430fSAndrzej Pietrasiewicz 888d6d22922SAndrzej Pietrasiewicz i = rndis_get_nr(); 889d6d22922SAndrzej Pietrasiewicz if (i < 0) { 89000a2430fSAndrzej Pietrasiewicz pr_debug("failed\n"); 89100a2430fSAndrzej Pietrasiewicz 89283210e59SAndrzej Pietrasiewicz return ERR_PTR(-ENODEV); 89300a2430fSAndrzej Pietrasiewicz } 894d6d22922SAndrzej Pietrasiewicz 895d6d22922SAndrzej Pietrasiewicz params = kzalloc(sizeof(*params), GFP_KERNEL); 896d6d22922SAndrzej Pietrasiewicz if (!params) { 897d6d22922SAndrzej Pietrasiewicz rndis_put_nr(i); 898d6d22922SAndrzej Pietrasiewicz 899d6d22922SAndrzej Pietrasiewicz return ERR_PTR(-ENOMEM); 900d6d22922SAndrzej Pietrasiewicz } 901d6d22922SAndrzej Pietrasiewicz 902d6d22922SAndrzej Pietrasiewicz #ifdef CONFIG_USB_GADGET_DEBUG_FILES 903d6d22922SAndrzej Pietrasiewicz { 904d6d22922SAndrzej Pietrasiewicz struct proc_dir_entry *proc_entry; 905d6d22922SAndrzej Pietrasiewicz char name[20]; 906d6d22922SAndrzej Pietrasiewicz 907d6d22922SAndrzej Pietrasiewicz sprintf(name, NAME_TEMPLATE, i); 908d6d22922SAndrzej Pietrasiewicz proc_entry = proc_create_data(name, 0660, NULL, 90997a32539SAlexey Dobriyan &rndis_proc_ops, params); 910d6d22922SAndrzej Pietrasiewicz if (!proc_entry) { 911d6d22922SAndrzej Pietrasiewicz kfree(params); 912d6d22922SAndrzej Pietrasiewicz rndis_put_nr(i); 913d6d22922SAndrzej Pietrasiewicz 914d6d22922SAndrzej Pietrasiewicz return ERR_PTR(-EIO); 915d6d22922SAndrzej Pietrasiewicz } 916d6d22922SAndrzej Pietrasiewicz } 917d6d22922SAndrzej Pietrasiewicz #endif 918d6d22922SAndrzej Pietrasiewicz 919d6d22922SAndrzej Pietrasiewicz params->confignr = i; 920d6d22922SAndrzej Pietrasiewicz params->used = 1; 921d6d22922SAndrzej Pietrasiewicz params->state = RNDIS_UNINITIALIZED; 922d6d22922SAndrzej Pietrasiewicz params->media_state = RNDIS_MEDIA_STATE_DISCONNECTED; 923d6d22922SAndrzej Pietrasiewicz params->resp_avail = resp_avail; 924d6d22922SAndrzej Pietrasiewicz params->v = v; 925f6281af9SGeliang Tang INIT_LIST_HEAD(¶ms->resp_queue); 926aaaba1c8SDaehwan Jung spin_lock_init(¶ms->resp_lock); 927d6d22922SAndrzej Pietrasiewicz pr_debug("%s: configNr = %d\n", __func__, i); 928d6d22922SAndrzej Pietrasiewicz 929d6d22922SAndrzej Pietrasiewicz return params; 930d6d22922SAndrzej Pietrasiewicz } 93100a2430fSAndrzej Pietrasiewicz EXPORT_SYMBOL_GPL(rndis_register); 93200a2430fSAndrzej Pietrasiewicz 93383210e59SAndrzej Pietrasiewicz void rndis_deregister(struct rndis_params *params) 93400a2430fSAndrzej Pietrasiewicz { 93581dff869SAndrzej Pietrasiewicz int i; 936d6d22922SAndrzej Pietrasiewicz 93700a2430fSAndrzej Pietrasiewicz pr_debug("%s:\n", __func__); 93800a2430fSAndrzej Pietrasiewicz 93983210e59SAndrzej Pietrasiewicz if (!params) 94083210e59SAndrzej Pietrasiewicz return; 941d6d22922SAndrzej Pietrasiewicz 942d6d22922SAndrzej Pietrasiewicz i = params->confignr; 943d6d22922SAndrzej Pietrasiewicz 944d6d22922SAndrzej Pietrasiewicz #ifdef CONFIG_USB_GADGET_DEBUG_FILES 945d6d22922SAndrzej Pietrasiewicz { 946d6d22922SAndrzej Pietrasiewicz char name[20]; 947d6d22922SAndrzej Pietrasiewicz 948d6d22922SAndrzej Pietrasiewicz sprintf(name, NAME_TEMPLATE, i); 949d6d22922SAndrzej Pietrasiewicz remove_proc_entry(name, NULL); 950d6d22922SAndrzej Pietrasiewicz } 951d6d22922SAndrzej Pietrasiewicz #endif 952d6d22922SAndrzej Pietrasiewicz 953d6d22922SAndrzej Pietrasiewicz kfree(params); 954d6d22922SAndrzej Pietrasiewicz rndis_put_nr(i); 95500a2430fSAndrzej Pietrasiewicz } 95600a2430fSAndrzej Pietrasiewicz EXPORT_SYMBOL_GPL(rndis_deregister); 95783210e59SAndrzej Pietrasiewicz int rndis_set_param_dev(struct rndis_params *params, struct net_device *dev, 95883210e59SAndrzej Pietrasiewicz u16 *cdc_filter) 95900a2430fSAndrzej Pietrasiewicz { 96000a2430fSAndrzej Pietrasiewicz pr_debug("%s:\n", __func__); 96100a2430fSAndrzej Pietrasiewicz if (!dev) 96200a2430fSAndrzej Pietrasiewicz return -EINVAL; 96383210e59SAndrzej Pietrasiewicz if (!params) 96483210e59SAndrzej Pietrasiewicz return -1; 96500a2430fSAndrzej Pietrasiewicz 96683210e59SAndrzej Pietrasiewicz params->dev = dev; 96783210e59SAndrzej Pietrasiewicz params->filter = cdc_filter; 96800a2430fSAndrzej Pietrasiewicz 96900a2430fSAndrzej Pietrasiewicz return 0; 97000a2430fSAndrzej Pietrasiewicz } 97100a2430fSAndrzej Pietrasiewicz EXPORT_SYMBOL_GPL(rndis_set_param_dev); 97200a2430fSAndrzej Pietrasiewicz 97383210e59SAndrzej Pietrasiewicz int rndis_set_param_vendor(struct rndis_params *params, u32 vendorID, 97483210e59SAndrzej Pietrasiewicz const char *vendorDescr) 97500a2430fSAndrzej Pietrasiewicz { 97600a2430fSAndrzej Pietrasiewicz pr_debug("%s:\n", __func__); 97700a2430fSAndrzej Pietrasiewicz if (!vendorDescr) return -1; 97883210e59SAndrzej Pietrasiewicz if (!params) 97983210e59SAndrzej Pietrasiewicz return -1; 98000a2430fSAndrzej Pietrasiewicz 98183210e59SAndrzej Pietrasiewicz params->vendorID = vendorID; 98283210e59SAndrzej Pietrasiewicz params->vendorDescr = vendorDescr; 98300a2430fSAndrzej Pietrasiewicz 98400a2430fSAndrzej Pietrasiewicz return 0; 98500a2430fSAndrzej Pietrasiewicz } 98600a2430fSAndrzej Pietrasiewicz EXPORT_SYMBOL_GPL(rndis_set_param_vendor); 98700a2430fSAndrzej Pietrasiewicz 98883210e59SAndrzej Pietrasiewicz int rndis_set_param_medium(struct rndis_params *params, u32 medium, u32 speed) 98900a2430fSAndrzej Pietrasiewicz { 99000a2430fSAndrzej Pietrasiewicz pr_debug("%s: %u %u\n", __func__, medium, speed); 99183210e59SAndrzej Pietrasiewicz if (!params) 99283210e59SAndrzej Pietrasiewicz return -1; 99300a2430fSAndrzej Pietrasiewicz 99483210e59SAndrzej Pietrasiewicz params->medium = medium; 99583210e59SAndrzej Pietrasiewicz params->speed = speed; 99600a2430fSAndrzej Pietrasiewicz 99700a2430fSAndrzej Pietrasiewicz return 0; 99800a2430fSAndrzej Pietrasiewicz } 99900a2430fSAndrzej Pietrasiewicz EXPORT_SYMBOL_GPL(rndis_set_param_medium); 100000a2430fSAndrzej Pietrasiewicz 100100a2430fSAndrzej Pietrasiewicz void rndis_add_hdr(struct sk_buff *skb) 100200a2430fSAndrzej Pietrasiewicz { 100300a2430fSAndrzej Pietrasiewicz struct rndis_packet_msg_type *header; 100400a2430fSAndrzej Pietrasiewicz 100500a2430fSAndrzej Pietrasiewicz if (!skb) 100600a2430fSAndrzej Pietrasiewicz return; 1007d58ff351SJohannes Berg header = skb_push(skb, sizeof(*header)); 100800a2430fSAndrzej Pietrasiewicz memset(header, 0, sizeof *header); 100900a2430fSAndrzej Pietrasiewicz header->MessageType = cpu_to_le32(RNDIS_MSG_PACKET); 101000a2430fSAndrzej Pietrasiewicz header->MessageLength = cpu_to_le32(skb->len); 101100a2430fSAndrzej Pietrasiewicz header->DataOffset = cpu_to_le32(36); 101200a2430fSAndrzej Pietrasiewicz header->DataLength = cpu_to_le32(skb->len - sizeof(*header)); 101300a2430fSAndrzej Pietrasiewicz } 101400a2430fSAndrzej Pietrasiewicz EXPORT_SYMBOL_GPL(rndis_add_hdr); 101500a2430fSAndrzej Pietrasiewicz 101683210e59SAndrzej Pietrasiewicz void rndis_free_response(struct rndis_params *params, u8 *buf) 101700a2430fSAndrzej Pietrasiewicz { 1018f6281af9SGeliang Tang rndis_resp_t *r, *n; 101900a2430fSAndrzej Pietrasiewicz 1020aaaba1c8SDaehwan Jung spin_lock(¶ms->resp_lock); 1021f6281af9SGeliang Tang list_for_each_entry_safe(r, n, ¶ms->resp_queue, list) { 10221c17a353SJulia Lawall if (r->buf == buf) { 102300a2430fSAndrzej Pietrasiewicz list_del(&r->list); 102400a2430fSAndrzej Pietrasiewicz kfree(r); 102500a2430fSAndrzej Pietrasiewicz } 102600a2430fSAndrzej Pietrasiewicz } 1027aaaba1c8SDaehwan Jung spin_unlock(¶ms->resp_lock); 102800a2430fSAndrzej Pietrasiewicz } 102900a2430fSAndrzej Pietrasiewicz EXPORT_SYMBOL_GPL(rndis_free_response); 103000a2430fSAndrzej Pietrasiewicz 103183210e59SAndrzej Pietrasiewicz u8 *rndis_get_next_response(struct rndis_params *params, u32 *length) 103200a2430fSAndrzej Pietrasiewicz { 1033f6281af9SGeliang Tang rndis_resp_t *r, *n; 103400a2430fSAndrzej Pietrasiewicz 103500a2430fSAndrzej Pietrasiewicz if (!length) return NULL; 103600a2430fSAndrzej Pietrasiewicz 1037aaaba1c8SDaehwan Jung spin_lock(¶ms->resp_lock); 1038f6281af9SGeliang Tang list_for_each_entry_safe(r, n, ¶ms->resp_queue, list) { 103900a2430fSAndrzej Pietrasiewicz if (!r->send) { 104000a2430fSAndrzej Pietrasiewicz r->send = 1; 104100a2430fSAndrzej Pietrasiewicz *length = r->length; 1042aaaba1c8SDaehwan Jung spin_unlock(¶ms->resp_lock); 104300a2430fSAndrzej Pietrasiewicz return r->buf; 104400a2430fSAndrzej Pietrasiewicz } 104500a2430fSAndrzej Pietrasiewicz } 104600a2430fSAndrzej Pietrasiewicz 1047aaaba1c8SDaehwan Jung spin_unlock(¶ms->resp_lock); 104800a2430fSAndrzej Pietrasiewicz return NULL; 104900a2430fSAndrzej Pietrasiewicz } 105000a2430fSAndrzej Pietrasiewicz EXPORT_SYMBOL_GPL(rndis_get_next_response); 105100a2430fSAndrzej Pietrasiewicz 105283210e59SAndrzej Pietrasiewicz static rndis_resp_t *rndis_add_response(struct rndis_params *params, u32 length) 105300a2430fSAndrzej Pietrasiewicz { 105400a2430fSAndrzej Pietrasiewicz rndis_resp_t *r; 105500a2430fSAndrzej Pietrasiewicz 105600a2430fSAndrzej Pietrasiewicz /* NOTE: this gets copied into ether.c USB_BUFSIZ bytes ... */ 105700a2430fSAndrzej Pietrasiewicz r = kmalloc(sizeof(rndis_resp_t) + length, GFP_ATOMIC); 105800a2430fSAndrzej Pietrasiewicz if (!r) return NULL; 105900a2430fSAndrzej Pietrasiewicz 106000a2430fSAndrzej Pietrasiewicz r->buf = (u8 *)(r + 1); 106100a2430fSAndrzej Pietrasiewicz r->length = length; 106200a2430fSAndrzej Pietrasiewicz r->send = 0; 106300a2430fSAndrzej Pietrasiewicz 1064aaaba1c8SDaehwan Jung spin_lock(¶ms->resp_lock); 1065f6281af9SGeliang Tang list_add_tail(&r->list, ¶ms->resp_queue); 1066aaaba1c8SDaehwan Jung spin_unlock(¶ms->resp_lock); 106700a2430fSAndrzej Pietrasiewicz return r; 106800a2430fSAndrzej Pietrasiewicz } 106900a2430fSAndrzej Pietrasiewicz 107000a2430fSAndrzej Pietrasiewicz int rndis_rm_hdr(struct gether *port, 107100a2430fSAndrzej Pietrasiewicz struct sk_buff *skb, 107200a2430fSAndrzej Pietrasiewicz struct sk_buff_head *list) 107300a2430fSAndrzej Pietrasiewicz { 107400a2430fSAndrzej Pietrasiewicz /* tmp points to a struct rndis_packet_msg_type */ 107500a2430fSAndrzej Pietrasiewicz __le32 *tmp = (void *)skb->data; 107600a2430fSAndrzej Pietrasiewicz 107700a2430fSAndrzej Pietrasiewicz /* MessageType, MessageLength */ 107800a2430fSAndrzej Pietrasiewicz if (cpu_to_le32(RNDIS_MSG_PACKET) 107900a2430fSAndrzej Pietrasiewicz != get_unaligned(tmp++)) { 108000a2430fSAndrzej Pietrasiewicz dev_kfree_skb_any(skb); 108100a2430fSAndrzej Pietrasiewicz return -EINVAL; 108200a2430fSAndrzej Pietrasiewicz } 108300a2430fSAndrzej Pietrasiewicz tmp++; 108400a2430fSAndrzej Pietrasiewicz 108500a2430fSAndrzej Pietrasiewicz /* DataOffset, DataLength */ 108600a2430fSAndrzej Pietrasiewicz if (!skb_pull(skb, get_unaligned_le32(tmp++) + 8)) { 108700a2430fSAndrzej Pietrasiewicz dev_kfree_skb_any(skb); 108800a2430fSAndrzej Pietrasiewicz return -EOVERFLOW; 108900a2430fSAndrzej Pietrasiewicz } 109000a2430fSAndrzej Pietrasiewicz skb_trim(skb, get_unaligned_le32(tmp++)); 109100a2430fSAndrzej Pietrasiewicz 109200a2430fSAndrzej Pietrasiewicz skb_queue_tail(list, skb); 109300a2430fSAndrzej Pietrasiewicz return 0; 109400a2430fSAndrzej Pietrasiewicz } 109500a2430fSAndrzej Pietrasiewicz EXPORT_SYMBOL_GPL(rndis_rm_hdr); 109600a2430fSAndrzej Pietrasiewicz 109700a2430fSAndrzej Pietrasiewicz #ifdef CONFIG_USB_GADGET_DEBUG_FILES 109800a2430fSAndrzej Pietrasiewicz 109900a2430fSAndrzej Pietrasiewicz static int rndis_proc_show(struct seq_file *m, void *v) 110000a2430fSAndrzej Pietrasiewicz { 110100a2430fSAndrzej Pietrasiewicz rndis_params *param = m->private; 110200a2430fSAndrzej Pietrasiewicz 110300a2430fSAndrzej Pietrasiewicz seq_printf(m, 110400a2430fSAndrzej Pietrasiewicz "Config Nr. %d\n" 110500a2430fSAndrzej Pietrasiewicz "used : %s\n" 110600a2430fSAndrzej Pietrasiewicz "state : %s\n" 110700a2430fSAndrzej Pietrasiewicz "medium : 0x%08X\n" 110800a2430fSAndrzej Pietrasiewicz "speed : %d\n" 110900a2430fSAndrzej Pietrasiewicz "cable : %s\n" 111000a2430fSAndrzej Pietrasiewicz "vendor ID : 0x%08X\n" 111100a2430fSAndrzej Pietrasiewicz "vendor : %s\n", 111200a2430fSAndrzej Pietrasiewicz param->confignr, (param->used) ? "y" : "n", 111300a2430fSAndrzej Pietrasiewicz ({ char *s = "?"; 111400a2430fSAndrzej Pietrasiewicz switch (param->state) { 111500a2430fSAndrzej Pietrasiewicz case RNDIS_UNINITIALIZED: 111600a2430fSAndrzej Pietrasiewicz s = "RNDIS_UNINITIALIZED"; break; 111700a2430fSAndrzej Pietrasiewicz case RNDIS_INITIALIZED: 111800a2430fSAndrzej Pietrasiewicz s = "RNDIS_INITIALIZED"; break; 111900a2430fSAndrzej Pietrasiewicz case RNDIS_DATA_INITIALIZED: 112000a2430fSAndrzej Pietrasiewicz s = "RNDIS_DATA_INITIALIZED"; break; 112100a2430fSAndrzej Pietrasiewicz } s; }), 112200a2430fSAndrzej Pietrasiewicz param->medium, 112300a2430fSAndrzej Pietrasiewicz (param->media_state) ? 0 : param->speed*100, 112400a2430fSAndrzej Pietrasiewicz (param->media_state) ? "disconnected" : "connected", 112500a2430fSAndrzej Pietrasiewicz param->vendorID, param->vendorDescr); 112600a2430fSAndrzej Pietrasiewicz return 0; 112700a2430fSAndrzej Pietrasiewicz } 112800a2430fSAndrzej Pietrasiewicz 112900a2430fSAndrzej Pietrasiewicz static ssize_t rndis_proc_write(struct file *file, const char __user *buffer, 113000a2430fSAndrzej Pietrasiewicz size_t count, loff_t *ppos) 113100a2430fSAndrzej Pietrasiewicz { 1132359745d7SMuchun Song rndis_params *p = pde_data(file_inode(file)); 113300a2430fSAndrzej Pietrasiewicz u32 speed = 0; 113400a2430fSAndrzej Pietrasiewicz int i, fl_speed = 0; 113500a2430fSAndrzej Pietrasiewicz 113600a2430fSAndrzej Pietrasiewicz for (i = 0; i < count; i++) { 113700a2430fSAndrzej Pietrasiewicz char c; 113800a2430fSAndrzej Pietrasiewicz if (get_user(c, buffer)) 113900a2430fSAndrzej Pietrasiewicz return -EFAULT; 114000a2430fSAndrzej Pietrasiewicz switch (c) { 114100a2430fSAndrzej Pietrasiewicz case '0': 114200a2430fSAndrzej Pietrasiewicz case '1': 114300a2430fSAndrzej Pietrasiewicz case '2': 114400a2430fSAndrzej Pietrasiewicz case '3': 114500a2430fSAndrzej Pietrasiewicz case '4': 114600a2430fSAndrzej Pietrasiewicz case '5': 114700a2430fSAndrzej Pietrasiewicz case '6': 114800a2430fSAndrzej Pietrasiewicz case '7': 114900a2430fSAndrzej Pietrasiewicz case '8': 115000a2430fSAndrzej Pietrasiewicz case '9': 115100a2430fSAndrzej Pietrasiewicz fl_speed = 1; 115200a2430fSAndrzej Pietrasiewicz speed = speed * 10 + c - '0'; 115300a2430fSAndrzej Pietrasiewicz break; 115400a2430fSAndrzej Pietrasiewicz case 'C': 115500a2430fSAndrzej Pietrasiewicz case 'c': 1156868055fdSAndrzej Pietrasiewicz rndis_signal_connect(p); 115700a2430fSAndrzej Pietrasiewicz break; 115800a2430fSAndrzej Pietrasiewicz case 'D': 115900a2430fSAndrzej Pietrasiewicz case 'd': 1160868055fdSAndrzej Pietrasiewicz rndis_signal_disconnect(p); 116100a2430fSAndrzej Pietrasiewicz break; 116200a2430fSAndrzej Pietrasiewicz default: 116300a2430fSAndrzej Pietrasiewicz if (fl_speed) p->speed = speed; 116400a2430fSAndrzej Pietrasiewicz else pr_debug("%c is not valid\n", c); 116500a2430fSAndrzej Pietrasiewicz break; 116600a2430fSAndrzej Pietrasiewicz } 116700a2430fSAndrzej Pietrasiewicz 116800a2430fSAndrzej Pietrasiewicz buffer++; 116900a2430fSAndrzej Pietrasiewicz } 117000a2430fSAndrzej Pietrasiewicz 117100a2430fSAndrzej Pietrasiewicz return count; 117200a2430fSAndrzej Pietrasiewicz } 117300a2430fSAndrzej Pietrasiewicz 117400a2430fSAndrzej Pietrasiewicz static int rndis_proc_open(struct inode *inode, struct file *file) 117500a2430fSAndrzej Pietrasiewicz { 1176359745d7SMuchun Song return single_open(file, rndis_proc_show, pde_data(inode)); 117700a2430fSAndrzej Pietrasiewicz } 117800a2430fSAndrzej Pietrasiewicz 117997a32539SAlexey Dobriyan static const struct proc_ops rndis_proc_ops = { 118097a32539SAlexey Dobriyan .proc_open = rndis_proc_open, 118197a32539SAlexey Dobriyan .proc_read = seq_read, 118297a32539SAlexey Dobriyan .proc_lseek = seq_lseek, 118397a32539SAlexey Dobriyan .proc_release = single_release, 118497a32539SAlexey Dobriyan .proc_write = rndis_proc_write, 118500a2430fSAndrzej Pietrasiewicz }; 118600a2430fSAndrzej Pietrasiewicz 118700a2430fSAndrzej Pietrasiewicz #define NAME_TEMPLATE "driver/rndis-%03d" 118800a2430fSAndrzej Pietrasiewicz 118900a2430fSAndrzej Pietrasiewicz #endif /* CONFIG_USB_GADGET_DEBUG_FILES */ 1190