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$ 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_CHIM_IDX_INVALID 0xffffffff 39 40 #define HN_NVS_RNDIS_MTYPE_DATA 0 41 #define HN_NVS_RNDIS_MTYPE_CTRL 1 42 43 /* 44 * NVS message transacion status codes. 45 */ 46 #define HN_NVS_STATUS_OK 1 47 #define HN_NVS_STATUS_FAILED 2 48 49 /* 50 * NVS request/response message types. 51 */ 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 */ 69 70 /* 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. 74 */ 75 #define HN_NVS_REQSIZE_MIN 32 76 77 /* NVS message common header */ 78 struct hn_nvs_hdr { 79 uint32_t nvs_type; 80 } __packed; 81 82 struct hn_nvs_init { 83 uint32_t nvs_type; /* HN_NVS_TYPE_INIT */ 84 uint32_t nvs_ver_min; 85 uint32_t nvs_ver_max; 86 uint8_t nvs_rsvd[20]; 87 } __packed; 88 CTASSERT(sizeof(struct hn_nvs_init) >= HN_NVS_REQSIZE_MIN); 89 90 struct hn_nvs_init_resp { 91 uint32_t nvs_type; /* HN_NVS_TYPE_INIT_RESP */ 92 uint32_t nvs_ver; /* deprecated */ 93 uint32_t nvs_rsvd; 94 uint32_t nvs_status; /* HN_NVS_STATUS_ */ 95 } __packed; 96 97 /* No reponse */ 98 struct hn_nvs_ndis_conf { 99 uint32_t nvs_type; /* HN_NVS_TYPE_NDIS_CONF */ 100 uint32_t nvs_mtu; 101 uint32_t nvs_rsvd; 102 uint64_t nvs_caps; /* HN_NVS_NDIS_CONF_ */ 103 uint8_t nvs_rsvd1[12]; 104 } __packed; 105 CTASSERT(sizeof(struct hn_nvs_ndis_conf) >= HN_NVS_REQSIZE_MIN); 106 107 #define HN_NVS_NDIS_CONF_SRIOV 0x0004 108 #define HN_NVS_NDIS_CONF_VLAN 0x0008 109 110 /* No response */ 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]; 116 } __packed; 117 CTASSERT(sizeof(struct hn_nvs_ndis_init) >= HN_NVS_REQSIZE_MIN); 118 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]; 124 } __packed; 125 CTASSERT(sizeof(struct hn_nvs_rxbuf_conn) >= HN_NVS_REQSIZE_MIN); 126 127 struct hn_nvs_rxbuf_sect { 128 uint32_t nvs_start; 129 uint32_t nvs_slotsz; 130 uint32_t nvs_slotcnt; 131 uint32_t nvs_end; 132 } __packed; 133 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[]; 139 } __packed; 140 141 /* No response */ 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]; 146 } __packed; 147 CTASSERT(sizeof(struct hn_nvs_rxbuf_disconn) >= HN_NVS_REQSIZE_MIN); 148 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]; 154 } __packed; 155 CTASSERT(sizeof(struct hn_nvs_chim_conn) >= HN_NVS_REQSIZE_MIN); 156 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 */ 161 } __packed; 162 163 /* No response */ 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]; 168 } __packed; 169 CTASSERT(sizeof(struct hn_nvs_chim_disconn) >= HN_NVS_REQSIZE_MIN); 170 171 #define HN_NVS_SUBCH_OP_ALLOC 1 172 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_ */ 176 uint32_t nvs_nsubch; 177 uint8_t nvs_rsvd[20]; 178 } __packed; 179 CTASSERT(sizeof(struct hn_nvs_subch_req) >= HN_NVS_REQSIZE_MIN); 180 181 struct hn_nvs_subch_resp { 182 uint32_t nvs_type; /* HN_NVS_TYPE_SUBCH_RESP */ 183 uint32_t nvs_status; /* HN_NVS_STATUS_ */ 184 uint32_t nvs_nsubch; 185 } __packed; 186 187 struct hn_nvs_rndis { 188 uint32_t nvs_type; /* HN_NVS_TYPE_RNDIS */ 189 uint32_t nvs_rndis_mtype;/* HN_NVS_RNDIS_MTYPE_ */ 190 /* 191 * Chimney sending buffer index and size. 192 * 193 * NOTE: 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. 197 */ 198 uint32_t nvs_chim_idx; 199 uint32_t nvs_chim_sz; 200 uint8_t nvs_rsvd[16]; 201 } __packed; 202 CTASSERT(sizeof(struct hn_nvs_rndis) >= HN_NVS_REQSIZE_MIN); 203 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]; 208 } __packed; 209 CTASSERT(sizeof(struct hn_nvs_rndis_ack) >= HN_NVS_REQSIZE_MIN); 210 211 #endif /* !_IF_HNREG_H_ */ 212