aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/usb
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@mbnet.fi>2008-01-25 17:51:12 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-31 22:26:56 -0500
commit7517579af8f32ecf9ddff4ead52bc801e4898efe (patch)
tree176664dd51b8cfa8d1faa8d4579fd25495aacc11 /drivers/net/usb
parent6e3bbcc5d75d187bb853a086e22cd813242f6b75 (diff)
rndis_host: Split up rndis_host.c
Split up rndis_host.c into rndis_host.h and rndis_base.c. This is done so that rndis_wlan can reuse common parts with rndis_host. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi> Acked-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: John W. Linville <linville@tuxdriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/usb')
-rw-r--r--drivers/net/usb/rndis_host.c223
-rw-r--r--drivers/net/usb/rndis_host.h248
2 files changed, 249 insertions, 222 deletions
diff --git a/drivers/net/usb/rndis_host.c b/drivers/net/usb/rndis_host.c
index 12daf9cfb77b..29d7e3b166f5 100644
--- a/drivers/net/usb/rndis_host.c
+++ b/drivers/net/usb/rndis_host.c
@@ -31,6 +31,7 @@
31#include <linux/usb/cdc.h> 31#include <linux/usb/cdc.h>
32 32
33#include "usbnet.h" 33#include "usbnet.h"
34#include "rndis_host.h"
34 35
35 36
36/* 37/*
@@ -56,228 +57,6 @@
56 */ 57 */
57 58
58/* 59/*
59 * CONTROL uses CDC "encapsulated commands" with funky notifications.
60 * - control-out: SEND_ENCAPSULATED
61 * - interrupt-in: RESPONSE_AVAILABLE
62 * - control-in: GET_ENCAPSULATED
63 *
64 * We'll try to ignore the RESPONSE_AVAILABLE notifications.
65 *
66 * REVISIT some RNDIS implementations seem to have curious issues still
67 * to be resolved.
68 */
69struct rndis_msg_hdr {
70 __le32 msg_type; /* RNDIS_MSG_* */
71 __le32 msg_len;
72 // followed by data that varies between messages
73 __le32 request_id;
74 __le32 status;
75 // ... and more
76} __attribute__ ((packed));
77
78/* MS-Windows uses this strange size, but RNDIS spec says 1024 minimum */
79#define CONTROL_BUFFER_SIZE 1025
80
81/* RNDIS defines an (absurdly huge) 10 second control timeout,
82 * but ActiveSync seems to use a more usual 5 second timeout
83 * (which matches the USB 2.0 spec).
84 */
85#define RNDIS_CONTROL_TIMEOUT_MS (5 * 1000)
86
87
88#define ccpu2 __constant_cpu_to_le32
89
90#define RNDIS_MSG_COMPLETION ccpu2(0x80000000)
91
92/* codes for "msg_type" field of rndis messages;
93 * only the data channel uses packet messages (maybe batched);
94 * everything else goes on the control channel.
95 */
96#define RNDIS_MSG_PACKET ccpu2(0x00000001) /* 1-N packets */
97#define RNDIS_MSG_INIT ccpu2(0x00000002)
98#define RNDIS_MSG_INIT_C (RNDIS_MSG_INIT|RNDIS_MSG_COMPLETION)
99#define RNDIS_MSG_HALT ccpu2(0x00000003)
100#define RNDIS_MSG_QUERY ccpu2(0x00000004)
101#define RNDIS_MSG_QUERY_C (RNDIS_MSG_QUERY|RNDIS_MSG_COMPLETION)
102#define RNDIS_MSG_SET ccpu2(0x00000005)
103#define RNDIS_MSG_SET_C (RNDIS_MSG_SET|RNDIS_MSG_COMPLETION)
104#define RNDIS_MSG_RESET ccpu2(0x00000006)
105#define RNDIS_MSG_RESET_C (RNDIS_MSG_RESET|RNDIS_MSG_COMPLETION)
106#define RNDIS_MSG_INDICATE ccpu2(0x00000007)
107#define RNDIS_MSG_KEEPALIVE ccpu2(0x00000008)
108#define RNDIS_MSG_KEEPALIVE_C (RNDIS_MSG_KEEPALIVE|RNDIS_MSG_COMPLETION)
109
110/* codes for "status" field of completion messages */
111#define RNDIS_STATUS_SUCCESS ccpu2(0x00000000)
112#define RNDIS_STATUS_FAILURE ccpu2(0xc0000001)
113#define RNDIS_STATUS_INVALID_DATA ccpu2(0xc0010015)
114#define RNDIS_STATUS_NOT_SUPPORTED ccpu2(0xc00000bb)
115#define RNDIS_STATUS_MEDIA_CONNECT ccpu2(0x4001000b)
116#define RNDIS_STATUS_MEDIA_DISCONNECT ccpu2(0x4001000c)
117
118
119struct rndis_data_hdr {
120 __le32 msg_type; /* RNDIS_MSG_PACKET */
121 __le32 msg_len; // rndis_data_hdr + data_len + pad
122 __le32 data_offset; // 36 -- right after header
123 __le32 data_len; // ... real packet size
124
125 __le32 oob_data_offset; // zero
126 __le32 oob_data_len; // zero
127 __le32 num_oob; // zero
128 __le32 packet_data_offset; // zero
129
130 __le32 packet_data_len; // zero
131 __le32 vc_handle; // zero
132 __le32 reserved; // zero
133} __attribute__ ((packed));
134
135struct rndis_init { /* OUT */
136 // header and:
137 __le32 msg_type; /* RNDIS_MSG_INIT */
138 __le32 msg_len; // 24
139 __le32 request_id;
140 __le32 major_version; // of rndis (1.0)
141 __le32 minor_version;
142 __le32 max_transfer_size;
143} __attribute__ ((packed));
144
145struct rndis_init_c { /* IN */
146 // header and:
147 __le32 msg_type; /* RNDIS_MSG_INIT_C */
148 __le32 msg_len;
149 __le32 request_id;
150 __le32 status;
151 __le32 major_version; // of rndis (1.0)
152 __le32 minor_version;
153 __le32 device_flags;
154 __le32 medium; // zero == 802.3
155 __le32 max_packets_per_message;
156 __le32 max_transfer_size;
157 __le32 packet_alignment; // max 7; (1<<n) bytes
158 __le32 af_list_offset; // zero
159 __le32 af_list_size; // zero
160} __attribute__ ((packed));
161
162struct rndis_halt { /* OUT (no reply) */
163 // header and:
164 __le32 msg_type; /* RNDIS_MSG_HALT */
165 __le32 msg_len;
166 __le32 request_id;
167} __attribute__ ((packed));
168
169struct rndis_query { /* OUT */
170 // header and:
171 __le32 msg_type; /* RNDIS_MSG_QUERY */
172 __le32 msg_len;
173 __le32 request_id;
174 __le32 oid;
175 __le32 len;
176 __le32 offset;
177/*?*/ __le32 handle; // zero
178} __attribute__ ((packed));
179
180struct rndis_query_c { /* IN */
181 // header and:
182 __le32 msg_type; /* RNDIS_MSG_QUERY_C */
183 __le32 msg_len;
184 __le32 request_id;
185 __le32 status;
186 __le32 len;
187 __le32 offset;
188} __attribute__ ((packed));
189
190struct rndis_set { /* OUT */
191 // header and:
192 __le32 msg_type; /* RNDIS_MSG_SET */
193 __le32 msg_len;
194 __le32 request_id;
195 __le32 oid;
196 __le32 len;
197 __le32 offset;
198/*?*/ __le32 handle; // zero
199} __attribute__ ((packed));
200
201struct rndis_set_c { /* IN */
202 // header and:
203 __le32 msg_type; /* RNDIS_MSG_SET_C */
204 __le32 msg_len;
205 __le32 request_id;
206 __le32 status;
207} __attribute__ ((packed));
208
209struct rndis_reset { /* IN */
210 // header and:
211 __le32 msg_type; /* RNDIS_MSG_RESET */
212 __le32 msg_len;
213 __le32 reserved;
214} __attribute__ ((packed));
215
216struct rndis_reset_c { /* OUT */
217 // header and:
218 __le32 msg_type; /* RNDIS_MSG_RESET_C */
219 __le32 msg_len;
220 __le32 status;
221 __le32 addressing_lost;
222} __attribute__ ((packed));
223
224struct rndis_indicate { /* IN (unrequested) */
225 // header and:
226 __le32 msg_type; /* RNDIS_MSG_INDICATE */
227 __le32 msg_len;
228 __le32 status;
229 __le32 length;
230 __le32 offset;
231/**/ __le32 diag_status;
232 __le32 error_offset;
233/**/ __le32 message;
234} __attribute__ ((packed));
235
236struct rndis_keepalive { /* OUT (optionally IN) */
237 // header and:
238 __le32 msg_type; /* RNDIS_MSG_KEEPALIVE */
239 __le32 msg_len;
240 __le32 request_id;
241} __attribute__ ((packed));
242
243struct rndis_keepalive_c { /* IN (optionally OUT) */
244 // header and:
245 __le32 msg_type; /* RNDIS_MSG_KEEPALIVE_C */
246 __le32 msg_len;
247 __le32 request_id;
248 __le32 status;
249} __attribute__ ((packed));
250
251/* NOTE: about 30 OIDs are "mandatory" for peripherals to support ... and
252 * there are gobs more that may optionally be supported. We'll avoid as much
253 * of that mess as possible.
254 */
255#define OID_802_3_PERMANENT_ADDRESS ccpu2(0x01010101)
256#define OID_GEN_MAXIMUM_FRAME_SIZE ccpu2(0x00010106)
257#define OID_GEN_CURRENT_PACKET_FILTER ccpu2(0x0001010e)
258
259/* packet filter bits used by OID_GEN_CURRENT_PACKET_FILTER */
260#define RNDIS_PACKET_TYPE_DIRECTED ccpu2(0x00000001)
261#define RNDIS_PACKET_TYPE_MULTICAST ccpu2(0x00000002)
262#define RNDIS_PACKET_TYPE_ALL_MULTICAST ccpu2(0x00000004)
263#define RNDIS_PACKET_TYPE_BROADCAST ccpu2(0x00000008)
264#define RNDIS_PACKET_TYPE_SOURCE_ROUTING ccpu2(0x00000010)
265#define RNDIS_PACKET_TYPE_PROMISCUOUS ccpu2(0x00000020)
266#define RNDIS_PACKET_TYPE_SMT ccpu2(0x00000040)
267#define RNDIS_PACKET_TYPE_ALL_LOCAL ccpu2(0x00000080)
268#define RNDIS_PACKET_TYPE_GROUP ccpu2(0x00001000)
269#define RNDIS_PACKET_TYPE_ALL_FUNCTIONAL ccpu2(0x00002000)
270#define RNDIS_PACKET_TYPE_FUNCTIONAL ccpu2(0x00004000)
271#define RNDIS_PACKET_TYPE_MAC_FRAME ccpu2(0x00008000)
272
273/* default filter used with RNDIS devices */
274#define RNDIS_DEFAULT_FILTER ( \
275 RNDIS_PACKET_TYPE_DIRECTED | \
276 RNDIS_PACKET_TYPE_BROADCAST | \
277 RNDIS_PACKET_TYPE_ALL_MULTICAST | \
278 RNDIS_PACKET_TYPE_PROMISCUOUS)
279
280/*
281 * RNDIS notifications from device: command completion; "reverse" 60 * RNDIS notifications from device: command completion; "reverse"
282 * keepalives; etc 61 * keepalives; etc
283 */ 62 */
diff --git a/drivers/net/usb/rndis_host.h b/drivers/net/usb/rndis_host.h
new file mode 100644
index 000000000000..1386a1791659
--- /dev/null
+++ b/drivers/net/usb/rndis_host.h
@@ -0,0 +1,248 @@
1/*
2 * Host Side support for RNDIS Networking Links
3 * Copyright (C) 2005 by David Brownell
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20
21#ifndef __RNDIS_HOST_H
22#define __RNDIS_HOST_H
23
24
25/*
26 * CONTROL uses CDC "encapsulated commands" with funky notifications.
27 * - control-out: SEND_ENCAPSULATED
28 * - interrupt-in: RESPONSE_AVAILABLE
29 * - control-in: GET_ENCAPSULATED
30 *
31 * We'll try to ignore the RESPONSE_AVAILABLE notifications.
32 *
33 * REVISIT some RNDIS implementations seem to have curious issues still
34 * to be resolved.
35 */
36struct rndis_msg_hdr {
37 __le32 msg_type; /* RNDIS_MSG_* */
38 __le32 msg_len;
39 // followed by data that varies between messages
40 __le32 request_id;
41 __le32 status;
42 // ... and more
43} __attribute__ ((packed));
44
45/* MS-Windows uses this strange size, but RNDIS spec says 1024 minimum */
46#define CONTROL_BUFFER_SIZE 1025
47
48/* RNDIS defines an (absurdly huge) 10 second control timeout,
49 * but ActiveSync seems to use a more usual 5 second timeout
50 * (which matches the USB 2.0 spec).
51 */
52#define RNDIS_CONTROL_TIMEOUT_MS (5 * 1000)
53
54
55#define ccpu2 __constant_cpu_to_le32
56
57#define RNDIS_MSG_COMPLETION ccpu2(0x80000000)
58
59/* codes for "msg_type" field of rndis messages;
60 * only the data channel uses packet messages (maybe batched);
61 * everything else goes on the control channel.
62 */
63#define RNDIS_MSG_PACKET ccpu2(0x00000001) /* 1-N packets */
64#define RNDIS_MSG_INIT ccpu2(0x00000002)
65#define RNDIS_MSG_INIT_C (RNDIS_MSG_INIT|RNDIS_MSG_COMPLETION)
66#define RNDIS_MSG_HALT ccpu2(0x00000003)
67#define RNDIS_MSG_QUERY ccpu2(0x00000004)
68#define RNDIS_MSG_QUERY_C (RNDIS_MSG_QUERY|RNDIS_MSG_COMPLETION)
69#define RNDIS_MSG_SET ccpu2(0x00000005)
70#define RNDIS_MSG_SET_C (RNDIS_MSG_SET|RNDIS_MSG_COMPLETION)
71#define RNDIS_MSG_RESET ccpu2(0x00000006)
72#define RNDIS_MSG_RESET_C (RNDIS_MSG_RESET|RNDIS_MSG_COMPLETION)
73#define RNDIS_MSG_INDICATE ccpu2(0x00000007)
74#define RNDIS_MSG_KEEPALIVE ccpu2(0x00000008)
75#define RNDIS_MSG_KEEPALIVE_C (RNDIS_MSG_KEEPALIVE|RNDIS_MSG_COMPLETION)
76
77/* codes for "status" field of completion messages */
78#define RNDIS_STATUS_SUCCESS ccpu2(0x00000000)
79#define RNDIS_STATUS_FAILURE ccpu2(0xc0000001)
80#define RNDIS_STATUS_INVALID_DATA ccpu2(0xc0010015)
81#define RNDIS_STATUS_NOT_SUPPORTED ccpu2(0xc00000bb)
82#define RNDIS_STATUS_MEDIA_CONNECT ccpu2(0x4001000b)
83#define RNDIS_STATUS_MEDIA_DISCONNECT ccpu2(0x4001000c)
84
85
86struct rndis_data_hdr {
87 __le32 msg_type; /* RNDIS_MSG_PACKET */
88 __le32 msg_len; // rndis_data_hdr + data_len + pad
89 __le32 data_offset; // 36 -- right after header
90 __le32 data_len; // ... real packet size
91
92 __le32 oob_data_offset; // zero
93 __le32 oob_data_len; // zero
94 __le32 num_oob; // zero
95 __le32 packet_data_offset; // zero
96
97 __le32 packet_data_len; // zero
98 __le32 vc_handle; // zero
99 __le32 reserved; // zero
100} __attribute__ ((packed));
101
102struct rndis_init { /* OUT */
103 // header and:
104 __le32 msg_type; /* RNDIS_MSG_INIT */
105 __le32 msg_len; // 24
106 __le32 request_id;
107 __le32 major_version; // of rndis (1.0)
108 __le32 minor_version;
109 __le32 max_transfer_size;
110} __attribute__ ((packed));
111
112struct rndis_init_c { /* IN */
113 // header and:
114 __le32 msg_type; /* RNDIS_MSG_INIT_C */
115 __le32 msg_len;
116 __le32 request_id;
117 __le32 status;
118 __le32 major_version; // of rndis (1.0)
119 __le32 minor_version;
120 __le32 device_flags;
121 __le32 medium; // zero == 802.3
122 __le32 max_packets_per_message;
123 __le32 max_transfer_size;
124 __le32 packet_alignment; // max 7; (1<<n) bytes
125 __le32 af_list_offset; // zero
126 __le32 af_list_size; // zero
127} __attribute__ ((packed));
128
129struct rndis_halt { /* OUT (no reply) */
130 // header and:
131 __le32 msg_type; /* RNDIS_MSG_HALT */
132 __le32 msg_len;
133 __le32 request_id;
134} __attribute__ ((packed));
135
136struct rndis_query { /* OUT */
137 // header and:
138 __le32 msg_type; /* RNDIS_MSG_QUERY */
139 __le32 msg_len;
140 __le32 request_id;
141 __le32 oid;
142 __le32 len;
143 __le32 offset;
144/*?*/ __le32 handle; // zero
145} __attribute__ ((packed));
146
147struct rndis_query_c { /* IN */
148 // header and:
149 __le32 msg_type; /* RNDIS_MSG_QUERY_C */
150 __le32 msg_len;
151 __le32 request_id;
152 __le32 status;
153 __le32 len;
154 __le32 offset;
155} __attribute__ ((packed));
156
157struct rndis_set { /* OUT */
158 // header and:
159 __le32 msg_type; /* RNDIS_MSG_SET */
160 __le32 msg_len;
161 __le32 request_id;
162 __le32 oid;
163 __le32 len;
164 __le32 offset;
165/*?*/ __le32 handle; // zero
166} __attribute__ ((packed));
167
168struct rndis_set_c { /* IN */
169 // header and:
170 __le32 msg_type; /* RNDIS_MSG_SET_C */
171 __le32 msg_len;
172 __le32 request_id;
173 __le32 status;
174} __attribute__ ((packed));
175
176struct rndis_reset { /* IN */
177 // header and:
178 __le32 msg_type; /* RNDIS_MSG_RESET */
179 __le32 msg_len;
180 __le32 reserved;
181} __attribute__ ((packed));
182
183struct rndis_reset_c { /* OUT */
184 // header and:
185 __le32 msg_type; /* RNDIS_MSG_RESET_C */
186 __le32 msg_len;
187 __le32 status;
188 __le32 addressing_lost;
189} __attribute__ ((packed));
190
191struct rndis_indicate { /* IN (unrequested) */
192 // header and:
193 __le32 msg_type; /* RNDIS_MSG_INDICATE */
194 __le32 msg_len;
195 __le32 status;
196 __le32 length;
197 __le32 offset;
198/**/ __le32 diag_status;
199 __le32 error_offset;
200/**/ __le32 message;
201} __attribute__ ((packed));
202
203struct rndis_keepalive { /* OUT (optionally IN) */
204 // header and:
205 __le32 msg_type; /* RNDIS_MSG_KEEPALIVE */
206 __le32 msg_len;
207 __le32 request_id;
208} __attribute__ ((packed));
209
210struct rndis_keepalive_c { /* IN (optionally OUT) */
211 // header and:
212 __le32 msg_type; /* RNDIS_MSG_KEEPALIVE_C */
213 __le32 msg_len;
214 __le32 request_id;
215 __le32 status;
216} __attribute__ ((packed));
217
218/* NOTE: about 30 OIDs are "mandatory" for peripherals to support ... and
219 * there are gobs more that may optionally be supported. We'll avoid as much
220 * of that mess as possible.
221 */
222#define OID_802_3_PERMANENT_ADDRESS ccpu2(0x01010101)
223#define OID_GEN_MAXIMUM_FRAME_SIZE ccpu2(0x00010106)
224#define OID_GEN_CURRENT_PACKET_FILTER ccpu2(0x0001010e)
225
226/* packet filter bits used by OID_GEN_CURRENT_PACKET_FILTER */
227#define RNDIS_PACKET_TYPE_DIRECTED ccpu2(0x00000001)
228#define RNDIS_PACKET_TYPE_MULTICAST ccpu2(0x00000002)
229#define RNDIS_PACKET_TYPE_ALL_MULTICAST ccpu2(0x00000004)
230#define RNDIS_PACKET_TYPE_BROADCAST ccpu2(0x00000008)
231#define RNDIS_PACKET_TYPE_SOURCE_ROUTING ccpu2(0x00000010)
232#define RNDIS_PACKET_TYPE_PROMISCUOUS ccpu2(0x00000020)
233#define RNDIS_PACKET_TYPE_SMT ccpu2(0x00000040)
234#define RNDIS_PACKET_TYPE_ALL_LOCAL ccpu2(0x00000080)
235#define RNDIS_PACKET_TYPE_GROUP ccpu2(0x00001000)
236#define RNDIS_PACKET_TYPE_ALL_FUNCTIONAL ccpu2(0x00002000)
237#define RNDIS_PACKET_TYPE_FUNCTIONAL ccpu2(0x00004000)
238#define RNDIS_PACKET_TYPE_MAC_FRAME ccpu2(0x00008000)
239
240/* default filter used with RNDIS devices */
241#define RNDIS_DEFAULT_FILTER ( \
242 RNDIS_PACKET_TYPE_DIRECTED | \
243 RNDIS_PACKET_TYPE_BROADCAST | \
244 RNDIS_PACKET_TYPE_ALL_MULTICAST | \
245 RNDIS_PACKET_TYPE_PROMISCUOUS)
246
247#endif /* __RNDIS_HOST_H */
248