1 /* SPDX-License-Identifier: GPL-2.0 */
3 * RNDIS Definitions for Remote NDIS
5 * Authors: Benedikt Spranger, Pengutronix
6 * Robert Schwebel, Pengutronix
8 * This software was originally developed in conformance with
9 * Microsoft's Remote NDIS Specification License Agreement.
12 #ifndef _USBGADGET_RNDIS_H
13 #define _USBGADGET_RNDIS_H
18 * By default rndis_signal_disconnect does not send status message about
19 * RNDIS disconnection to USB host (indicated as cable disconnected).
20 * Define RNDIS_COMPLETE_SIGNAL_DISCONNECT to send it.
21 * However, this will cause 1 sec delay on Ethernet device halt.
22 * Usually you do not need to define it. Mostly usable for debugging.
25 #define RNDIS_MAXIMUM_FRAME_SIZE 1518
26 #define RNDIS_MAX_TOTAL_SIZE 1558
28 /* Remote NDIS Versions */
29 #define RNDIS_MAJOR_VERSION 1
30 #define RNDIS_MINOR_VERSION 0
33 #define RNDIS_STATUS_SUCCESS 0x00000000U /* Success */
34 #define RNDIS_STATUS_FAILURE 0xC0000001U /* Unspecified error */
35 #define RNDIS_STATUS_INVALID_DATA 0xC0010015U /* Invalid data */
36 #define RNDIS_STATUS_NOT_SUPPORTED 0xC00000BBU /* Unsupported request */
37 #define RNDIS_STATUS_MEDIA_CONNECT 0x4001000BU /* Device connected */
38 #define RNDIS_STATUS_MEDIA_DISCONNECT 0x4001000CU /* Device disconnected */
40 * For all not specified status messages:
41 * RNDIS_STATUS_Xxx -> NDIS_STATUS_Xxx
44 /* Message Set for Connectionless (802.3) Devices */
45 #define REMOTE_NDIS_PACKET_MSG 0x00000001U
46 #define REMOTE_NDIS_INITIALIZE_MSG 0x00000002U /* Initialize device */
47 #define REMOTE_NDIS_HALT_MSG 0x00000003U
48 #define REMOTE_NDIS_QUERY_MSG 0x00000004U
49 #define REMOTE_NDIS_SET_MSG 0x00000005U
50 #define REMOTE_NDIS_RESET_MSG 0x00000006U
51 #define REMOTE_NDIS_INDICATE_STATUS_MSG 0x00000007U
52 #define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008U
54 /* Message completion */
55 #define REMOTE_NDIS_INITIALIZE_CMPLT 0x80000002U
56 #define REMOTE_NDIS_QUERY_CMPLT 0x80000004U
57 #define REMOTE_NDIS_SET_CMPLT 0x80000005U
58 #define REMOTE_NDIS_RESET_CMPLT 0x80000006U
59 #define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008U
62 #define RNDIS_DF_CONNECTIONLESS 0x00000001U
63 #define RNDIS_DF_CONNECTION_ORIENTED 0x00000002U
65 #define RNDIS_MEDIUM_802_3 0x00000000U
67 /* from drivers/net/sk98lin/h/skgepnmi.h */
68 #define OID_PNP_CAPABILITIES 0xFD010100
69 #define OID_PNP_SET_POWER 0xFD010101
70 #define OID_PNP_QUERY_POWER 0xFD010102
71 #define OID_PNP_ADD_WAKE_UP_PATTERN 0xFD010103
72 #define OID_PNP_REMOVE_WAKE_UP_PATTERN 0xFD010104
73 #define OID_PNP_ENABLE_WAKE_UP 0xFD010106
76 typedef struct rndis_init_msg_type {
82 __le32 MaxTransferSize;
83 } rndis_init_msg_type;
85 typedef struct rndis_init_cmplt_type {
94 __le32 MaxPacketsPerTransfer;
95 __le32 MaxTransferSize;
96 __le32 PacketAlignmentFactor;
99 } rndis_init_cmplt_type;
101 typedef struct rndis_halt_msg_type {
103 __le32 MessageLength;
105 } rndis_halt_msg_type;
107 typedef struct rndis_query_msg_type {
109 __le32 MessageLength;
112 __le32 InformationBufferLength;
113 __le32 InformationBufferOffset;
114 __le32 DeviceVcHandle;
115 } rndis_query_msg_type;
117 typedef struct rndis_query_cmplt_type {
119 __le32 MessageLength;
122 __le32 InformationBufferLength;
123 __le32 InformationBufferOffset;
124 } rndis_query_cmplt_type;
126 typedef struct rndis_set_msg_type {
128 __le32 MessageLength;
131 __le32 InformationBufferLength;
132 __le32 InformationBufferOffset;
133 __le32 DeviceVcHandle;
134 } rndis_set_msg_type;
136 typedef struct rndis_set_cmplt_type {
138 __le32 MessageLength;
141 } rndis_set_cmplt_type;
143 typedef struct rndis_reset_msg_type {
145 __le32 MessageLength;
147 } rndis_reset_msg_type;
149 typedef struct rndis_reset_cmplt_type {
151 __le32 MessageLength;
153 __le32 AddressingReset;
154 } rndis_reset_cmplt_type;
156 typedef struct rndis_indicate_status_msg_type {
158 __le32 MessageLength;
160 __le32 StatusBufferLength;
161 __le32 StatusBufferOffset;
162 } rndis_indicate_status_msg_type;
164 typedef struct rndis_keepalive_msg_type {
166 __le32 MessageLength;
168 } rndis_keepalive_msg_type;
170 typedef struct rndis_keepalive_cmplt_type {
172 __le32 MessageLength;
175 } rndis_keepalive_cmplt_type;
177 struct rndis_packet_msg_type {
179 __le32 MessageLength;
182 __le32 OOBDataOffset;
183 __le32 OOBDataLength;
184 __le32 NumOOBDataElements;
185 __le32 PerPacketInfoOffset;
186 __le32 PerPacketInfoLength;
189 } __attribute__ ((packed));
191 struct rndis_config_parameter {
192 __le32 ParameterNameOffset;
193 __le32 ParameterNameLength;
194 __le32 ParameterType;
195 __le32 ParameterValueOffset;
196 __le32 ParameterValueLength;
199 /* implementation specific */
203 RNDIS_DATA_INITIALIZED,
206 typedef struct rndis_resp_t {
207 struct list_head list;
213 typedef struct rndis_params {
217 enum rndis_state state;
224 struct net_device_stats *stats;
228 const char *vendorDescr;
229 #ifndef CONFIG_DM_ETH
230 struct eth_device *dev;
231 int (*ack)(struct eth_device *);
234 int (*ack)(struct udevice *);
236 struct list_head resp_queue;
239 /* RNDIS Message parser and other useless functions */
240 int rndis_msg_parser(u8 configNr, u8 *buf);
241 enum rndis_state rndis_get_state(int configNr);
242 void rndis_deregister(int configNr);
243 #ifndef CONFIG_DM_ETH
244 int rndis_register(int (*rndis_control_ack)(struct eth_device *));
245 int rndis_set_param_dev(u8 configNr, struct eth_device *dev, int mtu,
246 struct net_device_stats *stats, u16 *cdc_filter);
248 int rndis_register(int (*rndis_control_ack)(struct udevice *));
249 int rndis_set_param_dev(u8 configNr, struct udevice *dev, int mtu,
250 struct net_device_stats *stats, u16 *cdc_filter);
252 int rndis_set_param_vendor(u8 configNr, u32 vendorID,
253 const char *vendorDescr);
254 int rndis_set_param_medium(u8 configNr, u32 medium, u32 speed);
255 void rndis_add_hdr(void *bug, int length);
256 int rndis_rm_hdr(void *bug, int length);
257 u8 *rndis_get_next_response(int configNr, u32 *length);
258 void rndis_free_response(int configNr, u8 *buf);
260 void rndis_uninit(int configNr);
261 int rndis_signal_connect(int configNr);
262 int rndis_signal_disconnect(int configNr);
263 extern void rndis_set_host_mac(int configNr, const u8 *addr);
265 int rndis_init(void);
266 void rndis_exit(void);
268 #endif /* _USBGADGET_RNDIS_H */