rndis.h revision 307498
1/*	$FreeBSD: stable/11/sys/net/rndis.h 307498 2016-10-17 08:10:24Z sephe $ */
2/*	$OpenBSD: if_urndisreg.h,v 1.19 2013/11/21 14:08:05 mpi Exp $ */
3
4/*
5 * Copyright (c) 2010 Jonathan Armani <armani@openbsd.org>
6 * Copyright (c) 2010 Fabien Romano <fabien@openbsd.org>
7 * Copyright (c) 2010 Michael Knudsen <mk@openbsd.org>
8 * All rights reserved.
9 *
10 * Permission to use, copy, modify, and distribute this software for any
11 * purpose with or without fee is hereby granted, provided that the above
12 * copyright notice and this permission notice appear in all copies.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 */
22
23#ifndef	_NET_RNDIS_H_
24#define	_NET_RNDIS_H_
25
26/* Canonical major/minor version as of 22th Aug. 2016. */
27#define	RNDIS_VERSION_MAJOR		0x00000001
28#define	RNDIS_VERSION_MINOR		0x00000000
29
30#define	RNDIS_STATUS_SUCCESS 		0x00000000L
31#define	RNDIS_STATUS_PENDING 		0x00000103L
32#define	RNDIS_STATUS_MEDIA_CONNECT 	0x4001000BL
33#define	RNDIS_STATUS_MEDIA_DISCONNECT 	0x4001000CL
34#define	RNDIS_STATUS_BUFFER_OVERFLOW 	0x80000005L
35#define	RNDIS_STATUS_FAILURE 		0xC0000001L
36#define	RNDIS_STATUS_NOT_SUPPORTED 	0xC00000BBL
37#define	RNDIS_STATUS_RESOURCES 		0xC000009AL
38#define	RNDIS_STATUS_INVALID_DATA 	0xC0010015L
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 */
98struct 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
108struct rndis_packet_msg {
109	uint32_t rm_type;
110	uint32_t rm_len;
111	uint32_t rm_dataoffset;
112	uint32_t rm_datalen;
113	uint32_t rm_oobdataoffset;
114	uint32_t rm_oobdatalen;
115	uint32_t rm_oobdataelements;
116	uint32_t rm_pktinfooffset;
117	uint32_t rm_pktinfolen;
118	uint32_t rm_vchandle;
119	uint32_t rm_reserved;
120};
121
122/*
123 * Minimum value for rm_dataoffset, rm_oobdataoffset, and
124 * rm_pktinfooffset.
125 */
126#define	RNDIS_PACKET_MSG_OFFSET_MIN		\
127	(sizeof(struct rndis_packet_msg) -	\
128	 __offsetof(struct rndis_packet_msg, rm_dataoffset))
129
130/* Offset from the beginning of rndis_packet_msg. */
131#define	RNDIS_PACKET_MSG_OFFSET_ABS(ofs)	\
132	((ofs) + __offsetof(struct rndis_packet_msg, rm_dataoffset))
133
134#define	RNDIS_PACKET_MSG_OFFSET_ALIGN		4
135#define	RNDIS_PACKET_MSG_OFFSET_ALIGNMASK	\
136	(RNDIS_PACKET_MSG_OFFSET_ALIGN - 1)
137
138/* Per-packet-info for RNDIS data message */
139struct rndis_pktinfo {
140	uint32_t rm_size;
141	uint32_t rm_type;		/* NDIS_PKTINFO_TYPE_ */
142	uint32_t rm_pktinfooffset;
143	uint8_t rm_data[];
144};
145
146#define	RNDIS_PKTINFO_OFFSET		\
147	__offsetof(struct rndis_pktinfo, rm_data[0])
148#define	RNDIS_PKTINFO_SIZE_ALIGN	4
149#define	RNDIS_PKTINFO_SIZE_ALIGNMASK	(RNDIS_PKTINFO_SIZE_ALIGN - 1)
150
151#define	NDIS_PKTINFO_TYPE_CSUM		0
152#define	NDIS_PKTINFO_TYPE_IPSEC		1
153#define	NDIS_PKTINFO_TYPE_LSO		2
154#define	NDIS_PKTINFO_TYPE_CLASSIFY	3
155/* reserved 4 */
156#define	NDIS_PKTINFO_TYPE_SGLIST	5
157#define	NDIS_PKTINFO_TYPE_VLAN		6
158#define	NDIS_PKTINFO_TYPE_ORIG		7
159#define	NDIS_PKTINFO_TYPE_PKT_CANCELID	8
160#define	NDIS_PKTINFO_TYPE_ORIG_NBLIST	9
161#define	NDIS_PKTINFO_TYPE_CACHE_NBLIST	10
162#define	NDIS_PKTINFO_TYPE_PKT_PAD	11
163
164/*
165 * RNDIS control messages
166 */
167
168/*
169 * Common header for RNDIS completion messages.
170 *
171 * NOTE: It does not apply to REMOTE_NDIS_RESET_CMPLT.
172 */
173struct rndis_comp_hdr {
174	uint32_t rm_type;
175	uint32_t rm_len;
176	uint32_t rm_rid;
177	uint32_t rm_status;
178};
179
180/* Initialize the device. */
181#define	REMOTE_NDIS_INITIALIZE_MSG	0x00000002
182#define	REMOTE_NDIS_INITIALIZE_CMPLT	0x80000002
183
184struct rndis_init_req {
185	uint32_t rm_type;
186	uint32_t rm_len;
187	uint32_t rm_rid;
188	uint32_t rm_ver_major;
189	uint32_t rm_ver_minor;
190	uint32_t rm_max_xfersz;
191};
192
193struct rndis_init_comp {
194	uint32_t rm_type;
195	uint32_t rm_len;
196	uint32_t rm_rid;
197	uint32_t rm_status;
198	uint32_t rm_ver_major;
199	uint32_t rm_ver_minor;
200	uint32_t rm_devflags;
201	uint32_t rm_medium;
202	uint32_t rm_pktmaxcnt;
203	uint32_t rm_pktmaxsz;
204	uint32_t rm_align;
205	uint32_t rm_aflistoffset;
206	uint32_t rm_aflistsz;
207};
208
209#define	RNDIS_INIT_COMP_SIZE_MIN	\
210	__offsetof(struct rndis_init_comp, rm_aflistsz)
211
212/* Halt the device.  No response sent. */
213#define	REMOTE_NDIS_HALT_MSG		0x00000003
214
215struct rndis_halt_req {
216	uint32_t rm_type;
217	uint32_t rm_len;
218	uint32_t rm_rid;
219};
220
221/* Send a query object. */
222#define	REMOTE_NDIS_QUERY_MSG		0x00000004
223#define	REMOTE_NDIS_QUERY_CMPLT		0x80000004
224
225struct rndis_query_req {
226	uint32_t rm_type;
227	uint32_t rm_len;
228	uint32_t rm_rid;
229	uint32_t rm_oid;
230	uint32_t rm_infobuflen;
231	uint32_t rm_infobufoffset;
232	uint32_t rm_devicevchdl;
233};
234
235#define	RNDIS_QUERY_REQ_INFOBUFOFFSET		\
236	(sizeof(struct rndis_query_req) -	\
237	 __offsetof(struct rndis_query_req, rm_rid))
238
239struct rndis_query_comp {
240	uint32_t rm_type;
241	uint32_t rm_len;
242	uint32_t rm_rid;
243	uint32_t rm_status;
244	uint32_t rm_infobuflen;
245	uint32_t rm_infobufoffset;
246};
247
248/* infobuf offset from the beginning of rndis_query_comp. */
249#define	RNDIS_QUERY_COMP_INFOBUFOFFSET_ABS(ofs)	\
250	((ofs) + __offsetof(struct rndis_query_req, rm_rid))
251
252/* Send a set object request. */
253#define	REMOTE_NDIS_SET_MSG		0x00000005
254#define	REMOTE_NDIS_SET_CMPLT		0x80000005
255
256struct rndis_set_req {
257	uint32_t rm_type;
258	uint32_t rm_len;
259	uint32_t rm_rid;
260	uint32_t rm_oid;
261	uint32_t rm_infobuflen;
262	uint32_t rm_infobufoffset;
263	uint32_t rm_devicevchdl;
264};
265
266#define	RNDIS_SET_REQ_INFOBUFOFFSET		\
267	(sizeof(struct rndis_set_req) -		\
268	 __offsetof(struct rndis_set_req, rm_rid))
269
270struct rndis_set_comp {
271	uint32_t rm_type;
272	uint32_t rm_len;
273	uint32_t rm_rid;
274	uint32_t rm_status;
275};
276
277/*
278 * Parameter used by OID_GEN_RNDIS_CONFIG_PARAMETER.
279 */
280#define	REMOTE_NDIS_SET_PARAM_NUMERIC	0x00000000
281#define	REMOTE_NDIS_SET_PARAM_STRING	0x00000002
282
283struct rndis_set_parameter {
284	uint32_t rm_nameoffset;
285	uint32_t rm_namelen;
286	uint32_t rm_type;
287	uint32_t rm_valueoffset;
288	uint32_t rm_valuelen;
289};
290
291/* Perform a soft reset on the device. */
292#define	REMOTE_NDIS_RESET_MSG		0x00000006
293#define	REMOTE_NDIS_RESET_CMPLT		0x80000006
294
295struct rndis_reset_req {
296	uint32_t rm_type;
297	uint32_t rm_len;
298	uint32_t rm_rid;
299};
300
301struct rndis_reset_comp {
302	uint32_t rm_type;
303	uint32_t rm_len;
304	uint32_t rm_status;
305	uint32_t rm_adrreset;
306};
307
308/* 802.3 link-state or undefined message error.  Sent by device. */
309#define	REMOTE_NDIS_INDICATE_STATUS_MSG	0x00000007
310
311struct rndis_status_msg {
312	uint32_t rm_type;
313	uint32_t rm_len;
314	uint32_t rm_status;
315	uint32_t rm_stbuflen;
316	uint32_t rm_stbufoffset;
317	/* rndis_diag_info */
318};
319
320/*
321 * Immediately after rndis_status_msg.rm_stbufoffset, if a control
322 * message is malformatted, or a packet message contains inappropriate
323 * content.
324 */
325struct rndis_diag_info {
326	uint32_t rm_diagstatus;
327	uint32_t rm_erroffset;
328};
329
330/* Keepalive messsage.  May be sent by device. */
331#define	REMOTE_NDIS_KEEPALIVE_MSG	0x00000008
332#define	REMOTE_NDIS_KEEPALIVE_CMPLT	0x80000008
333
334struct rndis_keepalive_req {
335	uint32_t rm_type;
336	uint32_t rm_len;
337	uint32_t rm_rid;
338};
339
340struct rndis_keepalive_comp {
341	uint32_t rm_type;
342	uint32_t rm_len;
343	uint32_t rm_rid;
344	uint32_t rm_status;
345};
346
347/* packet filter bits used by OID_GEN_CURRENT_PACKET_FILTER */
348#define	NDIS_PACKET_TYPE_DIRECTED		0x00000001
349#define	NDIS_PACKET_TYPE_MULTICAST		0x00000002
350#define	NDIS_PACKET_TYPE_ALL_MULTICAST		0x00000004
351#define	NDIS_PACKET_TYPE_BROADCAST		0x00000008
352#define	NDIS_PACKET_TYPE_SOURCE_ROUTING		0x00000010
353#define	NDIS_PACKET_TYPE_PROMISCUOUS		0x00000020
354#define	NDIS_PACKET_TYPE_SMT			0x00000040
355#define	NDIS_PACKET_TYPE_ALL_LOCAL		0x00000080
356#define	NDIS_PACKET_TYPE_GROUP			0x00001000
357#define	NDIS_PACKET_TYPE_ALL_FUNCTIONAL		0x00002000
358#define	NDIS_PACKET_TYPE_FUNCTIONAL		0x00004000
359#define	NDIS_PACKET_TYPE_MAC_FRAME		0x00008000
360
361/* RNDIS offsets */
362#define	RNDIS_HEADER_OFFSET	((uint32_t)sizeof(struct rndis_msghdr))
363#define	RNDIS_DATA_OFFSET	\
364    ((uint32_t)(sizeof(struct rndis_packet_msg) - RNDIS_HEADER_OFFSET))
365
366#endif	/* !_NET_RNDIS_H_ */
367