xref: /openbsd/sys/dev/rndis.h (revision 4b1a56af)
1 /*	$OpenBSD: rndis.h,v 1.3 2022/01/09 05:42:37 jsg Exp $ */
2 
3 /*
4  * Copyright (c) 2010 Jonathan Armani <armani@openbsd.org>
5  * Copyright (c) 2010 Fabien Romano <fabien@openbsd.org>
6  * Copyright (c) 2010 Michael Knudsen <mk@openbsd.org>
7  * All rights reserved.
8  *
9  * Permission to use, copy, modify, and distribute this software for any
10  * purpose with or without fee is hereby granted, provided that the above
11  * copyright notice and this permission notice appear in all copies.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20  */
21 
22 #ifndef _DEV_RNDIS_H_
23 #define _DEV_RNDIS_H_
24 
25 /* Canonical major/minor version as of 22th Aug. 2016. */
26 #define RNDIS_VERSION_MAJOR		0x00000001
27 #define RNDIS_VERSION_MINOR		0x00000000
28 
29 #define RNDIS_STATUS_SUCCESS 		0x00000000L
30 #define RNDIS_STATUS_PENDING 		0x00000103L
31 #define RNDIS_STATUS_MEDIA_CONNECT 	0x4001000BL
32 #define RNDIS_STATUS_MEDIA_DISCONNECT 	0x4001000CL
33 #define RNDIS_STATUS_BUFFER_OVERFLOW 	0x80000005L
34 #define RNDIS_STATUS_FAILURE 		0xC0000001L
35 #define RNDIS_STATUS_NOT_SUPPORTED 	0xC00000BBL
36 #define RNDIS_STATUS_RESOURCES 		0xC000009AL
37 #define RNDIS_STATUS_INVALID_DATA 	0xC0010015L
38 #define RNDIS_STATUS_OFFLOAD_CURRENT_CONFIG	0x40020006
39 
40 #define OID_GEN_SUPPORTED_LIST		0x00010101
41 #define OID_GEN_HARDWARE_STATUS		0x00010102
42 #define OID_GEN_MEDIA_SUPPORTED		0x00010103
43 #define OID_GEN_MEDIA_IN_USE		0x00010104
44 #define OID_GEN_MAXIMUM_LOOKAHEAD	0x00010105
45 #define OID_GEN_MAXIMUM_FRAME_SIZE	0x00010106
46 #define OID_GEN_LINK_SPEED		0x00010107
47 #define OID_GEN_TRANSMIT_BUFFER_SPACE	0x00010108
48 #define OID_GEN_RECEIVE_BUFFER_SPACE	0x00010109
49 #define OID_GEN_TRANSMIT_BLOCK_SIZE	0x0001010A
50 #define OID_GEN_RECEIVE_BLOCK_SIZE	0x0001010B
51 #define OID_GEN_VENDOR_ID		0x0001010C
52 #define OID_GEN_VENDOR_DESCRIPTION	0x0001010D
53 #define OID_GEN_CURRENT_PACKET_FILTER	0x0001010E
54 #define OID_GEN_CURRENT_LOOKAHEAD	0x0001010F
55 #define OID_GEN_DRIVER_VERSION		0x00010110
56 #define OID_GEN_MAXIMUM_TOTAL_SIZE	0x00010111
57 #define OID_GEN_PROTOCOL_OPTIONS	0x00010112
58 #define OID_GEN_MAC_OPTIONS		0x00010113
59 #define OID_GEN_MEDIA_CONNECT_STATUS	0x00010114
60 #define OID_GEN_MAXIMUM_SEND_PACKETS	0x00010115
61 #define OID_GEN_VENDOR_DRIVER_VERSION	0x00010116
62 #define OID_GEN_SUPPORTED_GUIDS		0x00010117
63 #define OID_GEN_NETWORK_LAYER_ADDRESSES	0x00010118
64 #define OID_GEN_TRANSPORT_HEADER_OFFSET	0x00010119
65 #define OID_GEN_RECEIVE_SCALE_CAPABILITIES	0x00010203
66 #define OID_GEN_RECEIVE_SCALE_PARAMETERS	0x00010204
67 #define OID_GEN_MACHINE_NAME		0x0001021A
68 #define OID_GEN_RNDIS_CONFIG_PARAMETER	0x0001021B
69 #define OID_GEN_VLAN_ID			0x0001021C
70 
71 #define OID_802_3_PERMANENT_ADDRESS	0x01010101
72 #define OID_802_3_CURRENT_ADDRESS	0x01010102
73 #define OID_802_3_MULTICAST_LIST	0x01010103
74 #define OID_802_3_MAXIMUM_LIST_SIZE	0x01010104
75 #define OID_802_3_MAC_OPTIONS		0x01010105
76 #define OID_802_3_RCV_ERROR_ALIGNMENT	0x01020101
77 #define OID_802_3_XMIT_ONE_COLLISION	0x01020102
78 #define OID_802_3_XMIT_MORE_COLLISIONS	0x01020103
79 #define OID_802_3_XMIT_DEFERRED		0x01020201
80 #define OID_802_3_XMIT_MAX_COLLISIONS	0x01020202
81 #define OID_802_3_RCV_OVERRUN		0x01020203
82 #define OID_802_3_XMIT_UNDERRUN		0x01020204
83 #define OID_802_3_XMIT_HEARTBEAT_FAILURE	0x01020205
84 #define OID_802_3_XMIT_TIMES_CRS_LOST	0x01020206
85 #define OID_802_3_XMIT_LATE_COLLISIONS	0x01020207
86 
87 #define OID_TCP_OFFLOAD_PARAMETERS	0xFC01020C
88 
89 #define RNDIS_MEDIUM_802_3		0x00000000
90 
91 /* Device flags */
92 #define RNDIS_DF_CONNECTIONLESS		0x00000001
93 #define RNDIS_DF_CONNECTION_ORIENTED	0x00000002
94 
95 /*
96  * Common RNDIS message header.
97  */
98 struct rndis_msghdr {
99 	uint32_t	rm_type;
100 	uint32_t	rm_len;
101 };
102 
103 /*
104  * RNDIS data message
105  */
106 #define REMOTE_NDIS_PACKET_MSG		0x00000001
107 
108 
109 struct rndis_packet_msg {
110 	uint32_t	rm_type;
111 	uint32_t	rm_len;
112 	uint32_t	rm_dataoffset;
113 	uint32_t	rm_datalen;
114 	uint32_t	rm_oobdataoffset;
115 	uint32_t	rm_oobdatalen;
116 	uint32_t	rm_oobdataelements;
117 	uint32_t	rm_pktinfooffset;
118 	uint32_t	rm_pktinfolen;
119 	uint32_t	rm_vchandle;
120 	uint32_t	rm_reserved;
121 };
122 
123 /* Per-packet-info for RNDIS data message */
124 struct rndis_pktinfo {
125 	uint32_t	rm_size;
126 	uint32_t	rm_type;		/* NDIS_PKTINFO_TYPE_ */
127 	uint32_t	rm_pktinfooffset;
128 	uint8_t		rm_data[0];
129 };
130 
131 #define NDIS_PKTINFO_TYPE_CSUM		0
132 #define NDIS_PKTINFO_TYPE_IPSEC		1
133 #define NDIS_PKTINFO_TYPE_LSO		2
134 #define NDIS_PKTINFO_TYPE_CLASSIFY	3
135 /* reserved 4 */
136 #define NDIS_PKTINFO_TYPE_SGLIST	5
137 #define NDIS_PKTINFO_TYPE_VLAN		6
138 #define NDIS_PKTINFO_TYPE_ORIG		7
139 #define NDIS_PKTINFO_TYPE_PKT_CANCELID	8
140 #define NDIS_PKTINFO_TYPE_ORIG_NBLIST	9
141 #define NDIS_PKTINFO_TYPE_CACHE_NBLIST	10
142 #define NDIS_PKTINFO_TYPE_PKT_PAD	11
143 
144 /*
145  * RNDIS control messages
146  */
147 struct rndis_comp_hdr {
148 	uint32_t	rm_type;
149 	uint32_t	rm_len;
150 	uint32_t	rm_rid;
151 	uint32_t	rm_status;
152 };
153 
154 /* Initialize the device. */
155 #define REMOTE_NDIS_INITIALIZE_MSG	0x00000002
156 #define REMOTE_NDIS_INITIALIZE_CMPLT	0x80000002
157 
158 struct rndis_init_req {
159 	uint32_t	rm_type;
160 	uint32_t	rm_len;
161 	uint32_t	rm_rid;
162 	uint32_t	rm_ver_major;
163 	uint32_t	rm_ver_minor;
164 	uint32_t	rm_max_xfersz;
165 };
166 
167 struct rndis_init_comp {
168 	uint32_t	rm_type;
169 	uint32_t	rm_len;
170 	uint32_t	rm_rid;
171 	uint32_t	rm_status;
172 	uint32_t	rm_ver_major;
173 	uint32_t	rm_ver_minor;
174 	uint32_t	rm_devflags;
175 	uint32_t	rm_medium;
176 	uint32_t	rm_pktmaxcnt;
177 	uint32_t	rm_pktmaxsz;
178 	uint32_t	rm_align;
179 	uint32_t	rm_aflistoffset;
180 	uint32_t	rm_aflistsz;
181 };
182 
183 /* Halt the device.  No response sent. */
184 #define REMOTE_NDIS_HALT_MSG		0x00000003
185 
186 struct rndis_halt_req {
187 	uint32_t	rm_type;
188 	uint32_t	rm_len;
189 	uint32_t	rm_rid;
190 };
191 
192 /* Send a query object. */
193 #define REMOTE_NDIS_QUERY_MSG		0x00000004
194 #define REMOTE_NDIS_QUERY_CMPLT		0x80000004
195 
196 struct rndis_query_req {
197 	uint32_t	rm_type;
198 	uint32_t	rm_len;
199 	uint32_t	rm_rid;
200 	uint32_t	rm_oid;
201 	uint32_t	rm_infobuflen;
202 	uint32_t	rm_infobufoffset;
203 	uint32_t	rm_devicevchdl;
204 };
205 
206 struct rndis_query_comp {
207 	uint32_t	rm_type;
208 	uint32_t	rm_len;
209 	uint32_t	rm_rid;
210 	uint32_t	rm_status;
211 	uint32_t	rm_infobuflen;
212 	uint32_t	rm_infobufoffset;
213 };
214 
215 /* Send a set object request. */
216 #define REMOTE_NDIS_SET_MSG		0x00000005
217 #define REMOTE_NDIS_SET_CMPLT		0x80000005
218 
219 struct rndis_set_req {
220 	uint32_t	rm_type;
221 	uint32_t	rm_len;
222 	uint32_t	rm_rid;
223 	uint32_t	rm_oid;
224 	uint32_t	rm_infobuflen;
225 	uint32_t	rm_infobufoffset;
226 	uint32_t	rm_devicevchdl;
227 };
228 
229 struct rndis_set_comp {
230 	uint32_t	rm_type;
231 	uint32_t	rm_len;
232 	uint32_t	rm_rid;
233 	uint32_t	rm_status;
234 };
235 
236 /* Parameter used by OID_GEN_RNDIS_CONFIG_PARAMETER. */
237 #define REMOTE_NDIS_SET_PARAM_NUMERIC	0x00000000
238 #define REMOTE_NDIS_SET_PARAM_STRING	0x00000002
239 
240 struct rndis_set_parameter {
241 	uint32_t	rm_nameoffset;
242 	uint32_t	rm_namelen;
243 	uint32_t	rm_type;
244 	uint32_t	rm_valueoffset;
245 	uint32_t	rm_valuelen;
246 };
247 
248 /* Perform a soft reset on the device. */
249 #define REMOTE_NDIS_RESET_MSG		0x00000006
250 #define REMOTE_NDIS_RESET_CMPLT		0x80000006
251 
252 struct rndis_reset_req {
253 	uint32_t	rm_type;
254 	uint32_t	rm_len;
255 	uint32_t	rm_rid;
256 };
257 
258 struct rndis_reset_comp {
259 	uint32_t	rm_type;
260 	uint32_t	rm_len;
261 	uint32_t	rm_status;
262 	uint32_t	rm_adrreset;
263 };
264 
265 /* 802.3 link-state or undefined message error.  Sent by device. */
266 #define REMOTE_NDIS_INDICATE_STATUS_MSG	0x00000007
267 
268 struct rndis_status_msg {
269 	uint32_t	rm_type;
270 	uint32_t	rm_len;
271 	uint32_t	rm_status;
272 	uint32_t	rm_stbuflen;
273 	uint32_t	rm_stbufoffset;
274 	/* rndis_diag_info */
275 };
276 
277 /*
278  * Immediately after rndis_status_msg.rm_stbufoffset, if a control
279  * message is malformed, or a packet message contains inappropriate
280  * content.
281  */
282 struct rndis_diag_info {
283 	uint32_t	rm_diagstatus;
284 	uint32_t	rm_erroffset;
285 };
286 
287 /* Keepalive message.  May be sent by device. */
288 #define REMOTE_NDIS_KEEPALIVE_MSG	0x00000008
289 #define REMOTE_NDIS_KEEPALIVE_CMPLT	0x80000008
290 
291 struct rndis_keepalive_req {
292 	uint32_t	rm_type;
293 	uint32_t	rm_len;
294 	uint32_t	rm_rid;
295 };
296 
297 struct rndis_keepalive_comp {
298 	uint32_t	rm_type;
299 	uint32_t	rm_len;
300 	uint32_t	rm_rid;
301 	uint32_t	rm_status;
302 };
303 
304 /* packet filter bits used by OID_GEN_CURRENT_PACKET_FILTER */
305 #define NDIS_PACKET_TYPE_DIRECTED		0x00000001
306 #define NDIS_PACKET_TYPE_MULTICAST		0x00000002
307 #define NDIS_PACKET_TYPE_ALL_MULTICAST		0x00000004
308 #define NDIS_PACKET_TYPE_BROADCAST		0x00000008
309 #define NDIS_PACKET_TYPE_SOURCE_ROUTING		0x00000010
310 #define NDIS_PACKET_TYPE_PROMISCUOUS		0x00000020
311 #define NDIS_PACKET_TYPE_SMT			0x00000040
312 #define NDIS_PACKET_TYPE_ALL_LOCAL		0x00000080
313 #define NDIS_PACKET_TYPE_GROUP			0x00001000
314 #define NDIS_PACKET_TYPE_ALL_FUNCTIONAL		0x00002000
315 #define NDIS_PACKET_TYPE_FUNCTIONAL		0x00004000
316 #define NDIS_PACKET_TYPE_MAC_FRAME		0x00008000
317 
318 /* RNDIS offsets */
319 #define RNDIS_HEADER_OFFSET	(sizeof(struct rndis_msghdr))
320 #define RNDIS_DATA_OFFSET	(sizeof(struct rndis_packet_msg) - \
321 				 RNDIS_HEADER_OFFSET)
322 
323 #endif	/* _DEV_RNDIS_H_ */
324