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 #include <sys/param.h>
33 #include <sys/systm.h>
36 * NDIS protocol version numbers
38 #define HN_NDIS_VERSION_6_1 0x00060001
39 #define HN_NDIS_VERSION_6_30 0x0006001e
40 #define HN_NDIS_VERSION_MAJOR(ver) (((ver) & 0xffff0000) >> 16)
41 #define HN_NDIS_VERSION_MINOR(ver) ((ver) & 0xffff)
46 #define HN_NVS_VERSION_1 0x00002
47 #define HN_NVS_VERSION_2 0x30002
48 #define HN_NVS_VERSION_4 0x40000
49 #define HN_NVS_VERSION_5 0x50000
51 #define HN_NVS_RXBUF_SIG 0xcafe
52 #define HN_NVS_CHIM_SIG 0xface
54 #define HN_NVS_CHIM_IDX_INVALID 0xffffffff
56 #define HN_NVS_RNDIS_MTYPE_DATA 0
57 #define HN_NVS_RNDIS_MTYPE_CTRL 1
60 * NVS message transacion status codes.
62 #define HN_NVS_STATUS_OK 1
63 #define HN_NVS_STATUS_FAILED 2
66 * NVS request/response message types.
68 #define HN_NVS_TYPE_INIT 1
69 #define HN_NVS_TYPE_INIT_RESP 2
70 #define HN_NVS_TYPE_NDIS_INIT 100
71 #define HN_NVS_TYPE_RXBUF_CONN 101
72 #define HN_NVS_TYPE_RXBUF_CONNRESP 102
73 #define HN_NVS_TYPE_RXBUF_DISCONN 103
74 #define HN_NVS_TYPE_CHIM_CONN 104
75 #define HN_NVS_TYPE_CHIM_CONNRESP 105
76 #define HN_NVS_TYPE_CHIM_DISCONN 106
77 #define HN_NVS_TYPE_RNDIS 107
78 #define HN_NVS_TYPE_RNDIS_ACK 108
79 #define HN_NVS_TYPE_NDIS_CONF 125
80 #define HN_NVS_TYPE_VFASSOC_NOTE 128 /* notification */
81 #define HN_NVS_TYPE_SET_DATAPATH 129
82 #define HN_NVS_TYPE_SUBCH_REQ 133
83 #define HN_NVS_TYPE_SUBCH_RESP 133 /* same as SUBCH_REQ */
84 #define HN_NVS_TYPE_TXTBL_NOTE 134 /* notification */
87 * Any size less than this one will _not_ work, e.g. hn_nvs_init
88 * only has 12B valid data, however, if only 12B data were sent,
89 * Hypervisor would never reply.
91 #define HN_NVS_REQSIZE_MIN 32
93 /* NVS message common header */
99 uint32_t nvs_type; /* HN_NVS_TYPE_INIT */
100 uint32_t nvs_ver_min;
101 uint32_t nvs_ver_max;
102 uint8_t nvs_rsvd[20];
104 CTASSERT(sizeof(struct hn_nvs_init) >= HN_NVS_REQSIZE_MIN);
106 struct hn_nvs_init_resp {
107 uint32_t nvs_type; /* HN_NVS_TYPE_INIT_RESP */
108 uint32_t nvs_ver; /* deprecated */
110 uint32_t nvs_status; /* HN_NVS_STATUS_ */
114 struct hn_nvs_ndis_conf {
115 uint32_t nvs_type; /* HN_NVS_TYPE_NDIS_CONF */
118 uint64_t nvs_caps; /* HN_NVS_NDIS_CONF_ */
119 uint8_t nvs_rsvd1[12];
121 CTASSERT(sizeof(struct hn_nvs_ndis_conf) >= HN_NVS_REQSIZE_MIN);
123 #define HN_NVS_NDIS_CONF_SRIOV 0x0004
124 #define HN_NVS_NDIS_CONF_VLAN 0x0008
127 struct hn_nvs_ndis_init {
128 uint32_t nvs_type; /* HN_NVS_TYPE_NDIS_INIT */
129 uint32_t nvs_ndis_major; /* NDIS_VERSION_MAJOR_ */
130 uint32_t nvs_ndis_minor; /* NDIS_VERSION_MINOR_ */
131 uint8_t nvs_rsvd[20];
133 CTASSERT(sizeof(struct hn_nvs_ndis_init) >= HN_NVS_REQSIZE_MIN);
135 struct hn_nvs_rxbuf_conn {
136 uint32_t nvs_type; /* HN_NVS_TYPE_RXBUF_CONN */
137 uint32_t nvs_gpadl; /* RXBUF vmbus GPADL */
138 uint16_t nvs_sig; /* HN_NVS_RXBUF_SIG */
139 uint8_t nvs_rsvd[22];
141 CTASSERT(sizeof(struct hn_nvs_rxbuf_conn) >= HN_NVS_REQSIZE_MIN);
143 struct hn_nvs_rxbuf_sect {
146 uint32_t nvs_slotcnt;
150 struct hn_nvs_rxbuf_connresp {
151 uint32_t nvs_type; /* HN_NVS_TYPE_RXBUF_CONNRESP */
152 uint32_t nvs_status; /* HN_NVS_STATUS_ */
153 uint32_t nvs_nsect; /* # of elem in nvs_sect */
154 struct hn_nvs_rxbuf_sect nvs_sect[];
158 struct hn_nvs_rxbuf_disconn {
159 uint32_t nvs_type; /* HN_NVS_TYPE_RXBUF_DISCONN */
160 uint16_t nvs_sig; /* HN_NVS_RXBUF_SIG */
161 uint8_t nvs_rsvd[26];
163 CTASSERT(sizeof(struct hn_nvs_rxbuf_disconn) >= HN_NVS_REQSIZE_MIN);
165 struct hn_nvs_chim_conn {
166 uint32_t nvs_type; /* HN_NVS_TYPE_CHIM_CONN */
167 uint32_t nvs_gpadl; /* chimney buf vmbus GPADL */
168 uint16_t nvs_sig; /* NDIS_NVS_CHIM_SIG */
169 uint8_t nvs_rsvd[22];
171 CTASSERT(sizeof(struct hn_nvs_chim_conn) >= HN_NVS_REQSIZE_MIN);
173 struct hn_nvs_chim_connresp {
174 uint32_t nvs_type; /* HN_NVS_TYPE_CHIM_CONNRESP */
175 uint32_t nvs_status; /* HN_NVS_STATUS_ */
176 uint32_t nvs_sectsz; /* section size */
180 struct hn_nvs_chim_disconn {
181 uint32_t nvs_type; /* HN_NVS_TYPE_CHIM_DISCONN */
182 uint16_t nvs_sig; /* HN_NVS_CHIM_SIG */
183 uint8_t nvs_rsvd[26];
185 CTASSERT(sizeof(struct hn_nvs_chim_disconn) >= HN_NVS_REQSIZE_MIN);
187 #define HN_NVS_SUBCH_OP_ALLOC 1
189 struct hn_nvs_subch_req {
190 uint32_t nvs_type; /* HN_NVS_TYPE_SUBCH_REQ */
191 uint32_t nvs_op; /* HN_NVS_SUBCH_OP_ */
193 uint8_t nvs_rsvd[20];
195 CTASSERT(sizeof(struct hn_nvs_subch_req) >= HN_NVS_REQSIZE_MIN);
197 struct hn_nvs_subch_resp {
198 uint32_t nvs_type; /* HN_NVS_TYPE_SUBCH_RESP */
199 uint32_t nvs_status; /* HN_NVS_STATUS_ */
203 struct hn_nvs_rndis {
204 uint32_t nvs_type; /* HN_NVS_TYPE_RNDIS */
205 uint32_t nvs_rndis_mtype;/* HN_NVS_RNDIS_MTYPE_ */
207 * Chimney sending buffer index and size.
210 * If nvs_chim_idx is set to HN_NVS_CHIM_IDX_INVALID
211 * and nvs_chim_sz is set to 0, then chimney sending
212 * buffer is _not_ used by this RNDIS message.
214 uint32_t nvs_chim_idx;
215 uint32_t nvs_chim_sz;
216 uint8_t nvs_rsvd[16];
218 CTASSERT(sizeof(struct hn_nvs_rndis) >= HN_NVS_REQSIZE_MIN);
220 struct hn_nvs_rndis_ack {
221 uint32_t nvs_type; /* HN_NVS_TYPE_RNDIS_ACK */
222 uint32_t nvs_status; /* HN_NVS_STATUS_ */
223 uint8_t nvs_rsvd[24];
225 CTASSERT(sizeof(struct hn_nvs_rndis_ack) >= HN_NVS_REQSIZE_MIN);
231 /* Per-packet hash info */
232 #define HN_NDIS_HASH_INFO_SIZE sizeof(uint32_t)
233 #define HN_NDIS_PKTINFO_TYPE_HASHINF NDIS_PKTINFO_TYPE_ORIG_NBLIST
236 /* Per-packet hash value */
237 #define HN_NDIS_HASH_VALUE_SIZE sizeof(uint32_t)
238 #define HN_NDIS_PKTINFO_TYPE_HASHVAL NDIS_PKTINFO_TYPE_PKT_CANCELID
240 /* Per-packet-info size */
241 #define HN_RNDIS_PKTINFO_SIZE(dlen) \
242 __offsetof(struct rndis_pktinfo, rm_data[dlen])
244 #endif /* !_IF_HNREG_H_ */