if_hvnreg.h revision 1.3 1 /* $NetBSD: if_hvnreg.h,v 1.3 2022/05/20 13:55:17 nonaka Exp $ */
2 /* $OpenBSD: if_hvnreg.h,v 1.3 2016/09/14 17:48:28 mikeb Exp $ */
3
4 /*-
5 * Copyright (c) 2016 Microsoft Corp.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice unmodified, this list of conditions, and the following
13 * disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 #ifndef _IF_HVNREG_H_
31 #define _IF_HVNREG_H_
32
33 #define HVN_NVS_PROTO_VERSION_1 0x00002
34 #define HVN_NVS_PROTO_VERSION_2 0x30002
35 #define HVN_NVS_PROTO_VERSION_4 0x40000
36 #define HVN_NVS_PROTO_VERSION_5 0x50000
37
38 #define HVN_NVS_RXBUF_SIG 0x2409
39 #define HVN_NVS_CHIM_SIG 0x1984
40
41 #define HVN_NVS_CHIM_IDX_INVALID 0xffffffff
42
43 #define HVN_NVS_RNDIS_MTYPE_DATA 0
44 #define HVN_NVS_RNDIS_MTYPE_CTRL 1
45
46 /*
47 * NVS message transacion status codes.
48 */
49 #define HVN_NVS_STATUS_OK 1
50 #define HVN_NVS_STATUS_FAILED 2
51
52 /*
53 * NVS request/response message types.
54 */
55 #define HVN_NVS_TYPE_INIT 1
56 #define HVN_NVS_TYPE_INIT_RESP 2
57 #define HVN_NVS_TYPE_NDIS_INIT 100
58 #define HVN_NVS_TYPE_RXBUF_CONN 101
59 #define HVN_NVS_TYPE_RXBUF_CONNRESP 102
60 #define HVN_NVS_TYPE_RXBUF_DISCONN 103
61 #define HVN_NVS_TYPE_CHIM_CONN 104
62 #define HVN_NVS_TYPE_CHIM_CONNRESP 105
63 #define HVN_NVS_TYPE_CHIM_DISCONN 106
64 #define HVN_NVS_TYPE_RNDIS 107
65 #define HVN_NVS_TYPE_RNDIS_ACK 108
66 #define HVN_NVS_TYPE_NDIS_CONF 125
67 #define HVN_NVS_TYPE_VFASSOC_NOTE 128 /* notification */
68 #define HVN_NVS_TYPE_SET_DATAPATH 129
69 #define HVN_NVS_TYPE_SUBCH_REQ 133
70 #define HVN_NVS_TYPE_SUBCH_RESP 133 /* same as SUBCH_REQ */
71 #define HVN_NVS_TYPE_TXTBL_NOTE 134 /* notification */
72
73 /*
74 * Any size less than this one will _not_ work, e.g. hn_nvs_init
75 * only has 12B valid data, however, if only 12B data were sent,
76 * Hypervisor would never reply.
77 */
78 #define HVN_NVS_REQSIZE_MIN 32
79
80 /* NVS message common header */
81 struct hvn_nvs_hdr {
82 uint32_t nvs_type;
83 } __packed;
84
85 struct hvn_nvs_init {
86 uint32_t nvs_type; /* HVN_NVS_TYPE_INIT */
87 uint32_t nvs_ver_min;
88 uint32_t nvs_ver_max;
89 uint8_t nvs_rsvd[20];
90 } __packed;
91
92 struct hvn_nvs_init_resp {
93 uint32_t nvs_type; /* HVN_NVS_TYPE_INIT_RESP */
94 uint32_t nvs_ver; /* deprecated */
95 uint32_t nvs_rsvd;
96 uint32_t nvs_status; /* HVN_NVS_STATUS_ */
97 } __packed;
98
99 /* No response */
100 struct hvn_nvs_ndis_conf {
101 uint32_t nvs_type; /* HVN_NVS_TYPE_NDIS_CONF */
102 uint32_t nvs_mtu;
103 uint32_t nvs_rsvd;
104 uint64_t nvs_caps; /* HVN_NVS_NDIS_CONF_ */
105 uint8_t nvs_rsvd1[12];
106 } __packed;
107
108 #define HVN_NVS_NDIS_CONF_SRIOV 0x0004
109 #define HVN_NVS_NDIS_CONF_VLAN 0x0008
110
111 /* No response */
112 struct hvn_nvs_ndis_init {
113 uint32_t nvs_type; /* HVN_NVS_TYPE_NDIS_INIT */
114 uint32_t nvs_ndis_major; /* NDIS_VERSION_MAJOR_ */
115 uint32_t nvs_ndis_minor; /* NDIS_VERSION_MINOR_ */
116 uint8_t nvs_rsvd[20];
117 } __packed;
118
119 struct hvn_nvs_rxbuf_conn {
120 uint32_t nvs_type; /* HVN_NVS_TYPE_RXBUF_CONN */
121 uint32_t nvs_gpadl; /* RXBUF vmbus GPADL */
122 uint16_t nvs_sig; /* HVN_NVS_RXBUF_SIG */
123 uint8_t nvs_rsvd[22];
124 } __packed;
125
126 struct hvn_nvs_rxbuf_sect {
127 uint32_t nvs_start;
128 uint32_t nvs_slotsz;
129 uint32_t nvs_slotcnt;
130 uint32_t nvs_end;
131 } __packed;
132
133 struct hvn_nvs_rxbuf_conn_resp {
134 uint32_t nvs_type; /* HVN_NVS_TYPE_RXBUF_CONNRESP */
135 uint32_t nvs_status; /* HVN_NVS_STATUS_ */
136 uint32_t nvs_nsect; /* # of elem in nvs_sect */
137 struct hvn_nvs_rxbuf_sect nvs_sect[0];
138 } __packed;
139
140 /* No response */
141 struct hvn_nvs_rxbuf_disconn {
142 uint32_t nvs_type; /* HVN_NVS_TYPE_RXBUF_DISCONN */
143 uint16_t nvs_sig; /* HVN_NVS_RXBUF_SIG */
144 uint8_t nvs_rsvd[26];
145 } __packed;
146
147 struct hvn_nvs_chim_conn {
148 uint32_t nvs_type; /* HVN_NVS_TYPE_CHIM_CONN */
149 uint32_t nvs_gpadl; /* chimney buf vmbus GPADL */
150 uint16_t nvs_sig; /* NDIS_NVS_CHIM_SIG */
151 uint8_t nvs_rsvd[22];
152 } __packed;
153
154 struct hvn_nvs_chim_conn_resp {
155 uint32_t nvs_type; /* HVN_NVS_TYPE_CHIM_CONNRESP */
156 uint32_t nvs_status; /* HVN_NVS_STATUS_ */
157 uint32_t nvs_sectsz; /* section size */
158 } __packed;
159
160 /* No response */
161 struct hvn_nvs_chim_disconn {
162 uint32_t nvs_type; /* HVN_NVS_TYPE_CHIM_DISCONN */
163 uint16_t nvs_sig; /* HVN_NVS_CHIM_SIG */
164 uint8_t nvs_rsvd[26];
165 } __packed;
166
167 #define HVN_NVS_SUBCH_OP_ALLOC 1
168
169 struct hvn_nvs_subch_req {
170 uint32_t nvs_type; /* HVN_NVS_TYPE_SUBCH_REQ */
171 uint32_t nvs_op; /* HVN_NVS_SUBCH_OP_ */
172 uint32_t nvs_nsubch;
173 uint8_t nvs_rsvd[20];
174 } __packed;
175
176 struct hvn_nvs_subch_resp {
177 uint32_t nvs_type; /* HVN_NVS_TYPE_SUBCH_RESP */
178 uint32_t nvs_status; /* HVN_NVS_STATUS_ */
179 uint32_t nvs_nsubch;
180 } __packed;
181
182 struct hvn_nvs_rndis {
183 uint32_t nvs_type; /* HVN_NVS_TYPE_RNDIS */
184 uint32_t nvs_rndis_mtype;/* HVN_NVS_RNDIS_MTYPE_ */
185 /*
186 * Chimney sending buffer index and size.
187 *
188 * NOTE:
189 * If nvs_chim_idx is set to HVN_NVS_CHIM_IDX_INVALID
190 * and nvs_chim_sz is set to 0, then chimney sending
191 * buffer is _not_ used by this RNDIS message.
192 */
193 uint32_t nvs_chim_idx;
194 uint32_t nvs_chim_sz;
195 uint8_t nvs_rsvd[16];
196 } __packed;
197
198 struct hvn_nvs_rndis_ack {
199 uint32_t nvs_type; /* HVN_NVS_TYPE_RNDIS_ACK */
200 uint32_t nvs_status; /* HVN_NVS_STATUS_ */
201 uint8_t nvs_rsvd[24];
202 } __packed;
203
204 /*
205 * RNDIS extension
206 */
207
208 /* Per-packet hash info */
209 #define HVN_NDIS_HASH_INFO_SIZE sizeof(uint32_t)
210 #define HVN_NDIS_PKTINFO_TYPE_HASHINF NDIS_PKTINFO_TYPE_ORIG_NBLIST
211 /* NDIS_HASH_ */
212
213 /* Per-packet hash value */
214 #define HVN_NDIS_HASH_VALUE_SIZE sizeof(uint32_t)
215 #define HVN_NDIS_PKTINFO_TYPE_HASHVAL NDIS_PKTINFO_TYPE_PKT_CANCELID
216
217 /* Per-packet-info size */
218 #define HVN_RNDIS_PKTINFO_SIZE(dlen) \
219 offsetof(struct rndis_pktinfo, rm_data[dlen])
220
221 #endif /* _IF_HVNREG_H_ */
222