patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / drivers / usb / gadget / rndis.h
1 /* 
2  * RNDIS        Definitions for Remote NDIS
3  * 
4  * Version:     $Id: rndis.h,v 1.15 2004/03/25 21:33:46 robert Exp $
5  * 
6  * Authors:     Benedikt Spranger, Pengutronix
7  *              Robert Schwebel, Pengutronix
8  * 
9  *              This program is free software; you can redistribute it and/or
10  *              modify it under the terms of the GNU General Public License
11  *              version 2, as published by the Free Software Foundation. 
12  * 
13  *              This software was originally developed in conformance with
14  *              Microsoft's Remote NDIS Specification License Agreement.
15  */
16
17 #ifndef _LINUX_RNDIS_H
18 #define _LINUX_RNDIS_H
19
20 #include "ndis.h"
21
22 #define RNDIS_MAXIMUM_FRAME_SIZE        1518
23 #define RNDIS_MAX_TOTAL_SIZE            1558
24
25 /* Remote NDIS Versions */
26 #define RNDIS_MAJOR_VERSION             1
27 #define RNDIS_MINOR_VERSION             0
28
29 /* Status Values */
30 #define RNDIS_STATUS_SUCCESS            0x00000000U     /* Success           */
31 #define RNDIS_STATUS_FAILURE            0xC0000001U     /* Unspecified error */
32 #define RNDIS_STATUS_INVALID_DATA       0xC0010015U     /* Invalid data      */
33 #define RNDIS_STATUS_NOT_SUPPORTED      0xC00000BBU     /* Unsupported request */
34 #define RNDIS_STATUS_MEDIA_CONNECT      0x4001000BU     /* Device connected  */
35 #define RNDIS_STATUS_MEDIA_DISCONNECT   0x4001000CU     /* Device disconnected */
36 /* For all not specified status messages:
37  * RNDIS_STATUS_Xxx -> NDIS_STATUS_Xxx 
38  */
39
40 /* Message Set for Connectionless (802.3) Devices */
41 #define REMOTE_NDIS_INITIALIZE_MSG      0x00000002U     /* Initialize device */
42 #define REMOTE_NDIS_HALT_MSG            0x00000003U
43 #define REMOTE_NDIS_QUERY_MSG           0x00000004U
44 #define REMOTE_NDIS_SET_MSG             0x00000005U
45 #define REMOTE_NDIS_RESET_MSG           0x00000006U
46 #define REMOTE_NDIS_INDICATE_STATUS_MSG 0x00000007U
47 #define REMOTE_NDIS_KEEPALIVE_MSG       0x00000008U
48
49 /* Message completion */
50 #define REMOTE_NDIS_INITIALIZE_CMPLT    0x80000002U
51 #define REMOTE_NDIS_QUERY_CMPLT         0x80000004U
52 #define REMOTE_NDIS_SET_CMPLT           0x80000005U
53 #define REMOTE_NDIS_RESET_CMPLT         0x80000006U
54 #define REMOTE_NDIS_KEEPALIVE_CMPLT     0x80000008U
55
56 /* Device Flags */
57 #define RNDIS_DF_CONNECTIONLESS         0x00000001U
58 #define RNDIS_DF_CONNECTION_ORIENTED    0x00000002U
59
60 #define RNDIS_MEDIUM_802_3              0x00000000U
61
62 /* supported OIDs */
63 static const u32 oid_supported_list [] = 
64 {
65         /* mandatory general */
66         /* the general stuff */
67         OID_GEN_SUPPORTED_LIST,
68         OID_GEN_HARDWARE_STATUS,
69         OID_GEN_MEDIA_SUPPORTED,
70         OID_GEN_MEDIA_IN_USE,
71         OID_GEN_MAXIMUM_FRAME_SIZE,
72         OID_GEN_LINK_SPEED,
73         OID_GEN_TRANSMIT_BUFFER_SPACE,
74         OID_GEN_TRANSMIT_BLOCK_SIZE,
75         OID_GEN_RECEIVE_BLOCK_SIZE,
76         OID_GEN_VENDOR_ID,
77         OID_GEN_VENDOR_DESCRIPTION,
78         OID_GEN_VENDOR_DRIVER_VERSION,
79         OID_GEN_CURRENT_PACKET_FILTER,
80         OID_GEN_MAXIMUM_TOTAL_SIZE,
81         OID_GEN_MAC_OPTIONS,
82         OID_GEN_MEDIA_CONNECT_STATUS,
83         OID_GEN_PHYSICAL_MEDIUM,
84         OID_GEN_RNDIS_CONFIG_PARAMETER,
85         
86         /* the statistical stuff */
87         OID_GEN_XMIT_OK,
88         OID_GEN_RCV_OK,
89         OID_GEN_XMIT_ERROR,
90         OID_GEN_RCV_ERROR,
91         OID_GEN_RCV_NO_BUFFER,
92         OID_GEN_DIRECTED_BYTES_XMIT,
93         OID_GEN_DIRECTED_FRAMES_XMIT,
94         OID_GEN_MULTICAST_BYTES_XMIT,
95         OID_GEN_MULTICAST_FRAMES_XMIT,
96         OID_GEN_BROADCAST_BYTES_XMIT,
97         OID_GEN_BROADCAST_FRAMES_XMIT,
98         OID_GEN_DIRECTED_BYTES_RCV,
99         OID_GEN_DIRECTED_FRAMES_RCV,
100         OID_GEN_MULTICAST_BYTES_RCV,
101         OID_GEN_MULTICAST_FRAMES_RCV,
102         OID_GEN_BROADCAST_BYTES_RCV,
103         OID_GEN_BROADCAST_FRAMES_RCV,
104         OID_GEN_RCV_CRC_ERROR,
105         OID_GEN_TRANSMIT_QUEUE_LENGTH,
106
107         /* mandatory 802.3 */
108         /* the general stuff */
109         OID_802_3_PERMANENT_ADDRESS,
110         OID_802_3_CURRENT_ADDRESS,
111         OID_802_3_MULTICAST_LIST,
112         OID_802_3_MAC_OPTIONS,
113         OID_802_3_MAXIMUM_LIST_SIZE,
114         
115         /* the statistical stuff */
116         OID_802_3_RCV_ERROR_ALIGNMENT,
117         OID_802_3_XMIT_ONE_COLLISION,
118         OID_802_3_XMIT_MORE_COLLISIONS
119 };
120
121
122 typedef struct rndis_init_msg_type 
123 {
124         u32     MessageType;
125         u32     MessageLength;
126         u32     RequestID;
127         u32     MajorVersion;
128         u32     MinorVersion;
129         u32     MaxTransferSize;
130 } rndis_init_msg_type;
131
132 typedef struct rndis_init_cmplt_type
133 {
134         u32     MessageType;
135         u32     MessageLength;
136         u32     RequestID;
137         u32     Status;
138         u32     MajorVersion;
139         u32     MinorVersion;
140         u32     DeviceFlags;
141         u32     Medium;
142         u32     MaxPacketsPerTransfer;
143         u32     MaxTransferSize;
144         u32     PacketAlignmentFactor;
145         u32     AFListOffset;
146         u32     AFListSize;
147 } rndis_init_cmplt_type;
148
149 typedef struct rndis_halt_msg_type
150 {
151         u32     MessageType;
152         u32     MessageLength;
153         u32     RequestID;
154 } rndis_halt_msg_type;
155
156 typedef struct rndis_query_msg_type
157 {
158         u32     MessageType;
159         u32     MessageLength;
160         u32     RequestID;
161         u32     OID;
162         u32     InformationBufferLength;
163         u32     InformationBufferOffset;
164         u32     DeviceVcHandle;
165 } rndis_query_msg_type;
166
167 typedef struct rndis_query_cmplt_type
168 {
169         u32     MessageType;
170         u32     MessageLength;
171         u32     RequestID;
172         u32     Status;
173         u32     InformationBufferLength;
174         u32     InformationBufferOffset;
175 } rndis_query_cmplt_type;
176
177 typedef struct rndis_set_msg_type
178 {
179         u32     MessageType;
180         u32     MessageLength;
181         u32     RequestID;
182         u32     OID;
183         u32     InformationBufferLength;
184         u32     InformationBufferOffset;
185         u32     DeviceVcHandle;
186 } rndis_set_msg_type;
187
188 typedef struct rndis_set_cmplt_type
189 {
190         u32     MessageType;
191         u32     MessageLength;
192         u32     RequestID;
193         u32     Status;
194 } rndis_set_cmplt_type;
195
196 typedef struct rndis_reset_msg_type
197 {
198         u32     MessageType;
199         u32     MessageLength;
200         u32     Reserved;
201 } rndis_reset_msg_type;
202
203 typedef struct rndis_reset_cmplt_type
204 {
205         u32     MessageType;
206         u32     MessageLength;
207         u32     Status;
208         u32     AddressingReset;
209 } rndis_reset_cmplt_type;
210
211 typedef struct rndis_indicate_status_msg_type
212 {
213         u32     MessageType;
214         u32     MessageLength;
215         u32     Status;
216         u32     StatusBufferLength;
217         u32     StatusBufferOffset;
218 } rndis_indicate_status_msg_type;
219
220 typedef struct rndis_keepalive_msg_type
221 {
222         u32     MessageType;
223         u32     MessageLength;
224         u32     RequestID;
225 } rndis_keepalive_msg_type;
226
227 typedef struct rndis_keepalive_cmplt_type
228 {
229         u32     MessageType;
230         u32     MessageLength;
231         u32     RequestID;
232         u32     Status;
233 } rndis_keepalive_cmplt_type;
234
235 struct rndis_packet_msg_type
236 {
237         u32     MessageType;
238         u32     MessageLength;
239         u32     DataOffset;
240         u32     DataLength;
241         u32     OOBDataOffset;
242         u32     OOBDataLength;
243         u32     NumOOBDataElements;
244         u32     PerPacketInfoOffset;
245         u32     PerPacketInfoLength;
246         u32     VcHandle;
247         u32     Reserved;
248 };
249
250 struct rndis_config_parameter
251 {
252         u32     ParameterNameOffset;
253         u32     ParameterNameLength;
254         u32     ParameterType;
255         u32     ParameterValueOffset;
256         u32     ParameterValueLength;
257 };
258
259 /* implementation specific */
260 enum rndis_state
261 {
262         RNDIS_UNINITIALIZED,
263         RNDIS_INITIALIZED,
264         RNDIS_DATA_INITIALIZED,
265 };
266
267 typedef struct rndis_resp_t
268 {
269         struct list_head        list;
270         u8                      *buf;
271         u32                     length;
272         int                     send;
273 } rndis_resp_t;
274
275 typedef struct rndis_params
276 {
277         u8                      confignr;
278         int                     used;
279         enum rndis_state        state;
280         u32                     filter;
281         u32                     medium;
282         u32                     speed;
283         u32                     media_state;
284         const u8                *host_mac;
285         struct net_device       *dev;
286         struct net_device_stats *stats;
287         u32                     vendorID;
288         const char              *vendorDescr;
289         int                     (*ack) (struct net_device *);
290         struct list_head        resp_queue;
291 } rndis_params;
292
293 /* RNDIS Message parser and other useless functions */
294 int  rndis_msg_parser (u8 configNr, u8 *buf);
295 int  rndis_register (int (*rndis_control_ack) (struct net_device *));
296 void rndis_deregister (int configNr);
297 int  rndis_set_param_dev (u8 configNr, struct net_device *dev,
298                          struct net_device_stats *stats);
299 int  rndis_set_param_vendor (u8 configNr, u32 vendorID, 
300                             const char *vendorDescr);
301 int  rndis_set_param_medium (u8 configNr, u32 medium, u32 speed);
302 void rndis_add_hdr (struct sk_buff *skb);
303 int  rndis_rm_hdr (u8 *buf, u32 *length);
304 u8   *rndis_get_next_response (int configNr, u32 *length);
305 void rndis_free_response (int configNr, u8 *buf);
306
307 int  rndis_signal_connect (int configNr);
308 int  rndis_signal_disconnect (int configNr);
309 int  rndis_state (int configNr);
310 extern void rndis_set_host_mac (int configNr, const u8 *addr);
311
312 int __init rndis_init (void);
313 void rndis_exit (void);
314
315 #endif  /* _LINUX_RNDIS_H */