blob: e827af0be4aa9ac348100e9d38afec37d1f87847 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0 */
Vitaly Kuzmichev216c4472011-02-11 18:18:34 +03002/*
3 * RNDIS Definitions for Remote NDIS
4 *
5 * Authors: Benedikt Spranger, Pengutronix
6 * Robert Schwebel, Pengutronix
7 *
Vitaly Kuzmichev216c4472011-02-11 18:18:34 +03008 * This software was originally developed in conformance with
9 * Microsoft's Remote NDIS Specification License Agreement.
10 */
11
12#ifndef _USBGADGET_RNDIS_H
13#define _USBGADGET_RNDIS_H
14
15#include "ndis.h"
16
Vitaly Kuzmichev3433c332011-02-11 18:18:35 +030017/*
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.
23 */
24
Vitaly Kuzmichev216c4472011-02-11 18:18:34 +030025#define RNDIS_MAXIMUM_FRAME_SIZE 1518
26#define RNDIS_MAX_TOTAL_SIZE 1558
27
28/* Remote NDIS Versions */
29#define RNDIS_MAJOR_VERSION 1
30#define RNDIS_MINOR_VERSION 0
31
32/* Status Values */
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 */
39/*
40 * For all not specified status messages:
41 * RNDIS_STATUS_Xxx -> NDIS_STATUS_Xxx
42 */
43
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
53
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
60
61/* Device Flags */
62#define RNDIS_DF_CONNECTIONLESS 0x00000001U
63#define RNDIS_DF_CONNECTION_ORIENTED 0x00000002U
64
65#define RNDIS_MEDIUM_802_3 0x00000000U
66
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
74
75
76typedef struct rndis_init_msg_type {
77 __le32 MessageType;
78 __le32 MessageLength;
79 __le32 RequestID;
80 __le32 MajorVersion;
81 __le32 MinorVersion;
82 __le32 MaxTransferSize;
83} rndis_init_msg_type;
84
85typedef struct rndis_init_cmplt_type {
86 __le32 MessageType;
87 __le32 MessageLength;
88 __le32 RequestID;
89 __le32 Status;
90 __le32 MajorVersion;
91 __le32 MinorVersion;
92 __le32 DeviceFlags;
93 __le32 Medium;
94 __le32 MaxPacketsPerTransfer;
95 __le32 MaxTransferSize;
96 __le32 PacketAlignmentFactor;
97 __le32 AFListOffset;
98 __le32 AFListSize;
99} rndis_init_cmplt_type;
100
101typedef struct rndis_halt_msg_type {
102 __le32 MessageType;
103 __le32 MessageLength;
104 __le32 RequestID;
105} rndis_halt_msg_type;
106
107typedef struct rndis_query_msg_type {
108 __le32 MessageType;
109 __le32 MessageLength;
110 __le32 RequestID;
111 __le32 OID;
112 __le32 InformationBufferLength;
113 __le32 InformationBufferOffset;
114 __le32 DeviceVcHandle;
115} rndis_query_msg_type;
116
117typedef struct rndis_query_cmplt_type {
118 __le32 MessageType;
119 __le32 MessageLength;
120 __le32 RequestID;
121 __le32 Status;
122 __le32 InformationBufferLength;
123 __le32 InformationBufferOffset;
124} rndis_query_cmplt_type;
125
126typedef struct rndis_set_msg_type {
127 __le32 MessageType;
128 __le32 MessageLength;
129 __le32 RequestID;
130 __le32 OID;
131 __le32 InformationBufferLength;
132 __le32 InformationBufferOffset;
133 __le32 DeviceVcHandle;
134} rndis_set_msg_type;
135
136typedef struct rndis_set_cmplt_type {
137 __le32 MessageType;
138 __le32 MessageLength;
139 __le32 RequestID;
140 __le32 Status;
141} rndis_set_cmplt_type;
142
143typedef struct rndis_reset_msg_type {
144 __le32 MessageType;
145 __le32 MessageLength;
146 __le32 Reserved;
147} rndis_reset_msg_type;
148
149typedef struct rndis_reset_cmplt_type {
150 __le32 MessageType;
151 __le32 MessageLength;
152 __le32 Status;
153 __le32 AddressingReset;
154} rndis_reset_cmplt_type;
155
156typedef struct rndis_indicate_status_msg_type {
157 __le32 MessageType;
158 __le32 MessageLength;
159 __le32 Status;
160 __le32 StatusBufferLength;
161 __le32 StatusBufferOffset;
162} rndis_indicate_status_msg_type;
163
164typedef struct rndis_keepalive_msg_type {
165 __le32 MessageType;
166 __le32 MessageLength;
167 __le32 RequestID;
168} rndis_keepalive_msg_type;
169
170typedef struct rndis_keepalive_cmplt_type {
171 __le32 MessageType;
172 __le32 MessageLength;
173 __le32 RequestID;
174 __le32 Status;
175} rndis_keepalive_cmplt_type;
176
177struct rndis_packet_msg_type {
178 __le32 MessageType;
179 __le32 MessageLength;
180 __le32 DataOffset;
181 __le32 DataLength;
182 __le32 OOBDataOffset;
183 __le32 OOBDataLength;
184 __le32 NumOOBDataElements;
185 __le32 PerPacketInfoOffset;
186 __le32 PerPacketInfoLength;
187 __le32 VcHandle;
188 __le32 Reserved;
189} __attribute__ ((packed));
190
191struct rndis_config_parameter {
192 __le32 ParameterNameOffset;
193 __le32 ParameterNameLength;
194 __le32 ParameterType;
195 __le32 ParameterValueOffset;
196 __le32 ParameterValueLength;
197};
198
199/* implementation specific */
200enum rndis_state {
201 RNDIS_UNINITIALIZED,
202 RNDIS_INITIALIZED,
203 RNDIS_DATA_INITIALIZED,
204};
205
206typedef struct rndis_resp_t {
207 struct list_head list;
208 u8 *buf;
209 u32 length;
210 int send;
211} rndis_resp_t;
212
213typedef struct rndis_params {
214 u8 confignr;
215 u8 used;
216 u16 saved_filter;
217 enum rndis_state state;
218 u32 medium;
219 u32 speed;
220 u32 media_state;
221
222 const u8 *host_mac;
223 u16 *filter;
Vitaly Kuzmichev216c4472011-02-11 18:18:34 +0300224 struct net_device_stats *stats;
225 int mtu;
226
227 u32 vendorID;
228 const char *vendorDescr;
Mugunthan V N095b7612016-11-18 11:09:15 +0530229#ifndef CONFIG_DM_ETH
230 struct eth_device *dev;
231 int (*ack)(struct eth_device *);
232#else
233 struct udevice *dev;
234 int (*ack)(struct udevice *);
235#endif
Vitaly Kuzmichev216c4472011-02-11 18:18:34 +0300236 struct list_head resp_queue;
237} rndis_params;
238
239/* RNDIS Message parser and other useless functions */
240int rndis_msg_parser(u8 configNr, u8 *buf);
241enum rndis_state rndis_get_state(int configNr);
Vitaly Kuzmichev216c4472011-02-11 18:18:34 +0300242void rndis_deregister(int configNr);
Mugunthan V N095b7612016-11-18 11:09:15 +0530243#ifndef CONFIG_DM_ETH
244int rndis_register(int (*rndis_control_ack)(struct eth_device *));
Vitaly Kuzmichev216c4472011-02-11 18:18:34 +0300245int rndis_set_param_dev(u8 configNr, struct eth_device *dev, int mtu,
Mugunthan V N095b7612016-11-18 11:09:15 +0530246 struct net_device_stats *stats, u16 *cdc_filter);
247#else
248int rndis_register(int (*rndis_control_ack)(struct udevice *));
249int rndis_set_param_dev(u8 configNr, struct udevice *dev, int mtu,
250 struct net_device_stats *stats, u16 *cdc_filter);
251#endif
Vitaly Kuzmichev216c4472011-02-11 18:18:34 +0300252int rndis_set_param_vendor(u8 configNr, u32 vendorID,
253 const char *vendorDescr);
254int rndis_set_param_medium(u8 configNr, u32 medium, u32 speed);
255void rndis_add_hdr(void *bug, int length);
256int rndis_rm_hdr(void *bug, int length);
257u8 *rndis_get_next_response(int configNr, u32 *length);
258void rndis_free_response(int configNr, u8 *buf);
259
260void rndis_uninit(int configNr);
261int rndis_signal_connect(int configNr);
262int rndis_signal_disconnect(int configNr);
263extern void rndis_set_host_mac(int configNr, const u8 *addr);
264
265int rndis_init(void);
266void rndis_exit(void);
267
268#endif /* _USBGADGET_RNDIS_H */