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>
35 #define HN_NVS_RXBUF_SIG 0xcafe
36 #define HN_NVS_CHIM_SIG 0xface
38 #define HN_NVS_CHIM_IDX_INVALID 0xffffffff
40 #define HN_NVS_RNDIS_MTYPE_DATA 0
41 #define HN_NVS_RNDIS_MTYPE_CTRL 1
44 * NVS message transacion status codes.
46 #define HN_NVS_STATUS_OK 1
47 #define HN_NVS_STATUS_FAILED 2
50 * NVS request/response message types.
52 #define HN_NVS_TYPE_INIT 1
53 #define HN_NVS_TYPE_INIT_RESP 2
54 #define HN_NVS_TYPE_NDIS_INIT 100
55 #define HN_NVS_TYPE_RXBUF_CONN 101
56 #define HN_NVS_TYPE_RXBUF_CONNRESP 102
57 #define HN_NVS_TYPE_RXBUF_DISCONN 103
58 #define HN_NVS_TYPE_CHIM_CONN 104
59 #define HN_NVS_TYPE_CHIM_CONNRESP 105
60 #define HN_NVS_TYPE_CHIM_DISCONN 106
61 #define HN_NVS_TYPE_RNDIS 107
62 #define HN_NVS_TYPE_RNDIS_ACK 108
63 #define HN_NVS_TYPE_NDIS_CONF 125
64 #define HN_NVS_TYPE_VFASSOC_NOTE 128 /* notification */
65 #define HN_NVS_TYPE_SET_DATAPATH 129
66 #define HN_NVS_TYPE_SUBCH_REQ 133
67 #define HN_NVS_TYPE_SUBCH_RESP 133 /* same as SUBCH_REQ */
68 #define HN_NVS_TYPE_TXTBL_NOTE 134 /* notification */
71 * Any size less than this one will _not_ work, e.g. hn_nvs_init
72 * only has 12B valid data, however, if only 12B data were sent,
73 * Hypervisor would never reply.
75 #define HN_NVS_REQSIZE_MIN 32
77 /* NVS message common header */
83 uint32_t nvs_type; /* HN_NVS_TYPE_INIT */
88 CTASSERT(sizeof(struct hn_nvs_init) >= HN_NVS_REQSIZE_MIN);
90 struct hn_nvs_init_resp {
91 uint32_t nvs_type; /* HN_NVS_TYPE_INIT_RESP */
92 uint32_t nvs_ver; /* deprecated */
94 uint32_t nvs_status; /* HN_NVS_STATUS_ */
98 struct hn_nvs_ndis_conf {
99 uint32_t nvs_type; /* HN_NVS_TYPE_NDIS_CONF */
102 uint64_t nvs_caps; /* HN_NVS_NDIS_CONF_ */
103 uint8_t nvs_rsvd1[12];
105 CTASSERT(sizeof(struct hn_nvs_ndis_conf) >= HN_NVS_REQSIZE_MIN);
107 #define HN_NVS_NDIS_CONF_SRIOV 0x0004
108 #define HN_NVS_NDIS_CONF_VLAN 0x0008
111 struct hn_nvs_ndis_init {
112 uint32_t nvs_type; /* HN_NVS_TYPE_NDIS_INIT */
113 uint32_t nvs_ndis_major; /* NDIS_VERSION_MAJOR_ */
114 uint32_t nvs_ndis_minor; /* NDIS_VERSION_MINOR_ */
115 uint8_t nvs_rsvd[20];
117 CTASSERT(sizeof(struct hn_nvs_ndis_init) >= HN_NVS_REQSIZE_MIN);
119 struct hn_nvs_rxbuf_conn {
120 uint32_t nvs_type; /* HN_NVS_TYPE_RXBUF_CONN */
121 uint32_t nvs_gpadl; /* RXBUF vmbus GPADL */
122 uint16_t nvs_sig; /* HN_NVS_RXBUF_SIG */
123 uint8_t nvs_rsvd[22];
125 CTASSERT(sizeof(struct hn_nvs_rxbuf_conn) >= HN_NVS_REQSIZE_MIN);
127 struct hn_nvs_rxbuf_sect {
130 uint32_t nvs_slotcnt;
134 struct hn_nvs_rxbuf_connresp {
135 uint32_t nvs_type; /* HN_NVS_TYPE_RXBUF_CONNRESP */
136 uint32_t nvs_status; /* HN_NVS_STATUS_ */
137 uint32_t nvs_nsect; /* # of elem in nvs_sect */
138 struct hn_nvs_rxbuf_sect nvs_sect[];
142 struct hn_nvs_rxbuf_disconn {
143 uint32_t nvs_type; /* HN_NVS_TYPE_RXBUF_DISCONN */
144 uint16_t nvs_sig; /* HN_NVS_RXBUF_SIG */
145 uint8_t nvs_rsvd[26];
147 CTASSERT(sizeof(struct hn_nvs_rxbuf_disconn) >= HN_NVS_REQSIZE_MIN);
149 struct hn_nvs_chim_conn {
150 uint32_t nvs_type; /* HN_NVS_TYPE_CHIM_CONN */
151 uint32_t nvs_gpadl; /* chimney buf vmbus GPADL */
152 uint16_t nvs_sig; /* NDIS_NVS_CHIM_SIG */
153 uint8_t nvs_rsvd[22];
155 CTASSERT(sizeof(struct hn_nvs_chim_conn) >= HN_NVS_REQSIZE_MIN);
157 struct hn_nvs_chim_connresp {
158 uint32_t nvs_type; /* HN_NVS_TYPE_CHIM_CONNRESP */
159 uint32_t nvs_status; /* HN_NVS_STATUS_ */
160 uint32_t nvs_sectsz; /* section size */
164 struct hn_nvs_chim_disconn {
165 uint32_t nvs_type; /* HN_NVS_TYPE_CHIM_DISCONN */
166 uint16_t nvs_sig; /* HN_NVS_CHIM_SIG */
167 uint8_t nvs_rsvd[26];
169 CTASSERT(sizeof(struct hn_nvs_chim_disconn) >= HN_NVS_REQSIZE_MIN);
171 #define HN_NVS_SUBCH_OP_ALLOC 1
173 struct hn_nvs_subch_req {
174 uint32_t nvs_type; /* HN_NVS_TYPE_SUBCH_REQ */
175 uint32_t nvs_op; /* HN_NVS_SUBCH_OP_ */
177 uint8_t nvs_rsvd[20];
179 CTASSERT(sizeof(struct hn_nvs_subch_req) >= HN_NVS_REQSIZE_MIN);
181 struct hn_nvs_subch_resp {
182 uint32_t nvs_type; /* HN_NVS_TYPE_SUBCH_RESP */
183 uint32_t nvs_status; /* HN_NVS_STATUS_ */
187 struct hn_nvs_rndis {
188 uint32_t nvs_type; /* HN_NVS_TYPE_RNDIS */
189 uint32_t nvs_rndis_mtype;/* HN_NVS_RNDIS_MTYPE_ */
191 * Chimney sending buffer index and size.
194 * If nvs_chim_idx is set to HN_NVS_CHIM_IDX_INVALID
195 * and nvs_chim_sz is set to 0, then chimney sending
196 * buffer is _not_ used by this RNDIS message.
198 uint32_t nvs_chim_idx;
199 uint32_t nvs_chim_sz;
200 uint8_t nvs_rsvd[16];
202 CTASSERT(sizeof(struct hn_nvs_rndis) >= HN_NVS_REQSIZE_MIN);
204 struct hn_nvs_rndis_ack {
205 uint32_t nvs_type; /* HN_NVS_TYPE_RNDIS_ACK */
206 uint32_t nvs_status; /* HN_NVS_STATUS_ */
207 uint8_t nvs_rsvd[24];
209 CTASSERT(sizeof(struct hn_nvs_rndis_ack) >= HN_NVS_REQSIZE_MIN);
215 /* Per-packet hash info */
216 #define HN_NDIS_HASH_INFO_SIZE sizeof(uint32_t)
217 #define HN_NDIS_PKTINFO_TYPE_HASHINF NDIS_PKTINFO_TYPE_ORIG_NBLIST
220 /* Per-packet hash value */
221 #define HN_NDIS_HASH_VALUE_SIZE sizeof(uint32_t)
222 #define HN_NDIS_PKTINFO_TYPE_HASHVAL NDIS_PKTINFO_TYPE_PKT_CANCELID
224 #endif /* !_IF_HNREG_H_ */