1*ceebc2f3SEric Joyner /****************************************************************************** 2*ceebc2f3SEric Joyner 3*ceebc2f3SEric Joyner Copyright (c) 2013-2017, Intel Corporation 4*ceebc2f3SEric Joyner All rights reserved. 5*ceebc2f3SEric Joyner 6*ceebc2f3SEric Joyner Redistribution and use in source and binary forms, with or without 7*ceebc2f3SEric Joyner modification, are permitted provided that the following conditions are met: 8*ceebc2f3SEric Joyner 9*ceebc2f3SEric Joyner 1. Redistributions of source code must retain the above copyright notice, 10*ceebc2f3SEric Joyner this list of conditions and the following disclaimer. 11*ceebc2f3SEric Joyner 12*ceebc2f3SEric Joyner 2. Redistributions in binary form must reproduce the above copyright 13*ceebc2f3SEric Joyner notice, this list of conditions and the following disclaimer in the 14*ceebc2f3SEric Joyner documentation and/or other materials provided with the distribution. 15*ceebc2f3SEric Joyner 16*ceebc2f3SEric Joyner 3. Neither the name of the Intel Corporation nor the names of its 17*ceebc2f3SEric Joyner contributors may be used to endorse or promote products derived from 18*ceebc2f3SEric Joyner this software without specific prior written permission. 19*ceebc2f3SEric Joyner 20*ceebc2f3SEric Joyner THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21*ceebc2f3SEric Joyner AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22*ceebc2f3SEric Joyner IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23*ceebc2f3SEric Joyner ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 24*ceebc2f3SEric Joyner LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25*ceebc2f3SEric Joyner CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26*ceebc2f3SEric Joyner SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27*ceebc2f3SEric Joyner INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28*ceebc2f3SEric Joyner CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29*ceebc2f3SEric Joyner ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30*ceebc2f3SEric Joyner POSSIBILITY OF SUCH DAMAGE. 31*ceebc2f3SEric Joyner 32*ceebc2f3SEric Joyner ******************************************************************************/ 33*ceebc2f3SEric Joyner /*$FreeBSD$*/ 34*ceebc2f3SEric Joyner 35*ceebc2f3SEric Joyner #ifndef _VIRTCHNL_H_ 36*ceebc2f3SEric Joyner #define _VIRTCHNL_H_ 37*ceebc2f3SEric Joyner 38*ceebc2f3SEric Joyner /* Description: 39*ceebc2f3SEric Joyner * This header file describes the VF-PF communication protocol used 40*ceebc2f3SEric Joyner * by the drivers for all devices starting from our 40G product line 41*ceebc2f3SEric Joyner * 42*ceebc2f3SEric Joyner * Admin queue buffer usage: 43*ceebc2f3SEric Joyner * desc->opcode is always aqc_opc_send_msg_to_pf 44*ceebc2f3SEric Joyner * flags, retval, datalen, and data addr are all used normally. 45*ceebc2f3SEric Joyner * The Firmware copies the cookie fields when sending messages between the 46*ceebc2f3SEric Joyner * PF and VF, but uses all other fields internally. Due to this limitation, 47*ceebc2f3SEric Joyner * we must send all messages as "indirect", i.e. using an external buffer. 48*ceebc2f3SEric Joyner * 49*ceebc2f3SEric Joyner * All the VSI indexes are relative to the VF. Each VF can have maximum of 50*ceebc2f3SEric Joyner * three VSIs. All the queue indexes are relative to the VSI. Each VF can 51*ceebc2f3SEric Joyner * have a maximum of sixteen queues for all of its VSIs. 52*ceebc2f3SEric Joyner * 53*ceebc2f3SEric Joyner * The PF is required to return a status code in v_retval for all messages 54*ceebc2f3SEric Joyner * except RESET_VF, which does not require any response. The return value 55*ceebc2f3SEric Joyner * is of status_code type, defined in the shared type.h. 56*ceebc2f3SEric Joyner * 57*ceebc2f3SEric Joyner * In general, VF driver initialization should roughly follow the order of 58*ceebc2f3SEric Joyner * these opcodes. The VF driver must first validate the API version of the 59*ceebc2f3SEric Joyner * PF driver, then request a reset, then get resources, then configure 60*ceebc2f3SEric Joyner * queues and interrupts. After these operations are complete, the VF 61*ceebc2f3SEric Joyner * driver may start its queues, optionally add MAC and VLAN filters, and 62*ceebc2f3SEric Joyner * process traffic. 63*ceebc2f3SEric Joyner */ 64*ceebc2f3SEric Joyner 65*ceebc2f3SEric Joyner /* START GENERIC DEFINES 66*ceebc2f3SEric Joyner * Need to ensure the following enums and defines hold the same meaning and 67*ceebc2f3SEric Joyner * value in current and future projects 68*ceebc2f3SEric Joyner */ 69*ceebc2f3SEric Joyner 70*ceebc2f3SEric Joyner /* Error Codes */ 71*ceebc2f3SEric Joyner enum virtchnl_status_code { 72*ceebc2f3SEric Joyner VIRTCHNL_STATUS_SUCCESS = 0, 73*ceebc2f3SEric Joyner VIRTCHNL_ERR_PARAM = -5, 74*ceebc2f3SEric Joyner VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH = -38, 75*ceebc2f3SEric Joyner VIRTCHNL_STATUS_ERR_CQP_COMPL_ERROR = -39, 76*ceebc2f3SEric Joyner VIRTCHNL_STATUS_ERR_INVALID_VF_ID = -40, 77*ceebc2f3SEric Joyner VIRTCHNL_STATUS_NOT_SUPPORTED = -64, 78*ceebc2f3SEric Joyner }; 79*ceebc2f3SEric Joyner 80*ceebc2f3SEric Joyner #define VIRTCHNL_LINK_SPEED_100MB_SHIFT 0x1 81*ceebc2f3SEric Joyner #define VIRTCHNL_LINK_SPEED_1000MB_SHIFT 0x2 82*ceebc2f3SEric Joyner #define VIRTCHNL_LINK_SPEED_10GB_SHIFT 0x3 83*ceebc2f3SEric Joyner #define VIRTCHNL_LINK_SPEED_40GB_SHIFT 0x4 84*ceebc2f3SEric Joyner #define VIRTCHNL_LINK_SPEED_20GB_SHIFT 0x5 85*ceebc2f3SEric Joyner #define VIRTCHNL_LINK_SPEED_25GB_SHIFT 0x6 86*ceebc2f3SEric Joyner 87*ceebc2f3SEric Joyner enum virtchnl_link_speed { 88*ceebc2f3SEric Joyner VIRTCHNL_LINK_SPEED_UNKNOWN = 0, 89*ceebc2f3SEric Joyner VIRTCHNL_LINK_SPEED_100MB = BIT(VIRTCHNL_LINK_SPEED_100MB_SHIFT), 90*ceebc2f3SEric Joyner VIRTCHNL_LINK_SPEED_1GB = BIT(VIRTCHNL_LINK_SPEED_1000MB_SHIFT), 91*ceebc2f3SEric Joyner VIRTCHNL_LINK_SPEED_10GB = BIT(VIRTCHNL_LINK_SPEED_10GB_SHIFT), 92*ceebc2f3SEric Joyner VIRTCHNL_LINK_SPEED_40GB = BIT(VIRTCHNL_LINK_SPEED_40GB_SHIFT), 93*ceebc2f3SEric Joyner VIRTCHNL_LINK_SPEED_20GB = BIT(VIRTCHNL_LINK_SPEED_20GB_SHIFT), 94*ceebc2f3SEric Joyner VIRTCHNL_LINK_SPEED_25GB = BIT(VIRTCHNL_LINK_SPEED_25GB_SHIFT), 95*ceebc2f3SEric Joyner }; 96*ceebc2f3SEric Joyner 97*ceebc2f3SEric Joyner /* for hsplit_0 field of Rx HMC context */ 98*ceebc2f3SEric Joyner /* deprecated with AVF 1.0 */ 99*ceebc2f3SEric Joyner enum virtchnl_rx_hsplit { 100*ceebc2f3SEric Joyner VIRTCHNL_RX_HSPLIT_NO_SPLIT = 0, 101*ceebc2f3SEric Joyner VIRTCHNL_RX_HSPLIT_SPLIT_L2 = 1, 102*ceebc2f3SEric Joyner VIRTCHNL_RX_HSPLIT_SPLIT_IP = 2, 103*ceebc2f3SEric Joyner VIRTCHNL_RX_HSPLIT_SPLIT_TCP_UDP = 4, 104*ceebc2f3SEric Joyner VIRTCHNL_RX_HSPLIT_SPLIT_SCTP = 8, 105*ceebc2f3SEric Joyner }; 106*ceebc2f3SEric Joyner 107*ceebc2f3SEric Joyner #define VIRTCHNL_ETH_LENGTH_OF_ADDRESS 6 108*ceebc2f3SEric Joyner /* END GENERIC DEFINES */ 109*ceebc2f3SEric Joyner 110*ceebc2f3SEric Joyner /* Opcodes for VF-PF communication. These are placed in the v_opcode field 111*ceebc2f3SEric Joyner * of the virtchnl_msg structure. 112*ceebc2f3SEric Joyner */ 113*ceebc2f3SEric Joyner enum virtchnl_ops { 114*ceebc2f3SEric Joyner /* The PF sends status change events to VFs using 115*ceebc2f3SEric Joyner * the VIRTCHNL_OP_EVENT opcode. 116*ceebc2f3SEric Joyner * VFs send requests to the PF using the other ops. 117*ceebc2f3SEric Joyner * Use of "advanced opcode" features must be negotiated as part of capabilities 118*ceebc2f3SEric Joyner * exchange and are not considered part of base mode feature set. 119*ceebc2f3SEric Joyner */ 120*ceebc2f3SEric Joyner VIRTCHNL_OP_UNKNOWN = 0, 121*ceebc2f3SEric Joyner VIRTCHNL_OP_VERSION = 1, /* must ALWAYS be 1 */ 122*ceebc2f3SEric Joyner VIRTCHNL_OP_RESET_VF = 2, 123*ceebc2f3SEric Joyner VIRTCHNL_OP_GET_VF_RESOURCES = 3, 124*ceebc2f3SEric Joyner VIRTCHNL_OP_CONFIG_TX_QUEUE = 4, 125*ceebc2f3SEric Joyner VIRTCHNL_OP_CONFIG_RX_QUEUE = 5, 126*ceebc2f3SEric Joyner VIRTCHNL_OP_CONFIG_VSI_QUEUES = 6, 127*ceebc2f3SEric Joyner VIRTCHNL_OP_CONFIG_IRQ_MAP = 7, 128*ceebc2f3SEric Joyner VIRTCHNL_OP_ENABLE_QUEUES = 8, 129*ceebc2f3SEric Joyner VIRTCHNL_OP_DISABLE_QUEUES = 9, 130*ceebc2f3SEric Joyner VIRTCHNL_OP_ADD_ETH_ADDR = 10, 131*ceebc2f3SEric Joyner VIRTCHNL_OP_DEL_ETH_ADDR = 11, 132*ceebc2f3SEric Joyner VIRTCHNL_OP_ADD_VLAN = 12, 133*ceebc2f3SEric Joyner VIRTCHNL_OP_DEL_VLAN = 13, 134*ceebc2f3SEric Joyner VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE = 14, 135*ceebc2f3SEric Joyner VIRTCHNL_OP_GET_STATS = 15, 136*ceebc2f3SEric Joyner VIRTCHNL_OP_RSVD = 16, 137*ceebc2f3SEric Joyner VIRTCHNL_OP_EVENT = 17, /* must ALWAYS be 17 */ 138*ceebc2f3SEric Joyner VIRTCHNL_OP_IWARP = 20, /* advanced opcode */ 139*ceebc2f3SEric Joyner VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP = 21, /* advanced opcode */ 140*ceebc2f3SEric Joyner VIRTCHNL_OP_RELEASE_IWARP_IRQ_MAP = 22, /* advanced opcode */ 141*ceebc2f3SEric Joyner VIRTCHNL_OP_CONFIG_RSS_KEY = 23, 142*ceebc2f3SEric Joyner VIRTCHNL_OP_CONFIG_RSS_LUT = 24, 143*ceebc2f3SEric Joyner VIRTCHNL_OP_GET_RSS_HENA_CAPS = 25, 144*ceebc2f3SEric Joyner VIRTCHNL_OP_SET_RSS_HENA = 26, 145*ceebc2f3SEric Joyner VIRTCHNL_OP_ENABLE_VLAN_STRIPPING = 27, 146*ceebc2f3SEric Joyner VIRTCHNL_OP_DISABLE_VLAN_STRIPPING = 28, 147*ceebc2f3SEric Joyner VIRTCHNL_OP_REQUEST_QUEUES = 29, 148*ceebc2f3SEric Joyner 149*ceebc2f3SEric Joyner }; 150*ceebc2f3SEric Joyner 151*ceebc2f3SEric Joyner /* This macro is used to generate a compilation error if a structure 152*ceebc2f3SEric Joyner * is not exactly the correct length. It gives a divide by zero error if the 153*ceebc2f3SEric Joyner * structure is not of the correct size, otherwise it creates an enum that is 154*ceebc2f3SEric Joyner * never used. 155*ceebc2f3SEric Joyner */ 156*ceebc2f3SEric Joyner #define VIRTCHNL_CHECK_STRUCT_LEN(n, X) enum virtchnl_static_assert_enum_##X \ 157*ceebc2f3SEric Joyner {virtchnl_static_assert_##X = (n) / ((sizeof(struct X) == (n)) ? 1 : 0)} 158*ceebc2f3SEric Joyner 159*ceebc2f3SEric Joyner /* Virtual channel message descriptor. This overlays the admin queue 160*ceebc2f3SEric Joyner * descriptor. All other data is passed in external buffers. 161*ceebc2f3SEric Joyner */ 162*ceebc2f3SEric Joyner 163*ceebc2f3SEric Joyner struct virtchnl_msg { 164*ceebc2f3SEric Joyner u8 pad[8]; /* AQ flags/opcode/len/retval fields */ 165*ceebc2f3SEric Joyner enum virtchnl_ops v_opcode; /* avoid confusion with desc->opcode */ 166*ceebc2f3SEric Joyner enum virtchnl_status_code v_retval; /* ditto for desc->retval */ 167*ceebc2f3SEric Joyner u32 vfid; /* used by PF when sending to VF */ 168*ceebc2f3SEric Joyner }; 169*ceebc2f3SEric Joyner 170*ceebc2f3SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(20, virtchnl_msg); 171*ceebc2f3SEric Joyner 172*ceebc2f3SEric Joyner /* Message descriptions and data structures.*/ 173*ceebc2f3SEric Joyner 174*ceebc2f3SEric Joyner /* VIRTCHNL_OP_VERSION 175*ceebc2f3SEric Joyner * VF posts its version number to the PF. PF responds with its version number 176*ceebc2f3SEric Joyner * in the same format, along with a return code. 177*ceebc2f3SEric Joyner * Reply from PF has its major/minor versions also in param0 and param1. 178*ceebc2f3SEric Joyner * If there is a major version mismatch, then the VF cannot operate. 179*ceebc2f3SEric Joyner * If there is a minor version mismatch, then the VF can operate but should 180*ceebc2f3SEric Joyner * add a warning to the system log. 181*ceebc2f3SEric Joyner * 182*ceebc2f3SEric Joyner * This enum element MUST always be specified as == 1, regardless of other 183*ceebc2f3SEric Joyner * changes in the API. The PF must always respond to this message without 184*ceebc2f3SEric Joyner * error regardless of version mismatch. 185*ceebc2f3SEric Joyner */ 186*ceebc2f3SEric Joyner #define VIRTCHNL_VERSION_MAJOR 1 187*ceebc2f3SEric Joyner #define VIRTCHNL_VERSION_MINOR 1 188*ceebc2f3SEric Joyner #define VIRTCHNL_VERSION_MINOR_NO_VF_CAPS 0 189*ceebc2f3SEric Joyner 190*ceebc2f3SEric Joyner struct virtchnl_version_info { 191*ceebc2f3SEric Joyner u32 major; 192*ceebc2f3SEric Joyner u32 minor; 193*ceebc2f3SEric Joyner }; 194*ceebc2f3SEric Joyner 195*ceebc2f3SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_version_info); 196*ceebc2f3SEric Joyner 197*ceebc2f3SEric Joyner #define VF_IS_V10(_v) (((_v)->major == 1) && ((_v)->minor == 0)) 198*ceebc2f3SEric Joyner #define VF_IS_V11(_ver) (((_ver)->major == 1) && ((_ver)->minor == 1)) 199*ceebc2f3SEric Joyner 200*ceebc2f3SEric Joyner /* VIRTCHNL_OP_RESET_VF 201*ceebc2f3SEric Joyner * VF sends this request to PF with no parameters 202*ceebc2f3SEric Joyner * PF does NOT respond! VF driver must delay then poll VFGEN_RSTAT register 203*ceebc2f3SEric Joyner * until reset completion is indicated. The admin queue must be reinitialized 204*ceebc2f3SEric Joyner * after this operation. 205*ceebc2f3SEric Joyner * 206*ceebc2f3SEric Joyner * When reset is complete, PF must ensure that all queues in all VSIs associated 207*ceebc2f3SEric Joyner * with the VF are stopped, all queue configurations in the HMC are set to 0, 208*ceebc2f3SEric Joyner * and all MAC and VLAN filters (except the default MAC address) on all VSIs 209*ceebc2f3SEric Joyner * are cleared. 210*ceebc2f3SEric Joyner */ 211*ceebc2f3SEric Joyner 212*ceebc2f3SEric Joyner /* VSI types that use VIRTCHNL interface for VF-PF communication. VSI_SRIOV 213*ceebc2f3SEric Joyner * vsi_type should always be 6 for backward compatibility. Add other fields 214*ceebc2f3SEric Joyner * as needed. 215*ceebc2f3SEric Joyner */ 216*ceebc2f3SEric Joyner enum virtchnl_vsi_type { 217*ceebc2f3SEric Joyner VIRTCHNL_VSI_TYPE_INVALID = 0, 218*ceebc2f3SEric Joyner VIRTCHNL_VSI_SRIOV = 6, 219*ceebc2f3SEric Joyner }; 220*ceebc2f3SEric Joyner 221*ceebc2f3SEric Joyner /* VIRTCHNL_OP_GET_VF_RESOURCES 222*ceebc2f3SEric Joyner * Version 1.0 VF sends this request to PF with no parameters 223*ceebc2f3SEric Joyner * Version 1.1 VF sends this request to PF with u32 bitmap of its capabilities 224*ceebc2f3SEric Joyner * PF responds with an indirect message containing 225*ceebc2f3SEric Joyner * virtchnl_vf_resource and one or more 226*ceebc2f3SEric Joyner * virtchnl_vsi_resource structures. 227*ceebc2f3SEric Joyner */ 228*ceebc2f3SEric Joyner 229*ceebc2f3SEric Joyner struct virtchnl_vsi_resource { 230*ceebc2f3SEric Joyner u16 vsi_id; 231*ceebc2f3SEric Joyner u16 num_queue_pairs; 232*ceebc2f3SEric Joyner enum virtchnl_vsi_type vsi_type; 233*ceebc2f3SEric Joyner u16 qset_handle; 234*ceebc2f3SEric Joyner u8 default_mac_addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS]; 235*ceebc2f3SEric Joyner }; 236*ceebc2f3SEric Joyner 237*ceebc2f3SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource); 238*ceebc2f3SEric Joyner 239*ceebc2f3SEric Joyner /* VF capability flags 240*ceebc2f3SEric Joyner * VIRTCHNL_VF_OFFLOAD_L2 flag is inclusive of base mode L2 offloads including 241*ceebc2f3SEric Joyner * TX/RX Checksum offloading and TSO for non-tunnelled packets. 242*ceebc2f3SEric Joyner */ 243*ceebc2f3SEric Joyner #define VIRTCHNL_VF_OFFLOAD_L2 0x00000001 244*ceebc2f3SEric Joyner #define VIRTCHNL_VF_OFFLOAD_IWARP 0x00000002 245*ceebc2f3SEric Joyner #define VIRTCHNL_VF_OFFLOAD_RSVD 0x00000004 246*ceebc2f3SEric Joyner #define VIRTCHNL_VF_OFFLOAD_RSS_AQ 0x00000008 247*ceebc2f3SEric Joyner #define VIRTCHNL_VF_OFFLOAD_RSS_REG 0x00000010 248*ceebc2f3SEric Joyner #define VIRTCHNL_VF_OFFLOAD_WB_ON_ITR 0x00000020 249*ceebc2f3SEric Joyner #define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES 0x00000040 250*ceebc2f3SEric Joyner #define VIRTCHNL_VF_OFFLOAD_VLAN 0x00010000 251*ceebc2f3SEric Joyner #define VIRTCHNL_VF_OFFLOAD_RX_POLLING 0x00020000 252*ceebc2f3SEric Joyner #define VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 0x00040000 253*ceebc2f3SEric Joyner #define VIRTCHNL_VF_OFFLOAD_RSS_PF 0X00080000 254*ceebc2f3SEric Joyner #define VIRTCHNL_VF_OFFLOAD_ENCAP 0X00100000 255*ceebc2f3SEric Joyner #define VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM 0X00200000 256*ceebc2f3SEric Joyner #define VIRTCHNL_VF_OFFLOAD_RX_ENCAP_CSUM 0X00400000 257*ceebc2f3SEric Joyner 258*ceebc2f3SEric Joyner #define VF_BASE_MODE_OFFLOADS (VIRTCHNL_VF_OFFLOAD_L2 | \ 259*ceebc2f3SEric Joyner VIRTCHNL_VF_OFFLOAD_VLAN | \ 260*ceebc2f3SEric Joyner VIRTCHNL_VF_OFFLOAD_RSS_PF) 261*ceebc2f3SEric Joyner 262*ceebc2f3SEric Joyner struct virtchnl_vf_resource { 263*ceebc2f3SEric Joyner u16 num_vsis; 264*ceebc2f3SEric Joyner u16 num_queue_pairs; 265*ceebc2f3SEric Joyner u16 max_vectors; 266*ceebc2f3SEric Joyner u16 max_mtu; 267*ceebc2f3SEric Joyner 268*ceebc2f3SEric Joyner u32 vf_cap_flags; 269*ceebc2f3SEric Joyner u32 rss_key_size; 270*ceebc2f3SEric Joyner u32 rss_lut_size; 271*ceebc2f3SEric Joyner 272*ceebc2f3SEric Joyner struct virtchnl_vsi_resource vsi_res[1]; 273*ceebc2f3SEric Joyner }; 274*ceebc2f3SEric Joyner 275*ceebc2f3SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_vf_resource); 276*ceebc2f3SEric Joyner 277*ceebc2f3SEric Joyner /* VIRTCHNL_OP_CONFIG_TX_QUEUE 278*ceebc2f3SEric Joyner * VF sends this message to set up parameters for one TX queue. 279*ceebc2f3SEric Joyner * External data buffer contains one instance of virtchnl_txq_info. 280*ceebc2f3SEric Joyner * PF configures requested queue and returns a status code. 281*ceebc2f3SEric Joyner */ 282*ceebc2f3SEric Joyner 283*ceebc2f3SEric Joyner /* Tx queue config info */ 284*ceebc2f3SEric Joyner struct virtchnl_txq_info { 285*ceebc2f3SEric Joyner u16 vsi_id; 286*ceebc2f3SEric Joyner u16 queue_id; 287*ceebc2f3SEric Joyner u16 ring_len; /* number of descriptors, multiple of 8 */ 288*ceebc2f3SEric Joyner u16 headwb_enabled; /* deprecated with AVF 1.0 */ 289*ceebc2f3SEric Joyner u64 dma_ring_addr; 290*ceebc2f3SEric Joyner u64 dma_headwb_addr; /* deprecated with AVF 1.0 */ 291*ceebc2f3SEric Joyner }; 292*ceebc2f3SEric Joyner 293*ceebc2f3SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_txq_info); 294*ceebc2f3SEric Joyner 295*ceebc2f3SEric Joyner /* VIRTCHNL_OP_CONFIG_RX_QUEUE 296*ceebc2f3SEric Joyner * VF sends this message to set up parameters for one RX queue. 297*ceebc2f3SEric Joyner * External data buffer contains one instance of virtchnl_rxq_info. 298*ceebc2f3SEric Joyner * PF configures requested queue and returns a status code. 299*ceebc2f3SEric Joyner */ 300*ceebc2f3SEric Joyner 301*ceebc2f3SEric Joyner /* Rx queue config info */ 302*ceebc2f3SEric Joyner struct virtchnl_rxq_info { 303*ceebc2f3SEric Joyner u16 vsi_id; 304*ceebc2f3SEric Joyner u16 queue_id; 305*ceebc2f3SEric Joyner u32 ring_len; /* number of descriptors, multiple of 32 */ 306*ceebc2f3SEric Joyner u16 hdr_size; 307*ceebc2f3SEric Joyner u16 splithdr_enabled; /* deprecated with AVF 1.0 */ 308*ceebc2f3SEric Joyner u32 databuffer_size; 309*ceebc2f3SEric Joyner u32 max_pkt_size; 310*ceebc2f3SEric Joyner u32 pad1; 311*ceebc2f3SEric Joyner u64 dma_ring_addr; 312*ceebc2f3SEric Joyner enum virtchnl_rx_hsplit rx_split_pos; /* deprecated with AVF 1.0 */ 313*ceebc2f3SEric Joyner u32 pad2; 314*ceebc2f3SEric Joyner }; 315*ceebc2f3SEric Joyner 316*ceebc2f3SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_rxq_info); 317*ceebc2f3SEric Joyner 318*ceebc2f3SEric Joyner /* VIRTCHNL_OP_CONFIG_VSI_QUEUES 319*ceebc2f3SEric Joyner * VF sends this message to set parameters for all active TX and RX queues 320*ceebc2f3SEric Joyner * associated with the specified VSI. 321*ceebc2f3SEric Joyner * PF configures queues and returns status. 322*ceebc2f3SEric Joyner * If the number of queues specified is greater than the number of queues 323*ceebc2f3SEric Joyner * associated with the VSI, an error is returned and no queues are configured. 324*ceebc2f3SEric Joyner */ 325*ceebc2f3SEric Joyner struct virtchnl_queue_pair_info { 326*ceebc2f3SEric Joyner /* NOTE: vsi_id and queue_id should be identical for both queues. */ 327*ceebc2f3SEric Joyner struct virtchnl_txq_info txq; 328*ceebc2f3SEric Joyner struct virtchnl_rxq_info rxq; 329*ceebc2f3SEric Joyner }; 330*ceebc2f3SEric Joyner 331*ceebc2f3SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(64, virtchnl_queue_pair_info); 332*ceebc2f3SEric Joyner 333*ceebc2f3SEric Joyner struct virtchnl_vsi_queue_config_info { 334*ceebc2f3SEric Joyner u16 vsi_id; 335*ceebc2f3SEric Joyner u16 num_queue_pairs; 336*ceebc2f3SEric Joyner u32 pad; 337*ceebc2f3SEric Joyner struct virtchnl_queue_pair_info qpair[1]; 338*ceebc2f3SEric Joyner }; 339*ceebc2f3SEric Joyner 340*ceebc2f3SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_vsi_queue_config_info); 341*ceebc2f3SEric Joyner 342*ceebc2f3SEric Joyner /* VIRTCHNL_OP_REQUEST_QUEUES 343*ceebc2f3SEric Joyner * VF sends this message to request the PF to allocate additional queues to 344*ceebc2f3SEric Joyner * this VF. Each VF gets a guaranteed number of queues on init but asking for 345*ceebc2f3SEric Joyner * additional queues must be negotiated. This is a best effort request as it 346*ceebc2f3SEric Joyner * is possible the PF does not have enough queues left to support the request. 347*ceebc2f3SEric Joyner * If the PF cannot support the number requested it will respond with the 348*ceebc2f3SEric Joyner * maximum number it is able to support; otherwise it will respond with the 349*ceebc2f3SEric Joyner * number requested. 350*ceebc2f3SEric Joyner */ 351*ceebc2f3SEric Joyner 352*ceebc2f3SEric Joyner /* VF resource request */ 353*ceebc2f3SEric Joyner struct virtchnl_vf_res_request { 354*ceebc2f3SEric Joyner u16 num_queue_pairs; 355*ceebc2f3SEric Joyner }; 356*ceebc2f3SEric Joyner 357*ceebc2f3SEric Joyner /* VIRTCHNL_OP_CONFIG_IRQ_MAP 358*ceebc2f3SEric Joyner * VF uses this message to map vectors to queues. 359*ceebc2f3SEric Joyner * The rxq_map and txq_map fields are bitmaps used to indicate which queues 360*ceebc2f3SEric Joyner * are to be associated with the specified vector. 361*ceebc2f3SEric Joyner * The "other" causes are always mapped to vector 0. 362*ceebc2f3SEric Joyner * PF configures interrupt mapping and returns status. 363*ceebc2f3SEric Joyner */ 364*ceebc2f3SEric Joyner struct virtchnl_vector_map { 365*ceebc2f3SEric Joyner u16 vsi_id; 366*ceebc2f3SEric Joyner u16 vector_id; 367*ceebc2f3SEric Joyner u16 rxq_map; 368*ceebc2f3SEric Joyner u16 txq_map; 369*ceebc2f3SEric Joyner u16 rxitr_idx; 370*ceebc2f3SEric Joyner u16 txitr_idx; 371*ceebc2f3SEric Joyner }; 372*ceebc2f3SEric Joyner 373*ceebc2f3SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_vector_map); 374*ceebc2f3SEric Joyner 375*ceebc2f3SEric Joyner struct virtchnl_irq_map_info { 376*ceebc2f3SEric Joyner u16 num_vectors; 377*ceebc2f3SEric Joyner struct virtchnl_vector_map vecmap[1]; 378*ceebc2f3SEric Joyner }; 379*ceebc2f3SEric Joyner 380*ceebc2f3SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(14, virtchnl_irq_map_info); 381*ceebc2f3SEric Joyner 382*ceebc2f3SEric Joyner /* VIRTCHNL_OP_ENABLE_QUEUES 383*ceebc2f3SEric Joyner * VIRTCHNL_OP_DISABLE_QUEUES 384*ceebc2f3SEric Joyner * VF sends these message to enable or disable TX/RX queue pairs. 385*ceebc2f3SEric Joyner * The queues fields are bitmaps indicating which queues to act upon. 386*ceebc2f3SEric Joyner * (Currently, we only support 16 queues per VF, but we make the field 387*ceebc2f3SEric Joyner * u32 to allow for expansion.) 388*ceebc2f3SEric Joyner * PF performs requested action and returns status. 389*ceebc2f3SEric Joyner */ 390*ceebc2f3SEric Joyner struct virtchnl_queue_select { 391*ceebc2f3SEric Joyner u16 vsi_id; 392*ceebc2f3SEric Joyner u16 pad; 393*ceebc2f3SEric Joyner u32 rx_queues; 394*ceebc2f3SEric Joyner u32 tx_queues; 395*ceebc2f3SEric Joyner }; 396*ceebc2f3SEric Joyner 397*ceebc2f3SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_select); 398*ceebc2f3SEric Joyner 399*ceebc2f3SEric Joyner /* VIRTCHNL_OP_ADD_ETH_ADDR 400*ceebc2f3SEric Joyner * VF sends this message in order to add one or more unicast or multicast 401*ceebc2f3SEric Joyner * address filters for the specified VSI. 402*ceebc2f3SEric Joyner * PF adds the filters and returns status. 403*ceebc2f3SEric Joyner */ 404*ceebc2f3SEric Joyner 405*ceebc2f3SEric Joyner /* VIRTCHNL_OP_DEL_ETH_ADDR 406*ceebc2f3SEric Joyner * VF sends this message in order to remove one or more unicast or multicast 407*ceebc2f3SEric Joyner * filters for the specified VSI. 408*ceebc2f3SEric Joyner * PF removes the filters and returns status. 409*ceebc2f3SEric Joyner */ 410*ceebc2f3SEric Joyner 411*ceebc2f3SEric Joyner struct virtchnl_ether_addr { 412*ceebc2f3SEric Joyner u8 addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS]; 413*ceebc2f3SEric Joyner u8 pad[2]; 414*ceebc2f3SEric Joyner }; 415*ceebc2f3SEric Joyner 416*ceebc2f3SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_ether_addr); 417*ceebc2f3SEric Joyner 418*ceebc2f3SEric Joyner struct virtchnl_ether_addr_list { 419*ceebc2f3SEric Joyner u16 vsi_id; 420*ceebc2f3SEric Joyner u16 num_elements; 421*ceebc2f3SEric Joyner struct virtchnl_ether_addr list[1]; 422*ceebc2f3SEric Joyner }; 423*ceebc2f3SEric Joyner 424*ceebc2f3SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_ether_addr_list); 425*ceebc2f3SEric Joyner 426*ceebc2f3SEric Joyner /* VIRTCHNL_OP_ADD_VLAN 427*ceebc2f3SEric Joyner * VF sends this message to add one or more VLAN tag filters for receives. 428*ceebc2f3SEric Joyner * PF adds the filters and returns status. 429*ceebc2f3SEric Joyner * If a port VLAN is configured by the PF, this operation will return an 430*ceebc2f3SEric Joyner * error to the VF. 431*ceebc2f3SEric Joyner */ 432*ceebc2f3SEric Joyner 433*ceebc2f3SEric Joyner /* VIRTCHNL_OP_DEL_VLAN 434*ceebc2f3SEric Joyner * VF sends this message to remove one or more VLAN tag filters for receives. 435*ceebc2f3SEric Joyner * PF removes the filters and returns status. 436*ceebc2f3SEric Joyner * If a port VLAN is configured by the PF, this operation will return an 437*ceebc2f3SEric Joyner * error to the VF. 438*ceebc2f3SEric Joyner */ 439*ceebc2f3SEric Joyner 440*ceebc2f3SEric Joyner struct virtchnl_vlan_filter_list { 441*ceebc2f3SEric Joyner u16 vsi_id; 442*ceebc2f3SEric Joyner u16 num_elements; 443*ceebc2f3SEric Joyner u16 vlan_id[1]; 444*ceebc2f3SEric Joyner }; 445*ceebc2f3SEric Joyner 446*ceebc2f3SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_vlan_filter_list); 447*ceebc2f3SEric Joyner 448*ceebc2f3SEric Joyner /* VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE 449*ceebc2f3SEric Joyner * VF sends VSI id and flags. 450*ceebc2f3SEric Joyner * PF returns status code in retval. 451*ceebc2f3SEric Joyner * Note: we assume that broadcast accept mode is always enabled. 452*ceebc2f3SEric Joyner */ 453*ceebc2f3SEric Joyner struct virtchnl_promisc_info { 454*ceebc2f3SEric Joyner u16 vsi_id; 455*ceebc2f3SEric Joyner u16 flags; 456*ceebc2f3SEric Joyner }; 457*ceebc2f3SEric Joyner 458*ceebc2f3SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_promisc_info); 459*ceebc2f3SEric Joyner 460*ceebc2f3SEric Joyner #define FLAG_VF_UNICAST_PROMISC 0x00000001 461*ceebc2f3SEric Joyner #define FLAG_VF_MULTICAST_PROMISC 0x00000002 462*ceebc2f3SEric Joyner 463*ceebc2f3SEric Joyner /* VIRTCHNL_OP_GET_STATS 464*ceebc2f3SEric Joyner * VF sends this message to request stats for the selected VSI. VF uses 465*ceebc2f3SEric Joyner * the virtchnl_queue_select struct to specify the VSI. The queue_id 466*ceebc2f3SEric Joyner * field is ignored by the PF. 467*ceebc2f3SEric Joyner * 468*ceebc2f3SEric Joyner * PF replies with struct eth_stats in an external buffer. 469*ceebc2f3SEric Joyner */ 470*ceebc2f3SEric Joyner 471*ceebc2f3SEric Joyner /* VIRTCHNL_OP_CONFIG_RSS_KEY 472*ceebc2f3SEric Joyner * VIRTCHNL_OP_CONFIG_RSS_LUT 473*ceebc2f3SEric Joyner * VF sends these messages to configure RSS. Only supported if both PF 474*ceebc2f3SEric Joyner * and VF drivers set the VIRTCHNL_VF_OFFLOAD_RSS_PF bit during 475*ceebc2f3SEric Joyner * configuration negotiation. If this is the case, then the RSS fields in 476*ceebc2f3SEric Joyner * the VF resource struct are valid. 477*ceebc2f3SEric Joyner * Both the key and LUT are initialized to 0 by the PF, meaning that 478*ceebc2f3SEric Joyner * RSS is effectively disabled until set up by the VF. 479*ceebc2f3SEric Joyner */ 480*ceebc2f3SEric Joyner struct virtchnl_rss_key { 481*ceebc2f3SEric Joyner u16 vsi_id; 482*ceebc2f3SEric Joyner u16 key_len; 483*ceebc2f3SEric Joyner u8 key[1]; /* RSS hash key, packed bytes */ 484*ceebc2f3SEric Joyner }; 485*ceebc2f3SEric Joyner 486*ceebc2f3SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_rss_key); 487*ceebc2f3SEric Joyner 488*ceebc2f3SEric Joyner struct virtchnl_rss_lut { 489*ceebc2f3SEric Joyner u16 vsi_id; 490*ceebc2f3SEric Joyner u16 lut_entries; 491*ceebc2f3SEric Joyner u8 lut[1]; /* RSS lookup table */ 492*ceebc2f3SEric Joyner }; 493*ceebc2f3SEric Joyner 494*ceebc2f3SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_rss_lut); 495*ceebc2f3SEric Joyner 496*ceebc2f3SEric Joyner /* VIRTCHNL_OP_GET_RSS_HENA_CAPS 497*ceebc2f3SEric Joyner * VIRTCHNL_OP_SET_RSS_HENA 498*ceebc2f3SEric Joyner * VF sends these messages to get and set the hash filter enable bits for RSS. 499*ceebc2f3SEric Joyner * By default, the PF sets these to all possible traffic types that the 500*ceebc2f3SEric Joyner * hardware supports. The VF can query this value if it wants to change the 501*ceebc2f3SEric Joyner * traffic types that are hashed by the hardware. 502*ceebc2f3SEric Joyner */ 503*ceebc2f3SEric Joyner struct virtchnl_rss_hena { 504*ceebc2f3SEric Joyner u64 hena; 505*ceebc2f3SEric Joyner }; 506*ceebc2f3SEric Joyner 507*ceebc2f3SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_rss_hena); 508*ceebc2f3SEric Joyner 509*ceebc2f3SEric Joyner /* VIRTCHNL_OP_EVENT 510*ceebc2f3SEric Joyner * PF sends this message to inform the VF driver of events that may affect it. 511*ceebc2f3SEric Joyner * No direct response is expected from the VF, though it may generate other 512*ceebc2f3SEric Joyner * messages in response to this one. 513*ceebc2f3SEric Joyner */ 514*ceebc2f3SEric Joyner enum virtchnl_event_codes { 515*ceebc2f3SEric Joyner VIRTCHNL_EVENT_UNKNOWN = 0, 516*ceebc2f3SEric Joyner VIRTCHNL_EVENT_LINK_CHANGE, 517*ceebc2f3SEric Joyner VIRTCHNL_EVENT_RESET_IMPENDING, 518*ceebc2f3SEric Joyner VIRTCHNL_EVENT_PF_DRIVER_CLOSE, 519*ceebc2f3SEric Joyner }; 520*ceebc2f3SEric Joyner 521*ceebc2f3SEric Joyner #define PF_EVENT_SEVERITY_INFO 0 522*ceebc2f3SEric Joyner #define PF_EVENT_SEVERITY_ATTENTION 1 523*ceebc2f3SEric Joyner #define PF_EVENT_SEVERITY_ACTION_REQUIRED 2 524*ceebc2f3SEric Joyner #define PF_EVENT_SEVERITY_CERTAIN_DOOM 255 525*ceebc2f3SEric Joyner 526*ceebc2f3SEric Joyner struct virtchnl_pf_event { 527*ceebc2f3SEric Joyner enum virtchnl_event_codes event; 528*ceebc2f3SEric Joyner union { 529*ceebc2f3SEric Joyner struct { 530*ceebc2f3SEric Joyner enum virtchnl_link_speed link_speed; 531*ceebc2f3SEric Joyner bool link_status; 532*ceebc2f3SEric Joyner } link_event; 533*ceebc2f3SEric Joyner } event_data; 534*ceebc2f3SEric Joyner 535*ceebc2f3SEric Joyner int severity; 536*ceebc2f3SEric Joyner }; 537*ceebc2f3SEric Joyner 538*ceebc2f3SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_pf_event); 539*ceebc2f3SEric Joyner 540*ceebc2f3SEric Joyner 541*ceebc2f3SEric Joyner /* VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP 542*ceebc2f3SEric Joyner * VF uses this message to request PF to map IWARP vectors to IWARP queues. 543*ceebc2f3SEric Joyner * The request for this originates from the VF IWARP driver through 544*ceebc2f3SEric Joyner * a client interface between VF LAN and VF IWARP driver. 545*ceebc2f3SEric Joyner * A vector could have an AEQ and CEQ attached to it although 546*ceebc2f3SEric Joyner * there is a single AEQ per VF IWARP instance in which case 547*ceebc2f3SEric Joyner * most vectors will have an INVALID_IDX for aeq and valid idx for ceq. 548*ceebc2f3SEric Joyner * There will never be a case where there will be multiple CEQs attached 549*ceebc2f3SEric Joyner * to a single vector. 550*ceebc2f3SEric Joyner * PF configures interrupt mapping and returns status. 551*ceebc2f3SEric Joyner */ 552*ceebc2f3SEric Joyner 553*ceebc2f3SEric Joyner /* HW does not define a type value for AEQ; only for RX/TX and CEQ. 554*ceebc2f3SEric Joyner * In order for us to keep the interface simple, SW will define a 555*ceebc2f3SEric Joyner * unique type value for AEQ. 556*ceebc2f3SEric Joyner */ 557*ceebc2f3SEric Joyner #define QUEUE_TYPE_PE_AEQ 0x80 558*ceebc2f3SEric Joyner #define QUEUE_INVALID_IDX 0xFFFF 559*ceebc2f3SEric Joyner 560*ceebc2f3SEric Joyner struct virtchnl_iwarp_qv_info { 561*ceebc2f3SEric Joyner u32 v_idx; /* msix_vector */ 562*ceebc2f3SEric Joyner u16 ceq_idx; 563*ceebc2f3SEric Joyner u16 aeq_idx; 564*ceebc2f3SEric Joyner u8 itr_idx; 565*ceebc2f3SEric Joyner }; 566*ceebc2f3SEric Joyner 567*ceebc2f3SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_iwarp_qv_info); 568*ceebc2f3SEric Joyner 569*ceebc2f3SEric Joyner struct virtchnl_iwarp_qvlist_info { 570*ceebc2f3SEric Joyner u32 num_vectors; 571*ceebc2f3SEric Joyner struct virtchnl_iwarp_qv_info qv_info[1]; 572*ceebc2f3SEric Joyner }; 573*ceebc2f3SEric Joyner 574*ceebc2f3SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_iwarp_qvlist_info); 575*ceebc2f3SEric Joyner 576*ceebc2f3SEric Joyner 577*ceebc2f3SEric Joyner /* VF reset states - these are written into the RSTAT register: 578*ceebc2f3SEric Joyner * VFGEN_RSTAT on the VF 579*ceebc2f3SEric Joyner * When the PF initiates a reset, it writes 0 580*ceebc2f3SEric Joyner * When the reset is complete, it writes 1 581*ceebc2f3SEric Joyner * When the PF detects that the VF has recovered, it writes 2 582*ceebc2f3SEric Joyner * VF checks this register periodically to determine if a reset has occurred, 583*ceebc2f3SEric Joyner * then polls it to know when the reset is complete. 584*ceebc2f3SEric Joyner * If either the PF or VF reads the register while the hardware 585*ceebc2f3SEric Joyner * is in a reset state, it will return DEADBEEF, which, when masked 586*ceebc2f3SEric Joyner * will result in 3. 587*ceebc2f3SEric Joyner */ 588*ceebc2f3SEric Joyner enum virtchnl_vfr_states { 589*ceebc2f3SEric Joyner VIRTCHNL_VFR_INPROGRESS = 0, 590*ceebc2f3SEric Joyner VIRTCHNL_VFR_COMPLETED, 591*ceebc2f3SEric Joyner VIRTCHNL_VFR_VFACTIVE, 592*ceebc2f3SEric Joyner }; 593*ceebc2f3SEric Joyner 594*ceebc2f3SEric Joyner /** 595*ceebc2f3SEric Joyner * virtchnl_vc_validate_vf_msg 596*ceebc2f3SEric Joyner * @ver: Virtchnl version info 597*ceebc2f3SEric Joyner * @v_opcode: Opcode for the message 598*ceebc2f3SEric Joyner * @msg: pointer to the msg buffer 599*ceebc2f3SEric Joyner * @msglen: msg length 600*ceebc2f3SEric Joyner * 601*ceebc2f3SEric Joyner * validate msg format against struct for each opcode 602*ceebc2f3SEric Joyner */ 603*ceebc2f3SEric Joyner static inline int 604*ceebc2f3SEric Joyner virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode, 605*ceebc2f3SEric Joyner u8 *msg, u16 msglen) 606*ceebc2f3SEric Joyner { 607*ceebc2f3SEric Joyner bool err_msg_format = FALSE; 608*ceebc2f3SEric Joyner int valid_len = 0; 609*ceebc2f3SEric Joyner 610*ceebc2f3SEric Joyner /* Validate message length. */ 611*ceebc2f3SEric Joyner switch (v_opcode) { 612*ceebc2f3SEric Joyner case VIRTCHNL_OP_VERSION: 613*ceebc2f3SEric Joyner valid_len = sizeof(struct virtchnl_version_info); 614*ceebc2f3SEric Joyner break; 615*ceebc2f3SEric Joyner case VIRTCHNL_OP_RESET_VF: 616*ceebc2f3SEric Joyner break; 617*ceebc2f3SEric Joyner case VIRTCHNL_OP_GET_VF_RESOURCES: 618*ceebc2f3SEric Joyner if (VF_IS_V11(ver)) 619*ceebc2f3SEric Joyner valid_len = sizeof(u32); 620*ceebc2f3SEric Joyner break; 621*ceebc2f3SEric Joyner case VIRTCHNL_OP_CONFIG_TX_QUEUE: 622*ceebc2f3SEric Joyner valid_len = sizeof(struct virtchnl_txq_info); 623*ceebc2f3SEric Joyner break; 624*ceebc2f3SEric Joyner case VIRTCHNL_OP_CONFIG_RX_QUEUE: 625*ceebc2f3SEric Joyner valid_len = sizeof(struct virtchnl_rxq_info); 626*ceebc2f3SEric Joyner break; 627*ceebc2f3SEric Joyner case VIRTCHNL_OP_CONFIG_VSI_QUEUES: 628*ceebc2f3SEric Joyner valid_len = sizeof(struct virtchnl_vsi_queue_config_info); 629*ceebc2f3SEric Joyner if (msglen >= valid_len) { 630*ceebc2f3SEric Joyner struct virtchnl_vsi_queue_config_info *vqc = 631*ceebc2f3SEric Joyner (struct virtchnl_vsi_queue_config_info *)msg; 632*ceebc2f3SEric Joyner valid_len += (vqc->num_queue_pairs * 633*ceebc2f3SEric Joyner sizeof(struct 634*ceebc2f3SEric Joyner virtchnl_queue_pair_info)); 635*ceebc2f3SEric Joyner if (vqc->num_queue_pairs == 0) 636*ceebc2f3SEric Joyner err_msg_format = TRUE; 637*ceebc2f3SEric Joyner } 638*ceebc2f3SEric Joyner break; 639*ceebc2f3SEric Joyner case VIRTCHNL_OP_CONFIG_IRQ_MAP: 640*ceebc2f3SEric Joyner valid_len = sizeof(struct virtchnl_irq_map_info); 641*ceebc2f3SEric Joyner if (msglen >= valid_len) { 642*ceebc2f3SEric Joyner struct virtchnl_irq_map_info *vimi = 643*ceebc2f3SEric Joyner (struct virtchnl_irq_map_info *)msg; 644*ceebc2f3SEric Joyner valid_len += (vimi->num_vectors * 645*ceebc2f3SEric Joyner sizeof(struct virtchnl_vector_map)); 646*ceebc2f3SEric Joyner if (vimi->num_vectors == 0) 647*ceebc2f3SEric Joyner err_msg_format = TRUE; 648*ceebc2f3SEric Joyner } 649*ceebc2f3SEric Joyner break; 650*ceebc2f3SEric Joyner case VIRTCHNL_OP_ENABLE_QUEUES: 651*ceebc2f3SEric Joyner case VIRTCHNL_OP_DISABLE_QUEUES: 652*ceebc2f3SEric Joyner valid_len = sizeof(struct virtchnl_queue_select); 653*ceebc2f3SEric Joyner break; 654*ceebc2f3SEric Joyner case VIRTCHNL_OP_ADD_ETH_ADDR: 655*ceebc2f3SEric Joyner case VIRTCHNL_OP_DEL_ETH_ADDR: 656*ceebc2f3SEric Joyner valid_len = sizeof(struct virtchnl_ether_addr_list); 657*ceebc2f3SEric Joyner if (msglen >= valid_len) { 658*ceebc2f3SEric Joyner struct virtchnl_ether_addr_list *veal = 659*ceebc2f3SEric Joyner (struct virtchnl_ether_addr_list *)msg; 660*ceebc2f3SEric Joyner valid_len += veal->num_elements * 661*ceebc2f3SEric Joyner sizeof(struct virtchnl_ether_addr); 662*ceebc2f3SEric Joyner if (veal->num_elements == 0) 663*ceebc2f3SEric Joyner err_msg_format = TRUE; 664*ceebc2f3SEric Joyner } 665*ceebc2f3SEric Joyner break; 666*ceebc2f3SEric Joyner case VIRTCHNL_OP_ADD_VLAN: 667*ceebc2f3SEric Joyner case VIRTCHNL_OP_DEL_VLAN: 668*ceebc2f3SEric Joyner valid_len = sizeof(struct virtchnl_vlan_filter_list); 669*ceebc2f3SEric Joyner if (msglen >= valid_len) { 670*ceebc2f3SEric Joyner struct virtchnl_vlan_filter_list *vfl = 671*ceebc2f3SEric Joyner (struct virtchnl_vlan_filter_list *)msg; 672*ceebc2f3SEric Joyner valid_len += vfl->num_elements * sizeof(u16); 673*ceebc2f3SEric Joyner if (vfl->num_elements == 0) 674*ceebc2f3SEric Joyner err_msg_format = TRUE; 675*ceebc2f3SEric Joyner } 676*ceebc2f3SEric Joyner break; 677*ceebc2f3SEric Joyner case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE: 678*ceebc2f3SEric Joyner valid_len = sizeof(struct virtchnl_promisc_info); 679*ceebc2f3SEric Joyner break; 680*ceebc2f3SEric Joyner case VIRTCHNL_OP_GET_STATS: 681*ceebc2f3SEric Joyner valid_len = sizeof(struct virtchnl_queue_select); 682*ceebc2f3SEric Joyner break; 683*ceebc2f3SEric Joyner case VIRTCHNL_OP_IWARP: 684*ceebc2f3SEric Joyner /* These messages are opaque to us and will be validated in 685*ceebc2f3SEric Joyner * the RDMA client code. We just need to check for nonzero 686*ceebc2f3SEric Joyner * length. The firmware will enforce max length restrictions. 687*ceebc2f3SEric Joyner */ 688*ceebc2f3SEric Joyner if (msglen) 689*ceebc2f3SEric Joyner valid_len = msglen; 690*ceebc2f3SEric Joyner else 691*ceebc2f3SEric Joyner err_msg_format = TRUE; 692*ceebc2f3SEric Joyner break; 693*ceebc2f3SEric Joyner case VIRTCHNL_OP_RELEASE_IWARP_IRQ_MAP: 694*ceebc2f3SEric Joyner break; 695*ceebc2f3SEric Joyner case VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP: 696*ceebc2f3SEric Joyner valid_len = sizeof(struct virtchnl_iwarp_qvlist_info); 697*ceebc2f3SEric Joyner if (msglen >= valid_len) { 698*ceebc2f3SEric Joyner struct virtchnl_iwarp_qvlist_info *qv = 699*ceebc2f3SEric Joyner (struct virtchnl_iwarp_qvlist_info *)msg; 700*ceebc2f3SEric Joyner if (qv->num_vectors == 0) { 701*ceebc2f3SEric Joyner err_msg_format = TRUE; 702*ceebc2f3SEric Joyner break; 703*ceebc2f3SEric Joyner } 704*ceebc2f3SEric Joyner valid_len += ((qv->num_vectors - 1) * 705*ceebc2f3SEric Joyner sizeof(struct virtchnl_iwarp_qv_info)); 706*ceebc2f3SEric Joyner } 707*ceebc2f3SEric Joyner break; 708*ceebc2f3SEric Joyner case VIRTCHNL_OP_CONFIG_RSS_KEY: 709*ceebc2f3SEric Joyner valid_len = sizeof(struct virtchnl_rss_key); 710*ceebc2f3SEric Joyner if (msglen >= valid_len) { 711*ceebc2f3SEric Joyner struct virtchnl_rss_key *vrk = 712*ceebc2f3SEric Joyner (struct virtchnl_rss_key *)msg; 713*ceebc2f3SEric Joyner valid_len += vrk->key_len - 1; 714*ceebc2f3SEric Joyner } 715*ceebc2f3SEric Joyner break; 716*ceebc2f3SEric Joyner case VIRTCHNL_OP_CONFIG_RSS_LUT: 717*ceebc2f3SEric Joyner valid_len = sizeof(struct virtchnl_rss_lut); 718*ceebc2f3SEric Joyner if (msglen >= valid_len) { 719*ceebc2f3SEric Joyner struct virtchnl_rss_lut *vrl = 720*ceebc2f3SEric Joyner (struct virtchnl_rss_lut *)msg; 721*ceebc2f3SEric Joyner valid_len += vrl->lut_entries - 1; 722*ceebc2f3SEric Joyner } 723*ceebc2f3SEric Joyner break; 724*ceebc2f3SEric Joyner case VIRTCHNL_OP_GET_RSS_HENA_CAPS: 725*ceebc2f3SEric Joyner break; 726*ceebc2f3SEric Joyner case VIRTCHNL_OP_SET_RSS_HENA: 727*ceebc2f3SEric Joyner valid_len = sizeof(struct virtchnl_rss_hena); 728*ceebc2f3SEric Joyner break; 729*ceebc2f3SEric Joyner case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING: 730*ceebc2f3SEric Joyner case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING: 731*ceebc2f3SEric Joyner break; 732*ceebc2f3SEric Joyner case VIRTCHNL_OP_REQUEST_QUEUES: 733*ceebc2f3SEric Joyner valid_len = sizeof(struct virtchnl_vf_res_request); 734*ceebc2f3SEric Joyner break; 735*ceebc2f3SEric Joyner /* These are always errors coming from the VF. */ 736*ceebc2f3SEric Joyner case VIRTCHNL_OP_EVENT: 737*ceebc2f3SEric Joyner case VIRTCHNL_OP_UNKNOWN: 738*ceebc2f3SEric Joyner default: 739*ceebc2f3SEric Joyner return VIRTCHNL_ERR_PARAM; 740*ceebc2f3SEric Joyner } 741*ceebc2f3SEric Joyner /* few more checks */ 742*ceebc2f3SEric Joyner if (err_msg_format || valid_len != msglen) 743*ceebc2f3SEric Joyner return VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH; 744*ceebc2f3SEric Joyner 745*ceebc2f3SEric Joyner return 0; 746*ceebc2f3SEric Joyner } 747*ceebc2f3SEric Joyner #endif /* _VIRTCHNL_H_ */ 748