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