2 * RNDIS Definitions for Remote NDIS
4 * Authors: Benedikt Spranger, Pengutronix
5 * Robert Schwebel, Pengutronix
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2, as published by the Free Software Foundation.
11 * This software was originally developed in conformance with
12 * Microsoft's Remote NDIS Specification License Agreement.
15 #ifndef _USBGADGET_RNDIS_H
16 #define _USBGADGET_RNDIS_H
20 #define RNDIS_MAXIMUM_FRAME_SIZE 1518
21 #define RNDIS_MAX_TOTAL_SIZE 1558
23 /* Remote NDIS Versions */
24 #define RNDIS_MAJOR_VERSION 1
25 #define RNDIS_MINOR_VERSION 0
28 #define RNDIS_STATUS_SUCCESS 0x00000000U /* Success */
29 #define RNDIS_STATUS_FAILURE 0xC0000001U /* Unspecified error */
30 #define RNDIS_STATUS_INVALID_DATA 0xC0010015U /* Invalid data */
31 #define RNDIS_STATUS_NOT_SUPPORTED 0xC00000BBU /* Unsupported request */
32 #define RNDIS_STATUS_MEDIA_CONNECT 0x4001000BU /* Device connected */
33 #define RNDIS_STATUS_MEDIA_DISCONNECT 0x4001000CU /* Device disconnected */
35 * For all not specified status messages:
36 * RNDIS_STATUS_Xxx -> NDIS_STATUS_Xxx
39 /* Message Set for Connectionless (802.3) Devices */
40 #define REMOTE_NDIS_PACKET_MSG 0x00000001U
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
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
57 #define RNDIS_DF_CONNECTIONLESS 0x00000001U
58 #define RNDIS_DF_CONNECTION_ORIENTED 0x00000002U
60 #define RNDIS_MEDIUM_802_3 0x00000000U
62 /* from drivers/net/sk98lin/h/skgepnmi.h */
63 #define OID_PNP_CAPABILITIES 0xFD010100
64 #define OID_PNP_SET_POWER 0xFD010101
65 #define OID_PNP_QUERY_POWER 0xFD010102
66 #define OID_PNP_ADD_WAKE_UP_PATTERN 0xFD010103
67 #define OID_PNP_REMOVE_WAKE_UP_PATTERN 0xFD010104
68 #define OID_PNP_ENABLE_WAKE_UP 0xFD010106
71 typedef struct rndis_init_msg_type {
77 __le32 MaxTransferSize;
78 } rndis_init_msg_type;
80 typedef struct rndis_init_cmplt_type {
89 __le32 MaxPacketsPerTransfer;
90 __le32 MaxTransferSize;
91 __le32 PacketAlignmentFactor;
94 } rndis_init_cmplt_type;
96 typedef struct rndis_halt_msg_type {
100 } rndis_halt_msg_type;
102 typedef struct rndis_query_msg_type {
104 __le32 MessageLength;
107 __le32 InformationBufferLength;
108 __le32 InformationBufferOffset;
109 __le32 DeviceVcHandle;
110 } rndis_query_msg_type;
112 typedef struct rndis_query_cmplt_type {
114 __le32 MessageLength;
117 __le32 InformationBufferLength;
118 __le32 InformationBufferOffset;
119 } rndis_query_cmplt_type;
121 typedef struct rndis_set_msg_type {
123 __le32 MessageLength;
126 __le32 InformationBufferLength;
127 __le32 InformationBufferOffset;
128 __le32 DeviceVcHandle;
129 } rndis_set_msg_type;
131 typedef struct rndis_set_cmplt_type {
133 __le32 MessageLength;
136 } rndis_set_cmplt_type;
138 typedef struct rndis_reset_msg_type {
140 __le32 MessageLength;
142 } rndis_reset_msg_type;
144 typedef struct rndis_reset_cmplt_type {
146 __le32 MessageLength;
148 __le32 AddressingReset;
149 } rndis_reset_cmplt_type;
151 typedef struct rndis_indicate_status_msg_type {
153 __le32 MessageLength;
155 __le32 StatusBufferLength;
156 __le32 StatusBufferOffset;
157 } rndis_indicate_status_msg_type;
159 typedef struct rndis_keepalive_msg_type {
161 __le32 MessageLength;
163 } rndis_keepalive_msg_type;
165 typedef struct rndis_keepalive_cmplt_type {
167 __le32 MessageLength;
170 } rndis_keepalive_cmplt_type;
172 struct rndis_packet_msg_type {
174 __le32 MessageLength;
177 __le32 OOBDataOffset;
178 __le32 OOBDataLength;
179 __le32 NumOOBDataElements;
180 __le32 PerPacketInfoOffset;
181 __le32 PerPacketInfoLength;
184 } __attribute__ ((packed));
186 struct rndis_config_parameter {
187 __le32 ParameterNameOffset;
188 __le32 ParameterNameLength;
189 __le32 ParameterType;
190 __le32 ParameterValueOffset;
191 __le32 ParameterValueLength;
194 /* implementation specific */
198 RNDIS_DATA_INITIALIZED,
201 typedef struct rndis_resp_t {
202 struct list_head list;
208 typedef struct rndis_params {
212 enum rndis_state state;
219 struct eth_device *dev;
220 struct net_device_stats *stats;
224 const char *vendorDescr;
225 int (*ack)(struct eth_device *);
226 struct list_head resp_queue;
229 /* RNDIS Message parser and other useless functions */
230 int rndis_msg_parser(u8 configNr, u8 *buf);
231 enum rndis_state rndis_get_state(int configNr);
232 int rndis_register(int (*rndis_control_ack)(struct eth_device *));
233 void rndis_deregister(int configNr);
234 int rndis_set_param_dev(u8 configNr, struct eth_device *dev, int mtu,
235 struct net_device_stats *stats, u16 *cdc_filter);
236 int rndis_set_param_vendor(u8 configNr, u32 vendorID,
237 const char *vendorDescr);
238 int rndis_set_param_medium(u8 configNr, u32 medium, u32 speed);
239 void rndis_add_hdr(void *bug, int length);
240 int rndis_rm_hdr(void *bug, int length);
241 u8 *rndis_get_next_response(int configNr, u32 *length);
242 void rndis_free_response(int configNr, u8 *buf);
244 void rndis_uninit(int configNr);
245 int rndis_signal_connect(int configNr);
246 int rndis_signal_disconnect(int configNr);
247 extern void rndis_set_host_mac(int configNr, const u8 *addr);
249 int rndis_init(void);
250 void rndis_exit(void);
252 #endif /* _USBGADGET_RNDIS_H */