David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * RNDIS MSG parser |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 3 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * Version: $Id: rndis.c,v 1.19 2004/03/25 21:33:46 robert Exp $ |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 5 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * Authors: Benedikt Spranger, Pengutronix |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 7 | * Robert Schwebel, Pengutronix |
| 8 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 11 | * version 2, as published by the Free Software Foundation. |
| 12 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * This software was originally developed in conformance with |
| 14 | * Microsoft's Remote NDIS Specification License Agreement. |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 15 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | * 03/12/2004 Kai-Uwe Bloem <linux-development@auerswald.de> |
| 17 | * Fixed message length bug in init_response |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 18 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | * 03/25/2004 Kai-Uwe Bloem <linux-development@auerswald.de> |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 20 | * Fixed rndis_rm_hdr length bug. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | * |
| 22 | * Copyright (C) 2004 by David Brownell |
| 23 | * updates to merge with Linux 2.6, better match RNDIS spec |
| 24 | */ |
| 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <linux/module.h> |
| 27 | #include <linux/moduleparam.h> |
| 28 | #include <linux/kernel.h> |
| 29 | #include <linux/errno.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #include <linux/init.h> |
| 31 | #include <linux/list.h> |
| 32 | #include <linux/proc_fs.h> |
| 33 | #include <linux/netdevice.h> |
| 34 | |
| 35 | #include <asm/io.h> |
| 36 | #include <asm/byteorder.h> |
| 37 | #include <asm/system.h> |
David Brownell | 6cdee10 | 2005-04-18 17:39:34 -0700 | [diff] [blame] | 38 | #include <asm/unaligned.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
| 40 | |
| 41 | #undef RNDIS_PM |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 42 | #undef RNDIS_WAKEUP |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | #undef VERBOSE |
| 44 | |
| 45 | #include "rndis.h" |
| 46 | |
| 47 | |
| 48 | /* The driver for your USB chip needs to support ep0 OUT to work with |
| 49 | * RNDIS, plus all three CDC Ethernet endpoints (interrupt not optional). |
| 50 | * |
| 51 | * Windows hosts need an INF file like Documentation/usb/linux.inf |
| 52 | * and will be happier if you provide the host_addr module parameter. |
| 53 | */ |
| 54 | |
| 55 | #if 0 |
| 56 | #define DEBUG(str,args...) do { \ |
| 57 | if (rndis_debug) \ |
| 58 | printk(KERN_DEBUG str , ## args ); \ |
| 59 | } while (0) |
| 60 | static int rndis_debug = 0; |
| 61 | |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 62 | module_param (rndis_debug, int, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | MODULE_PARM_DESC (rndis_debug, "enable debugging"); |
| 64 | |
| 65 | #else |
| 66 | |
| 67 | #define rndis_debug 0 |
| 68 | #define DEBUG(str,args...) do{}while(0) |
| 69 | #endif |
| 70 | |
| 71 | #define RNDIS_MAX_CONFIGS 1 |
| 72 | |
| 73 | |
| 74 | static rndis_params rndis_per_dev_params [RNDIS_MAX_CONFIGS]; |
| 75 | |
| 76 | /* Driver Version */ |
| 77 | static const __le32 rndis_driver_version = __constant_cpu_to_le32 (1); |
| 78 | |
| 79 | /* Function Prototypes */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | static rndis_resp_t *rndis_add_response (int configNr, u32 length); |
| 81 | |
| 82 | |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 83 | /* supported OIDs */ |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 84 | static const u32 oid_supported_list [] = |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 85 | { |
| 86 | /* the general stuff */ |
| 87 | OID_GEN_SUPPORTED_LIST, |
| 88 | OID_GEN_HARDWARE_STATUS, |
| 89 | OID_GEN_MEDIA_SUPPORTED, |
| 90 | OID_GEN_MEDIA_IN_USE, |
| 91 | OID_GEN_MAXIMUM_FRAME_SIZE, |
| 92 | OID_GEN_LINK_SPEED, |
| 93 | OID_GEN_TRANSMIT_BLOCK_SIZE, |
| 94 | OID_GEN_RECEIVE_BLOCK_SIZE, |
| 95 | OID_GEN_VENDOR_ID, |
| 96 | OID_GEN_VENDOR_DESCRIPTION, |
| 97 | OID_GEN_VENDOR_DRIVER_VERSION, |
| 98 | OID_GEN_CURRENT_PACKET_FILTER, |
| 99 | OID_GEN_MAXIMUM_TOTAL_SIZE, |
| 100 | OID_GEN_MEDIA_CONNECT_STATUS, |
| 101 | OID_GEN_PHYSICAL_MEDIUM, |
| 102 | #if 0 |
| 103 | OID_GEN_RNDIS_CONFIG_PARAMETER, |
| 104 | #endif |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 105 | |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 106 | /* the statistical stuff */ |
| 107 | OID_GEN_XMIT_OK, |
| 108 | OID_GEN_RCV_OK, |
| 109 | OID_GEN_XMIT_ERROR, |
| 110 | OID_GEN_RCV_ERROR, |
| 111 | OID_GEN_RCV_NO_BUFFER, |
| 112 | #ifdef RNDIS_OPTIONAL_STATS |
| 113 | OID_GEN_DIRECTED_BYTES_XMIT, |
| 114 | OID_GEN_DIRECTED_FRAMES_XMIT, |
| 115 | OID_GEN_MULTICAST_BYTES_XMIT, |
| 116 | OID_GEN_MULTICAST_FRAMES_XMIT, |
| 117 | OID_GEN_BROADCAST_BYTES_XMIT, |
| 118 | OID_GEN_BROADCAST_FRAMES_XMIT, |
| 119 | OID_GEN_DIRECTED_BYTES_RCV, |
| 120 | OID_GEN_DIRECTED_FRAMES_RCV, |
| 121 | OID_GEN_MULTICAST_BYTES_RCV, |
| 122 | OID_GEN_MULTICAST_FRAMES_RCV, |
| 123 | OID_GEN_BROADCAST_BYTES_RCV, |
| 124 | OID_GEN_BROADCAST_FRAMES_RCV, |
| 125 | OID_GEN_RCV_CRC_ERROR, |
| 126 | OID_GEN_TRANSMIT_QUEUE_LENGTH, |
| 127 | #endif /* RNDIS_OPTIONAL_STATS */ |
| 128 | |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 129 | /* mandatory 802.3 */ |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 130 | /* the general stuff */ |
| 131 | OID_802_3_PERMANENT_ADDRESS, |
| 132 | OID_802_3_CURRENT_ADDRESS, |
| 133 | OID_802_3_MULTICAST_LIST, |
| 134 | OID_802_3_MAC_OPTIONS, |
| 135 | OID_802_3_MAXIMUM_LIST_SIZE, |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 136 | |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 137 | /* the statistical stuff */ |
| 138 | OID_802_3_RCV_ERROR_ALIGNMENT, |
| 139 | OID_802_3_XMIT_ONE_COLLISION, |
| 140 | OID_802_3_XMIT_MORE_COLLISIONS, |
| 141 | #ifdef RNDIS_OPTIONAL_STATS |
| 142 | OID_802_3_XMIT_DEFERRED, |
| 143 | OID_802_3_XMIT_MAX_COLLISIONS, |
| 144 | OID_802_3_RCV_OVERRUN, |
| 145 | OID_802_3_XMIT_UNDERRUN, |
| 146 | OID_802_3_XMIT_HEARTBEAT_FAILURE, |
| 147 | OID_802_3_XMIT_TIMES_CRS_LOST, |
| 148 | OID_802_3_XMIT_LATE_COLLISIONS, |
| 149 | #endif /* RNDIS_OPTIONAL_STATS */ |
| 150 | |
| 151 | #ifdef RNDIS_PM |
| 152 | /* PM and wakeup are mandatory for USB: */ |
| 153 | |
| 154 | /* power management */ |
| 155 | OID_PNP_CAPABILITIES, |
| 156 | OID_PNP_QUERY_POWER, |
| 157 | OID_PNP_SET_POWER, |
| 158 | |
| 159 | #ifdef RNDIS_WAKEUP |
| 160 | /* wake up host */ |
| 161 | OID_PNP_ENABLE_WAKE_UP, |
| 162 | OID_PNP_ADD_WAKE_UP_PATTERN, |
| 163 | OID_PNP_REMOVE_WAKE_UP_PATTERN, |
| 164 | #endif /* RNDIS_WAKEUP */ |
| 165 | #endif /* RNDIS_PM */ |
| 166 | }; |
| 167 | |
| 168 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | /* NDIS Functions */ |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 170 | static int |
| 171 | gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, |
| 172 | rndis_resp_t *r) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | { |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 174 | int retval = -ENOTSUPP; |
| 175 | u32 length = 4; /* usually */ |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 176 | __le32 *outbuf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | int i, count; |
| 178 | rndis_query_cmplt_type *resp; |
| 179 | |
| 180 | if (!r) return -ENOMEM; |
| 181 | resp = (rndis_query_cmplt_type *) r->buf; |
| 182 | |
| 183 | if (!resp) return -ENOMEM; |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 184 | |
| 185 | if (buf_len && rndis_debug > 1) { |
| 186 | DEBUG("query OID %08x value, len %d:\n", OID, buf_len); |
| 187 | for (i = 0; i < buf_len; i += 16) { |
| 188 | DEBUG ("%03d: %08x %08x %08x %08x\n", i, |
David Brownell | 01ee7d7 | 2007-05-25 20:40:14 -0700 | [diff] [blame] | 189 | le32_to_cpu(get_unaligned((__le32 *) |
| 190 | &buf[i])), |
| 191 | le32_to_cpu(get_unaligned((__le32 *) |
| 192 | &buf[i + 4])), |
| 193 | le32_to_cpu(get_unaligned((__le32 *) |
| 194 | &buf[i + 8])), |
| 195 | le32_to_cpu(get_unaligned((__le32 *) |
| 196 | &buf[i + 12]))); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 197 | } |
| 198 | } |
| 199 | |
| 200 | /* response goes here, right after the header */ |
| 201 | outbuf = (__le32 *) &resp[1]; |
| 202 | resp->InformationBufferOffset = __constant_cpu_to_le32 (16); |
| 203 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | switch (OID) { |
| 205 | |
| 206 | /* general oids (table 4-1) */ |
| 207 | |
| 208 | /* mandatory */ |
| 209 | case OID_GEN_SUPPORTED_LIST: |
| 210 | DEBUG ("%s: OID_GEN_SUPPORTED_LIST\n", __FUNCTION__); |
| 211 | length = sizeof (oid_supported_list); |
| 212 | count = length / sizeof (u32); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | for (i = 0; i < count; i++) |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 214 | outbuf[i] = cpu_to_le32 (oid_supported_list[i]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | retval = 0; |
| 216 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 217 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | /* mandatory */ |
| 219 | case OID_GEN_HARDWARE_STATUS: |
| 220 | DEBUG("%s: OID_GEN_HARDWARE_STATUS\n", __FUNCTION__); |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 221 | /* Bogus question! |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | * Hardware must be ready to receive high level protocols. |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 223 | * BTW: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | * reddite ergo quae sunt Caesaris Caesari |
| 225 | * et quae sunt Dei Deo! |
| 226 | */ |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 227 | *outbuf = __constant_cpu_to_le32 (0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | retval = 0; |
| 229 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 230 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | /* mandatory */ |
| 232 | case OID_GEN_MEDIA_SUPPORTED: |
| 233 | DEBUG("%s: OID_GEN_MEDIA_SUPPORTED\n", __FUNCTION__); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 234 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | retval = 0; |
| 236 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 237 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | /* mandatory */ |
| 239 | case OID_GEN_MEDIA_IN_USE: |
| 240 | DEBUG("%s: OID_GEN_MEDIA_IN_USE\n", __FUNCTION__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | /* one medium, one transport... (maybe you do it better) */ |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 242 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | retval = 0; |
| 244 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 245 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | /* mandatory */ |
| 247 | case OID_GEN_MAXIMUM_FRAME_SIZE: |
| 248 | DEBUG("%s: OID_GEN_MAXIMUM_FRAME_SIZE\n", __FUNCTION__); |
| 249 | if (rndis_per_dev_params [configNr].dev) { |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 250 | *outbuf = cpu_to_le32 ( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | rndis_per_dev_params [configNr].dev->mtu); |
| 252 | retval = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | } |
| 254 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 255 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | /* mandatory */ |
| 257 | case OID_GEN_LINK_SPEED: |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 258 | if (rndis_debug > 1) |
| 259 | DEBUG("%s: OID_GEN_LINK_SPEED\n", __FUNCTION__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | if (rndis_per_dev_params [configNr].media_state |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 261 | == NDIS_MEDIA_STATE_DISCONNECTED) |
| 262 | *outbuf = __constant_cpu_to_le32 (0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | else |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 264 | *outbuf = cpu_to_le32 ( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | rndis_per_dev_params [configNr].speed); |
| 266 | retval = 0; |
| 267 | break; |
| 268 | |
| 269 | /* mandatory */ |
| 270 | case OID_GEN_TRANSMIT_BLOCK_SIZE: |
| 271 | DEBUG("%s: OID_GEN_TRANSMIT_BLOCK_SIZE\n", __FUNCTION__); |
| 272 | if (rndis_per_dev_params [configNr].dev) { |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 273 | *outbuf = cpu_to_le32 ( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | rndis_per_dev_params [configNr].dev->mtu); |
| 275 | retval = 0; |
| 276 | } |
| 277 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 278 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | /* mandatory */ |
| 280 | case OID_GEN_RECEIVE_BLOCK_SIZE: |
| 281 | DEBUG("%s: OID_GEN_RECEIVE_BLOCK_SIZE\n", __FUNCTION__); |
| 282 | if (rndis_per_dev_params [configNr].dev) { |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 283 | *outbuf = cpu_to_le32 ( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | rndis_per_dev_params [configNr].dev->mtu); |
| 285 | retval = 0; |
| 286 | } |
| 287 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 288 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | /* mandatory */ |
| 290 | case OID_GEN_VENDOR_ID: |
| 291 | DEBUG("%s: OID_GEN_VENDOR_ID\n", __FUNCTION__); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 292 | *outbuf = cpu_to_le32 ( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | rndis_per_dev_params [configNr].vendorID); |
| 294 | retval = 0; |
| 295 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 296 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | /* mandatory */ |
| 298 | case OID_GEN_VENDOR_DESCRIPTION: |
| 299 | DEBUG("%s: OID_GEN_VENDOR_DESCRIPTION\n", __FUNCTION__); |
| 300 | length = strlen (rndis_per_dev_params [configNr].vendorDescr); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 301 | memcpy (outbuf, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | rndis_per_dev_params [configNr].vendorDescr, length); |
| 303 | retval = 0; |
| 304 | break; |
| 305 | |
| 306 | case OID_GEN_VENDOR_DRIVER_VERSION: |
| 307 | DEBUG("%s: OID_GEN_VENDOR_DRIVER_VERSION\n", __FUNCTION__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | /* Created as LE */ |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 309 | *outbuf = rndis_driver_version; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | retval = 0; |
| 311 | break; |
| 312 | |
| 313 | /* mandatory */ |
| 314 | case OID_GEN_CURRENT_PACKET_FILTER: |
| 315 | DEBUG("%s: OID_GEN_CURRENT_PACKET_FILTER\n", __FUNCTION__); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 316 | *outbuf = cpu_to_le32 (*rndis_per_dev_params[configNr].filter); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | retval = 0; |
| 318 | break; |
| 319 | |
| 320 | /* mandatory */ |
| 321 | case OID_GEN_MAXIMUM_TOTAL_SIZE: |
| 322 | DEBUG("%s: OID_GEN_MAXIMUM_TOTAL_SIZE\n", __FUNCTION__); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 323 | *outbuf = __constant_cpu_to_le32(RNDIS_MAX_TOTAL_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | retval = 0; |
| 325 | break; |
| 326 | |
| 327 | /* mandatory */ |
| 328 | case OID_GEN_MEDIA_CONNECT_STATUS: |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 329 | if (rndis_debug > 1) |
| 330 | DEBUG("%s: OID_GEN_MEDIA_CONNECT_STATUS\n", __FUNCTION__); |
| 331 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | .media_state); |
| 333 | retval = 0; |
| 334 | break; |
| 335 | |
| 336 | case OID_GEN_PHYSICAL_MEDIUM: |
| 337 | DEBUG("%s: OID_GEN_PHYSICAL_MEDIUM\n", __FUNCTION__); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 338 | *outbuf = __constant_cpu_to_le32 (0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | retval = 0; |
| 340 | break; |
| 341 | |
| 342 | /* The RNDIS specification is incomplete/wrong. Some versions |
| 343 | * of MS-Windows expect OIDs that aren't specified there. Other |
| 344 | * versions emit undefined RNDIS messages. DOCUMENT ALL THESE! |
| 345 | */ |
| 346 | case OID_GEN_MAC_OPTIONS: /* from WinME */ |
| 347 | DEBUG("%s: OID_GEN_MAC_OPTIONS\n", __FUNCTION__); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 348 | *outbuf = __constant_cpu_to_le32( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | NDIS_MAC_OPTION_RECEIVE_SERIALIZED |
| 350 | | NDIS_MAC_OPTION_FULL_DUPLEX); |
| 351 | retval = 0; |
| 352 | break; |
| 353 | |
| 354 | /* statistics OIDs (table 4-2) */ |
| 355 | |
| 356 | /* mandatory */ |
| 357 | case OID_GEN_XMIT_OK: |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 358 | if (rndis_debug > 1) |
| 359 | DEBUG("%s: OID_GEN_XMIT_OK\n", __FUNCTION__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | if (rndis_per_dev_params [configNr].stats) { |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 361 | *outbuf = cpu_to_le32 ( |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 362 | rndis_per_dev_params [configNr].stats->tx_packets - |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | rndis_per_dev_params [configNr].stats->tx_errors - |
| 364 | rndis_per_dev_params [configNr].stats->tx_dropped); |
| 365 | retval = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | } |
| 367 | break; |
| 368 | |
| 369 | /* mandatory */ |
| 370 | case OID_GEN_RCV_OK: |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 371 | if (rndis_debug > 1) |
| 372 | DEBUG("%s: OID_GEN_RCV_OK\n", __FUNCTION__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | if (rndis_per_dev_params [configNr].stats) { |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 374 | *outbuf = cpu_to_le32 ( |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 375 | rndis_per_dev_params [configNr].stats->rx_packets - |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | rndis_per_dev_params [configNr].stats->rx_errors - |
| 377 | rndis_per_dev_params [configNr].stats->rx_dropped); |
| 378 | retval = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | } |
| 380 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 381 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 382 | /* mandatory */ |
| 383 | case OID_GEN_XMIT_ERROR: |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 384 | if (rndis_debug > 1) |
| 385 | DEBUG("%s: OID_GEN_XMIT_ERROR\n", __FUNCTION__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | if (rndis_per_dev_params [configNr].stats) { |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 387 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | .stats->tx_errors); |
| 389 | retval = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | } |
| 391 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 392 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | /* mandatory */ |
| 394 | case OID_GEN_RCV_ERROR: |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 395 | if (rndis_debug > 1) |
| 396 | DEBUG("%s: OID_GEN_RCV_ERROR\n", __FUNCTION__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | if (rndis_per_dev_params [configNr].stats) { |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 398 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | .stats->rx_errors); |
| 400 | retval = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | } |
| 402 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 403 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | /* mandatory */ |
| 405 | case OID_GEN_RCV_NO_BUFFER: |
| 406 | DEBUG("%s: OID_GEN_RCV_NO_BUFFER\n", __FUNCTION__); |
| 407 | if (rndis_per_dev_params [configNr].stats) { |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 408 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | .stats->rx_dropped); |
| 410 | retval = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | } |
| 412 | break; |
| 413 | |
| 414 | #ifdef RNDIS_OPTIONAL_STATS |
| 415 | case OID_GEN_DIRECTED_BYTES_XMIT: |
| 416 | DEBUG("%s: OID_GEN_DIRECTED_BYTES_XMIT\n", __FUNCTION__); |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 417 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | * Aunt Tilly's size of shoes |
| 419 | * minus antarctica count of penguins |
| 420 | * divided by weight of Alpha Centauri |
| 421 | */ |
| 422 | if (rndis_per_dev_params [configNr].stats) { |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 423 | *outbuf = cpu_to_le32 ( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | (rndis_per_dev_params [configNr] |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 425 | .stats->tx_packets - |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | rndis_per_dev_params [configNr] |
| 427 | .stats->tx_errors - |
| 428 | rndis_per_dev_params [configNr] |
| 429 | .stats->tx_dropped) |
| 430 | * 123); |
| 431 | retval = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | } |
| 433 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 434 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | case OID_GEN_DIRECTED_FRAMES_XMIT: |
| 436 | DEBUG("%s: OID_GEN_DIRECTED_FRAMES_XMIT\n", __FUNCTION__); |
| 437 | /* dito */ |
| 438 | if (rndis_per_dev_params [configNr].stats) { |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 439 | *outbuf = cpu_to_le32 ( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | (rndis_per_dev_params [configNr] |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 441 | .stats->tx_packets - |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | rndis_per_dev_params [configNr] |
| 443 | .stats->tx_errors - |
| 444 | rndis_per_dev_params [configNr] |
| 445 | .stats->tx_dropped) |
| 446 | / 123); |
| 447 | retval = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | } |
| 449 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 450 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | case OID_GEN_MULTICAST_BYTES_XMIT: |
| 452 | DEBUG("%s: OID_GEN_MULTICAST_BYTES_XMIT\n", __FUNCTION__); |
| 453 | if (rndis_per_dev_params [configNr].stats) { |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 454 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | .stats->multicast*1234); |
| 456 | retval = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | } |
| 458 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 459 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | case OID_GEN_MULTICAST_FRAMES_XMIT: |
| 461 | DEBUG("%s: OID_GEN_MULTICAST_FRAMES_XMIT\n", __FUNCTION__); |
| 462 | if (rndis_per_dev_params [configNr].stats) { |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 463 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | .stats->multicast); |
| 465 | retval = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | } |
| 467 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 468 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | case OID_GEN_BROADCAST_BYTES_XMIT: |
| 470 | DEBUG("%s: OID_GEN_BROADCAST_BYTES_XMIT\n", __FUNCTION__); |
| 471 | if (rndis_per_dev_params [configNr].stats) { |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 472 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | .stats->tx_packets/42*255); |
| 474 | retval = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | } |
| 476 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 477 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | case OID_GEN_BROADCAST_FRAMES_XMIT: |
| 479 | DEBUG("%s: OID_GEN_BROADCAST_FRAMES_XMIT\n", __FUNCTION__); |
| 480 | if (rndis_per_dev_params [configNr].stats) { |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 481 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | .stats->tx_packets/42); |
| 483 | retval = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | } |
| 485 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 486 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 | case OID_GEN_DIRECTED_BYTES_RCV: |
| 488 | DEBUG("%s: OID_GEN_DIRECTED_BYTES_RCV\n", __FUNCTION__); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 489 | *outbuf = __constant_cpu_to_le32 (0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | retval = 0; |
| 491 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 492 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | case OID_GEN_DIRECTED_FRAMES_RCV: |
| 494 | DEBUG("%s: OID_GEN_DIRECTED_FRAMES_RCV\n", __FUNCTION__); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 495 | *outbuf = __constant_cpu_to_le32 (0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | retval = 0; |
| 497 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 498 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | case OID_GEN_MULTICAST_BYTES_RCV: |
| 500 | DEBUG("%s: OID_GEN_MULTICAST_BYTES_RCV\n", __FUNCTION__); |
| 501 | if (rndis_per_dev_params [configNr].stats) { |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 502 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | .stats->multicast * 1111); |
| 504 | retval = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | } |
| 506 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 507 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | case OID_GEN_MULTICAST_FRAMES_RCV: |
| 509 | DEBUG("%s: OID_GEN_MULTICAST_FRAMES_RCV\n", __FUNCTION__); |
| 510 | if (rndis_per_dev_params [configNr].stats) { |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 511 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | .stats->multicast); |
| 513 | retval = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 514 | } |
| 515 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 516 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 517 | case OID_GEN_BROADCAST_BYTES_RCV: |
| 518 | DEBUG("%s: OID_GEN_BROADCAST_BYTES_RCV\n", __FUNCTION__); |
| 519 | if (rndis_per_dev_params [configNr].stats) { |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 520 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | .stats->rx_packets/42*255); |
| 522 | retval = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | } |
| 524 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 525 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | case OID_GEN_BROADCAST_FRAMES_RCV: |
| 527 | DEBUG("%s: OID_GEN_BROADCAST_FRAMES_RCV\n", __FUNCTION__); |
| 528 | if (rndis_per_dev_params [configNr].stats) { |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 529 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 530 | .stats->rx_packets/42); |
| 531 | retval = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 532 | } |
| 533 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 534 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | case OID_GEN_RCV_CRC_ERROR: |
| 536 | DEBUG("%s: OID_GEN_RCV_CRC_ERROR\n", __FUNCTION__); |
| 537 | if (rndis_per_dev_params [configNr].stats) { |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 538 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | .stats->rx_crc_errors); |
| 540 | retval = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | } |
| 542 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 543 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 544 | case OID_GEN_TRANSMIT_QUEUE_LENGTH: |
| 545 | DEBUG("%s: OID_GEN_TRANSMIT_QUEUE_LENGTH\n", __FUNCTION__); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 546 | *outbuf = __constant_cpu_to_le32 (0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | retval = 0; |
| 548 | break; |
| 549 | #endif /* RNDIS_OPTIONAL_STATS */ |
| 550 | |
| 551 | /* ieee802.3 OIDs (table 4-3) */ |
| 552 | |
| 553 | /* mandatory */ |
| 554 | case OID_802_3_PERMANENT_ADDRESS: |
| 555 | DEBUG("%s: OID_802_3_PERMANENT_ADDRESS\n", __FUNCTION__); |
| 556 | if (rndis_per_dev_params [configNr].dev) { |
| 557 | length = ETH_ALEN; |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 558 | memcpy (outbuf, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | rndis_per_dev_params [configNr].host_mac, |
| 560 | length); |
| 561 | retval = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | } |
| 563 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 564 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | /* mandatory */ |
| 566 | case OID_802_3_CURRENT_ADDRESS: |
| 567 | DEBUG("%s: OID_802_3_CURRENT_ADDRESS\n", __FUNCTION__); |
| 568 | if (rndis_per_dev_params [configNr].dev) { |
| 569 | length = ETH_ALEN; |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 570 | memcpy (outbuf, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | rndis_per_dev_params [configNr].host_mac, |
| 572 | length); |
| 573 | retval = 0; |
| 574 | } |
| 575 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 576 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | /* mandatory */ |
| 578 | case OID_802_3_MULTICAST_LIST: |
| 579 | DEBUG("%s: OID_802_3_MULTICAST_LIST\n", __FUNCTION__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | /* Multicast base address only */ |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 581 | *outbuf = __constant_cpu_to_le32 (0xE0000000); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 582 | retval = 0; |
| 583 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 584 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | /* mandatory */ |
| 586 | case OID_802_3_MAXIMUM_LIST_SIZE: |
| 587 | DEBUG("%s: OID_802_3_MAXIMUM_LIST_SIZE\n", __FUNCTION__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | /* Multicast base address only */ |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 589 | *outbuf = __constant_cpu_to_le32 (1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 590 | retval = 0; |
| 591 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 592 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | case OID_802_3_MAC_OPTIONS: |
| 594 | DEBUG("%s: OID_802_3_MAC_OPTIONS\n", __FUNCTION__); |
| 595 | break; |
| 596 | |
| 597 | /* ieee802.3 statistics OIDs (table 4-4) */ |
| 598 | |
| 599 | /* mandatory */ |
| 600 | case OID_802_3_RCV_ERROR_ALIGNMENT: |
| 601 | DEBUG("%s: OID_802_3_RCV_ERROR_ALIGNMENT\n", __FUNCTION__); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 602 | if (rndis_per_dev_params [configNr].stats) { |
| 603 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 604 | .stats->rx_frame_errors); |
| 605 | retval = 0; |
| 606 | } |
| 607 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 608 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | /* mandatory */ |
| 610 | case OID_802_3_XMIT_ONE_COLLISION: |
| 611 | DEBUG("%s: OID_802_3_XMIT_ONE_COLLISION\n", __FUNCTION__); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 612 | *outbuf = __constant_cpu_to_le32 (0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | retval = 0; |
| 614 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 615 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | /* mandatory */ |
| 617 | case OID_802_3_XMIT_MORE_COLLISIONS: |
| 618 | DEBUG("%s: OID_802_3_XMIT_MORE_COLLISIONS\n", __FUNCTION__); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 619 | *outbuf = __constant_cpu_to_le32 (0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | retval = 0; |
| 621 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 622 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | #ifdef RNDIS_OPTIONAL_STATS |
| 624 | case OID_802_3_XMIT_DEFERRED: |
| 625 | DEBUG("%s: OID_802_3_XMIT_DEFERRED\n", __FUNCTION__); |
| 626 | /* TODO */ |
| 627 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 628 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | case OID_802_3_XMIT_MAX_COLLISIONS: |
| 630 | DEBUG("%s: OID_802_3_XMIT_MAX_COLLISIONS\n", __FUNCTION__); |
| 631 | /* TODO */ |
| 632 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 633 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | case OID_802_3_RCV_OVERRUN: |
| 635 | DEBUG("%s: OID_802_3_RCV_OVERRUN\n", __FUNCTION__); |
| 636 | /* TODO */ |
| 637 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 638 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | case OID_802_3_XMIT_UNDERRUN: |
| 640 | DEBUG("%s: OID_802_3_XMIT_UNDERRUN\n", __FUNCTION__); |
| 641 | /* TODO */ |
| 642 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 643 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | case OID_802_3_XMIT_HEARTBEAT_FAILURE: |
| 645 | DEBUG("%s: OID_802_3_XMIT_HEARTBEAT_FAILURE\n", __FUNCTION__); |
| 646 | /* TODO */ |
| 647 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 648 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | case OID_802_3_XMIT_TIMES_CRS_LOST: |
| 650 | DEBUG("%s: OID_802_3_XMIT_TIMES_CRS_LOST\n", __FUNCTION__); |
| 651 | /* TODO */ |
| 652 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 653 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | case OID_802_3_XMIT_LATE_COLLISIONS: |
| 655 | DEBUG("%s: OID_802_3_XMIT_LATE_COLLISIONS\n", __FUNCTION__); |
| 656 | /* TODO */ |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 657 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | #endif /* RNDIS_OPTIONAL_STATS */ |
| 659 | |
| 660 | #ifdef RNDIS_PM |
| 661 | /* power management OIDs (table 4-5) */ |
| 662 | case OID_PNP_CAPABILITIES: |
| 663 | DEBUG("%s: OID_PNP_CAPABILITIES\n", __FUNCTION__); |
| 664 | |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 665 | /* for now, no wakeup capabilities */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | length = sizeof (struct NDIS_PNP_CAPABILITIES); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 667 | memset(outbuf, 0, length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | retval = 0; |
| 669 | break; |
| 670 | case OID_PNP_QUERY_POWER: |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 671 | DEBUG("%s: OID_PNP_QUERY_POWER D%d\n", __FUNCTION__, |
David Brownell | 01ee7d7 | 2007-05-25 20:40:14 -0700 | [diff] [blame] | 672 | le32_to_cpu(get_unaligned((__le32 *)buf)) - 1); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 673 | /* only suspend is a real power state, and |
| 674 | * it can't be entered by OID_PNP_SET_POWER... |
| 675 | */ |
| 676 | length = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 677 | retval = 0; |
| 678 | break; |
| 679 | #endif |
| 680 | |
| 681 | default: |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 682 | printk (KERN_WARNING "%s: query unknown OID 0x%08X\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | __FUNCTION__, OID); |
| 684 | } |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 685 | if (retval < 0) |
| 686 | length = 0; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 687 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 688 | resp->InformationBufferLength = cpu_to_le32 (length); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 689 | r->length = length + sizeof *resp; |
| 690 | resp->MessageLength = cpu_to_le32 (r->length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | return retval; |
| 692 | } |
| 693 | |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 694 | static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len, |
| 695 | rndis_resp_t *r) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | { |
| 697 | rndis_set_cmplt_type *resp; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 698 | int i, retval = -ENOTSUPP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | struct rndis_params *params; |
| 700 | |
| 701 | if (!r) |
| 702 | return -ENOMEM; |
| 703 | resp = (rndis_set_cmplt_type *) r->buf; |
| 704 | if (!resp) |
| 705 | return -ENOMEM; |
| 706 | |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 707 | if (buf_len && rndis_debug > 1) { |
| 708 | DEBUG("set OID %08x value, len %d:\n", OID, buf_len); |
| 709 | for (i = 0; i < buf_len; i += 16) { |
| 710 | DEBUG ("%03d: %08x %08x %08x %08x\n", i, |
David Brownell | 01ee7d7 | 2007-05-25 20:40:14 -0700 | [diff] [blame] | 711 | le32_to_cpu(get_unaligned((__le32 *) |
| 712 | &buf[i])), |
| 713 | le32_to_cpu(get_unaligned((__le32 *) |
| 714 | &buf[i + 4])), |
| 715 | le32_to_cpu(get_unaligned((__le32 *) |
| 716 | &buf[i + 8])), |
| 717 | le32_to_cpu(get_unaligned((__le32 *) |
| 718 | &buf[i + 12]))); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 719 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 720 | } |
| 721 | |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 722 | params = &rndis_per_dev_params [configNr]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 723 | switch (OID) { |
| 724 | case OID_GEN_CURRENT_PACKET_FILTER: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 725 | |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 726 | /* these NDIS_PACKET_TYPE_* bitflags are shared with |
| 727 | * cdc_filter; it's not RNDIS-specific |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 728 | * NDIS_PACKET_TYPE_x == USB_CDC_PACKET_TYPE_x for x in: |
| 729 | * PROMISCUOUS, DIRECTED, |
| 730 | * MULTICAST, ALL_MULTICAST, BROADCAST |
| 731 | */ |
David Brownell | 01ee7d7 | 2007-05-25 20:40:14 -0700 | [diff] [blame] | 732 | *params->filter = (u16) le32_to_cpu(get_unaligned( |
| 733 | (__le32 *)buf)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 734 | DEBUG("%s: OID_GEN_CURRENT_PACKET_FILTER %08x\n", |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 735 | __FUNCTION__, *params->filter); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 736 | |
| 737 | /* this call has a significant side effect: it's |
| 738 | * what makes the packet flow start and stop, like |
| 739 | * activating the CDC Ethernet altsetting. |
| 740 | */ |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 741 | #ifdef RNDIS_PM |
| 742 | update_linkstate: |
| 743 | #endif |
| 744 | retval = 0; |
| 745 | if (*params->filter) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 746 | params->state = RNDIS_DATA_INITIALIZED; |
| 747 | netif_carrier_on(params->dev); |
| 748 | if (netif_running(params->dev)) |
| 749 | netif_wake_queue (params->dev); |
| 750 | } else { |
| 751 | params->state = RNDIS_INITIALIZED; |
| 752 | netif_carrier_off (params->dev); |
| 753 | netif_stop_queue (params->dev); |
| 754 | } |
| 755 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 756 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 | case OID_802_3_MULTICAST_LIST: |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 758 | /* I think we can ignore this */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 759 | DEBUG("%s: OID_802_3_MULTICAST_LIST\n", __FUNCTION__); |
| 760 | retval = 0; |
| 761 | break; |
| 762 | #if 0 |
| 763 | case OID_GEN_RNDIS_CONFIG_PARAMETER: |
| 764 | { |
| 765 | struct rndis_config_parameter *param; |
| 766 | param = (struct rndis_config_parameter *) buf; |
| 767 | DEBUG("%s: OID_GEN_RNDIS_CONFIG_PARAMETER '%*s'\n", |
| 768 | __FUNCTION__, |
| 769 | min(cpu_to_le32(param->ParameterNameLength),80), |
| 770 | buf + param->ParameterNameOffset); |
| 771 | retval = 0; |
| 772 | } |
| 773 | break; |
| 774 | #endif |
| 775 | |
| 776 | #ifdef RNDIS_PM |
| 777 | case OID_PNP_SET_POWER: |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 778 | /* The only real power state is USB suspend, and RNDIS requests |
| 779 | * can't enter it; this one isn't really about power. After |
| 780 | * resuming, Windows forces a reset, and then SET_POWER D0. |
| 781 | * FIXME ... then things go batty; Windows wedges itself. |
| 782 | */ |
David Brownell | 01ee7d7 | 2007-05-25 20:40:14 -0700 | [diff] [blame] | 783 | i = le32_to_cpu(get_unaligned((__le32 *)buf)); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 784 | DEBUG("%s: OID_PNP_SET_POWER D%d\n", __FUNCTION__, i - 1); |
| 785 | switch (i) { |
| 786 | case NdisDeviceStateD0: |
| 787 | *params->filter = params->saved_filter; |
| 788 | goto update_linkstate; |
| 789 | case NdisDeviceStateD3: |
| 790 | case NdisDeviceStateD2: |
| 791 | case NdisDeviceStateD1: |
| 792 | params->saved_filter = *params->filter; |
| 793 | retval = 0; |
| 794 | break; |
| 795 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 796 | break; |
| 797 | |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 798 | #ifdef RNDIS_WAKEUP |
| 799 | // no wakeup support advertised, so wakeup OIDs always fail: |
| 800 | // - OID_PNP_ENABLE_WAKE_UP |
| 801 | // - OID_PNP_{ADD,REMOVE}_WAKE_UP_PATTERN |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 802 | #endif |
| 803 | |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 804 | #endif /* RNDIS_PM */ |
| 805 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 806 | default: |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 807 | printk (KERN_WARNING "%s: set unknown OID 0x%08X, size %d\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 808 | __FUNCTION__, OID, buf_len); |
| 809 | } |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 810 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 811 | return retval; |
| 812 | } |
| 813 | |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 814 | /* |
| 815 | * Response Functions |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 816 | */ |
| 817 | |
| 818 | static int rndis_init_response (int configNr, rndis_init_msg_type *buf) |
| 819 | { |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 820 | rndis_init_cmplt_type *resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 821 | rndis_resp_t *r; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 822 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 823 | if (!rndis_per_dev_params [configNr].dev) return -ENOTSUPP; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 824 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 825 | r = rndis_add_response (configNr, sizeof (rndis_init_cmplt_type)); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 826 | if (!r) |
| 827 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 828 | resp = (rndis_init_cmplt_type *) r->buf; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 829 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 830 | resp->MessageType = __constant_cpu_to_le32 ( |
| 831 | REMOTE_NDIS_INITIALIZE_CMPLT); |
| 832 | resp->MessageLength = __constant_cpu_to_le32 (52); |
| 833 | resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ |
| 834 | resp->Status = __constant_cpu_to_le32 (RNDIS_STATUS_SUCCESS); |
| 835 | resp->MajorVersion = __constant_cpu_to_le32 (RNDIS_MAJOR_VERSION); |
| 836 | resp->MinorVersion = __constant_cpu_to_le32 (RNDIS_MINOR_VERSION); |
| 837 | resp->DeviceFlags = __constant_cpu_to_le32 (RNDIS_DF_CONNECTIONLESS); |
| 838 | resp->Medium = __constant_cpu_to_le32 (RNDIS_MEDIUM_802_3); |
| 839 | resp->MaxPacketsPerTransfer = __constant_cpu_to_le32 (1); |
| 840 | resp->MaxTransferSize = cpu_to_le32 ( |
| 841 | rndis_per_dev_params [configNr].dev->mtu |
| 842 | + sizeof (struct ethhdr) |
| 843 | + sizeof (struct rndis_packet_msg_type) |
| 844 | + 22); |
| 845 | resp->PacketAlignmentFactor = __constant_cpu_to_le32 (0); |
| 846 | resp->AFListOffset = __constant_cpu_to_le32 (0); |
| 847 | resp->AFListSize = __constant_cpu_to_le32 (0); |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 848 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 849 | if (rndis_per_dev_params [configNr].ack) |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 850 | rndis_per_dev_params [configNr].ack ( |
| 851 | rndis_per_dev_params [configNr].dev); |
| 852 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 853 | return 0; |
| 854 | } |
| 855 | |
| 856 | static int rndis_query_response (int configNr, rndis_query_msg_type *buf) |
| 857 | { |
| 858 | rndis_query_cmplt_type *resp; |
| 859 | rndis_resp_t *r; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 860 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 861 | // DEBUG("%s: OID = %08X\n", __FUNCTION__, cpu_to_le32(buf->OID)); |
| 862 | if (!rndis_per_dev_params [configNr].dev) return -ENOTSUPP; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 863 | |
Shaun Tancheff | 8763716 | 2006-02-22 19:47:19 -0800 | [diff] [blame] | 864 | /* |
| 865 | * we need more memory: |
| 866 | * gen_ndis_query_resp expects enough space for |
| 867 | * rndis_query_cmplt_type followed by data. |
| 868 | * oid_supported_list is the largest data reply |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 869 | */ |
Shaun Tancheff | 8763716 | 2006-02-22 19:47:19 -0800 | [diff] [blame] | 870 | r = rndis_add_response (configNr, |
| 871 | sizeof (oid_supported_list) + sizeof(rndis_query_cmplt_type)); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 872 | if (!r) |
| 873 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 874 | resp = (rndis_query_cmplt_type *) r->buf; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 875 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 876 | resp->MessageType = __constant_cpu_to_le32 (REMOTE_NDIS_QUERY_CMPLT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 877 | resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 878 | |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 879 | if (gen_ndis_query_resp (configNr, le32_to_cpu (buf->OID), |
| 880 | le32_to_cpu(buf->InformationBufferOffset) |
| 881 | + 8 + (u8 *) buf, |
| 882 | le32_to_cpu(buf->InformationBufferLength), |
| 883 | r)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 884 | /* OID not supported */ |
| 885 | resp->Status = __constant_cpu_to_le32 ( |
| 886 | RNDIS_STATUS_NOT_SUPPORTED); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 887 | resp->MessageLength = __constant_cpu_to_le32 (sizeof *resp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 888 | resp->InformationBufferLength = __constant_cpu_to_le32 (0); |
| 889 | resp->InformationBufferOffset = __constant_cpu_to_le32 (0); |
| 890 | } else |
| 891 | resp->Status = __constant_cpu_to_le32 (RNDIS_STATUS_SUCCESS); |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 892 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 893 | if (rndis_per_dev_params [configNr].ack) |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 894 | rndis_per_dev_params [configNr].ack ( |
| 895 | rndis_per_dev_params [configNr].dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 896 | return 0; |
| 897 | } |
| 898 | |
| 899 | static int rndis_set_response (int configNr, rndis_set_msg_type *buf) |
| 900 | { |
| 901 | u32 BufLength, BufOffset; |
| 902 | rndis_set_cmplt_type *resp; |
| 903 | rndis_resp_t *r; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 904 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 905 | r = rndis_add_response (configNr, sizeof (rndis_set_cmplt_type)); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 906 | if (!r) |
| 907 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 908 | resp = (rndis_set_cmplt_type *) r->buf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 909 | |
| 910 | BufLength = le32_to_cpu (buf->InformationBufferLength); |
| 911 | BufOffset = le32_to_cpu (buf->InformationBufferOffset); |
| 912 | |
| 913 | #ifdef VERBOSE |
| 914 | DEBUG("%s: Length: %d\n", __FUNCTION__, BufLength); |
| 915 | DEBUG("%s: Offset: %d\n", __FUNCTION__, BufOffset); |
| 916 | DEBUG("%s: InfoBuffer: ", __FUNCTION__); |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 917 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 918 | for (i = 0; i < BufLength; i++) { |
| 919 | DEBUG ("%02x ", *(((u8 *) buf) + i + 8 + BufOffset)); |
| 920 | } |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 921 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 922 | DEBUG ("\n"); |
| 923 | #endif |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 924 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 925 | resp->MessageType = __constant_cpu_to_le32 (REMOTE_NDIS_SET_CMPLT); |
| 926 | resp->MessageLength = __constant_cpu_to_le32 (16); |
| 927 | resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 928 | if (gen_ndis_set_resp (configNr, le32_to_cpu (buf->OID), |
| 929 | ((u8 *) buf) + 8 + BufOffset, BufLength, r)) |
| 930 | resp->Status = __constant_cpu_to_le32 (RNDIS_STATUS_NOT_SUPPORTED); |
| 931 | else |
| 932 | resp->Status = __constant_cpu_to_le32 (RNDIS_STATUS_SUCCESS); |
| 933 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 934 | if (rndis_per_dev_params [configNr].ack) |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 935 | rndis_per_dev_params [configNr].ack ( |
| 936 | rndis_per_dev_params [configNr].dev); |
| 937 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 938 | return 0; |
| 939 | } |
| 940 | |
| 941 | static int rndis_reset_response (int configNr, rndis_reset_msg_type *buf) |
| 942 | { |
| 943 | rndis_reset_cmplt_type *resp; |
| 944 | rndis_resp_t *r; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 945 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 946 | r = rndis_add_response (configNr, sizeof (rndis_reset_cmplt_type)); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 947 | if (!r) |
| 948 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 949 | resp = (rndis_reset_cmplt_type *) r->buf; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 950 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 951 | resp->MessageType = __constant_cpu_to_le32 (REMOTE_NDIS_RESET_CMPLT); |
| 952 | resp->MessageLength = __constant_cpu_to_le32 (16); |
| 953 | resp->Status = __constant_cpu_to_le32 (RNDIS_STATUS_SUCCESS); |
| 954 | /* resent information */ |
| 955 | resp->AddressingReset = __constant_cpu_to_le32 (1); |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 956 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 957 | if (rndis_per_dev_params [configNr].ack) |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 958 | rndis_per_dev_params [configNr].ack ( |
| 959 | rndis_per_dev_params [configNr].dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 960 | |
| 961 | return 0; |
| 962 | } |
| 963 | |
| 964 | static int rndis_keepalive_response (int configNr, |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 965 | rndis_keepalive_msg_type *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 966 | { |
| 967 | rndis_keepalive_cmplt_type *resp; |
| 968 | rndis_resp_t *r; |
| 969 | |
| 970 | /* host "should" check only in RNDIS_DATA_INITIALIZED state */ |
| 971 | |
| 972 | r = rndis_add_response (configNr, sizeof (rndis_keepalive_cmplt_type)); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 973 | if (!r) |
| 974 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 975 | resp = (rndis_keepalive_cmplt_type *) r->buf; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 976 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 977 | resp->MessageType = __constant_cpu_to_le32 ( |
| 978 | REMOTE_NDIS_KEEPALIVE_CMPLT); |
| 979 | resp->MessageLength = __constant_cpu_to_le32 (16); |
| 980 | resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ |
| 981 | resp->Status = __constant_cpu_to_le32 (RNDIS_STATUS_SUCCESS); |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 982 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 983 | if (rndis_per_dev_params [configNr].ack) |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 984 | rndis_per_dev_params [configNr].ack ( |
| 985 | rndis_per_dev_params [configNr].dev); |
| 986 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 987 | return 0; |
| 988 | } |
| 989 | |
| 990 | |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 991 | /* |
| 992 | * Device to Host Comunication |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 993 | */ |
| 994 | static int rndis_indicate_status_msg (int configNr, u32 status) |
| 995 | { |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 996 | rndis_indicate_status_msg_type *resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 997 | rndis_resp_t *r; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 998 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 999 | if (rndis_per_dev_params [configNr].state == RNDIS_UNINITIALIZED) |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1000 | return -ENOTSUPP; |
| 1001 | |
| 1002 | r = rndis_add_response (configNr, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1003 | sizeof (rndis_indicate_status_msg_type)); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 1004 | if (!r) |
| 1005 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1006 | resp = (rndis_indicate_status_msg_type *) r->buf; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1007 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1008 | resp->MessageType = __constant_cpu_to_le32 ( |
| 1009 | REMOTE_NDIS_INDICATE_STATUS_MSG); |
| 1010 | resp->MessageLength = __constant_cpu_to_le32 (20); |
| 1011 | resp->Status = cpu_to_le32 (status); |
| 1012 | resp->StatusBufferLength = __constant_cpu_to_le32 (0); |
| 1013 | resp->StatusBufferOffset = __constant_cpu_to_le32 (0); |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1014 | |
| 1015 | if (rndis_per_dev_params [configNr].ack) |
| 1016 | rndis_per_dev_params [configNr].ack ( |
| 1017 | rndis_per_dev_params [configNr].dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1018 | return 0; |
| 1019 | } |
| 1020 | |
| 1021 | int rndis_signal_connect (int configNr) |
| 1022 | { |
| 1023 | rndis_per_dev_params [configNr].media_state |
| 1024 | = NDIS_MEDIA_STATE_CONNECTED; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1025 | return rndis_indicate_status_msg (configNr, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1026 | RNDIS_STATUS_MEDIA_CONNECT); |
| 1027 | } |
| 1028 | |
| 1029 | int rndis_signal_disconnect (int configNr) |
| 1030 | { |
| 1031 | rndis_per_dev_params [configNr].media_state |
| 1032 | = NDIS_MEDIA_STATE_DISCONNECTED; |
| 1033 | return rndis_indicate_status_msg (configNr, |
| 1034 | RNDIS_STATUS_MEDIA_DISCONNECT); |
| 1035 | } |
| 1036 | |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 1037 | void rndis_uninit (int configNr) |
| 1038 | { |
David Brownell | 486e2df | 2005-05-24 17:51:52 -0700 | [diff] [blame] | 1039 | u8 *buf; |
| 1040 | u32 length; |
| 1041 | |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 1042 | if (configNr >= RNDIS_MAX_CONFIGS) |
| 1043 | return; |
| 1044 | rndis_per_dev_params [configNr].used = 0; |
| 1045 | rndis_per_dev_params [configNr].state = RNDIS_UNINITIALIZED; |
David Brownell | 486e2df | 2005-05-24 17:51:52 -0700 | [diff] [blame] | 1046 | |
| 1047 | /* drain the response queue */ |
| 1048 | while ((buf = rndis_get_next_response(configNr, &length))) |
| 1049 | rndis_free_response(configNr, buf); |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 1050 | } |
| 1051 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1052 | void rndis_set_host_mac (int configNr, const u8 *addr) |
| 1053 | { |
| 1054 | rndis_per_dev_params [configNr].host_mac = addr; |
| 1055 | } |
| 1056 | |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1057 | /* |
| 1058 | * Message Parser |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1059 | */ |
| 1060 | int rndis_msg_parser (u8 configNr, u8 *buf) |
| 1061 | { |
| 1062 | u32 MsgType, MsgLength; |
| 1063 | __le32 *tmp; |
| 1064 | struct rndis_params *params; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1065 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1066 | if (!buf) |
| 1067 | return -ENOMEM; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1068 | |
| 1069 | tmp = (__le32 *) buf; |
David Brownell | 01ee7d7 | 2007-05-25 20:40:14 -0700 | [diff] [blame] | 1070 | MsgType = le32_to_cpu(get_unaligned(tmp++)); |
| 1071 | MsgLength = le32_to_cpu(get_unaligned(tmp++)); |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1072 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1073 | if (configNr >= RNDIS_MAX_CONFIGS) |
| 1074 | return -ENOTSUPP; |
| 1075 | params = &rndis_per_dev_params [configNr]; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1076 | |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 1077 | /* NOTE: RNDIS is *EXTREMELY* chatty ... Windows constantly polls for |
| 1078 | * rx/tx statistics and link status, in addition to KEEPALIVE traffic |
| 1079 | * and normal HC level polling to see if there's any IN traffic. |
| 1080 | */ |
| 1081 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1082 | /* For USB: responses may take up to 10 seconds */ |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 1083 | switch (MsgType) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1084 | case REMOTE_NDIS_INITIALIZE_MSG: |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1085 | DEBUG("%s: REMOTE_NDIS_INITIALIZE_MSG\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1086 | __FUNCTION__ ); |
| 1087 | params->state = RNDIS_INITIALIZED; |
| 1088 | return rndis_init_response (configNr, |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1089 | (rndis_init_msg_type *) buf); |
| 1090 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1091 | case REMOTE_NDIS_HALT_MSG: |
| 1092 | DEBUG("%s: REMOTE_NDIS_HALT_MSG\n", |
| 1093 | __FUNCTION__ ); |
| 1094 | params->state = RNDIS_UNINITIALIZED; |
| 1095 | if (params->dev) { |
| 1096 | netif_carrier_off (params->dev); |
| 1097 | netif_stop_queue (params->dev); |
| 1098 | } |
| 1099 | return 0; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1100 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1101 | case REMOTE_NDIS_QUERY_MSG: |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1102 | return rndis_query_response (configNr, |
| 1103 | (rndis_query_msg_type *) buf); |
| 1104 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1105 | case REMOTE_NDIS_SET_MSG: |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1106 | return rndis_set_response (configNr, |
| 1107 | (rndis_set_msg_type *) buf); |
| 1108 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1109 | case REMOTE_NDIS_RESET_MSG: |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1110 | DEBUG("%s: REMOTE_NDIS_RESET_MSG\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1111 | __FUNCTION__ ); |
| 1112 | return rndis_reset_response (configNr, |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1113 | (rndis_reset_msg_type *) buf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1114 | |
| 1115 | case REMOTE_NDIS_KEEPALIVE_MSG: |
| 1116 | /* For USB: host does this every 5 seconds */ |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 1117 | if (rndis_debug > 1) |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1118 | DEBUG("%s: REMOTE_NDIS_KEEPALIVE_MSG\n", |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 1119 | __FUNCTION__ ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1120 | return rndis_keepalive_response (configNr, |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1121 | (rndis_keepalive_msg_type *) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1122 | buf); |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1123 | |
| 1124 | default: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1125 | /* At least Windows XP emits some undefined RNDIS messages. |
| 1126 | * In one case those messages seemed to relate to the host |
| 1127 | * suspending itself. |
| 1128 | */ |
| 1129 | printk (KERN_WARNING |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1130 | "%s: unknown RNDIS message 0x%08X len %d\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1131 | __FUNCTION__ , MsgType, MsgLength); |
| 1132 | { |
| 1133 | unsigned i; |
| 1134 | for (i = 0; i < MsgLength; i += 16) { |
| 1135 | DEBUG ("%03d: " |
| 1136 | " %02x %02x %02x %02x" |
| 1137 | " %02x %02x %02x %02x" |
| 1138 | " %02x %02x %02x %02x" |
| 1139 | " %02x %02x %02x %02x" |
| 1140 | "\n", |
| 1141 | i, |
| 1142 | buf[i], buf [i+1], |
| 1143 | buf[i+2], buf[i+3], |
| 1144 | buf[i+4], buf [i+5], |
| 1145 | buf[i+6], buf[i+7], |
| 1146 | buf[i+8], buf [i+9], |
| 1147 | buf[i+10], buf[i+11], |
| 1148 | buf[i+12], buf [i+13], |
| 1149 | buf[i+14], buf[i+15]); |
| 1150 | } |
| 1151 | } |
| 1152 | break; |
| 1153 | } |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1154 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1155 | return -ENOTSUPP; |
| 1156 | } |
| 1157 | |
| 1158 | int rndis_register (int (* rndis_control_ack) (struct net_device *)) |
| 1159 | { |
| 1160 | u8 i; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1161 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1162 | for (i = 0; i < RNDIS_MAX_CONFIGS; i++) { |
| 1163 | if (!rndis_per_dev_params [i].used) { |
| 1164 | rndis_per_dev_params [i].used = 1; |
| 1165 | rndis_per_dev_params [i].ack = rndis_control_ack; |
| 1166 | DEBUG("%s: configNr = %d\n", __FUNCTION__, i); |
| 1167 | return i; |
| 1168 | } |
| 1169 | } |
| 1170 | DEBUG("failed\n"); |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1171 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1172 | return -1; |
| 1173 | } |
| 1174 | |
| 1175 | void rndis_deregister (int configNr) |
| 1176 | { |
| 1177 | DEBUG("%s: \n", __FUNCTION__ ); |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1178 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1179 | if (configNr >= RNDIS_MAX_CONFIGS) return; |
| 1180 | rndis_per_dev_params [configNr].used = 0; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1181 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1182 | return; |
| 1183 | } |
| 1184 | |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1185 | int rndis_set_param_dev (u8 configNr, struct net_device *dev, |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 1186 | struct net_device_stats *stats, |
| 1187 | u16 *cdc_filter) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1188 | { |
| 1189 | DEBUG("%s:\n", __FUNCTION__ ); |
| 1190 | if (!dev || !stats) return -1; |
| 1191 | if (configNr >= RNDIS_MAX_CONFIGS) return -1; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1192 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1193 | rndis_per_dev_params [configNr].dev = dev; |
| 1194 | rndis_per_dev_params [configNr].stats = stats; |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 1195 | rndis_per_dev_params [configNr].filter = cdc_filter; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1196 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1197 | return 0; |
| 1198 | } |
| 1199 | |
| 1200 | int rndis_set_param_vendor (u8 configNr, u32 vendorID, const char *vendorDescr) |
| 1201 | { |
| 1202 | DEBUG("%s:\n", __FUNCTION__ ); |
| 1203 | if (!vendorDescr) return -1; |
| 1204 | if (configNr >= RNDIS_MAX_CONFIGS) return -1; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1205 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1206 | rndis_per_dev_params [configNr].vendorID = vendorID; |
| 1207 | rndis_per_dev_params [configNr].vendorDescr = vendorDescr; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1208 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1209 | return 0; |
| 1210 | } |
| 1211 | |
| 1212 | int rndis_set_param_medium (u8 configNr, u32 medium, u32 speed) |
| 1213 | { |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 1214 | DEBUG("%s: %u %u\n", __FUNCTION__, medium, speed); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1215 | if (configNr >= RNDIS_MAX_CONFIGS) return -1; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1216 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1217 | rndis_per_dev_params [configNr].medium = medium; |
| 1218 | rndis_per_dev_params [configNr].speed = speed; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1219 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1220 | return 0; |
| 1221 | } |
| 1222 | |
| 1223 | void rndis_add_hdr (struct sk_buff *skb) |
| 1224 | { |
| 1225 | struct rndis_packet_msg_type *header; |
| 1226 | |
| 1227 | if (!skb) |
| 1228 | return; |
| 1229 | header = (void *) skb_push (skb, sizeof *header); |
| 1230 | memset (header, 0, sizeof *header); |
David Brownell | 6cdee10 | 2005-04-18 17:39:34 -0700 | [diff] [blame] | 1231 | header->MessageType = __constant_cpu_to_le32(REMOTE_NDIS_PACKET_MSG); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1232 | header->MessageLength = cpu_to_le32(skb->len); |
| 1233 | header->DataOffset = __constant_cpu_to_le32 (36); |
David Brownell | 6cdee10 | 2005-04-18 17:39:34 -0700 | [diff] [blame] | 1234 | header->DataLength = cpu_to_le32(skb->len - sizeof *header); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1235 | } |
| 1236 | |
| 1237 | void rndis_free_response (int configNr, u8 *buf) |
| 1238 | { |
| 1239 | rndis_resp_t *r; |
| 1240 | struct list_head *act, *tmp; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1241 | |
| 1242 | list_for_each_safe (act, tmp, |
| 1243 | &(rndis_per_dev_params [configNr].resp_queue)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1244 | { |
| 1245 | r = list_entry (act, rndis_resp_t, list); |
| 1246 | if (r && r->buf == buf) { |
| 1247 | list_del (&r->list); |
| 1248 | kfree (r); |
| 1249 | } |
| 1250 | } |
| 1251 | } |
| 1252 | |
| 1253 | u8 *rndis_get_next_response (int configNr, u32 *length) |
| 1254 | { |
| 1255 | rndis_resp_t *r; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1256 | struct list_head *act, *tmp; |
| 1257 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1258 | if (!length) return NULL; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1259 | |
| 1260 | list_for_each_safe (act, tmp, |
| 1261 | &(rndis_per_dev_params [configNr].resp_queue)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1262 | { |
| 1263 | r = list_entry (act, rndis_resp_t, list); |
| 1264 | if (!r->send) { |
| 1265 | r->send = 1; |
| 1266 | *length = r->length; |
| 1267 | return r->buf; |
| 1268 | } |
| 1269 | } |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1270 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1271 | return NULL; |
| 1272 | } |
| 1273 | |
| 1274 | static rndis_resp_t *rndis_add_response (int configNr, u32 length) |
| 1275 | { |
| 1276 | rndis_resp_t *r; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1277 | |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 1278 | /* NOTE: this gets copied into ether.c USB_BUFSIZ bytes ... */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1279 | r = kmalloc (sizeof (rndis_resp_t) + length, GFP_ATOMIC); |
| 1280 | if (!r) return NULL; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1281 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1282 | r->buf = (u8 *) (r + 1); |
| 1283 | r->length = length; |
| 1284 | r->send = 0; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1285 | |
| 1286 | list_add_tail (&r->list, |
| 1287 | &(rndis_per_dev_params [configNr].resp_queue)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1288 | return r; |
| 1289 | } |
| 1290 | |
David Brownell | 6cdee10 | 2005-04-18 17:39:34 -0700 | [diff] [blame] | 1291 | int rndis_rm_hdr(struct sk_buff *skb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1292 | { |
David Brownell | 6cdee10 | 2005-04-18 17:39:34 -0700 | [diff] [blame] | 1293 | /* tmp points to a struct rndis_packet_msg_type */ |
| 1294 | __le32 *tmp = (void *) skb->data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1295 | |
David Brownell | 6cdee10 | 2005-04-18 17:39:34 -0700 | [diff] [blame] | 1296 | /* MessageType, MessageLength */ |
| 1297 | if (__constant_cpu_to_le32(REMOTE_NDIS_PACKET_MSG) |
| 1298 | != get_unaligned(tmp++)) |
| 1299 | return -EINVAL; |
| 1300 | tmp++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1301 | |
David Brownell | 6cdee10 | 2005-04-18 17:39:34 -0700 | [diff] [blame] | 1302 | /* DataOffset, DataLength */ |
| 1303 | if (!skb_pull(skb, le32_to_cpu(get_unaligned(tmp++)) |
| 1304 | + 8 /* offset of DataOffset */)) |
| 1305 | return -EOVERFLOW; |
| 1306 | skb_trim(skb, le32_to_cpu(get_unaligned(tmp++))); |
| 1307 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1308 | return 0; |
| 1309 | } |
| 1310 | |
| 1311 | #ifdef CONFIG_USB_GADGET_DEBUG_FILES |
| 1312 | |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1313 | static int rndis_proc_read (char *page, char **start, off_t off, int count, int *eof, |
| 1314 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1315 | { |
| 1316 | char *out = page; |
| 1317 | int len; |
| 1318 | rndis_params *param = (rndis_params *) data; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1319 | |
| 1320 | out += snprintf (out, count, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1321 | "Config Nr. %d\n" |
| 1322 | "used : %s\n" |
| 1323 | "state : %s\n" |
| 1324 | "medium : 0x%08X\n" |
| 1325 | "speed : %d\n" |
| 1326 | "cable : %s\n" |
| 1327 | "vendor ID : 0x%08X\n" |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1328 | "vendor : %s\n", |
| 1329 | param->confignr, (param->used) ? "y" : "n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1330 | ({ char *s = "?"; |
| 1331 | switch (param->state) { |
| 1332 | case RNDIS_UNINITIALIZED: |
| 1333 | s = "RNDIS_UNINITIALIZED"; break; |
| 1334 | case RNDIS_INITIALIZED: |
| 1335 | s = "RNDIS_INITIALIZED"; break; |
| 1336 | case RNDIS_DATA_INITIALIZED: |
| 1337 | s = "RNDIS_DATA_INITIALIZED"; break; |
| 1338 | }; s; }), |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1339 | param->medium, |
| 1340 | (param->media_state) ? 0 : param->speed*100, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1341 | (param->media_state) ? "disconnected" : "connected", |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1342 | param->vendorID, param->vendorDescr); |
| 1343 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1344 | len = out - page; |
| 1345 | len -= off; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1346 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1347 | if (len < count) { |
| 1348 | *eof = 1; |
| 1349 | if (len <= 0) |
| 1350 | return 0; |
| 1351 | } else |
| 1352 | len = count; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1353 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1354 | *start = page + off; |
| 1355 | return len; |
| 1356 | } |
| 1357 | |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1358 | static int rndis_proc_write (struct file *file, const char __user *buffer, |
| 1359 | unsigned long count, void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1360 | { |
| 1361 | rndis_params *p = data; |
| 1362 | u32 speed = 0; |
| 1363 | int i, fl_speed = 0; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1364 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1365 | for (i = 0; i < count; i++) { |
| 1366 | char c; |
| 1367 | if (get_user(c, buffer)) |
| 1368 | return -EFAULT; |
| 1369 | switch (c) { |
| 1370 | case '0': |
| 1371 | case '1': |
| 1372 | case '2': |
| 1373 | case '3': |
| 1374 | case '4': |
| 1375 | case '5': |
| 1376 | case '6': |
| 1377 | case '7': |
| 1378 | case '8': |
| 1379 | case '9': |
| 1380 | fl_speed = 1; |
| 1381 | speed = speed*10 + c - '0'; |
| 1382 | break; |
| 1383 | case 'C': |
| 1384 | case 'c': |
| 1385 | rndis_signal_connect (p->confignr); |
| 1386 | break; |
| 1387 | case 'D': |
| 1388 | case 'd': |
| 1389 | rndis_signal_disconnect(p->confignr); |
| 1390 | break; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1391 | default: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1392 | if (fl_speed) p->speed = speed; |
| 1393 | else DEBUG ("%c is not valid\n", c); |
| 1394 | break; |
| 1395 | } |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1396 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1397 | buffer++; |
| 1398 | } |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1399 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1400 | return count; |
| 1401 | } |
| 1402 | |
| 1403 | #define NAME_TEMPLATE "driver/rndis-%03d" |
| 1404 | |
| 1405 | static struct proc_dir_entry *rndis_connect_state [RNDIS_MAX_CONFIGS]; |
| 1406 | |
| 1407 | #endif /* CONFIG_USB_GADGET_DEBUG_FILES */ |
| 1408 | |
| 1409 | |
David Brownell | a353678 | 2006-07-06 15:48:53 -0700 | [diff] [blame] | 1410 | int __devinit rndis_init (void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1411 | { |
| 1412 | u8 i; |
| 1413 | |
| 1414 | for (i = 0; i < RNDIS_MAX_CONFIGS; i++) { |
| 1415 | #ifdef CONFIG_USB_GADGET_DEBUG_FILES |
| 1416 | char name [20]; |
| 1417 | |
| 1418 | sprintf (name, NAME_TEMPLATE, i); |
| 1419 | if (!(rndis_connect_state [i] |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1420 | = create_proc_entry (name, 0660, NULL))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1421 | { |
| 1422 | DEBUG ("%s :remove entries", __FUNCTION__); |
| 1423 | while (i) { |
| 1424 | sprintf (name, NAME_TEMPLATE, --i); |
| 1425 | remove_proc_entry (name, NULL); |
| 1426 | } |
| 1427 | DEBUG ("\n"); |
| 1428 | return -EIO; |
| 1429 | } |
| 1430 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1431 | rndis_connect_state [i]->write_proc = rndis_proc_write; |
| 1432 | rndis_connect_state [i]->read_proc = rndis_proc_read; |
| 1433 | rndis_connect_state [i]->data = (void *) |
| 1434 | (rndis_per_dev_params + i); |
| 1435 | #endif |
| 1436 | rndis_per_dev_params [i].confignr = i; |
| 1437 | rndis_per_dev_params [i].used = 0; |
| 1438 | rndis_per_dev_params [i].state = RNDIS_UNINITIALIZED; |
| 1439 | rndis_per_dev_params [i].media_state |
| 1440 | = NDIS_MEDIA_STATE_DISCONNECTED; |
| 1441 | INIT_LIST_HEAD (&(rndis_per_dev_params [i].resp_queue)); |
| 1442 | } |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1443 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1444 | return 0; |
| 1445 | } |
| 1446 | |
| 1447 | void rndis_exit (void) |
| 1448 | { |
| 1449 | #ifdef CONFIG_USB_GADGET_DEBUG_FILES |
| 1450 | u8 i; |
| 1451 | char name [20]; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1452 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1453 | for (i = 0; i < RNDIS_MAX_CONFIGS; i++) { |
| 1454 | sprintf (name, NAME_TEMPLATE, i); |
| 1455 | remove_proc_entry (name, NULL); |
| 1456 | } |
| 1457 | #endif |
| 1458 | } |
| 1459 | |