linux/drivers/net/ethernet/intel/iavf/iavf_common.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0
   2/* Copyright(c) 2013 - 2018 Intel Corporation. */
   3
   4#include "iavf_type.h"
   5#include "iavf_adminq.h"
   6#include "iavf_prototype.h"
   7#include <linux/avf/virtchnl.h>
   8
   9/**
  10 * iavf_set_mac_type - Sets MAC type
  11 * @hw: pointer to the HW structure
  12 *
  13 * This function sets the mac type of the adapter based on the
  14 * vendor ID and device ID stored in the hw structure.
  15 **/
  16enum iavf_status iavf_set_mac_type(struct iavf_hw *hw)
  17{
  18        enum iavf_status status = 0;
  19
  20        if (hw->vendor_id == PCI_VENDOR_ID_INTEL) {
  21                switch (hw->device_id) {
  22                case IAVF_DEV_ID_X722_VF:
  23                        hw->mac.type = IAVF_MAC_X722_VF;
  24                        break;
  25                case IAVF_DEV_ID_VF:
  26                case IAVF_DEV_ID_VF_HV:
  27                case IAVF_DEV_ID_ADAPTIVE_VF:
  28                        hw->mac.type = IAVF_MAC_VF;
  29                        break;
  30                default:
  31                        hw->mac.type = IAVF_MAC_GENERIC;
  32                        break;
  33                }
  34        } else {
  35                status = IAVF_ERR_DEVICE_NOT_SUPPORTED;
  36        }
  37
  38        hw_dbg(hw, "found mac: %d, returns: %d\n", hw->mac.type, status);
  39        return status;
  40}
  41
  42/**
  43 * iavf_aq_str - convert AQ err code to a string
  44 * @hw: pointer to the HW structure
  45 * @aq_err: the AQ error code to convert
  46 **/
  47const char *iavf_aq_str(struct iavf_hw *hw, enum iavf_admin_queue_err aq_err)
  48{
  49        switch (aq_err) {
  50        case IAVF_AQ_RC_OK:
  51                return "OK";
  52        case IAVF_AQ_RC_EPERM:
  53                return "IAVF_AQ_RC_EPERM";
  54        case IAVF_AQ_RC_ENOENT:
  55                return "IAVF_AQ_RC_ENOENT";
  56        case IAVF_AQ_RC_ESRCH:
  57                return "IAVF_AQ_RC_ESRCH";
  58        case IAVF_AQ_RC_EINTR:
  59                return "IAVF_AQ_RC_EINTR";
  60        case IAVF_AQ_RC_EIO:
  61                return "IAVF_AQ_RC_EIO";
  62        case IAVF_AQ_RC_ENXIO:
  63                return "IAVF_AQ_RC_ENXIO";
  64        case IAVF_AQ_RC_E2BIG:
  65                return "IAVF_AQ_RC_E2BIG";
  66        case IAVF_AQ_RC_EAGAIN:
  67                return "IAVF_AQ_RC_EAGAIN";
  68        case IAVF_AQ_RC_ENOMEM:
  69                return "IAVF_AQ_RC_ENOMEM";
  70        case IAVF_AQ_RC_EACCES:
  71                return "IAVF_AQ_RC_EACCES";
  72        case IAVF_AQ_RC_EFAULT:
  73                return "IAVF_AQ_RC_EFAULT";
  74        case IAVF_AQ_RC_EBUSY:
  75                return "IAVF_AQ_RC_EBUSY";
  76        case IAVF_AQ_RC_EEXIST:
  77                return "IAVF_AQ_RC_EEXIST";
  78        case IAVF_AQ_RC_EINVAL:
  79                return "IAVF_AQ_RC_EINVAL";
  80        case IAVF_AQ_RC_ENOTTY:
  81                return "IAVF_AQ_RC_ENOTTY";
  82        case IAVF_AQ_RC_ENOSPC:
  83                return "IAVF_AQ_RC_ENOSPC";
  84        case IAVF_AQ_RC_ENOSYS:
  85                return "IAVF_AQ_RC_ENOSYS";
  86        case IAVF_AQ_RC_ERANGE:
  87                return "IAVF_AQ_RC_ERANGE";
  88        case IAVF_AQ_RC_EFLUSHED:
  89                return "IAVF_AQ_RC_EFLUSHED";
  90        case IAVF_AQ_RC_BAD_ADDR:
  91                return "IAVF_AQ_RC_BAD_ADDR";
  92        case IAVF_AQ_RC_EMODE:
  93                return "IAVF_AQ_RC_EMODE";
  94        case IAVF_AQ_RC_EFBIG:
  95                return "IAVF_AQ_RC_EFBIG";
  96        }
  97
  98        snprintf(hw->err_str, sizeof(hw->err_str), "%d", aq_err);
  99        return hw->err_str;
 100}
 101
 102/**
 103 * iavf_stat_str - convert status err code to a string
 104 * @hw: pointer to the HW structure
 105 * @stat_err: the status error code to convert
 106 **/
 107const char *iavf_stat_str(struct iavf_hw *hw, enum iavf_status stat_err)
 108{
 109        switch (stat_err) {
 110        case 0:
 111                return "OK";
 112        case IAVF_ERR_NVM:
 113                return "IAVF_ERR_NVM";
 114        case IAVF_ERR_NVM_CHECKSUM:
 115                return "IAVF_ERR_NVM_CHECKSUM";
 116        case IAVF_ERR_PHY:
 117                return "IAVF_ERR_PHY";
 118        case IAVF_ERR_CONFIG:
 119                return "IAVF_ERR_CONFIG";
 120        case IAVF_ERR_PARAM:
 121                return "IAVF_ERR_PARAM";
 122        case IAVF_ERR_MAC_TYPE:
 123                return "IAVF_ERR_MAC_TYPE";
 124        case IAVF_ERR_UNKNOWN_PHY:
 125                return "IAVF_ERR_UNKNOWN_PHY";
 126        case IAVF_ERR_LINK_SETUP:
 127                return "IAVF_ERR_LINK_SETUP";
 128        case IAVF_ERR_ADAPTER_STOPPED:
 129                return "IAVF_ERR_ADAPTER_STOPPED";
 130        case IAVF_ERR_INVALID_MAC_ADDR:
 131                return "IAVF_ERR_INVALID_MAC_ADDR";
 132        case IAVF_ERR_DEVICE_NOT_SUPPORTED:
 133                return "IAVF_ERR_DEVICE_NOT_SUPPORTED";
 134        case IAVF_ERR_MASTER_REQUESTS_PENDING:
 135                return "IAVF_ERR_MASTER_REQUESTS_PENDING";
 136        case IAVF_ERR_INVALID_LINK_SETTINGS:
 137                return "IAVF_ERR_INVALID_LINK_SETTINGS";
 138        case IAVF_ERR_AUTONEG_NOT_COMPLETE:
 139                return "IAVF_ERR_AUTONEG_NOT_COMPLETE";
 140        case IAVF_ERR_RESET_FAILED:
 141                return "IAVF_ERR_RESET_FAILED";
 142        case IAVF_ERR_SWFW_SYNC:
 143                return "IAVF_ERR_SWFW_SYNC";
 144        case IAVF_ERR_NO_AVAILABLE_VSI:
 145                return "IAVF_ERR_NO_AVAILABLE_VSI";
 146        case IAVF_ERR_NO_MEMORY:
 147                return "IAVF_ERR_NO_MEMORY";
 148        case IAVF_ERR_BAD_PTR:
 149                return "IAVF_ERR_BAD_PTR";
 150        case IAVF_ERR_RING_FULL:
 151                return "IAVF_ERR_RING_FULL";
 152        case IAVF_ERR_INVALID_PD_ID:
 153                return "IAVF_ERR_INVALID_PD_ID";
 154        case IAVF_ERR_INVALID_QP_ID:
 155                return "IAVF_ERR_INVALID_QP_ID";
 156        case IAVF_ERR_INVALID_CQ_ID:
 157                return "IAVF_ERR_INVALID_CQ_ID";
 158        case IAVF_ERR_INVALID_CEQ_ID:
 159                return "IAVF_ERR_INVALID_CEQ_ID";
 160        case IAVF_ERR_INVALID_AEQ_ID:
 161                return "IAVF_ERR_INVALID_AEQ_ID";
 162        case IAVF_ERR_INVALID_SIZE:
 163                return "IAVF_ERR_INVALID_SIZE";
 164        case IAVF_ERR_INVALID_ARP_INDEX:
 165                return "IAVF_ERR_INVALID_ARP_INDEX";
 166        case IAVF_ERR_INVALID_FPM_FUNC_ID:
 167                return "IAVF_ERR_INVALID_FPM_FUNC_ID";
 168        case IAVF_ERR_QP_INVALID_MSG_SIZE:
 169                return "IAVF_ERR_QP_INVALID_MSG_SIZE";
 170        case IAVF_ERR_QP_TOOMANY_WRS_POSTED:
 171                return "IAVF_ERR_QP_TOOMANY_WRS_POSTED";
 172        case IAVF_ERR_INVALID_FRAG_COUNT:
 173                return "IAVF_ERR_INVALID_FRAG_COUNT";
 174        case IAVF_ERR_QUEUE_EMPTY:
 175                return "IAVF_ERR_QUEUE_EMPTY";
 176        case IAVF_ERR_INVALID_ALIGNMENT:
 177                return "IAVF_ERR_INVALID_ALIGNMENT";
 178        case IAVF_ERR_FLUSHED_QUEUE:
 179                return "IAVF_ERR_FLUSHED_QUEUE";
 180        case IAVF_ERR_INVALID_PUSH_PAGE_INDEX:
 181                return "IAVF_ERR_INVALID_PUSH_PAGE_INDEX";
 182        case IAVF_ERR_INVALID_IMM_DATA_SIZE:
 183                return "IAVF_ERR_INVALID_IMM_DATA_SIZE";
 184        case IAVF_ERR_TIMEOUT:
 185                return "IAVF_ERR_TIMEOUT";
 186        case IAVF_ERR_OPCODE_MISMATCH:
 187                return "IAVF_ERR_OPCODE_MISMATCH";
 188        case IAVF_ERR_CQP_COMPL_ERROR:
 189                return "IAVF_ERR_CQP_COMPL_ERROR";
 190        case IAVF_ERR_INVALID_VF_ID:
 191                return "IAVF_ERR_INVALID_VF_ID";
 192        case IAVF_ERR_INVALID_HMCFN_ID:
 193                return "IAVF_ERR_INVALID_HMCFN_ID";
 194        case IAVF_ERR_BACKING_PAGE_ERROR:
 195                return "IAVF_ERR_BACKING_PAGE_ERROR";
 196        case IAVF_ERR_NO_PBLCHUNKS_AVAILABLE:
 197                return "IAVF_ERR_NO_PBLCHUNKS_AVAILABLE";
 198        case IAVF_ERR_INVALID_PBLE_INDEX:
 199                return "IAVF_ERR_INVALID_PBLE_INDEX";
 200        case IAVF_ERR_INVALID_SD_INDEX:
 201                return "IAVF_ERR_INVALID_SD_INDEX";
 202        case IAVF_ERR_INVALID_PAGE_DESC_INDEX:
 203                return "IAVF_ERR_INVALID_PAGE_DESC_INDEX";
 204        case IAVF_ERR_INVALID_SD_TYPE:
 205                return "IAVF_ERR_INVALID_SD_TYPE";
 206        case IAVF_ERR_MEMCPY_FAILED:
 207                return "IAVF_ERR_MEMCPY_FAILED";
 208        case IAVF_ERR_INVALID_HMC_OBJ_INDEX:
 209                return "IAVF_ERR_INVALID_HMC_OBJ_INDEX";
 210        case IAVF_ERR_INVALID_HMC_OBJ_COUNT:
 211                return "IAVF_ERR_INVALID_HMC_OBJ_COUNT";
 212        case IAVF_ERR_INVALID_SRQ_ARM_LIMIT:
 213                return "IAVF_ERR_INVALID_SRQ_ARM_LIMIT";
 214        case IAVF_ERR_SRQ_ENABLED:
 215                return "IAVF_ERR_SRQ_ENABLED";
 216        case IAVF_ERR_ADMIN_QUEUE_ERROR:
 217                return "IAVF_ERR_ADMIN_QUEUE_ERROR";
 218        case IAVF_ERR_ADMIN_QUEUE_TIMEOUT:
 219                return "IAVF_ERR_ADMIN_QUEUE_TIMEOUT";
 220        case IAVF_ERR_BUF_TOO_SHORT:
 221                return "IAVF_ERR_BUF_TOO_SHORT";
 222        case IAVF_ERR_ADMIN_QUEUE_FULL:
 223                return "IAVF_ERR_ADMIN_QUEUE_FULL";
 224        case IAVF_ERR_ADMIN_QUEUE_NO_WORK:
 225                return "IAVF_ERR_ADMIN_QUEUE_NO_WORK";
 226        case IAVF_ERR_BAD_IWARP_CQE:
 227                return "IAVF_ERR_BAD_IWARP_CQE";
 228        case IAVF_ERR_NVM_BLANK_MODE:
 229                return "IAVF_ERR_NVM_BLANK_MODE";
 230        case IAVF_ERR_NOT_IMPLEMENTED:
 231                return "IAVF_ERR_NOT_IMPLEMENTED";
 232        case IAVF_ERR_PE_DOORBELL_NOT_ENABLED:
 233                return "IAVF_ERR_PE_DOORBELL_NOT_ENABLED";
 234        case IAVF_ERR_DIAG_TEST_FAILED:
 235                return "IAVF_ERR_DIAG_TEST_FAILED";
 236        case IAVF_ERR_NOT_READY:
 237                return "IAVF_ERR_NOT_READY";
 238        case IAVF_NOT_SUPPORTED:
 239                return "IAVF_NOT_SUPPORTED";
 240        case IAVF_ERR_FIRMWARE_API_VERSION:
 241                return "IAVF_ERR_FIRMWARE_API_VERSION";
 242        case IAVF_ERR_ADMIN_QUEUE_CRITICAL_ERROR:
 243                return "IAVF_ERR_ADMIN_QUEUE_CRITICAL_ERROR";
 244        }
 245
 246        snprintf(hw->err_str, sizeof(hw->err_str), "%d", stat_err);
 247        return hw->err_str;
 248}
 249
 250/**
 251 * iavf_debug_aq
 252 * @hw: debug mask related to admin queue
 253 * @mask: debug mask
 254 * @desc: pointer to admin queue descriptor
 255 * @buffer: pointer to command buffer
 256 * @buf_len: max length of buffer
 257 *
 258 * Dumps debug log about adminq command with descriptor contents.
 259 **/
 260void iavf_debug_aq(struct iavf_hw *hw, enum iavf_debug_mask mask, void *desc,
 261                   void *buffer, u16 buf_len)
 262{
 263        struct iavf_aq_desc *aq_desc = (struct iavf_aq_desc *)desc;
 264        u8 *buf = (u8 *)buffer;
 265
 266        if ((!(mask & hw->debug_mask)) || !desc)
 267                return;
 268
 269        iavf_debug(hw, mask,
 270                   "AQ CMD: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n",
 271                   le16_to_cpu(aq_desc->opcode),
 272                   le16_to_cpu(aq_desc->flags),
 273                   le16_to_cpu(aq_desc->datalen),
 274                   le16_to_cpu(aq_desc->retval));
 275        iavf_debug(hw, mask, "\tcookie (h,l) 0x%08X 0x%08X\n",
 276                   le32_to_cpu(aq_desc->cookie_high),
 277                   le32_to_cpu(aq_desc->cookie_low));
 278        iavf_debug(hw, mask, "\tparam (0,1)  0x%08X 0x%08X\n",
 279                   le32_to_cpu(aq_desc->params.internal.param0),
 280                   le32_to_cpu(aq_desc->params.internal.param1));
 281        iavf_debug(hw, mask, "\taddr (h,l)   0x%08X 0x%08X\n",
 282                   le32_to_cpu(aq_desc->params.external.addr_high),
 283                   le32_to_cpu(aq_desc->params.external.addr_low));
 284
 285        if (buffer && aq_desc->datalen) {
 286                u16 len = le16_to_cpu(aq_desc->datalen);
 287
 288                iavf_debug(hw, mask, "AQ CMD Buffer:\n");
 289                if (buf_len < len)
 290                        len = buf_len;
 291                /* write the full 16-byte chunks */
 292                if (hw->debug_mask & mask) {
 293                        char prefix[27];
 294
 295                        snprintf(prefix, sizeof(prefix),
 296                                 "iavf %02x:%02x.%x: \t0x",
 297                                 hw->bus.bus_id,
 298                                 hw->bus.device,
 299                                 hw->bus.func);
 300
 301                        print_hex_dump(KERN_INFO, prefix, DUMP_PREFIX_OFFSET,
 302                                       16, 1, buf, len, false);
 303                }
 304        }
 305}
 306
 307/**
 308 * iavf_check_asq_alive
 309 * @hw: pointer to the hw struct
 310 *
 311 * Returns true if Queue is enabled else false.
 312 **/
 313bool iavf_check_asq_alive(struct iavf_hw *hw)
 314{
 315        if (hw->aq.asq.len)
 316                return !!(rd32(hw, hw->aq.asq.len) &
 317                          IAVF_VF_ATQLEN1_ATQENABLE_MASK);
 318        else
 319                return false;
 320}
 321
 322/**
 323 * iavf_aq_queue_shutdown
 324 * @hw: pointer to the hw struct
 325 * @unloading: is the driver unloading itself
 326 *
 327 * Tell the Firmware that we're shutting down the AdminQ and whether
 328 * or not the driver is unloading as well.
 329 **/
 330enum iavf_status iavf_aq_queue_shutdown(struct iavf_hw *hw, bool unloading)
 331{
 332        struct iavf_aq_desc desc;
 333        struct iavf_aqc_queue_shutdown *cmd =
 334                (struct iavf_aqc_queue_shutdown *)&desc.params.raw;
 335        enum iavf_status status;
 336
 337        iavf_fill_default_direct_cmd_desc(&desc, iavf_aqc_opc_queue_shutdown);
 338
 339        if (unloading)
 340                cmd->driver_unloading = cpu_to_le32(IAVF_AQ_DRIVER_UNLOADING);
 341        status = iavf_asq_send_command(hw, &desc, NULL, 0, NULL);
 342
 343        return status;
 344}
 345
 346/**
 347 * iavf_aq_get_set_rss_lut
 348 * @hw: pointer to the hardware structure
 349 * @vsi_id: vsi fw index
 350 * @pf_lut: for PF table set true, for VSI table set false
 351 * @lut: pointer to the lut buffer provided by the caller
 352 * @lut_size: size of the lut buffer
 353 * @set: set true to set the table, false to get the table
 354 *
 355 * Internal function to get or set RSS look up table
 356 **/
 357static enum iavf_status iavf_aq_get_set_rss_lut(struct iavf_hw *hw,
 358                                                u16 vsi_id, bool pf_lut,
 359                                                u8 *lut, u16 lut_size,
 360                                                bool set)
 361{
 362        enum iavf_status status;
 363        struct iavf_aq_desc desc;
 364        struct iavf_aqc_get_set_rss_lut *cmd_resp =
 365                   (struct iavf_aqc_get_set_rss_lut *)&desc.params.raw;
 366
 367        if (set)
 368                iavf_fill_default_direct_cmd_desc(&desc,
 369                                                  iavf_aqc_opc_set_rss_lut);
 370        else
 371                iavf_fill_default_direct_cmd_desc(&desc,
 372                                                  iavf_aqc_opc_get_rss_lut);
 373
 374        /* Indirect command */
 375        desc.flags |= cpu_to_le16((u16)IAVF_AQ_FLAG_BUF);
 376        desc.flags |= cpu_to_le16((u16)IAVF_AQ_FLAG_RD);
 377
 378        cmd_resp->vsi_id =
 379                        cpu_to_le16((u16)((vsi_id <<
 380                                          IAVF_AQC_SET_RSS_LUT_VSI_ID_SHIFT) &
 381                                          IAVF_AQC_SET_RSS_LUT_VSI_ID_MASK));
 382        cmd_resp->vsi_id |= cpu_to_le16((u16)IAVF_AQC_SET_RSS_LUT_VSI_VALID);
 383
 384        if (pf_lut)
 385                cmd_resp->flags |= cpu_to_le16((u16)
 386                                        ((IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_PF <<
 387                                        IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT) &
 388                                        IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_MASK));
 389        else
 390                cmd_resp->flags |= cpu_to_le16((u16)
 391                                        ((IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_VSI <<
 392                                        IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT) &
 393                                        IAVF_AQC_SET_RSS_LUT_TABLE_TYPE_MASK));
 394
 395        status = iavf_asq_send_command(hw, &desc, lut, lut_size, NULL);
 396
 397        return status;
 398}
 399
 400/**
 401 * iavf_aq_get_rss_lut
 402 * @hw: pointer to the hardware structure
 403 * @vsi_id: vsi fw index
 404 * @pf_lut: for PF table set true, for VSI table set false
 405 * @lut: pointer to the lut buffer provided by the caller
 406 * @lut_size: size of the lut buffer
 407 *
 408 * get the RSS lookup table, PF or VSI type
 409 **/
 410enum iavf_status iavf_aq_get_rss_lut(struct iavf_hw *hw, u16 vsi_id,
 411                                     bool pf_lut, u8 *lut, u16 lut_size)
 412{
 413        return iavf_aq_get_set_rss_lut(hw, vsi_id, pf_lut, lut, lut_size,
 414                                       false);
 415}
 416
 417/**
 418 * iavf_aq_set_rss_lut
 419 * @hw: pointer to the hardware structure
 420 * @vsi_id: vsi fw index
 421 * @pf_lut: for PF table set true, for VSI table set false
 422 * @lut: pointer to the lut buffer provided by the caller
 423 * @lut_size: size of the lut buffer
 424 *
 425 * set the RSS lookup table, PF or VSI type
 426 **/
 427enum iavf_status iavf_aq_set_rss_lut(struct iavf_hw *hw, u16 vsi_id,
 428                                     bool pf_lut, u8 *lut, u16 lut_size)
 429{
 430        return iavf_aq_get_set_rss_lut(hw, vsi_id, pf_lut, lut, lut_size, true);
 431}
 432
 433/**
 434 * iavf_aq_get_set_rss_key
 435 * @hw: pointer to the hw struct
 436 * @vsi_id: vsi fw index
 437 * @key: pointer to key info struct
 438 * @set: set true to set the key, false to get the key
 439 *
 440 * get the RSS key per VSI
 441 **/
 442static enum
 443iavf_status iavf_aq_get_set_rss_key(struct iavf_hw *hw, u16 vsi_id,
 444                                    struct iavf_aqc_get_set_rss_key_data *key,
 445                                    bool set)
 446{
 447        enum iavf_status status;
 448        struct iavf_aq_desc desc;
 449        struct iavf_aqc_get_set_rss_key *cmd_resp =
 450                        (struct iavf_aqc_get_set_rss_key *)&desc.params.raw;
 451        u16 key_size = sizeof(struct iavf_aqc_get_set_rss_key_data);
 452
 453        if (set)
 454                iavf_fill_default_direct_cmd_desc(&desc,
 455                                                  iavf_aqc_opc_set_rss_key);
 456        else
 457                iavf_fill_default_direct_cmd_desc(&desc,
 458                                                  iavf_aqc_opc_get_rss_key);
 459
 460        /* Indirect command */
 461        desc.flags |= cpu_to_le16((u16)IAVF_AQ_FLAG_BUF);
 462        desc.flags |= cpu_to_le16((u16)IAVF_AQ_FLAG_RD);
 463
 464        cmd_resp->vsi_id =
 465                        cpu_to_le16((u16)((vsi_id <<
 466                                          IAVF_AQC_SET_RSS_KEY_VSI_ID_SHIFT) &
 467                                          IAVF_AQC_SET_RSS_KEY_VSI_ID_MASK));
 468        cmd_resp->vsi_id |= cpu_to_le16((u16)IAVF_AQC_SET_RSS_KEY_VSI_VALID);
 469
 470        status = iavf_asq_send_command(hw, &desc, key, key_size, NULL);
 471
 472        return status;
 473}
 474
 475/**
 476 * iavf_aq_get_rss_key
 477 * @hw: pointer to the hw struct
 478 * @vsi_id: vsi fw index
 479 * @key: pointer to key info struct
 480 *
 481 **/
 482enum iavf_status iavf_aq_get_rss_key(struct iavf_hw *hw, u16 vsi_id,
 483                                     struct iavf_aqc_get_set_rss_key_data *key)
 484{
 485        return iavf_aq_get_set_rss_key(hw, vsi_id, key, false);
 486}
 487
 488/**
 489 * iavf_aq_set_rss_key
 490 * @hw: pointer to the hw struct
 491 * @vsi_id: vsi fw index
 492 * @key: pointer to key info struct
 493 *
 494 * set the RSS key per VSI
 495 **/
 496enum iavf_status iavf_aq_set_rss_key(struct iavf_hw *hw, u16 vsi_id,
 497                                     struct iavf_aqc_get_set_rss_key_data *key)
 498{
 499        return iavf_aq_get_set_rss_key(hw, vsi_id, key, true);
 500}
 501
 502/* The iavf_ptype_lookup table is used to convert from the 8-bit ptype in the
 503 * hardware to a bit-field that can be used by SW to more easily determine the
 504 * packet type.
 505 *
 506 * Macros are used to shorten the table lines and make this table human
 507 * readable.
 508 *
 509 * We store the PTYPE in the top byte of the bit field - this is just so that
 510 * we can check that the table doesn't have a row missing, as the index into
 511 * the table should be the PTYPE.
 512 *
 513 * Typical work flow:
 514 *
 515 * IF NOT iavf_ptype_lookup[ptype].known
 516 * THEN
 517 *      Packet is unknown
 518 * ELSE IF iavf_ptype_lookup[ptype].outer_ip == IAVF_RX_PTYPE_OUTER_IP
 519 *      Use the rest of the fields to look at the tunnels, inner protocols, etc
 520 * ELSE
 521 *      Use the enum iavf_rx_l2_ptype to decode the packet type
 522 * ENDIF
 523 */
 524
 525/* macro to make the table lines short */
 526#define IAVF_PTT(PTYPE, OUTER_IP, OUTER_IP_VER, OUTER_FRAG, T, TE, TEF, I, PL)\
 527        {       PTYPE, \
 528                1, \
 529                IAVF_RX_PTYPE_OUTER_##OUTER_IP, \
 530                IAVF_RX_PTYPE_OUTER_##OUTER_IP_VER, \
 531                IAVF_RX_PTYPE_##OUTER_FRAG, \
 532                IAVF_RX_PTYPE_TUNNEL_##T, \
 533                IAVF_RX_PTYPE_TUNNEL_END_##TE, \
 534                IAVF_RX_PTYPE_##TEF, \
 535                IAVF_RX_PTYPE_INNER_PROT_##I, \
 536                IAVF_RX_PTYPE_PAYLOAD_LAYER_##PL }
 537
 538#define IAVF_PTT_UNUSED_ENTRY(PTYPE) \
 539                { PTYPE, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
 540
 541/* shorter macros makes the table fit but are terse */
 542#define IAVF_RX_PTYPE_NOF               IAVF_RX_PTYPE_NOT_FRAG
 543#define IAVF_RX_PTYPE_FRG               IAVF_RX_PTYPE_FRAG
 544#define IAVF_RX_PTYPE_INNER_PROT_TS     IAVF_RX_PTYPE_INNER_PROT_TIMESYNC
 545
 546/* Lookup table mapping the HW PTYPE to the bit field for decoding */
 547struct iavf_rx_ptype_decoded iavf_ptype_lookup[] = {
 548        /* L2 Packet types */
 549        IAVF_PTT_UNUSED_ENTRY(0),
 550        IAVF_PTT(1,  L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
 551        IAVF_PTT(2,  L2, NONE, NOF, NONE, NONE, NOF, TS,   PAY2),
 552        IAVF_PTT(3,  L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
 553        IAVF_PTT_UNUSED_ENTRY(4),
 554        IAVF_PTT_UNUSED_ENTRY(5),
 555        IAVF_PTT(6,  L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
 556        IAVF_PTT(7,  L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
 557        IAVF_PTT_UNUSED_ENTRY(8),
 558        IAVF_PTT_UNUSED_ENTRY(9),
 559        IAVF_PTT(10, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
 560        IAVF_PTT(11, L2, NONE, NOF, NONE, NONE, NOF, NONE, NONE),
 561        IAVF_PTT(12, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
 562        IAVF_PTT(13, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
 563        IAVF_PTT(14, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
 564        IAVF_PTT(15, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
 565        IAVF_PTT(16, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
 566        IAVF_PTT(17, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
 567        IAVF_PTT(18, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
 568        IAVF_PTT(19, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
 569        IAVF_PTT(20, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
 570        IAVF_PTT(21, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
 571
 572        /* Non Tunneled IPv4 */
 573        IAVF_PTT(22, IP, IPV4, FRG, NONE, NONE, NOF, NONE, PAY3),
 574        IAVF_PTT(23, IP, IPV4, NOF, NONE, NONE, NOF, NONE, PAY3),
 575        IAVF_PTT(24, IP, IPV4, NOF, NONE, NONE, NOF, UDP,  PAY4),
 576        IAVF_PTT_UNUSED_ENTRY(25),
 577        IAVF_PTT(26, IP, IPV4, NOF, NONE, NONE, NOF, TCP,  PAY4),
 578        IAVF_PTT(27, IP, IPV4, NOF, NONE, NONE, NOF, SCTP, PAY4),
 579        IAVF_PTT(28, IP, IPV4, NOF, NONE, NONE, NOF, ICMP, PAY4),
 580
 581        /* IPv4 --> IPv4 */
 582        IAVF_PTT(29, IP, IPV4, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
 583        IAVF_PTT(30, IP, IPV4, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
 584        IAVF_PTT(31, IP, IPV4, NOF, IP_IP, IPV4, NOF, UDP,  PAY4),
 585        IAVF_PTT_UNUSED_ENTRY(32),
 586        IAVF_PTT(33, IP, IPV4, NOF, IP_IP, IPV4, NOF, TCP,  PAY4),
 587        IAVF_PTT(34, IP, IPV4, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
 588        IAVF_PTT(35, IP, IPV4, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
 589
 590        /* IPv4 --> IPv6 */
 591        IAVF_PTT(36, IP, IPV4, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
 592        IAVF_PTT(37, IP, IPV4, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
 593        IAVF_PTT(38, IP, IPV4, NOF, IP_IP, IPV6, NOF, UDP,  PAY4),
 594        IAVF_PTT_UNUSED_ENTRY(39),
 595        IAVF_PTT(40, IP, IPV4, NOF, IP_IP, IPV6, NOF, TCP,  PAY4),
 596        IAVF_PTT(41, IP, IPV4, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
 597        IAVF_PTT(42, IP, IPV4, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
 598
 599        /* IPv4 --> GRE/NAT */
 600        IAVF_PTT(43, IP, IPV4, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
 601
 602        /* IPv4 --> GRE/NAT --> IPv4 */
 603        IAVF_PTT(44, IP, IPV4, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
 604        IAVF_PTT(45, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
 605        IAVF_PTT(46, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, UDP,  PAY4),
 606        IAVF_PTT_UNUSED_ENTRY(47),
 607        IAVF_PTT(48, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, TCP,  PAY4),
 608        IAVF_PTT(49, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
 609        IAVF_PTT(50, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
 610
 611        /* IPv4 --> GRE/NAT --> IPv6 */
 612        IAVF_PTT(51, IP, IPV4, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
 613        IAVF_PTT(52, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
 614        IAVF_PTT(53, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, UDP,  PAY4),
 615        IAVF_PTT_UNUSED_ENTRY(54),
 616        IAVF_PTT(55, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, TCP,  PAY4),
 617        IAVF_PTT(56, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
 618        IAVF_PTT(57, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
 619
 620        /* IPv4 --> GRE/NAT --> MAC */
 621        IAVF_PTT(58, IP, IPV4, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
 622
 623        /* IPv4 --> GRE/NAT --> MAC --> IPv4 */
 624        IAVF_PTT(59, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
 625        IAVF_PTT(60, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
 626        IAVF_PTT(61, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP,  PAY4),
 627        IAVF_PTT_UNUSED_ENTRY(62),
 628        IAVF_PTT(63, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP,  PAY4),
 629        IAVF_PTT(64, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
 630        IAVF_PTT(65, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
 631
 632        /* IPv4 --> GRE/NAT -> MAC --> IPv6 */
 633        IAVF_PTT(66, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
 634        IAVF_PTT(67, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
 635        IAVF_PTT(68, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP,  PAY4),
 636        IAVF_PTT_UNUSED_ENTRY(69),
 637        IAVF_PTT(70, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP,  PAY4),
 638        IAVF_PTT(71, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
 639        IAVF_PTT(72, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
 640
 641        /* IPv4 --> GRE/NAT --> MAC/VLAN */
 642        IAVF_PTT(73, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
 643
 644        /* IPv4 ---> GRE/NAT -> MAC/VLAN --> IPv4 */
 645        IAVF_PTT(74, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
 646        IAVF_PTT(75, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
 647        IAVF_PTT(76, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP,  PAY4),
 648        IAVF_PTT_UNUSED_ENTRY(77),
 649        IAVF_PTT(78, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP,  PAY4),
 650        IAVF_PTT(79, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
 651        IAVF_PTT(80, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
 652
 653        /* IPv4 -> GRE/NAT -> MAC/VLAN --> IPv6 */
 654        IAVF_PTT(81, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
 655        IAVF_PTT(82, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
 656        IAVF_PTT(83, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP,  PAY4),
 657        IAVF_PTT_UNUSED_ENTRY(84),
 658        IAVF_PTT(85, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP,  PAY4),
 659        IAVF_PTT(86, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
 660        IAVF_PTT(87, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
 661
 662        /* Non Tunneled IPv6 */
 663        IAVF_PTT(88, IP, IPV6, FRG, NONE, NONE, NOF, NONE, PAY3),
 664        IAVF_PTT(89, IP, IPV6, NOF, NONE, NONE, NOF, NONE, PAY3),
 665        IAVF_PTT(90, IP, IPV6, NOF, NONE, NONE, NOF, UDP,  PAY3),
 666        IAVF_PTT_UNUSED_ENTRY(91),
 667        IAVF_PTT(92, IP, IPV6, NOF, NONE, NONE, NOF, TCP,  PAY4),
 668        IAVF_PTT(93, IP, IPV6, NOF, NONE, NONE, NOF, SCTP, PAY4),
 669        IAVF_PTT(94, IP, IPV6, NOF, NONE, NONE, NOF, ICMP, PAY4),
 670
 671        /* IPv6 --> IPv4 */
 672        IAVF_PTT(95,  IP, IPV6, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
 673        IAVF_PTT(96,  IP, IPV6, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
 674        IAVF_PTT(97,  IP, IPV6, NOF, IP_IP, IPV4, NOF, UDP,  PAY4),
 675        IAVF_PTT_UNUSED_ENTRY(98),
 676        IAVF_PTT(99,  IP, IPV6, NOF, IP_IP, IPV4, NOF, TCP,  PAY4),
 677        IAVF_PTT(100, IP, IPV6, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
 678        IAVF_PTT(101, IP, IPV6, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
 679
 680        /* IPv6 --> IPv6 */
 681        IAVF_PTT(102, IP, IPV6, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
 682        IAVF_PTT(103, IP, IPV6, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
 683        IAVF_PTT(104, IP, IPV6, NOF, IP_IP, IPV6, NOF, UDP,  PAY4),
 684        IAVF_PTT_UNUSED_ENTRY(105),
 685        IAVF_PTT(106, IP, IPV6, NOF, IP_IP, IPV6, NOF, TCP,  PAY4),
 686        IAVF_PTT(107, IP, IPV6, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
 687        IAVF_PTT(108, IP, IPV6, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
 688
 689        /* IPv6 --> GRE/NAT */
 690        IAVF_PTT(109, IP, IPV6, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
 691
 692        /* IPv6 --> GRE/NAT -> IPv4 */
 693        IAVF_PTT(110, IP, IPV6, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
 694        IAVF_PTT(111, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
 695        IAVF_PTT(112, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, UDP,  PAY4),
 696        IAVF_PTT_UNUSED_ENTRY(113),
 697        IAVF_PTT(114, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, TCP,  PAY4),
 698        IAVF_PTT(115, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
 699        IAVF_PTT(116, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
 700
 701        /* IPv6 --> GRE/NAT -> IPv6 */
 702        IAVF_PTT(117, IP, IPV6, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
 703        IAVF_PTT(118, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
 704        IAVF_PTT(119, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, UDP,  PAY4),
 705        IAVF_PTT_UNUSED_ENTRY(120),
 706        IAVF_PTT(121, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, TCP,  PAY4),
 707        IAVF_PTT(122, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
 708        IAVF_PTT(123, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
 709
 710        /* IPv6 --> GRE/NAT -> MAC */
 711        IAVF_PTT(124, IP, IPV6, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
 712
 713        /* IPv6 --> GRE/NAT -> MAC -> IPv4 */
 714        IAVF_PTT(125, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
 715        IAVF_PTT(126, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
 716        IAVF_PTT(127, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP,  PAY4),
 717        IAVF_PTT_UNUSED_ENTRY(128),
 718        IAVF_PTT(129, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP,  PAY4),
 719        IAVF_PTT(130, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
 720        IAVF_PTT(131, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
 721
 722        /* IPv6 --> GRE/NAT -> MAC -> IPv6 */
 723        IAVF_PTT(132, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
 724        IAVF_PTT(133, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
 725        IAVF_PTT(134, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP,  PAY4),
 726        IAVF_PTT_UNUSED_ENTRY(135),
 727        IAVF_PTT(136, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP,  PAY4),
 728        IAVF_PTT(137, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
 729        IAVF_PTT(138, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
 730
 731        /* IPv6 --> GRE/NAT -> MAC/VLAN */
 732        IAVF_PTT(139, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
 733
 734        /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv4 */
 735        IAVF_PTT(140, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
 736        IAVF_PTT(141, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
 737        IAVF_PTT(142, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP,  PAY4),
 738        IAVF_PTT_UNUSED_ENTRY(143),
 739        IAVF_PTT(144, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP,  PAY4),
 740        IAVF_PTT(145, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
 741        IAVF_PTT(146, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
 742
 743        /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv6 */
 744        IAVF_PTT(147, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
 745        IAVF_PTT(148, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
 746        IAVF_PTT(149, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP,  PAY4),
 747        IAVF_PTT_UNUSED_ENTRY(150),
 748        IAVF_PTT(151, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP,  PAY4),
 749        IAVF_PTT(152, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
 750        IAVF_PTT(153, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
 751
 752        /* unused entries */
 753        IAVF_PTT_UNUSED_ENTRY(154),
 754        IAVF_PTT_UNUSED_ENTRY(155),
 755        IAVF_PTT_UNUSED_ENTRY(156),
 756        IAVF_PTT_UNUSED_ENTRY(157),
 757        IAVF_PTT_UNUSED_ENTRY(158),
 758        IAVF_PTT_UNUSED_ENTRY(159),
 759
 760        IAVF_PTT_UNUSED_ENTRY(160),
 761        IAVF_PTT_UNUSED_ENTRY(161),
 762        IAVF_PTT_UNUSED_ENTRY(162),
 763        IAVF_PTT_UNUSED_ENTRY(163),
 764        IAVF_PTT_UNUSED_ENTRY(164),
 765        IAVF_PTT_UNUSED_ENTRY(165),
 766        IAVF_PTT_UNUSED_ENTRY(166),
 767        IAVF_PTT_UNUSED_ENTRY(167),
 768        IAVF_PTT_UNUSED_ENTRY(168),
 769        IAVF_PTT_UNUSED_ENTRY(169),
 770
 771        IAVF_PTT_UNUSED_ENTRY(170),
 772        IAVF_PTT_UNUSED_ENTRY(171),
 773        IAVF_PTT_UNUSED_ENTRY(172),
 774        IAVF_PTT_UNUSED_ENTRY(173),
 775        IAVF_PTT_UNUSED_ENTRY(174),
 776        IAVF_PTT_UNUSED_ENTRY(175),
 777        IAVF_PTT_UNUSED_ENTRY(176),
 778        IAVF_PTT_UNUSED_ENTRY(177),
 779        IAVF_PTT_UNUSED_ENTRY(178),
 780        IAVF_PTT_UNUSED_ENTRY(179),
 781
 782        IAVF_PTT_UNUSED_ENTRY(180),
 783        IAVF_PTT_UNUSED_ENTRY(181),
 784        IAVF_PTT_UNUSED_ENTRY(182),
 785        IAVF_PTT_UNUSED_ENTRY(183),
 786        IAVF_PTT_UNUSED_ENTRY(184),
 787        IAVF_PTT_UNUSED_ENTRY(185),
 788        IAVF_PTT_UNUSED_ENTRY(186),
 789        IAVF_PTT_UNUSED_ENTRY(187),
 790        IAVF_PTT_UNUSED_ENTRY(188),
 791        IAVF_PTT_UNUSED_ENTRY(189),
 792
 793        IAVF_PTT_UNUSED_ENTRY(190),
 794        IAVF_PTT_UNUSED_ENTRY(191),
 795        IAVF_PTT_UNUSED_ENTRY(192),
 796        IAVF_PTT_UNUSED_ENTRY(193),
 797        IAVF_PTT_UNUSED_ENTRY(194),
 798        IAVF_PTT_UNUSED_ENTRY(195),
 799        IAVF_PTT_UNUSED_ENTRY(196),
 800        IAVF_PTT_UNUSED_ENTRY(197),
 801        IAVF_PTT_UNUSED_ENTRY(198),
 802        IAVF_PTT_UNUSED_ENTRY(199),
 803
 804        IAVF_PTT_UNUSED_ENTRY(200),
 805        IAVF_PTT_UNUSED_ENTRY(201),
 806        IAVF_PTT_UNUSED_ENTRY(202),
 807        IAVF_PTT_UNUSED_ENTRY(203),
 808        IAVF_PTT_UNUSED_ENTRY(204),
 809        IAVF_PTT_UNUSED_ENTRY(205),
 810        IAVF_PTT_UNUSED_ENTRY(206),
 811        IAVF_PTT_UNUSED_ENTRY(207),
 812        IAVF_PTT_UNUSED_ENTRY(208),
 813        IAVF_PTT_UNUSED_ENTRY(209),
 814
 815        IAVF_PTT_UNUSED_ENTRY(210),
 816        IAVF_PTT_UNUSED_ENTRY(211),
 817        IAVF_PTT_UNUSED_ENTRY(212),
 818        IAVF_PTT_UNUSED_ENTRY(213),
 819        IAVF_PTT_UNUSED_ENTRY(214),
 820        IAVF_PTT_UNUSED_ENTRY(215),
 821        IAVF_PTT_UNUSED_ENTRY(216),
 822        IAVF_PTT_UNUSED_ENTRY(217),
 823        IAVF_PTT_UNUSED_ENTRY(218),
 824        IAVF_PTT_UNUSED_ENTRY(219),
 825
 826        IAVF_PTT_UNUSED_ENTRY(220),
 827        IAVF_PTT_UNUSED_ENTRY(221),
 828        IAVF_PTT_UNUSED_ENTRY(222),
 829        IAVF_PTT_UNUSED_ENTRY(223),
 830        IAVF_PTT_UNUSED_ENTRY(224),
 831        IAVF_PTT_UNUSED_ENTRY(225),
 832        IAVF_PTT_UNUSED_ENTRY(226),
 833        IAVF_PTT_UNUSED_ENTRY(227),
 834        IAVF_PTT_UNUSED_ENTRY(228),
 835        IAVF_PTT_UNUSED_ENTRY(229),
 836
 837        IAVF_PTT_UNUSED_ENTRY(230),
 838        IAVF_PTT_UNUSED_ENTRY(231),
 839        IAVF_PTT_UNUSED_ENTRY(232),
 840        IAVF_PTT_UNUSED_ENTRY(233),
 841        IAVF_PTT_UNUSED_ENTRY(234),
 842        IAVF_PTT_UNUSED_ENTRY(235),
 843        IAVF_PTT_UNUSED_ENTRY(236),
 844        IAVF_PTT_UNUSED_ENTRY(237),
 845        IAVF_PTT_UNUSED_ENTRY(238),
 846        IAVF_PTT_UNUSED_ENTRY(239),
 847
 848        IAVF_PTT_UNUSED_ENTRY(240),
 849        IAVF_PTT_UNUSED_ENTRY(241),
 850        IAVF_PTT_UNUSED_ENTRY(242),
 851        IAVF_PTT_UNUSED_ENTRY(243),
 852        IAVF_PTT_UNUSED_ENTRY(244),
 853        IAVF_PTT_UNUSED_ENTRY(245),
 854        IAVF_PTT_UNUSED_ENTRY(246),
 855        IAVF_PTT_UNUSED_ENTRY(247),
 856        IAVF_PTT_UNUSED_ENTRY(248),
 857        IAVF_PTT_UNUSED_ENTRY(249),
 858
 859        IAVF_PTT_UNUSED_ENTRY(250),
 860        IAVF_PTT_UNUSED_ENTRY(251),
 861        IAVF_PTT_UNUSED_ENTRY(252),
 862        IAVF_PTT_UNUSED_ENTRY(253),
 863        IAVF_PTT_UNUSED_ENTRY(254),
 864        IAVF_PTT_UNUSED_ENTRY(255)
 865};
 866
 867/**
 868 * iavf_aq_send_msg_to_pf
 869 * @hw: pointer to the hardware structure
 870 * @v_opcode: opcodes for VF-PF communication
 871 * @v_retval: return error code
 872 * @msg: pointer to the msg buffer
 873 * @msglen: msg length
 874 * @cmd_details: pointer to command details
 875 *
 876 * Send message to PF driver using admin queue. By default, this message
 877 * is sent asynchronously, i.e. iavf_asq_send_command() does not wait for
 878 * completion before returning.
 879 **/
 880enum iavf_status iavf_aq_send_msg_to_pf(struct iavf_hw *hw,
 881                                        enum virtchnl_ops v_opcode,
 882                                        enum iavf_status v_retval,
 883                                        u8 *msg, u16 msglen,
 884                                        struct iavf_asq_cmd_details *cmd_details)
 885{
 886        struct iavf_asq_cmd_details details;
 887        struct iavf_aq_desc desc;
 888        enum iavf_status status;
 889
 890        iavf_fill_default_direct_cmd_desc(&desc, iavf_aqc_opc_send_msg_to_pf);
 891        desc.flags |= cpu_to_le16((u16)IAVF_AQ_FLAG_SI);
 892        desc.cookie_high = cpu_to_le32(v_opcode);
 893        desc.cookie_low = cpu_to_le32(v_retval);
 894        if (msglen) {
 895                desc.flags |= cpu_to_le16((u16)(IAVF_AQ_FLAG_BUF
 896                                                | IAVF_AQ_FLAG_RD));
 897                if (msglen > IAVF_AQ_LARGE_BUF)
 898                        desc.flags |= cpu_to_le16((u16)IAVF_AQ_FLAG_LB);
 899                desc.datalen = cpu_to_le16(msglen);
 900        }
 901        if (!cmd_details) {
 902                memset(&details, 0, sizeof(details));
 903                details.async = true;
 904                cmd_details = &details;
 905        }
 906        status = iavf_asq_send_command(hw, &desc, msg, msglen, cmd_details);
 907        return status;
 908}
 909
 910/**
 911 * iavf_vf_parse_hw_config
 912 * @hw: pointer to the hardware structure
 913 * @msg: pointer to the virtual channel VF resource structure
 914 *
 915 * Given a VF resource message from the PF, populate the hw struct
 916 * with appropriate information.
 917 **/
 918void iavf_vf_parse_hw_config(struct iavf_hw *hw,
 919                             struct virtchnl_vf_resource *msg)
 920{
 921        struct virtchnl_vsi_resource *vsi_res;
 922        int i;
 923
 924        vsi_res = &msg->vsi_res[0];
 925
 926        hw->dev_caps.num_vsis = msg->num_vsis;
 927        hw->dev_caps.num_rx_qp = msg->num_queue_pairs;
 928        hw->dev_caps.num_tx_qp = msg->num_queue_pairs;
 929        hw->dev_caps.num_msix_vectors_vf = msg->max_vectors;
 930        hw->dev_caps.dcb = msg->vf_cap_flags &
 931                           VIRTCHNL_VF_OFFLOAD_L2;
 932        hw->dev_caps.fcoe = 0;
 933        for (i = 0; i < msg->num_vsis; i++) {
 934                if (vsi_res->vsi_type == VIRTCHNL_VSI_SRIOV) {
 935                        ether_addr_copy(hw->mac.perm_addr,
 936                                        vsi_res->default_mac_addr);
 937                        ether_addr_copy(hw->mac.addr,
 938                                        vsi_res->default_mac_addr);
 939                }
 940                vsi_res++;
 941        }
 942}
 943
 944/**
 945 * iavf_vf_reset
 946 * @hw: pointer to the hardware structure
 947 *
 948 * Send a VF_RESET message to the PF. Does not wait for response from PF
 949 * as none will be forthcoming. Immediately after calling this function,
 950 * the admin queue should be shut down and (optionally) reinitialized.
 951 **/
 952enum iavf_status iavf_vf_reset(struct iavf_hw *hw)
 953{
 954        return iavf_aq_send_msg_to_pf(hw, VIRTCHNL_OP_RESET_VF,
 955                                      0, NULL, 0, NULL);
 956}
 957