2 * Copyright (c) 2016 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_OFFLOAD_SET_NOCHG 0
36 #define NDIS_OFFLOAD_SET_ON 1
37 #define NDIS_OFFLOAD_SET_OFF 2
40 #define NDIS_ENCAP_TYPE_NVGRE 0x00000001
42 #define NDIS_HASH_FUNCTION_MASK 0x000000FF /* see hash function */
43 #define NDIS_HASH_TYPE_MASK 0x00FFFF00 /* see hash type */
46 #define NDIS_HASH_FUNCTION_TOEPLITZ 0x00000001
49 #define NDIS_HASH_IPV4 0x00000100
50 #define NDIS_HASH_TCP_IPV4 0x00000200
51 #define NDIS_HASH_IPV6 0x00000400
52 #define NDIS_HASH_IPV6_EX 0x00000800
53 #define NDIS_HASH_TCP_IPV6 0x00001000
54 #define NDIS_HASH_TCP_IPV6_EX 0x00002000
56 #define NDIS_HASH_KEYSIZE_TOEPLITZ 40
57 #define NDIS_HASH_INDCNT 128
59 #define NDIS_OBJTYPE_DEFAULT 0x80
60 #define NDIS_OBJTYPE_RSS_CAPS 0x88
61 #define NDIS_OBJTYPE_RSS_PARAMS 0x89
63 struct ndis_object_hdr {
64 uint8_t ndis_type; /* NDIS_OBJTYPE_ */
65 uint8_t ndis_rev; /* type specific */
66 uint16_t ndis_size; /* incl. this hdr */
70 * OID_TCP_OFFLOAD_PARAMETERS
71 * ndis_type: NDIS_OBJTYPE_DEFAULT
73 struct ndis_offload_params {
74 struct ndis_object_hdr ndis_hdr;
75 uint8_t ndis_ip4csum; /* NDIS_OFFLOAD_PARAM_ */
76 uint8_t ndis_tcp4csum; /* NDIS_OFFLOAD_PARAM_ */
77 uint8_t ndis_udp4csum; /* NDIS_OFFLOAD_PARAM_ */
78 uint8_t ndis_tcp6csum; /* NDIS_OFFLOAD_PARAM_ */
79 uint8_t ndis_udp6csum; /* NDIS_OFFLOAD_PARAM_ */
80 uint8_t ndis_lsov1; /* NDIS_OFFLOAD_PARAM_ */
81 uint8_t ndis_ipsecv1; /* NDIS_OFFLOAD_IPSECV1_ */
82 uint8_t ndis_lsov2_ip4; /* NDIS_OFFLOAD_LSOV2_ */
83 uint8_t ndis_lsov2_ip6; /* NDIS_OFFLOAD_LSOV2_ */
84 uint8_t ndis_tcp4conn; /* 0 */
85 uint8_t ndis_tcp6conn; /* 0 */
86 uint32_t ndis_flags; /* 0 */
88 uint8_t ndis_ipsecv2; /* NDIS_OFFLOAD_IPSECV2_ */
89 uint8_t ndis_ipsecv2_ip4;/* NDIS_OFFLOAD_IPSECV2_ */
91 uint8_t ndis_rsc_ip4; /* NDIS_OFFLOAD_RSC_ */
92 uint8_t ndis_rsc_ip6; /* NDIS_OFFLOAD_RSC_ */
93 uint8_t ndis_encap; /* NDIS_OFFLOAD_SET_ */
94 uint8_t ndis_encap_types;/* NDIS_ENCAP_TYPE_ */
97 #define NDIS_OFFLOAD_PARAMS_SIZE sizeof(struct ndis_offload_params)
98 #define NDIS_OFFLOAD_PARAMS_SIZE_6_1 \
99 __offsetof(struct ndis_offload_params, ndis_rsc_ip4)
101 #define NDIS_OFFLOAD_PARAMS_REV_2 2 /* NDIS 6.1 */
102 #define NDIS_OFFLOAD_PARAMS_REV_3 3 /* NDIS 6.30 */
104 #define NDIS_OFFLOAD_PARAM_NOCHG 0 /* common */
105 #define NDIS_OFFLOAD_PARAM_OFF 1
106 #define NDIS_OFFLOAD_PARAM_TX 2
107 #define NDIS_OFFLOAD_PARAM_RX 3
108 #define NDIS_OFFLOAD_PARAM_TXRX 4
110 /* NDIS_OFFLOAD_PARAM_NOCHG */
111 #define NDIS_OFFLOAD_LSOV1_OFF 1
112 #define NDIS_OFFLOAD_LSOV1_ON 2
114 /* NDIS_OFFLOAD_PARAM_NOCHG */
115 #define NDIS_OFFLOAD_IPSECV1_OFF 1
116 #define NDIS_OFFLOAD_IPSECV1_AH 2
117 #define NDIS_OFFLOAD_IPSECV1_ESP 3
118 #define NDIS_OFFLOAD_IPSECV1_AH_ESP 4
120 /* NDIS_OFFLOAD_PARAM_NOCHG */
121 #define NDIS_OFFLOAD_LSOV2_OFF 1
122 #define NDIS_OFFLOAD_LSOV2_ON 2
124 /* NDIS_OFFLOAD_PARAM_NOCHG */
125 #define NDIS_OFFLOAD_IPSECV2_OFF 1
126 #define NDIS_OFFLOAD_IPSECV2_AH 2
127 #define NDIS_OFFLOAD_IPSECV2_ESP 3
128 #define NDIS_OFFLOAD_IPSECV2_AH_ESP 4
130 /* NDIS_OFFLOAD_PARAM_NOCHG */
131 #define NDIS_OFFLOAD_RSC_OFF 1
132 #define NDIS_OFFLOAD_RSC_ON 2
135 * OID_GEN_RECEIVE_SCALE_CAPABILITIES
136 * ndis_type: NDIS_OBJTYPE_RSS_CAPS
138 struct ndis_rss_caps {
139 struct ndis_object_hdr ndis_hdr;
140 uint32_t ndis_flags; /* NDIS_RSS_CAP_ */
141 uint32_t ndis_nmsi; /* # of MSIs */
142 uint32_t ndis_nrxr; /* # of RX rings */
144 uint16_t ndis_nind; /* # of indtbl ent. */
148 #define NDIS_RSS_CAPS_SIZE \
149 __offsetof(struct ndis_rss_caps, ndis_pad)
150 #define NDIS_RSS_CAPS_SIZE_6_0 \
151 __offsetof(struct ndis_rss_caps, ndis_nind)
153 #define NDIS_RSS_CAPS_REV_1 1 /* NDIS 6.{0,1,20} */
154 #define NDIS_RSS_CAPS_REV_2 2 /* NDIS 6.30 */
156 #define NDIS_RSS_CAP_MSI 0x01000000
157 #define NDIS_RSS_CAP_CLASSIFY_ISR 0x02000000
158 #define NDIS_RSS_CAP_CLASSIFY_DPC 0x04000000
159 #define NDIS_RSS_CAP_MSIX 0x08000000
160 #define NDIS_RSS_CAP_IPV4 0x00000100
161 #define NDIS_RSS_CAP_IPV6 0x00000200
162 #define NDIS_RSS_CAP_IPV6_EX 0x00000400
163 #define NDIS_RSS_CAP_HASH_TOEPLITZ 0x00000001
166 * OID_GEN_RECEIVE_SCALE_PARAMETERS
167 * ndis_type: NDIS_OBJTYPE_RSS_PARAMS
169 struct ndis_rss_params {
170 struct ndis_object_hdr ndis_hdr;
171 uint16_t ndis_flags; /* NDIS_RSS_FLAG_ */
172 uint16_t ndis_bcpu; /* base cpu 0 */
173 uint32_t ndis_hash; /* NDIS_HASH_ */
174 uint16_t ndis_indsize; /* indirect table */
175 uint32_t ndis_indoffset;
176 uint16_t ndis_keysize; /* hash key */
177 uint32_t ndis_keyoffset;
179 uint32_t ndis_cpumaskoffset;
180 uint32_t ndis_cpumaskcnt;
181 uint32_t ndis_cpumaskentsz;
184 #define NDIS_RSS_PARAMS_SIZE sizeof(struct ndis_rss_params)
185 #define NDIS_RSS_PARAMS_SIZE_6_0 \
186 __offsetof(struct ndis_rss_params, ndis_cpumaskoffset)
188 #define NDIS_RSS_PARAMS_REV_1 1 /* NDIS 6.0 */
189 #define NDIS_RSS_PARAMS_REV_2 2 /* NDIS 6.20 */
191 #define NDIS_RSS_FLAG_BCPU_UNCHG 0x0001
192 #define NDIS_RSS_FLAG_HASH_UNCHG 0x0002
193 #define NDIS_RSS_FLAG_IND_UNCHG 0x0004
194 #define NDIS_RSS_FLAG_KEY_UNCHG 0x0008
195 #define NDIS_RSS_FLAG_DISABLE 0x0010
197 /* non-standard convenient struct */
198 struct ndis_rssprm_toeplitz {
199 struct ndis_rss_params rss_params;
200 /* Toeplitz hash key */
201 uint8_t rss_key[NDIS_HASH_KEYSIZE_TOEPLITZ];
203 uint32_t rss_ind[NDIS_HASH_INDCNT];
211 #define NDIS_VLAN_INFO_SIZE sizeof(uint32_t)
212 #define NDIS_VLAN_INFO_PRI_MASK 0x0007
213 #define NDIS_VLAN_INFO_CFI_MASK 0x0008
214 #define NDIS_VLAN_INFO_ID_MASK 0xfff0
215 #define NDIS_VLAN_INFO_MAKE(id, pri, cfi) \
216 (((pri) & NDIS_VLAN_INFO_PRI_MASK) | \
217 (((cfi) & 0x1) << 3) | (((id) & 0xfff) << 4))
218 #define NDIS_VLAN_INFO_ID(inf) (((inf) & NDIS_VLAN_INFO_ID_MASK) >> 4)
219 #define NDIS_VLAN_INFO_CFI(inf) (((inf) & NDIS_VLAN_INFO_CFI_MASK) >> 3)
220 #define NDIS_VLAN_INFO_PRI(inf) ((inf) & NDIS_VLAN_INFO_PRI_MASK)
222 /* Reception checksum */
223 #define NDIS_RXCSUM_INFO_SIZE sizeof(uint32_t)
224 #define NDIS_RXCSUM_INFO_TCPCS_FAILED 0x0001
225 #define NDIS_RXCSUM_INFO_UDPCS_FAILED 0x0002
226 #define NDIS_RXCSUM_INFO_IPCS_FAILED 0x0004
227 #define NDIS_RXCSUM_INFO_TCPCS_OK 0x0008
228 #define NDIS_RXCSUM_INFO_UDPCS_OK 0x0010
229 #define NDIS_RXCSUM_INFO_IPCS_OK 0x0020
230 #define NDIS_RXCSUM_INFO_LOOPBACK 0x0040
231 #define NDIS_RXCSUM_INFO_TCPCS_INVAL 0x0080
232 #define NDIS_RXCSUM_INFO_IPCS_INVAL 0x0100
235 #define NDIS_LSO2_INFO_SIZE sizeof(uint32_t)
236 #define NDIS_LSO2_INFO_MSS_MASK 0x000fffff
237 #define NDIS_LSO2_INFO_THOFF_MASK 0x3ff00000
238 #define NDIS_LSO2_INFO_ISLSO2 0x40000000
239 #define NDIS_LSO2_INFO_ISIPV6 0x80000000
241 #define NDIS_LSO2_INFO_MAKE(thoff, mss) \
242 ((((uint32_t)(mss)) & NDIS_LSO2_INFO_MSS_MASK) | \
243 ((((uint32_t)(thoff)) & 0x3ff) << 20) | \
244 NDIS_LSO2_INFO_ISLSO2)
246 #define NDIS_LSO2_INFO_MAKEIPV4(thoff, mss) \
247 NDIS_LSO2_INFO_MAKE((thoff), (mss))
249 #define NDIS_LSO2_INFO_MAKEIPV6(thoff, mss) \
250 (NDIS_LSO2_INFO_MAKE((thoff), (mss)) | NDIS_LSO2_INFO_ISIPV6)
252 /* Transmission checksum */
253 #define NDIS_TXCSUM_INFO_SIZE sizeof(uint32_t)
254 #define NDIS_TXCSUM_INFO_IPV4 0x00000001
255 #define NDIS_TXCSUM_INFO_IPV6 0x00000002
256 #define NDIS_TXCSUM_INFO_TCPCS 0x00000004
257 #define NDIS_TXCSUM_INFO_UDPCS 0x00000008
258 #define NDIS_TXCSUM_INFO_IPCS 0x00000010
259 #define NDIS_TXCSUM_INFO_THOFF 0x03ff0000
261 #endif /* !_NET_NDIS_H_ */