1 /*- 2 * Copyright (c) 2016 Microsoft Corp. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice unmodified, this list of conditions, and the following 10 * disclaimer. 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. 14 * 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. 25 * 26 * $FreeBSD$ 27 */ 28 29 #ifndef _NET_NDIS_H_ 30 #define _NET_NDIS_H_ 31 32 #define NDIS_MEDIA_STATE_CONNECTED 0 33 #define NDIS_MEDIA_STATE_DISCONNECTED 1 34 35 #define OID_GEN_RSS_CAPABILITIES 0x00010203 36 #define OID_GEN_RSS_PARAMETERS 0x00010204 37 #define OID_TCP_OFFLOAD_PARAMETERS 0xFC01020C 38 39 #define NDIS_OBJTYPE_DEFAULT 0x80 40 #define NDIS_OBJTYPE_RSS_CAPS 0x88 41 #define NDIS_OBJTYPE_RSS_PARAMS 0x89 42 43 /* common_set */ 44 #define NDIS_OFFLOAD_SET_NOCHG 0 45 #define NDIS_OFFLOAD_SET_ON 1 46 #define NDIS_OFFLOAD_SET_OFF 2 47 48 /* a.k.a GRE MAC */ 49 #define NDIS_ENCAP_TYPE_NVGRE 0x00000001 50 51 #define NDIS_HASH_FUNCTION_MASK 0x000000FF /* see hash function */ 52 #define NDIS_HASH_TYPE_MASK 0x00FFFF00 /* see hash type */ 53 54 /* hash function */ 55 #define NDIS_HASH_FUNCTION_TOEPLITZ 0x00000001 56 57 /* hash type */ 58 #define NDIS_HASH_IPV4 0x00000100 59 #define NDIS_HASH_TCP_IPV4 0x00000200 60 #define NDIS_HASH_IPV6 0x00000400 61 #define NDIS_HASH_IPV6_EX 0x00000800 62 #define NDIS_HASH_TCP_IPV6 0x00001000 63 #define NDIS_HASH_TCP_IPV6_EX 0x00002000 64 65 #define NDIS_HASH_KEYSIZE_TOEPLITZ 40 66 #define NDIS_HASH_INDCNT 128 67 68 struct ndis_object_hdr { 69 uint8_t ndis_type; /* NDIS_OBJTYPE_ */ 70 uint8_t ndis_rev; /* type specific */ 71 uint16_t ndis_size; /* incl. this hdr */ 72 }; 73 74 /* 75 * OID_TCP_OFFLOAD_PARAMETERS 76 * ndis_type: NDIS_OBJTYPE_DEFAULT 77 */ 78 struct ndis_offload_params { 79 struct ndis_object_hdr ndis_hdr; 80 uint8_t ndis_ip4csum; /* param_set */ 81 uint8_t ndis_tcp4csum; /* param_set */ 82 uint8_t ndis_udp4csum; /* param_set */ 83 uint8_t ndis_tcp6csum; /* param_set */ 84 uint8_t ndis_udp6csum; /* param_set */ 85 uint8_t ndis_lsov1; /* lsov1_set */ 86 uint8_t ndis_ipsecv1; /* ipsecv1_set */ 87 uint8_t ndis_lsov2_ip4; /* lsov2_set */ 88 uint8_t ndis_lsov2_ip6; /* lsov2_set */ 89 uint8_t ndis_tcp4conn; /* PARAM_NOCHG */ 90 uint8_t ndis_tcp6conn; /* PARAM_NOCHG */ 91 uint32_t ndis_flags; /* 0 */ 92 /* NDIS >= 6.1 */ 93 uint8_t ndis_ipsecv2; /* ipsecv2_set */ 94 uint8_t ndis_ipsecv2_ip4; /* ipsecv2_set */ 95 /* NDIS >= 6.30 */ 96 uint8_t ndis_rsc_ip4; /* rsc_set */ 97 uint8_t ndis_rsc_ip6; /* rsc_set */ 98 uint8_t ndis_encap; /* common_set */ 99 uint8_t ndis_encap_types; /* NDIS_ENCAP_TYPE_ */ 100 }; 101 102 #define NDIS_OFFLOAD_PARAMS_SIZE sizeof(struct ndis_offload_params) 103 #define NDIS_OFFLOAD_PARAMS_SIZE_6_1 \ 104 __offsetof(struct ndis_offload_params, ndis_rsc_ip4) 105 106 #define NDIS_OFFLOAD_PARAMS_REV_2 2 /* NDIS 6.1 */ 107 #define NDIS_OFFLOAD_PARAMS_REV_3 3 /* NDIS 6.30 */ 108 109 /* param_set */ 110 #define NDIS_OFFLOAD_PARAM_NOCHG 0 /* common to all sets */ 111 #define NDIS_OFFLOAD_PARAM_OFF 1 112 #define NDIS_OFFLOAD_PARAM_TX 2 113 #define NDIS_OFFLOAD_PARAM_RX 3 114 #define NDIS_OFFLOAD_PARAM_TXRX 4 115 116 /* lsov1_set */ 117 /* NDIS_OFFLOAD_PARAM_NOCHG */ 118 #define NDIS_OFFLOAD_LSOV1_OFF 1 119 #define NDIS_OFFLOAD_LSOV1_ON 2 120 121 /* ipsecv1_set */ 122 /* NDIS_OFFLOAD_PARAM_NOCHG */ 123 #define NDIS_OFFLOAD_IPSECV1_OFF 1 124 #define NDIS_OFFLOAD_IPSECV1_AH 2 125 #define NDIS_OFFLOAD_IPSECV1_ESP 3 126 #define NDIS_OFFLOAD_IPSECV1_AH_ESP 4 127 128 /* lsov2_set */ 129 /* NDIS_OFFLOAD_PARAM_NOCHG */ 130 #define NDIS_OFFLOAD_LSOV2_OFF 1 131 #define NDIS_OFFLOAD_LSOV2_ON 2 132 133 /* ipsecv2_set */ 134 /* NDIS_OFFLOAD_PARAM_NOCHG */ 135 #define NDIS_OFFLOAD_IPSECV2_OFF 1 136 #define NDIS_OFFLOAD_IPSECV2_AH 2 137 #define NDIS_OFFLOAD_IPSECV2_ESP 3 138 #define NDIS_OFFLOAD_IPSECV2_AH_ESP 4 139 140 /* rsc_set */ 141 /* NDIS_OFFLOAD_PARAM_NOCHG */ 142 #define NDIS_OFFLOAD_RSC_OFF 1 143 #define NDIS_OFFLOAD_RSC_ON 2 144 145 /* 146 * OID_GEN_RSS_CAPABILITIES 147 * ndis_type: NDIS_OBJTYPE_RSS_CAPS 148 */ 149 struct ndis_rss_caps { 150 struct ndis_object_hdr ndis_hdr; 151 uint32_t ndis_flags; /* NDIS_RSS_CAP_ */ 152 uint32_t ndis_nmsi; /* # of MSIs */ 153 uint32_t ndis_nrxr; /* # of RX rings */ 154 /* NDIS >= 6.30 */ 155 uint16_t ndis_nind; /* # of indtbl ent. */ 156 uint16_t ndis_pad; 157 }; 158 159 #define NDIS_RSS_CAPS_SIZE \ 160 __offsetof(struct ndis_rss_caps, ndis_pad) 161 #define NDIS_RSS_CAPS_SIZE_6_0 \ 162 __offsetof(struct ndis_rss_caps, ndis_nind) 163 164 #define NDIS_RSS_CAPS_REV_1 1 /* NDIS 6.{0,1,20} */ 165 #define NDIS_RSS_CAPS_REV_2 2 /* NDIS 6.30 */ 166 167 #define NDIS_RSS_CAP_MSI 0x01000000 168 #define NDIS_RSS_CAP_CLASSIFY_ISR 0x02000000 169 #define NDIS_RSS_CAP_CLASSIFY_DPC 0x04000000 170 #define NDIS_RSS_CAP_MSIX 0x08000000 171 #define NDIS_RSS_CAP_IPV4 0x00000100 172 #define NDIS_RSS_CAP_IPV6 0x00000200 173 #define NDIS_RSS_CAP_IPV6_EX 0x00000400 174 #define NDIS_RSS_CAP_HASH_TOEPLITZ 0x00000001 175 176 /* 177 * OID_GEN_RSS_PARAMETERS 178 * ndis_type: NDIS_OBJTYPE_RSS_PARAMS 179 */ 180 struct ndis_rss_params { 181 struct ndis_object_hdr ndis_hdr; 182 uint16_t ndis_flags; /* NDIS_RSS_FLAG_ */ 183 uint16_t ndis_bcpu; /* base cpu 0 */ 184 uint32_t ndis_hash; /* NDIS_HASH_ */ 185 uint16_t ndis_indsize; /* indirect table */ 186 uint32_t ndis_indoffset; 187 uint16_t ndis_keysize; /* hash key */ 188 uint32_t ndis_keyoffset; 189 /* NDIS >= 6.20 */ 190 uint32_t ndis_cpumaskoffset; 191 uint32_t ndis_cpumaskcnt; 192 uint32_t ndis_cpumaskentsz; 193 }; 194 195 #define NDIS_RSS_PARAMS_SIZE sizeof(struct ndis_rss_params) 196 #define NDIS_RSS_PARAMS_SIZE_6_0 \ 197 __offsetof(struct ndis_rss_params, ndis_cpumaskoffset) 198 199 #define NDIS_RSS_PARAMS_REV_1 1 /* NDIS 6.0 */ 200 #define NDIS_RSS_PARAMS_REV_2 2 /* NDIS 6.20 */ 201 202 #define NDIS_RSS_FLAG_BCPU_UNCHG 0x0001 203 #define NDIS_RSS_FLAG_HASH_UNCHG 0x0002 204 #define NDIS_RSS_FLAG_IND_UNCHG 0x0004 205 #define NDIS_RSS_FLAG_KEY_UNCHG 0x0008 206 #define NDIS_RSS_FLAG_DISABLE 0x0010 207 208 /* non-standard convenient struct */ 209 struct ndis_rssprm_toeplitz { 210 struct ndis_rss_params rss_params; 211 /* Toeplitz hash key */ 212 uint8_t rss_key[NDIS_HASH_KEYSIZE_TOEPLITZ]; 213 /* Indirect table */ 214 uint32_t rss_ind[NDIS_HASH_INDCNT]; 215 }; 216 217 #endif /* !_NET_NDIS_H_ */ 218