1 /****************************************************************************** 2 3 Copyright (c) 2013-2015, Intel Corporation 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without 7 modification, are permitted provided that the following conditions are met: 8 9 1. Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 12 2. Redistributions in binary form must reproduce the above copyright 13 notice, this list of conditions and the following disclaimer in the 14 documentation and/or other materials provided with the distribution. 15 16 3. Neither the name of the Intel Corporation nor the names of its 17 contributors may be used to endorse or promote products derived from 18 this software without specific prior written permission. 19 20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 POSSIBILITY OF SUCH DAMAGE. 31 32 ******************************************************************************/ 33 /*$FreeBSD$*/ 34 35 #ifndef _I40E_VIRTCHNL_H_ 36 #define _I40E_VIRTCHNL_H_ 37 38 #include "i40e_type.h" 39 40 /* Description: 41 * This header file describes the VF-PF communication protocol used 42 * by the various i40e drivers. 43 * 44 * Admin queue buffer usage: 45 * desc->opcode is always i40e_aqc_opc_send_msg_to_pf 46 * flags, retval, datalen, and data addr are all used normally. 47 * Firmware copies the cookie fields when sending messages between the PF and 48 * VF, but uses all other fields internally. Due to this limitation, we 49 * must send all messages as "indirect", i.e. using an external buffer. 50 * 51 * All the vsi indexes are relative to the VF. Each VF can have maximum of 52 * three VSIs. All the queue indexes are relative to the VSI. Each VF can 53 * have a maximum of sixteen queues for all of its VSIs. 54 * 55 * The PF is required to return a status code in v_retval for all messages 56 * except RESET_VF, which does not require any response. The return value is of 57 * i40e_status_code type, defined in the i40e_type.h. 58 * 59 * In general, VF driver initialization should roughly follow the order of these 60 * opcodes. The VF driver must first validate the API version of the PF driver, 61 * then request a reset, then get resources, then configure queues and 62 * interrupts. After these operations are complete, the VF driver may start 63 * its queues, optionally add MAC and VLAN filters, and process traffic. 64 */ 65 66 /* Opcodes for VF-PF communication. These are placed in the v_opcode field 67 * of the virtchnl_msg structure. 68 */ 69 enum i40e_virtchnl_ops { 70 /* The PF sends status change events to VFs using 71 * the I40E_VIRTCHNL_OP_EVENT opcode. 72 * VFs send requests to the PF using the other ops. 73 */ 74 I40E_VIRTCHNL_OP_UNKNOWN = 0, 75 I40E_VIRTCHNL_OP_VERSION = 1, /* must ALWAYS be 1 */ 76 I40E_VIRTCHNL_OP_RESET_VF = 2, 77 I40E_VIRTCHNL_OP_GET_VF_RESOURCES = 3, 78 I40E_VIRTCHNL_OP_CONFIG_TX_QUEUE = 4, 79 I40E_VIRTCHNL_OP_CONFIG_RX_QUEUE = 5, 80 I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES = 6, 81 I40E_VIRTCHNL_OP_CONFIG_IRQ_MAP = 7, 82 I40E_VIRTCHNL_OP_ENABLE_QUEUES = 8, 83 I40E_VIRTCHNL_OP_DISABLE_QUEUES = 9, 84 I40E_VIRTCHNL_OP_ADD_ETHER_ADDRESS = 10, 85 I40E_VIRTCHNL_OP_DEL_ETHER_ADDRESS = 11, 86 I40E_VIRTCHNL_OP_ADD_VLAN = 12, 87 I40E_VIRTCHNL_OP_DEL_VLAN = 13, 88 I40E_VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE = 14, 89 I40E_VIRTCHNL_OP_GET_STATS = 15, 90 I40E_VIRTCHNL_OP_FCOE = 16, 91 I40E_VIRTCHNL_OP_EVENT = 17, /* must ALWAYS be 17 */ 92 I40E_VIRTCHNL_OP_CONFIG_RSS_KEY = 23, 93 I40E_VIRTCHNL_OP_CONFIG_RSS_LUT = 24, 94 I40E_VIRTCHNL_OP_GET_RSS_HENA_CAPS = 25, 95 I40E_VIRTCHNL_OP_SET_RSS_HENA = 26, 96 97 }; 98 99 /* Virtual channel message descriptor. This overlays the admin queue 100 * descriptor. All other data is passed in external buffers. 101 */ 102 103 struct i40e_virtchnl_msg { 104 u8 pad[8]; /* AQ flags/opcode/len/retval fields */ 105 enum i40e_virtchnl_ops v_opcode; /* avoid confusion with desc->opcode */ 106 enum i40e_status_code v_retval; /* ditto for desc->retval */ 107 u32 vfid; /* used by PF when sending to VF */ 108 }; 109 110 /* Message descriptions and data structures.*/ 111 112 /* I40E_VIRTCHNL_OP_VERSION 113 * VF posts its version number to the PF. PF responds with its version number 114 * in the same format, along with a return code. 115 * Reply from PF has its major/minor versions also in param0 and param1. 116 * If there is a major version mismatch, then the VF cannot operate. 117 * If there is a minor version mismatch, then the VF can operate but should 118 * add a warning to the system log. 119 * 120 * This enum element MUST always be specified as == 1, regardless of other 121 * changes in the API. The PF must always respond to this message without 122 * error regardless of version mismatch. 123 */ 124 #define I40E_VIRTCHNL_VERSION_MAJOR 1 125 #define I40E_VIRTCHNL_VERSION_MINOR 1 126 #define I40E_VIRTCHNL_VERSION_MINOR_NO_VF_CAPS 0 127 128 struct i40e_virtchnl_version_info { 129 u32 major; 130 u32 minor; 131 }; 132 133 /* I40E_VIRTCHNL_OP_RESET_VF 134 * VF sends this request to PF with no parameters 135 * PF does NOT respond! VF driver must delay then poll VFGEN_RSTAT register 136 * until reset completion is indicated. The admin queue must be reinitialized 137 * after this operation. 138 * 139 * When reset is complete, PF must ensure that all queues in all VSIs associated 140 * with the VF are stopped, all queue configurations in the HMC are set to 0, 141 * and all MAC and VLAN filters (except the default MAC address) on all VSIs 142 * are cleared. 143 */ 144 145 /* I40E_VIRTCHNL_OP_GET_VF_RESOURCES 146 * Version 1.0 VF sends this request to PF with no parameters 147 * Version 1.1 VF sends this request to PF with u32 bitmap of its capabilities 148 * PF responds with an indirect message containing 149 * i40e_virtchnl_vf_resource and one or more 150 * i40e_virtchnl_vsi_resource structures. 151 */ 152 153 struct i40e_virtchnl_vsi_resource { 154 u16 vsi_id; 155 u16 num_queue_pairs; 156 enum i40e_vsi_type vsi_type; 157 u16 qset_handle; 158 u8 default_mac_addr[I40E_ETH_LENGTH_OF_ADDRESS]; 159 }; 160 /* VF offload flags */ 161 #define I40E_VIRTCHNL_VF_OFFLOAD_L2 0x00000001 162 #define I40E_VIRTCHNL_VF_OFFLOAD_IWARP 0x00000002 163 #define I40E_VIRTCHNL_VF_OFFLOAD_FCOE 0x00000004 164 #define I40E_VIRTCHNL_VF_OFFLOAD_RSS_AQ 0x00000008 165 #define I40E_VIRTCHNL_VF_OFFLOAD_RSS_REG 0x00000010 166 #define I40E_VIRTCHNL_VF_OFFLOAD_WB_ON_ITR 0x00000020 167 #define I40E_VIRTCHNL_VF_OFFLOAD_VLAN 0x00010000 168 #define I40E_VIRTCHNL_VF_OFFLOAD_RX_POLLING 0x00020000 169 #define I40E_VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 0x00040000 170 #define I40E_VIRTCHNL_VF_OFFLOAD_RSS_PF 0X00080000 171 #define I40E_VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM 0X00100000 172 173 #define I40E_VF_BASE_MODE_OFFLOADS (I40E_VIRTCHNL_VF_OFFLOAD_L2 | \ 174 I40E_VIRTCHNL_VF_OFFLOAD_VLAN | \ 175 I40E_VIRTCHNL_VF_OFFLOAD_RSS_PF) 176 177 struct i40e_virtchnl_vf_resource { 178 u16 num_vsis; 179 u16 num_queue_pairs; 180 u16 max_vectors; 181 u16 max_mtu; 182 183 u32 vf_offload_flags; 184 u32 rss_key_size; 185 u32 rss_lut_size; 186 187 struct i40e_virtchnl_vsi_resource vsi_res[1]; 188 }; 189 190 /* I40E_VIRTCHNL_OP_CONFIG_TX_QUEUE 191 * VF sends this message to set up parameters for one TX queue. 192 * External data buffer contains one instance of i40e_virtchnl_txq_info. 193 * PF configures requested queue and returns a status code. 194 */ 195 196 /* Tx queue config info */ 197 struct i40e_virtchnl_txq_info { 198 u16 vsi_id; 199 u16 queue_id; 200 u16 ring_len; /* number of descriptors, multiple of 8 */ 201 u16 headwb_enabled; 202 u64 dma_ring_addr; 203 u64 dma_headwb_addr; 204 }; 205 206 /* I40E_VIRTCHNL_OP_CONFIG_RX_QUEUE 207 * VF sends this message to set up parameters for one RX queue. 208 * External data buffer contains one instance of i40e_virtchnl_rxq_info. 209 * PF configures requested queue and returns a status code. 210 */ 211 212 /* Rx queue config info */ 213 struct i40e_virtchnl_rxq_info { 214 u16 vsi_id; 215 u16 queue_id; 216 u32 ring_len; /* number of descriptors, multiple of 32 */ 217 u16 hdr_size; 218 u16 splithdr_enabled; 219 u32 databuffer_size; 220 u32 max_pkt_size; 221 u64 dma_ring_addr; 222 enum i40e_hmc_obj_rx_hsplit_0 rx_split_pos; 223 }; 224 225 /* I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES 226 * VF sends this message to set parameters for all active TX and RX queues 227 * associated with the specified VSI. 228 * PF configures queues and returns status. 229 * If the number of queues specified is greater than the number of queues 230 * associated with the VSI, an error is returned and no queues are configured. 231 */ 232 struct i40e_virtchnl_queue_pair_info { 233 /* NOTE: vsi_id and queue_id should be identical for both queues. */ 234 struct i40e_virtchnl_txq_info txq; 235 struct i40e_virtchnl_rxq_info rxq; 236 }; 237 238 struct i40e_virtchnl_vsi_queue_config_info { 239 u16 vsi_id; 240 u16 num_queue_pairs; 241 struct i40e_virtchnl_queue_pair_info qpair[1]; 242 }; 243 244 /* I40E_VIRTCHNL_OP_CONFIG_IRQ_MAP 245 * VF uses this message to map vectors to queues. 246 * The rxq_map and txq_map fields are bitmaps used to indicate which queues 247 * are to be associated with the specified vector. 248 * The "other" causes are always mapped to vector 0. 249 * PF configures interrupt mapping and returns status. 250 */ 251 struct i40e_virtchnl_vector_map { 252 u16 vsi_id; 253 u16 vector_id; 254 u16 rxq_map; 255 u16 txq_map; 256 u16 rxitr_idx; 257 u16 txitr_idx; 258 }; 259 260 struct i40e_virtchnl_irq_map_info { 261 u16 num_vectors; 262 struct i40e_virtchnl_vector_map vecmap[1]; 263 }; 264 265 /* I40E_VIRTCHNL_OP_ENABLE_QUEUES 266 * I40E_VIRTCHNL_OP_DISABLE_QUEUES 267 * VF sends these message to enable or disable TX/RX queue pairs. 268 * The queues fields are bitmaps indicating which queues to act upon. 269 * (Currently, we only support 16 queues per VF, but we make the field 270 * u32 to allow for expansion.) 271 * PF performs requested action and returns status. 272 */ 273 struct i40e_virtchnl_queue_select { 274 u16 vsi_id; 275 u16 pad; 276 u32 rx_queues; 277 u32 tx_queues; 278 }; 279 280 /* I40E_VIRTCHNL_OP_ADD_ETHER_ADDRESS 281 * VF sends this message in order to add one or more unicast or multicast 282 * address filters for the specified VSI. 283 * PF adds the filters and returns status. 284 */ 285 286 /* I40E_VIRTCHNL_OP_DEL_ETHER_ADDRESS 287 * VF sends this message in order to remove one or more unicast or multicast 288 * filters for the specified VSI. 289 * PF removes the filters and returns status. 290 */ 291 292 struct i40e_virtchnl_ether_addr { 293 u8 addr[I40E_ETH_LENGTH_OF_ADDRESS]; 294 u8 pad[2]; 295 }; 296 297 struct i40e_virtchnl_ether_addr_list { 298 u16 vsi_id; 299 u16 num_elements; 300 struct i40e_virtchnl_ether_addr list[1]; 301 }; 302 303 /* I40E_VIRTCHNL_OP_ADD_VLAN 304 * VF sends this message to add one or more VLAN tag filters for receives. 305 * PF adds the filters and returns status. 306 * If a port VLAN is configured by the PF, this operation will return an 307 * error to the VF. 308 */ 309 310 /* I40E_VIRTCHNL_OP_DEL_VLAN 311 * VF sends this message to remove one or more VLAN tag filters for receives. 312 * PF removes the filters and returns status. 313 * If a port VLAN is configured by the PF, this operation will return an 314 * error to the VF. 315 */ 316 317 struct i40e_virtchnl_vlan_filter_list { 318 u16 vsi_id; 319 u16 num_elements; 320 u16 vlan_id[1]; 321 }; 322 323 /* I40E_VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE 324 * VF sends VSI id and flags. 325 * PF returns status code in retval. 326 * Note: we assume that broadcast accept mode is always enabled. 327 */ 328 struct i40e_virtchnl_promisc_info { 329 u16 vsi_id; 330 u16 flags; 331 }; 332 333 #define I40E_FLAG_VF_UNICAST_PROMISC 0x00000001 334 #define I40E_FLAG_VF_MULTICAST_PROMISC 0x00000002 335 336 /* I40E_VIRTCHNL_OP_GET_STATS 337 * VF sends this message to request stats for the selected VSI. VF uses 338 * the i40e_virtchnl_queue_select struct to specify the VSI. The queue_id 339 * field is ignored by the PF. 340 * 341 * PF replies with struct i40e_eth_stats in an external buffer. 342 */ 343 344 /* I40E_VIRTCHNL_OP_CONFIG_RSS_KEY 345 * I40E_VIRTCHNL_OP_CONFIG_RSS_LUT 346 * VF sends these messages to configure RSS. Only supported if both PF 347 * and VF drivers set the I40E_VIRTCHNL_VF_OFFLOAD_RSS_PF bit during 348 * configuration negotiation. If this is the case, then the rss fields in 349 * the vf resource struct are valid. 350 * Both the key and LUT are initialized to 0 by the PF, meaning that 351 * RSS is effectively disabled until set up by the VF. 352 */ 353 struct i40e_virtchnl_rss_key { 354 u16 vsi_id; 355 u16 key_len; 356 u8 key[1]; /* RSS hash key, packed bytes */ 357 }; 358 359 struct i40e_virtchnl_rss_lut { 360 u16 vsi_id; 361 u16 lut_entries; 362 u8 lut[1]; /* RSS lookup table*/ 363 }; 364 365 /* I40E_VIRTCHNL_OP_GET_RSS_HENA_CAPS 366 * I40E_VIRTCHNL_OP_SET_RSS_HENA 367 * VF sends these messages to get and set the hash filter enable bits for RSS. 368 * By default, the PF sets these to all possible traffic types that the 369 * hardware supports. The VF can query this value if it wants to change the 370 * traffic types that are hashed by the hardware. 371 * Traffic types are defined in the i40e_filter_pctype enum in i40e_type.h 372 */ 373 struct i40e_virtchnl_rss_hena { 374 u64 hena; 375 }; 376 377 /* I40E_VIRTCHNL_OP_EVENT 378 * PF sends this message to inform the VF driver of events that may affect it. 379 * No direct response is expected from the VF, though it may generate other 380 * messages in response to this one. 381 */ 382 enum i40e_virtchnl_event_codes { 383 I40E_VIRTCHNL_EVENT_UNKNOWN = 0, 384 I40E_VIRTCHNL_EVENT_LINK_CHANGE, 385 I40E_VIRTCHNL_EVENT_RESET_IMPENDING, 386 I40E_VIRTCHNL_EVENT_PF_DRIVER_CLOSE, 387 }; 388 #define I40E_PF_EVENT_SEVERITY_INFO 0 389 #define I40E_PF_EVENT_SEVERITY_ATTENTION 1 390 #define I40E_PF_EVENT_SEVERITY_ACTION_REQUIRED 2 391 #define I40E_PF_EVENT_SEVERITY_CERTAIN_DOOM 255 392 393 struct i40e_virtchnl_pf_event { 394 enum i40e_virtchnl_event_codes event; 395 union { 396 struct { 397 enum i40e_aq_link_speed link_speed; 398 bool link_status; 399 } link_event; 400 } event_data; 401 402 int severity; 403 }; 404 405 /* VF reset states - these are written into the RSTAT register: 406 * I40E_VFGEN_RSTAT1 on the PF 407 * I40E_VFGEN_RSTAT on the VF 408 * When the PF initiates a reset, it writes 0 409 * When the reset is complete, it writes 1 410 * When the PF detects that the VF has recovered, it writes 2 411 * VF checks this register periodically to determine if a reset has occurred, 412 * then polls it to know when the reset is complete. 413 * If either the PF or VF reads the register while the hardware 414 * is in a reset state, it will return DEADBEEF, which, when masked 415 * will result in 3. 416 */ 417 enum i40e_vfr_states { 418 I40E_VFR_INPROGRESS = 0, 419 I40E_VFR_COMPLETED, 420 I40E_VFR_VFACTIVE, 421 I40E_VFR_UNKNOWN, 422 }; 423 424 #endif /* _I40E_VIRTCHNL_H_ */ 425