Jesse Brandeburg | 5c3c48a | 2013-09-11 08:40:07 +0000 | [diff] [blame^] | 1 | /******************************************************************************* |
| 2 | * |
| 3 | * Intel Ethernet Controller XL710 Family Linux Driver |
| 4 | * Copyright(c) 2013 Intel Corporation. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms and conditions of the GNU General Public License, |
| 8 | * version 2, as published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | * more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License along with |
| 16 | * this program; if not, write to the Free Software Foundation, Inc., |
| 17 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | * |
| 19 | * The full GNU General Public License is included in this distribution in |
| 20 | * the file called "COPYING". |
| 21 | * |
| 22 | * Contact Information: |
| 23 | * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> |
| 24 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 25 | * |
| 26 | ******************************************************************************/ |
| 27 | |
| 28 | #ifndef _I40E_VIRTCHNL_H_ |
| 29 | #define _I40E_VIRTCHNL_H_ |
| 30 | |
| 31 | #include "i40e_type.h" |
| 32 | |
| 33 | /* Description: |
| 34 | * This header file describes the VF-PF communication protocol used |
| 35 | * by the various i40e drivers. |
| 36 | * |
| 37 | * Admin queue buffer usage: |
| 38 | * desc->opcode is always i40e_aqc_opc_send_msg_to_pf |
| 39 | * flags, retval, datalen, and data addr are all used normally. |
| 40 | * Firmware copies the cookie fields when sending messages between the PF and |
| 41 | * VF, but uses all other fields internally. Due to this limitation, we |
| 42 | * must send all messages as "indirect", i.e. using an external buffer. |
| 43 | * |
| 44 | * All the vsi indexes are relative to the VF. Each VF can have maximum of |
| 45 | * three VSIs. All the queue indexes are relative to the VSI. Each VF can |
| 46 | * have a maximum of sixteen queues for all of its VSIs. |
| 47 | * |
| 48 | * The PF is required to return a status code in v_retval for all messages |
| 49 | * except RESET_VF, which does not require any response. The return value is of |
| 50 | * i40e_status_code type, defined in the i40e_type.h. |
| 51 | * |
| 52 | * In general, VF driver initialization should roughly follow the order of these |
| 53 | * opcodes. The VF driver must first validate the API version of the PF driver, |
| 54 | * then request a reset, then get resources, then configure queues and |
| 55 | * interrupts. After these operations are complete, the VF driver may start |
| 56 | * its queues, optionally add MAC and VLAN filters, and process traffic. |
| 57 | */ |
| 58 | |
| 59 | /* Opcodes for VF-PF communication. These are placed in the v_opcode field |
| 60 | * of the virtchnl_msg structure. |
| 61 | */ |
| 62 | enum i40e_virtchnl_ops { |
| 63 | /* VF sends req. to pf for the following |
| 64 | * ops. |
| 65 | */ |
| 66 | I40E_VIRTCHNL_OP_UNKNOWN = 0, |
| 67 | I40E_VIRTCHNL_OP_VERSION = 1, /* must ALWAYS be 1 */ |
| 68 | I40E_VIRTCHNL_OP_RESET_VF, |
| 69 | I40E_VIRTCHNL_OP_GET_VF_RESOURCES, |
| 70 | I40E_VIRTCHNL_OP_CONFIG_TX_QUEUE, |
| 71 | I40E_VIRTCHNL_OP_CONFIG_RX_QUEUE, |
| 72 | I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES, |
| 73 | I40E_VIRTCHNL_OP_CONFIG_IRQ_MAP, |
| 74 | I40E_VIRTCHNL_OP_ENABLE_QUEUES, |
| 75 | I40E_VIRTCHNL_OP_DISABLE_QUEUES, |
| 76 | I40E_VIRTCHNL_OP_ADD_ETHER_ADDRESS, |
| 77 | I40E_VIRTCHNL_OP_DEL_ETHER_ADDRESS, |
| 78 | I40E_VIRTCHNL_OP_ADD_VLAN, |
| 79 | I40E_VIRTCHNL_OP_DEL_VLAN, |
| 80 | I40E_VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE, |
| 81 | I40E_VIRTCHNL_OP_GET_STATS, |
| 82 | I40E_VIRTCHNL_OP_FCOE, |
| 83 | /* PF sends status change events to vfs using |
| 84 | * the following op. |
| 85 | */ |
| 86 | I40E_VIRTCHNL_OP_EVENT, |
| 87 | }; |
| 88 | |
| 89 | /* Virtual channel message descriptor. This overlays the admin queue |
| 90 | * descriptor. All other data is passed in external buffers. |
| 91 | */ |
| 92 | |
| 93 | struct i40e_virtchnl_msg { |
| 94 | u8 pad[8]; /* AQ flags/opcode/len/retval fields */ |
| 95 | enum i40e_virtchnl_ops v_opcode; /* avoid confusion with desc->opcode */ |
| 96 | i40e_status v_retval; /* ditto for desc->retval */ |
| 97 | u32 vfid; /* used by PF when sending to VF */ |
| 98 | }; |
| 99 | |
| 100 | /* Message descriptions and data structures.*/ |
| 101 | |
| 102 | /* I40E_VIRTCHNL_OP_VERSION |
| 103 | * VF posts its version number to the PF. PF responds with its version number |
| 104 | * in the same format, along with a return code. |
| 105 | * Reply from PF has its major/minor versions also in param0 and param1. |
| 106 | * If there is a major version mismatch, then the VF cannot operate. |
| 107 | * If there is a minor version mismatch, then the VF can operate but should |
| 108 | * add a warning to the system log. |
| 109 | * |
| 110 | * This enum element MUST always be specified as == 1, regardless of other |
| 111 | * changes in the API. The PF must always respond to this message without |
| 112 | * error regardless of version mismatch. |
| 113 | */ |
| 114 | #define I40E_VIRTCHNL_VERSION_MAJOR 1 |
| 115 | #define I40E_VIRTCHNL_VERSION_MINOR 0 |
| 116 | struct i40e_virtchnl_version_info { |
| 117 | u32 major; |
| 118 | u32 minor; |
| 119 | }; |
| 120 | |
| 121 | /* I40E_VIRTCHNL_OP_RESET_VF |
| 122 | * VF sends this request to PF with no parameters |
| 123 | * PF does NOT respond! VF driver must delay then poll VFGEN_RSTAT register |
| 124 | * until reset completion is indicated. The admin queue must be reinitialized |
| 125 | * after this operation. |
| 126 | * |
| 127 | * When reset is complete, PF must ensure that all queues in all VSIs associated |
| 128 | * with the VF are stopped, all queue configurations in the HMC are set to 0, |
| 129 | * and all MAC and VLAN filters (except the default MAC address) on all VSIs |
| 130 | * are cleared. |
| 131 | */ |
| 132 | |
| 133 | /* I40E_VIRTCHNL_OP_GET_VF_RESOURCES |
| 134 | * VF sends this request to PF with no parameters |
| 135 | * PF responds with an indirect message containing |
| 136 | * i40e_virtchnl_vf_resource and one or more |
| 137 | * i40e_virtchnl_vsi_resource structures. |
| 138 | */ |
| 139 | |
| 140 | struct i40e_virtchnl_vsi_resource { |
| 141 | u16 vsi_id; |
| 142 | u16 num_queue_pairs; |
| 143 | enum i40e_vsi_type vsi_type; |
| 144 | u16 qset_handle; |
| 145 | u8 default_mac_addr[I40E_ETH_LENGTH_OF_ADDRESS]; |
| 146 | }; |
| 147 | /* VF offload flags */ |
| 148 | #define I40E_VIRTCHNL_VF_OFFLOAD_L2 0x00000001 |
| 149 | #define I40E_VIRTCHNL_VF_OFFLOAD_FCOE 0x00000004 |
| 150 | #define I40E_VIRTCHNL_VF_OFFLOAD_VLAN 0x00010000 |
| 151 | |
| 152 | struct i40e_virtchnl_vf_resource { |
| 153 | u16 num_vsis; |
| 154 | u16 num_queue_pairs; |
| 155 | u16 max_vectors; |
| 156 | u16 max_mtu; |
| 157 | |
| 158 | u32 vf_offload_flags; |
| 159 | u32 max_fcoe_contexts; |
| 160 | u32 max_fcoe_filters; |
| 161 | |
| 162 | struct i40e_virtchnl_vsi_resource vsi_res[1]; |
| 163 | }; |
| 164 | |
| 165 | /* I40E_VIRTCHNL_OP_CONFIG_TX_QUEUE |
| 166 | * VF sends this message to set up parameters for one TX queue. |
| 167 | * External data buffer contains one instance of i40e_virtchnl_txq_info. |
| 168 | * PF configures requested queue and returns a status code. |
| 169 | */ |
| 170 | |
| 171 | /* Tx queue config info */ |
| 172 | struct i40e_virtchnl_txq_info { |
| 173 | u16 vsi_id; |
| 174 | u16 queue_id; |
| 175 | u16 ring_len; /* number of descriptors, multiple of 8 */ |
| 176 | u16 headwb_enabled; |
| 177 | u64 dma_ring_addr; |
| 178 | u64 dma_headwb_addr; |
| 179 | }; |
| 180 | |
| 181 | /* I40E_VIRTCHNL_OP_CONFIG_RX_QUEUE |
| 182 | * VF sends this message to set up parameters for one RX queue. |
| 183 | * External data buffer contains one instance of i40e_virtchnl_rxq_info. |
| 184 | * PF configures requested queue and returns a status code. |
| 185 | */ |
| 186 | |
| 187 | /* Rx queue config info */ |
| 188 | struct i40e_virtchnl_rxq_info { |
| 189 | u16 vsi_id; |
| 190 | u16 queue_id; |
| 191 | u32 ring_len; /* number of descriptors, multiple of 32 */ |
| 192 | u16 hdr_size; |
| 193 | u16 splithdr_enabled; |
| 194 | u32 databuffer_size; |
| 195 | u32 max_pkt_size; |
| 196 | u64 dma_ring_addr; |
| 197 | enum i40e_hmc_obj_rx_hsplit_0 rx_split_pos; |
| 198 | }; |
| 199 | |
| 200 | /* I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES |
| 201 | * VF sends this message to set parameters for all active TX and RX queues |
| 202 | * associated with the specified VSI. |
| 203 | * PF configures queues and returns status. |
| 204 | * If the number of queues specified is greater than the number of queues |
| 205 | * associated with the VSI, an error is returned and no queues are configured. |
| 206 | */ |
| 207 | struct i40e_virtchnl_queue_pair_info { |
| 208 | /* NOTE: vsi_id and queue_id should be identical for both queues. */ |
| 209 | struct i40e_virtchnl_txq_info txq; |
| 210 | struct i40e_virtchnl_rxq_info rxq; |
| 211 | }; |
| 212 | |
| 213 | struct i40e_virtchnl_vsi_queue_config_info { |
| 214 | u16 vsi_id; |
| 215 | u16 num_queue_pairs; |
| 216 | struct i40e_virtchnl_queue_pair_info qpair[1]; |
| 217 | }; |
| 218 | |
| 219 | /* I40E_VIRTCHNL_OP_CONFIG_IRQ_MAP |
| 220 | * VF uses this message to map vectors to queues. |
| 221 | * The rxq_map and txq_map fields are bitmaps used to indicate which queues |
| 222 | * are to be associated with the specified vector. |
| 223 | * The "other" causes are always mapped to vector 0. |
| 224 | * PF configures interrupt mapping and returns status. |
| 225 | */ |
| 226 | struct i40e_virtchnl_vector_map { |
| 227 | u16 vsi_id; |
| 228 | u16 vector_id; |
| 229 | u16 rxq_map; |
| 230 | u16 txq_map; |
| 231 | u16 rxitr_idx; |
| 232 | u16 txitr_idx; |
| 233 | }; |
| 234 | |
| 235 | struct i40e_virtchnl_irq_map_info { |
| 236 | u16 num_vectors; |
| 237 | struct i40e_virtchnl_vector_map vecmap[1]; |
| 238 | }; |
| 239 | |
| 240 | /* I40E_VIRTCHNL_OP_ENABLE_QUEUES |
| 241 | * I40E_VIRTCHNL_OP_DISABLE_QUEUES |
| 242 | * VF sends these message to enable or disable TX/RX queue pairs. |
| 243 | * The queues fields are bitmaps indicating which queues to act upon. |
| 244 | * (Currently, we only support 16 queues per VF, but we make the field |
| 245 | * u32 to allow for expansion.) |
| 246 | * PF performs requested action and returns status. |
| 247 | */ |
| 248 | struct i40e_virtchnl_queue_select { |
| 249 | u16 vsi_id; |
| 250 | u16 pad; |
| 251 | u32 rx_queues; |
| 252 | u32 tx_queues; |
| 253 | }; |
| 254 | |
| 255 | /* I40E_VIRTCHNL_OP_ADD_ETHER_ADDRESS |
| 256 | * VF sends this message in order to add one or more unicast or multicast |
| 257 | * address filters for the specified VSI. |
| 258 | * PF adds the filters and returns status. |
| 259 | */ |
| 260 | |
| 261 | /* I40E_VIRTCHNL_OP_DEL_ETHER_ADDRESS |
| 262 | * VF sends this message in order to remove one or more unicast or multicast |
| 263 | * filters for the specified VSI. |
| 264 | * PF removes the filters and returns status. |
| 265 | */ |
| 266 | |
| 267 | struct i40e_virtchnl_ether_addr { |
| 268 | u8 addr[I40E_ETH_LENGTH_OF_ADDRESS]; |
| 269 | u8 pad[2]; |
| 270 | }; |
| 271 | |
| 272 | struct i40e_virtchnl_ether_addr_list { |
| 273 | u16 vsi_id; |
| 274 | u16 num_elements; |
| 275 | struct i40e_virtchnl_ether_addr list[1]; |
| 276 | }; |
| 277 | |
| 278 | /* I40E_VIRTCHNL_OP_ADD_VLAN |
| 279 | * VF sends this message to add one or more VLAN tag filters for receives. |
| 280 | * PF adds the filters and returns status. |
| 281 | * If a port VLAN is configured by the PF, this operation will return an |
| 282 | * error to the VF. |
| 283 | */ |
| 284 | |
| 285 | /* I40E_VIRTCHNL_OP_DEL_VLAN |
| 286 | * VF sends this message to remove one or more VLAN tag filters for receives. |
| 287 | * PF removes the filters and returns status. |
| 288 | * If a port VLAN is configured by the PF, this operation will return an |
| 289 | * error to the VF. |
| 290 | */ |
| 291 | |
| 292 | struct i40e_virtchnl_vlan_filter_list { |
| 293 | u16 vsi_id; |
| 294 | u16 num_elements; |
| 295 | u16 vlan_id[1]; |
| 296 | }; |
| 297 | |
| 298 | /* I40E_VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE |
| 299 | * VF sends VSI id and flags. |
| 300 | * PF returns status code in retval. |
| 301 | * Note: we assume that broadcast accept mode is always enabled. |
| 302 | */ |
| 303 | struct i40e_virtchnl_promisc_info { |
| 304 | u16 vsi_id; |
| 305 | u16 flags; |
| 306 | }; |
| 307 | |
| 308 | #define I40E_FLAG_VF_UNICAST_PROMISC 0x00000001 |
| 309 | #define I40E_FLAG_VF_MULTICAST_PROMISC 0x00000002 |
| 310 | |
| 311 | /* I40E_VIRTCHNL_OP_GET_STATS |
| 312 | * VF sends this message to request stats for the selected VSI. VF uses |
| 313 | * the i40e_virtchnl_queue_select struct to specify the VSI. The queue_id |
| 314 | * field is ignored by the PF. |
| 315 | * |
| 316 | * PF replies with struct i40e_eth_stats in an external buffer. |
| 317 | */ |
| 318 | |
| 319 | /* I40E_VIRTCHNL_OP_EVENT |
| 320 | * PF sends this message to inform the VF driver of events that may affect it. |
| 321 | * No direct response is expected from the VF, though it may generate other |
| 322 | * messages in response to this one. |
| 323 | */ |
| 324 | enum i40e_virtchnl_event_codes { |
| 325 | I40E_VIRTCHNL_EVENT_UNKNOWN = 0, |
| 326 | I40E_VIRTCHNL_EVENT_LINK_CHANGE, |
| 327 | I40E_VIRTCHNL_EVENT_RESET_IMPENDING, |
| 328 | I40E_VIRTCHNL_EVENT_PF_DRIVER_CLOSE, |
| 329 | }; |
| 330 | #define I40E_PF_EVENT_SEVERITY_INFO 0 |
| 331 | #define I40E_PF_EVENT_SEVERITY_CERTAIN_DOOM 255 |
| 332 | |
| 333 | struct i40e_virtchnl_pf_event { |
| 334 | enum i40e_virtchnl_event_codes event; |
| 335 | union { |
| 336 | struct { |
| 337 | enum i40e_aq_link_speed link_speed; |
| 338 | bool link_status; |
| 339 | } link_event; |
| 340 | } event_data; |
| 341 | |
| 342 | int severity; |
| 343 | }; |
| 344 | |
| 345 | /* The following are TBD, not necessary for LAN functionality. |
| 346 | * I40E_VIRTCHNL_OP_FCOE |
| 347 | */ |
| 348 | |
| 349 | /* VF reset states - these are written into the RSTAT register: |
| 350 | * I40E_VFGEN_RSTAT1 on the PF |
| 351 | * I40E_VFGEN_RSTAT on the VF |
| 352 | * When the PF initiates a reset, it writes 0 |
| 353 | * When the reset is complete, it writes 1 |
| 354 | * When the PF detects that the VF has recovered, it writes 2 |
| 355 | * VF checks this register periodically to determine if a reset has occurred, |
| 356 | * then polls it to know when the reset is complete. |
| 357 | * If either the PF or VF reads the register while the hardware |
| 358 | * is in a reset state, it will return DEADBEEF, which, when masked |
| 359 | * will result in 3. |
| 360 | */ |
| 361 | enum i40e_vfr_states { |
| 362 | I40E_VFR_INPROGRESS = 0, |
| 363 | I40E_VFR_COMPLETED, |
| 364 | I40E_VFR_VFACTIVE, |
| 365 | I40E_VFR_UNKNOWN, |
| 366 | }; |
| 367 | |
| 368 | #endif /* _I40E_VIRTCHNL_H_ */ |