Print this page
XXXXX update i40e Intel code to 1.12.16
        (includes: Restore 9601 & 13041, fix one header file)

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/i40e/core/virtchnl.h
          +++ new/usr/src/uts/common/io/i40e/core/virtchnl.h
   1    1  /******************************************************************************
   2    2  
   3      -  Copyright (c) 2013-2018, Intel Corporation
        3 +  Copyright (c) 2013-2019, Intel Corporation
   4    4    All rights reserved.
   5    5  
   6    6    Redistribution and use in source and binary forms, with or without
   7    7    modification, are permitted provided that the following conditions are met:
   8    8  
   9    9     1. Redistributions of source code must retain the above copyright notice,
  10   10        this list of conditions and the following disclaimer.
  11   11  
  12   12     2. Redistributions in binary form must reproduce the above copyright
  13   13        notice, this list of conditions and the following disclaimer in the
↓ open down ↓ 11 lines elided ↑ open up ↑
  25   25    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  26   26    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  27   27    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  28   28    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29   29    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  30   30    POSSIBILITY OF SUCH DAMAGE.
  31   31  
  32   32  ******************************************************************************/
  33   33  /*$FreeBSD$*/
  34   34  
       35 +
  35   36  #ifndef _VIRTCHNL_H_
  36   37  #define _VIRTCHNL_H_
  37   38  
  38   39  /* Description:
  39      - * This header file describes the VF-PF communication protocol used
  40      - * by the drivers for all devices starting from our 40G product line
       40 + * This header file describes the Virtual Function (VF) - Physical Function
       41 + * (PF) communication protocol used by the drivers for all devices starting
       42 + * from our 40G product line
  41   43   *
  42   44   * Admin queue buffer usage:
  43   45   * desc->opcode is always aqc_opc_send_msg_to_pf
  44   46   * flags, retval, datalen, and data addr are all used normally.
  45   47   * The Firmware copies the cookie fields when sending messages between the
  46   48   * PF and VF, but uses all other fields internally. Due to this limitation,
  47   49   * we must send all messages as "indirect", i.e. using an external buffer.
  48   50   *
  49   51   * All the VSI indexes are relative to the VF. Each VF can have maximum of
  50   52   * three VSIs. All the queue indexes are relative to the VSI.  Each VF can
  51   53   * have a maximum of sixteen queues for all of its VSIs.
  52   54   *
  53   55   * The PF is required to return a status code in v_retval for all messages
  54      - * except RESET_VF, which does not require any response. The return value
  55      - * is of status_code type, defined in the shared type.h.
       56 + * except RESET_VF, which does not require any response. The returned value
       57 + * is of virtchnl_status_code type, defined in the shared type.h.
  56   58   *
  57   59   * In general, VF driver initialization should roughly follow the order of
  58   60   * these opcodes. The VF driver must first validate the API version of the
  59   61   * PF driver, then request a reset, then get resources, then configure
  60   62   * queues and interrupts. After these operations are complete, the VF
  61   63   * driver may start its queues, optionally add MAC and VLAN filters, and
  62   64   * process traffic.
  63   65   */
  64   66  
  65   67  /* START GENERIC DEFINES
  66   68   * Need to ensure the following enums and defines hold the same meaning and
  67   69   * value in current and future projects
  68   70   */
  69   71  
       72 +
  70   73  /* Error Codes */
  71   74  enum virtchnl_status_code {
  72   75          VIRTCHNL_STATUS_SUCCESS                         = 0,
  73      -        VIRTCHNL_ERR_PARAM                              = -5,
       76 +        VIRTCHNL_STATUS_ERR_PARAM                       = -5,
       77 +        VIRTCHNL_STATUS_ERR_NO_MEMORY                   = -18,
  74   78          VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH             = -38,
  75   79          VIRTCHNL_STATUS_ERR_CQP_COMPL_ERROR             = -39,
  76   80          VIRTCHNL_STATUS_ERR_INVALID_VF_ID               = -40,
  77      -        VIRTCHNL_STATUS_NOT_SUPPORTED                   = -64,
       81 +        VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR           = -53,
       82 +        VIRTCHNL_STATUS_ERR_NOT_SUPPORTED               = -64,
  78   83  };
  79   84  
       85 +/* Backward compatibility */
       86 +#define VIRTCHNL_ERR_PARAM VIRTCHNL_STATUS_ERR_PARAM
       87 +#define VIRTCHNL_STATUS_NOT_SUPPORTED VIRTCHNL_STATUS_ERR_NOT_SUPPORTED
       88 +
  80   89  #define VIRTCHNL_LINK_SPEED_2_5GB_SHIFT         0x0
  81   90  #define VIRTCHNL_LINK_SPEED_100MB_SHIFT         0x1
  82   91  #define VIRTCHNL_LINK_SPEED_1000MB_SHIFT        0x2
  83   92  #define VIRTCHNL_LINK_SPEED_10GB_SHIFT          0x3
  84   93  #define VIRTCHNL_LINK_SPEED_40GB_SHIFT          0x4
  85   94  #define VIRTCHNL_LINK_SPEED_20GB_SHIFT          0x5
  86   95  #define VIRTCHNL_LINK_SPEED_25GB_SHIFT          0x6
  87   96  #define VIRTCHNL_LINK_SPEED_5GB_SHIFT           0x7
  88   97  
  89   98  enum virtchnl_link_speed {
↓ open down ↓ 42 lines elided ↑ open up ↑
 132  141          VIRTCHNL_OP_ENABLE_QUEUES = 8,
 133  142          VIRTCHNL_OP_DISABLE_QUEUES = 9,
 134  143          VIRTCHNL_OP_ADD_ETH_ADDR = 10,
 135  144          VIRTCHNL_OP_DEL_ETH_ADDR = 11,
 136  145          VIRTCHNL_OP_ADD_VLAN = 12,
 137  146          VIRTCHNL_OP_DEL_VLAN = 13,
 138  147          VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE = 14,
 139  148          VIRTCHNL_OP_GET_STATS = 15,
 140  149          VIRTCHNL_OP_RSVD = 16,
 141  150          VIRTCHNL_OP_EVENT = 17, /* must ALWAYS be 17 */
      151 +        /* opcode 19 is reserved */
 142  152          VIRTCHNL_OP_IWARP = 20, /* advanced opcode */
 143  153          VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP = 21, /* advanced opcode */
 144  154          VIRTCHNL_OP_RELEASE_IWARP_IRQ_MAP = 22, /* advanced opcode */
 145  155          VIRTCHNL_OP_CONFIG_RSS_KEY = 23,
 146  156          VIRTCHNL_OP_CONFIG_RSS_LUT = 24,
 147  157          VIRTCHNL_OP_GET_RSS_HENA_CAPS = 25,
 148  158          VIRTCHNL_OP_SET_RSS_HENA = 26,
 149  159          VIRTCHNL_OP_ENABLE_VLAN_STRIPPING = 27,
 150  160          VIRTCHNL_OP_DISABLE_VLAN_STRIPPING = 28,
 151  161          VIRTCHNL_OP_REQUEST_QUEUES = 29,
 152      -
      162 +        VIRTCHNL_OP_ENABLE_CHANNELS = 30,
      163 +        VIRTCHNL_OP_DISABLE_CHANNELS = 31,
      164 +        VIRTCHNL_OP_ADD_CLOUD_FILTER = 32,
      165 +        VIRTCHNL_OP_DEL_CLOUD_FILTER = 33,
      166 +        /* opcode 34 is reserved */
      167 +        /* opcodes 38, 39, 40, 41, 42 and 43 are reserved */
      168 +        /* opcode 44 is reserved */
      169 +        /* opcode 45, 46, 47, 48 and 49 are reserved */
      170 +        VIRTCHNL_OP_GET_MAX_RSS_QREGION = 50,
      171 +        VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS = 51,
      172 +        VIRTCHNL_OP_ADD_VLAN_V2 = 52,
      173 +        VIRTCHNL_OP_DEL_VLAN_V2 = 53,
      174 +        VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 = 54,
      175 +        VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 = 55,
      176 +        VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 = 56,
      177 +        VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2 = 57,
      178 +        VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2 = 58,
      179 +        VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2 = 59,
      180 +        /* opcodes 60 through 69 are reserved */
      181 +        VIRTCHNL_OP_ENABLE_QUEUES_V2 = 107,
      182 +        VIRTCHNL_OP_DISABLE_QUEUES_V2 = 108,
      183 +        VIRTCHNL_OP_MAP_QUEUE_VECTOR = 111,
      184 +        VIRTCHNL_OP_MAX,
 153  185  };
 154  186  
 155      -/* This macro is used to generate a compilation error if a structure
      187 +static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)
      188 +{
      189 +        switch (v_opcode) {
      190 +        case VIRTCHNL_OP_UNKNOWN:
      191 +                return "VIRTCHNL_OP_UNKNOWN";
      192 +        case VIRTCHNL_OP_VERSION:
      193 +                return "VIRTCHNL_OP_VERSION";
      194 +        case VIRTCHNL_OP_RESET_VF:
      195 +                return "VIRTCHNL_OP_RESET_VF";
      196 +        case VIRTCHNL_OP_GET_VF_RESOURCES:
      197 +                return "VIRTCHNL_OP_GET_VF_RESOURCES";
      198 +        case VIRTCHNL_OP_CONFIG_TX_QUEUE:
      199 +                return "VIRTCHNL_OP_CONFIG_TX_QUEUE";
      200 +        case VIRTCHNL_OP_CONFIG_RX_QUEUE:
      201 +                return "VIRTCHNL_OP_CONFIG_RX_QUEUE";
      202 +        case VIRTCHNL_OP_CONFIG_VSI_QUEUES:
      203 +                return "VIRTCHNL_OP_CONFIG_VSI_QUEUES";
      204 +        case VIRTCHNL_OP_CONFIG_IRQ_MAP:
      205 +                return "VIRTCHNL_OP_CONFIG_IRQ_MAP";
      206 +        case VIRTCHNL_OP_ENABLE_QUEUES:
      207 +                return "VIRTCHNL_OP_ENABLE_QUEUES";
      208 +        case VIRTCHNL_OP_DISABLE_QUEUES:
      209 +                return "VIRTCHNL_OP_DISABLE_QUEUES";
      210 +        case VIRTCHNL_OP_ADD_ETH_ADDR:
      211 +                return "VIRTCHNL_OP_ADD_ETH_ADDR";
      212 +        case VIRTCHNL_OP_DEL_ETH_ADDR:
      213 +                return "VIRTCHNL_OP_DEL_ETH_ADDR";
      214 +        case VIRTCHNL_OP_ADD_VLAN:
      215 +                return "VIRTCHNL_OP_ADD_VLAN";
      216 +        case VIRTCHNL_OP_DEL_VLAN:
      217 +                return "VIRTCHNL_OP_DEL_VLAN";
      218 +        case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE:
      219 +                return "VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE";
      220 +        case VIRTCHNL_OP_GET_STATS:
      221 +                return "VIRTCHNL_OP_GET_STATS";
      222 +        case VIRTCHNL_OP_RSVD:
      223 +                return "VIRTCHNL_OP_RSVD";
      224 +        case VIRTCHNL_OP_EVENT:
      225 +                return "VIRTCHNL_OP_EVENT";
      226 +        case VIRTCHNL_OP_IWARP:
      227 +                return "VIRTCHNL_OP_IWARP";
      228 +        case VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP:
      229 +                return "VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP:";
      230 +        case VIRTCHNL_OP_RELEASE_IWARP_IRQ_MAP:
      231 +                return "VIRTCHNL_OP_RELEASE_IWARP_IRQ_MAP";
      232 +        case VIRTCHNL_OP_CONFIG_RSS_KEY:
      233 +                return "VIRTCHNL_OP_CONFIG_RSS_KEY";
      234 +        case VIRTCHNL_OP_CONFIG_RSS_LUT:
      235 +                return "VIRTCHNL_OP_CONFIG_RSS_LUT";
      236 +        case VIRTCHNL_OP_GET_RSS_HENA_CAPS:
      237 +                return "VIRTCHNL_OP_GET_RSS_HENA_CAPS";
      238 +        case VIRTCHNL_OP_SET_RSS_HENA:
      239 +                return "VIRTCHNL_OP_SET_RSS_HENA";
      240 +        case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING:
      241 +                return "VIRTCHNL_OP_ENABLE_VLAN_STRIPPING";
      242 +        case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING:
      243 +                return "VIRTCHNL_OP_DISABLE_VLAN_STRIPPING";
      244 +        case VIRTCHNL_OP_REQUEST_QUEUES:
      245 +                return "VIRTCHNL_OP_REQUEST_QUEUES";
      246 +        case VIRTCHNL_OP_ENABLE_CHANNELS:
      247 +                return "VIRTCHNL_OP_ENABLE_CHANNELS";
      248 +        case VIRTCHNL_OP_DISABLE_CHANNELS:
      249 +                return "VIRTCHNL_OP_DISABLE_CHANNELS";
      250 +        case VIRTCHNL_OP_ADD_CLOUD_FILTER:
      251 +                return "VIRTCHNL_OP_ADD_CLOUD_FILTER";
      252 +        case VIRTCHNL_OP_DEL_CLOUD_FILTER:
      253 +                return "VIRTCHNL_OP_DEL_CLOUD_FILTER";
      254 +        case VIRTCHNL_OP_GET_MAX_RSS_QREGION:
      255 +                return "VIRTCHNL_OP_GET_MAX_RSS_QREGION";
      256 +        case VIRTCHNL_OP_ENABLE_QUEUES_V2:
      257 +                return "VIRTCHNL_OP_ENABLE_QUEUES_V2";
      258 +        case VIRTCHNL_OP_DISABLE_QUEUES_V2:
      259 +                return "VIRTCHNL_OP_DISABLE_QUEUES_V2";
      260 +        case VIRTCHNL_OP_MAP_QUEUE_VECTOR:
      261 +                return "VIRTCHNL_OP_MAP_QUEUE_VECTOR";
      262 +        case VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS:
      263 +                return "VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS";
      264 +        case VIRTCHNL_OP_ADD_VLAN_V2:
      265 +                return "VIRTCHNL_OP_ADD_VLAN_V2";
      266 +        case VIRTCHNL_OP_DEL_VLAN_V2:
      267 +                return "VIRTCHNL_OP_DEL_VLAN_V2";
      268 +        case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2:
      269 +                return "VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2";
      270 +        case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2:
      271 +                return "VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2";
      272 +        case VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2:
      273 +                return "VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2";
      274 +        case VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2:
      275 +                return "VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2";
      276 +        case VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2:
      277 +                return "VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2";
      278 +        case VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2:
      279 +                return "VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2";
      280 +        case VIRTCHNL_OP_MAX:
      281 +                return "VIRTCHNL_OP_MAX";
      282 +        default:
      283 +                return "Unsupported (update virtchnl.h)";
      284 +        }
      285 +}
      286 +
      287 +/* These macros are used to generate compilation errors if a structure/union
 156  288   * is not exactly the correct length. It gives a divide by zero error if the
 157      - * structure is not of the correct size, otherwise it creates an enum that is
 158      - * never used.
      289 + * structure/union is not of the correct size, otherwise it creates an enum
      290 + * that is never used.
 159  291   */
 160  292  #define VIRTCHNL_CHECK_STRUCT_LEN(n, X) enum virtchnl_static_assert_enum_##X \
 161      -        {virtchnl_static_assert_##X = (n) / ((sizeof(struct X) == (n)) ? 1 : 0)}
      293 +        { virtchnl_static_assert_##X = (n)/((sizeof(struct X) == (n)) ? 1 : 0) }
      294 +#define VIRTCHNL_CHECK_UNION_LEN(n, X) enum virtchnl_static_asset_enum_##X \
      295 +        { virtchnl_static_assert_##X = (n)/((sizeof(union X) == (n)) ? 1 : 0) }
 162  296  
 163  297  /* Virtual channel message descriptor. This overlays the admin queue
 164  298   * descriptor. All other data is passed in external buffers.
 165  299   */
 166  300  
 167  301  struct virtchnl_msg {
 168  302          u8 pad[8];                       /* AQ flags/opcode/len/retval fields */
 169      -        enum virtchnl_ops v_opcode; /* avoid confusion with desc->opcode */
 170      -        enum virtchnl_status_code v_retval;  /* ditto for desc->retval */
      303 +
      304 +        /* avoid confusion with desc->opcode */
      305 +        enum virtchnl_ops v_opcode;
      306 +
      307 +        /* ditto for desc->retval */
      308 +        enum virtchnl_status_code v_retval;
 171  309          u32 vfid;                        /* used by PF when sending to VF */
 172  310  };
 173  311  
 174  312  VIRTCHNL_CHECK_STRUCT_LEN(20, virtchnl_msg);
 175  313  
 176      -/* Message descriptions and data structures.*/
      314 +/* Message descriptions and data structures. */
 177  315  
 178  316  /* VIRTCHNL_OP_VERSION
 179  317   * VF posts its version number to the PF. PF responds with its version number
 180  318   * in the same format, along with a return code.
 181  319   * Reply from PF has its major/minor versions also in param0 and param1.
 182  320   * If there is a major version mismatch, then the VF cannot operate.
 183  321   * If there is a minor version mismatch, then the VF can operate but should
 184  322   * add a warning to the system log.
 185  323   *
 186  324   * This enum element MUST always be specified as == 1, regardless of other
 187  325   * changes in the API. The PF must always respond to this message without
 188  326   * error regardless of version mismatch.
 189  327   */
 190  328  #define VIRTCHNL_VERSION_MAJOR          1
 191  329  #define VIRTCHNL_VERSION_MINOR          1
      330 +#define VIRTCHNL_VERSION_MAJOR_2        2
      331 +#define VIRTCHNL_VERSION_MINOR_0        0
 192  332  #define VIRTCHNL_VERSION_MINOR_NO_VF_CAPS       0
 193  333  
 194  334  struct virtchnl_version_info {
 195  335          u32 major;
 196  336          u32 minor;
 197  337  };
 198  338  
 199  339  VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_version_info);
 200  340  
 201  341  #define VF_IS_V10(_v) (((_v)->major == 1) && ((_v)->minor == 0))
↓ open down ↓ 24 lines elided ↑ open up ↑
 226  366   * Version 1.0 VF sends this request to PF with no parameters
 227  367   * Version 1.1 VF sends this request to PF with u32 bitmap of its capabilities
 228  368   * PF responds with an indirect message containing
 229  369   * virtchnl_vf_resource and one or more
 230  370   * virtchnl_vsi_resource structures.
 231  371   */
 232  372  
 233  373  struct virtchnl_vsi_resource {
 234  374          u16 vsi_id;
 235  375          u16 num_queue_pairs;
 236      -        enum virtchnl_vsi_type vsi_type;
      376 +
      377 +        /* see enum virtchnl_vsi_type */
      378 +        s32 vsi_type;
 237  379          u16 qset_handle;
 238  380          u8 default_mac_addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
 239  381  };
 240  382  
 241  383  VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
 242  384  
 243  385  /* VF capability flags
 244  386   * VIRTCHNL_VF_OFFLOAD_L2 flag is inclusive of base mode L2 offloads including
 245  387   * TX/RX Checksum offloading and TSO for non-tunnelled packets.
 246  388   */
 247  389  #define VIRTCHNL_VF_OFFLOAD_L2                  0x00000001
 248  390  #define VIRTCHNL_VF_OFFLOAD_IWARP               0x00000002
 249  391  #define VIRTCHNL_VF_OFFLOAD_RSVD                0x00000004
 250  392  #define VIRTCHNL_VF_OFFLOAD_RSS_AQ              0x00000008
 251  393  #define VIRTCHNL_VF_OFFLOAD_RSS_REG             0x00000010
 252  394  #define VIRTCHNL_VF_OFFLOAD_WB_ON_ITR           0x00000020
 253  395  #define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES          0x00000040
      396 +#define VIRTCHNL_VF_OFFLOAD_CRC                 0x00000080
      397 +        /* 0X00000100 is reserved */
      398 +#define VIRTCHNL_VF_LARGE_NUM_QPAIRS            0x00000200
      399 +#define VIRTCHNL_VF_OFFLOAD_VLAN_V2             0x00008000
 254  400  #define VIRTCHNL_VF_OFFLOAD_VLAN                0x00010000
 255  401  #define VIRTCHNL_VF_OFFLOAD_RX_POLLING          0x00020000
 256  402  #define VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2       0x00040000
 257  403  #define VIRTCHNL_VF_OFFLOAD_RSS_PF              0X00080000
 258  404  #define VIRTCHNL_VF_OFFLOAD_ENCAP               0X00100000
 259  405  #define VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM          0X00200000
 260  406  #define VIRTCHNL_VF_OFFLOAD_RX_ENCAP_CSUM       0X00400000
      407 +#define VIRTCHNL_VF_OFFLOAD_ADQ                 0X00800000
      408 +#define VIRTCHNL_VF_OFFLOAD_ADQ_V2              0X01000000
      409 +#define VIRTCHNL_VF_OFFLOAD_USO                 0X02000000
      410 +        /* 0x04000000 is reserved */
      411 +        /* 0X08000000 and 0X10000000 are reserved */
      412 +        /* 0X20000000 is reserved */
      413 +        /* 0X40000000 is reserved */
      414 +        /* 0X80000000 is reserved */
 261  415  
      416 +/* Define below the capability flags that are not offloads */
      417 +#define VIRTCHNL_VF_CAP_ADV_LINK_SPEED          0x00000080
 262  418  #define VF_BASE_MODE_OFFLOADS (VIRTCHNL_VF_OFFLOAD_L2 | \
 263  419                                 VIRTCHNL_VF_OFFLOAD_VLAN | \
 264  420                                 VIRTCHNL_VF_OFFLOAD_RSS_PF)
 265  421  
 266  422  struct virtchnl_vf_resource {
 267  423          u16 num_vsis;
 268  424          u16 num_queue_pairs;
 269  425          u16 max_vectors;
 270  426          u16 max_mtu;
 271  427  
↓ open down ↓ 20 lines elided ↑ open up ↑
 292  448          u16 headwb_enabled; /* deprecated with AVF 1.0 */
 293  449          u64 dma_ring_addr;
 294  450          u64 dma_headwb_addr; /* deprecated with AVF 1.0 */
 295  451  };
 296  452  
 297  453  VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_txq_info);
 298  454  
 299  455  /* VIRTCHNL_OP_CONFIG_RX_QUEUE
 300  456   * VF sends this message to set up parameters for one RX queue.
 301  457   * External data buffer contains one instance of virtchnl_rxq_info.
 302      - * PF configures requested queue and returns a status code.
      458 + * PF configures requested queue and returns a status code. The
      459 + * crc_disable flag disables CRC stripping on the VF. Setting
      460 + * the crc_disable flag to 1 will disable CRC stripping for each
      461 + * queue in the VF where the flag is set. The VIRTCHNL_VF_OFFLOAD_CRC
      462 + * offload must have been set prior to sending this info or the PF
      463 + * will ignore the request. This flag should be set the same for
      464 + * all of the queues for a VF.
 303  465   */
 304  466  
 305  467  /* Rx queue config info */
 306  468  struct virtchnl_rxq_info {
 307  469          u16 vsi_id;
 308  470          u16 queue_id;
 309  471          u32 ring_len;           /* number of descriptors, multiple of 32 */
 310  472          u16 hdr_size;
 311  473          u16 splithdr_enabled; /* deprecated with AVF 1.0 */
 312  474          u32 databuffer_size;
 313  475          u32 max_pkt_size;
 314      -        u32 pad1;
      476 +        u8 crc_disable;
      477 +        u8 pad1[3];
 315  478          u64 dma_ring_addr;
 316      -        enum virtchnl_rx_hsplit rx_split_pos; /* deprecated with AVF 1.0 */
      479 +
      480 +        /* see enum virtchnl_rx_hsplit; deprecated with AVF 1.0 */
      481 +        s32 rx_split_pos;
 317  482          u32 pad2;
 318  483  };
 319  484  
 320  485  VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_rxq_info);
 321  486  
 322  487  /* VIRTCHNL_OP_CONFIG_VSI_QUEUES
 323      - * VF sends this message to set parameters for all active TX and RX queues
      488 + * VF sends this message to set parameters for active TX and RX queues
 324  489   * associated with the specified VSI.
 325  490   * PF configures queues and returns status.
 326  491   * If the number of queues specified is greater than the number of queues
 327  492   * associated with the VSI, an error is returned and no queues are configured.
      493 + * NOTE: The VF is not required to configure all queues in a single request.
      494 + * It may send multiple messages. PF drivers must correctly handle all VF
      495 + * requests.
 328  496   */
 329  497  struct virtchnl_queue_pair_info {
 330  498          /* NOTE: vsi_id and queue_id should be identical for both queues. */
 331  499          struct virtchnl_txq_info txq;
 332  500          struct virtchnl_rxq_info rxq;
 333  501  };
 334  502  
 335  503  VIRTCHNL_CHECK_STRUCT_LEN(64, virtchnl_queue_pair_info);
 336  504  
 337  505  struct virtchnl_vsi_queue_config_info {
↓ open down ↓ 4 lines elided ↑ open up ↑
 342  510  };
 343  511  
 344  512  VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_vsi_queue_config_info);
 345  513  
 346  514  /* VIRTCHNL_OP_REQUEST_QUEUES
 347  515   * VF sends this message to request the PF to allocate additional queues to
 348  516   * this VF.  Each VF gets a guaranteed number of queues on init but asking for
 349  517   * additional queues must be negotiated.  This is a best effort request as it
 350  518   * is possible the PF does not have enough queues left to support the request.
 351  519   * If the PF cannot support the number requested it will respond with the
 352      - * maximum number it is able to support; otherwise it will respond with the
 353      - * number requested.
      520 + * maximum number it is able to support.  If the request is successful, PF will
      521 + * then reset the VF to institute required changes.
 354  522   */
 355  523  
 356  524  /* VF resource request */
 357  525  struct virtchnl_vf_res_request {
 358  526          u16 num_queue_pairs;
 359  527  };
 360  528  
 361  529  /* VIRTCHNL_OP_CONFIG_IRQ_MAP
 362  530   * VF uses this message to map vectors to queues.
 363  531   * The rxq_map and txq_map fields are bitmaps used to indicate which queues
 364  532   * are to be associated with the specified vector.
 365      - * The "other" causes are always mapped to vector 0.
      533 + * The "other" causes are always mapped to vector 0. The VF may not request
      534 + * that vector 0 be used for traffic.
 366  535   * PF configures interrupt mapping and returns status.
      536 + * NOTE: due to hardware requirements, all active queues (both TX and RX)
      537 + * should be mapped to interrupts, even if the driver intends to operate
      538 + * only in polling mode. In this case the interrupt may be disabled, but
      539 + * the ITR timer will still run to trigger writebacks.
 367  540   */
 368  541  struct virtchnl_vector_map {
 369  542          u16 vsi_id;
 370  543          u16 vector_id;
 371  544          u16 rxq_map;
 372  545          u16 txq_map;
 373  546          u16 rxitr_idx;
 374  547          u16 txitr_idx;
 375  548  };
 376  549  
↓ open down ↓ 6 lines elided ↑ open up ↑
 383  556  
 384  557  VIRTCHNL_CHECK_STRUCT_LEN(14, virtchnl_irq_map_info);
 385  558  
 386  559  /* VIRTCHNL_OP_ENABLE_QUEUES
 387  560   * VIRTCHNL_OP_DISABLE_QUEUES
 388  561   * VF sends these message to enable or disable TX/RX queue pairs.
 389  562   * The queues fields are bitmaps indicating which queues to act upon.
 390  563   * (Currently, we only support 16 queues per VF, but we make the field
 391  564   * u32 to allow for expansion.)
 392  565   * PF performs requested action and returns status.
      566 + * NOTE: The VF is not required to enable/disable all queues in a single
      567 + * request. It may send multiple messages.
      568 + * PF drivers must correctly handle all VF requests.
 393  569   */
 394  570  struct virtchnl_queue_select {
 395  571          u16 vsi_id;
 396  572          u16 pad;
 397  573          u32 rx_queues;
 398  574          u32 tx_queues;
 399  575  };
 400  576  
 401  577  VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_select);
 402  578  
      579 +/* VIRTCHNL_OP_GET_MAX_RSS_QREGION
      580 + *
      581 + * if VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
      582 + * then this op must be supported.
      583 + *
      584 + * VF sends this message in order to query the max RSS queue region
      585 + * size supported by PF, when VIRTCHNL_VF_LARGE_NUM_QPAIRS is enabled.
      586 + * This information should be used when configuring the RSS LUT and/or
      587 + * configuring queue region based filters.
      588 + *
      589 + * The maximum RSS queue region is 2^qregion_width. So, a qregion_width
      590 + * of 6 would inform the VF that the PF supports a maximum RSS queue region
      591 + * of 64.
      592 + *
      593 + * A queue region represents a range of queues that can be used to configure
      594 + * a RSS LUT. For example, if a VF is given 64 queues, but only a max queue
      595 + * region size of 16 (i.e. 2^qregion_width = 16) then it will only be able
      596 + * to configure the RSS LUT with queue indices from 0 to 15. However, other
      597 + * filters can be used to direct packets to queues >15 via specifying a queue
      598 + * base/offset and queue region width.
      599 + */
      600 +struct virtchnl_max_rss_qregion {
      601 +        u16 vport_id;
      602 +        u16 qregion_width;
      603 +        u8 pad[4];
      604 +};
      605 +
      606 +VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_max_rss_qregion);
      607 +
 403  608  /* VIRTCHNL_OP_ADD_ETH_ADDR
 404  609   * VF sends this message in order to add one or more unicast or multicast
 405  610   * address filters for the specified VSI.
 406  611   * PF adds the filters and returns status.
 407  612   */
 408  613  
 409  614  /* VIRTCHNL_OP_DEL_ETH_ADDR
 410  615   * VF sends this message in order to remove one or more unicast or multicast
 411  616   * filters for the specified VSI.
 412  617   * PF removes the filters and returns status.
 413  618   */
 414  619  
      620 +/* VIRTCHNL_ETHER_ADDR_LEGACY
      621 + * Prior to adding the @type member to virtchnl_ether_addr, there were 2 pad
      622 + * bytes. Moving forward all VF drivers should not set type to
      623 + * VIRTCHNL_ETHER_ADDR_LEGACY. This is only here to not break previous/legacy
      624 + * behavior. The control plane function (i.e. PF) can use a best effort method
      625 + * of tracking the primary/device unicast in this case, but there is no
      626 + * guarantee and functionality depends on the implementation of the PF.
      627 + */
      628 +
      629 +/* VIRTCHNL_ETHER_ADDR_PRIMARY
      630 + * All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_PRIMARY for the
      631 + * primary/device unicast MAC address filter for VIRTCHNL_OP_ADD_ETH_ADDR and
      632 + * VIRTCHNL_OP_DEL_ETH_ADDR. This allows for the underlying control plane
      633 + * function (i.e. PF) to accurately track and use this MAC address for
      634 + * displaying on the host and for VM/function reset.
      635 + */
      636 +
      637 +/* VIRTCHNL_ETHER_ADDR_EXTRA
      638 + * All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_EXTRA for any extra
      639 + * unicast and/or multicast filters that are being added/deleted via
      640 + * VIRTCHNL_OP_DEL_ETH_ADDR/VIRTCHNL_OP_ADD_ETH_ADDR respectively.
      641 + */
 415  642  struct virtchnl_ether_addr {
 416  643          u8 addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
 417      -        u8 pad[2];
      644 +        u8 type;
      645 +#define VIRTCHNL_ETHER_ADDR_LEGACY      0
      646 +#define VIRTCHNL_ETHER_ADDR_PRIMARY     1
      647 +#define VIRTCHNL_ETHER_ADDR_EXTRA       2
      648 +#define VIRTCHNL_ETHER_ADDR_TYPE_MASK   3 /* first two bits of type are valid */
      649 +        u8 pad;
 418  650  };
 419  651  
 420  652  VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_ether_addr);
 421  653  
 422  654  struct virtchnl_ether_addr_list {
 423  655          u16 vsi_id;
 424  656          u16 num_elements;
 425  657          struct virtchnl_ether_addr list[1];
 426  658  };
 427  659  
↓ open down ↓ 14 lines elided ↑ open up ↑
 442  674   */
 443  675  
 444  676  struct virtchnl_vlan_filter_list {
 445  677          u16 vsi_id;
 446  678          u16 num_elements;
 447  679          u16 vlan_id[1];
 448  680  };
 449  681  
 450  682  VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_vlan_filter_list);
 451  683  
      684 +/* This enum is used for all of the VIRTCHNL_VF_OFFLOAD_VLAN_V2_CAPS related
      685 + * structures and opcodes.
      686 + *
      687 + * VIRTCHNL_VLAN_UNSUPPORTED - This field is not supported and if a VF driver
      688 + * populates it the PF should return VIRTCHNL_STATUS_ERR_NOT_SUPPORTED.
      689 + *
      690 + * VIRTCHNL_VLAN_ETHERTYPE_8100 - This field supports 0x8100 ethertype.
      691 + * VIRTCHNL_VLAN_ETHERTYPE_88A8 - This field supports 0x88A8 ethertype.
      692 + * VIRTCHNL_VLAN_ETHERTYPE_9100 - This field supports 0x9100 ethertype.
      693 + *
      694 + * VIRTCHNL_VLAN_ETHERTYPE_AND - Used when multiple ethertypes can be supported
      695 + * by the PF concurrently. For example, if the PF can support
      696 + * VIRTCHNL_VLAN_ETHERTYPE_8100 AND VIRTCHNL_VLAN_ETHERTYPE_88A8 filters it
      697 + * would OR the following bits:
      698 + *
      699 + *      VIRTHCNL_VLAN_ETHERTYPE_8100 |
      700 + *      VIRTCHNL_VLAN_ETHERTYPE_88A8 |
      701 + *      VIRTCHNL_VLAN_ETHERTYPE_AND;
      702 + *
      703 + * The VF would interpret this as VLAN filtering can be supported on both 0x8100
      704 + * and 0x88A8 VLAN ethertypes.
      705 + *
      706 + * VIRTCHNL_ETHERTYPE_XOR - Used when only a single ethertype can be supported
      707 + * by the PF concurrently. For example if the PF can support
      708 + * VIRTCHNL_VLAN_ETHERTYPE_8100 XOR VIRTCHNL_VLAN_ETHERTYPE_88A8 stripping
      709 + * offload it would OR the following bits:
      710 + *
      711 + *      VIRTCHNL_VLAN_ETHERTYPE_8100 |
      712 + *      VIRTCHNL_VLAN_ETHERTYPE_88A8 |
      713 + *      VIRTCHNL_VLAN_ETHERTYPE_XOR;
      714 + *
      715 + * The VF would interpret this as VLAN stripping can be supported on either
      716 + * 0x8100 or 0x88a8 VLAN ethertypes. So when requesting VLAN stripping via
      717 + * VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 the specified ethertype will override
      718 + * the previously set value.
      719 + *
      720 + * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1 - Used to tell the VF to insert and/or
      721 + * strip the VLAN tag using the L2TAG1 field of the Tx/Rx descriptors.
      722 + *
      723 + * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 - Used to tell the VF to insert hardware
      724 + * offloaded VLAN tags using the L2TAG2 field of the Tx descriptor.
      725 + *
      726 + * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 - Used to tell the VF to strip hardware
      727 + * offloaded VLAN tags using the L2TAG2_2 field of the Rx descriptor.
      728 + *
      729 + * VIRTCHNL_VLAN_PRIO - This field supports VLAN priority bits. This is used for
      730 + * VLAN filtering if the underlying PF supports it.
      731 + *
      732 + * VIRTCHNL_VLAN_TOGGLE_ALLOWED - This field is used to say whether a
      733 + * certain VLAN capability can be toggled. For example if the underlying PF/CP
      734 + * allows the VF to toggle VLAN filtering, stripping, and/or insertion it should
      735 + * set this bit along with the supported ethertypes.
      736 + */
      737 +enum virtchnl_vlan_support {
      738 +        VIRTCHNL_VLAN_UNSUPPORTED =             0,
      739 +        VIRTCHNL_VLAN_ETHERTYPE_8100 =          0x00000001,
      740 +        VIRTCHNL_VLAN_ETHERTYPE_88A8 =          0x00000002,
      741 +        VIRTCHNL_VLAN_ETHERTYPE_9100 =          0x00000004,
      742 +        VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1 =     0x00000100,
      743 +        VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 =     0x00000200,
      744 +        VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2_2 =   0x00000400,
      745 +        VIRTCHNL_VLAN_PRIO =                    0x01000000,
      746 +        VIRTCHNL_VLAN_FILTER_MASK =             0x10000000,
      747 +        VIRTCHNL_VLAN_ETHERTYPE_AND =           0x20000000,
      748 +        VIRTCHNL_VLAN_ETHERTYPE_XOR =           0x40000000,
      749 +        VIRTCHNL_VLAN_TOGGLE =                  0x80000000
      750 +};
      751 +
      752 +/* This structure is used as part of the VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS
      753 + * for filtering, insertion, and stripping capabilities.
      754 + *
      755 + * If only outer capabilities are supported (for filtering, insertion, and/or
      756 + * stripping) then this refers to the outer most or single VLAN from the VF's
      757 + * perspective.
      758 + *
      759 + * If only inner capabilities are supported (for filtering, insertion, and/or
      760 + * stripping) then this refers to the outer most or single VLAN from the VF's
      761 + * perspective. Functionally this is the same as if only outer capabilities are
      762 + * supported. The VF driver is just forced to use the inner fields when
      763 + * adding/deleting filters and enabling/disabling offloads (if supported).
      764 + *
      765 + * If both outer and inner capabilities are supported (for filtering, insertion,
      766 + * and/or stripping) then outer refers to the outer most or single VLAN and
      767 + * inner refers to the second VLAN, if it exists, in the packet.
      768 + *
      769 + * There is no support for tunneled VLAN offloads, so outer or inner are never
      770 + * referring to a tunneled packet from the VF's perspective.
      771 + */
      772 +struct virtchnl_vlan_supported_caps {
      773 +        u32 outer;
      774 +        u32 inner;
      775 +};
      776 +
      777 +/* The PF populates these fields based on the supported VLAN filtering. If a
      778 + * field is VIRTCHNL_VLAN_UNSUPPORTED then it's not supported and the PF will
      779 + * reject any VIRTCHNL_OP_ADD_VLAN_V2 or VIRTCHNL_OP_DEL_VLAN_V2 messages using
      780 + * the unsupported fields.
      781 + *
      782 + * Also, a VF is only allowed to toggle its VLAN filtering setting if the
      783 + * VIRTCHNL_VLAN_TOGGLE bit is set.
      784 + *
      785 + * The ethertype(s) specified in the ethertype_init field are the ethertypes
      786 + * enabled for VLAN filtering. VLAN filtering in this case refers to the outer
      787 + * most VLAN from the VF's perspective. If both inner and outer filtering are
      788 + * allowed then ethertype_init only refers to the outer most VLAN as only
      789 + * VLAN ethertype supported for inner VLAN filtering is
      790 + * VIRTCHNL_VLAN_ETHERTYPE_8100. By default, inner VLAN filtering is disabled
      791 + * when both inner and outer filtering are allowed.
      792 + *
      793 + * The max_filters field tells the VF how many VLAN filters it's allowed to have
      794 + * at any one time. If it exceeds this amount and tries to add another filter,
      795 + * then the request will be rejected by the PF. To prevent failures, the VF
      796 + * should keep track of how many VLAN filters it has added and not attempt to
      797 + * add more than max_filters.
      798 + */
      799 +struct virtchnl_vlan_filtering_caps {
      800 +        struct virtchnl_vlan_supported_caps filtering_support;
      801 +        u32 ethertype_init;
      802 +        u16 max_filters;
      803 +        u8 pad[2];
      804 +};
      805 +
      806 +VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vlan_filtering_caps);
      807 +
      808 +/* This enum is used for the virtchnl_vlan_offload_caps structure to specify
      809 + * if the PF supports a different ethertype for stripping and insertion.
      810 + *
      811 + * VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION - The ethertype(s) specified
      812 + * for stripping affect the ethertype(s) specified for insertion and visa versa
      813 + * as well. If the VF tries to configure VLAN stripping via
      814 + * VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 with VIRTCHNL_VLAN_ETHERTYPE_8100 then
      815 + * that will be the ethertype for both stripping and insertion.
      816 + *
      817 + * VIRTCHNL_ETHERTYPE_MATCH_NOT_REQUIRED - The ethertype(s) specified for
      818 + * stripping do not affect the ethertype(s) specified for insertion and visa
      819 + * versa.
      820 + */
      821 +enum virtchnl_vlan_ethertype_match {
      822 +        VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION = 0,
      823 +        VIRTCHNL_ETHERTYPE_MATCH_NOT_REQUIRED = 1,
      824 +};
      825 +
      826 +/* The PF populates these fields based on the supported VLAN offloads. If a
      827 + * field is VIRTCHNL_VLAN_UNSUPPORTED then it's not supported and the PF will
      828 + * reject any VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 or
      829 + * VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 messages using the unsupported fields.
      830 + *
      831 + * Also, a VF is only allowed to toggle its VLAN offload setting if the
      832 + * VIRTCHNL_VLAN_TOGGLE_ALLOWED bit is set.
      833 + *
      834 + * The VF driver needs to be aware of how the tags are stripped by hardware and
      835 + * inserted by the VF driver based on the level of offload support. The PF will
      836 + * populate these fields based on where the VLAN tags are expected to be
      837 + * offloaded via the VIRTHCNL_VLAN_TAG_LOCATION_* bits. The VF will need to
      838 + * interpret these fields. See the definition of the
      839 + * VIRTCHNL_VLAN_TAG_LOCATION_* bits above the virtchnl_vlan_support
      840 + * enumeration.
      841 + */
      842 +struct virtchnl_vlan_offload_caps {
      843 +        struct virtchnl_vlan_supported_caps stripping_support;
      844 +        struct virtchnl_vlan_supported_caps insertion_support;
      845 +        u32 ethertype_init;
      846 +        u8 ethertype_match;
      847 +        u8 pad[3];
      848 +};
      849 +
      850 +VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_vlan_offload_caps);
      851 +
      852 +/* VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS
      853 + * VF sends this message to determine its VLAN capabilities.
      854 + *
      855 + * PF will mark which capabilities it supports based on hardware support and
      856 + * current configuration. For example, if a port VLAN is configured the PF will
      857 + * not allow outer VLAN filtering, stripping, or insertion to be configured so
      858 + * it will block these features from the VF.
      859 + *
      860 + * The VF will need to cross reference its capabilities with the PFs
      861 + * capabilities in the response message from the PF to determine the VLAN
      862 + * support.
      863 + */
      864 +struct virtchnl_vlan_caps {
      865 +        struct virtchnl_vlan_filtering_caps filtering;
      866 +        struct virtchnl_vlan_offload_caps offloads;
      867 +};
      868 +
      869 +VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_vlan_caps);
      870 +
      871 +struct virtchnl_vlan {
      872 +        u16 tci;        /* tci[15:13] = PCP and tci[11:0] = VID */
      873 +        u16 tci_mask;   /* only valid if VIRTCHNL_VLAN_FILTER_MASK set in
      874 +                         * filtering caps
      875 +                         */
      876 +        u16 tpid;       /* 0x8100, 0x88a8, etc. and only type(s) set in
      877 +                         * filtering caps. Note that tpid here does not refer to
      878 +                         * VIRTCHNL_VLAN_ETHERTYPE_*, but it refers to the
      879 +                         * actual 2-byte VLAN TPID
      880 +                         */
      881 +        u8 pad[2];
      882 +};
      883 +
      884 +VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_vlan);
      885 +
      886 +struct virtchnl_vlan_filter {
      887 +        struct virtchnl_vlan inner;
      888 +        struct virtchnl_vlan outer;
      889 +        u8 pad[16];
      890 +};
      891 +
      892 +VIRTCHNL_CHECK_STRUCT_LEN(32, virtchnl_vlan_filter);
      893 +
      894 +/* VIRTCHNL_OP_ADD_VLAN_V2
      895 + * VIRTCHNL_OP_DEL_VLAN_V2
      896 + *
      897 + * VF sends these messages to add/del one or more VLAN tag filters for Rx
      898 + * traffic.
      899 + *
      900 + * The PF attempts to add the filters and returns status.
      901 + *
      902 + * The VF should only ever attempt to add/del virtchnl_vlan_filter(s) using the
      903 + * supported fields negotiated via VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS.
      904 + */
      905 +struct virtchnl_vlan_filter_list_v2 {
      906 +        u16 vport_id;
      907 +        u16 num_elements;
      908 +        u8 pad[4];
      909 +        struct virtchnl_vlan_filter filters[1];
      910 +};
      911 +
      912 +VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_vlan_filter_list_v2);
      913 +
      914 +/* VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2
      915 + * VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2
      916 + * VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2
      917 + * VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2
      918 + *
      919 + * VF sends this message to enable or disable VLAN stripping or insertion. It
      920 + * also needs to specify an ethertype. The VF knows which VLAN ethertypes are
      921 + * allowed and whether or not it's allowed to enable/disable the specific
      922 + * offload via the VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS message. The VF needs to
      923 + * parse the virtchnl_vlan_caps.offloads fields to determine which offload
      924 + * messages are allowed.
      925 + *
      926 + * For example, if the PF populates the virtchnl_vlan_caps.offloads in the
      927 + * following manner the VF will be allowed to enable and/or disable 0x8100 inner
      928 + * VLAN insertion and/or stripping via the opcodes listed above. Inner in this
      929 + * case means the outer most or single VLAN from the VF's perspective. This is
      930 + * because no outer offloads are supported. See the comments above the
      931 + * virtchnl_vlan_supported_caps structure for more details.
      932 + *
      933 + * virtchnl_vlan_caps.offloads.stripping_support.inner =
      934 + *                      VIRTCHNL_VLAN_TOGGLE |
      935 + *                      VIRTCHNL_VLAN_ETHERTYPE_8100;
      936 + *
      937 + * virtchnl_vlan_caps.offloads.insertion_support.inner =
      938 + *                      VIRTCHNL_VLAN_TOGGLE |
      939 + *                      VIRTCHNL_VLAN_ETHERTYPE_8100;
      940 + *
      941 + * In order to enable inner (again note that in this case inner is the outer
      942 + * most or single VLAN from the VF's perspective) VLAN stripping for 0x8100
      943 + * VLANs, the VF would populate the virtchnl_vlan_setting structure in the
      944 + * following manner and send the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 message.
      945 + *
      946 + * virtchnl_vlan_setting.inner_ethertype_setting =
      947 + *                      VIRTCHNL_VLAN_ETHERTYPE_8100;
      948 + *
      949 + * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on
      950 + * initialization.
      951 + *
      952 + * The reason that VLAN TPID(s) are not being used for the
      953 + * outer_ethertype_setting and inner_ethertype_setting fields is because it's
      954 + * possible a device could support VLAN insertion and/or stripping offload on
      955 + * multiple ethertypes concurrently, so this method allows a VF to request
      956 + * multiple ethertypes in one message using the virtchnl_vlan_support
      957 + * enumeration.
      958 + *
      959 + * For example, if the PF populates the virtchnl_vlan_caps.offloads in the
      960 + * following manner the VF will be allowed to enable 0x8100 and 0x88a8 outer
      961 + * VLAN insertion and stripping simultaneously. The
      962 + * virtchnl_vlan_caps.offloads.ethertype_match field will also have to be
      963 + * populated based on what the PF can support.
      964 + *
      965 + * virtchnl_vlan_caps.offloads.stripping_support.outer =
      966 + *                      VIRTCHNL_VLAN_TOGGLE |
      967 + *                      VIRTCHNL_VLAN_ETHERTYPE_8100 |
      968 + *                      VIRTCHNL_VLAN_ETHERTYPE_88A8 |
      969 + *                      VIRTCHNL_VLAN_ETHERTYPE_AND;
      970 + *
      971 + * virtchnl_vlan_caps.offloads.insertion_support.outer =
      972 + *                      VIRTCHNL_VLAN_TOGGLE |
      973 + *                      VIRTCHNL_VLAN_ETHERTYPE_8100 |
      974 + *                      VIRTCHNL_VLAN_ETHERTYPE_88A8 |
      975 + *                      VIRTCHNL_VLAN_ETHERTYPE_AND;
      976 + *
      977 + * In order to enable outer VLAN stripping for 0x8100 and 0x88a8 VLANs, the VF
      978 + * would populate the virthcnl_vlan_offload_structure in the following manner
      979 + * and send the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 message.
      980 + *
      981 + * virtchnl_vlan_setting.outer_ethertype_setting =
      982 + *                      VIRTHCNL_VLAN_ETHERTYPE_8100 |
      983 + *                      VIRTHCNL_VLAN_ETHERTYPE_88A8;
      984 + *
      985 + * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on
      986 + * initialization.
      987 + *
      988 + * There is also the case where a PF and the underlying hardware can support
      989 + * VLAN offloads on multiple ethertypes, but not concurrently. For example, if
      990 + * the PF populates the virtchnl_vlan_caps.offloads in the following manner the
      991 + * VF will be allowed to enable and/or disable 0x8100 XOR 0x88a8 outer VLAN
      992 + * offloads. The ethertypes must match for stripping and insertion.
      993 + *
      994 + * virtchnl_vlan_caps.offloads.stripping_support.outer =
      995 + *                      VIRTCHNL_VLAN_TOGGLE |
      996 + *                      VIRTCHNL_VLAN_ETHERTYPE_8100 |
      997 + *                      VIRTCHNL_VLAN_ETHERTYPE_88A8 |
      998 + *                      VIRTCHNL_VLAN_ETHERTYPE_XOR;
      999 + *
     1000 + * virtchnl_vlan_caps.offloads.insertion_support.outer =
     1001 + *                      VIRTCHNL_VLAN_TOGGLE |
     1002 + *                      VIRTCHNL_VLAN_ETHERTYPE_8100 |
     1003 + *                      VIRTCHNL_VLAN_ETHERTYPE_88A8 |
     1004 + *                      VIRTCHNL_VLAN_ETHERTYPE_XOR;
     1005 + *
     1006 + * virtchnl_vlan_caps.offloads.ethertype_match =
     1007 + *                      VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION;
     1008 + *
     1009 + * In order to enable outer VLAN stripping for 0x88a8 VLANs, the VF would
     1010 + * populate the virtchnl_vlan_setting structure in the following manner and send
     1011 + * the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2. Also, this will change the
     1012 + * ethertype for VLAN insertion if it's enabled. So, for completeness, a
     1013 + * VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 with the same ethertype should be sent.
     1014 + *
     1015 + * virtchnl_vlan_setting.outer_ethertype_setting = VIRTHCNL_VLAN_ETHERTYPE_88A8;
     1016 + *
     1017 + * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on
     1018 + * initialization.
     1019 + *
     1020 + * VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2
     1021 + * VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2
     1022 + *
     1023 + * VF sends this message to enable or disable VLAN filtering. It also needs to
     1024 + * specify an ethertype. The VF knows which VLAN ethertypes are allowed and
     1025 + * whether or not it's allowed to enable/disable filtering via the
     1026 + * VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS message. The VF needs to
     1027 + * parse the virtchnl_vlan_caps.filtering fields to determine which, if any,
     1028 + * filtering messages are allowed.
     1029 + *
     1030 + * For example, if the PF populates the virtchnl_vlan_caps.filtering in the
     1031 + * following manner the VF will be allowed to enable/disable 0x8100 and 0x88a8
     1032 + * outer VLAN filtering together. Note, that the VIRTCHNL_VLAN_ETHERTYPE_AND
     1033 + * means that all filtering ethertypes will to be enabled and disabled together
     1034 + * regardless of the request from the VF. This means that the underlying
     1035 + * hardware only supports VLAN filtering for all VLAN the specified ethertypes
     1036 + * or none of them.
     1037 + *
     1038 + * virtchnl_vlan_caps.filtering.filtering_support.outer =
     1039 + *                      VIRTCHNL_VLAN_TOGGLE |
     1040 + *                      VIRTCHNL_VLAN_ETHERTYPE_8100 |
     1041 + *                      VIRTHCNL_VLAN_ETHERTYPE_88A8 |
     1042 + *                      VIRTCHNL_VLAN_ETHERTYPE_9100 |
     1043 + *                      VIRTCHNL_VLAN_ETHERTYPE_AND;
     1044 + *
     1045 + * In order to enable outer VLAN filtering for 0x88a8 and 0x8100 VLANs (0x9100
     1046 + * VLANs aren't supported by the VF driver), the VF would populate the
     1047 + * virtchnl_vlan_setting structure in the following manner and send the
     1048 + * VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2. The same message format would be used
     1049 + * to disable outer VLAN filtering for 0x88a8 and 0x8100 VLANs, but the
     1050 + * VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2 opcode is used.
     1051 + *
     1052 + * virtchnl_vlan_setting.outer_ethertype_setting =
     1053 + *                      VIRTCHNL_VLAN_ETHERTYPE_8100 |
     1054 + *                      VIRTCHNL_VLAN_ETHERTYPE_88A8;
     1055 + *
     1056 + */
     1057 +struct virtchnl_vlan_setting {
     1058 +        u32 outer_ethertype_setting;
     1059 +        u32 inner_ethertype_setting;
     1060 +        u16 vport_id;
     1061 +        u8 pad[6];
     1062 +};
     1063 +
     1064 +VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vlan_setting);
     1065 +
 452 1066  /* VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE
 453 1067   * VF sends VSI id and flags.
 454 1068   * PF returns status code in retval.
 455 1069   * Note: we assume that broadcast accept mode is always enabled.
 456 1070   */
 457 1071  struct virtchnl_promisc_info {
 458 1072          u16 vsi_id;
 459 1073          u16 flags;
 460 1074  };
 461 1075  
 462 1076  VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_promisc_info);
 463 1077  
 464 1078  #define FLAG_VF_UNICAST_PROMISC 0x00000001
 465 1079  #define FLAG_VF_MULTICAST_PROMISC       0x00000002
 466 1080  
 467 1081  /* VIRTCHNL_OP_GET_STATS
 468 1082   * VF sends this message to request stats for the selected VSI. VF uses
 469 1083   * the virtchnl_queue_select struct to specify the VSI. The queue_id
 470 1084   * field is ignored by the PF.
 471 1085   *
 472      - * PF replies with struct eth_stats in an external buffer.
     1086 + * PF replies with struct virtchnl_eth_stats in an external buffer.
 473 1087   */
 474 1088  
     1089 +struct virtchnl_eth_stats {
     1090 +        u64 rx_bytes;                   /* received bytes */
     1091 +        u64 rx_unicast;                 /* received unicast pkts */
     1092 +        u64 rx_multicast;               /* received multicast pkts */
     1093 +        u64 rx_broadcast;               /* received broadcast pkts */
     1094 +        u64 rx_discards;
     1095 +        u64 rx_unknown_protocol;
     1096 +        u64 tx_bytes;                   /* transmitted bytes */
     1097 +        u64 tx_unicast;                 /* transmitted unicast pkts */
     1098 +        u64 tx_multicast;               /* transmitted multicast pkts */
     1099 +        u64 tx_broadcast;               /* transmitted broadcast pkts */
     1100 +        u64 tx_discards;
     1101 +        u64 tx_errors;
     1102 +};
     1103 +
 475 1104  /* VIRTCHNL_OP_CONFIG_RSS_KEY
 476 1105   * VIRTCHNL_OP_CONFIG_RSS_LUT
 477 1106   * VF sends these messages to configure RSS. Only supported if both PF
 478 1107   * and VF drivers set the VIRTCHNL_VF_OFFLOAD_RSS_PF bit during
 479 1108   * configuration negotiation. If this is the case, then the RSS fields in
 480 1109   * the VF resource struct are valid.
 481 1110   * Both the key and LUT are initialized to 0 by the PF, meaning that
 482 1111   * RSS is effectively disabled until set up by the VF.
 483 1112   */
 484 1113  struct virtchnl_rss_key {
↓ open down ↓ 18 lines elided ↑ open up ↑
 503 1132   * By default, the PF sets these to all possible traffic types that the
 504 1133   * hardware supports. The VF can query this value if it wants to change the
 505 1134   * traffic types that are hashed by the hardware.
 506 1135   */
 507 1136  struct virtchnl_rss_hena {
 508 1137          u64 hena;
 509 1138  };
 510 1139  
 511 1140  VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_rss_hena);
 512 1141  
     1142 +#if defined(ADV_AVF_SUPPORT) || defined(VIRTCHNL_VER_2_0)
     1143 +/* Type of RSS algorithm */
     1144 +enum virtchnl_rss_algorithm {
     1145 +        VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC    = 0,
     1146 +        VIRTCHNL_RSS_ALG_R_ASYMMETRIC           = 1,
     1147 +        VIRTCHNL_RSS_ALG_TOEPLITZ_SYMMETRIC     = 2,
     1148 +        VIRTCHNL_RSS_ALG_XOR_SYMMETRIC          = 3,
     1149 +};
     1150 +#endif /* ADV_AVF_SUPPORT || VIRTCHNL_VER_2_0 */
     1151 +
     1152 +/* This is used by PF driver to enforce how many channels can be supported.
     1153 + * When ADQ_V2 capability is negotiated, it will allow 16 channels otherwise
     1154 + * PF driver will allow only max 4 channels
     1155 + */
     1156 +#define VIRTCHNL_MAX_ADQ_CHANNELS 4
     1157 +#define VIRTCHNL_MAX_ADQ_V2_CHANNELS 16
     1158 +
     1159 +/* VIRTCHNL_OP_ENABLE_CHANNELS
     1160 + * VIRTCHNL_OP_DISABLE_CHANNELS
     1161 + * VF sends these messages to enable or disable channels based on
     1162 + * the user specified queue count and queue offset for each traffic class.
     1163 + * This struct encompasses all the information that the PF needs from
     1164 + * VF to create a channel.
     1165 + */
     1166 +struct virtchnl_channel_info {
     1167 +        u16 count; /* number of queues in a channel */
     1168 +        u16 offset; /* queues in a channel start from 'offset' */
     1169 +        u32 pad;
     1170 +        u64 max_tx_rate;
     1171 +};
     1172 +
     1173 +VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_channel_info);
     1174 +
     1175 +struct virtchnl_tc_info {
     1176 +        u32     num_tc;
     1177 +        u32     pad;
     1178 +        struct  virtchnl_channel_info list[1];
     1179 +};
     1180 +
     1181 +VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_tc_info);
     1182 +
     1183 +/* VIRTCHNL_ADD_CLOUD_FILTER
     1184 + * VIRTCHNL_DEL_CLOUD_FILTER
     1185 + * VF sends these messages to add or delete a cloud filter based on the
     1186 + * user specified match and action filters. These structures encompass
     1187 + * all the information that the PF needs from the VF to add/delete a
     1188 + * cloud filter.
     1189 + */
     1190 +
     1191 +struct virtchnl_l4_spec {
     1192 +        u8      src_mac[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
     1193 +        u8      dst_mac[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
     1194 +        /* vlan_prio is part of this 16 bit field even from OS perspective
     1195 +         * vlan_id:12 is actual vlan_id, then vlanid:bit14..12 is vlan_prio
     1196 +         * in future, when decided to offload vlan_prio, pass that information
     1197 +         * as part of the "vlan_id" field, Bit14..12
     1198 +         */
     1199 +        __be16  vlan_id;
     1200 +        __be16  pad; /* reserved for future use */
     1201 +        __be32  src_ip[4];
     1202 +        __be32  dst_ip[4];
     1203 +        __be16  src_port;
     1204 +        __be16  dst_port;
     1205 +};
     1206 +
     1207 +VIRTCHNL_CHECK_STRUCT_LEN(52, virtchnl_l4_spec);
     1208 +
     1209 +union virtchnl_flow_spec {
     1210 +        struct  virtchnl_l4_spec tcp_spec;
     1211 +        u8      buffer[128]; /* reserved for future use */
     1212 +};
     1213 +
     1214 +VIRTCHNL_CHECK_UNION_LEN(128, virtchnl_flow_spec);
     1215 +
     1216 +enum virtchnl_action {
     1217 +        /* action types */
     1218 +        VIRTCHNL_ACTION_DROP = 0,
     1219 +        VIRTCHNL_ACTION_TC_REDIRECT,
     1220 +        VIRTCHNL_ACTION_PASSTHRU,
     1221 +        VIRTCHNL_ACTION_QUEUE,
     1222 +        VIRTCHNL_ACTION_Q_REGION,
     1223 +        VIRTCHNL_ACTION_MARK,
     1224 +        VIRTCHNL_ACTION_COUNT,
     1225 +};
     1226 +
     1227 +enum virtchnl_flow_type {
     1228 +        /* flow types */
     1229 +        VIRTCHNL_TCP_V4_FLOW = 0,
     1230 +        VIRTCHNL_TCP_V6_FLOW,
     1231 +        VIRTCHNL_UDP_V4_FLOW,
     1232 +        VIRTCHNL_UDP_V6_FLOW,
     1233 +};
     1234 +
     1235 +struct virtchnl_filter {
     1236 +        union   virtchnl_flow_spec data;
     1237 +        union   virtchnl_flow_spec mask;
     1238 +
     1239 +        /* see enum virtchnl_flow_type */
     1240 +        s32     flow_type;
     1241 +
     1242 +        /* see enum virtchnl_action */
     1243 +        s32     action;
     1244 +        u32     action_meta;
     1245 +        u8      field_flags;
     1246 +};
     1247 +
     1248 +VIRTCHNL_CHECK_STRUCT_LEN(272, virtchnl_filter);
     1249 +
     1250 +
     1251 +
 513 1252  /* VIRTCHNL_OP_EVENT
 514 1253   * PF sends this message to inform the VF driver of events that may affect it.
 515 1254   * No direct response is expected from the VF, though it may generate other
 516 1255   * messages in response to this one.
 517 1256   */
 518 1257  enum virtchnl_event_codes {
 519 1258          VIRTCHNL_EVENT_UNKNOWN = 0,
 520 1259          VIRTCHNL_EVENT_LINK_CHANGE,
 521 1260          VIRTCHNL_EVENT_RESET_IMPENDING,
 522 1261          VIRTCHNL_EVENT_PF_DRIVER_CLOSE,
 523 1262  };
 524 1263  
 525 1264  #define PF_EVENT_SEVERITY_INFO          0
 526 1265  #define PF_EVENT_SEVERITY_ATTENTION     1
 527 1266  #define PF_EVENT_SEVERITY_ACTION_REQUIRED       2
 528 1267  #define PF_EVENT_SEVERITY_CERTAIN_DOOM  255
 529 1268  
 530 1269  struct virtchnl_pf_event {
 531      -        enum virtchnl_event_codes event;
     1270 +        /* see enum virtchnl_event_codes */
     1271 +        s32 event;
 532 1272          union {
     1273 +                /* If the PF driver does not support the new speed reporting
     1274 +                 * capabilities then use link_event else use link_event_adv to
     1275 +                 * get the speed and link information. The ability to understand
     1276 +                 * new speeds is indicated by setting the capability flag
     1277 +                 * VIRTCHNL_VF_CAP_ADV_LINK_SPEED in vf_cap_flags parameter
     1278 +                 * in virtchnl_vf_resource struct and can be used to determine
     1279 +                 * which link event struct to use below.
     1280 +                 */
 533 1281                  struct {
 534 1282                          enum virtchnl_link_speed link_speed;
 535 1283                          bool link_status;
     1284 +#ifndef __sun
     1285 +                        /* In illumos, sizeof (bool) is 4 bytes, not one. */
     1286 +                        u8 pad[3];
     1287 +#endif
 536 1288                  } link_event;
     1289 +                struct {
     1290 +                        /* link_speed provided in Mbps */
     1291 +                        u32 link_speed;
     1292 +                        u8 link_status;
     1293 +                        u8 pad[3];
     1294 +                } link_event_adv;
     1295 +                struct {
     1296 +                        /* link_speed provided in Mbps */
     1297 +                        u32 link_speed;
     1298 +                        u16 vport_id;
     1299 +                        u8 link_status;
     1300 +                        u8 pad;
     1301 +                } link_event_adv_vport;
 537 1302          } event_data;
 538 1303  
 539      -        int severity;
     1304 +        s32 severity;
 540 1305  };
 541 1306  
 542 1307  VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_pf_event);
 543 1308  
 544 1309  
 545 1310  /* VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP
 546 1311   * VF uses this message to request PF to map IWARP vectors to IWARP queues.
 547 1312   * The request for this originates from the VF IWARP driver through
 548 1313   * a client interface between VF LAN and VF IWARP driver.
 549 1314   * A vector could have an AEQ and CEQ attached to it although
 550 1315   * there is a single AEQ per VF IWARP instance in which case
 551 1316   * most vectors will have an INVALID_IDX for aeq and valid idx for ceq.
 552 1317   * There will never be a case where there will be multiple CEQs attached
 553 1318   * to a single vector.
 554 1319   * PF configures interrupt mapping and returns status.
 555 1320   */
 556      -
 557      -/* HW does not define a type value for AEQ; only for RX/TX and CEQ.
 558      - * In order for us to keep the interface simple, SW will define a
 559      - * unique type value for AEQ.
 560      - */
 561      -#define QUEUE_TYPE_PE_AEQ  0x80
 562      -#define QUEUE_INVALID_IDX  0xFFFF
 563      -
 564 1321  struct virtchnl_iwarp_qv_info {
 565 1322          u32 v_idx; /* msix_vector */
 566 1323          u16 ceq_idx;
 567 1324          u16 aeq_idx;
 568 1325          u8 itr_idx;
 569 1326  };
 570 1327  
 571 1328  VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_iwarp_qv_info);
 572 1329  
 573 1330  struct virtchnl_iwarp_qvlist_info {
↓ open down ↓ 14 lines elided ↑ open up ↑
 588 1345   * If either the PF or VF reads the register while the hardware
 589 1346   * is in a reset state, it will return DEADBEEF, which, when masked
 590 1347   * will result in 3.
 591 1348   */
 592 1349  enum virtchnl_vfr_states {
 593 1350          VIRTCHNL_VFR_INPROGRESS = 0,
 594 1351          VIRTCHNL_VFR_COMPLETED,
 595 1352          VIRTCHNL_VFR_VFACTIVE,
 596 1353  };
 597 1354  
     1355 +
     1356 +/* TX and RX queue types are valid in legacy as well as split queue models.
     1357 + * With Split Queue model, 2 additional types are introduced - TX_COMPLETION
     1358 + * and RX_BUFFER. In split queue model, RX corresponds to the queue where HW
     1359 + * posts completions.
     1360 + */
     1361 +enum virtchnl_queue_type {
     1362 +        VIRTCHNL_QUEUE_TYPE_TX                  = 0,
     1363 +        VIRTCHNL_QUEUE_TYPE_RX                  = 1,
     1364 +        VIRTCHNL_QUEUE_TYPE_TX_COMPLETION       = 2,
     1365 +        VIRTCHNL_QUEUE_TYPE_RX_BUFFER           = 3,
     1366 +        VIRTCHNL_QUEUE_TYPE_CONFIG_TX           = 4,
     1367 +        VIRTCHNL_QUEUE_TYPE_CONFIG_RX           = 5
     1368 +};
     1369 +
     1370 +
     1371 +/* structure to specify a chunk of contiguous queues */
     1372 +struct virtchnl_queue_chunk {
     1373 +        /* see enum virtchnl_queue_type */
     1374 +        s32 type;
     1375 +        u16 start_queue_id;
     1376 +        u16 num_queues;
     1377 +};
     1378 +
     1379 +VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_queue_chunk);
     1380 +
     1381 +/* structure to specify several chunks of contiguous queues */
     1382 +struct virtchnl_queue_chunks {
     1383 +        u16 num_chunks;
     1384 +        u16 rsvd;
     1385 +        struct virtchnl_queue_chunk chunks[1];
     1386 +};
     1387 +
     1388 +VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_chunks);
     1389 +
     1390 +
     1391 +/* VIRTCHNL_OP_ENABLE_QUEUES_V2
     1392 + * VIRTCHNL_OP_DISABLE_QUEUES_V2
     1393 + * VIRTCHNL_OP_DEL_QUEUES
     1394 + *
     1395 + * If VIRTCHNL version was negotiated in VIRTCHNL_OP_VERSION as 2.0
     1396 + * then all of these ops are available.
     1397 + *
     1398 + * If VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
     1399 + * then VIRTCHNL_OP_ENABLE_QUEUES_V2 and VIRTCHNL_OP_DISABLE_QUEUES_V2 are
     1400 + * available.
     1401 + *
     1402 + * PF sends these messages to enable, disable or delete queues specified in
     1403 + * chunks. PF sends virtchnl_del_ena_dis_queues struct to specify the queues
     1404 + * to be enabled/disabled/deleted. Also applicable to single queue RX or
     1405 + * TX. CP performs requested action and returns status.
     1406 + */
     1407 +struct virtchnl_del_ena_dis_queues {
     1408 +        u16 vport_id;
     1409 +        u16 pad;
     1410 +        struct virtchnl_queue_chunks chunks;
     1411 +};
     1412 +
     1413 +VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_del_ena_dis_queues);
     1414 +
     1415 +/* Virtchannel interrupt throttling rate index */
     1416 +enum virtchnl_itr_idx {
     1417 +        VIRTCHNL_ITR_IDX_0      = 0,
     1418 +        VIRTCHNL_ITR_IDX_1      = 1,
     1419 +        VIRTCHNL_ITR_IDX_NO_ITR = 3,
     1420 +};
     1421 +
     1422 +/* Queue to vector mapping */
     1423 +struct virtchnl_queue_vector {
     1424 +        u16 queue_id;
     1425 +        u16 vector_id;
     1426 +        u8 pad[4];
     1427 +
     1428 +        /* see enum virtchnl_itr_idx */
     1429 +        s32 itr_idx;
     1430 +
     1431 +        /* see enum virtchnl_queue_type */
     1432 +        s32 queue_type;
     1433 +};
     1434 +
     1435 +VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_queue_vector);
     1436 +
     1437 +/* VIRTCHNL_OP_MAP_QUEUE_VECTOR
     1438 + *
     1439 + * If VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
     1440 + * then only VIRTCHNL_OP_MAP_QUEUE_VECTOR is available.
     1441 + *
     1442 + * PF sends this message to map or unmap queues to vectors and ITR index
     1443 + * registers. External data buffer contains virtchnl_queue_vector_maps structure
     1444 + * that contains num_qv_maps of virtchnl_queue_vector structures.
     1445 + * CP maps the requested queue vector maps after validating the queue and vector
     1446 + * ids and returns a status code.
     1447 + */
     1448 +struct virtchnl_queue_vector_maps {
     1449 +        u16 vport_id;
     1450 +        u16 num_qv_maps;
     1451 +        u8 pad[4];
     1452 +        struct virtchnl_queue_vector qv_maps[1];
     1453 +};
     1454 +
     1455 +VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_queue_vector_maps);
     1456 +
     1457 +
     1458 +
     1459 +/* Since VF messages are limited by u16 size, precalculate the maximum possible
     1460 + * values of nested elements in virtchnl structures that virtual channel can
     1461 + * possibly handle in a single message.
     1462 + */
     1463 +enum virtchnl_vector_limits {
     1464 +        VIRTCHNL_OP_CONFIG_VSI_QUEUES_MAX       =
     1465 +                ((u16)(~0) - sizeof(struct virtchnl_vsi_queue_config_info)) /
     1466 +                sizeof(struct virtchnl_queue_pair_info),
     1467 +
     1468 +        VIRTCHNL_OP_CONFIG_IRQ_MAP_MAX          =
     1469 +                ((u16)(~0) - sizeof(struct virtchnl_irq_map_info)) /
     1470 +                sizeof(struct virtchnl_vector_map),
     1471 +
     1472 +        VIRTCHNL_OP_ADD_DEL_ETH_ADDR_MAX        =
     1473 +                ((u16)(~0) - sizeof(struct virtchnl_ether_addr_list)) /
     1474 +                sizeof(struct virtchnl_ether_addr),
     1475 +
     1476 +        VIRTCHNL_OP_ADD_DEL_VLAN_MAX            =
     1477 +                ((u16)(~0) - sizeof(struct virtchnl_vlan_filter_list)) /
     1478 +                sizeof(u16),
     1479 +
     1480 +        VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP_MAX    =
     1481 +                ((u16)(~0) - sizeof(struct virtchnl_iwarp_qvlist_info)) /
     1482 +                sizeof(struct virtchnl_iwarp_qv_info),
     1483 +
     1484 +        VIRTCHNL_OP_ENABLE_CHANNELS_MAX         =
     1485 +                ((u16)(~0) - sizeof(struct virtchnl_tc_info)) /
     1486 +                sizeof(struct virtchnl_channel_info),
     1487 +
     1488 +        VIRTCHNL_OP_ENABLE_DISABLE_DEL_QUEUES_V2_MAX    =
     1489 +                ((u16)(~0) - sizeof(struct virtchnl_del_ena_dis_queues)) /
     1490 +                sizeof(struct virtchnl_queue_chunk),
     1491 +
     1492 +        VIRTCHNL_OP_MAP_UNMAP_QUEUE_VECTOR_MAX  =
     1493 +                ((u16)(~0) - sizeof(struct virtchnl_queue_vector_maps)) /
     1494 +                sizeof(struct virtchnl_queue_vector),
     1495 +
     1496 +        VIRTCHNL_OP_ADD_DEL_VLAN_V2_MAX         =
     1497 +                ((u16)(~0) - sizeof(struct virtchnl_vlan_filter_list_v2)) /
     1498 +                sizeof(struct virtchnl_vlan_filter),
     1499 +};
     1500 +
 598 1501  /**
 599 1502   * virtchnl_vc_validate_vf_msg
 600 1503   * @ver: Virtchnl version info
 601 1504   * @v_opcode: Opcode for the message
 602 1505   * @msg: pointer to the msg buffer
 603 1506   * @msglen: msg length
 604 1507   *
 605 1508   * validate msg format against struct for each opcode
 606 1509   */
 607 1510  static inline int
 608 1511  virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
 609 1512                              u8 *msg, u16 msglen)
 610 1513  {
 611 1514          bool err_msg_format = FALSE;
 612      -        int valid_len = 0;
     1515 +        u32 valid_len = 0;
 613 1516  
 614 1517          /* Validate message length. */
 615 1518          switch (v_opcode) {
 616 1519          case VIRTCHNL_OP_VERSION:
 617 1520                  valid_len = sizeof(struct virtchnl_version_info);
 618 1521                  break;
 619 1522          case VIRTCHNL_OP_RESET_VF:
 620 1523                  break;
 621 1524          case VIRTCHNL_OP_GET_VF_RESOURCES:
 622 1525                  if (VF_IS_V11(ver))
↓ open down ↓ 3 lines elided ↑ open up ↑
 626 1529                  valid_len = sizeof(struct virtchnl_txq_info);
 627 1530                  break;
 628 1531          case VIRTCHNL_OP_CONFIG_RX_QUEUE:
 629 1532                  valid_len = sizeof(struct virtchnl_rxq_info);
 630 1533                  break;
 631 1534          case VIRTCHNL_OP_CONFIG_VSI_QUEUES:
 632 1535                  valid_len = sizeof(struct virtchnl_vsi_queue_config_info);
 633 1536                  if (msglen >= valid_len) {
 634 1537                          struct virtchnl_vsi_queue_config_info *vqc =
 635 1538                              (struct virtchnl_vsi_queue_config_info *)msg;
     1539 +
     1540 +                        if (vqc->num_queue_pairs == 0 || vqc->num_queue_pairs >
     1541 +                            VIRTCHNL_OP_CONFIG_VSI_QUEUES_MAX) {
     1542 +                                err_msg_format = TRUE;
     1543 +                                break;
     1544 +                        }
     1545 +
 636 1546                          valid_len += (vqc->num_queue_pairs *
 637 1547                                        sizeof(struct
 638 1548                                               virtchnl_queue_pair_info));
 639      -                        if (vqc->num_queue_pairs == 0)
 640      -                                err_msg_format = TRUE;
 641 1549                  }
 642 1550                  break;
 643 1551          case VIRTCHNL_OP_CONFIG_IRQ_MAP:
 644 1552                  valid_len = sizeof(struct virtchnl_irq_map_info);
 645 1553                  if (msglen >= valid_len) {
 646 1554                          struct virtchnl_irq_map_info *vimi =
 647 1555                              (struct virtchnl_irq_map_info *)msg;
     1556 +
     1557 +                        if (vimi->num_vectors == 0 || vimi->num_vectors >
     1558 +                            VIRTCHNL_OP_CONFIG_IRQ_MAP_MAX) {
     1559 +                                err_msg_format = TRUE;
     1560 +                                break;
     1561 +                        }
     1562 +
 648 1563                          valid_len += (vimi->num_vectors *
 649 1564                                        sizeof(struct virtchnl_vector_map));
 650      -                        if (vimi->num_vectors == 0)
 651      -                                err_msg_format = TRUE;
 652 1565                  }
 653 1566                  break;
 654 1567          case VIRTCHNL_OP_ENABLE_QUEUES:
 655 1568          case VIRTCHNL_OP_DISABLE_QUEUES:
 656 1569                  valid_len = sizeof(struct virtchnl_queue_select);
 657 1570                  break;
     1571 +        case VIRTCHNL_OP_GET_MAX_RSS_QREGION:
     1572 +                break;
 658 1573          case VIRTCHNL_OP_ADD_ETH_ADDR:
 659 1574          case VIRTCHNL_OP_DEL_ETH_ADDR:
 660 1575                  valid_len = sizeof(struct virtchnl_ether_addr_list);
 661 1576                  if (msglen >= valid_len) {
 662 1577                          struct virtchnl_ether_addr_list *veal =
 663 1578                              (struct virtchnl_ether_addr_list *)msg;
     1579 +
     1580 +                        if (veal->num_elements == 0 || veal->num_elements >
     1581 +                            VIRTCHNL_OP_ADD_DEL_ETH_ADDR_MAX) {
     1582 +                                err_msg_format = TRUE;
     1583 +                                break;
     1584 +                        }
     1585 +
 664 1586                          valid_len += veal->num_elements *
 665 1587                              sizeof(struct virtchnl_ether_addr);
 666      -                        if (veal->num_elements == 0)
 667      -                                err_msg_format = TRUE;
 668 1588                  }
 669 1589                  break;
 670 1590          case VIRTCHNL_OP_ADD_VLAN:
 671 1591          case VIRTCHNL_OP_DEL_VLAN:
 672 1592                  valid_len = sizeof(struct virtchnl_vlan_filter_list);
 673 1593                  if (msglen >= valid_len) {
 674 1594                          struct virtchnl_vlan_filter_list *vfl =
 675 1595                              (struct virtchnl_vlan_filter_list *)msg;
 676      -                        valid_len += vfl->num_elements * sizeof(u16);
 677      -                        if (vfl->num_elements == 0)
     1596 +
     1597 +                        if (vfl->num_elements == 0 || vfl->num_elements >
     1598 +                            VIRTCHNL_OP_ADD_DEL_VLAN_MAX) {
 678 1599                                  err_msg_format = TRUE;
     1600 +                                break;
     1601 +                        }
     1602 +
     1603 +                        valid_len += vfl->num_elements * sizeof(u16);
 679 1604                  }
 680 1605                  break;
 681 1606          case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE:
 682 1607                  valid_len = sizeof(struct virtchnl_promisc_info);
 683 1608                  break;
 684 1609          case VIRTCHNL_OP_GET_STATS:
 685 1610                  valid_len = sizeof(struct virtchnl_queue_select);
 686 1611                  break;
 687 1612          case VIRTCHNL_OP_IWARP:
 688 1613                  /* These messages are opaque to us and will be validated in
↓ open down ↓ 5 lines elided ↑ open up ↑
 694 1619                  else
 695 1620                          err_msg_format = TRUE;
 696 1621                  break;
 697 1622          case VIRTCHNL_OP_RELEASE_IWARP_IRQ_MAP:
 698 1623                  break;
 699 1624          case VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP:
 700 1625                  valid_len = sizeof(struct virtchnl_iwarp_qvlist_info);
 701 1626                  if (msglen >= valid_len) {
 702 1627                          struct virtchnl_iwarp_qvlist_info *qv =
 703 1628                                  (struct virtchnl_iwarp_qvlist_info *)msg;
 704      -                        if (qv->num_vectors == 0) {
     1629 +
     1630 +                        if (qv->num_vectors == 0 || qv->num_vectors >
     1631 +                            VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP_MAX) {
 705 1632                                  err_msg_format = TRUE;
 706 1633                                  break;
 707 1634                          }
     1635 +
 708 1636                          valid_len += ((qv->num_vectors - 1) *
 709 1637                                  sizeof(struct virtchnl_iwarp_qv_info));
 710 1638                  }
 711 1639                  break;
 712 1640          case VIRTCHNL_OP_CONFIG_RSS_KEY:
 713 1641                  valid_len = sizeof(struct virtchnl_rss_key);
 714 1642                  if (msglen >= valid_len) {
 715 1643                          struct virtchnl_rss_key *vrk =
 716 1644                                  (struct virtchnl_rss_key *)msg;
     1645 +
     1646 +                        if (vrk->key_len == 0) {
     1647 +                                /* zero length is allowed as input */
     1648 +                                break;
     1649 +                        }
     1650 +
 717 1651                          valid_len += vrk->key_len - 1;
 718 1652                  }
 719 1653                  break;
 720 1654          case VIRTCHNL_OP_CONFIG_RSS_LUT:
 721 1655                  valid_len = sizeof(struct virtchnl_rss_lut);
 722 1656                  if (msglen >= valid_len) {
 723 1657                          struct virtchnl_rss_lut *vrl =
 724 1658                                  (struct virtchnl_rss_lut *)msg;
     1659 +
     1660 +                        if (vrl->lut_entries == 0) {
     1661 +                                /* zero entries is allowed as input */
     1662 +                                break;
     1663 +                        }
     1664 +
 725 1665                          valid_len += vrl->lut_entries - 1;
 726 1666                  }
 727 1667                  break;
 728 1668          case VIRTCHNL_OP_GET_RSS_HENA_CAPS:
 729 1669                  break;
 730 1670          case VIRTCHNL_OP_SET_RSS_HENA:
 731 1671                  valid_len = sizeof(struct virtchnl_rss_hena);
 732 1672                  break;
 733 1673          case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING:
 734 1674          case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING:
 735 1675                  break;
 736 1676          case VIRTCHNL_OP_REQUEST_QUEUES:
 737 1677                  valid_len = sizeof(struct virtchnl_vf_res_request);
 738 1678                  break;
     1679 +        case VIRTCHNL_OP_ENABLE_CHANNELS:
     1680 +                valid_len = sizeof(struct virtchnl_tc_info);
     1681 +                if (msglen >= valid_len) {
     1682 +                        struct virtchnl_tc_info *vti =
     1683 +                                (struct virtchnl_tc_info *)msg;
     1684 +
     1685 +                        if (vti->num_tc == 0 || vti->num_tc >
     1686 +                            VIRTCHNL_OP_ENABLE_CHANNELS_MAX) {
     1687 +                                err_msg_format = TRUE;
     1688 +                                break;
     1689 +                        }
     1690 +
     1691 +                        valid_len += (vti->num_tc - 1) *
     1692 +                                     sizeof(struct virtchnl_channel_info);
     1693 +                }
     1694 +                break;
     1695 +        case VIRTCHNL_OP_DISABLE_CHANNELS:
     1696 +                break;
     1697 +        case VIRTCHNL_OP_ADD_CLOUD_FILTER:
     1698 +        case VIRTCHNL_OP_DEL_CLOUD_FILTER:
     1699 +                valid_len = sizeof(struct virtchnl_filter);
     1700 +                break;
     1701 +        case VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS:
     1702 +                break;
     1703 +        case VIRTCHNL_OP_ADD_VLAN_V2:
     1704 +        case VIRTCHNL_OP_DEL_VLAN_V2:
     1705 +                valid_len = sizeof(struct virtchnl_vlan_filter_list_v2);
     1706 +                if (msglen >= valid_len) {
     1707 +                        struct virtchnl_vlan_filter_list_v2 *vfl =
     1708 +                            (struct virtchnl_vlan_filter_list_v2 *)msg;
     1709 +
     1710 +                        if (vfl->num_elements == 0 || vfl->num_elements >
     1711 +                            VIRTCHNL_OP_ADD_DEL_VLAN_V2_MAX) {
     1712 +                                err_msg_format = TRUE;
     1713 +                                break;
     1714 +                        }
     1715 +
     1716 +                        valid_len += (vfl->num_elements - 1) *
     1717 +                                sizeof(struct virtchnl_vlan_filter);
     1718 +                }
     1719 +                break;
     1720 +        case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2:
     1721 +        case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2:
     1722 +        case VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2:
     1723 +        case VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2:
     1724 +        case VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2:
     1725 +        case VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2:
     1726 +                valid_len = sizeof(struct virtchnl_vlan_setting);
     1727 +                break;
     1728 +        case VIRTCHNL_OP_ENABLE_QUEUES_V2:
     1729 +        case VIRTCHNL_OP_DISABLE_QUEUES_V2:
     1730 +                valid_len = sizeof(struct virtchnl_del_ena_dis_queues);
     1731 +                if (msglen >= valid_len) {
     1732 +                        struct virtchnl_del_ena_dis_queues *qs =
     1733 +                                (struct virtchnl_del_ena_dis_queues *)msg;
     1734 +                        if (qs->chunks.num_chunks == 0 ||
     1735 +                            qs->chunks.num_chunks > VIRTCHNL_OP_ENABLE_DISABLE_DEL_QUEUES_V2_MAX) {
     1736 +                                err_msg_format = TRUE;
     1737 +                                break;
     1738 +                        }
     1739 +                        valid_len += (qs->chunks.num_chunks - 1) *
     1740 +                                      sizeof(struct virtchnl_queue_chunk);
     1741 +                }
     1742 +                break;
     1743 +        case VIRTCHNL_OP_MAP_QUEUE_VECTOR:
     1744 +                valid_len = sizeof(struct virtchnl_queue_vector_maps);
     1745 +                if (msglen >= valid_len) {
     1746 +                        struct virtchnl_queue_vector_maps *v_qp =
     1747 +                                (struct virtchnl_queue_vector_maps *)msg;
     1748 +                        if (v_qp->num_qv_maps == 0 ||
     1749 +                            v_qp->num_qv_maps > VIRTCHNL_OP_MAP_UNMAP_QUEUE_VECTOR_MAX) {
     1750 +                                err_msg_format = TRUE;
     1751 +                                break;
     1752 +                        }
     1753 +                        valid_len += (v_qp->num_qv_maps - 1) *
     1754 +                                      sizeof(struct virtchnl_queue_vector);
     1755 +                }
     1756 +                break;
 739 1757          /* These are always errors coming from the VF. */
 740 1758          case VIRTCHNL_OP_EVENT:
 741 1759          case VIRTCHNL_OP_UNKNOWN:
 742 1760          default:
 743      -                return VIRTCHNL_ERR_PARAM;
     1761 +                return VIRTCHNL_STATUS_ERR_PARAM;
 744 1762          }
 745 1763          /* few more checks */
 746 1764          if (err_msg_format || valid_len != msglen)
 747 1765                  return VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH;
 748 1766  
 749 1767          return 0;
 750 1768  }
 751 1769  #endif /* _VIRTCHNL_H_ */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX