Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright (c) 2018 Microsoft Corp. 3 : : * All rights reserved. 4 : : */ 5 : : 6 : : /* 7 : : * The indirection table message is the largest message 8 : : * received from host, and that is 112 bytes. 9 : : */ 10 : : #define NVS_RESPSIZE_MAX 256 11 : : 12 : : /* 13 : : * NDIS protocol version numbers 14 : : */ 15 : : #define NDIS_VERSION_6_1 0x00060001 16 : : #define NDIS_VERSION_6_20 0x00060014 17 : : #define NDIS_VERSION_6_30 0x0006001e 18 : : #define NDIS_VERSION_MAJOR(ver) (((ver) & 0xffff0000) >> 16) 19 : : #define NDIS_VERSION_MINOR(ver) ((ver) & 0xffff) 20 : : 21 : : /* 22 : : * NVS versions. 23 : : */ 24 : : #define NVS_VERSION_1 0x00002 25 : : #define NVS_VERSION_2 0x30002 26 : : #define NVS_VERSION_4 0x40000 27 : : #define NVS_VERSION_5 0x50000 28 : : #define NVS_VERSION_6 0x60000 29 : : #define NVS_VERSION_61 0x60001 30 : : 31 : : #define NVS_RXBUF_SIG 0xcafe 32 : : #define NVS_CHIM_SIG 0xface 33 : : 34 : : #define NVS_CHIM_IDX_INVALID 0xffffffff 35 : : 36 : : #define NVS_RNDIS_MTYPE_DATA 0 37 : : #define NVS_RNDIS_MTYPE_CTRL 1 38 : : 39 : : /* 40 : : * NVS message transaction status codes. 41 : : */ 42 : : #define NVS_STATUS_OK 1 43 : : #define NVS_STATUS_FAILED 2 44 : : 45 : : /* 46 : : * NVS request/response message types. 47 : : */ 48 : : #define NVS_TYPE_INIT 1 49 : : #define NVS_TYPE_INIT_RESP 2 50 : : 51 : : #define NVS_TYPE_NDIS_INIT 100 52 : : #define NVS_TYPE_RXBUF_CONN 101 53 : : #define NVS_TYPE_RXBUF_CONNRESP 102 54 : : #define NVS_TYPE_RXBUF_DISCONN 103 55 : : #define NVS_TYPE_CHIM_CONN 104 56 : : #define NVS_TYPE_CHIM_CONNRESP 105 57 : : #define NVS_TYPE_CHIM_DISCONN 106 58 : : #define NVS_TYPE_RNDIS 107 59 : : #define NVS_TYPE_RNDIS_ACK 108 60 : : 61 : : #define NVS_TYPE_NDIS_CONF 125 62 : : #define NVS_TYPE_VFASSOC_NOTE 128 /* notification */ 63 : : #define NVS_TYPE_SET_DATAPATH 129 64 : : #define NVS_TYPE_SUBCH_REQ 133 65 : : #define NVS_TYPE_SUBCH_RESP 133 /* same as SUBCH_REQ */ 66 : : #define NVS_TYPE_TXTBL_NOTE 134 /* notification */ 67 : : 68 : : /* Private data for primary/secondary processes */ 69 : : struct hn_nvs_process_priv { 70 : : struct rte_vmbus_device *vmbus_dev; 71 : : }; 72 : : 73 : : /* NVS message common header */ 74 : : struct __rte_packed_begin hn_nvs_hdr { 75 : : uint32_t type; 76 : : } __rte_packed_end; 77 : : 78 : : struct __rte_packed_begin hn_nvs_init { 79 : : uint32_t type; /* NVS_TYPE_INIT */ 80 : : uint32_t ver_min; 81 : : uint32_t ver_max; 82 : : uint8_t rsvd[28]; 83 : : } __rte_packed_end; 84 : : 85 : : struct __rte_packed_begin hn_nvs_init_resp { 86 : : uint32_t type; /* NVS_TYPE_INIT_RESP */ 87 : : uint32_t ver; /* deprecated */ 88 : : uint32_t rsvd; 89 : : uint32_t status; /* NVS_STATUS_ */ 90 : : } __rte_packed_end; 91 : : 92 : : /* No response */ 93 : : struct __rte_packed_begin hn_nvs_ndis_conf { 94 : : uint32_t type; /* NVS_TYPE_NDIS_CONF */ 95 : : uint32_t mtu; 96 : : uint32_t rsvd; 97 : : uint64_t caps; /* NVS_NDIS_CONF_ */ 98 : : uint8_t rsvd1[20]; 99 : : } __rte_packed_end; 100 : : 101 : : #define NVS_NDIS_CONF_SRIOV 0x0004 102 : : #define NVS_NDIS_CONF_VLAN 0x0008 103 : : 104 : : /* No response */ 105 : : struct __rte_packed_begin hn_nvs_ndis_init { 106 : : uint32_t type; /* NVS_TYPE_NDIS_INIT */ 107 : : uint32_t ndis_major; /* NDIS_VERSION_MAJOR_ */ 108 : : uint32_t ndis_minor; /* NDIS_VERSION_MINOR_ */ 109 : : uint8_t rsvd[28]; 110 : : } __rte_packed_end; 111 : : 112 : : struct __rte_packed_begin hn_nvs_vf_association { 113 : : uint32_t type; /* NVS_TYPE_VFASSOC_NOTE */ 114 : : uint32_t allocated; 115 : : uint32_t serial; 116 : : } __rte_packed_end; 117 : : 118 : : #define NVS_DATAPATH_SYNTHETIC 0 119 : : #define NVS_DATAPATH_VF 1 120 : : 121 : : /* No response */ 122 : : struct __rte_packed_begin hn_nvs_datapath { 123 : : uint32_t type; /* NVS_TYPE_SET_DATAPATH */ 124 : : uint32_t active_path;/* NVS_DATAPATH_* */ 125 : : uint8_t rsvd[32]; 126 : : } __rte_packed_end; 127 : : 128 : : struct __rte_packed_begin hn_nvs_rxbuf_conn { 129 : : uint32_t type; /* NVS_TYPE_RXBUF_CONN */ 130 : : uint32_t gpadl; /* RXBUF vmbus GPADL */ 131 : : uint16_t sig; /* NVS_RXBUF_SIG */ 132 : : uint8_t rsvd[30]; 133 : : } __rte_packed_end; 134 : : 135 : : struct __rte_packed_begin hn_nvs_rxbuf_sect { 136 : : uint32_t start; 137 : : uint32_t slotsz; 138 : : uint32_t slotcnt; 139 : : uint32_t end; 140 : : } __rte_packed_end; 141 : : 142 : : struct __rte_packed_begin hn_nvs_rxbuf_connresp { 143 : : uint32_t type; /* NVS_TYPE_RXBUF_CONNRESP */ 144 : : uint32_t status; /* NVS_STATUS_ */ 145 : : uint32_t nsect; /* # of elem in nvs_sect */ 146 : : struct hn_nvs_rxbuf_sect nvs_sect[1]; 147 : : } __rte_packed_end; 148 : : 149 : : /* No response */ 150 : : struct __rte_packed_begin hn_nvs_rxbuf_disconn { 151 : : uint32_t type; /* NVS_TYPE_RXBUF_DISCONN */ 152 : : uint16_t sig; /* NVS_RXBUF_SIG */ 153 : : uint8_t rsvd[34]; 154 : : } __rte_packed_end; 155 : : 156 : : struct __rte_packed_begin hn_nvs_chim_conn { 157 : : uint32_t type; /* NVS_TYPE_CHIM_CONN */ 158 : : uint32_t gpadl; /* chimney buf vmbus GPADL */ 159 : : uint16_t sig; /* NDIS_NVS_CHIM_SIG */ 160 : : uint8_t rsvd[30]; 161 : : } __rte_packed_end; 162 : : 163 : : struct __rte_packed_begin hn_nvs_chim_connresp { 164 : : uint32_t type; /* NVS_TYPE_CHIM_CONNRESP */ 165 : : uint32_t status; /* NVS_STATUS_ */ 166 : : uint32_t sectsz; /* section size */ 167 : : } __rte_packed_end; 168 : : 169 : : /* No response */ 170 : : struct __rte_packed_begin hn_nvs_chim_disconn { 171 : : uint32_t type; /* NVS_TYPE_CHIM_DISCONN */ 172 : : uint16_t sig; /* NVS_CHIM_SIG */ 173 : : uint8_t rsvd[34]; 174 : : } __rte_packed_end; 175 : : 176 : : #define NVS_SUBCH_OP_ALLOC 1 177 : : 178 : : struct __rte_packed_begin hn_nvs_subch_req { 179 : : uint32_t type; /* NVS_TYPE_SUBCH_REQ */ 180 : : uint32_t op; /* NVS_SUBCH_OP_ */ 181 : : uint32_t nsubch; 182 : : uint8_t rsvd[28]; 183 : : } __rte_packed_end; 184 : : 185 : : struct __rte_packed_begin hn_nvs_subch_resp { 186 : : uint32_t type; /* NVS_TYPE_SUBCH_RESP */ 187 : : uint32_t status; /* NVS_STATUS_ */ 188 : : uint32_t nsubch; 189 : : uint8_t rsvd[28]; 190 : : } __rte_packed_end; 191 : : 192 : : struct __rte_packed_begin hn_nvs_rndis { 193 : : uint32_t type; /* NVS_TYPE_RNDIS */ 194 : : uint32_t rndis_mtype;/* NVS_RNDIS_MTYPE_ */ 195 : : /* 196 : : * Chimney sending buffer index and size. 197 : : * 198 : : * NOTE: 199 : : * If nvs_chim_idx is set to NVS_CHIM_IDX_INVALID 200 : : * and nvs_chim_sz is set to 0, then chimney sending 201 : : * buffer is _not_ used by this RNDIS message. 202 : : */ 203 : : uint32_t chim_idx; 204 : : uint32_t chim_sz; 205 : : uint8_t rsvd[24]; 206 : : } __rte_packed_end; 207 : : 208 : : struct __rte_packed_begin hn_nvs_rndis_ack { 209 : : uint32_t type; /* NVS_TYPE_RNDIS_ACK */ 210 : : uint32_t status; /* NVS_STATUS_ */ 211 : : uint8_t rsvd[32]; 212 : : } __rte_packed_end; 213 : : 214 : : 215 : : int hn_nvs_attach(struct hn_data *hv, unsigned int mtu); 216 : : void hn_nvs_detach(struct hn_data *hv); 217 : : void hn_nvs_ack_rxbuf(struct vmbus_channel *chan, uint64_t tid); 218 : : int hn_nvs_alloc_subchans(struct hn_data *hv, uint32_t *nsubch); 219 : : int hn_nvs_set_datapath(struct hn_data *hv, uint32_t path); 220 : : void hn_nvs_handle_vfassoc(struct rte_eth_dev *dev, 221 : : const struct vmbus_chanpkt_hdr *hdr, 222 : : const void *data); 223 : : 224 : : struct rte_vmbus_device *get_vmbus_device(struct hn_data *hv); 225 : : 226 : : static inline int 227 : : hn_nvs_send(struct vmbus_channel *chan, uint16_t flags, 228 : : void *nvs_msg, int nvs_msglen, uintptr_t sndc, 229 : : bool *need_sig) 230 : : { 231 : 0 : return rte_vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_INBAND, 232 : : nvs_msg, nvs_msglen, (uint64_t)sndc, 233 : : flags, need_sig); 234 : : } 235 : : 236 : : static inline int 237 : : hn_nvs_send_sglist(struct vmbus_channel *chan, 238 : : struct vmbus_gpa sg[], unsigned int sglen, 239 : : void *nvs_msg, int nvs_msglen, 240 : : uintptr_t sndc, bool *need_sig) 241 : : { 242 : 0 : return rte_vmbus_chan_send_sglist(chan, sg, sglen, nvs_msg, nvs_msglen, 243 : : (uint64_t)sndc, need_sig); 244 : : }