net/i40e/base: add raw format for 32 bytes Rx description
[dpdk.git] / drivers / net / i40e / base / i40e_adminq.c
index b8c6e30..27c82d9 100644 (file)
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2020 Intel Corporation
  */
 
 #include "i40e_status.h"
@@ -468,7 +468,7 @@ enum i40e_status_code i40e_init_arq(struct i40e_hw *hw)
        /* initialize base registers */
        ret_code = i40e_config_arq_regs(hw);
        if (ret_code != I40E_SUCCESS)
-               goto init_adminq_free_rings;
+               goto init_config_regs;
 
        /* success! */
        hw->aq.arq.count = hw->aq.num_arq_entries;
@@ -476,6 +476,10 @@ enum i40e_status_code i40e_init_arq(struct i40e_hw *hw)
 
 init_adminq_free_rings:
        i40e_free_adminq_arq(hw);
+       return ret_code;
+
+init_config_regs:
+       i40e_free_arq_bufs(hw);
 
 init_adminq_exit:
        return ret_code;
@@ -569,6 +573,70 @@ STATIC void i40e_resume_aq(struct i40e_hw *hw)
 }
 #endif /* PF_DRIVER */
 
+/**
+ *  i40e_set_hw_flags - set HW flags
+ *  @hw: pointer to the hardware structure
+ **/
+STATIC void i40e_set_hw_flags(struct i40e_hw *hw)
+{
+       struct i40e_adminq_info *aq = &hw->aq;
+
+       hw->flags = 0;
+
+       switch (hw->mac.type) {
+       case I40E_MAC_XL710:
+               if (aq->api_maj_ver > 1 ||
+                   (aq->api_maj_ver == 1 &&
+                    aq->api_min_ver >= I40E_MINOR_VER_GET_LINK_INFO_XL710)) {
+                       hw->flags |= I40E_HW_FLAG_AQ_PHY_ACCESS_CAPABLE;
+                       hw->flags |= I40E_HW_FLAG_FW_LLDP_STOPPABLE;
+                       /* The ability to RX (not drop) 802.1ad frames */
+                       hw->flags |= I40E_HW_FLAG_802_1AD_CAPABLE;
+               }
+               break;
+       case I40E_MAC_X722:
+               hw->flags |= I40E_HW_FLAG_AQ_SRCTL_ACCESS_ENABLE |
+                            I40E_HW_FLAG_NVM_READ_REQUIRES_LOCK;
+
+               if (aq->api_maj_ver > 1 ||
+                   (aq->api_maj_ver == 1 &&
+                    aq->api_min_ver >= I40E_MINOR_VER_FW_LLDP_STOPPABLE_X722))
+                       hw->flags |= I40E_HW_FLAG_FW_LLDP_STOPPABLE;
+
+               if (aq->api_maj_ver > 1 ||
+                   (aq->api_maj_ver == 1 &&
+                    aq->api_min_ver >= I40E_MINOR_VER_GET_LINK_INFO_X722))
+                       hw->flags |= I40E_HW_FLAG_AQ_PHY_ACCESS_CAPABLE;
+
+               if (aq->api_maj_ver > 1 ||
+                   (aq->api_maj_ver == 1 &&
+                    aq->api_min_ver >= I40E_MINOR_VER_FW_REQUEST_FEC_X722))
+                       hw->flags |= I40E_HW_FLAG_X722_FEC_REQUEST_CAPABLE;
+
+               /* fall through */
+       default:
+               break;
+       }
+
+       /* Newer versions of firmware require lock when reading the NVM */
+       if (aq->api_maj_ver > 1 ||
+           (aq->api_maj_ver == 1 &&
+            aq->api_min_ver >= 5))
+               hw->flags |= I40E_HW_FLAG_NVM_READ_REQUIRES_LOCK;
+
+       if (aq->api_maj_ver > 1 ||
+           (aq->api_maj_ver == 1 &&
+            aq->api_min_ver >= 8)) {
+               hw->flags |= I40E_HW_FLAG_FW_LLDP_PERSISTENT;
+               hw->flags |= I40E_HW_FLAG_DROP_MODE;
+       }
+
+       if (aq->api_maj_ver > 1 ||
+           (aq->api_maj_ver == 1 &&
+            aq->api_min_ver >= 9))
+               hw->flags |= I40E_HW_FLAG_AQ_PHY_ACCESS_EXTENDED;
+}
+
 /**
  *  i40e_init_adminq - main initialization routine for Admin Queue
  *  @hw: pointer to the hardware structure
@@ -584,8 +652,10 @@ enum i40e_status_code i40e_init_adminq(struct i40e_hw *hw)
 {
        struct i40e_adminq_info *aq = &hw->aq;
        enum i40e_status_code ret_code;
-       u16 cfg_ptr, oem_hi, oem_lo;
-       u16 eetrack_lo, eetrack_hi;
+       u16 oem_hi = 0, oem_lo = 0;
+       u16 eetrack_hi = 0;
+       u16 eetrack_lo = 0;
+       u16 cfg_ptr = 0;
        int retry = 0;
 
        /* verify input for valid configuration */
@@ -615,6 +685,10 @@ enum i40e_status_code i40e_init_adminq(struct i40e_hw *hw)
        if (ret_code != I40E_SUCCESS)
                goto init_adminq_free_asq;
 
+       /* VF has no need of firmware */
+       if (i40e_is_vf(hw))
+               goto init_adminq_exit;
+
        /* There are some cases where the firmware may not be quite ready
         * for AdminQ operations, so we retry the AdminQ setup a few times
         * if we see timeouts in this first AQ call.
@@ -636,6 +710,12 @@ enum i40e_status_code i40e_init_adminq(struct i40e_hw *hw)
        if (ret_code != I40E_SUCCESS)
                goto init_adminq_free_arq;
 
+       /*
+        * Some features were introduced in different FW API version
+        * for different MAC type.
+        */
+       i40e_set_hw_flags(hw);
+
        /* get the NVM version info */
        i40e_read_nvm_word(hw, I40E_SR_NVM_DEV_STARTER_VERSION,
                           &hw->nvm.version);
@@ -715,7 +795,7 @@ u16 i40e_clean_asq(struct i40e_hw *hw)
        desc = I40E_ADMINQ_DESC(*asq, ntc);
        details = I40E_ADMINQ_DETAILS(*asq, ntc);
        while (rd32(hw, hw->aq.asq.head) != ntc) {
-               i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE,
+               i40e_debug(hw, I40E_DEBUG_AQ_COMMAND,
                           "ntc %d head %d.\n", ntc, rd32(hw, hw->aq.asq.head));
 
                if (details->callback) {
@@ -760,7 +840,7 @@ STATIC bool i40e_asq_done(struct i40e_hw *hw)
 }
 
 /**
- *  i40e_asq_send_command - send command to Admin Queue
+ *  i40e_asq_send_command_exec - send command to Admin Queue
  *  @hw: pointer to the hw struct
  *  @desc: prefilled descriptor describing the command (non DMA mem)
  *  @buff: buffer to use for indirect commands
@@ -770,11 +850,12 @@ STATIC bool i40e_asq_done(struct i40e_hw *hw)
  *  This is the main send command driver routine for the Admin Queue send
  *  queue.  It runs the queue, cleans the queue, etc
  **/
-enum i40e_status_code i40e_asq_send_command(struct i40e_hw *hw,
-                               struct i40e_aq_desc *desc,
-                               void *buff, /* can be NULL */
-                               u16  buff_size,
-                               struct i40e_asq_cmd_details *cmd_details)
+STATIC enum i40e_status_code
+i40e_asq_send_command_exec(struct i40e_hw *hw,
+                          struct i40e_aq_desc *desc,
+                          void *buff, /* can be NULL */
+                          u16  buff_size,
+                          struct i40e_asq_cmd_details *cmd_details)
 {
        enum i40e_status_code status = I40E_SUCCESS;
        struct i40e_dma_mem *dma_buff = NULL;
@@ -784,8 +865,6 @@ enum i40e_status_code i40e_asq_send_command(struct i40e_hw *hw,
        u16  retval = 0;
        u32  val = 0;
 
-       i40e_acquire_spinlock(&hw->aq.asq_spinlock);
-
        hw->aq.asq_last_status = I40E_AQ_RC_OK;
 
        if (hw->aq.asq.count == 0) {
@@ -887,7 +966,7 @@ enum i40e_status_code i40e_asq_send_command(struct i40e_hw *hw,
        }
 
        /* bump the tail */
-       i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE, "AQTX: desc and buffer:\n");
+       i40e_debug(hw, I40E_DEBUG_AQ_COMMAND, "AQTX: desc and buffer:\n");
        i40e_debug_aq(hw, I40E_DEBUG_AQ_COMMAND, (void *)desc_on_ring,
                      buff, buff_size);
        (hw->aq.asq.next_to_use)++;
@@ -940,7 +1019,7 @@ enum i40e_status_code i40e_asq_send_command(struct i40e_hw *hw,
                hw->aq.asq_last_status = (enum i40e_admin_queue_err)retval;
        }
 
-       i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE,
+       i40e_debug(hw, I40E_DEBUG_AQ_COMMAND,
                   "AQTX: desc and buffer writeback:\n");
        i40e_debug_aq(hw, I40E_DEBUG_AQ_COMMAND, (void *)desc, buff, buff_size);
 
@@ -968,6 +1047,64 @@ enum i40e_status_code i40e_asq_send_command(struct i40e_hw *hw,
        }
 
 asq_send_command_error:
+       return status;
+}
+
+/**
+ *  i40e_asq_send_command - send command to Admin Queue
+ *  @hw: pointer to the hw struct
+ *  @desc: prefilled descriptor describing the command (non DMA mem)
+ *  @buff: buffer to use for indirect commands
+ *  @buff_size: size of buffer for indirect commands
+ *  @cmd_details: pointer to command details structure
+ *
+ *  Acquires the lock and calls the main send command execution
+ *  routine.
+ **/
+enum i40e_status_code
+i40e_asq_send_command(struct i40e_hw *hw,
+                     struct i40e_aq_desc *desc,
+                     void *buff, /* can be NULL */
+                     u16  buff_size,
+                     struct i40e_asq_cmd_details *cmd_details)
+{
+       enum i40e_status_code status = I40E_SUCCESS;
+
+       i40e_acquire_spinlock(&hw->aq.asq_spinlock);
+       status = i40e_asq_send_command_exec(hw, desc, buff, buff_size,
+                                           cmd_details);
+       i40e_release_spinlock(&hw->aq.asq_spinlock);
+       return status;
+}
+
+/**
+ *  i40e_asq_send_command_v2 - send command to Admin Queue
+ *  @hw: pointer to the hw struct
+ *  @desc: prefilled descriptor describing the command (non DMA mem)
+ *  @buff: buffer to use for indirect commands
+ *  @buff_size: size of buffer for indirect commands
+ *  @cmd_details: pointer to command details structure
+ *  @aq_status: pointer to Admin Queue status return value
+ *
+ *  Acquires the lock and calls the main send command execution
+ *  routine. Returns the last Admin Queue status in aq_status
+ *  to avoid race conditions in access to hw->aq.asq_last_status.
+ **/
+enum i40e_status_code
+i40e_asq_send_command_v2(struct i40e_hw *hw,
+                        struct i40e_aq_desc *desc,
+                        void *buff, /* can be NULL */
+                        u16  buff_size,
+                        struct i40e_asq_cmd_details *cmd_details,
+                        enum i40e_admin_queue_err *aq_status)
+{
+       enum i40e_status_code status = I40E_SUCCESS;
+
+       i40e_acquire_spinlock(&hw->aq.asq_spinlock);
+       status = i40e_asq_send_command_exec(hw, desc, buff, buff_size,
+                                           cmd_details);
+       if (aq_status)
+               *aq_status = hw->aq.asq_last_status;
        i40e_release_spinlock(&hw->aq.asq_spinlock);
        return status;
 }
@@ -1069,7 +1206,7 @@ enum i40e_status_code i40e_clean_arq_element(struct i40e_hw *hw,
                            hw->aq.arq.r.arq_bi[desc_idx].va,
                            e->msg_len, I40E_DMA_TO_NONDMA);
 
-       i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE, "AQRX: desc and buffer:\n");
+       i40e_debug(hw, I40E_DEBUG_AQ_COMMAND, "AQRX: desc and buffer:\n");
        i40e_debug_aq(hw, I40E_DEBUG_AQ_COMMAND, (void *)desc, e->msg_buf,
                      hw->aq.arq_buf_size);