171d10453SEric Joyner /* SPDX-License-Identifier: BSD-3-Clause */ 2015f8cc5SEric Joyner /* Copyright (c) 2024, Intel Corporation 371d10453SEric Joyner * All rights reserved. 471d10453SEric Joyner * 571d10453SEric Joyner * Redistribution and use in source and binary forms, with or without 671d10453SEric Joyner * modification, are permitted provided that the following conditions are met: 771d10453SEric Joyner * 871d10453SEric Joyner * 1. Redistributions of source code must retain the above copyright notice, 971d10453SEric Joyner * this list of conditions and the following disclaimer. 1071d10453SEric Joyner * 1171d10453SEric Joyner * 2. Redistributions in binary form must reproduce the above copyright 1271d10453SEric Joyner * notice, this list of conditions and the following disclaimer in the 1371d10453SEric Joyner * documentation and/or other materials provided with the distribution. 1471d10453SEric Joyner * 1571d10453SEric Joyner * 3. Neither the name of the Intel Corporation nor the names of its 1671d10453SEric Joyner * contributors may be used to endorse or promote products derived from 1771d10453SEric Joyner * this software without specific prior written permission. 1871d10453SEric Joyner * 1971d10453SEric Joyner * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 2071d10453SEric Joyner * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2171d10453SEric Joyner * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2271d10453SEric Joyner * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 2371d10453SEric Joyner * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2471d10453SEric Joyner * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2571d10453SEric Joyner * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2671d10453SEric Joyner * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2771d10453SEric Joyner * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2871d10453SEric Joyner * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2971d10453SEric Joyner * POSSIBILITY OF SUCH DAMAGE. 3071d10453SEric Joyner */ 3171d10453SEric Joyner 3271d10453SEric Joyner #ifndef _VIRTCHNL_H_ 3371d10453SEric Joyner #define _VIRTCHNL_H_ 3471d10453SEric Joyner 3571d10453SEric Joyner /* Description: 369cf1841cSEric Joyner * This header file describes the Virtual Function (VF) - Physical Function 379cf1841cSEric Joyner * (PF) communication protocol used by the drivers for all devices starting 389cf1841cSEric Joyner * from our 40G product line 3971d10453SEric Joyner * 4071d10453SEric Joyner * Admin queue buffer usage: 4171d10453SEric Joyner * desc->opcode is always aqc_opc_send_msg_to_pf 4271d10453SEric Joyner * flags, retval, datalen, and data addr are all used normally. 4371d10453SEric Joyner * The Firmware copies the cookie fields when sending messages between the 4471d10453SEric Joyner * PF and VF, but uses all other fields internally. Due to this limitation, 4571d10453SEric Joyner * we must send all messages as "indirect", i.e. using an external buffer. 4671d10453SEric Joyner * 4771d10453SEric Joyner * All the VSI indexes are relative to the VF. Each VF can have maximum of 4871d10453SEric Joyner * three VSIs. All the queue indexes are relative to the VSI. Each VF can 4971d10453SEric Joyner * have a maximum of sixteen queues for all of its VSIs. 5071d10453SEric Joyner * 5171d10453SEric Joyner * The PF is required to return a status code in v_retval for all messages 529cf1841cSEric Joyner * except RESET_VF, which does not require any response. The returned value 5356429daeSEric Joyner * is of virtchnl_status_code type, defined here. 5471d10453SEric Joyner * 5571d10453SEric Joyner * In general, VF driver initialization should roughly follow the order of 5671d10453SEric Joyner * these opcodes. The VF driver must first validate the API version of the 5771d10453SEric Joyner * PF driver, then request a reset, then get resources, then configure 5871d10453SEric Joyner * queues and interrupts. After these operations are complete, the VF 5971d10453SEric Joyner * driver may start its queues, optionally add MAC and VLAN filters, and 6071d10453SEric Joyner * process traffic. 6171d10453SEric Joyner */ 6271d10453SEric Joyner 6371d10453SEric Joyner /* START GENERIC DEFINES 6471d10453SEric Joyner * Need to ensure the following enums and defines hold the same meaning and 6571d10453SEric Joyner * value in current and future projects 6671d10453SEric Joyner */ 6771d10453SEric Joyner 6856429daeSEric Joyner #define VIRTCHNL_ETH_LENGTH_OF_ADDRESS 6 6956429daeSEric Joyner 7056429daeSEric Joyner /* These macros are used to generate compilation errors if a structure/union 7156429daeSEric Joyner * is not exactly the correct length. It gives a divide by zero error if the 7256429daeSEric Joyner * structure/union is not of the correct size, otherwise it creates an enum 7356429daeSEric Joyner * that is never used. 7456429daeSEric Joyner */ 7556429daeSEric Joyner #define VIRTCHNL_CHECK_STRUCT_LEN(n, X) enum virtchnl_static_assert_enum_##X \ 7656429daeSEric Joyner { virtchnl_static_assert_##X = (n)/((sizeof(struct X) == (n)) ? 1 : 0) } 7756429daeSEric Joyner #define VIRTCHNL_CHECK_UNION_LEN(n, X) enum virtchnl_static_asset_enum_##X \ 7856429daeSEric Joyner { virtchnl_static_assert_##X = (n)/((sizeof(union X) == (n)) ? 1 : 0) } 7956429daeSEric Joyner 8056429daeSEric Joyner /* Error Codes 8156429daeSEric Joyner * Note that many older versions of various iAVF drivers convert the reported 8256429daeSEric Joyner * status code directly into an iavf_status enumeration. For this reason, it 8356429daeSEric Joyner * is important that the values of these enumerations line up. 8456429daeSEric Joyner */ 8571d10453SEric Joyner enum virtchnl_status_code { 8671d10453SEric Joyner VIRTCHNL_STATUS_SUCCESS = 0, 8771d10453SEric Joyner VIRTCHNL_STATUS_ERR_PARAM = -5, 8871d10453SEric Joyner VIRTCHNL_STATUS_ERR_NO_MEMORY = -18, 8971d10453SEric Joyner VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH = -38, 9071d10453SEric Joyner VIRTCHNL_STATUS_ERR_CQP_COMPL_ERROR = -39, 9171d10453SEric Joyner VIRTCHNL_STATUS_ERR_INVALID_VF_ID = -40, 9271d10453SEric Joyner VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR = -53, 9371d10453SEric Joyner VIRTCHNL_STATUS_ERR_NOT_SUPPORTED = -64, 9471d10453SEric Joyner }; 9571d10453SEric Joyner 9671d10453SEric Joyner /* Backward compatibility */ 9771d10453SEric Joyner #define VIRTCHNL_ERR_PARAM VIRTCHNL_STATUS_ERR_PARAM 9871d10453SEric Joyner #define VIRTCHNL_STATUS_NOT_SUPPORTED VIRTCHNL_STATUS_ERR_NOT_SUPPORTED 9971d10453SEric Joyner 10071d10453SEric Joyner #define VIRTCHNL_LINK_SPEED_2_5GB_SHIFT 0x0 10171d10453SEric Joyner #define VIRTCHNL_LINK_SPEED_100MB_SHIFT 0x1 10271d10453SEric Joyner #define VIRTCHNL_LINK_SPEED_1000MB_SHIFT 0x2 10371d10453SEric Joyner #define VIRTCHNL_LINK_SPEED_10GB_SHIFT 0x3 10471d10453SEric Joyner #define VIRTCHNL_LINK_SPEED_40GB_SHIFT 0x4 10571d10453SEric Joyner #define VIRTCHNL_LINK_SPEED_20GB_SHIFT 0x5 10671d10453SEric Joyner #define VIRTCHNL_LINK_SPEED_25GB_SHIFT 0x6 10771d10453SEric Joyner #define VIRTCHNL_LINK_SPEED_5GB_SHIFT 0x7 10871d10453SEric Joyner 10971d10453SEric Joyner enum virtchnl_link_speed { 11071d10453SEric Joyner VIRTCHNL_LINK_SPEED_UNKNOWN = 0, 11171d10453SEric Joyner VIRTCHNL_LINK_SPEED_100MB = BIT(VIRTCHNL_LINK_SPEED_100MB_SHIFT), 11271d10453SEric Joyner VIRTCHNL_LINK_SPEED_1GB = BIT(VIRTCHNL_LINK_SPEED_1000MB_SHIFT), 11371d10453SEric Joyner VIRTCHNL_LINK_SPEED_10GB = BIT(VIRTCHNL_LINK_SPEED_10GB_SHIFT), 11471d10453SEric Joyner VIRTCHNL_LINK_SPEED_40GB = BIT(VIRTCHNL_LINK_SPEED_40GB_SHIFT), 11571d10453SEric Joyner VIRTCHNL_LINK_SPEED_20GB = BIT(VIRTCHNL_LINK_SPEED_20GB_SHIFT), 11671d10453SEric Joyner VIRTCHNL_LINK_SPEED_25GB = BIT(VIRTCHNL_LINK_SPEED_25GB_SHIFT), 11771d10453SEric Joyner VIRTCHNL_LINK_SPEED_2_5GB = BIT(VIRTCHNL_LINK_SPEED_2_5GB_SHIFT), 11871d10453SEric Joyner VIRTCHNL_LINK_SPEED_5GB = BIT(VIRTCHNL_LINK_SPEED_5GB_SHIFT), 11971d10453SEric Joyner }; 12071d10453SEric Joyner 12171d10453SEric Joyner /* for hsplit_0 field of Rx HMC context */ 12271d10453SEric Joyner /* deprecated with AVF 1.0 */ 12371d10453SEric Joyner enum virtchnl_rx_hsplit { 12471d10453SEric Joyner VIRTCHNL_RX_HSPLIT_NO_SPLIT = 0, 12571d10453SEric Joyner VIRTCHNL_RX_HSPLIT_SPLIT_L2 = 1, 12671d10453SEric Joyner VIRTCHNL_RX_HSPLIT_SPLIT_IP = 2, 12771d10453SEric Joyner VIRTCHNL_RX_HSPLIT_SPLIT_TCP_UDP = 4, 12871d10453SEric Joyner VIRTCHNL_RX_HSPLIT_SPLIT_SCTP = 8, 12971d10453SEric Joyner }; 13071d10453SEric Joyner 13156429daeSEric Joyner enum virtchnl_bw_limit_type { 13256429daeSEric Joyner VIRTCHNL_BW_SHAPER = 0, 13356429daeSEric Joyner }; 13471d10453SEric Joyner /* END GENERIC DEFINES */ 13571d10453SEric Joyner 13671d10453SEric Joyner /* Opcodes for VF-PF communication. These are placed in the v_opcode field 13771d10453SEric Joyner * of the virtchnl_msg structure. 13871d10453SEric Joyner */ 13971d10453SEric Joyner enum virtchnl_ops { 14071d10453SEric Joyner /* The PF sends status change events to VFs using 14171d10453SEric Joyner * the VIRTCHNL_OP_EVENT opcode. 14271d10453SEric Joyner * VFs send requests to the PF using the other ops. 14371d10453SEric Joyner * Use of "advanced opcode" features must be negotiated as part of capabilities 14471d10453SEric Joyner * exchange and are not considered part of base mode feature set. 14556429daeSEric Joyner * 14671d10453SEric Joyner */ 14771d10453SEric Joyner VIRTCHNL_OP_UNKNOWN = 0, 14871d10453SEric Joyner VIRTCHNL_OP_VERSION = 1, /* must ALWAYS be 1 */ 14971d10453SEric Joyner VIRTCHNL_OP_RESET_VF = 2, 15071d10453SEric Joyner VIRTCHNL_OP_GET_VF_RESOURCES = 3, 15171d10453SEric Joyner VIRTCHNL_OP_CONFIG_TX_QUEUE = 4, 15271d10453SEric Joyner VIRTCHNL_OP_CONFIG_RX_QUEUE = 5, 15371d10453SEric Joyner VIRTCHNL_OP_CONFIG_VSI_QUEUES = 6, 15471d10453SEric Joyner VIRTCHNL_OP_CONFIG_IRQ_MAP = 7, 15571d10453SEric Joyner VIRTCHNL_OP_ENABLE_QUEUES = 8, 15671d10453SEric Joyner VIRTCHNL_OP_DISABLE_QUEUES = 9, 15771d10453SEric Joyner VIRTCHNL_OP_ADD_ETH_ADDR = 10, 15871d10453SEric Joyner VIRTCHNL_OP_DEL_ETH_ADDR = 11, 15971d10453SEric Joyner VIRTCHNL_OP_ADD_VLAN = 12, 16071d10453SEric Joyner VIRTCHNL_OP_DEL_VLAN = 13, 16171d10453SEric Joyner VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE = 14, 16271d10453SEric Joyner VIRTCHNL_OP_GET_STATS = 15, 16371d10453SEric Joyner VIRTCHNL_OP_RSVD = 16, 16471d10453SEric Joyner VIRTCHNL_OP_EVENT = 17, /* must ALWAYS be 17 */ 16571d10453SEric Joyner /* opcode 19 is reserved */ 16671d10453SEric Joyner /* opcodes 20, 21, and 22 are reserved */ 16771d10453SEric Joyner VIRTCHNL_OP_CONFIG_RSS_KEY = 23, 16871d10453SEric Joyner VIRTCHNL_OP_CONFIG_RSS_LUT = 24, 16971d10453SEric Joyner VIRTCHNL_OP_GET_RSS_HENA_CAPS = 25, 17071d10453SEric Joyner VIRTCHNL_OP_SET_RSS_HENA = 26, 17171d10453SEric Joyner VIRTCHNL_OP_ENABLE_VLAN_STRIPPING = 27, 17271d10453SEric Joyner VIRTCHNL_OP_DISABLE_VLAN_STRIPPING = 28, 17371d10453SEric Joyner VIRTCHNL_OP_REQUEST_QUEUES = 29, 17471d10453SEric Joyner VIRTCHNL_OP_ENABLE_CHANNELS = 30, 17571d10453SEric Joyner VIRTCHNL_OP_DISABLE_CHANNELS = 31, 17671d10453SEric Joyner VIRTCHNL_OP_ADD_CLOUD_FILTER = 32, 17771d10453SEric Joyner VIRTCHNL_OP_DEL_CLOUD_FILTER = 33, 1787d7af7f8SEric Joyner /* opcode 34 is reserved */ 1799cf1841cSEric Joyner /* opcodes 38, 39, 40, 41, 42 and 43 are reserved */ 1807d7af7f8SEric Joyner /* opcode 44 is reserved */ 18156429daeSEric Joyner VIRTCHNL_OP_ADD_RSS_CFG = 45, 18256429daeSEric Joyner VIRTCHNL_OP_DEL_RSS_CFG = 46, 18356429daeSEric Joyner VIRTCHNL_OP_ADD_FDIR_FILTER = 47, 18456429daeSEric Joyner VIRTCHNL_OP_DEL_FDIR_FILTER = 48, 185d08b8680SEric Joyner VIRTCHNL_OP_GET_MAX_RSS_QREGION = 50, 1869cf1841cSEric Joyner VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS = 51, 1879cf1841cSEric Joyner VIRTCHNL_OP_ADD_VLAN_V2 = 52, 1889cf1841cSEric Joyner VIRTCHNL_OP_DEL_VLAN_V2 = 53, 1899cf1841cSEric Joyner VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 = 54, 1909cf1841cSEric Joyner VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 = 55, 1919cf1841cSEric Joyner VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 = 56, 1929cf1841cSEric Joyner VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2 = 57, 1939cf1841cSEric Joyner VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2 = 58, 1949cf1841cSEric Joyner VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2 = 59, 19556429daeSEric Joyner /* opcodes 60 through 65 are reserved */ 19656429daeSEric Joyner VIRTCHNL_OP_GET_QOS_CAPS = 66, 19756429daeSEric Joyner VIRTCHNL_OP_CONFIG_QUEUE_TC_MAP = 67, 1988923de59SPiotr Kubaj /* opcode 68 through 70 are reserved */ 199d08b8680SEric Joyner VIRTCHNL_OP_ENABLE_QUEUES_V2 = 107, 200d08b8680SEric Joyner VIRTCHNL_OP_DISABLE_QUEUES_V2 = 108, 201d08b8680SEric Joyner VIRTCHNL_OP_MAP_QUEUE_VECTOR = 111, 2028923de59SPiotr Kubaj VIRTCHNL_OP_CONFIG_QUEUE_BW = 112, 2038923de59SPiotr Kubaj VIRTCHNL_OP_CONFIG_QUANTA = 113, 2049dc2f6e2SEric Joyner VIRTCHNL_OP_FLOW_SUBSCRIBE = 114, 2059dc2f6e2SEric Joyner VIRTCHNL_OP_FLOW_UNSUBSCRIBE = 115, 2069c30461dSEric Joyner /* opcode 116 through 130 are reserved */ 2077d7af7f8SEric Joyner VIRTCHNL_OP_MAX, 20871d10453SEric Joyner }; 20971d10453SEric Joyner 210d08b8680SEric Joyner static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode) 211d08b8680SEric Joyner { 212d08b8680SEric Joyner switch (v_opcode) { 213d08b8680SEric Joyner case VIRTCHNL_OP_UNKNOWN: 214d08b8680SEric Joyner return "VIRTCHNL_OP_UNKNOWN"; 215d08b8680SEric Joyner case VIRTCHNL_OP_VERSION: 216d08b8680SEric Joyner return "VIRTCHNL_OP_VERSION"; 217d08b8680SEric Joyner case VIRTCHNL_OP_RESET_VF: 218d08b8680SEric Joyner return "VIRTCHNL_OP_RESET_VF"; 219d08b8680SEric Joyner case VIRTCHNL_OP_GET_VF_RESOURCES: 220d08b8680SEric Joyner return "VIRTCHNL_OP_GET_VF_RESOURCES"; 221d08b8680SEric Joyner case VIRTCHNL_OP_CONFIG_TX_QUEUE: 222d08b8680SEric Joyner return "VIRTCHNL_OP_CONFIG_TX_QUEUE"; 223d08b8680SEric Joyner case VIRTCHNL_OP_CONFIG_RX_QUEUE: 224d08b8680SEric Joyner return "VIRTCHNL_OP_CONFIG_RX_QUEUE"; 225d08b8680SEric Joyner case VIRTCHNL_OP_CONFIG_VSI_QUEUES: 226d08b8680SEric Joyner return "VIRTCHNL_OP_CONFIG_VSI_QUEUES"; 227d08b8680SEric Joyner case VIRTCHNL_OP_CONFIG_IRQ_MAP: 228d08b8680SEric Joyner return "VIRTCHNL_OP_CONFIG_IRQ_MAP"; 229d08b8680SEric Joyner case VIRTCHNL_OP_ENABLE_QUEUES: 230d08b8680SEric Joyner return "VIRTCHNL_OP_ENABLE_QUEUES"; 231d08b8680SEric Joyner case VIRTCHNL_OP_DISABLE_QUEUES: 232d08b8680SEric Joyner return "VIRTCHNL_OP_DISABLE_QUEUES"; 233d08b8680SEric Joyner case VIRTCHNL_OP_ADD_ETH_ADDR: 234d08b8680SEric Joyner return "VIRTCHNL_OP_ADD_ETH_ADDR"; 235d08b8680SEric Joyner case VIRTCHNL_OP_DEL_ETH_ADDR: 236d08b8680SEric Joyner return "VIRTCHNL_OP_DEL_ETH_ADDR"; 237d08b8680SEric Joyner case VIRTCHNL_OP_ADD_VLAN: 238d08b8680SEric Joyner return "VIRTCHNL_OP_ADD_VLAN"; 239d08b8680SEric Joyner case VIRTCHNL_OP_DEL_VLAN: 240d08b8680SEric Joyner return "VIRTCHNL_OP_DEL_VLAN"; 241d08b8680SEric Joyner case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE: 242d08b8680SEric Joyner return "VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE"; 243d08b8680SEric Joyner case VIRTCHNL_OP_GET_STATS: 244d08b8680SEric Joyner return "VIRTCHNL_OP_GET_STATS"; 245d08b8680SEric Joyner case VIRTCHNL_OP_RSVD: 246d08b8680SEric Joyner return "VIRTCHNL_OP_RSVD"; 247d08b8680SEric Joyner case VIRTCHNL_OP_EVENT: 248d08b8680SEric Joyner return "VIRTCHNL_OP_EVENT"; 249d08b8680SEric Joyner case VIRTCHNL_OP_CONFIG_RSS_KEY: 250d08b8680SEric Joyner return "VIRTCHNL_OP_CONFIG_RSS_KEY"; 251d08b8680SEric Joyner case VIRTCHNL_OP_CONFIG_RSS_LUT: 252d08b8680SEric Joyner return "VIRTCHNL_OP_CONFIG_RSS_LUT"; 253d08b8680SEric Joyner case VIRTCHNL_OP_GET_RSS_HENA_CAPS: 254d08b8680SEric Joyner return "VIRTCHNL_OP_GET_RSS_HENA_CAPS"; 255d08b8680SEric Joyner case VIRTCHNL_OP_SET_RSS_HENA: 256d08b8680SEric Joyner return "VIRTCHNL_OP_SET_RSS_HENA"; 257d08b8680SEric Joyner case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING: 258d08b8680SEric Joyner return "VIRTCHNL_OP_ENABLE_VLAN_STRIPPING"; 259d08b8680SEric Joyner case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING: 260d08b8680SEric Joyner return "VIRTCHNL_OP_DISABLE_VLAN_STRIPPING"; 261d08b8680SEric Joyner case VIRTCHNL_OP_REQUEST_QUEUES: 262d08b8680SEric Joyner return "VIRTCHNL_OP_REQUEST_QUEUES"; 263d08b8680SEric Joyner case VIRTCHNL_OP_ENABLE_CHANNELS: 264d08b8680SEric Joyner return "VIRTCHNL_OP_ENABLE_CHANNELS"; 265d08b8680SEric Joyner case VIRTCHNL_OP_DISABLE_CHANNELS: 266d08b8680SEric Joyner return "VIRTCHNL_OP_DISABLE_CHANNELS"; 267d08b8680SEric Joyner case VIRTCHNL_OP_ADD_CLOUD_FILTER: 268d08b8680SEric Joyner return "VIRTCHNL_OP_ADD_CLOUD_FILTER"; 269d08b8680SEric Joyner case VIRTCHNL_OP_DEL_CLOUD_FILTER: 270d08b8680SEric Joyner return "VIRTCHNL_OP_DEL_CLOUD_FILTER"; 27156429daeSEric Joyner case VIRTCHNL_OP_ADD_RSS_CFG: 27256429daeSEric Joyner return "VIRTCHNL_OP_ADD_RSS_CFG"; 27356429daeSEric Joyner case VIRTCHNL_OP_DEL_RSS_CFG: 27456429daeSEric Joyner return "VIRTCHNL_OP_DEL_RSS_CFG"; 27556429daeSEric Joyner case VIRTCHNL_OP_ADD_FDIR_FILTER: 27656429daeSEric Joyner return "VIRTCHNL_OP_ADD_FDIR_FILTER"; 27756429daeSEric Joyner case VIRTCHNL_OP_DEL_FDIR_FILTER: 27856429daeSEric Joyner return "VIRTCHNL_OP_DEL_FDIR_FILTER"; 279d08b8680SEric Joyner case VIRTCHNL_OP_GET_MAX_RSS_QREGION: 280d08b8680SEric Joyner return "VIRTCHNL_OP_GET_MAX_RSS_QREGION"; 2819cf1841cSEric Joyner case VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS: 2829cf1841cSEric Joyner return "VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS"; 2839cf1841cSEric Joyner case VIRTCHNL_OP_ADD_VLAN_V2: 2849cf1841cSEric Joyner return "VIRTCHNL_OP_ADD_VLAN_V2"; 2859cf1841cSEric Joyner case VIRTCHNL_OP_DEL_VLAN_V2: 2869cf1841cSEric Joyner return "VIRTCHNL_OP_DEL_VLAN_V2"; 2879cf1841cSEric Joyner case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2: 2889cf1841cSEric Joyner return "VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2"; 2899cf1841cSEric Joyner case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2: 2909cf1841cSEric Joyner return "VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2"; 2919cf1841cSEric Joyner case VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2: 2929cf1841cSEric Joyner return "VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2"; 2939cf1841cSEric Joyner case VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2: 2949cf1841cSEric Joyner return "VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2"; 2959cf1841cSEric Joyner case VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2: 2969cf1841cSEric Joyner return "VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2"; 2979cf1841cSEric Joyner case VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2: 2989cf1841cSEric Joyner return "VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2"; 2998923de59SPiotr Kubaj case VIRTCHNL_OP_ENABLE_QUEUES_V2: 3008923de59SPiotr Kubaj return "VIRTCHNL_OP_ENABLE_QUEUES_V2"; 3018923de59SPiotr Kubaj case VIRTCHNL_OP_DISABLE_QUEUES_V2: 3028923de59SPiotr Kubaj return "VIRTCHNL_OP_DISABLE_QUEUES_V2"; 3038923de59SPiotr Kubaj case VIRTCHNL_OP_MAP_QUEUE_VECTOR: 3048923de59SPiotr Kubaj return "VIRTCHNL_OP_MAP_QUEUE_VECTOR"; 3059dc2f6e2SEric Joyner case VIRTCHNL_OP_FLOW_SUBSCRIBE: 3069dc2f6e2SEric Joyner return "VIRTCHNL_OP_FLOW_SUBSCRIBE"; 3079dc2f6e2SEric Joyner case VIRTCHNL_OP_FLOW_UNSUBSCRIBE: 3089dc2f6e2SEric Joyner return "VIRTCHNL_OP_FLOW_UNSUBSCRIBE"; 309d08b8680SEric Joyner case VIRTCHNL_OP_MAX: 310d08b8680SEric Joyner return "VIRTCHNL_OP_MAX"; 311d08b8680SEric Joyner default: 312d08b8680SEric Joyner return "Unsupported (update virtchnl.h)"; 313d08b8680SEric Joyner } 314d08b8680SEric Joyner } 315d08b8680SEric Joyner 31656429daeSEric Joyner static inline const char *virtchnl_stat_str(enum virtchnl_status_code v_status) 31756429daeSEric Joyner { 31856429daeSEric Joyner switch (v_status) { 31956429daeSEric Joyner case VIRTCHNL_STATUS_SUCCESS: 32056429daeSEric Joyner return "VIRTCHNL_STATUS_SUCCESS"; 32156429daeSEric Joyner case VIRTCHNL_STATUS_ERR_PARAM: 32256429daeSEric Joyner return "VIRTCHNL_STATUS_ERR_PARAM"; 32356429daeSEric Joyner case VIRTCHNL_STATUS_ERR_NO_MEMORY: 32456429daeSEric Joyner return "VIRTCHNL_STATUS_ERR_NO_MEMORY"; 32556429daeSEric Joyner case VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH: 32656429daeSEric Joyner return "VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH"; 32756429daeSEric Joyner case VIRTCHNL_STATUS_ERR_CQP_COMPL_ERROR: 32856429daeSEric Joyner return "VIRTCHNL_STATUS_ERR_CQP_COMPL_ERROR"; 32956429daeSEric Joyner case VIRTCHNL_STATUS_ERR_INVALID_VF_ID: 33056429daeSEric Joyner return "VIRTCHNL_STATUS_ERR_INVALID_VF_ID"; 33156429daeSEric Joyner case VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR: 33256429daeSEric Joyner return "VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR"; 33356429daeSEric Joyner case VIRTCHNL_STATUS_ERR_NOT_SUPPORTED: 33456429daeSEric Joyner return "VIRTCHNL_STATUS_ERR_NOT_SUPPORTED"; 33556429daeSEric Joyner default: 33656429daeSEric Joyner return "Unknown status code (update virtchnl.h)"; 33756429daeSEric Joyner } 33856429daeSEric Joyner } 33971d10453SEric Joyner 34071d10453SEric Joyner /* Virtual channel message descriptor. This overlays the admin queue 34171d10453SEric Joyner * descriptor. All other data is passed in external buffers. 34271d10453SEric Joyner */ 34371d10453SEric Joyner 34471d10453SEric Joyner struct virtchnl_msg { 34571d10453SEric Joyner u8 pad[8]; /* AQ flags/opcode/len/retval fields */ 3469cf1841cSEric Joyner 3479cf1841cSEric Joyner /* avoid confusion with desc->opcode */ 3489cf1841cSEric Joyner enum virtchnl_ops v_opcode; 3499cf1841cSEric Joyner 3509cf1841cSEric Joyner /* ditto for desc->retval */ 3519cf1841cSEric Joyner enum virtchnl_status_code v_retval; 35271d10453SEric Joyner u32 vfid; /* used by PF when sending to VF */ 35371d10453SEric Joyner }; 35471d10453SEric Joyner 35571d10453SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(20, virtchnl_msg); 35671d10453SEric Joyner 35771d10453SEric Joyner /* Message descriptions and data structures. */ 35871d10453SEric Joyner 35971d10453SEric Joyner /* VIRTCHNL_OP_VERSION 36071d10453SEric Joyner * VF posts its version number to the PF. PF responds with its version number 36171d10453SEric Joyner * in the same format, along with a return code. 36271d10453SEric Joyner * Reply from PF has its major/minor versions also in param0 and param1. 36371d10453SEric Joyner * If there is a major version mismatch, then the VF cannot operate. 36471d10453SEric Joyner * If there is a minor version mismatch, then the VF can operate but should 36571d10453SEric Joyner * add a warning to the system log. 36671d10453SEric Joyner * 36771d10453SEric Joyner * This enum element MUST always be specified as == 1, regardless of other 36871d10453SEric Joyner * changes in the API. The PF must always respond to this message without 36971d10453SEric Joyner * error regardless of version mismatch. 37071d10453SEric Joyner */ 37171d10453SEric Joyner #define VIRTCHNL_VERSION_MAJOR 1 37271d10453SEric Joyner #define VIRTCHNL_VERSION_MINOR 1 3739cf1841cSEric Joyner #define VIRTCHNL_VERSION_MAJOR_2 2 3749cf1841cSEric Joyner #define VIRTCHNL_VERSION_MINOR_0 0 37571d10453SEric Joyner #define VIRTCHNL_VERSION_MINOR_NO_VF_CAPS 0 37671d10453SEric Joyner 37771d10453SEric Joyner struct virtchnl_version_info { 37871d10453SEric Joyner u32 major; 37971d10453SEric Joyner u32 minor; 38071d10453SEric Joyner }; 38171d10453SEric Joyner 38271d10453SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_version_info); 38371d10453SEric Joyner 38456429daeSEric Joyner #define VF_IS_V10(_ver) (((_ver)->major == 1) && ((_ver)->minor == 0)) 38571d10453SEric Joyner #define VF_IS_V11(_ver) (((_ver)->major == 1) && ((_ver)->minor == 1)) 38656429daeSEric Joyner #define VF_IS_V20(_ver) (((_ver)->major == 2) && ((_ver)->minor == 0)) 38771d10453SEric Joyner 38871d10453SEric Joyner /* VIRTCHNL_OP_RESET_VF 38971d10453SEric Joyner * VF sends this request to PF with no parameters 39071d10453SEric Joyner * PF does NOT respond! VF driver must delay then poll VFGEN_RSTAT register 39171d10453SEric Joyner * until reset completion is indicated. The admin queue must be reinitialized 39271d10453SEric Joyner * after this operation. 39371d10453SEric Joyner * 39471d10453SEric Joyner * When reset is complete, PF must ensure that all queues in all VSIs associated 39571d10453SEric Joyner * with the VF are stopped, all queue configurations in the HMC are set to 0, 39671d10453SEric Joyner * and all MAC and VLAN filters (except the default MAC address) on all VSIs 39771d10453SEric Joyner * are cleared. 39871d10453SEric Joyner */ 39971d10453SEric Joyner 40071d10453SEric Joyner /* VSI types that use VIRTCHNL interface for VF-PF communication. VSI_SRIOV 40171d10453SEric Joyner * vsi_type should always be 6 for backward compatibility. Add other fields 40271d10453SEric Joyner * as needed. 40371d10453SEric Joyner */ 40471d10453SEric Joyner enum virtchnl_vsi_type { 40571d10453SEric Joyner VIRTCHNL_VSI_TYPE_INVALID = 0, 40671d10453SEric Joyner VIRTCHNL_VSI_SRIOV = 6, 40771d10453SEric Joyner }; 40871d10453SEric Joyner 40971d10453SEric Joyner /* VIRTCHNL_OP_GET_VF_RESOURCES 41071d10453SEric Joyner * Version 1.0 VF sends this request to PF with no parameters 41171d10453SEric Joyner * Version 1.1 VF sends this request to PF with u32 bitmap of its capabilities 41271d10453SEric Joyner * PF responds with an indirect message containing 41371d10453SEric Joyner * virtchnl_vf_resource and one or more 41471d10453SEric Joyner * virtchnl_vsi_resource structures. 41571d10453SEric Joyner */ 41671d10453SEric Joyner 41771d10453SEric Joyner struct virtchnl_vsi_resource { 41871d10453SEric Joyner u16 vsi_id; 41971d10453SEric Joyner u16 num_queue_pairs; 4209cf1841cSEric Joyner 4219cf1841cSEric Joyner /* see enum virtchnl_vsi_type */ 4229cf1841cSEric Joyner s32 vsi_type; 42371d10453SEric Joyner u16 qset_handle; 42471d10453SEric Joyner u8 default_mac_addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS]; 42571d10453SEric Joyner }; 42671d10453SEric Joyner 42771d10453SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource); 42871d10453SEric Joyner 42971d10453SEric Joyner /* VF capability flags 43071d10453SEric Joyner * VIRTCHNL_VF_OFFLOAD_L2 flag is inclusive of base mode L2 offloads including 43171d10453SEric Joyner * TX/RX Checksum offloading and TSO for non-tunnelled packets. 43271d10453SEric Joyner */ 43356429daeSEric Joyner #define VIRTCHNL_VF_OFFLOAD_L2 BIT(0) 43456429daeSEric Joyner #define VIRTCHNL_VF_OFFLOAD_IWARP BIT(1) 43556429daeSEric Joyner #define VIRTCHNL_VF_CAP_RDMA VIRTCHNL_VF_OFFLOAD_IWARP 43656429daeSEric Joyner #define VIRTCHNL_VF_OFFLOAD_RSS_AQ BIT(3) 43756429daeSEric Joyner #define VIRTCHNL_VF_OFFLOAD_RSS_REG BIT(4) 43856429daeSEric Joyner #define VIRTCHNL_VF_OFFLOAD_WB_ON_ITR BIT(5) 43956429daeSEric Joyner #define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES BIT(6) 44056429daeSEric Joyner /* used to negotiate communicating link speeds in Mbps */ 44156429daeSEric Joyner #define VIRTCHNL_VF_CAP_ADV_LINK_SPEED BIT(7) 44256429daeSEric Joyner /* BIT(8) is reserved */ 44356429daeSEric Joyner #define VIRTCHNL_VF_LARGE_NUM_QPAIRS BIT(9) 44456429daeSEric Joyner #define VIRTCHNL_VF_OFFLOAD_CRC BIT(10) 4459dc2f6e2SEric Joyner #define VIRTCHNL_VF_OFFLOAD_FSUB_PF BIT(14) 44656429daeSEric Joyner #define VIRTCHNL_VF_OFFLOAD_VLAN_V2 BIT(15) 44756429daeSEric Joyner #define VIRTCHNL_VF_OFFLOAD_VLAN BIT(16) 44856429daeSEric Joyner #define VIRTCHNL_VF_OFFLOAD_RX_POLLING BIT(17) 44956429daeSEric Joyner #define VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 BIT(18) 45056429daeSEric Joyner #define VIRTCHNL_VF_OFFLOAD_RSS_PF BIT(19) 45156429daeSEric Joyner #define VIRTCHNL_VF_OFFLOAD_ENCAP BIT(20) 45256429daeSEric Joyner #define VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM BIT(21) 45356429daeSEric Joyner #define VIRTCHNL_VF_OFFLOAD_RX_ENCAP_CSUM BIT(22) 45456429daeSEric Joyner #define VIRTCHNL_VF_OFFLOAD_ADQ BIT(23) 45556429daeSEric Joyner #define VIRTCHNL_VF_OFFLOAD_ADQ_V2 BIT(24) 45656429daeSEric Joyner #define VIRTCHNL_VF_OFFLOAD_USO BIT(25) 45756429daeSEric Joyner /* BIT(26) is reserved */ 45856429daeSEric Joyner #define VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF BIT(27) 45956429daeSEric Joyner #define VIRTCHNL_VF_OFFLOAD_FDIR_PF BIT(28) 46056429daeSEric Joyner #define VIRTCHNL_VF_OFFLOAD_QOS BIT(29) 46156429daeSEric Joyner /* BIT(30) is reserved */ 46256429daeSEric Joyner /* BIT(31) is reserved */ 46371d10453SEric Joyner 46471d10453SEric Joyner #define VF_BASE_MODE_OFFLOADS (VIRTCHNL_VF_OFFLOAD_L2 | \ 46571d10453SEric Joyner VIRTCHNL_VF_OFFLOAD_VLAN | \ 46671d10453SEric Joyner VIRTCHNL_VF_OFFLOAD_RSS_PF) 46771d10453SEric Joyner 46871d10453SEric Joyner struct virtchnl_vf_resource { 46971d10453SEric Joyner u16 num_vsis; 47071d10453SEric Joyner u16 num_queue_pairs; 47171d10453SEric Joyner u16 max_vectors; 47271d10453SEric Joyner u16 max_mtu; 47371d10453SEric Joyner 47471d10453SEric Joyner u32 vf_cap_flags; 47571d10453SEric Joyner u32 rss_key_size; 47671d10453SEric Joyner u32 rss_lut_size; 47771d10453SEric Joyner 47871d10453SEric Joyner struct virtchnl_vsi_resource vsi_res[1]; 47971d10453SEric Joyner }; 48071d10453SEric Joyner 48171d10453SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_vf_resource); 48271d10453SEric Joyner 48371d10453SEric Joyner /* VIRTCHNL_OP_CONFIG_TX_QUEUE 48471d10453SEric Joyner * VF sends this message to set up parameters for one TX queue. 48571d10453SEric Joyner * External data buffer contains one instance of virtchnl_txq_info. 48671d10453SEric Joyner * PF configures requested queue and returns a status code. 48771d10453SEric Joyner */ 48871d10453SEric Joyner 48971d10453SEric Joyner /* Tx queue config info */ 49071d10453SEric Joyner struct virtchnl_txq_info { 49171d10453SEric Joyner u16 vsi_id; 49271d10453SEric Joyner u16 queue_id; 49371d10453SEric Joyner u16 ring_len; /* number of descriptors, multiple of 8 */ 49471d10453SEric Joyner u16 headwb_enabled; /* deprecated with AVF 1.0 */ 49571d10453SEric Joyner u64 dma_ring_addr; 49671d10453SEric Joyner u64 dma_headwb_addr; /* deprecated with AVF 1.0 */ 49771d10453SEric Joyner }; 49871d10453SEric Joyner 49971d10453SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_txq_info); 50071d10453SEric Joyner 50156429daeSEric Joyner /* RX descriptor IDs (range from 0 to 63) */ 50256429daeSEric Joyner enum virtchnl_rx_desc_ids { 50356429daeSEric Joyner VIRTCHNL_RXDID_0_16B_BASE = 0, 50456429daeSEric Joyner VIRTCHNL_RXDID_1_32B_BASE = 1, 50556429daeSEric Joyner VIRTCHNL_RXDID_2_FLEX_SQ_NIC = 2, 50656429daeSEric Joyner VIRTCHNL_RXDID_3_FLEX_SQ_SW = 3, 50756429daeSEric Joyner VIRTCHNL_RXDID_4_FLEX_SQ_NIC_VEB = 4, 50856429daeSEric Joyner VIRTCHNL_RXDID_5_FLEX_SQ_NIC_ACL = 5, 50956429daeSEric Joyner VIRTCHNL_RXDID_6_FLEX_SQ_NIC_2 = 6, 51056429daeSEric Joyner VIRTCHNL_RXDID_7_HW_RSVD = 7, 5118923de59SPiotr Kubaj /* 8 through 15 are reserved */ 51256429daeSEric Joyner VIRTCHNL_RXDID_16_COMMS_GENERIC = 16, 51356429daeSEric Joyner VIRTCHNL_RXDID_17_COMMS_AUX_VLAN = 17, 51456429daeSEric Joyner VIRTCHNL_RXDID_18_COMMS_AUX_IPV4 = 18, 51556429daeSEric Joyner VIRTCHNL_RXDID_19_COMMS_AUX_IPV6 = 19, 51656429daeSEric Joyner VIRTCHNL_RXDID_20_COMMS_AUX_FLOW = 20, 51756429daeSEric Joyner VIRTCHNL_RXDID_21_COMMS_AUX_TCP = 21, 51856429daeSEric Joyner /* 22 through 63 are reserved */ 51956429daeSEric Joyner }; 52056429daeSEric Joyner 52156429daeSEric Joyner /* RX descriptor ID bitmasks */ 52256429daeSEric Joyner enum virtchnl_rx_desc_id_bitmasks { 52356429daeSEric Joyner VIRTCHNL_RXDID_0_16B_BASE_M = BIT(VIRTCHNL_RXDID_0_16B_BASE), 52456429daeSEric Joyner VIRTCHNL_RXDID_1_32B_BASE_M = BIT(VIRTCHNL_RXDID_1_32B_BASE), 52556429daeSEric Joyner VIRTCHNL_RXDID_2_FLEX_SQ_NIC_M = BIT(VIRTCHNL_RXDID_2_FLEX_SQ_NIC), 52656429daeSEric Joyner VIRTCHNL_RXDID_3_FLEX_SQ_SW_M = BIT(VIRTCHNL_RXDID_3_FLEX_SQ_SW), 52756429daeSEric Joyner VIRTCHNL_RXDID_4_FLEX_SQ_NIC_VEB_M = BIT(VIRTCHNL_RXDID_4_FLEX_SQ_NIC_VEB), 52856429daeSEric Joyner VIRTCHNL_RXDID_5_FLEX_SQ_NIC_ACL_M = BIT(VIRTCHNL_RXDID_5_FLEX_SQ_NIC_ACL), 52956429daeSEric Joyner VIRTCHNL_RXDID_6_FLEX_SQ_NIC_2_M = BIT(VIRTCHNL_RXDID_6_FLEX_SQ_NIC_2), 53056429daeSEric Joyner VIRTCHNL_RXDID_7_HW_RSVD_M = BIT(VIRTCHNL_RXDID_7_HW_RSVD), 53156429daeSEric Joyner /* 9 through 15 are reserved */ 53256429daeSEric Joyner VIRTCHNL_RXDID_16_COMMS_GENERIC_M = BIT(VIRTCHNL_RXDID_16_COMMS_GENERIC), 53356429daeSEric Joyner VIRTCHNL_RXDID_17_COMMS_AUX_VLAN_M = BIT(VIRTCHNL_RXDID_17_COMMS_AUX_VLAN), 53456429daeSEric Joyner VIRTCHNL_RXDID_18_COMMS_AUX_IPV4_M = BIT(VIRTCHNL_RXDID_18_COMMS_AUX_IPV4), 53556429daeSEric Joyner VIRTCHNL_RXDID_19_COMMS_AUX_IPV6_M = BIT(VIRTCHNL_RXDID_19_COMMS_AUX_IPV6), 53656429daeSEric Joyner VIRTCHNL_RXDID_20_COMMS_AUX_FLOW_M = BIT(VIRTCHNL_RXDID_20_COMMS_AUX_FLOW), 53756429daeSEric Joyner VIRTCHNL_RXDID_21_COMMS_AUX_TCP_M = BIT(VIRTCHNL_RXDID_21_COMMS_AUX_TCP), 53856429daeSEric Joyner /* 22 through 63 are reserved */ 53956429daeSEric Joyner }; 54056429daeSEric Joyner 54171d10453SEric Joyner /* VIRTCHNL_OP_CONFIG_RX_QUEUE 54271d10453SEric Joyner * VF sends this message to set up parameters for one RX queue. 54371d10453SEric Joyner * External data buffer contains one instance of virtchnl_rxq_info. 54471d10453SEric Joyner * PF configures requested queue and returns a status code. The 54571d10453SEric Joyner * crc_disable flag disables CRC stripping on the VF. Setting 54671d10453SEric Joyner * the crc_disable flag to 1 will disable CRC stripping for each 54771d10453SEric Joyner * queue in the VF where the flag is set. The VIRTCHNL_VF_OFFLOAD_CRC 54871d10453SEric Joyner * offload must have been set prior to sending this info or the PF 54971d10453SEric Joyner * will ignore the request. This flag should be set the same for 55071d10453SEric Joyner * all of the queues for a VF. 55171d10453SEric Joyner */ 55271d10453SEric Joyner 55371d10453SEric Joyner /* Rx queue config info */ 55471d10453SEric Joyner struct virtchnl_rxq_info { 55571d10453SEric Joyner u16 vsi_id; 55671d10453SEric Joyner u16 queue_id; 55771d10453SEric Joyner u32 ring_len; /* number of descriptors, multiple of 32 */ 55871d10453SEric Joyner u16 hdr_size; 55971d10453SEric Joyner u16 splithdr_enabled; /* deprecated with AVF 1.0 */ 56071d10453SEric Joyner u32 databuffer_size; 56171d10453SEric Joyner u32 max_pkt_size; 56271d10453SEric Joyner u8 crc_disable; 56371d10453SEric Joyner u8 pad1[3]; 56471d10453SEric Joyner u64 dma_ring_addr; 5659cf1841cSEric Joyner 5669cf1841cSEric Joyner /* see enum virtchnl_rx_hsplit; deprecated with AVF 1.0 */ 5679cf1841cSEric Joyner s32 rx_split_pos; 56871d10453SEric Joyner u32 pad2; 56971d10453SEric Joyner }; 57071d10453SEric Joyner 57171d10453SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_rxq_info); 57271d10453SEric Joyner 57371d10453SEric Joyner /* VIRTCHNL_OP_CONFIG_VSI_QUEUES 57471d10453SEric Joyner * VF sends this message to set parameters for active TX and RX queues 57571d10453SEric Joyner * associated with the specified VSI. 57671d10453SEric Joyner * PF configures queues and returns status. 57771d10453SEric Joyner * If the number of queues specified is greater than the number of queues 57871d10453SEric Joyner * associated with the VSI, an error is returned and no queues are configured. 57971d10453SEric Joyner * NOTE: The VF is not required to configure all queues in a single request. 58071d10453SEric Joyner * It may send multiple messages. PF drivers must correctly handle all VF 58171d10453SEric Joyner * requests. 58271d10453SEric Joyner */ 58371d10453SEric Joyner struct virtchnl_queue_pair_info { 58471d10453SEric Joyner /* NOTE: vsi_id and queue_id should be identical for both queues. */ 58571d10453SEric Joyner struct virtchnl_txq_info txq; 58671d10453SEric Joyner struct virtchnl_rxq_info rxq; 58771d10453SEric Joyner }; 58871d10453SEric Joyner 58971d10453SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(64, virtchnl_queue_pair_info); 59071d10453SEric Joyner 59171d10453SEric Joyner struct virtchnl_vsi_queue_config_info { 59271d10453SEric Joyner u16 vsi_id; 59371d10453SEric Joyner u16 num_queue_pairs; 59471d10453SEric Joyner u32 pad; 59571d10453SEric Joyner struct virtchnl_queue_pair_info qpair[1]; 59671d10453SEric Joyner }; 59771d10453SEric Joyner 59871d10453SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_vsi_queue_config_info); 59971d10453SEric Joyner 60071d10453SEric Joyner /* VIRTCHNL_OP_REQUEST_QUEUES 60171d10453SEric Joyner * VF sends this message to request the PF to allocate additional queues to 60271d10453SEric Joyner * this VF. Each VF gets a guaranteed number of queues on init but asking for 60371d10453SEric Joyner * additional queues must be negotiated. This is a best effort request as it 60471d10453SEric Joyner * is possible the PF does not have enough queues left to support the request. 60571d10453SEric Joyner * If the PF cannot support the number requested it will respond with the 60671d10453SEric Joyner * maximum number it is able to support. If the request is successful, PF will 60771d10453SEric Joyner * then reset the VF to institute required changes. 60871d10453SEric Joyner */ 60971d10453SEric Joyner 61071d10453SEric Joyner /* VF resource request */ 61171d10453SEric Joyner struct virtchnl_vf_res_request { 61271d10453SEric Joyner u16 num_queue_pairs; 61371d10453SEric Joyner }; 61471d10453SEric Joyner 61571d10453SEric Joyner /* VIRTCHNL_OP_CONFIG_IRQ_MAP 61671d10453SEric Joyner * VF uses this message to map vectors to queues. 61771d10453SEric Joyner * The rxq_map and txq_map fields are bitmaps used to indicate which queues 61871d10453SEric Joyner * are to be associated with the specified vector. 61971d10453SEric Joyner * The "other" causes are always mapped to vector 0. The VF may not request 62071d10453SEric Joyner * that vector 0 be used for traffic. 62171d10453SEric Joyner * PF configures interrupt mapping and returns status. 62271d10453SEric Joyner * NOTE: due to hardware requirements, all active queues (both TX and RX) 62371d10453SEric Joyner * should be mapped to interrupts, even if the driver intends to operate 62471d10453SEric Joyner * only in polling mode. In this case the interrupt may be disabled, but 62571d10453SEric Joyner * the ITR timer will still run to trigger writebacks. 62671d10453SEric Joyner */ 62771d10453SEric Joyner struct virtchnl_vector_map { 62871d10453SEric Joyner u16 vsi_id; 62971d10453SEric Joyner u16 vector_id; 63071d10453SEric Joyner u16 rxq_map; 63171d10453SEric Joyner u16 txq_map; 63271d10453SEric Joyner u16 rxitr_idx; 63371d10453SEric Joyner u16 txitr_idx; 63471d10453SEric Joyner }; 63571d10453SEric Joyner 63671d10453SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_vector_map); 63771d10453SEric Joyner 63871d10453SEric Joyner struct virtchnl_irq_map_info { 63971d10453SEric Joyner u16 num_vectors; 64071d10453SEric Joyner struct virtchnl_vector_map vecmap[1]; 64171d10453SEric Joyner }; 64271d10453SEric Joyner 64371d10453SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(14, virtchnl_irq_map_info); 64471d10453SEric Joyner 64571d10453SEric Joyner /* VIRTCHNL_OP_ENABLE_QUEUES 64671d10453SEric Joyner * VIRTCHNL_OP_DISABLE_QUEUES 64771d10453SEric Joyner * VF sends these message to enable or disable TX/RX queue pairs. 64871d10453SEric Joyner * The queues fields are bitmaps indicating which queues to act upon. 64971d10453SEric Joyner * (Currently, we only support 16 queues per VF, but we make the field 65071d10453SEric Joyner * u32 to allow for expansion.) 65171d10453SEric Joyner * PF performs requested action and returns status. 65271d10453SEric Joyner * NOTE: The VF is not required to enable/disable all queues in a single 65371d10453SEric Joyner * request. It may send multiple messages. 65471d10453SEric Joyner * PF drivers must correctly handle all VF requests. 65571d10453SEric Joyner */ 65671d10453SEric Joyner struct virtchnl_queue_select { 65771d10453SEric Joyner u16 vsi_id; 65871d10453SEric Joyner u16 pad; 65971d10453SEric Joyner u32 rx_queues; 66071d10453SEric Joyner u32 tx_queues; 66171d10453SEric Joyner }; 66271d10453SEric Joyner 66371d10453SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_select); 66471d10453SEric Joyner 665d08b8680SEric Joyner /* VIRTCHNL_OP_GET_MAX_RSS_QREGION 666d08b8680SEric Joyner * 667d08b8680SEric Joyner * if VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES 668d08b8680SEric Joyner * then this op must be supported. 669d08b8680SEric Joyner * 670d08b8680SEric Joyner * VF sends this message in order to query the max RSS queue region 671d08b8680SEric Joyner * size supported by PF, when VIRTCHNL_VF_LARGE_NUM_QPAIRS is enabled. 672d08b8680SEric Joyner * This information should be used when configuring the RSS LUT and/or 673d08b8680SEric Joyner * configuring queue region based filters. 674d08b8680SEric Joyner * 675d08b8680SEric Joyner * The maximum RSS queue region is 2^qregion_width. So, a qregion_width 676d08b8680SEric Joyner * of 6 would inform the VF that the PF supports a maximum RSS queue region 677d08b8680SEric Joyner * of 64. 678d08b8680SEric Joyner * 679d08b8680SEric Joyner * A queue region represents a range of queues that can be used to configure 680d08b8680SEric Joyner * a RSS LUT. For example, if a VF is given 64 queues, but only a max queue 681d08b8680SEric Joyner * region size of 16 (i.e. 2^qregion_width = 16) then it will only be able 682d08b8680SEric Joyner * to configure the RSS LUT with queue indices from 0 to 15. However, other 683d08b8680SEric Joyner * filters can be used to direct packets to queues >15 via specifying a queue 684d08b8680SEric Joyner * base/offset and queue region width. 685d08b8680SEric Joyner */ 686d08b8680SEric Joyner struct virtchnl_max_rss_qregion { 687d08b8680SEric Joyner u16 vport_id; 688d08b8680SEric Joyner u16 qregion_width; 689d08b8680SEric Joyner u8 pad[4]; 690d08b8680SEric Joyner }; 691d08b8680SEric Joyner 692d08b8680SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_max_rss_qregion); 693d08b8680SEric Joyner 69471d10453SEric Joyner /* VIRTCHNL_OP_ADD_ETH_ADDR 69571d10453SEric Joyner * VF sends this message in order to add one or more unicast or multicast 69671d10453SEric Joyner * address filters for the specified VSI. 69771d10453SEric Joyner * PF adds the filters and returns status. 69871d10453SEric Joyner */ 69971d10453SEric Joyner 70071d10453SEric Joyner /* VIRTCHNL_OP_DEL_ETH_ADDR 70171d10453SEric Joyner * VF sends this message in order to remove one or more unicast or multicast 70271d10453SEric Joyner * filters for the specified VSI. 70371d10453SEric Joyner * PF removes the filters and returns status. 70471d10453SEric Joyner */ 70571d10453SEric Joyner 7067d7af7f8SEric Joyner /* VIRTCHNL_ETHER_ADDR_LEGACY 7077d7af7f8SEric Joyner * Prior to adding the @type member to virtchnl_ether_addr, there were 2 pad 7087d7af7f8SEric Joyner * bytes. Moving forward all VF drivers should not set type to 7097d7af7f8SEric Joyner * VIRTCHNL_ETHER_ADDR_LEGACY. This is only here to not break previous/legacy 7107d7af7f8SEric Joyner * behavior. The control plane function (i.e. PF) can use a best effort method 7117d7af7f8SEric Joyner * of tracking the primary/device unicast in this case, but there is no 7127d7af7f8SEric Joyner * guarantee and functionality depends on the implementation of the PF. 7137d7af7f8SEric Joyner */ 7147d7af7f8SEric Joyner 7157d7af7f8SEric Joyner /* VIRTCHNL_ETHER_ADDR_PRIMARY 7167d7af7f8SEric Joyner * All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_PRIMARY for the 7177d7af7f8SEric Joyner * primary/device unicast MAC address filter for VIRTCHNL_OP_ADD_ETH_ADDR and 7187d7af7f8SEric Joyner * VIRTCHNL_OP_DEL_ETH_ADDR. This allows for the underlying control plane 7197d7af7f8SEric Joyner * function (i.e. PF) to accurately track and use this MAC address for 7207d7af7f8SEric Joyner * displaying on the host and for VM/function reset. 7217d7af7f8SEric Joyner */ 7227d7af7f8SEric Joyner 7237d7af7f8SEric Joyner /* VIRTCHNL_ETHER_ADDR_EXTRA 7247d7af7f8SEric Joyner * All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_EXTRA for any extra 7257d7af7f8SEric Joyner * unicast and/or multicast filters that are being added/deleted via 7267d7af7f8SEric Joyner * VIRTCHNL_OP_DEL_ETH_ADDR/VIRTCHNL_OP_ADD_ETH_ADDR respectively. 7277d7af7f8SEric Joyner */ 72871d10453SEric Joyner struct virtchnl_ether_addr { 72971d10453SEric Joyner u8 addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS]; 7307d7af7f8SEric Joyner u8 type; 7317d7af7f8SEric Joyner #define VIRTCHNL_ETHER_ADDR_LEGACY 0 7327d7af7f8SEric Joyner #define VIRTCHNL_ETHER_ADDR_PRIMARY 1 7337d7af7f8SEric Joyner #define VIRTCHNL_ETHER_ADDR_EXTRA 2 7347d7af7f8SEric Joyner #define VIRTCHNL_ETHER_ADDR_TYPE_MASK 3 /* first two bits of type are valid */ 7357d7af7f8SEric Joyner u8 pad; 73671d10453SEric Joyner }; 73771d10453SEric Joyner 73871d10453SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_ether_addr); 73971d10453SEric Joyner 74071d10453SEric Joyner struct virtchnl_ether_addr_list { 74171d10453SEric Joyner u16 vsi_id; 74271d10453SEric Joyner u16 num_elements; 74371d10453SEric Joyner struct virtchnl_ether_addr list[1]; 74471d10453SEric Joyner }; 74571d10453SEric Joyner 74671d10453SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_ether_addr_list); 74771d10453SEric Joyner 74871d10453SEric Joyner /* VIRTCHNL_OP_ADD_VLAN 74971d10453SEric Joyner * VF sends this message to add one or more VLAN tag filters for receives. 75071d10453SEric Joyner * PF adds the filters and returns status. 75171d10453SEric Joyner * If a port VLAN is configured by the PF, this operation will return an 75271d10453SEric Joyner * error to the VF. 75371d10453SEric Joyner */ 75471d10453SEric Joyner 75571d10453SEric Joyner /* VIRTCHNL_OP_DEL_VLAN 75671d10453SEric Joyner * VF sends this message to remove one or more VLAN tag filters for receives. 75771d10453SEric Joyner * PF removes the filters and returns status. 75871d10453SEric Joyner * If a port VLAN is configured by the PF, this operation will return an 75971d10453SEric Joyner * error to the VF. 76071d10453SEric Joyner */ 76171d10453SEric Joyner 76271d10453SEric Joyner struct virtchnl_vlan_filter_list { 76371d10453SEric Joyner u16 vsi_id; 76471d10453SEric Joyner u16 num_elements; 76571d10453SEric Joyner u16 vlan_id[1]; 76671d10453SEric Joyner }; 76771d10453SEric Joyner 76871d10453SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_vlan_filter_list); 76971d10453SEric Joyner 7709cf1841cSEric Joyner /* This enum is used for all of the VIRTCHNL_VF_OFFLOAD_VLAN_V2_CAPS related 7719cf1841cSEric Joyner * structures and opcodes. 7729cf1841cSEric Joyner * 7739cf1841cSEric Joyner * VIRTCHNL_VLAN_UNSUPPORTED - This field is not supported and if a VF driver 7749cf1841cSEric Joyner * populates it the PF should return VIRTCHNL_STATUS_ERR_NOT_SUPPORTED. 7759cf1841cSEric Joyner * 7769cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_8100 - This field supports 0x8100 ethertype. 7779cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_88A8 - This field supports 0x88A8 ethertype. 7789cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_9100 - This field supports 0x9100 ethertype. 7799cf1841cSEric Joyner * 7809cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_AND - Used when multiple ethertypes can be supported 7819cf1841cSEric Joyner * by the PF concurrently. For example, if the PF can support 7829cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_8100 AND VIRTCHNL_VLAN_ETHERTYPE_88A8 filters it 7839cf1841cSEric Joyner * would OR the following bits: 7849cf1841cSEric Joyner * 7859cf1841cSEric Joyner * VIRTHCNL_VLAN_ETHERTYPE_8100 | 7869cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_88A8 | 7879cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_AND; 7889cf1841cSEric Joyner * 7899cf1841cSEric Joyner * The VF would interpret this as VLAN filtering can be supported on both 0x8100 7909cf1841cSEric Joyner * and 0x88A8 VLAN ethertypes. 7919cf1841cSEric Joyner * 7929cf1841cSEric Joyner * VIRTCHNL_ETHERTYPE_XOR - Used when only a single ethertype can be supported 7939cf1841cSEric Joyner * by the PF concurrently. For example if the PF can support 7949cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_8100 XOR VIRTCHNL_VLAN_ETHERTYPE_88A8 stripping 7959cf1841cSEric Joyner * offload it would OR the following bits: 7969cf1841cSEric Joyner * 7979cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_8100 | 7989cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_88A8 | 7999cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_XOR; 8009cf1841cSEric Joyner * 8019cf1841cSEric Joyner * The VF would interpret this as VLAN stripping can be supported on either 8029cf1841cSEric Joyner * 0x8100 or 0x88a8 VLAN ethertypes. So when requesting VLAN stripping via 8039cf1841cSEric Joyner * VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 the specified ethertype will override 8049cf1841cSEric Joyner * the previously set value. 8059cf1841cSEric Joyner * 8069cf1841cSEric Joyner * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1 - Used to tell the VF to insert and/or 8079cf1841cSEric Joyner * strip the VLAN tag using the L2TAG1 field of the Tx/Rx descriptors. 8089cf1841cSEric Joyner * 8099cf1841cSEric Joyner * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 - Used to tell the VF to insert hardware 8109cf1841cSEric Joyner * offloaded VLAN tags using the L2TAG2 field of the Tx descriptor. 8119cf1841cSEric Joyner * 8129cf1841cSEric Joyner * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 - Used to tell the VF to strip hardware 8139cf1841cSEric Joyner * offloaded VLAN tags using the L2TAG2_2 field of the Rx descriptor. 8149cf1841cSEric Joyner * 8159cf1841cSEric Joyner * VIRTCHNL_VLAN_PRIO - This field supports VLAN priority bits. This is used for 8169cf1841cSEric Joyner * VLAN filtering if the underlying PF supports it. 8179cf1841cSEric Joyner * 8189cf1841cSEric Joyner * VIRTCHNL_VLAN_TOGGLE_ALLOWED - This field is used to say whether a 8199cf1841cSEric Joyner * certain VLAN capability can be toggled. For example if the underlying PF/CP 8209cf1841cSEric Joyner * allows the VF to toggle VLAN filtering, stripping, and/or insertion it should 8219cf1841cSEric Joyner * set this bit along with the supported ethertypes. 8229cf1841cSEric Joyner */ 8239cf1841cSEric Joyner enum virtchnl_vlan_support { 8249cf1841cSEric Joyner VIRTCHNL_VLAN_UNSUPPORTED = 0, 8259cf1841cSEric Joyner VIRTCHNL_VLAN_ETHERTYPE_8100 = 0x00000001, 8269cf1841cSEric Joyner VIRTCHNL_VLAN_ETHERTYPE_88A8 = 0x00000002, 8279cf1841cSEric Joyner VIRTCHNL_VLAN_ETHERTYPE_9100 = 0x00000004, 8289cf1841cSEric Joyner VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1 = 0x00000100, 8299cf1841cSEric Joyner VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 = 0x00000200, 8309cf1841cSEric Joyner VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2_2 = 0x00000400, 8319cf1841cSEric Joyner VIRTCHNL_VLAN_PRIO = 0x01000000, 8329cf1841cSEric Joyner VIRTCHNL_VLAN_FILTER_MASK = 0x10000000, 8339cf1841cSEric Joyner VIRTCHNL_VLAN_ETHERTYPE_AND = 0x20000000, 8349cf1841cSEric Joyner VIRTCHNL_VLAN_ETHERTYPE_XOR = 0x40000000, 8359cf1841cSEric Joyner VIRTCHNL_VLAN_TOGGLE = 0x80000000 8369cf1841cSEric Joyner }; 8379cf1841cSEric Joyner 8389cf1841cSEric Joyner /* This structure is used as part of the VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS 8399cf1841cSEric Joyner * for filtering, insertion, and stripping capabilities. 8409cf1841cSEric Joyner * 8419cf1841cSEric Joyner * If only outer capabilities are supported (for filtering, insertion, and/or 8429cf1841cSEric Joyner * stripping) then this refers to the outer most or single VLAN from the VF's 8439cf1841cSEric Joyner * perspective. 8449cf1841cSEric Joyner * 8459cf1841cSEric Joyner * If only inner capabilities are supported (for filtering, insertion, and/or 8469cf1841cSEric Joyner * stripping) then this refers to the outer most or single VLAN from the VF's 8479cf1841cSEric Joyner * perspective. Functionally this is the same as if only outer capabilities are 8489cf1841cSEric Joyner * supported. The VF driver is just forced to use the inner fields when 8499cf1841cSEric Joyner * adding/deleting filters and enabling/disabling offloads (if supported). 8509cf1841cSEric Joyner * 8519cf1841cSEric Joyner * If both outer and inner capabilities are supported (for filtering, insertion, 8529cf1841cSEric Joyner * and/or stripping) then outer refers to the outer most or single VLAN and 8539cf1841cSEric Joyner * inner refers to the second VLAN, if it exists, in the packet. 8549cf1841cSEric Joyner * 8559cf1841cSEric Joyner * There is no support for tunneled VLAN offloads, so outer or inner are never 8569cf1841cSEric Joyner * referring to a tunneled packet from the VF's perspective. 8579cf1841cSEric Joyner */ 8589cf1841cSEric Joyner struct virtchnl_vlan_supported_caps { 8599cf1841cSEric Joyner u32 outer; 8609cf1841cSEric Joyner u32 inner; 8619cf1841cSEric Joyner }; 8629cf1841cSEric Joyner 8639cf1841cSEric Joyner /* The PF populates these fields based on the supported VLAN filtering. If a 8649cf1841cSEric Joyner * field is VIRTCHNL_VLAN_UNSUPPORTED then it's not supported and the PF will 8659cf1841cSEric Joyner * reject any VIRTCHNL_OP_ADD_VLAN_V2 or VIRTCHNL_OP_DEL_VLAN_V2 messages using 8669cf1841cSEric Joyner * the unsupported fields. 8679cf1841cSEric Joyner * 8689cf1841cSEric Joyner * Also, a VF is only allowed to toggle its VLAN filtering setting if the 8699cf1841cSEric Joyner * VIRTCHNL_VLAN_TOGGLE bit is set. 8709cf1841cSEric Joyner * 8719cf1841cSEric Joyner * The ethertype(s) specified in the ethertype_init field are the ethertypes 8729cf1841cSEric Joyner * enabled for VLAN filtering. VLAN filtering in this case refers to the outer 8739cf1841cSEric Joyner * most VLAN from the VF's perspective. If both inner and outer filtering are 8749cf1841cSEric Joyner * allowed then ethertype_init only refers to the outer most VLAN as only 8759cf1841cSEric Joyner * VLAN ethertype supported for inner VLAN filtering is 8769cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_8100. By default, inner VLAN filtering is disabled 8779cf1841cSEric Joyner * when both inner and outer filtering are allowed. 8789cf1841cSEric Joyner * 8799cf1841cSEric Joyner * The max_filters field tells the VF how many VLAN filters it's allowed to have 8809cf1841cSEric Joyner * at any one time. If it exceeds this amount and tries to add another filter, 8819cf1841cSEric Joyner * then the request will be rejected by the PF. To prevent failures, the VF 8829cf1841cSEric Joyner * should keep track of how many VLAN filters it has added and not attempt to 8839cf1841cSEric Joyner * add more than max_filters. 8849cf1841cSEric Joyner */ 8859cf1841cSEric Joyner struct virtchnl_vlan_filtering_caps { 8869cf1841cSEric Joyner struct virtchnl_vlan_supported_caps filtering_support; 8879cf1841cSEric Joyner u32 ethertype_init; 8889cf1841cSEric Joyner u16 max_filters; 8899cf1841cSEric Joyner u8 pad[2]; 8909cf1841cSEric Joyner }; 8919cf1841cSEric Joyner 8929cf1841cSEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vlan_filtering_caps); 8939cf1841cSEric Joyner 8949cf1841cSEric Joyner /* This enum is used for the virtchnl_vlan_offload_caps structure to specify 8959cf1841cSEric Joyner * if the PF supports a different ethertype for stripping and insertion. 8969cf1841cSEric Joyner * 8979cf1841cSEric Joyner * VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION - The ethertype(s) specified 8989cf1841cSEric Joyner * for stripping affect the ethertype(s) specified for insertion and visa versa 8999cf1841cSEric Joyner * as well. If the VF tries to configure VLAN stripping via 9009cf1841cSEric Joyner * VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 with VIRTCHNL_VLAN_ETHERTYPE_8100 then 9019cf1841cSEric Joyner * that will be the ethertype for both stripping and insertion. 9029cf1841cSEric Joyner * 9039cf1841cSEric Joyner * VIRTCHNL_ETHERTYPE_MATCH_NOT_REQUIRED - The ethertype(s) specified for 9049cf1841cSEric Joyner * stripping do not affect the ethertype(s) specified for insertion and visa 9059cf1841cSEric Joyner * versa. 9069cf1841cSEric Joyner */ 9079cf1841cSEric Joyner enum virtchnl_vlan_ethertype_match { 9089cf1841cSEric Joyner VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION = 0, 9099cf1841cSEric Joyner VIRTCHNL_ETHERTYPE_MATCH_NOT_REQUIRED = 1, 9109cf1841cSEric Joyner }; 9119cf1841cSEric Joyner 9129cf1841cSEric Joyner /* The PF populates these fields based on the supported VLAN offloads. If a 9139cf1841cSEric Joyner * field is VIRTCHNL_VLAN_UNSUPPORTED then it's not supported and the PF will 9149cf1841cSEric Joyner * reject any VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 or 9159cf1841cSEric Joyner * VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 messages using the unsupported fields. 9169cf1841cSEric Joyner * 9179cf1841cSEric Joyner * Also, a VF is only allowed to toggle its VLAN offload setting if the 9189cf1841cSEric Joyner * VIRTCHNL_VLAN_TOGGLE_ALLOWED bit is set. 9199cf1841cSEric Joyner * 9209cf1841cSEric Joyner * The VF driver needs to be aware of how the tags are stripped by hardware and 9219cf1841cSEric Joyner * inserted by the VF driver based on the level of offload support. The PF will 9229cf1841cSEric Joyner * populate these fields based on where the VLAN tags are expected to be 9239cf1841cSEric Joyner * offloaded via the VIRTHCNL_VLAN_TAG_LOCATION_* bits. The VF will need to 9249cf1841cSEric Joyner * interpret these fields. See the definition of the 9259cf1841cSEric Joyner * VIRTCHNL_VLAN_TAG_LOCATION_* bits above the virtchnl_vlan_support 9269cf1841cSEric Joyner * enumeration. 9279cf1841cSEric Joyner */ 9289cf1841cSEric Joyner struct virtchnl_vlan_offload_caps { 9299cf1841cSEric Joyner struct virtchnl_vlan_supported_caps stripping_support; 9309cf1841cSEric Joyner struct virtchnl_vlan_supported_caps insertion_support; 9319cf1841cSEric Joyner u32 ethertype_init; 9329cf1841cSEric Joyner u8 ethertype_match; 9339cf1841cSEric Joyner u8 pad[3]; 9349cf1841cSEric Joyner }; 9359cf1841cSEric Joyner 9369cf1841cSEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_vlan_offload_caps); 9379cf1841cSEric Joyner 9389cf1841cSEric Joyner /* VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS 9399cf1841cSEric Joyner * VF sends this message to determine its VLAN capabilities. 9409cf1841cSEric Joyner * 9419cf1841cSEric Joyner * PF will mark which capabilities it supports based on hardware support and 9429cf1841cSEric Joyner * current configuration. For example, if a port VLAN is configured the PF will 9439cf1841cSEric Joyner * not allow outer VLAN filtering, stripping, or insertion to be configured so 9449cf1841cSEric Joyner * it will block these features from the VF. 9459cf1841cSEric Joyner * 9469cf1841cSEric Joyner * The VF will need to cross reference its capabilities with the PFs 9479cf1841cSEric Joyner * capabilities in the response message from the PF to determine the VLAN 9489cf1841cSEric Joyner * support. 9499cf1841cSEric Joyner */ 9509cf1841cSEric Joyner struct virtchnl_vlan_caps { 9519cf1841cSEric Joyner struct virtchnl_vlan_filtering_caps filtering; 9529cf1841cSEric Joyner struct virtchnl_vlan_offload_caps offloads; 9539cf1841cSEric Joyner }; 9549cf1841cSEric Joyner 9559cf1841cSEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_vlan_caps); 9569cf1841cSEric Joyner 9579cf1841cSEric Joyner struct virtchnl_vlan { 9589cf1841cSEric Joyner u16 tci; /* tci[15:13] = PCP and tci[11:0] = VID */ 9599cf1841cSEric Joyner u16 tci_mask; /* only valid if VIRTCHNL_VLAN_FILTER_MASK set in 9609cf1841cSEric Joyner * filtering caps 9619cf1841cSEric Joyner */ 9629cf1841cSEric Joyner u16 tpid; /* 0x8100, 0x88a8, etc. and only type(s) set in 9639cf1841cSEric Joyner * filtering caps. Note that tpid here does not refer to 9649cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_*, but it refers to the 9659cf1841cSEric Joyner * actual 2-byte VLAN TPID 9669cf1841cSEric Joyner */ 9679cf1841cSEric Joyner u8 pad[2]; 9689cf1841cSEric Joyner }; 9699cf1841cSEric Joyner 9709cf1841cSEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_vlan); 9719cf1841cSEric Joyner 9729cf1841cSEric Joyner struct virtchnl_vlan_filter { 9739cf1841cSEric Joyner struct virtchnl_vlan inner; 9749cf1841cSEric Joyner struct virtchnl_vlan outer; 9759cf1841cSEric Joyner u8 pad[16]; 9769cf1841cSEric Joyner }; 9779cf1841cSEric Joyner 9789cf1841cSEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(32, virtchnl_vlan_filter); 9799cf1841cSEric Joyner 9809cf1841cSEric Joyner /* VIRTCHNL_OP_ADD_VLAN_V2 9819cf1841cSEric Joyner * VIRTCHNL_OP_DEL_VLAN_V2 9829cf1841cSEric Joyner * 9839cf1841cSEric Joyner * VF sends these messages to add/del one or more VLAN tag filters for Rx 9849cf1841cSEric Joyner * traffic. 9859cf1841cSEric Joyner * 9869cf1841cSEric Joyner * The PF attempts to add the filters and returns status. 9879cf1841cSEric Joyner * 9889cf1841cSEric Joyner * The VF should only ever attempt to add/del virtchnl_vlan_filter(s) using the 9899cf1841cSEric Joyner * supported fields negotiated via VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS. 9909cf1841cSEric Joyner */ 9919cf1841cSEric Joyner struct virtchnl_vlan_filter_list_v2 { 9929cf1841cSEric Joyner u16 vport_id; 9939cf1841cSEric Joyner u16 num_elements; 9949cf1841cSEric Joyner u8 pad[4]; 9959cf1841cSEric Joyner struct virtchnl_vlan_filter filters[1]; 9969cf1841cSEric Joyner }; 9979cf1841cSEric Joyner 9989cf1841cSEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_vlan_filter_list_v2); 9999cf1841cSEric Joyner 10009cf1841cSEric Joyner /* VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 10019cf1841cSEric Joyner * VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 10029cf1841cSEric Joyner * VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 10039cf1841cSEric Joyner * VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2 10049cf1841cSEric Joyner * 10059cf1841cSEric Joyner * VF sends this message to enable or disable VLAN stripping or insertion. It 10069cf1841cSEric Joyner * also needs to specify an ethertype. The VF knows which VLAN ethertypes are 10079cf1841cSEric Joyner * allowed and whether or not it's allowed to enable/disable the specific 10089cf1841cSEric Joyner * offload via the VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS message. The VF needs to 10099cf1841cSEric Joyner * parse the virtchnl_vlan_caps.offloads fields to determine which offload 10109cf1841cSEric Joyner * messages are allowed. 10119cf1841cSEric Joyner * 10129cf1841cSEric Joyner * For example, if the PF populates the virtchnl_vlan_caps.offloads in the 10139cf1841cSEric Joyner * following manner the VF will be allowed to enable and/or disable 0x8100 inner 10149cf1841cSEric Joyner * VLAN insertion and/or stripping via the opcodes listed above. Inner in this 10159cf1841cSEric Joyner * case means the outer most or single VLAN from the VF's perspective. This is 10169cf1841cSEric Joyner * because no outer offloads are supported. See the comments above the 10179cf1841cSEric Joyner * virtchnl_vlan_supported_caps structure for more details. 10189cf1841cSEric Joyner * 10199cf1841cSEric Joyner * virtchnl_vlan_caps.offloads.stripping_support.inner = 10209cf1841cSEric Joyner * VIRTCHNL_VLAN_TOGGLE | 10219cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_8100; 10229cf1841cSEric Joyner * 10239cf1841cSEric Joyner * virtchnl_vlan_caps.offloads.insertion_support.inner = 10249cf1841cSEric Joyner * VIRTCHNL_VLAN_TOGGLE | 10259cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_8100; 10269cf1841cSEric Joyner * 10279cf1841cSEric Joyner * In order to enable inner (again note that in this case inner is the outer 10289cf1841cSEric Joyner * most or single VLAN from the VF's perspective) VLAN stripping for 0x8100 10299cf1841cSEric Joyner * VLANs, the VF would populate the virtchnl_vlan_setting structure in the 10309cf1841cSEric Joyner * following manner and send the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 message. 10319cf1841cSEric Joyner * 10329cf1841cSEric Joyner * virtchnl_vlan_setting.inner_ethertype_setting = 10339cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_8100; 10349cf1841cSEric Joyner * 10359cf1841cSEric Joyner * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on 10369cf1841cSEric Joyner * initialization. 10379cf1841cSEric Joyner * 10389cf1841cSEric Joyner * The reason that VLAN TPID(s) are not being used for the 10399cf1841cSEric Joyner * outer_ethertype_setting and inner_ethertype_setting fields is because it's 10409cf1841cSEric Joyner * possible a device could support VLAN insertion and/or stripping offload on 10419cf1841cSEric Joyner * multiple ethertypes concurrently, so this method allows a VF to request 10429cf1841cSEric Joyner * multiple ethertypes in one message using the virtchnl_vlan_support 10439cf1841cSEric Joyner * enumeration. 10449cf1841cSEric Joyner * 10459cf1841cSEric Joyner * For example, if the PF populates the virtchnl_vlan_caps.offloads in the 10469cf1841cSEric Joyner * following manner the VF will be allowed to enable 0x8100 and 0x88a8 outer 10479cf1841cSEric Joyner * VLAN insertion and stripping simultaneously. The 10489cf1841cSEric Joyner * virtchnl_vlan_caps.offloads.ethertype_match field will also have to be 10499cf1841cSEric Joyner * populated based on what the PF can support. 10509cf1841cSEric Joyner * 10519cf1841cSEric Joyner * virtchnl_vlan_caps.offloads.stripping_support.outer = 10529cf1841cSEric Joyner * VIRTCHNL_VLAN_TOGGLE | 10539cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_8100 | 10549cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_88A8 | 10559cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_AND; 10569cf1841cSEric Joyner * 10579cf1841cSEric Joyner * virtchnl_vlan_caps.offloads.insertion_support.outer = 10589cf1841cSEric Joyner * VIRTCHNL_VLAN_TOGGLE | 10599cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_8100 | 10609cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_88A8 | 10619cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_AND; 10629cf1841cSEric Joyner * 10639cf1841cSEric Joyner * In order to enable outer VLAN stripping for 0x8100 and 0x88a8 VLANs, the VF 10649cf1841cSEric Joyner * would populate the virthcnl_vlan_offload_structure in the following manner 10659cf1841cSEric Joyner * and send the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 message. 10669cf1841cSEric Joyner * 10679cf1841cSEric Joyner * virtchnl_vlan_setting.outer_ethertype_setting = 10689cf1841cSEric Joyner * VIRTHCNL_VLAN_ETHERTYPE_8100 | 10699cf1841cSEric Joyner * VIRTHCNL_VLAN_ETHERTYPE_88A8; 10709cf1841cSEric Joyner * 10719cf1841cSEric Joyner * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on 10729cf1841cSEric Joyner * initialization. 10739cf1841cSEric Joyner * 10749cf1841cSEric Joyner * There is also the case where a PF and the underlying hardware can support 10759cf1841cSEric Joyner * VLAN offloads on multiple ethertypes, but not concurrently. For example, if 10769cf1841cSEric Joyner * the PF populates the virtchnl_vlan_caps.offloads in the following manner the 10779cf1841cSEric Joyner * VF will be allowed to enable and/or disable 0x8100 XOR 0x88a8 outer VLAN 10789cf1841cSEric Joyner * offloads. The ethertypes must match for stripping and insertion. 10799cf1841cSEric Joyner * 10809cf1841cSEric Joyner * virtchnl_vlan_caps.offloads.stripping_support.outer = 10819cf1841cSEric Joyner * VIRTCHNL_VLAN_TOGGLE | 10829cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_8100 | 10839cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_88A8 | 10849cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_XOR; 10859cf1841cSEric Joyner * 10869cf1841cSEric Joyner * virtchnl_vlan_caps.offloads.insertion_support.outer = 10879cf1841cSEric Joyner * VIRTCHNL_VLAN_TOGGLE | 10889cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_8100 | 10899cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_88A8 | 10909cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_XOR; 10919cf1841cSEric Joyner * 10929cf1841cSEric Joyner * virtchnl_vlan_caps.offloads.ethertype_match = 10939cf1841cSEric Joyner * VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION; 10949cf1841cSEric Joyner * 10959cf1841cSEric Joyner * In order to enable outer VLAN stripping for 0x88a8 VLANs, the VF would 10969cf1841cSEric Joyner * populate the virtchnl_vlan_setting structure in the following manner and send 10979cf1841cSEric Joyner * the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2. Also, this will change the 10989cf1841cSEric Joyner * ethertype for VLAN insertion if it's enabled. So, for completeness, a 10999cf1841cSEric Joyner * VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 with the same ethertype should be sent. 11009cf1841cSEric Joyner * 11019cf1841cSEric Joyner * virtchnl_vlan_setting.outer_ethertype_setting = VIRTHCNL_VLAN_ETHERTYPE_88A8; 11029cf1841cSEric Joyner * 11039cf1841cSEric Joyner * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on 11049cf1841cSEric Joyner * initialization. 11059cf1841cSEric Joyner * 11069cf1841cSEric Joyner * VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2 11079cf1841cSEric Joyner * VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2 11089cf1841cSEric Joyner * 11099cf1841cSEric Joyner * VF sends this message to enable or disable VLAN filtering. It also needs to 11109cf1841cSEric Joyner * specify an ethertype. The VF knows which VLAN ethertypes are allowed and 11119cf1841cSEric Joyner * whether or not it's allowed to enable/disable filtering via the 11129cf1841cSEric Joyner * VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS message. The VF needs to 11139cf1841cSEric Joyner * parse the virtchnl_vlan_caps.filtering fields to determine which, if any, 11149cf1841cSEric Joyner * filtering messages are allowed. 11159cf1841cSEric Joyner * 11169cf1841cSEric Joyner * For example, if the PF populates the virtchnl_vlan_caps.filtering in the 11179cf1841cSEric Joyner * following manner the VF will be allowed to enable/disable 0x8100 and 0x88a8 11189cf1841cSEric Joyner * outer VLAN filtering together. Note, that the VIRTCHNL_VLAN_ETHERTYPE_AND 11199cf1841cSEric Joyner * means that all filtering ethertypes will to be enabled and disabled together 11209cf1841cSEric Joyner * regardless of the request from the VF. This means that the underlying 11219cf1841cSEric Joyner * hardware only supports VLAN filtering for all VLAN the specified ethertypes 11229cf1841cSEric Joyner * or none of them. 11239cf1841cSEric Joyner * 11249cf1841cSEric Joyner * virtchnl_vlan_caps.filtering.filtering_support.outer = 11259cf1841cSEric Joyner * VIRTCHNL_VLAN_TOGGLE | 11269cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_8100 | 11279cf1841cSEric Joyner * VIRTHCNL_VLAN_ETHERTYPE_88A8 | 11289cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_9100 | 11299cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_AND; 11309cf1841cSEric Joyner * 11319cf1841cSEric Joyner * In order to enable outer VLAN filtering for 0x88a8 and 0x8100 VLANs (0x9100 11329cf1841cSEric Joyner * VLANs aren't supported by the VF driver), the VF would populate the 11339cf1841cSEric Joyner * virtchnl_vlan_setting structure in the following manner and send the 11349cf1841cSEric Joyner * VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2. The same message format would be used 11359cf1841cSEric Joyner * to disable outer VLAN filtering for 0x88a8 and 0x8100 VLANs, but the 11369cf1841cSEric Joyner * VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2 opcode is used. 11379cf1841cSEric Joyner * 11389cf1841cSEric Joyner * virtchnl_vlan_setting.outer_ethertype_setting = 11399cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_8100 | 11409cf1841cSEric Joyner * VIRTCHNL_VLAN_ETHERTYPE_88A8; 11419cf1841cSEric Joyner * 11429cf1841cSEric Joyner */ 11439cf1841cSEric Joyner struct virtchnl_vlan_setting { 11449cf1841cSEric Joyner u32 outer_ethertype_setting; 11459cf1841cSEric Joyner u32 inner_ethertype_setting; 11469cf1841cSEric Joyner u16 vport_id; 11479cf1841cSEric Joyner u8 pad[6]; 11489cf1841cSEric Joyner }; 11499cf1841cSEric Joyner 11509cf1841cSEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vlan_setting); 11519cf1841cSEric Joyner 115271d10453SEric Joyner /* VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE 115371d10453SEric Joyner * VF sends VSI id and flags. 115471d10453SEric Joyner * PF returns status code in retval. 115571d10453SEric Joyner * Note: we assume that broadcast accept mode is always enabled. 115671d10453SEric Joyner */ 115771d10453SEric Joyner struct virtchnl_promisc_info { 115871d10453SEric Joyner u16 vsi_id; 115971d10453SEric Joyner u16 flags; 116071d10453SEric Joyner }; 116171d10453SEric Joyner 116271d10453SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_promisc_info); 116371d10453SEric Joyner 116471d10453SEric Joyner #define FLAG_VF_UNICAST_PROMISC 0x00000001 116571d10453SEric Joyner #define FLAG_VF_MULTICAST_PROMISC 0x00000002 116671d10453SEric Joyner 116771d10453SEric Joyner /* VIRTCHNL_OP_GET_STATS 116871d10453SEric Joyner * VF sends this message to request stats for the selected VSI. VF uses 116971d10453SEric Joyner * the virtchnl_queue_select struct to specify the VSI. The queue_id 117071d10453SEric Joyner * field is ignored by the PF. 117171d10453SEric Joyner * 117271d10453SEric Joyner * PF replies with struct virtchnl_eth_stats in an external buffer. 117371d10453SEric Joyner */ 117471d10453SEric Joyner 117571d10453SEric Joyner struct virtchnl_eth_stats { 117671d10453SEric Joyner u64 rx_bytes; /* received bytes */ 117771d10453SEric Joyner u64 rx_unicast; /* received unicast pkts */ 117871d10453SEric Joyner u64 rx_multicast; /* received multicast pkts */ 117971d10453SEric Joyner u64 rx_broadcast; /* received broadcast pkts */ 118071d10453SEric Joyner u64 rx_discards; 118171d10453SEric Joyner u64 rx_unknown_protocol; 118271d10453SEric Joyner u64 tx_bytes; /* transmitted bytes */ 118371d10453SEric Joyner u64 tx_unicast; /* transmitted unicast pkts */ 118471d10453SEric Joyner u64 tx_multicast; /* transmitted multicast pkts */ 118571d10453SEric Joyner u64 tx_broadcast; /* transmitted broadcast pkts */ 118671d10453SEric Joyner u64 tx_discards; 118771d10453SEric Joyner u64 tx_errors; 118871d10453SEric Joyner }; 118971d10453SEric Joyner 119071d10453SEric Joyner /* VIRTCHNL_OP_CONFIG_RSS_KEY 119171d10453SEric Joyner * VIRTCHNL_OP_CONFIG_RSS_LUT 119271d10453SEric Joyner * VF sends these messages to configure RSS. Only supported if both PF 119371d10453SEric Joyner * and VF drivers set the VIRTCHNL_VF_OFFLOAD_RSS_PF bit during 119471d10453SEric Joyner * configuration negotiation. If this is the case, then the RSS fields in 119571d10453SEric Joyner * the VF resource struct are valid. 119671d10453SEric Joyner * Both the key and LUT are initialized to 0 by the PF, meaning that 119771d10453SEric Joyner * RSS is effectively disabled until set up by the VF. 119871d10453SEric Joyner */ 119971d10453SEric Joyner struct virtchnl_rss_key { 120071d10453SEric Joyner u16 vsi_id; 120171d10453SEric Joyner u16 key_len; 120271d10453SEric Joyner u8 key[1]; /* RSS hash key, packed bytes */ 120371d10453SEric Joyner }; 120471d10453SEric Joyner 120571d10453SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_rss_key); 120671d10453SEric Joyner 120771d10453SEric Joyner struct virtchnl_rss_lut { 120871d10453SEric Joyner u16 vsi_id; 120971d10453SEric Joyner u16 lut_entries; 121071d10453SEric Joyner u8 lut[1]; /* RSS lookup table */ 121171d10453SEric Joyner }; 121271d10453SEric Joyner 121371d10453SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_rss_lut); 121471d10453SEric Joyner 12158923de59SPiotr Kubaj /* enum virthcnl_hash_filter 12168923de59SPiotr Kubaj * 12178923de59SPiotr Kubaj * Bits defining the hash filters in the hena field of the virtchnl_rss_hena 12188923de59SPiotr Kubaj * structure. Each bit indicates a specific hash filter for RSS. 12198923de59SPiotr Kubaj * 12208923de59SPiotr Kubaj * Note that not all bits are supported on all hardware. The VF should use 12218923de59SPiotr Kubaj * VIRTCHNL_OP_GET_RSS_HENA_CAPS to determine which bits the PF is capable of 12228923de59SPiotr Kubaj * before using VIRTCHNL_OP_SET_RSS_HENA to enable specific filters. 12238923de59SPiotr Kubaj */ 12248923de59SPiotr Kubaj enum virtchnl_hash_filter { 12258923de59SPiotr Kubaj /* Bits 0 through 28 are reserved for future use */ 12268923de59SPiotr Kubaj /* Bit 29, 30, and 32 are not supported on XL710 a X710 */ 12278923de59SPiotr Kubaj VIRTCHNL_HASH_FILTER_UNICAST_IPV4_UDP = 29, 12288923de59SPiotr Kubaj VIRTCHNL_HASH_FILTER_MULTICAST_IPV4_UDP = 30, 12298923de59SPiotr Kubaj VIRTCHNL_HASH_FILTER_IPV4_UDP = 31, 12308923de59SPiotr Kubaj VIRTCHNL_HASH_FILTER_IPV4_TCP_SYN_NO_ACK = 32, 12318923de59SPiotr Kubaj VIRTCHNL_HASH_FILTER_IPV4_TCP = 33, 12328923de59SPiotr Kubaj VIRTCHNL_HASH_FILTER_IPV4_SCTP = 34, 12338923de59SPiotr Kubaj VIRTCHNL_HASH_FILTER_IPV4_OTHER = 35, 12348923de59SPiotr Kubaj VIRTCHNL_HASH_FILTER_FRAG_IPV4 = 36, 12358923de59SPiotr Kubaj /* Bits 37 and 38 are reserved for future use */ 12368923de59SPiotr Kubaj /* Bit 39, 40, and 42 are not supported on XL710 a X710 */ 12378923de59SPiotr Kubaj VIRTCHNL_HASH_FILTER_UNICAST_IPV6_UDP = 39, 12388923de59SPiotr Kubaj VIRTCHNL_HASH_FILTER_MULTICAST_IPV6_UDP = 40, 12398923de59SPiotr Kubaj VIRTCHNL_HASH_FILTER_IPV6_UDP = 41, 12408923de59SPiotr Kubaj VIRTCHNL_HASH_FILTER_IPV6_TCP_SYN_NO_ACK = 42, 12418923de59SPiotr Kubaj VIRTCHNL_HASH_FILTER_IPV6_TCP = 43, 12428923de59SPiotr Kubaj VIRTCHNL_HASH_FILTER_IPV6_SCTP = 44, 12438923de59SPiotr Kubaj VIRTCHNL_HASH_FILTER_IPV6_OTHER = 45, 12448923de59SPiotr Kubaj VIRTCHNL_HASH_FILTER_FRAG_IPV6 = 46, 12458923de59SPiotr Kubaj /* Bit 37 is reserved for future use */ 12468923de59SPiotr Kubaj VIRTCHNL_HASH_FILTER_FCOE_OX = 48, 12478923de59SPiotr Kubaj VIRTCHNL_HASH_FILTER_FCOE_RX = 49, 12488923de59SPiotr Kubaj VIRTCHNL_HASH_FILTER_FCOE_OTHER = 50, 12498923de59SPiotr Kubaj /* Bits 51 through 62 are reserved for future use */ 12508923de59SPiotr Kubaj VIRTCHNL_HASH_FILTER_L2_PAYLOAD = 63, 12518923de59SPiotr Kubaj }; 12528923de59SPiotr Kubaj 12538923de59SPiotr Kubaj #define VIRTCHNL_HASH_FILTER_INVALID (0) 12548923de59SPiotr Kubaj 125571d10453SEric Joyner /* VIRTCHNL_OP_GET_RSS_HENA_CAPS 125671d10453SEric Joyner * VIRTCHNL_OP_SET_RSS_HENA 125771d10453SEric Joyner * VF sends these messages to get and set the hash filter enable bits for RSS. 125871d10453SEric Joyner * By default, the PF sets these to all possible traffic types that the 125971d10453SEric Joyner * hardware supports. The VF can query this value if it wants to change the 126071d10453SEric Joyner * traffic types that are hashed by the hardware. 126171d10453SEric Joyner */ 126271d10453SEric Joyner struct virtchnl_rss_hena { 12638923de59SPiotr Kubaj /* see enum virtchnl_hash_filter */ 126471d10453SEric Joyner u64 hena; 126571d10453SEric Joyner }; 126671d10453SEric Joyner 126771d10453SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_rss_hena); 126871d10453SEric Joyner 126956429daeSEric Joyner /* Type of RSS algorithm */ 127056429daeSEric Joyner enum virtchnl_rss_algorithm { 127156429daeSEric Joyner VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC = 0, 127256429daeSEric Joyner VIRTCHNL_RSS_ALG_R_ASYMMETRIC = 1, 127356429daeSEric Joyner VIRTCHNL_RSS_ALG_TOEPLITZ_SYMMETRIC = 2, 127456429daeSEric Joyner VIRTCHNL_RSS_ALG_XOR_SYMMETRIC = 3, 127556429daeSEric Joyner }; 127656429daeSEric Joyner 127771d10453SEric Joyner /* This is used by PF driver to enforce how many channels can be supported. 127871d10453SEric Joyner * When ADQ_V2 capability is negotiated, it will allow 16 channels otherwise 127971d10453SEric Joyner * PF driver will allow only max 4 channels 128071d10453SEric Joyner */ 128171d10453SEric Joyner #define VIRTCHNL_MAX_ADQ_CHANNELS 4 128271d10453SEric Joyner #define VIRTCHNL_MAX_ADQ_V2_CHANNELS 16 128371d10453SEric Joyner 128471d10453SEric Joyner /* VIRTCHNL_OP_ENABLE_CHANNELS 128571d10453SEric Joyner * VIRTCHNL_OP_DISABLE_CHANNELS 128671d10453SEric Joyner * VF sends these messages to enable or disable channels based on 128771d10453SEric Joyner * the user specified queue count and queue offset for each traffic class. 128871d10453SEric Joyner * This struct encompasses all the information that the PF needs from 128971d10453SEric Joyner * VF to create a channel. 129071d10453SEric Joyner */ 129171d10453SEric Joyner struct virtchnl_channel_info { 129271d10453SEric Joyner u16 count; /* number of queues in a channel */ 129371d10453SEric Joyner u16 offset; /* queues in a channel start from 'offset' */ 129471d10453SEric Joyner u32 pad; 129571d10453SEric Joyner u64 max_tx_rate; 129671d10453SEric Joyner }; 129771d10453SEric Joyner 129871d10453SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_channel_info); 129971d10453SEric Joyner 130071d10453SEric Joyner struct virtchnl_tc_info { 130171d10453SEric Joyner u32 num_tc; 130271d10453SEric Joyner u32 pad; 130371d10453SEric Joyner struct virtchnl_channel_info list[1]; 130471d10453SEric Joyner }; 130571d10453SEric Joyner 130671d10453SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_tc_info); 130771d10453SEric Joyner 130871d10453SEric Joyner /* VIRTCHNL_ADD_CLOUD_FILTER 130971d10453SEric Joyner * VIRTCHNL_DEL_CLOUD_FILTER 131071d10453SEric Joyner * VF sends these messages to add or delete a cloud filter based on the 131171d10453SEric Joyner * user specified match and action filters. These structures encompass 131271d10453SEric Joyner * all the information that the PF needs from the VF to add/delete a 131371d10453SEric Joyner * cloud filter. 131471d10453SEric Joyner */ 131571d10453SEric Joyner 131671d10453SEric Joyner struct virtchnl_l4_spec { 1317d08b8680SEric Joyner u8 src_mac[VIRTCHNL_ETH_LENGTH_OF_ADDRESS]; 1318d08b8680SEric Joyner u8 dst_mac[VIRTCHNL_ETH_LENGTH_OF_ADDRESS]; 131971d10453SEric Joyner /* vlan_prio is part of this 16 bit field even from OS perspective 132071d10453SEric Joyner * vlan_id:12 is actual vlan_id, then vlanid:bit14..12 is vlan_prio 132171d10453SEric Joyner * in future, when decided to offload vlan_prio, pass that information 132271d10453SEric Joyner * as part of the "vlan_id" field, Bit14..12 132371d10453SEric Joyner */ 132471d10453SEric Joyner __be16 vlan_id; 132571d10453SEric Joyner __be16 pad; /* reserved for future use */ 132671d10453SEric Joyner __be32 src_ip[4]; 132771d10453SEric Joyner __be32 dst_ip[4]; 132871d10453SEric Joyner __be16 src_port; 132971d10453SEric Joyner __be16 dst_port; 133071d10453SEric Joyner }; 133171d10453SEric Joyner 133271d10453SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(52, virtchnl_l4_spec); 133371d10453SEric Joyner 133471d10453SEric Joyner union virtchnl_flow_spec { 133571d10453SEric Joyner struct virtchnl_l4_spec tcp_spec; 133671d10453SEric Joyner u8 buffer[128]; /* reserved for future use */ 133771d10453SEric Joyner }; 133871d10453SEric Joyner 133971d10453SEric Joyner VIRTCHNL_CHECK_UNION_LEN(128, virtchnl_flow_spec); 134071d10453SEric Joyner 134171d10453SEric Joyner enum virtchnl_action { 134271d10453SEric Joyner /* action types */ 134371d10453SEric Joyner VIRTCHNL_ACTION_DROP = 0, 134471d10453SEric Joyner VIRTCHNL_ACTION_TC_REDIRECT, 13457d7af7f8SEric Joyner VIRTCHNL_ACTION_PASSTHRU, 13467d7af7f8SEric Joyner VIRTCHNL_ACTION_QUEUE, 13477d7af7f8SEric Joyner VIRTCHNL_ACTION_Q_REGION, 13487d7af7f8SEric Joyner VIRTCHNL_ACTION_MARK, 13497d7af7f8SEric Joyner VIRTCHNL_ACTION_COUNT, 135071d10453SEric Joyner }; 135171d10453SEric Joyner 135271d10453SEric Joyner enum virtchnl_flow_type { 135371d10453SEric Joyner /* flow types */ 135471d10453SEric Joyner VIRTCHNL_TCP_V4_FLOW = 0, 135571d10453SEric Joyner VIRTCHNL_TCP_V6_FLOW, 135671d10453SEric Joyner VIRTCHNL_UDP_V4_FLOW, 135771d10453SEric Joyner VIRTCHNL_UDP_V6_FLOW, 135871d10453SEric Joyner }; 135971d10453SEric Joyner 136071d10453SEric Joyner struct virtchnl_filter { 136171d10453SEric Joyner union virtchnl_flow_spec data; 136271d10453SEric Joyner union virtchnl_flow_spec mask; 13639cf1841cSEric Joyner 13649cf1841cSEric Joyner /* see enum virtchnl_flow_type */ 13659cf1841cSEric Joyner s32 flow_type; 13669cf1841cSEric Joyner 13679cf1841cSEric Joyner /* see enum virtchnl_action */ 13689cf1841cSEric Joyner s32 action; 136971d10453SEric Joyner u32 action_meta; 137071d10453SEric Joyner u8 field_flags; 137171d10453SEric Joyner }; 137271d10453SEric Joyner 137371d10453SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(272, virtchnl_filter); 137471d10453SEric Joyner 137556429daeSEric Joyner struct virtchnl_shaper_bw { 137656429daeSEric Joyner /* Unit is Kbps */ 137756429daeSEric Joyner u32 committed; 137856429daeSEric Joyner u32 peak; 137956429daeSEric Joyner }; 138056429daeSEric Joyner 138156429daeSEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_shaper_bw); 138256429daeSEric Joyner 138371d10453SEric Joyner /* VIRTCHNL_OP_EVENT 138471d10453SEric Joyner * PF sends this message to inform the VF driver of events that may affect it. 138571d10453SEric Joyner * No direct response is expected from the VF, though it may generate other 138671d10453SEric Joyner * messages in response to this one. 138771d10453SEric Joyner */ 138871d10453SEric Joyner enum virtchnl_event_codes { 138971d10453SEric Joyner VIRTCHNL_EVENT_UNKNOWN = 0, 139071d10453SEric Joyner VIRTCHNL_EVENT_LINK_CHANGE, 139171d10453SEric Joyner VIRTCHNL_EVENT_RESET_IMPENDING, 139271d10453SEric Joyner VIRTCHNL_EVENT_PF_DRIVER_CLOSE, 139371d10453SEric Joyner }; 139471d10453SEric Joyner 139571d10453SEric Joyner #define PF_EVENT_SEVERITY_INFO 0 139671d10453SEric Joyner #define PF_EVENT_SEVERITY_ATTENTION 1 139771d10453SEric Joyner #define PF_EVENT_SEVERITY_ACTION_REQUIRED 2 139871d10453SEric Joyner #define PF_EVENT_SEVERITY_CERTAIN_DOOM 255 139971d10453SEric Joyner 140071d10453SEric Joyner struct virtchnl_pf_event { 14019cf1841cSEric Joyner /* see enum virtchnl_event_codes */ 14029cf1841cSEric Joyner s32 event; 140371d10453SEric Joyner union { 140471d10453SEric Joyner /* If the PF driver does not support the new speed reporting 140571d10453SEric Joyner * capabilities then use link_event else use link_event_adv to 140671d10453SEric Joyner * get the speed and link information. The ability to understand 140771d10453SEric Joyner * new speeds is indicated by setting the capability flag 140871d10453SEric Joyner * VIRTCHNL_VF_CAP_ADV_LINK_SPEED in vf_cap_flags parameter 140971d10453SEric Joyner * in virtchnl_vf_resource struct and can be used to determine 141071d10453SEric Joyner * which link event struct to use below. 141171d10453SEric Joyner */ 141271d10453SEric Joyner struct { 141371d10453SEric Joyner enum virtchnl_link_speed link_speed; 14149cf1841cSEric Joyner bool link_status; 14159cf1841cSEric Joyner u8 pad[3]; 141671d10453SEric Joyner } link_event; 141771d10453SEric Joyner struct { 141871d10453SEric Joyner /* link_speed provided in Mbps */ 141971d10453SEric Joyner u32 link_speed; 142071d10453SEric Joyner u8 link_status; 14219cf1841cSEric Joyner u8 pad[3]; 142271d10453SEric Joyner } link_event_adv; 142371d10453SEric Joyner } event_data; 142471d10453SEric Joyner 14259cf1841cSEric Joyner s32 severity; 142671d10453SEric Joyner }; 142771d10453SEric Joyner 142871d10453SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_pf_event); 142971d10453SEric Joyner 1430d08b8680SEric Joyner /* VF reset states - these are written into the RSTAT register: 1431d08b8680SEric Joyner * VFGEN_RSTAT on the VF 1432d08b8680SEric Joyner * When the PF initiates a reset, it writes 0 1433d08b8680SEric Joyner * When the reset is complete, it writes 1 1434d08b8680SEric Joyner * When the PF detects that the VF has recovered, it writes 2 1435d08b8680SEric Joyner * VF checks this register periodically to determine if a reset has occurred, 1436d08b8680SEric Joyner * then polls it to know when the reset is complete. 1437d08b8680SEric Joyner * If either the PF or VF reads the register while the hardware 1438d08b8680SEric Joyner * is in a reset state, it will return DEADBEEF, which, when masked 1439d08b8680SEric Joyner * will result in 3. 1440d08b8680SEric Joyner */ 1441d08b8680SEric Joyner enum virtchnl_vfr_states { 1442d08b8680SEric Joyner VIRTCHNL_VFR_INPROGRESS = 0, 1443d08b8680SEric Joyner VIRTCHNL_VFR_COMPLETED, 1444d08b8680SEric Joyner VIRTCHNL_VFR_VFACTIVE, 1445d08b8680SEric Joyner }; 1446d08b8680SEric Joyner 144756429daeSEric Joyner #define VIRTCHNL_MAX_NUM_PROTO_HDRS 32 14489dc2f6e2SEric Joyner #define VIRTCHNL_MAX_NUM_PROTO_HDRS_W_MSK 16 14498923de59SPiotr Kubaj #define VIRTCHNL_MAX_SIZE_RAW_PACKET 1024 145056429daeSEric Joyner #define PROTO_HDR_SHIFT 5 145156429daeSEric Joyner #define PROTO_HDR_FIELD_START(proto_hdr_type) \ 145256429daeSEric Joyner (proto_hdr_type << PROTO_HDR_SHIFT) 145356429daeSEric Joyner #define PROTO_HDR_FIELD_MASK ((1UL << PROTO_HDR_SHIFT) - 1) 145456429daeSEric Joyner 145556429daeSEric Joyner /* VF use these macros to configure each protocol header. 145656429daeSEric Joyner * Specify which protocol headers and protocol header fields base on 145756429daeSEric Joyner * virtchnl_proto_hdr_type and virtchnl_proto_hdr_field. 145856429daeSEric Joyner * @param hdr: a struct of virtchnl_proto_hdr 145956429daeSEric Joyner * @param hdr_type: ETH/IPV4/TCP, etc 146056429daeSEric Joyner * @param field: SRC/DST/TEID/SPI, etc 146156429daeSEric Joyner */ 146256429daeSEric Joyner #define VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, field) \ 146356429daeSEric Joyner ((hdr)->field_selector |= BIT((field) & PROTO_HDR_FIELD_MASK)) 146456429daeSEric Joyner #define VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, field) \ 146556429daeSEric Joyner ((hdr)->field_selector &= ~BIT((field) & PROTO_HDR_FIELD_MASK)) 146656429daeSEric Joyner #define VIRTCHNL_TEST_PROTO_HDR_FIELD(hdr, val) \ 146756429daeSEric Joyner ((hdr)->field_selector & BIT((val) & PROTO_HDR_FIELD_MASK)) 146856429daeSEric Joyner #define VIRTCHNL_GET_PROTO_HDR_FIELD(hdr) ((hdr)->field_selector) 146956429daeSEric Joyner 147056429daeSEric Joyner #define VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \ 147156429daeSEric Joyner (VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, \ 147256429daeSEric Joyner VIRTCHNL_PROTO_HDR_ ## hdr_type ## _ ## field)) 147356429daeSEric Joyner #define VIRTCHNL_DEL_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \ 147456429daeSEric Joyner (VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, \ 147556429daeSEric Joyner VIRTCHNL_PROTO_HDR_ ## hdr_type ## _ ## field)) 147656429daeSEric Joyner 147756429daeSEric Joyner #define VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, hdr_type) \ 147856429daeSEric Joyner ((hdr)->type = VIRTCHNL_PROTO_HDR_ ## hdr_type) 147956429daeSEric Joyner #define VIRTCHNL_GET_PROTO_HDR_TYPE(hdr) \ 148056429daeSEric Joyner (((hdr)->type) >> PROTO_HDR_SHIFT) 148156429daeSEric Joyner #define VIRTCHNL_TEST_PROTO_HDR_TYPE(hdr, val) \ 148256429daeSEric Joyner ((hdr)->type == ((s32)((val) >> PROTO_HDR_SHIFT))) 148356429daeSEric Joyner #define VIRTCHNL_TEST_PROTO_HDR(hdr, val) \ 148456429daeSEric Joyner (VIRTCHNL_TEST_PROTO_HDR_TYPE(hdr, val) && \ 148556429daeSEric Joyner VIRTCHNL_TEST_PROTO_HDR_FIELD(hdr, val)) 148656429daeSEric Joyner 148756429daeSEric Joyner /* Protocol header type within a packet segment. A segment consists of one or 148856429daeSEric Joyner * more protocol headers that make up a logical group of protocol headers. Each 148956429daeSEric Joyner * logical group of protocol headers encapsulates or is encapsulated using/by 149056429daeSEric Joyner * tunneling or encapsulation protocols for network virtualization. 149156429daeSEric Joyner */ 149256429daeSEric Joyner enum virtchnl_proto_hdr_type { 149356429daeSEric Joyner VIRTCHNL_PROTO_HDR_NONE, 149456429daeSEric Joyner VIRTCHNL_PROTO_HDR_ETH, 149556429daeSEric Joyner VIRTCHNL_PROTO_HDR_S_VLAN, 149656429daeSEric Joyner VIRTCHNL_PROTO_HDR_C_VLAN, 149756429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV4, 149856429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV6, 149956429daeSEric Joyner VIRTCHNL_PROTO_HDR_TCP, 150056429daeSEric Joyner VIRTCHNL_PROTO_HDR_UDP, 150156429daeSEric Joyner VIRTCHNL_PROTO_HDR_SCTP, 150256429daeSEric Joyner VIRTCHNL_PROTO_HDR_GTPU_IP, 150356429daeSEric Joyner VIRTCHNL_PROTO_HDR_GTPU_EH, 150456429daeSEric Joyner VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN, 150556429daeSEric Joyner VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP, 150656429daeSEric Joyner VIRTCHNL_PROTO_HDR_PPPOE, 150756429daeSEric Joyner VIRTCHNL_PROTO_HDR_L2TPV3, 150856429daeSEric Joyner VIRTCHNL_PROTO_HDR_ESP, 150956429daeSEric Joyner VIRTCHNL_PROTO_HDR_AH, 151056429daeSEric Joyner VIRTCHNL_PROTO_HDR_PFCP, 151156429daeSEric Joyner VIRTCHNL_PROTO_HDR_GTPC, 151256429daeSEric Joyner VIRTCHNL_PROTO_HDR_ECPRI, 151356429daeSEric Joyner VIRTCHNL_PROTO_HDR_L2TPV2, 151456429daeSEric Joyner VIRTCHNL_PROTO_HDR_PPP, 151556429daeSEric Joyner /* IPv4 and IPv6 Fragment header types are only associated to 151656429daeSEric Joyner * VIRTCHNL_PROTO_HDR_IPV4 and VIRTCHNL_PROTO_HDR_IPV6 respectively, 151756429daeSEric Joyner * cannot be used independently. 151856429daeSEric Joyner */ 151956429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV4_FRAG, 152056429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG, 152156429daeSEric Joyner VIRTCHNL_PROTO_HDR_GRE, 152256429daeSEric Joyner }; 152356429daeSEric Joyner 152456429daeSEric Joyner /* Protocol header field within a protocol header. */ 152556429daeSEric Joyner enum virtchnl_proto_hdr_field { 152656429daeSEric Joyner /* ETHER */ 152756429daeSEric Joyner VIRTCHNL_PROTO_HDR_ETH_SRC = 152856429daeSEric Joyner PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ETH), 152956429daeSEric Joyner VIRTCHNL_PROTO_HDR_ETH_DST, 153056429daeSEric Joyner VIRTCHNL_PROTO_HDR_ETH_ETHERTYPE, 153156429daeSEric Joyner /* S-VLAN */ 153256429daeSEric Joyner VIRTCHNL_PROTO_HDR_S_VLAN_ID = 153356429daeSEric Joyner PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_S_VLAN), 153456429daeSEric Joyner /* C-VLAN */ 153556429daeSEric Joyner VIRTCHNL_PROTO_HDR_C_VLAN_ID = 153656429daeSEric Joyner PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_C_VLAN), 153756429daeSEric Joyner /* IPV4 */ 153856429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV4_SRC = 153956429daeSEric Joyner PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV4), 154056429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV4_DST, 154156429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV4_DSCP, 154256429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV4_TTL, 154356429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV4_PROT, 154456429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV4_CHKSUM, 154556429daeSEric Joyner /* IPV6 */ 154656429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV6_SRC = 154756429daeSEric Joyner PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV6), 154856429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV6_DST, 154956429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV6_TC, 155056429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV6_HOP_LIMIT, 155156429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV6_PROT, 155256429daeSEric Joyner /* IPV6 Prefix */ 155356429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV6_PREFIX32_SRC, 155456429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV6_PREFIX32_DST, 155556429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV6_PREFIX40_SRC, 155656429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV6_PREFIX40_DST, 155756429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV6_PREFIX48_SRC, 155856429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV6_PREFIX48_DST, 155956429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV6_PREFIX56_SRC, 156056429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV6_PREFIX56_DST, 156156429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV6_PREFIX64_SRC, 156256429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV6_PREFIX64_DST, 156356429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV6_PREFIX96_SRC, 156456429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV6_PREFIX96_DST, 156556429daeSEric Joyner /* TCP */ 156656429daeSEric Joyner VIRTCHNL_PROTO_HDR_TCP_SRC_PORT = 156756429daeSEric Joyner PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_TCP), 156856429daeSEric Joyner VIRTCHNL_PROTO_HDR_TCP_DST_PORT, 156956429daeSEric Joyner VIRTCHNL_PROTO_HDR_TCP_CHKSUM, 157056429daeSEric Joyner /* UDP */ 157156429daeSEric Joyner VIRTCHNL_PROTO_HDR_UDP_SRC_PORT = 157256429daeSEric Joyner PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_UDP), 157356429daeSEric Joyner VIRTCHNL_PROTO_HDR_UDP_DST_PORT, 157456429daeSEric Joyner VIRTCHNL_PROTO_HDR_UDP_CHKSUM, 157556429daeSEric Joyner /* SCTP */ 157656429daeSEric Joyner VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT = 157756429daeSEric Joyner PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_SCTP), 157856429daeSEric Joyner VIRTCHNL_PROTO_HDR_SCTP_DST_PORT, 157956429daeSEric Joyner VIRTCHNL_PROTO_HDR_SCTP_CHKSUM, 158056429daeSEric Joyner /* GTPU_IP */ 158156429daeSEric Joyner VIRTCHNL_PROTO_HDR_GTPU_IP_TEID = 158256429daeSEric Joyner PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_IP), 158356429daeSEric Joyner /* GTPU_EH */ 158456429daeSEric Joyner VIRTCHNL_PROTO_HDR_GTPU_EH_PDU = 158556429daeSEric Joyner PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH), 158656429daeSEric Joyner VIRTCHNL_PROTO_HDR_GTPU_EH_QFI, 158756429daeSEric Joyner /* PPPOE */ 158856429daeSEric Joyner VIRTCHNL_PROTO_HDR_PPPOE_SESS_ID = 158956429daeSEric Joyner PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_PPPOE), 159056429daeSEric Joyner /* L2TPV3 */ 159156429daeSEric Joyner VIRTCHNL_PROTO_HDR_L2TPV3_SESS_ID = 159256429daeSEric Joyner PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_L2TPV3), 159356429daeSEric Joyner /* ESP */ 159456429daeSEric Joyner VIRTCHNL_PROTO_HDR_ESP_SPI = 159556429daeSEric Joyner PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ESP), 159656429daeSEric Joyner /* AH */ 159756429daeSEric Joyner VIRTCHNL_PROTO_HDR_AH_SPI = 159856429daeSEric Joyner PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_AH), 159956429daeSEric Joyner /* PFCP */ 160056429daeSEric Joyner VIRTCHNL_PROTO_HDR_PFCP_S_FIELD = 160156429daeSEric Joyner PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_PFCP), 160256429daeSEric Joyner VIRTCHNL_PROTO_HDR_PFCP_SEID, 160356429daeSEric Joyner /* GTPC */ 160456429daeSEric Joyner VIRTCHNL_PROTO_HDR_GTPC_TEID = 160556429daeSEric Joyner PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPC), 160656429daeSEric Joyner /* ECPRI */ 160756429daeSEric Joyner VIRTCHNL_PROTO_HDR_ECPRI_MSG_TYPE = 160856429daeSEric Joyner PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ECPRI), 160956429daeSEric Joyner VIRTCHNL_PROTO_HDR_ECPRI_PC_RTC_ID, 161056429daeSEric Joyner /* IPv4 Dummy Fragment */ 161156429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV4_FRAG_PKID = 161256429daeSEric Joyner PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV4_FRAG), 161356429daeSEric Joyner /* IPv6 Extension Fragment */ 161456429daeSEric Joyner VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG_PKID = 161556429daeSEric Joyner PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG), 161656429daeSEric Joyner /* GTPU_DWN/UP */ 161756429daeSEric Joyner VIRTCHNL_PROTO_HDR_GTPU_DWN_QFI = 161856429daeSEric Joyner PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN), 161956429daeSEric Joyner VIRTCHNL_PROTO_HDR_GTPU_UP_QFI = 162056429daeSEric Joyner PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP), 16218923de59SPiotr Kubaj /* L2TPv2 */ 16228923de59SPiotr Kubaj VIRTCHNL_PROTO_HDR_L2TPV2_SESS_ID = 16238923de59SPiotr Kubaj PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_L2TPV2), 16248923de59SPiotr Kubaj VIRTCHNL_PROTO_HDR_L2TPV2_LEN_SESS_ID, 162556429daeSEric Joyner }; 162656429daeSEric Joyner 162756429daeSEric Joyner struct virtchnl_proto_hdr { 162856429daeSEric Joyner /* see enum virtchnl_proto_hdr_type */ 162956429daeSEric Joyner s32 type; 163056429daeSEric Joyner u32 field_selector; /* a bit mask to select field for header type */ 163156429daeSEric Joyner u8 buffer[64]; 163256429daeSEric Joyner /** 163356429daeSEric Joyner * binary buffer in network order for specific header type. 163456429daeSEric Joyner * For example, if type = VIRTCHNL_PROTO_HDR_IPV4, a IPv4 163556429daeSEric Joyner * header is expected to be copied into the buffer. 163656429daeSEric Joyner */ 163756429daeSEric Joyner }; 163856429daeSEric Joyner 163956429daeSEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_proto_hdr); 164056429daeSEric Joyner 16419dc2f6e2SEric Joyner struct virtchnl_proto_hdr_w_msk { 16429dc2f6e2SEric Joyner /* see enum virtchnl_proto_hdr_type */ 16439dc2f6e2SEric Joyner s32 type; 16449dc2f6e2SEric Joyner u32 pad; 16459dc2f6e2SEric Joyner /** 16469dc2f6e2SEric Joyner * binary buffer in network order for specific header type. 16479dc2f6e2SEric Joyner * For example, if type = VIRTCHNL_PROTO_HDR_IPV4, a IPv4 16489dc2f6e2SEric Joyner * header is expected to be copied into the buffer. 16499dc2f6e2SEric Joyner */ 16509dc2f6e2SEric Joyner u8 buffer_spec[64]; 16519dc2f6e2SEric Joyner /* binary buffer for bit-mask applied to specific header type */ 16529dc2f6e2SEric Joyner u8 buffer_mask[64]; 16539dc2f6e2SEric Joyner }; 16549dc2f6e2SEric Joyner 16559dc2f6e2SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(136, virtchnl_proto_hdr_w_msk); 16569dc2f6e2SEric Joyner 165756429daeSEric Joyner struct virtchnl_proto_hdrs { 165856429daeSEric Joyner u8 tunnel_level; 165956429daeSEric Joyner /** 166056429daeSEric Joyner * specify where protocol header start from. 16618923de59SPiotr Kubaj * must be 0 when sending a raw packet request. 166256429daeSEric Joyner * 0 - from the outer layer 166356429daeSEric Joyner * 1 - from the first inner layer 166456429daeSEric Joyner * 2 - from the second inner layer 166556429daeSEric Joyner * .... 16668923de59SPiotr Kubaj */ 16678923de59SPiotr Kubaj int count; 16688923de59SPiotr Kubaj /** 16699dc2f6e2SEric Joyner * count must <= 16709dc2f6e2SEric Joyner * VIRTCHNL_MAX_NUM_PROTO_HDRS + VIRTCHNL_MAX_NUM_PROTO_HDRS_W_MSK 16719dc2f6e2SEric Joyner * count = 0 : select raw 16729dc2f6e2SEric Joyner * 1 < count <= VIRTCHNL_MAX_NUM_PROTO_HDRS : select proto_hdr 16739dc2f6e2SEric Joyner * count > VIRTCHNL_MAX_NUM_PROTO_HDRS : select proto_hdr_w_msk 16749dc2f6e2SEric Joyner * last valid index = count - VIRTCHNL_MAX_NUM_PROTO_HDRS 16758923de59SPiotr Kubaj */ 16768923de59SPiotr Kubaj union { 16778923de59SPiotr Kubaj struct virtchnl_proto_hdr 16788923de59SPiotr Kubaj proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS]; 16799dc2f6e2SEric Joyner struct virtchnl_proto_hdr_w_msk 16809dc2f6e2SEric Joyner proto_hdr_w_msk[VIRTCHNL_MAX_NUM_PROTO_HDRS_W_MSK]; 16818923de59SPiotr Kubaj struct { 16828923de59SPiotr Kubaj u16 pkt_len; 16838923de59SPiotr Kubaj u8 spec[VIRTCHNL_MAX_SIZE_RAW_PACKET]; 16848923de59SPiotr Kubaj u8 mask[VIRTCHNL_MAX_SIZE_RAW_PACKET]; 16858923de59SPiotr Kubaj } raw; 16868923de59SPiotr Kubaj }; 168756429daeSEric Joyner }; 168856429daeSEric Joyner 168956429daeSEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(2312, virtchnl_proto_hdrs); 169056429daeSEric Joyner 169156429daeSEric Joyner struct virtchnl_rss_cfg { 169256429daeSEric Joyner struct virtchnl_proto_hdrs proto_hdrs; /* protocol headers */ 169356429daeSEric Joyner 169456429daeSEric Joyner /* see enum virtchnl_rss_algorithm; rss algorithm type */ 169556429daeSEric Joyner s32 rss_algorithm; 169656429daeSEric Joyner u8 reserved[128]; /* reserve for future */ 169756429daeSEric Joyner }; 169856429daeSEric Joyner 169956429daeSEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(2444, virtchnl_rss_cfg); 170056429daeSEric Joyner 17019dc2f6e2SEric Joyner /* action configuration for FDIR and FSUB */ 170256429daeSEric Joyner struct virtchnl_filter_action { 170356429daeSEric Joyner /* see enum virtchnl_action type */ 170456429daeSEric Joyner s32 type; 170556429daeSEric Joyner union { 170656429daeSEric Joyner /* used for queue and qgroup action */ 170756429daeSEric Joyner struct { 170856429daeSEric Joyner u16 index; 170956429daeSEric Joyner u8 region; 171056429daeSEric Joyner } queue; 171156429daeSEric Joyner /* used for count action */ 171256429daeSEric Joyner struct { 171356429daeSEric Joyner /* share counter ID with other flow rules */ 171456429daeSEric Joyner u8 shared; 171556429daeSEric Joyner u32 id; /* counter ID */ 171656429daeSEric Joyner } count; 171756429daeSEric Joyner /* used for mark action */ 171856429daeSEric Joyner u32 mark_id; 171956429daeSEric Joyner u8 reserve[32]; 172056429daeSEric Joyner } act_conf; 172156429daeSEric Joyner }; 172256429daeSEric Joyner 172356429daeSEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_filter_action); 172456429daeSEric Joyner 172556429daeSEric Joyner #define VIRTCHNL_MAX_NUM_ACTIONS 8 172656429daeSEric Joyner 172756429daeSEric Joyner struct virtchnl_filter_action_set { 172856429daeSEric Joyner /* action number must be less then VIRTCHNL_MAX_NUM_ACTIONS */ 172956429daeSEric Joyner int count; 173056429daeSEric Joyner struct virtchnl_filter_action actions[VIRTCHNL_MAX_NUM_ACTIONS]; 173156429daeSEric Joyner }; 173256429daeSEric Joyner 173356429daeSEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(292, virtchnl_filter_action_set); 173456429daeSEric Joyner 173556429daeSEric Joyner /* pattern and action for FDIR rule */ 173656429daeSEric Joyner struct virtchnl_fdir_rule { 173756429daeSEric Joyner struct virtchnl_proto_hdrs proto_hdrs; 173856429daeSEric Joyner struct virtchnl_filter_action_set action_set; 173956429daeSEric Joyner }; 174056429daeSEric Joyner 174156429daeSEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(2604, virtchnl_fdir_rule); 174256429daeSEric Joyner 174356429daeSEric Joyner /* Status returned to VF after VF requests FDIR commands 174456429daeSEric Joyner * VIRTCHNL_FDIR_SUCCESS 174556429daeSEric Joyner * VF FDIR related request is successfully done by PF 174656429daeSEric Joyner * The request can be OP_ADD/DEL/QUERY_FDIR_FILTER. 174756429daeSEric Joyner * 174856429daeSEric Joyner * VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE 174956429daeSEric Joyner * OP_ADD_FDIR_FILTER request is failed due to no Hardware resource. 175056429daeSEric Joyner * 175156429daeSEric Joyner * VIRTCHNL_FDIR_FAILURE_RULE_EXIST 175256429daeSEric Joyner * OP_ADD_FDIR_FILTER request is failed due to the rule is already existed. 175356429daeSEric Joyner * 175456429daeSEric Joyner * VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT 175556429daeSEric Joyner * OP_ADD_FDIR_FILTER request is failed due to conflict with existing rule. 175656429daeSEric Joyner * 175756429daeSEric Joyner * VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST 175856429daeSEric Joyner * OP_DEL_FDIR_FILTER request is failed due to this rule doesn't exist. 175956429daeSEric Joyner * 176056429daeSEric Joyner * VIRTCHNL_FDIR_FAILURE_RULE_INVALID 176156429daeSEric Joyner * OP_ADD_FDIR_FILTER request is failed due to parameters validation 176256429daeSEric Joyner * or HW doesn't support. 176356429daeSEric Joyner * 176456429daeSEric Joyner * VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT 176556429daeSEric Joyner * OP_ADD/DEL_FDIR_FILTER request is failed due to timing out 176656429daeSEric Joyner * for programming. 176756429daeSEric Joyner * 176856429daeSEric Joyner * VIRTCHNL_FDIR_FAILURE_QUERY_INVALID 176956429daeSEric Joyner * OP_QUERY_FDIR_FILTER request is failed due to parameters validation, 177056429daeSEric Joyner * for example, VF query counter of a rule who has no counter action. 177156429daeSEric Joyner */ 177256429daeSEric Joyner enum virtchnl_fdir_prgm_status { 177356429daeSEric Joyner VIRTCHNL_FDIR_SUCCESS = 0, 177456429daeSEric Joyner VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE, 177556429daeSEric Joyner VIRTCHNL_FDIR_FAILURE_RULE_EXIST, 177656429daeSEric Joyner VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT, 177756429daeSEric Joyner VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST, 177856429daeSEric Joyner VIRTCHNL_FDIR_FAILURE_RULE_INVALID, 177956429daeSEric Joyner VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT, 178056429daeSEric Joyner VIRTCHNL_FDIR_FAILURE_QUERY_INVALID, 178156429daeSEric Joyner }; 178256429daeSEric Joyner 178356429daeSEric Joyner /* VIRTCHNL_OP_ADD_FDIR_FILTER 178456429daeSEric Joyner * VF sends this request to PF by filling out vsi_id, 178556429daeSEric Joyner * validate_only and rule_cfg. PF will return flow_id 178656429daeSEric Joyner * if the request is successfully done and return add_status to VF. 178756429daeSEric Joyner */ 178856429daeSEric Joyner struct virtchnl_fdir_add { 178956429daeSEric Joyner u16 vsi_id; /* INPUT */ 179056429daeSEric Joyner /* 179156429daeSEric Joyner * 1 for validating a fdir rule, 0 for creating a fdir rule. 179256429daeSEric Joyner * Validate and create share one ops: VIRTCHNL_OP_ADD_FDIR_FILTER. 179356429daeSEric Joyner */ 179456429daeSEric Joyner u16 validate_only; /* INPUT */ 179556429daeSEric Joyner u32 flow_id; /* OUTPUT */ 179656429daeSEric Joyner struct virtchnl_fdir_rule rule_cfg; /* INPUT */ 179756429daeSEric Joyner 179856429daeSEric Joyner /* see enum virtchnl_fdir_prgm_status; OUTPUT */ 179956429daeSEric Joyner s32 status; 180056429daeSEric Joyner }; 180156429daeSEric Joyner 180256429daeSEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(2616, virtchnl_fdir_add); 180356429daeSEric Joyner 180456429daeSEric Joyner /* VIRTCHNL_OP_DEL_FDIR_FILTER 180556429daeSEric Joyner * VF sends this request to PF by filling out vsi_id 180656429daeSEric Joyner * and flow_id. PF will return del_status to VF. 180756429daeSEric Joyner */ 180856429daeSEric Joyner struct virtchnl_fdir_del { 180956429daeSEric Joyner u16 vsi_id; /* INPUT */ 181056429daeSEric Joyner u16 pad; 181156429daeSEric Joyner u32 flow_id; /* INPUT */ 181256429daeSEric Joyner 181356429daeSEric Joyner /* see enum virtchnl_fdir_prgm_status; OUTPUT */ 181456429daeSEric Joyner s32 status; 181556429daeSEric Joyner }; 181656429daeSEric Joyner 181756429daeSEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_fdir_del); 181856429daeSEric Joyner 18199dc2f6e2SEric Joyner /* Status returned to VF after VF requests FSUB commands 18209dc2f6e2SEric Joyner * VIRTCHNL_FSUB_SUCCESS 18219dc2f6e2SEric Joyner * VF FLOW related request is successfully done by PF 18229dc2f6e2SEric Joyner * The request can be OP_FLOW_SUBSCRIBE/UNSUBSCRIBE. 18239dc2f6e2SEric Joyner * 18249dc2f6e2SEric Joyner * VIRTCHNL_FSUB_FAILURE_RULE_NORESOURCE 18259dc2f6e2SEric Joyner * OP_FLOW_SUBSCRIBE request is failed due to no Hardware resource. 18269dc2f6e2SEric Joyner * 18279dc2f6e2SEric Joyner * VIRTCHNL_FSUB_FAILURE_RULE_EXIST 18289dc2f6e2SEric Joyner * OP_FLOW_SUBSCRIBE request is failed due to the rule is already existed. 18299dc2f6e2SEric Joyner * 18309dc2f6e2SEric Joyner * VIRTCHNL_FSUB_FAILURE_RULE_NONEXIST 18319dc2f6e2SEric Joyner * OP_FLOW_UNSUBSCRIBE request is failed due to this rule doesn't exist. 18329dc2f6e2SEric Joyner * 18339dc2f6e2SEric Joyner * VIRTCHNL_FSUB_FAILURE_RULE_INVALID 18349dc2f6e2SEric Joyner * OP_FLOW_SUBSCRIBE request is failed due to parameters validation 18359dc2f6e2SEric Joyner * or HW doesn't support. 18369dc2f6e2SEric Joyner */ 18379dc2f6e2SEric Joyner enum virtchnl_fsub_prgm_status { 18389dc2f6e2SEric Joyner VIRTCHNL_FSUB_SUCCESS = 0, 18399dc2f6e2SEric Joyner VIRTCHNL_FSUB_FAILURE_RULE_NORESOURCE, 18409dc2f6e2SEric Joyner VIRTCHNL_FSUB_FAILURE_RULE_EXIST, 18419dc2f6e2SEric Joyner VIRTCHNL_FSUB_FAILURE_RULE_NONEXIST, 18429dc2f6e2SEric Joyner VIRTCHNL_FSUB_FAILURE_RULE_INVALID, 18439dc2f6e2SEric Joyner }; 18449dc2f6e2SEric Joyner 18459dc2f6e2SEric Joyner /* VIRTCHNL_OP_FLOW_SUBSCRIBE 18469dc2f6e2SEric Joyner * VF sends this request to PF by filling out vsi_id, 18479dc2f6e2SEric Joyner * validate_only, priority, proto_hdrs and actions. 18489dc2f6e2SEric Joyner * PF will return flow_id 18499dc2f6e2SEric Joyner * if the request is successfully done and return status to VF. 18509dc2f6e2SEric Joyner */ 18519dc2f6e2SEric Joyner struct virtchnl_flow_sub { 18529dc2f6e2SEric Joyner u16 vsi_id; /* INPUT */ 18539dc2f6e2SEric Joyner u8 validate_only; /* INPUT */ 18549dc2f6e2SEric Joyner /* 0 is the highest priority; INPUT */ 18559dc2f6e2SEric Joyner u8 priority; 18569dc2f6e2SEric Joyner u32 flow_id; /* OUTPUT */ 18579dc2f6e2SEric Joyner struct virtchnl_proto_hdrs proto_hdrs; /* INPUT */ 18589dc2f6e2SEric Joyner struct virtchnl_filter_action_set actions; /* INPUT */ 18599dc2f6e2SEric Joyner /* see enum virtchnl_fsub_prgm_status; OUTPUT */ 18609dc2f6e2SEric Joyner s32 status; 18619dc2f6e2SEric Joyner }; 18629dc2f6e2SEric Joyner 18639dc2f6e2SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(2616, virtchnl_flow_sub); 18649dc2f6e2SEric Joyner 18659dc2f6e2SEric Joyner /* VIRTCHNL_OP_FLOW_UNSUBSCRIBE 18669dc2f6e2SEric Joyner * VF sends this request to PF by filling out vsi_id 18679dc2f6e2SEric Joyner * and flow_id. PF will return status to VF. 18689dc2f6e2SEric Joyner */ 18699dc2f6e2SEric Joyner struct virtchnl_flow_unsub { 18709dc2f6e2SEric Joyner u16 vsi_id; /* INPUT */ 18719dc2f6e2SEric Joyner u16 pad; 18729dc2f6e2SEric Joyner u32 flow_id; /* INPUT */ 18739dc2f6e2SEric Joyner /* see enum virtchnl_fsub_prgm_status; OUTPUT */ 18749dc2f6e2SEric Joyner s32 status; 18759dc2f6e2SEric Joyner }; 18769dc2f6e2SEric Joyner 18779dc2f6e2SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_flow_unsub); 18789dc2f6e2SEric Joyner 187956429daeSEric Joyner /* VIRTCHNL_OP_GET_QOS_CAPS 188056429daeSEric Joyner * VF sends this message to get its QoS Caps, such as 188156429daeSEric Joyner * TC number, Arbiter and Bandwidth. 188256429daeSEric Joyner */ 188356429daeSEric Joyner struct virtchnl_qos_cap_elem { 188456429daeSEric Joyner u8 tc_num; 188556429daeSEric Joyner u8 tc_prio; 188656429daeSEric Joyner #define VIRTCHNL_ABITER_STRICT 0 188756429daeSEric Joyner #define VIRTCHNL_ABITER_ETS 2 188856429daeSEric Joyner u8 arbiter; 188956429daeSEric Joyner #define VIRTCHNL_STRICT_WEIGHT 1 189056429daeSEric Joyner u8 weight; 189156429daeSEric Joyner enum virtchnl_bw_limit_type type; 189256429daeSEric Joyner union { 189356429daeSEric Joyner struct virtchnl_shaper_bw shaper; 189456429daeSEric Joyner u8 pad2[32]; 189556429daeSEric Joyner }; 189656429daeSEric Joyner }; 189756429daeSEric Joyner 189856429daeSEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_qos_cap_elem); 189956429daeSEric Joyner 190056429daeSEric Joyner struct virtchnl_qos_cap_list { 190156429daeSEric Joyner u16 vsi_id; 190256429daeSEric Joyner u16 num_elem; 190356429daeSEric Joyner struct virtchnl_qos_cap_elem cap[1]; 190456429daeSEric Joyner }; 190556429daeSEric Joyner 190656429daeSEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(44, virtchnl_qos_cap_list); 190756429daeSEric Joyner 190856429daeSEric Joyner /* VIRTCHNL_OP_CONFIG_QUEUE_TC_MAP 190956429daeSEric Joyner * VF sends message virtchnl_queue_tc_mapping to set queue to tc 191056429daeSEric Joyner * mapping for all the Tx and Rx queues with a specified VSI, and 191156429daeSEric Joyner * would get response about bitmap of valid user priorities 191256429daeSEric Joyner * associated with queues. 191356429daeSEric Joyner */ 191456429daeSEric Joyner struct virtchnl_queue_tc_mapping { 191556429daeSEric Joyner u16 vsi_id; 191656429daeSEric Joyner u16 num_tc; 191756429daeSEric Joyner u16 num_queue_pairs; 191856429daeSEric Joyner u8 pad[2]; 191956429daeSEric Joyner union { 192056429daeSEric Joyner struct { 192156429daeSEric Joyner u16 start_queue_id; 192256429daeSEric Joyner u16 queue_count; 192356429daeSEric Joyner } req; 192456429daeSEric Joyner struct { 192556429daeSEric Joyner #define VIRTCHNL_USER_PRIO_TYPE_UP 0 192656429daeSEric Joyner #define VIRTCHNL_USER_PRIO_TYPE_DSCP 1 192756429daeSEric Joyner u16 prio_type; 192856429daeSEric Joyner u16 valid_prio_bitmap; 192956429daeSEric Joyner } resp; 193056429daeSEric Joyner } tc[1]; 193156429daeSEric Joyner }; 193256429daeSEric Joyner 193356429daeSEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_tc_mapping); 193456429daeSEric Joyner 19358923de59SPiotr Kubaj /* VIRTCHNL_OP_CONFIG_QUEUE_BW */ 19368923de59SPiotr Kubaj struct virtchnl_queue_bw { 19378923de59SPiotr Kubaj u16 queue_id; 19388923de59SPiotr Kubaj u8 tc; 19398923de59SPiotr Kubaj u8 pad; 19408923de59SPiotr Kubaj struct virtchnl_shaper_bw shaper; 19418923de59SPiotr Kubaj }; 19428923de59SPiotr Kubaj 19438923de59SPiotr Kubaj VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_bw); 19448923de59SPiotr Kubaj 19458923de59SPiotr Kubaj struct virtchnl_queues_bw_cfg { 19468923de59SPiotr Kubaj u16 vsi_id; 19478923de59SPiotr Kubaj u16 num_queues; 19488923de59SPiotr Kubaj struct virtchnl_queue_bw cfg[1]; 19498923de59SPiotr Kubaj }; 19508923de59SPiotr Kubaj 19518923de59SPiotr Kubaj VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_queues_bw_cfg); 19528923de59SPiotr Kubaj 19538923de59SPiotr Kubaj /* queue types */ 1954d08b8680SEric Joyner enum virtchnl_queue_type { 1955d08b8680SEric Joyner VIRTCHNL_QUEUE_TYPE_TX = 0, 1956d08b8680SEric Joyner VIRTCHNL_QUEUE_TYPE_RX = 1, 1957d08b8680SEric Joyner }; 1958d08b8680SEric Joyner 1959d08b8680SEric Joyner /* structure to specify a chunk of contiguous queues */ 1960d08b8680SEric Joyner struct virtchnl_queue_chunk { 19619cf1841cSEric Joyner /* see enum virtchnl_queue_type */ 19629cf1841cSEric Joyner s32 type; 1963d08b8680SEric Joyner u16 start_queue_id; 1964d08b8680SEric Joyner u16 num_queues; 1965d08b8680SEric Joyner }; 1966d08b8680SEric Joyner 1967d08b8680SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_queue_chunk); 1968d08b8680SEric Joyner 1969d08b8680SEric Joyner /* structure to specify several chunks of contiguous queues */ 1970d08b8680SEric Joyner struct virtchnl_queue_chunks { 1971d08b8680SEric Joyner u16 num_chunks; 1972d08b8680SEric Joyner u16 rsvd; 1973d08b8680SEric Joyner struct virtchnl_queue_chunk chunks[1]; 1974d08b8680SEric Joyner }; 1975d08b8680SEric Joyner 1976d08b8680SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_chunks); 1977d08b8680SEric Joyner 1978d08b8680SEric Joyner /* VIRTCHNL_OP_ENABLE_QUEUES_V2 1979d08b8680SEric Joyner * VIRTCHNL_OP_DISABLE_QUEUES_V2 1980d08b8680SEric Joyner * 19818923de59SPiotr Kubaj * These opcodes can be used if VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in 19828923de59SPiotr Kubaj * VIRTCHNL_OP_GET_VF_RESOURCES 1983d08b8680SEric Joyner * 19848923de59SPiotr Kubaj * VF sends virtchnl_ena_dis_queues struct to specify the queues to be 19858923de59SPiotr Kubaj * enabled/disabled in chunks. Also applicable to single queue RX or 19868923de59SPiotr Kubaj * TX. PF performs requested action and returns status. 1987d08b8680SEric Joyner */ 1988d08b8680SEric Joyner struct virtchnl_del_ena_dis_queues { 1989d08b8680SEric Joyner u16 vport_id; 1990d08b8680SEric Joyner u16 pad; 1991d08b8680SEric Joyner struct virtchnl_queue_chunks chunks; 1992d08b8680SEric Joyner }; 1993d08b8680SEric Joyner 1994d08b8680SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_del_ena_dis_queues); 1995d08b8680SEric Joyner 1996d08b8680SEric Joyner /* Virtchannel interrupt throttling rate index */ 1997d08b8680SEric Joyner enum virtchnl_itr_idx { 1998d08b8680SEric Joyner VIRTCHNL_ITR_IDX_0 = 0, 1999d08b8680SEric Joyner VIRTCHNL_ITR_IDX_1 = 1, 2000d08b8680SEric Joyner VIRTCHNL_ITR_IDX_NO_ITR = 3, 2001d08b8680SEric Joyner }; 2002d08b8680SEric Joyner 2003d08b8680SEric Joyner /* Queue to vector mapping */ 2004d08b8680SEric Joyner struct virtchnl_queue_vector { 2005d08b8680SEric Joyner u16 queue_id; 2006d08b8680SEric Joyner u16 vector_id; 2007d08b8680SEric Joyner u8 pad[4]; 20089cf1841cSEric Joyner 20099cf1841cSEric Joyner /* see enum virtchnl_itr_idx */ 20109cf1841cSEric Joyner s32 itr_idx; 20119cf1841cSEric Joyner 20129cf1841cSEric Joyner /* see enum virtchnl_queue_type */ 20139cf1841cSEric Joyner s32 queue_type; 2014d08b8680SEric Joyner }; 2015d08b8680SEric Joyner 2016d08b8680SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_queue_vector); 2017d08b8680SEric Joyner 2018d08b8680SEric Joyner /* VIRTCHNL_OP_MAP_QUEUE_VECTOR 2019d08b8680SEric Joyner * 20208923de59SPiotr Kubaj * This opcode can be used only if VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated 20218923de59SPiotr Kubaj * in VIRTCHNL_OP_GET_VF_RESOURCES 2022d08b8680SEric Joyner * 20238923de59SPiotr Kubaj * VF sends this message to map queues to vectors and ITR index registers. 20248923de59SPiotr Kubaj * External data buffer contains virtchnl_queue_vector_maps structure 2025d08b8680SEric Joyner * that contains num_qv_maps of virtchnl_queue_vector structures. 20268923de59SPiotr Kubaj * PF maps the requested queue vector maps after validating the queue and vector 2027d08b8680SEric Joyner * ids and returns a status code. 2028d08b8680SEric Joyner */ 2029d08b8680SEric Joyner struct virtchnl_queue_vector_maps { 2030d08b8680SEric Joyner u16 vport_id; 2031d08b8680SEric Joyner u16 num_qv_maps; 2032d08b8680SEric Joyner u8 pad[4]; 2033d08b8680SEric Joyner struct virtchnl_queue_vector qv_maps[1]; 2034d08b8680SEric Joyner }; 2035d08b8680SEric Joyner 2036d08b8680SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_queue_vector_maps); 2037d08b8680SEric Joyner 20388923de59SPiotr Kubaj struct virtchnl_quanta_cfg { 20398923de59SPiotr Kubaj u16 quanta_size; 20408923de59SPiotr Kubaj struct virtchnl_queue_chunk queue_select; 20418923de59SPiotr Kubaj }; 20428923de59SPiotr Kubaj 20438923de59SPiotr Kubaj VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_quanta_cfg); 20448923de59SPiotr Kubaj 2045*f2635e84SEric Joyner /* 2046*f2635e84SEric Joyner * VIRTCHNL_OP_HQOS_READ_TREE 2047*f2635e84SEric Joyner * VIRTCHNL_OP_HQOS_ELEM_ADD 2048*f2635e84SEric Joyner * VIRTCHNL_OP_HQOS_ELEM_DEL 2049*f2635e84SEric Joyner * VIRTCHNL_OP_HQOS_ELEM_BW_SET 2050*f2635e84SEric Joyner * List with tc and queus HW QoS values 2051*f2635e84SEric Joyner */ 2052*f2635e84SEric Joyner struct virtchnl_hqos_cfg { 2053*f2635e84SEric Joyner #define VIRTCHNL_HQOS_ELEM_TYPE_NODE 0 2054*f2635e84SEric Joyner #define VIRTCHNL_HQOS_ELEM_TYPE_LEAF 1 2055*f2635e84SEric Joyner u8 node_type; 2056*f2635e84SEric Joyner u8 pad[7]; 2057*f2635e84SEric Joyner u32 teid; 2058*f2635e84SEric Joyner u32 parent_teid; 2059*f2635e84SEric Joyner u64 tx_max; 2060*f2635e84SEric Joyner u64 tx_share; 2061*f2635e84SEric Joyner u32 tx_priority; 2062*f2635e84SEric Joyner u32 tx_weight; 2063*f2635e84SEric Joyner }; 2064*f2635e84SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_hqos_cfg); 2065*f2635e84SEric Joyner 2066*f2635e84SEric Joyner struct virtchnl_hqos_cfg_list { 2067*f2635e84SEric Joyner u16 num_elem; 2068*f2635e84SEric Joyner u8 pad[6]; 2069*f2635e84SEric Joyner struct virtchnl_hqos_cfg cfg[1]; 2070*f2635e84SEric Joyner }; 2071*f2635e84SEric Joyner VIRTCHNL_CHECK_STRUCT_LEN(48, virtchnl_hqos_cfg_list); 2072*f2635e84SEric Joyner 207371d10453SEric Joyner /* Since VF messages are limited by u16 size, precalculate the maximum possible 207471d10453SEric Joyner * values of nested elements in virtchnl structures that virtual channel can 207571d10453SEric Joyner * possibly handle in a single message. 207671d10453SEric Joyner */ 207771d10453SEric Joyner enum virtchnl_vector_limits { 207871d10453SEric Joyner VIRTCHNL_OP_CONFIG_VSI_QUEUES_MAX = 207971d10453SEric Joyner ((u16)(~0) - sizeof(struct virtchnl_vsi_queue_config_info)) / 208071d10453SEric Joyner sizeof(struct virtchnl_queue_pair_info), 208171d10453SEric Joyner 208271d10453SEric Joyner VIRTCHNL_OP_CONFIG_IRQ_MAP_MAX = 208371d10453SEric Joyner ((u16)(~0) - sizeof(struct virtchnl_irq_map_info)) / 208471d10453SEric Joyner sizeof(struct virtchnl_vector_map), 208571d10453SEric Joyner 208671d10453SEric Joyner VIRTCHNL_OP_ADD_DEL_ETH_ADDR_MAX = 208771d10453SEric Joyner ((u16)(~0) - sizeof(struct virtchnl_ether_addr_list)) / 208871d10453SEric Joyner sizeof(struct virtchnl_ether_addr), 208971d10453SEric Joyner 209071d10453SEric Joyner VIRTCHNL_OP_ADD_DEL_VLAN_MAX = 209171d10453SEric Joyner ((u16)(~0) - sizeof(struct virtchnl_vlan_filter_list)) / 209271d10453SEric Joyner sizeof(u16), 209371d10453SEric Joyner 209471d10453SEric Joyner VIRTCHNL_OP_ENABLE_CHANNELS_MAX = 209571d10453SEric Joyner ((u16)(~0) - sizeof(struct virtchnl_tc_info)) / 209671d10453SEric Joyner sizeof(struct virtchnl_channel_info), 209771d10453SEric Joyner 2098d08b8680SEric Joyner VIRTCHNL_OP_ENABLE_DISABLE_DEL_QUEUES_V2_MAX = 2099d08b8680SEric Joyner ((u16)(~0) - sizeof(struct virtchnl_del_ena_dis_queues)) / 2100d08b8680SEric Joyner sizeof(struct virtchnl_queue_chunk), 2101d08b8680SEric Joyner 2102d08b8680SEric Joyner VIRTCHNL_OP_MAP_UNMAP_QUEUE_VECTOR_MAX = 2103d08b8680SEric Joyner ((u16)(~0) - sizeof(struct virtchnl_queue_vector_maps)) / 2104d08b8680SEric Joyner sizeof(struct virtchnl_queue_vector), 21059cf1841cSEric Joyner 21069cf1841cSEric Joyner VIRTCHNL_OP_ADD_DEL_VLAN_V2_MAX = 21079cf1841cSEric Joyner ((u16)(~0) - sizeof(struct virtchnl_vlan_filter_list_v2)) / 21089cf1841cSEric Joyner sizeof(struct virtchnl_vlan_filter), 210971d10453SEric Joyner }; 211071d10453SEric Joyner 211171d10453SEric Joyner /** 211271d10453SEric Joyner * virtchnl_vc_validate_vf_msg 211371d10453SEric Joyner * @ver: Virtchnl version info 211471d10453SEric Joyner * @v_opcode: Opcode for the message 211571d10453SEric Joyner * @msg: pointer to the msg buffer 211671d10453SEric Joyner * @msglen: msg length 211771d10453SEric Joyner * 211871d10453SEric Joyner * validate msg format against struct for each opcode 211971d10453SEric Joyner */ 212071d10453SEric Joyner static inline int 212171d10453SEric Joyner virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode, 212271d10453SEric Joyner u8 *msg, u16 msglen) 212371d10453SEric Joyner { 212471d10453SEric Joyner bool err_msg_format = false; 21257d7af7f8SEric Joyner u32 valid_len = 0; 212671d10453SEric Joyner 212771d10453SEric Joyner /* Validate message length. */ 212871d10453SEric Joyner switch (v_opcode) { 212971d10453SEric Joyner case VIRTCHNL_OP_VERSION: 213071d10453SEric Joyner valid_len = sizeof(struct virtchnl_version_info); 213171d10453SEric Joyner break; 213271d10453SEric Joyner case VIRTCHNL_OP_RESET_VF: 213371d10453SEric Joyner break; 213471d10453SEric Joyner case VIRTCHNL_OP_GET_VF_RESOURCES: 213571d10453SEric Joyner if (VF_IS_V11(ver)) 213671d10453SEric Joyner valid_len = sizeof(u32); 213771d10453SEric Joyner break; 213871d10453SEric Joyner case VIRTCHNL_OP_CONFIG_TX_QUEUE: 213971d10453SEric Joyner valid_len = sizeof(struct virtchnl_txq_info); 214071d10453SEric Joyner break; 214171d10453SEric Joyner case VIRTCHNL_OP_CONFIG_RX_QUEUE: 214271d10453SEric Joyner valid_len = sizeof(struct virtchnl_rxq_info); 214371d10453SEric Joyner break; 214471d10453SEric Joyner case VIRTCHNL_OP_CONFIG_VSI_QUEUES: 214571d10453SEric Joyner valid_len = sizeof(struct virtchnl_vsi_queue_config_info); 214671d10453SEric Joyner if (msglen >= valid_len) { 214771d10453SEric Joyner struct virtchnl_vsi_queue_config_info *vqc = 214871d10453SEric Joyner (struct virtchnl_vsi_queue_config_info *)msg; 214971d10453SEric Joyner 215071d10453SEric Joyner if (vqc->num_queue_pairs == 0 || vqc->num_queue_pairs > 215171d10453SEric Joyner VIRTCHNL_OP_CONFIG_VSI_QUEUES_MAX) { 215271d10453SEric Joyner err_msg_format = true; 215371d10453SEric Joyner break; 215471d10453SEric Joyner } 215571d10453SEric Joyner 215671d10453SEric Joyner valid_len += (vqc->num_queue_pairs * 215771d10453SEric Joyner sizeof(struct 215871d10453SEric Joyner virtchnl_queue_pair_info)); 215971d10453SEric Joyner } 216071d10453SEric Joyner break; 216171d10453SEric Joyner case VIRTCHNL_OP_CONFIG_IRQ_MAP: 216271d10453SEric Joyner valid_len = sizeof(struct virtchnl_irq_map_info); 216371d10453SEric Joyner if (msglen >= valid_len) { 216471d10453SEric Joyner struct virtchnl_irq_map_info *vimi = 216571d10453SEric Joyner (struct virtchnl_irq_map_info *)msg; 216671d10453SEric Joyner 216771d10453SEric Joyner if (vimi->num_vectors == 0 || vimi->num_vectors > 216871d10453SEric Joyner VIRTCHNL_OP_CONFIG_IRQ_MAP_MAX) { 216971d10453SEric Joyner err_msg_format = true; 217071d10453SEric Joyner break; 217171d10453SEric Joyner } 217271d10453SEric Joyner 217371d10453SEric Joyner valid_len += (vimi->num_vectors * 217471d10453SEric Joyner sizeof(struct virtchnl_vector_map)); 217571d10453SEric Joyner } 217671d10453SEric Joyner break; 217771d10453SEric Joyner case VIRTCHNL_OP_ENABLE_QUEUES: 217871d10453SEric Joyner case VIRTCHNL_OP_DISABLE_QUEUES: 217971d10453SEric Joyner valid_len = sizeof(struct virtchnl_queue_select); 218071d10453SEric Joyner break; 2181d08b8680SEric Joyner case VIRTCHNL_OP_GET_MAX_RSS_QREGION: 2182d08b8680SEric Joyner break; 218371d10453SEric Joyner case VIRTCHNL_OP_ADD_ETH_ADDR: 218471d10453SEric Joyner case VIRTCHNL_OP_DEL_ETH_ADDR: 218571d10453SEric Joyner valid_len = sizeof(struct virtchnl_ether_addr_list); 218671d10453SEric Joyner if (msglen >= valid_len) { 218771d10453SEric Joyner struct virtchnl_ether_addr_list *veal = 218871d10453SEric Joyner (struct virtchnl_ether_addr_list *)msg; 218971d10453SEric Joyner 219071d10453SEric Joyner if (veal->num_elements == 0 || veal->num_elements > 219171d10453SEric Joyner VIRTCHNL_OP_ADD_DEL_ETH_ADDR_MAX) { 219271d10453SEric Joyner err_msg_format = true; 219371d10453SEric Joyner break; 219471d10453SEric Joyner } 219571d10453SEric Joyner 219671d10453SEric Joyner valid_len += veal->num_elements * 219771d10453SEric Joyner sizeof(struct virtchnl_ether_addr); 219871d10453SEric Joyner } 219971d10453SEric Joyner break; 220071d10453SEric Joyner case VIRTCHNL_OP_ADD_VLAN: 220171d10453SEric Joyner case VIRTCHNL_OP_DEL_VLAN: 220271d10453SEric Joyner valid_len = sizeof(struct virtchnl_vlan_filter_list); 220371d10453SEric Joyner if (msglen >= valid_len) { 220471d10453SEric Joyner struct virtchnl_vlan_filter_list *vfl = 220571d10453SEric Joyner (struct virtchnl_vlan_filter_list *)msg; 220671d10453SEric Joyner 220771d10453SEric Joyner if (vfl->num_elements == 0 || vfl->num_elements > 220871d10453SEric Joyner VIRTCHNL_OP_ADD_DEL_VLAN_MAX) { 220971d10453SEric Joyner err_msg_format = true; 221071d10453SEric Joyner break; 221171d10453SEric Joyner } 221271d10453SEric Joyner 221371d10453SEric Joyner valid_len += vfl->num_elements * sizeof(u16); 221471d10453SEric Joyner } 221571d10453SEric Joyner break; 221671d10453SEric Joyner case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE: 221771d10453SEric Joyner valid_len = sizeof(struct virtchnl_promisc_info); 221871d10453SEric Joyner break; 221971d10453SEric Joyner case VIRTCHNL_OP_GET_STATS: 222071d10453SEric Joyner valid_len = sizeof(struct virtchnl_queue_select); 222171d10453SEric Joyner break; 222271d10453SEric Joyner case VIRTCHNL_OP_CONFIG_RSS_KEY: 222371d10453SEric Joyner valid_len = sizeof(struct virtchnl_rss_key); 222471d10453SEric Joyner if (msglen >= valid_len) { 222571d10453SEric Joyner struct virtchnl_rss_key *vrk = 222671d10453SEric Joyner (struct virtchnl_rss_key *)msg; 222771d10453SEric Joyner 222871d10453SEric Joyner if (vrk->key_len == 0) { 222971d10453SEric Joyner /* zero length is allowed as input */ 223071d10453SEric Joyner break; 223171d10453SEric Joyner } 223271d10453SEric Joyner 223371d10453SEric Joyner valid_len += vrk->key_len - 1; 223471d10453SEric Joyner } 223571d10453SEric Joyner break; 223671d10453SEric Joyner case VIRTCHNL_OP_CONFIG_RSS_LUT: 223771d10453SEric Joyner valid_len = sizeof(struct virtchnl_rss_lut); 223871d10453SEric Joyner if (msglen >= valid_len) { 223971d10453SEric Joyner struct virtchnl_rss_lut *vrl = 224071d10453SEric Joyner (struct virtchnl_rss_lut *)msg; 224171d10453SEric Joyner 224271d10453SEric Joyner if (vrl->lut_entries == 0) { 224371d10453SEric Joyner /* zero entries is allowed as input */ 224471d10453SEric Joyner break; 224571d10453SEric Joyner } 224671d10453SEric Joyner 224771d10453SEric Joyner valid_len += vrl->lut_entries - 1; 224871d10453SEric Joyner } 224971d10453SEric Joyner break; 225071d10453SEric Joyner case VIRTCHNL_OP_GET_RSS_HENA_CAPS: 225171d10453SEric Joyner break; 225271d10453SEric Joyner case VIRTCHNL_OP_SET_RSS_HENA: 225371d10453SEric Joyner valid_len = sizeof(struct virtchnl_rss_hena); 225471d10453SEric Joyner break; 225571d10453SEric Joyner case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING: 225671d10453SEric Joyner case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING: 225771d10453SEric Joyner break; 225871d10453SEric Joyner case VIRTCHNL_OP_REQUEST_QUEUES: 225971d10453SEric Joyner valid_len = sizeof(struct virtchnl_vf_res_request); 226071d10453SEric Joyner break; 226171d10453SEric Joyner case VIRTCHNL_OP_ENABLE_CHANNELS: 226271d10453SEric Joyner valid_len = sizeof(struct virtchnl_tc_info); 226371d10453SEric Joyner if (msglen >= valid_len) { 226471d10453SEric Joyner struct virtchnl_tc_info *vti = 226571d10453SEric Joyner (struct virtchnl_tc_info *)msg; 226671d10453SEric Joyner 226771d10453SEric Joyner if (vti->num_tc == 0 || vti->num_tc > 226871d10453SEric Joyner VIRTCHNL_OP_ENABLE_CHANNELS_MAX) { 226971d10453SEric Joyner err_msg_format = true; 227071d10453SEric Joyner break; 227171d10453SEric Joyner } 227271d10453SEric Joyner 227371d10453SEric Joyner valid_len += (vti->num_tc - 1) * 227471d10453SEric Joyner sizeof(struct virtchnl_channel_info); 227571d10453SEric Joyner } 227671d10453SEric Joyner break; 227771d10453SEric Joyner case VIRTCHNL_OP_DISABLE_CHANNELS: 227871d10453SEric Joyner break; 227971d10453SEric Joyner case VIRTCHNL_OP_ADD_CLOUD_FILTER: 228071d10453SEric Joyner case VIRTCHNL_OP_DEL_CLOUD_FILTER: 228171d10453SEric Joyner valid_len = sizeof(struct virtchnl_filter); 228271d10453SEric Joyner break; 228356429daeSEric Joyner case VIRTCHNL_OP_ADD_RSS_CFG: 228456429daeSEric Joyner case VIRTCHNL_OP_DEL_RSS_CFG: 228556429daeSEric Joyner valid_len = sizeof(struct virtchnl_rss_cfg); 228656429daeSEric Joyner break; 228756429daeSEric Joyner case VIRTCHNL_OP_ADD_FDIR_FILTER: 228856429daeSEric Joyner valid_len = sizeof(struct virtchnl_fdir_add); 228956429daeSEric Joyner break; 229056429daeSEric Joyner case VIRTCHNL_OP_DEL_FDIR_FILTER: 229156429daeSEric Joyner valid_len = sizeof(struct virtchnl_fdir_del); 229256429daeSEric Joyner break; 22939dc2f6e2SEric Joyner case VIRTCHNL_OP_FLOW_SUBSCRIBE: 22949dc2f6e2SEric Joyner valid_len = sizeof(struct virtchnl_flow_sub); 22959dc2f6e2SEric Joyner break; 22969dc2f6e2SEric Joyner case VIRTCHNL_OP_FLOW_UNSUBSCRIBE: 22979dc2f6e2SEric Joyner valid_len = sizeof(struct virtchnl_flow_unsub); 22989dc2f6e2SEric Joyner break; 229956429daeSEric Joyner case VIRTCHNL_OP_GET_QOS_CAPS: 230056429daeSEric Joyner break; 230156429daeSEric Joyner case VIRTCHNL_OP_CONFIG_QUEUE_TC_MAP: 230256429daeSEric Joyner valid_len = sizeof(struct virtchnl_queue_tc_mapping); 230356429daeSEric Joyner if (msglen >= valid_len) { 230456429daeSEric Joyner struct virtchnl_queue_tc_mapping *q_tc = 230556429daeSEric Joyner (struct virtchnl_queue_tc_mapping *)msg; 230656429daeSEric Joyner if (q_tc->num_tc == 0) { 230756429daeSEric Joyner err_msg_format = true; 230856429daeSEric Joyner break; 230956429daeSEric Joyner } 231056429daeSEric Joyner valid_len += (q_tc->num_tc - 1) * 231156429daeSEric Joyner sizeof(q_tc->tc[0]); 231256429daeSEric Joyner } 231356429daeSEric Joyner break; 23148923de59SPiotr Kubaj case VIRTCHNL_OP_CONFIG_QUEUE_BW: 23158923de59SPiotr Kubaj valid_len = sizeof(struct virtchnl_queues_bw_cfg); 23168923de59SPiotr Kubaj if (msglen >= valid_len) { 23178923de59SPiotr Kubaj struct virtchnl_queues_bw_cfg *q_bw = 23188923de59SPiotr Kubaj (struct virtchnl_queues_bw_cfg *)msg; 23198923de59SPiotr Kubaj if (q_bw->num_queues == 0) { 23208923de59SPiotr Kubaj err_msg_format = true; 23218923de59SPiotr Kubaj break; 23228923de59SPiotr Kubaj } 23238923de59SPiotr Kubaj valid_len += (q_bw->num_queues - 1) * 23248923de59SPiotr Kubaj sizeof(q_bw->cfg[0]); 23258923de59SPiotr Kubaj } 23268923de59SPiotr Kubaj break; 23278923de59SPiotr Kubaj case VIRTCHNL_OP_CONFIG_QUANTA: 23288923de59SPiotr Kubaj valid_len = sizeof(struct virtchnl_quanta_cfg); 23298923de59SPiotr Kubaj if (msglen >= valid_len) { 23308923de59SPiotr Kubaj struct virtchnl_quanta_cfg *q_quanta = 23318923de59SPiotr Kubaj (struct virtchnl_quanta_cfg *)msg; 23328923de59SPiotr Kubaj if (q_quanta->quanta_size == 0 || 23338923de59SPiotr Kubaj q_quanta->queue_select.num_queues == 0) { 23348923de59SPiotr Kubaj err_msg_format = true; 23358923de59SPiotr Kubaj break; 23368923de59SPiotr Kubaj } 23378923de59SPiotr Kubaj } 23388923de59SPiotr Kubaj break; 23399cf1841cSEric Joyner case VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS: 23409cf1841cSEric Joyner break; 23419cf1841cSEric Joyner case VIRTCHNL_OP_ADD_VLAN_V2: 23429cf1841cSEric Joyner case VIRTCHNL_OP_DEL_VLAN_V2: 23439cf1841cSEric Joyner valid_len = sizeof(struct virtchnl_vlan_filter_list_v2); 23449cf1841cSEric Joyner if (msglen >= valid_len) { 23459cf1841cSEric Joyner struct virtchnl_vlan_filter_list_v2 *vfl = 23469cf1841cSEric Joyner (struct virtchnl_vlan_filter_list_v2 *)msg; 23479cf1841cSEric Joyner 23489cf1841cSEric Joyner if (vfl->num_elements == 0 || vfl->num_elements > 23499cf1841cSEric Joyner VIRTCHNL_OP_ADD_DEL_VLAN_V2_MAX) { 23509cf1841cSEric Joyner err_msg_format = true; 23519cf1841cSEric Joyner break; 23529cf1841cSEric Joyner } 23539cf1841cSEric Joyner 23549cf1841cSEric Joyner valid_len += (vfl->num_elements - 1) * 23559cf1841cSEric Joyner sizeof(struct virtchnl_vlan_filter); 23569cf1841cSEric Joyner } 23579cf1841cSEric Joyner break; 23589cf1841cSEric Joyner case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2: 23599cf1841cSEric Joyner case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2: 23609cf1841cSEric Joyner case VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2: 23619cf1841cSEric Joyner case VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2: 23629cf1841cSEric Joyner case VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2: 23639cf1841cSEric Joyner case VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2: 23649cf1841cSEric Joyner valid_len = sizeof(struct virtchnl_vlan_setting); 23659cf1841cSEric Joyner break; 2366d08b8680SEric Joyner case VIRTCHNL_OP_ENABLE_QUEUES_V2: 2367d08b8680SEric Joyner case VIRTCHNL_OP_DISABLE_QUEUES_V2: 2368d08b8680SEric Joyner valid_len = sizeof(struct virtchnl_del_ena_dis_queues); 2369d08b8680SEric Joyner if (msglen >= valid_len) { 2370d08b8680SEric Joyner struct virtchnl_del_ena_dis_queues *qs = 2371d08b8680SEric Joyner (struct virtchnl_del_ena_dis_queues *)msg; 2372d08b8680SEric Joyner if (qs->chunks.num_chunks == 0 || 2373d08b8680SEric Joyner qs->chunks.num_chunks > VIRTCHNL_OP_ENABLE_DISABLE_DEL_QUEUES_V2_MAX) { 2374d08b8680SEric Joyner err_msg_format = true; 2375d08b8680SEric Joyner break; 2376d08b8680SEric Joyner } 2377d08b8680SEric Joyner valid_len += (qs->chunks.num_chunks - 1) * 2378d08b8680SEric Joyner sizeof(struct virtchnl_queue_chunk); 2379d08b8680SEric Joyner } 2380d08b8680SEric Joyner break; 2381d08b8680SEric Joyner case VIRTCHNL_OP_MAP_QUEUE_VECTOR: 2382d08b8680SEric Joyner valid_len = sizeof(struct virtchnl_queue_vector_maps); 2383d08b8680SEric Joyner if (msglen >= valid_len) { 2384d08b8680SEric Joyner struct virtchnl_queue_vector_maps *v_qp = 2385d08b8680SEric Joyner (struct virtchnl_queue_vector_maps *)msg; 2386d08b8680SEric Joyner if (v_qp->num_qv_maps == 0 || 2387d08b8680SEric Joyner v_qp->num_qv_maps > VIRTCHNL_OP_MAP_UNMAP_QUEUE_VECTOR_MAX) { 2388d08b8680SEric Joyner err_msg_format = true; 2389d08b8680SEric Joyner break; 2390d08b8680SEric Joyner } 2391d08b8680SEric Joyner valid_len += (v_qp->num_qv_maps - 1) * 2392d08b8680SEric Joyner sizeof(struct virtchnl_queue_vector); 2393d08b8680SEric Joyner } 2394d08b8680SEric Joyner break; 239571d10453SEric Joyner /* These are always errors coming from the VF. */ 239671d10453SEric Joyner case VIRTCHNL_OP_EVENT: 239771d10453SEric Joyner case VIRTCHNL_OP_UNKNOWN: 239871d10453SEric Joyner default: 239971d10453SEric Joyner return VIRTCHNL_STATUS_ERR_PARAM; 240071d10453SEric Joyner } 240171d10453SEric Joyner /* few more checks */ 240271d10453SEric Joyner if (err_msg_format || valid_len != msglen) 240371d10453SEric Joyner return VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH; 240471d10453SEric Joyner 240571d10453SEric Joyner return 0; 240671d10453SEric Joyner } 240771d10453SEric Joyner #endif /* _VIRTCHNL_H_ */ 2408