xref: /freebsd/sys/dev/hyperv/netvsc/if_hnreg.h (revision 61b88a230bac766f55984d8d33b98845d2b0d1a9)
1584e7c57SSepherosa Ziehau /*-
293b4e111SSepherosa Ziehau  * Copyright (c) 2016-2017 Microsoft Corp.
3584e7c57SSepherosa Ziehau  * All rights reserved.
4584e7c57SSepherosa Ziehau  *
5584e7c57SSepherosa Ziehau  * Redistribution and use in source and binary forms, with or without
6584e7c57SSepherosa Ziehau  * modification, are permitted provided that the following conditions
7584e7c57SSepherosa Ziehau  * are met:
8584e7c57SSepherosa Ziehau  * 1. Redistributions of source code must retain the above copyright
9584e7c57SSepherosa Ziehau  *    notice unmodified, this list of conditions, and the following
10584e7c57SSepherosa Ziehau  *    disclaimer.
11584e7c57SSepherosa Ziehau  * 2. Redistributions in binary form must reproduce the above copyright
12584e7c57SSepherosa Ziehau  *    notice, this list of conditions and the following disclaimer in the
13584e7c57SSepherosa Ziehau  *    documentation and/or other materials provided with the distribution.
14584e7c57SSepherosa Ziehau  *
15584e7c57SSepherosa Ziehau  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16584e7c57SSepherosa Ziehau  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17584e7c57SSepherosa Ziehau  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18584e7c57SSepherosa Ziehau  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19584e7c57SSepherosa Ziehau  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20584e7c57SSepherosa Ziehau  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21584e7c57SSepherosa Ziehau  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22584e7c57SSepherosa Ziehau  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23584e7c57SSepherosa Ziehau  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24584e7c57SSepherosa Ziehau  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25584e7c57SSepherosa Ziehau  */
26584e7c57SSepherosa Ziehau 
27584e7c57SSepherosa Ziehau #ifndef _IF_HNREG_H_
28584e7c57SSepherosa Ziehau #define _IF_HNREG_H_
29584e7c57SSepherosa Ziehau 
30584e7c57SSepherosa Ziehau #include <sys/param.h>
31584e7c57SSepherosa Ziehau #include <sys/systm.h>
32584e7c57SSepherosa Ziehau 
33b67f3d28SSepherosa Ziehau /*
34b67f3d28SSepherosa Ziehau  * NDIS protocol version numbers
35b67f3d28SSepherosa Ziehau  */
36b67f3d28SSepherosa Ziehau #define HN_NDIS_VERSION_6_1		0x00060001
370634f75cSSepherosa Ziehau #define HN_NDIS_VERSION_6_20		0x00060014
38b67f3d28SSepherosa Ziehau #define HN_NDIS_VERSION_6_30		0x0006001e
39b67f3d28SSepherosa Ziehau #define HN_NDIS_VERSION_MAJOR(ver)	(((ver) & 0xffff0000) >> 16)
40b67f3d28SSepherosa Ziehau #define HN_NDIS_VERSION_MINOR(ver)	((ver) & 0xffff)
41b67f3d28SSepherosa Ziehau 
42021deeceSSepherosa Ziehau /*
43021deeceSSepherosa Ziehau  * NVS versions.
44021deeceSSepherosa Ziehau  */
45021deeceSSepherosa Ziehau #define HN_NVS_VERSION_1		0x00002
46021deeceSSepherosa Ziehau #define HN_NVS_VERSION_2		0x30002
47021deeceSSepherosa Ziehau #define HN_NVS_VERSION_4		0x40000
48021deeceSSepherosa Ziehau #define HN_NVS_VERSION_5		0x50000
49a491581fSWei Hu #define HN_NVS_VERSION_6		0x60000
50a491581fSWei Hu #define HN_NVS_VERSION_61		0x60001
51021deeceSSepherosa Ziehau 
52d293af40SSepherosa Ziehau #define HN_NVS_RXBUF_SIG		0xcafe
5355c4b97bSSepherosa Ziehau #define HN_NVS_CHIM_SIG			0xface
54d293af40SSepherosa Ziehau 
5562c4e6e9SSepherosa Ziehau #define HN_NVS_CHIM_IDX_INVALID		0xffffffff
5662c4e6e9SSepherosa Ziehau 
5762c4e6e9SSepherosa Ziehau #define HN_NVS_RNDIS_MTYPE_DATA		0
5862c4e6e9SSepherosa Ziehau #define HN_NVS_RNDIS_MTYPE_CTRL		1
5962c4e6e9SSepherosa Ziehau 
6062c4e6e9SSepherosa Ziehau /*
61*61b88a23SGordon Bergling  * NVS message transaction status codes.
6262c4e6e9SSepherosa Ziehau  */
63584e7c57SSepherosa Ziehau #define HN_NVS_STATUS_OK		1
645f0dee26SSepherosa Ziehau #define HN_NVS_STATUS_FAILED		2
65584e7c57SSepherosa Ziehau 
6662c4e6e9SSepherosa Ziehau /*
6762c4e6e9SSepherosa Ziehau  * NVS request/response message types.
6862c4e6e9SSepherosa Ziehau  */
69584e7c57SSepherosa Ziehau #define HN_NVS_TYPE_INIT		1
70584e7c57SSepherosa Ziehau #define HN_NVS_TYPE_INIT_RESP		2
71386c97e6SSepherosa Ziehau #define HN_NVS_TYPE_NDIS_INIT		100
72d293af40SSepherosa Ziehau #define HN_NVS_TYPE_RXBUF_CONN		101
73d293af40SSepherosa Ziehau #define HN_NVS_TYPE_RXBUF_CONNRESP	102
748b204d66SSepherosa Ziehau #define HN_NVS_TYPE_RXBUF_DISCONN	103
7555c4b97bSSepherosa Ziehau #define HN_NVS_TYPE_CHIM_CONN		104
7655c4b97bSSepherosa Ziehau #define HN_NVS_TYPE_CHIM_CONNRESP	105
77a04b666aSSepherosa Ziehau #define HN_NVS_TYPE_CHIM_DISCONN	106
7862c4e6e9SSepherosa Ziehau #define HN_NVS_TYPE_RNDIS		107
795f0dee26SSepherosa Ziehau #define HN_NVS_TYPE_RNDIS_ACK		108
809b392221SSepherosa Ziehau #define HN_NVS_TYPE_NDIS_CONF		125
8146911ec7SSepherosa Ziehau #define HN_NVS_TYPE_VFASSOC_NOTE	128	/* notification */
8246911ec7SSepherosa Ziehau #define HN_NVS_TYPE_SET_DATAPATH	129
830f9b8485SSepherosa Ziehau #define HN_NVS_TYPE_SUBCH_REQ		133
840f9b8485SSepherosa Ziehau #define HN_NVS_TYPE_SUBCH_RESP		133	/* same as SUBCH_REQ */
8546911ec7SSepherosa Ziehau #define HN_NVS_TYPE_TXTBL_NOTE		134	/* notification */
86584e7c57SSepherosa Ziehau 
87584e7c57SSepherosa Ziehau /*
88584e7c57SSepherosa Ziehau  * Any size less than this one will _not_ work, e.g. hn_nvs_init
89584e7c57SSepherosa Ziehau  * only has 12B valid data, however, if only 12B data were sent,
90584e7c57SSepherosa Ziehau  * Hypervisor would never reply.
91584e7c57SSepherosa Ziehau  */
92584e7c57SSepherosa Ziehau #define HN_NVS_REQSIZE_MIN		32
93584e7c57SSepherosa Ziehau 
94de56155fSSepherosa Ziehau /* NVS message common header */
95de56155fSSepherosa Ziehau struct hn_nvs_hdr {
96de56155fSSepherosa Ziehau 	uint32_t	nvs_type;
97de56155fSSepherosa Ziehau } __packed;
98de56155fSSepherosa Ziehau 
99584e7c57SSepherosa Ziehau struct hn_nvs_init {
100584e7c57SSepherosa Ziehau 	uint32_t	nvs_type;	/* HN_NVS_TYPE_INIT */
101584e7c57SSepherosa Ziehau 	uint32_t	nvs_ver_min;
102584e7c57SSepherosa Ziehau 	uint32_t	nvs_ver_max;
103584e7c57SSepherosa Ziehau 	uint8_t		nvs_rsvd[20];
104a491581fSWei Hu 	uint8_t		nvs_msg_pad[8];
105584e7c57SSepherosa Ziehau } __packed;
106584e7c57SSepherosa Ziehau CTASSERT(sizeof(struct hn_nvs_init) >= HN_NVS_REQSIZE_MIN);
107584e7c57SSepherosa Ziehau 
108584e7c57SSepherosa Ziehau struct hn_nvs_init_resp {
109584e7c57SSepherosa Ziehau 	uint32_t	nvs_type;	/* HN_NVS_TYPE_INIT_RESP */
110584e7c57SSepherosa Ziehau 	uint32_t	nvs_ver;	/* deprecated */
111584e7c57SSepherosa Ziehau 	uint32_t	nvs_rsvd;
112584e7c57SSepherosa Ziehau 	uint32_t	nvs_status;	/* HN_NVS_STATUS_ */
113584e7c57SSepherosa Ziehau } __packed;
114584e7c57SSepherosa Ziehau 
1159b392221SSepherosa Ziehau /* No reponse */
1169b392221SSepherosa Ziehau struct hn_nvs_ndis_conf {
1179b392221SSepherosa Ziehau 	uint32_t	nvs_type;	/* HN_NVS_TYPE_NDIS_CONF */
1189b392221SSepherosa Ziehau 	uint32_t	nvs_mtu;
1199b392221SSepherosa Ziehau 	uint32_t	nvs_rsvd;
1209b392221SSepherosa Ziehau 	uint64_t	nvs_caps;	/* HN_NVS_NDIS_CONF_ */
1219b392221SSepherosa Ziehau 	uint8_t		nvs_rsvd1[12];
122a491581fSWei Hu 	uint8_t		nvs_msg_pad[8];
1239b392221SSepherosa Ziehau } __packed;
1249b392221SSepherosa Ziehau CTASSERT(sizeof(struct hn_nvs_ndis_conf) >= HN_NVS_REQSIZE_MIN);
1259b392221SSepherosa Ziehau 
1269b392221SSepherosa Ziehau #define HN_NVS_NDIS_CONF_SRIOV		0x0004
1279b392221SSepherosa Ziehau #define HN_NVS_NDIS_CONF_VLAN		0x0008
128a491581fSWei Hu #define HN_NVS_NDIS_CONF_RSC		0x0080
1299b392221SSepherosa Ziehau 
130386c97e6SSepherosa Ziehau /* No response */
131386c97e6SSepherosa Ziehau struct hn_nvs_ndis_init {
132386c97e6SSepherosa Ziehau 	uint32_t	nvs_type;	/* HN_NVS_TYPE_NDIS_INIT */
133386c97e6SSepherosa Ziehau 	uint32_t	nvs_ndis_major;	/* NDIS_VERSION_MAJOR_ */
134386c97e6SSepherosa Ziehau 	uint32_t	nvs_ndis_minor;	/* NDIS_VERSION_MINOR_ */
135386c97e6SSepherosa Ziehau 	uint8_t		nvs_rsvd[20];
136a491581fSWei Hu 	uint8_t		nvs_msg_pad[8];
137386c97e6SSepherosa Ziehau } __packed;
138386c97e6SSepherosa Ziehau CTASSERT(sizeof(struct hn_nvs_ndis_init) >= HN_NVS_REQSIZE_MIN);
139386c97e6SSepherosa Ziehau 
1409c6cae24SSepherosa Ziehau #define HN_NVS_DATAPATH_SYNTH		0
1415bdfd3fdSDexuan Cui #define HN_NVS_DATAPATH_VF		1
1425bdfd3fdSDexuan Cui 
1435bdfd3fdSDexuan Cui /* No response */
1445bdfd3fdSDexuan Cui struct hn_nvs_datapath {
1455bdfd3fdSDexuan Cui 	uint32_t	nvs_type;	/* HN_NVS_TYPE_SET_DATAPATH */
1465bdfd3fdSDexuan Cui 	uint32_t	nvs_active_path;/* HN_NVS_DATAPATH_* */
1475bdfd3fdSDexuan Cui 	uint32_t	nvs_rsvd[6];
148a491581fSWei Hu 	uint8_t		nvs_msg_pad[8];
1495bdfd3fdSDexuan Cui } __packed;
1505bdfd3fdSDexuan Cui CTASSERT(sizeof(struct hn_nvs_datapath) >= HN_NVS_REQSIZE_MIN);
1515bdfd3fdSDexuan Cui 
152d293af40SSepherosa Ziehau struct hn_nvs_rxbuf_conn {
153d293af40SSepherosa Ziehau 	uint32_t	nvs_type;	/* HN_NVS_TYPE_RXBUF_CONN */
154d293af40SSepherosa Ziehau 	uint32_t	nvs_gpadl;	/* RXBUF vmbus GPADL */
155d293af40SSepherosa Ziehau 	uint16_t	nvs_sig;	/* HN_NVS_RXBUF_SIG */
156d293af40SSepherosa Ziehau 	uint8_t		nvs_rsvd[22];
157a491581fSWei Hu 	uint8_t		nvs_msg_pad[8];
158d293af40SSepherosa Ziehau } __packed;
159d293af40SSepherosa Ziehau CTASSERT(sizeof(struct hn_nvs_rxbuf_conn) >= HN_NVS_REQSIZE_MIN);
160d293af40SSepherosa Ziehau 
161d293af40SSepherosa Ziehau struct hn_nvs_rxbuf_sect {
162d293af40SSepherosa Ziehau 	uint32_t	nvs_start;
163d293af40SSepherosa Ziehau 	uint32_t	nvs_slotsz;
164d293af40SSepherosa Ziehau 	uint32_t	nvs_slotcnt;
165d293af40SSepherosa Ziehau 	uint32_t	nvs_end;
166d293af40SSepherosa Ziehau } __packed;
167d293af40SSepherosa Ziehau 
168d293af40SSepherosa Ziehau struct hn_nvs_rxbuf_connresp {
169d293af40SSepherosa Ziehau 	uint32_t	nvs_type;	/* HN_NVS_TYPE_RXBUF_CONNRESP */
170d293af40SSepherosa Ziehau 	uint32_t	nvs_status;	/* HN_NVS_STATUS_ */
171d293af40SSepherosa Ziehau 	uint32_t	nvs_nsect;	/* # of elem in nvs_sect */
172d293af40SSepherosa Ziehau 	struct hn_nvs_rxbuf_sect nvs_sect[];
173d293af40SSepherosa Ziehau } __packed;
174d293af40SSepherosa Ziehau 
1758b204d66SSepherosa Ziehau /* No response */
1768b204d66SSepherosa Ziehau struct hn_nvs_rxbuf_disconn {
1778b204d66SSepherosa Ziehau 	uint32_t	nvs_type;	/* HN_NVS_TYPE_RXBUF_DISCONN */
1788b204d66SSepherosa Ziehau 	uint16_t	nvs_sig;	/* HN_NVS_RXBUF_SIG */
1798b204d66SSepherosa Ziehau 	uint8_t		nvs_rsvd[26];
180a491581fSWei Hu 	uint8_t		nvs_msg_pad[8];
1818b204d66SSepherosa Ziehau } __packed;
1828b204d66SSepherosa Ziehau CTASSERT(sizeof(struct hn_nvs_rxbuf_disconn) >= HN_NVS_REQSIZE_MIN);
1838b204d66SSepherosa Ziehau 
18455c4b97bSSepherosa Ziehau struct hn_nvs_chim_conn {
18555c4b97bSSepherosa Ziehau 	uint32_t	nvs_type;	/* HN_NVS_TYPE_CHIM_CONN */
18655c4b97bSSepherosa Ziehau 	uint32_t	nvs_gpadl;	/* chimney buf vmbus GPADL */
18755c4b97bSSepherosa Ziehau 	uint16_t	nvs_sig;	/* NDIS_NVS_CHIM_SIG */
18855c4b97bSSepherosa Ziehau 	uint8_t		nvs_rsvd[22];
189a491581fSWei Hu 	uint8_t		nvs_msg_pad[8];
19055c4b97bSSepherosa Ziehau } __packed;
19155c4b97bSSepherosa Ziehau CTASSERT(sizeof(struct hn_nvs_chim_conn) >= HN_NVS_REQSIZE_MIN);
19255c4b97bSSepherosa Ziehau 
19355c4b97bSSepherosa Ziehau struct hn_nvs_chim_connresp {
19455c4b97bSSepherosa Ziehau 	uint32_t	nvs_type;	/* HN_NVS_TYPE_CHIM_CONNRESP */
19555c4b97bSSepherosa Ziehau 	uint32_t	nvs_status;	/* HN_NVS_STATUS_ */
19655c4b97bSSepherosa Ziehau 	uint32_t	nvs_sectsz;	/* section size */
19755c4b97bSSepherosa Ziehau } __packed;
19855c4b97bSSepherosa Ziehau 
199a04b666aSSepherosa Ziehau /* No response */
200a04b666aSSepherosa Ziehau struct hn_nvs_chim_disconn {
201a04b666aSSepherosa Ziehau 	uint32_t	nvs_type;	/* HN_NVS_TYPE_CHIM_DISCONN */
202a04b666aSSepherosa Ziehau 	uint16_t	nvs_sig;	/* HN_NVS_CHIM_SIG */
203a04b666aSSepherosa Ziehau 	uint8_t		nvs_rsvd[26];
204a491581fSWei Hu 	uint8_t		nvs_msg_pad[8];
205a04b666aSSepherosa Ziehau } __packed;
206a04b666aSSepherosa Ziehau CTASSERT(sizeof(struct hn_nvs_chim_disconn) >= HN_NVS_REQSIZE_MIN);
207a04b666aSSepherosa Ziehau 
2080f9b8485SSepherosa Ziehau #define HN_NVS_SUBCH_OP_ALLOC		1
2090f9b8485SSepherosa Ziehau 
2100f9b8485SSepherosa Ziehau struct hn_nvs_subch_req {
2110f9b8485SSepherosa Ziehau 	uint32_t	nvs_type;	/* HN_NVS_TYPE_SUBCH_REQ */
2120f9b8485SSepherosa Ziehau 	uint32_t	nvs_op;		/* HN_NVS_SUBCH_OP_ */
2130f9b8485SSepherosa Ziehau 	uint32_t	nvs_nsubch;
2140f9b8485SSepherosa Ziehau 	uint8_t		nvs_rsvd[20];
215a491581fSWei Hu 	uint8_t		nvs_msg_pad[8];
2160f9b8485SSepherosa Ziehau } __packed;
2170f9b8485SSepherosa Ziehau CTASSERT(sizeof(struct hn_nvs_subch_req) >= HN_NVS_REQSIZE_MIN);
2180f9b8485SSepherosa Ziehau 
2190f9b8485SSepherosa Ziehau struct hn_nvs_subch_resp {
2200f9b8485SSepherosa Ziehau 	uint32_t	nvs_type;	/* HN_NVS_TYPE_SUBCH_RESP */
2210f9b8485SSepherosa Ziehau 	uint32_t	nvs_status;	/* HN_NVS_STATUS_ */
2220f9b8485SSepherosa Ziehau 	uint32_t	nvs_nsubch;
2230f9b8485SSepherosa Ziehau } __packed;
2240f9b8485SSepherosa Ziehau 
22562c4e6e9SSepherosa Ziehau struct hn_nvs_rndis {
22662c4e6e9SSepherosa Ziehau 	uint32_t	nvs_type;	/* HN_NVS_TYPE_RNDIS */
22762c4e6e9SSepherosa Ziehau 	uint32_t	nvs_rndis_mtype;/* HN_NVS_RNDIS_MTYPE_ */
22862c4e6e9SSepherosa Ziehau 	/*
22962c4e6e9SSepherosa Ziehau 	 * Chimney sending buffer index and size.
23062c4e6e9SSepherosa Ziehau 	 *
23162c4e6e9SSepherosa Ziehau 	 * NOTE:
23262c4e6e9SSepherosa Ziehau 	 * If nvs_chim_idx is set to HN_NVS_CHIM_IDX_INVALID
23362c4e6e9SSepherosa Ziehau 	 * and nvs_chim_sz is set to 0, then chimney sending
23462c4e6e9SSepherosa Ziehau 	 * buffer is _not_ used by this RNDIS message.
23562c4e6e9SSepherosa Ziehau 	 */
23662c4e6e9SSepherosa Ziehau 	uint32_t	nvs_chim_idx;
23762c4e6e9SSepherosa Ziehau 	uint32_t	nvs_chim_sz;
23862c4e6e9SSepherosa Ziehau 	uint8_t		nvs_rsvd[16];
239a491581fSWei Hu 	uint8_t		nvs_msg_pad[8];
24062c4e6e9SSepherosa Ziehau } __packed;
24162c4e6e9SSepherosa Ziehau CTASSERT(sizeof(struct hn_nvs_rndis) >= HN_NVS_REQSIZE_MIN);
24262c4e6e9SSepherosa Ziehau 
2435f0dee26SSepherosa Ziehau struct hn_nvs_rndis_ack {
2445f0dee26SSepherosa Ziehau 	uint32_t	nvs_type;	/* HN_NVS_TYPE_RNDIS_ACK */
2455f0dee26SSepherosa Ziehau 	uint32_t	nvs_status;	/* HN_NVS_STATUS_ */
2465f0dee26SSepherosa Ziehau 	uint8_t		nvs_rsvd[24];
247a491581fSWei Hu 	uint8_t		nvs_msg_pad[8];
2485f0dee26SSepherosa Ziehau } __packed;
2495f0dee26SSepherosa Ziehau CTASSERT(sizeof(struct hn_nvs_rndis_ack) >= HN_NVS_REQSIZE_MIN);
2505f0dee26SSepherosa Ziehau 
2514e835450SSepherosa Ziehau /*
2524e835450SSepherosa Ziehau  * RNDIS extension
2534e835450SSepherosa Ziehau  */
2544e835450SSepherosa Ziehau 
2554e835450SSepherosa Ziehau /* Per-packet hash info */
2564e835450SSepherosa Ziehau #define HN_NDIS_HASH_INFO_SIZE		sizeof(uint32_t)
2574e835450SSepherosa Ziehau #define HN_NDIS_PKTINFO_TYPE_HASHINF	NDIS_PKTINFO_TYPE_ORIG_NBLIST
2584e835450SSepherosa Ziehau /* NDIS_HASH_ */
2594e835450SSepherosa Ziehau 
2604e835450SSepherosa Ziehau /* Per-packet hash value */
2614e835450SSepherosa Ziehau #define HN_NDIS_HASH_VALUE_SIZE		sizeof(uint32_t)
2624e835450SSepherosa Ziehau #define HN_NDIS_PKTINFO_TYPE_HASHVAL	NDIS_PKTINFO_TYPE_PKT_CANCELID
2634e835450SSepherosa Ziehau 
264b44fb279SSepherosa Ziehau /* Per-packet-info size */
265b44fb279SSepherosa Ziehau #define HN_RNDIS_PKTINFO_SIZE(dlen)	\
266b44fb279SSepherosa Ziehau 	__offsetof(struct rndis_pktinfo, rm_data[dlen])
267b44fb279SSepherosa Ziehau 
268584e7c57SSepherosa Ziehau #endif	/* !_IF_HNREG_H_ */
269