2 * Copyright (c) 2016-2017 Microsoft Corp.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice unmodified, this list of conditions, and the following
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #define NDIS_MEDIA_STATE_CONNECTED 0
33 #define NDIS_MEDIA_STATE_DISCONNECTED 1
35 #define NDIS_NETCHANGE_TYPE_POSSIBLE 1
36 #define NDIS_NETCHANGE_TYPE_DEFINITE 2
37 #define NDIS_NETCHANGE_TYPE_FROMMEDIA 3
39 #define NDIS_OFFLOAD_SET_NOCHG 0
40 #define NDIS_OFFLOAD_SET_ON 1
41 #define NDIS_OFFLOAD_SET_OFF 2
44 #define NDIS_ENCAP_TYPE_NVGRE 0x00000001
46 #define NDIS_HASH_FUNCTION_MASK 0x000000FF /* see hash function */
47 #define NDIS_HASH_TYPE_MASK 0x00FFFF00 /* see hash type */
50 #define NDIS_HASH_FUNCTION_TOEPLITZ 0x00000001
53 #define NDIS_HASH_IPV4 0x00000100
54 #define NDIS_HASH_TCP_IPV4 0x00000200
55 #define NDIS_HASH_IPV6 0x00000400
56 #define NDIS_HASH_IPV6_EX 0x00000800
57 #define NDIS_HASH_TCP_IPV6 0x00001000
58 #define NDIS_HASH_TCP_IPV6_EX 0x00002000
60 #define NDIS_HASH_ALL (NDIS_HASH_IPV4 | \
61 NDIS_HASH_TCP_IPV4 | \
64 NDIS_HASH_TCP_IPV6 | \
65 NDIS_HASH_TCP_IPV6_EX)
67 /* Hash description for use with printf(9) %b identifier. */
68 #define NDIS_HASH_BITS \
69 "\20\1TOEPLITZ\11IP4\12TCP4\13IP6\14IP6EX\15TCP6\16TCP6EX"
71 #define NDIS_HASH_KEYSIZE_TOEPLITZ 40
72 #define NDIS_HASH_INDCNT 128
74 #define NDIS_OBJTYPE_DEFAULT 0x80
75 #define NDIS_OBJTYPE_RSS_CAPS 0x88
76 #define NDIS_OBJTYPE_RSS_PARAMS 0x89
77 #define NDIS_OBJTYPE_OFFLOAD 0xa7
79 struct ndis_object_hdr {
80 uint8_t ndis_type; /* NDIS_OBJTYPE_ */
81 uint8_t ndis_rev; /* type specific */
82 uint16_t ndis_size; /* incl. this hdr */
86 * OID_TCP_OFFLOAD_PARAMETERS
87 * ndis_type: NDIS_OBJTYPE_DEFAULT
89 struct ndis_offload_params {
90 struct ndis_object_hdr ndis_hdr;
91 uint8_t ndis_ip4csum; /* NDIS_OFFLOAD_PARAM_ */
92 uint8_t ndis_tcp4csum; /* NDIS_OFFLOAD_PARAM_ */
93 uint8_t ndis_udp4csum; /* NDIS_OFFLOAD_PARAM_ */
94 uint8_t ndis_tcp6csum; /* NDIS_OFFLOAD_PARAM_ */
95 uint8_t ndis_udp6csum; /* NDIS_OFFLOAD_PARAM_ */
96 uint8_t ndis_lsov1; /* NDIS_OFFLOAD_PARAM_ */
97 uint8_t ndis_ipsecv1; /* NDIS_OFFLOAD_IPSECV1_ */
98 uint8_t ndis_lsov2_ip4; /* NDIS_OFFLOAD_LSOV2_ */
99 uint8_t ndis_lsov2_ip6; /* NDIS_OFFLOAD_LSOV2_ */
100 uint8_t ndis_tcp4conn; /* 0 */
101 uint8_t ndis_tcp6conn; /* 0 */
102 uint32_t ndis_flags; /* 0 */
104 uint8_t ndis_ipsecv2; /* NDIS_OFFLOAD_IPSECV2_ */
105 uint8_t ndis_ipsecv2_ip4;/* NDIS_OFFLOAD_IPSECV2_ */
107 uint8_t ndis_rsc_ip4; /* NDIS_OFFLOAD_RSC_ */
108 uint8_t ndis_rsc_ip6; /* NDIS_OFFLOAD_RSC_ */
109 uint8_t ndis_encap; /* NDIS_OFFLOAD_SET_ */
110 uint8_t ndis_encap_types;/* NDIS_ENCAP_TYPE_ */
113 #define NDIS_OFFLOAD_PARAMS_SIZE sizeof(struct ndis_offload_params)
114 #define NDIS_OFFLOAD_PARAMS_SIZE_6_1 \
115 __offsetof(struct ndis_offload_params, ndis_rsc_ip4)
117 #define NDIS_OFFLOAD_PARAMS_REV_2 2 /* NDIS 6.1 */
118 #define NDIS_OFFLOAD_PARAMS_REV_3 3 /* NDIS 6.30 */
120 #define NDIS_OFFLOAD_PARAM_NOCHG 0 /* common */
121 #define NDIS_OFFLOAD_PARAM_OFF 1
122 #define NDIS_OFFLOAD_PARAM_TX 2
123 #define NDIS_OFFLOAD_PARAM_RX 3
124 #define NDIS_OFFLOAD_PARAM_TXRX 4
126 /* NDIS_OFFLOAD_PARAM_NOCHG */
127 #define NDIS_OFFLOAD_LSOV1_OFF 1
128 #define NDIS_OFFLOAD_LSOV1_ON 2
130 /* NDIS_OFFLOAD_PARAM_NOCHG */
131 #define NDIS_OFFLOAD_IPSECV1_OFF 1
132 #define NDIS_OFFLOAD_IPSECV1_AH 2
133 #define NDIS_OFFLOAD_IPSECV1_ESP 3
134 #define NDIS_OFFLOAD_IPSECV1_AH_ESP 4
136 /* NDIS_OFFLOAD_PARAM_NOCHG */
137 #define NDIS_OFFLOAD_LSOV2_OFF 1
138 #define NDIS_OFFLOAD_LSOV2_ON 2
140 /* NDIS_OFFLOAD_PARAM_NOCHG */
141 #define NDIS_OFFLOAD_IPSECV2_OFF 1
142 #define NDIS_OFFLOAD_IPSECV2_AH 2
143 #define NDIS_OFFLOAD_IPSECV2_ESP 3
144 #define NDIS_OFFLOAD_IPSECV2_AH_ESP 4
146 /* NDIS_OFFLOAD_PARAM_NOCHG */
147 #define NDIS_OFFLOAD_RSC_OFF 1
148 #define NDIS_OFFLOAD_RSC_ON 2
151 * OID_GEN_RECEIVE_SCALE_CAPABILITIES
152 * ndis_type: NDIS_OBJTYPE_RSS_CAPS
154 struct ndis_rss_caps {
155 struct ndis_object_hdr ndis_hdr;
156 uint32_t ndis_caps; /* NDIS_RSS_CAP_ */
157 uint32_t ndis_nmsi; /* # of MSIs */
158 uint32_t ndis_nrxr; /* # of RX rings */
160 uint16_t ndis_nind; /* # of indtbl ent. */
164 #define NDIS_RSS_CAPS_SIZE \
165 __offsetof(struct ndis_rss_caps, ndis_pad)
166 #define NDIS_RSS_CAPS_SIZE_6_0 \
167 __offsetof(struct ndis_rss_caps, ndis_nind)
169 #define NDIS_RSS_CAPS_REV_1 1 /* NDIS 6.{0,1,20} */
170 #define NDIS_RSS_CAPS_REV_2 2 /* NDIS 6.30 */
172 #define NDIS_RSS_CAP_MSI 0x01000000
173 #define NDIS_RSS_CAP_CLASSIFY_ISR 0x02000000
174 #define NDIS_RSS_CAP_CLASSIFY_DPC 0x04000000
175 #define NDIS_RSS_CAP_MSIX 0x08000000
176 #define NDIS_RSS_CAP_IPV4 0x00000100
177 #define NDIS_RSS_CAP_IPV6 0x00000200
178 #define NDIS_RSS_CAP_IPV6_EX 0x00000400
179 #define NDIS_RSS_CAP_HASH_TOEPLITZ NDIS_HASH_FUNCTION_TOEPLITZ
180 #define NDIS_RSS_CAP_HASHFUNC_MASK NDIS_HASH_FUNCTION_MASK
183 * OID_GEN_RECEIVE_SCALE_PARAMETERS
184 * ndis_type: NDIS_OBJTYPE_RSS_PARAMS
186 struct ndis_rss_params {
187 struct ndis_object_hdr ndis_hdr;
188 uint16_t ndis_flags; /* NDIS_RSS_FLAG_ */
189 uint16_t ndis_bcpu; /* base cpu 0 */
190 uint32_t ndis_hash; /* NDIS_HASH_ */
191 uint16_t ndis_indsize; /* indirect table */
192 uint32_t ndis_indoffset;
193 uint16_t ndis_keysize; /* hash key */
194 uint32_t ndis_keyoffset;
196 uint32_t ndis_cpumaskoffset;
197 uint32_t ndis_cpumaskcnt;
198 uint32_t ndis_cpumaskentsz;
201 #define NDIS_RSS_PARAMS_SIZE sizeof(struct ndis_rss_params)
202 #define NDIS_RSS_PARAMS_SIZE_6_0 \
203 __offsetof(struct ndis_rss_params, ndis_cpumaskoffset)
205 #define NDIS_RSS_PARAMS_REV_1 1 /* NDIS 6.0 */
206 #define NDIS_RSS_PARAMS_REV_2 2 /* NDIS 6.20 */
208 #define NDIS_RSS_FLAG_NONE 0x0000
209 #define NDIS_RSS_FLAG_BCPU_UNCHG 0x0001
210 #define NDIS_RSS_FLAG_HASH_UNCHG 0x0002
211 #define NDIS_RSS_FLAG_IND_UNCHG 0x0004
212 #define NDIS_RSS_FLAG_KEY_UNCHG 0x0008
213 #define NDIS_RSS_FLAG_DISABLE 0x0010
215 /* non-standard convenient struct */
216 struct ndis_rssprm_toeplitz {
217 struct ndis_rss_params rss_params;
218 /* Toeplitz hash key */
219 uint8_t rss_key[NDIS_HASH_KEYSIZE_TOEPLITZ];
221 uint32_t rss_ind[NDIS_HASH_INDCNT];
224 #define NDIS_RSSPRM_TOEPLITZ_SIZE(nind) \
225 __offsetof(struct ndis_rssprm_toeplitz, rss_ind[nind])
228 * OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES
229 * ndis_type: NDIS_OBJTYPE_OFFLOAD
232 #define NDIS_OFFLOAD_ENCAP_NONE 0x0000
233 #define NDIS_OFFLOAD_ENCAP_NULL 0x0001
234 #define NDIS_OFFLOAD_ENCAP_8023 0x0002
235 #define NDIS_OFFLOAD_ENCAP_8023PQ 0x0004
236 #define NDIS_OFFLOAD_ENCAP_8023PQ_OOB 0x0008
237 #define NDIS_OFFLOAD_ENCAP_RFC1483 0x0010
239 struct ndis_csum_offload {
240 uint32_t ndis_ip4_txenc; /*NDIS_OFFLOAD_ENCAP_*/
241 uint32_t ndis_ip4_txcsum;
242 #define NDIS_TXCSUM_CAP_IP4OPT 0x001
243 #define NDIS_TXCSUM_CAP_TCP4OPT 0x004
244 #define NDIS_TXCSUM_CAP_TCP4 0x010
245 #define NDIS_TXCSUM_CAP_UDP4 0x040
246 #define NDIS_TXCSUM_CAP_IP4 0x100
247 uint32_t ndis_ip4_rxenc; /*NDIS_OFFLOAD_ENCAP_*/
248 uint32_t ndis_ip4_rxcsum;
249 #define NDIS_RXCSUM_CAP_IP4OPT 0x001
250 #define NDIS_RXCSUM_CAP_TCP4OPT 0x004
251 #define NDIS_RXCSUM_CAP_TCP4 0x010
252 #define NDIS_RXCSUM_CAP_UDP4 0x040
253 #define NDIS_RXCSUM_CAP_IP4 0x100
254 uint32_t ndis_ip6_txenc; /*NDIS_OFFLOAD_ENCAP_*/
255 uint32_t ndis_ip6_txcsum;
256 #define NDIS_TXCSUM_CAP_IP6EXT 0x001
257 #define NDIS_TXCSUM_CAP_TCP6OPT 0x004
258 #define NDIS_TXCSUM_CAP_TCP6 0x010
259 #define NDIS_TXCSUM_CAP_UDP6 0x040
260 uint32_t ndis_ip6_rxenc; /*NDIS_OFFLOAD_ENCAP_*/
261 uint32_t ndis_ip6_rxcsum;
262 #define NDIS_RXCSUM_CAP_IP6EXT 0x001
263 #define NDIS_RXCSUM_CAP_TCP6OPT 0x004
264 #define NDIS_RXCSUM_CAP_TCP6 0x010
265 #define NDIS_RXCSUM_CAP_UDP6 0x040
268 struct ndis_lsov1_offload {
269 uint32_t ndis_encap; /*NDIS_OFFLOAD_ENCAP_*/
270 uint32_t ndis_maxsize;
271 uint32_t ndis_minsegs;
275 struct ndis_ipsecv1_offload {
276 uint32_t ndis_encap; /*NDIS_OFFLOAD_ENCAP_*/
277 uint32_t ndis_ah_esp;
278 uint32_t ndis_xport_tun;
279 uint32_t ndis_ip4_opts;
281 uint32_t ndis_ip4_ah;
282 uint32_t ndis_ip4_esp;
285 struct ndis_lsov2_offload {
286 uint32_t ndis_ip4_encap; /*NDIS_OFFLOAD_ENCAP_*/
287 uint32_t ndis_ip4_maxsz;
288 uint32_t ndis_ip4_minsg;
289 uint32_t ndis_ip6_encap; /*NDIS_OFFLOAD_ENCAP_*/
290 uint32_t ndis_ip6_maxsz;
291 uint32_t ndis_ip6_minsg;
292 uint32_t ndis_ip6_opts;
293 #define NDIS_LSOV2_CAP_IP6EXT 0x001
294 #define NDIS_LSOV2_CAP_TCP6OPT 0x004
297 struct ndis_ipsecv2_offload {
298 uint32_t ndis_encap; /*NDIS_OFFLOAD_ENCAP_*/
300 uint16_t ndis_ip4opt;
301 uint16_t ndis_ip6ext;
304 uint16_t ndis_ah_esp;
307 uint16_t ndis_xport_tun;
309 uint16_t ndis_extseq;
310 uint32_t ndis_udp_esp;
312 uint32_t ndis_crypto;
313 uint32_t ndis_sa_caps;
316 struct ndis_rsc_offload {
321 struct ndis_encap_offload {
323 uint32_t ndis_maxhdr;
326 struct ndis_offload {
327 struct ndis_object_hdr ndis_hdr;
328 struct ndis_csum_offload ndis_csum;
329 struct ndis_lsov1_offload ndis_lsov1;
330 struct ndis_ipsecv1_offload ndis_ipsecv1;
331 struct ndis_lsov2_offload ndis_lsov2;
334 struct ndis_ipsecv2_offload ndis_ipsecv2;
336 struct ndis_rsc_offload ndis_rsc;
337 struct ndis_encap_offload ndis_encap_gre;
340 #define NDIS_OFFLOAD_SIZE sizeof(struct ndis_offload)
341 #define NDIS_OFFLOAD_SIZE_6_0 \
342 __offsetof(struct ndis_offload, ndis_ipsecv2)
343 #define NDIS_OFFLOAD_SIZE_6_1 \
344 __offsetof(struct ndis_offload, ndis_rsc)
346 #define NDIS_OFFLOAD_REV_1 1 /* NDIS 6.0 */
347 #define NDIS_OFFLOAD_REV_2 2 /* NDIS 6.1 */
348 #define NDIS_OFFLOAD_REV_3 3 /* NDIS 6.30 */
355 #define NDIS_VLAN_INFO_SIZE sizeof(uint32_t)
356 #define NDIS_VLAN_INFO_PRI_MASK 0x0007
357 #define NDIS_VLAN_INFO_CFI_MASK 0x0008
358 #define NDIS_VLAN_INFO_ID_MASK 0xfff0
359 #define NDIS_VLAN_INFO_MAKE(id, pri, cfi) \
360 (((pri) & NDIS_VLAN_INFO_PRI_MASK) | \
361 (((cfi) & 0x1) << 3) | (((id) & 0xfff) << 4))
362 #define NDIS_VLAN_INFO_ID(inf) (((inf) & NDIS_VLAN_INFO_ID_MASK) >> 4)
363 #define NDIS_VLAN_INFO_CFI(inf) (((inf) & NDIS_VLAN_INFO_CFI_MASK) >> 3)
364 #define NDIS_VLAN_INFO_PRI(inf) ((inf) & NDIS_VLAN_INFO_PRI_MASK)
366 /* Reception checksum */
367 #define NDIS_RXCSUM_INFO_SIZE sizeof(uint32_t)
368 #define NDIS_RXCSUM_INFO_TCPCS_FAILED 0x0001
369 #define NDIS_RXCSUM_INFO_UDPCS_FAILED 0x0002
370 #define NDIS_RXCSUM_INFO_IPCS_FAILED 0x0004
371 #define NDIS_RXCSUM_INFO_TCPCS_OK 0x0008
372 #define NDIS_RXCSUM_INFO_UDPCS_OK 0x0010
373 #define NDIS_RXCSUM_INFO_IPCS_OK 0x0020
374 #define NDIS_RXCSUM_INFO_LOOPBACK 0x0040
375 #define NDIS_RXCSUM_INFO_TCPCS_INVAL 0x0080
376 #define NDIS_RXCSUM_INFO_IPCS_INVAL 0x0100
379 #define NDIS_LSO2_INFO_SIZE sizeof(uint32_t)
380 #define NDIS_LSO2_INFO_MSS_MASK 0x000fffff
381 #define NDIS_LSO2_INFO_THOFF_MASK 0x3ff00000
382 #define NDIS_LSO2_INFO_ISLSO2 0x40000000
383 #define NDIS_LSO2_INFO_ISIPV6 0x80000000
385 #define NDIS_LSO2_INFO_MAKE(thoff, mss) \
386 ((((uint32_t)(mss)) & NDIS_LSO2_INFO_MSS_MASK) | \
387 ((((uint32_t)(thoff)) & 0x3ff) << 20) | \
388 NDIS_LSO2_INFO_ISLSO2)
390 #define NDIS_LSO2_INFO_MAKEIPV4(thoff, mss) \
391 NDIS_LSO2_INFO_MAKE((thoff), (mss))
393 #define NDIS_LSO2_INFO_MAKEIPV6(thoff, mss) \
394 (NDIS_LSO2_INFO_MAKE((thoff), (mss)) | NDIS_LSO2_INFO_ISIPV6)
396 /* Transmission checksum */
397 #define NDIS_TXCSUM_INFO_SIZE sizeof(uint32_t)
398 #define NDIS_TXCSUM_INFO_IPV4 0x00000001
399 #define NDIS_TXCSUM_INFO_IPV6 0x00000002
400 #define NDIS_TXCSUM_INFO_TCPCS 0x00000004
401 #define NDIS_TXCSUM_INFO_UDPCS 0x00000008
402 #define NDIS_TXCSUM_INFO_IPCS 0x00000010
403 #define NDIS_TXCSUM_INFO_THOFF 0x03ff0000
405 #endif /* !_NET_NDIS_H_ */