if_hnreg.h revision 307164
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: stable/10/sys/dev/hyperv/netvsc/if_hnreg.h 307164 2016-10-13 02:28:40Z sephe $
27 */
28
29#ifndef _IF_HNREG_H_
30#define _IF_HNREG_H_
31
32#include <sys/param.h>
33#include <sys/systm.h>
34
35#define HN_NVS_RXBUF_SIG		0xcafe
36#define HN_NVS_CHIM_SIG			0xface
37
38#define HN_NVS_STATUS_OK		1
39
40#define HN_NVS_TYPE_INIT		1
41#define HN_NVS_TYPE_INIT_RESP		2
42#define HN_NVS_TYPE_NDIS_INIT		100
43#define HN_NVS_TYPE_RXBUF_CONN		101
44#define HN_NVS_TYPE_RXBUF_CONNRESP	102
45#define HN_NVS_TYPE_RXBUF_DISCONN	103
46#define HN_NVS_TYPE_CHIM_CONN		104
47#define HN_NVS_TYPE_CHIM_CONNRESP	105
48#define HN_NVS_TYPE_CHIM_DISCONN	106
49#define HN_NVS_TYPE_NDIS_CONF		125
50#define HN_NVS_TYPE_SUBCH_REQ		133
51#define HN_NVS_TYPE_SUBCH_RESP		133	/* same as SUBCH_REQ */
52
53/*
54 * Any size less than this one will _not_ work, e.g. hn_nvs_init
55 * only has 12B valid data, however, if only 12B data were sent,
56 * Hypervisor would never reply.
57 */
58#define HN_NVS_REQSIZE_MIN		32
59
60struct hn_nvs_init {
61	uint32_t	nvs_type;	/* HN_NVS_TYPE_INIT */
62	uint32_t	nvs_ver_min;
63	uint32_t	nvs_ver_max;
64	uint8_t		nvs_rsvd[20];
65} __packed;
66CTASSERT(sizeof(struct hn_nvs_init) >= HN_NVS_REQSIZE_MIN);
67
68struct hn_nvs_init_resp {
69	uint32_t	nvs_type;	/* HN_NVS_TYPE_INIT_RESP */
70	uint32_t	nvs_ver;	/* deprecated */
71	uint32_t	nvs_rsvd;
72	uint32_t	nvs_status;	/* HN_NVS_STATUS_ */
73} __packed;
74
75/* No reponse */
76struct hn_nvs_ndis_conf {
77	uint32_t	nvs_type;	/* HN_NVS_TYPE_NDIS_CONF */
78	uint32_t	nvs_mtu;
79	uint32_t	nvs_rsvd;
80	uint64_t	nvs_caps;	/* HN_NVS_NDIS_CONF_ */
81	uint8_t		nvs_rsvd1[12];
82} __packed;
83CTASSERT(sizeof(struct hn_nvs_ndis_conf) >= HN_NVS_REQSIZE_MIN);
84
85#define HN_NVS_NDIS_CONF_SRIOV		0x0004
86#define HN_NVS_NDIS_CONF_VLAN		0x0008
87
88/* No response */
89struct hn_nvs_ndis_init {
90	uint32_t	nvs_type;	/* HN_NVS_TYPE_NDIS_INIT */
91	uint32_t	nvs_ndis_major;	/* NDIS_VERSION_MAJOR_ */
92	uint32_t	nvs_ndis_minor;	/* NDIS_VERSION_MINOR_ */
93	uint8_t		nvs_rsvd[20];
94} __packed;
95CTASSERT(sizeof(struct hn_nvs_ndis_init) >= HN_NVS_REQSIZE_MIN);
96
97struct hn_nvs_rxbuf_conn {
98	uint32_t	nvs_type;	/* HN_NVS_TYPE_RXBUF_CONN */
99	uint32_t	nvs_gpadl;	/* RXBUF vmbus GPADL */
100	uint16_t	nvs_sig;	/* HN_NVS_RXBUF_SIG */
101	uint8_t		nvs_rsvd[22];
102} __packed;
103CTASSERT(sizeof(struct hn_nvs_rxbuf_conn) >= HN_NVS_REQSIZE_MIN);
104
105struct hn_nvs_rxbuf_sect {
106	uint32_t	nvs_start;
107	uint32_t	nvs_slotsz;
108	uint32_t	nvs_slotcnt;
109	uint32_t	nvs_end;
110} __packed;
111
112struct hn_nvs_rxbuf_connresp {
113	uint32_t	nvs_type;	/* HN_NVS_TYPE_RXBUF_CONNRESP */
114	uint32_t	nvs_status;	/* HN_NVS_STATUS_ */
115	uint32_t	nvs_nsect;	/* # of elem in nvs_sect */
116	struct hn_nvs_rxbuf_sect nvs_sect[];
117} __packed;
118
119/* No response */
120struct hn_nvs_rxbuf_disconn {
121	uint32_t	nvs_type;	/* HN_NVS_TYPE_RXBUF_DISCONN */
122	uint16_t	nvs_sig;	/* HN_NVS_RXBUF_SIG */
123	uint8_t		nvs_rsvd[26];
124} __packed;
125CTASSERT(sizeof(struct hn_nvs_rxbuf_disconn) >= HN_NVS_REQSIZE_MIN);
126
127struct hn_nvs_chim_conn {
128	uint32_t	nvs_type;	/* HN_NVS_TYPE_CHIM_CONN */
129	uint32_t	nvs_gpadl;	/* chimney buf vmbus GPADL */
130	uint16_t	nvs_sig;	/* NDIS_NVS_CHIM_SIG */
131	uint8_t		nvs_rsvd[22];
132} __packed;
133CTASSERT(sizeof(struct hn_nvs_chim_conn) >= HN_NVS_REQSIZE_MIN);
134
135struct hn_nvs_chim_connresp {
136	uint32_t	nvs_type;	/* HN_NVS_TYPE_CHIM_CONNRESP */
137	uint32_t	nvs_status;	/* HN_NVS_STATUS_ */
138	uint32_t	nvs_sectsz;	/* section size */
139} __packed;
140
141/* No response */
142struct hn_nvs_chim_disconn {
143	uint32_t	nvs_type;	/* HN_NVS_TYPE_CHIM_DISCONN */
144	uint16_t	nvs_sig;	/* HN_NVS_CHIM_SIG */
145	uint8_t		nvs_rsvd[26];
146} __packed;
147CTASSERT(sizeof(struct hn_nvs_chim_disconn) >= HN_NVS_REQSIZE_MIN);
148
149#define HN_NVS_SUBCH_OP_ALLOC		1
150
151struct hn_nvs_subch_req {
152	uint32_t	nvs_type;	/* HN_NVS_TYPE_SUBCH_REQ */
153	uint32_t	nvs_op;		/* HN_NVS_SUBCH_OP_ */
154	uint32_t	nvs_nsubch;
155	uint8_t		nvs_rsvd[20];
156} __packed;
157CTASSERT(sizeof(struct hn_nvs_subch_req) >= HN_NVS_REQSIZE_MIN);
158
159struct hn_nvs_subch_resp {
160	uint32_t	nvs_type;	/* HN_NVS_TYPE_SUBCH_RESP */
161	uint32_t	nvs_status;	/* HN_NVS_STATUS_ */
162	uint32_t	nvs_nsubch;
163} __packed;
164
165#endif	/* !_IF_HNREG_H_ */
166