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_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_NDIS_CONF 125 49 50 /* 51 * Any size less than this one will _not_ work, e.g. hn_nvs_init 52 * only has 12B valid data, however, if only 12B data were sent, 53 * Hypervisor would never reply. 54 */ 55 #define HN_NVS_REQSIZE_MIN 32 56 57 struct hn_nvs_init { 58 uint32_t nvs_type; /* HN_NVS_TYPE_INIT */ 59 uint32_t nvs_ver_min; 60 uint32_t nvs_ver_max; 61 uint8_t nvs_rsvd[20]; 62 } __packed; 63 CTASSERT(sizeof(struct hn_nvs_init) >= HN_NVS_REQSIZE_MIN); 64 65 struct hn_nvs_init_resp { 66 uint32_t nvs_type; /* HN_NVS_TYPE_INIT_RESP */ 67 uint32_t nvs_ver; /* deprecated */ 68 uint32_t nvs_rsvd; 69 uint32_t nvs_status; /* HN_NVS_STATUS_ */ 70 } __packed; 71 72 /* No reponse */ 73 struct hn_nvs_ndis_conf { 74 uint32_t nvs_type; /* HN_NVS_TYPE_NDIS_CONF */ 75 uint32_t nvs_mtu; 76 uint32_t nvs_rsvd; 77 uint64_t nvs_caps; /* HN_NVS_NDIS_CONF_ */ 78 uint8_t nvs_rsvd1[12]; 79 } __packed; 80 CTASSERT(sizeof(struct hn_nvs_ndis_conf) >= HN_NVS_REQSIZE_MIN); 81 82 #define HN_NVS_NDIS_CONF_SRIOV 0x0004 83 #define HN_NVS_NDIS_CONF_VLAN 0x0008 84 85 /* No response */ 86 struct hn_nvs_ndis_init { 87 uint32_t nvs_type; /* HN_NVS_TYPE_NDIS_INIT */ 88 uint32_t nvs_ndis_major; /* NDIS_VERSION_MAJOR_ */ 89 uint32_t nvs_ndis_minor; /* NDIS_VERSION_MINOR_ */ 90 uint8_t nvs_rsvd[20]; 91 } __packed; 92 CTASSERT(sizeof(struct hn_nvs_ndis_init) >= HN_NVS_REQSIZE_MIN); 93 94 struct hn_nvs_rxbuf_conn { 95 uint32_t nvs_type; /* HN_NVS_TYPE_RXBUF_CONN */ 96 uint32_t nvs_gpadl; /* RXBUF vmbus GPADL */ 97 uint16_t nvs_sig; /* HN_NVS_RXBUF_SIG */ 98 uint8_t nvs_rsvd[22]; 99 } __packed; 100 CTASSERT(sizeof(struct hn_nvs_rxbuf_conn) >= HN_NVS_REQSIZE_MIN); 101 102 struct hn_nvs_rxbuf_sect { 103 uint32_t nvs_start; 104 uint32_t nvs_slotsz; 105 uint32_t nvs_slotcnt; 106 uint32_t nvs_end; 107 } __packed; 108 109 struct hn_nvs_rxbuf_connresp { 110 uint32_t nvs_type; /* HN_NVS_TYPE_RXBUF_CONNRESP */ 111 uint32_t nvs_status; /* HN_NVS_STATUS_ */ 112 uint32_t nvs_nsect; /* # of elem in nvs_sect */ 113 struct hn_nvs_rxbuf_sect nvs_sect[]; 114 } __packed; 115 116 /* No response */ 117 struct hn_nvs_rxbuf_disconn { 118 uint32_t nvs_type; /* HN_NVS_TYPE_RXBUF_DISCONN */ 119 uint16_t nvs_sig; /* HN_NVS_RXBUF_SIG */ 120 uint8_t nvs_rsvd[26]; 121 } __packed; 122 CTASSERT(sizeof(struct hn_nvs_rxbuf_disconn) >= HN_NVS_REQSIZE_MIN); 123 124 struct hn_nvs_chim_conn { 125 uint32_t nvs_type; /* HN_NVS_TYPE_CHIM_CONN */ 126 uint32_t nvs_gpadl; /* chimney buf vmbus GPADL */ 127 uint16_t nvs_sig; /* NDIS_NVS_CHIM_SIG */ 128 uint8_t nvs_rsvd[22]; 129 } __packed; 130 CTASSERT(sizeof(struct hn_nvs_chim_conn) >= HN_NVS_REQSIZE_MIN); 131 132 struct hn_nvs_chim_connresp { 133 uint32_t nvs_type; /* HN_NVS_TYPE_CHIM_CONNRESP */ 134 uint32_t nvs_status; /* HN_NVS_STATUS_ */ 135 uint32_t nvs_sectsz; /* section size */ 136 } __packed; 137 138 #endif /* !_IF_HNREG_H_ */ 139