aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb/rndis_host.h
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@mbnet.fi>2008-01-25 17:51:45 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-31 22:27:00 -0500
commit3692e94f1559523b84a5a0e65929ee84b276e83f (patch)
tree19e1c018d5f7dbebd0c22dd5ddb2876ea7354e12 /include/linux/usb/rndis_host.h
parent039ee17d1baabaa21783a0d5ab3e8c6d8c794bdf (diff)
Move usbnet.h and rndis_host.h to include/linux/usb
Move headers usbnet.h and rndis_host.h to include/linux/usb and fix includes for drivers/net/usb modules. Headers are moved because rndis_wlan will be outside drivers/net/usb in drivers/net/wireless and yet need these headers. 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 'include/linux/usb/rndis_host.h')
-rw-r--r--include/linux/usb/rndis_host.h274
1 files changed, 274 insertions, 0 deletions
diff --git a/include/linux/usb/rndis_host.h b/include/linux/usb/rndis_host.h
new file mode 100644
index 000000000000..edc1d4a0e272
--- /dev/null
+++ b/include/linux/usb/rndis_host.h
@@ -0,0 +1,274 @@
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/* codes for OID_GEN_PHYSICAL_MEDIUM */
86#define RNDIS_PHYSICAL_MEDIUM_UNSPECIFIED ccpu2(0x00000000)
87#define RNDIS_PHYSICAL_MEDIUM_WIRELESS_LAN ccpu2(0x00000001)
88#define RNDIS_PHYSICAL_MEDIUM_CABLE_MODEM ccpu2(0x00000002)
89#define RNDIS_PHYSICAL_MEDIUM_PHONE_LINE ccpu2(0x00000003)
90#define RNDIS_PHYSICAL_MEDIUM_POWER_LINE ccpu2(0x00000004)
91#define RNDIS_PHYSICAL_MEDIUM_DSL ccpu2(0x00000005)
92#define RNDIS_PHYSICAL_MEDIUM_FIBRE_CHANNEL ccpu2(0x00000006)
93#define RNDIS_PHYSICAL_MEDIUM_1394 ccpu2(0x00000007)
94#define RNDIS_PHYSICAL_MEDIUM_WIRELESS_WAN ccpu2(0x00000008)
95#define RNDIS_PHYSICAL_MEDIUM_MAX ccpu2(0x00000009)
96
97struct rndis_data_hdr {
98 __le32 msg_type; /* RNDIS_MSG_PACKET */
99 __le32 msg_len; // rndis_data_hdr + data_len + pad
100 __le32 data_offset; // 36 -- right after header
101 __le32 data_len; // ... real packet size
102
103 __le32 oob_data_offset; // zero
104 __le32 oob_data_len; // zero
105 __le32 num_oob; // zero
106 __le32 packet_data_offset; // zero
107
108 __le32 packet_data_len; // zero
109 __le32 vc_handle; // zero
110 __le32 reserved; // zero
111} __attribute__ ((packed));
112
113struct rndis_init { /* OUT */
114 // header and:
115 __le32 msg_type; /* RNDIS_MSG_INIT */
116 __le32 msg_len; // 24
117 __le32 request_id;
118 __le32 major_version; // of rndis (1.0)
119 __le32 minor_version;
120 __le32 max_transfer_size;
121} __attribute__ ((packed));
122
123struct rndis_init_c { /* IN */
124 // header and:
125 __le32 msg_type; /* RNDIS_MSG_INIT_C */
126 __le32 msg_len;
127 __le32 request_id;
128 __le32 status;
129 __le32 major_version; // of rndis (1.0)
130 __le32 minor_version;
131 __le32 device_flags;
132 __le32 medium; // zero == 802.3
133 __le32 max_packets_per_message;
134 __le32 max_transfer_size;
135 __le32 packet_alignment; // max 7; (1<<n) bytes
136 __le32 af_list_offset; // zero
137 __le32 af_list_size; // zero
138} __attribute__ ((packed));
139
140struct rndis_halt { /* OUT (no reply) */
141 // header and:
142 __le32 msg_type; /* RNDIS_MSG_HALT */
143 __le32 msg_len;
144 __le32 request_id;
145} __attribute__ ((packed));
146
147struct rndis_query { /* OUT */
148 // header and:
149 __le32 msg_type; /* RNDIS_MSG_QUERY */
150 __le32 msg_len;
151 __le32 request_id;
152 __le32 oid;
153 __le32 len;
154 __le32 offset;
155/*?*/ __le32 handle; // zero
156} __attribute__ ((packed));
157
158struct rndis_query_c { /* IN */
159 // header and:
160 __le32 msg_type; /* RNDIS_MSG_QUERY_C */
161 __le32 msg_len;
162 __le32 request_id;
163 __le32 status;
164 __le32 len;
165 __le32 offset;
166} __attribute__ ((packed));
167
168struct rndis_set { /* OUT */
169 // header and:
170 __le32 msg_type; /* RNDIS_MSG_SET */
171 __le32 msg_len;
172 __le32 request_id;
173 __le32 oid;
174 __le32 len;
175 __le32 offset;
176/*?*/ __le32 handle; // zero
177} __attribute__ ((packed));
178
179struct rndis_set_c { /* IN */
180 // header and:
181 __le32 msg_type; /* RNDIS_MSG_SET_C */
182 __le32 msg_len;
183 __le32 request_id;
184 __le32 status;
185} __attribute__ ((packed));
186
187struct rndis_reset { /* IN */
188 // header and:
189 __le32 msg_type; /* RNDIS_MSG_RESET */
190 __le32 msg_len;
191 __le32 reserved;
192} __attribute__ ((packed));
193
194struct rndis_reset_c { /* OUT */
195 // header and:
196 __le32 msg_type; /* RNDIS_MSG_RESET_C */
197 __le32 msg_len;
198 __le32 status;
199 __le32 addressing_lost;
200} __attribute__ ((packed));
201
202struct rndis_indicate { /* IN (unrequested) */
203 // header and:
204 __le32 msg_type; /* RNDIS_MSG_INDICATE */
205 __le32 msg_len;
206 __le32 status;
207 __le32 length;
208 __le32 offset;
209/**/ __le32 diag_status;
210 __le32 error_offset;
211/**/ __le32 message;
212} __attribute__ ((packed));
213
214struct rndis_keepalive { /* OUT (optionally IN) */
215 // header and:
216 __le32 msg_type; /* RNDIS_MSG_KEEPALIVE */
217 __le32 msg_len;
218 __le32 request_id;
219} __attribute__ ((packed));
220
221struct rndis_keepalive_c { /* IN (optionally OUT) */
222 // header and:
223 __le32 msg_type; /* RNDIS_MSG_KEEPALIVE_C */
224 __le32 msg_len;
225 __le32 request_id;
226 __le32 status;
227} __attribute__ ((packed));
228
229/* NOTE: about 30 OIDs are "mandatory" for peripherals to support ... and
230 * there are gobs more that may optionally be supported. We'll avoid as much
231 * of that mess as possible.
232 */
233#define OID_802_3_PERMANENT_ADDRESS ccpu2(0x01010101)
234#define OID_GEN_MAXIMUM_FRAME_SIZE ccpu2(0x00010106)
235#define OID_GEN_CURRENT_PACKET_FILTER ccpu2(0x0001010e)
236#define OID_GEN_PHYSICAL_MEDIUM ccpu2(0x00010202)
237
238/* packet filter bits used by OID_GEN_CURRENT_PACKET_FILTER */
239#define RNDIS_PACKET_TYPE_DIRECTED ccpu2(0x00000001)
240#define RNDIS_PACKET_TYPE_MULTICAST ccpu2(0x00000002)
241#define RNDIS_PACKET_TYPE_ALL_MULTICAST ccpu2(0x00000004)
242#define RNDIS_PACKET_TYPE_BROADCAST ccpu2(0x00000008)
243#define RNDIS_PACKET_TYPE_SOURCE_ROUTING ccpu2(0x00000010)
244#define RNDIS_PACKET_TYPE_PROMISCUOUS ccpu2(0x00000020)
245#define RNDIS_PACKET_TYPE_SMT ccpu2(0x00000040)
246#define RNDIS_PACKET_TYPE_ALL_LOCAL ccpu2(0x00000080)
247#define RNDIS_PACKET_TYPE_GROUP ccpu2(0x00001000)
248#define RNDIS_PACKET_TYPE_ALL_FUNCTIONAL ccpu2(0x00002000)
249#define RNDIS_PACKET_TYPE_FUNCTIONAL ccpu2(0x00004000)
250#define RNDIS_PACKET_TYPE_MAC_FRAME ccpu2(0x00008000)
251
252/* default filter used with RNDIS devices */
253#define RNDIS_DEFAULT_FILTER ( \
254 RNDIS_PACKET_TYPE_DIRECTED | \
255 RNDIS_PACKET_TYPE_BROADCAST | \
256 RNDIS_PACKET_TYPE_ALL_MULTICAST | \
257 RNDIS_PACKET_TYPE_PROMISCUOUS)
258
259/* Flags to require specific physical medium type for generic_rndis_bind() */
260#define FLAG_RNDIS_PHYM_NOT_WIRELESS 0x0001
261#define FLAG_RNDIS_PHYM_WIRELESS 0x0002
262
263
264extern void rndis_status(struct usbnet *dev, struct urb *urb);
265extern int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf);
266extern int
267generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags);
268extern void rndis_unbind(struct usbnet *dev, struct usb_interface *intf);
269extern int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb);
270extern struct sk_buff *
271rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags);
272
273#endif /* __RNDIS_HOST_H */
274