remove repeated 'the' in the code
[dpdk.git] / drivers / net / i40e / base / i40e_common.c
index cd8b27e..9eee104 100644 (file)
@@ -2,6 +2,8 @@
  * Copyright(c) 2001-2020 Intel Corporation
  */
 
+#include <inttypes.h>
+
 #include "i40e_type.h"
 #include "i40e_adminq.h"
 #include "i40e_prototype.h"
@@ -1274,12 +1276,15 @@ STATIC enum i40e_media_type i40e_get_media_type(struct i40e_hw *hw)
        case I40E_PHY_TYPE_40GBASE_LR4:
        case I40E_PHY_TYPE_25GBASE_LR:
        case I40E_PHY_TYPE_25GBASE_SR:
+       case I40E_PHY_TYPE_10GBASE_AOC:
+       case I40E_PHY_TYPE_25GBASE_AOC:
+       case I40E_PHY_TYPE_40GBASE_AOC:
                media = I40E_MEDIA_TYPE_FIBER;
                break;
        case I40E_PHY_TYPE_100BASE_TX:
        case I40E_PHY_TYPE_1000BASE_T:
-       case I40E_PHY_TYPE_2_5GBASE_T:
-       case I40E_PHY_TYPE_5GBASE_T:
+       case I40E_PHY_TYPE_2_5GBASE_T_LINK_STATUS:
+       case I40E_PHY_TYPE_5GBASE_T_LINK_STATUS:
        case I40E_PHY_TYPE_10GBASE_T:
                media = I40E_MEDIA_TYPE_BASET;
                break;
@@ -1288,10 +1293,7 @@ STATIC enum i40e_media_type i40e_get_media_type(struct i40e_hw *hw)
        case I40E_PHY_TYPE_10GBASE_CR1:
        case I40E_PHY_TYPE_40GBASE_CR4:
        case I40E_PHY_TYPE_10GBASE_SFPP_CU:
-       case I40E_PHY_TYPE_40GBASE_AOC:
-       case I40E_PHY_TYPE_10GBASE_AOC:
        case I40E_PHY_TYPE_25GBASE_CR:
-       case I40E_PHY_TYPE_25GBASE_AOC:
        case I40E_PHY_TYPE_25GBASE_ACC:
                media = I40E_MEDIA_TYPE_DA;
                break;
@@ -1339,7 +1341,7 @@ STATIC enum i40e_status_code i40e_poll_globr(struct i40e_hw *hw,
        return I40E_ERR_RESET_FAILED;
 }
 
-#define I40E_PF_RESET_WAIT_COUNT       200
+#define I40E_PF_RESET_WAIT_COUNT       1000
 /**
  * i40e_pf_reset - Reset the PF
  * @hw: pointer to the hardware structure
@@ -2076,6 +2078,9 @@ enum i40e_status_code i40e_aq_get_link_info(struct i40e_hw *hw,
             hw->aq.fw_min_ver < 40)) && hw_link_info->phy_type == 0xE)
                hw_link_info->phy_type = I40E_PHY_TYPE_10GBASE_SFPP_CU;
 
+       /* 'Get Link Status' response data structure from X722 FW has
+        * different format and does not contain this information
+        */
        if (hw->flags & I40E_HW_FLAG_AQ_PHY_ACCESS_CAPABLE &&
            hw->mac.type != I40E_MAC_X722) {
                __le32 tmp;
@@ -2672,7 +2677,7 @@ enum i40e_status_code i40e_aq_set_vsi_vlan_promisc(struct i40e_hw *hw,
 }
 
 /**
- * i40e_get_vsi_params - get VSI configuration info
+ * i40e_aq_get_vsi_params - get VSI configuration info
  * @hw: pointer to the hw struct
  * @vsi_ctx: pointer to a vsi context struct
  * @cmd_details: pointer to command details structure or NULL
@@ -2933,7 +2938,7 @@ enum i40e_status_code i40e_get_link_status(struct i40e_hw *hw, bool *link_up)
 }
 
 /**
- * i40e_updatelink_status - update status of the HW network link
+ * i40e_update_link_info - update status of the HW network link
  * @hw: pointer to the hw struct
  **/
 enum i40e_status_code i40e_update_link_info(struct i40e_hw *hw)
@@ -2946,10 +2951,13 @@ enum i40e_status_code i40e_update_link_info(struct i40e_hw *hw)
                return status;
 
        /* extra checking needed to ensure link info to user is timely */
-       if ((hw->phy.link_info.link_info & I40E_AQ_MEDIA_AVAILABLE) &&
-           ((hw->phy.link_info.link_info & I40E_AQ_LINK_UP) ||
-            !(hw->phy.link_info_old.link_info & I40E_AQ_LINK_UP))) {
-               status = i40e_aq_get_phy_capabilities(hw, false, false,
+       if (((hw->phy.link_info.link_info & I40E_AQ_MEDIA_AVAILABLE) &&
+            ((hw->phy.link_info.link_info & I40E_AQ_LINK_UP) ||
+             !(hw->phy.link_info_old.link_info & I40E_AQ_LINK_UP))) ||
+               hw->mac.type == I40E_MAC_X722) {
+               status = i40e_aq_get_phy_capabilities(hw, false,
+                                                     hw->mac.type ==
+                                                     I40E_MAC_X722,
                                                      &abilities, NULL);
                if (status)
                        return status;
@@ -3112,6 +3120,46 @@ get_veb_exit:
        return status;
 }
 
+/**
+ * i40e_prepare_add_macvlan
+ * @mv_list: list of macvlans to be added
+ * @desc: pointer to AQ descriptor structure
+ * @count: length of the list
+ * @seid: VSI for the mac address
+ *
+ * Internal helper function that prepares the add macvlan request
+ * and returns the buffer size.
+ **/
+static u16
+i40e_prepare_add_macvlan(struct i40e_aqc_add_macvlan_element_data *mv_list,
+                        struct i40e_aq_desc *desc, u16 count, u16 seid)
+{
+       struct i40e_aqc_macvlan *cmd =
+               (struct i40e_aqc_macvlan *)&desc->params.raw;
+       u16 buf_size;
+       int i;
+
+       buf_size = count * sizeof(*mv_list);
+
+       /* prep the rest of the request */
+       i40e_fill_default_direct_cmd_desc(desc, i40e_aqc_opc_add_macvlan);
+       cmd->num_addresses = CPU_TO_LE16(count);
+       cmd->seid[0] = CPU_TO_LE16(I40E_AQC_MACVLAN_CMD_SEID_VALID | seid);
+       cmd->seid[1] = 0;
+       cmd->seid[2] = 0;
+
+       for (i = 0; i < count; i++)
+               if (I40E_IS_MULTICAST(mv_list[i].mac_addr))
+                       mv_list[i].flags |=
+                           CPU_TO_LE16(I40E_AQC_MACVLAN_ADD_USE_SHARED_MAC);
+
+       desc->flags |= CPU_TO_LE16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
+       if (buf_size > I40E_AQ_LARGE_BUF)
+               desc->flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
+
+       return buf_size;
+}
+
 /**
  * i40e_aq_add_macvlan
  * @hw: pointer to the hw struct
@@ -3122,8 +3170,74 @@ get_veb_exit:
  *
  * Add MAC/VLAN addresses to the HW filtering
  **/
-enum i40e_status_code i40e_aq_add_macvlan(struct i40e_hw *hw, u16 seid,
-                       struct i40e_aqc_add_macvlan_element_data *mv_list,
+enum i40e_status_code
+i40e_aq_add_macvlan(struct i40e_hw *hw, u16 seid,
+                   struct i40e_aqc_add_macvlan_element_data *mv_list,
+                   u16 count, struct i40e_asq_cmd_details *cmd_details)
+{
+       struct i40e_aq_desc desc;
+       enum i40e_status_code status;
+       u16 buf_size;
+
+       if (count == 0 || !mv_list || !hw)
+               return I40E_ERR_PARAM;
+
+       buf_size = i40e_prepare_add_macvlan(mv_list, &desc, count, seid);
+
+       status = i40e_asq_send_command(hw, &desc, mv_list, buf_size,
+                                      cmd_details);
+
+       return status;
+}
+
+/**
+ * i40e_aq_add_macvlan_v2
+ * @hw: pointer to the hw struct
+ * @seid: VSI for the mac address
+ * @mv_list: list of macvlans to be added
+ * @count: length of the list
+ * @cmd_details: pointer to command details structure or NULL
+ * @aq_status: pointer to Admin Queue status return value
+ *
+ * Add MAC/VLAN addresses to the HW filtering.
+ * The _v2 version returns the last Admin Queue status in aq_status
+ * to avoid race conditions in access to hw->aq.asq_last_status.
+ * It also calls _v2 versions of asq_send_command functions to
+ * get the aq_status on the stack.
+ **/
+enum i40e_status_code
+i40e_aq_add_macvlan_v2(struct i40e_hw *hw, u16 seid,
+                      struct i40e_aqc_add_macvlan_element_data *mv_list,
+                      u16 count, struct i40e_asq_cmd_details *cmd_details,
+                      enum i40e_admin_queue_err *aq_status)
+{
+       struct i40e_aq_desc desc;
+       enum i40e_status_code status;
+       u16 buf_size;
+
+       if (count == 0 || !mv_list || !hw)
+               return I40E_ERR_PARAM;
+
+       buf_size = i40e_prepare_add_macvlan(mv_list, &desc, count, seid);
+
+       status = i40e_asq_send_command_v2(hw, &desc, mv_list, buf_size,
+                                         cmd_details, aq_status);
+
+       return status;
+}
+
+/**
+ * i40e_aq_remove_macvlan
+ * @hw: pointer to the hw struct
+ * @seid: VSI for the mac address
+ * @mv_list: list of macvlans to be removed
+ * @count: length of the list
+ * @cmd_details: pointer to command details structure or NULL
+ *
+ * Remove MAC/VLAN addresses from the HW filtering
+ **/
+enum i40e_status_code i40e_aq_remove_macvlan(struct i40e_hw *hw, u16 seid,
+                       struct i40e_aqc_remove_macvlan_element_data *mv_list,
                        u16 count, struct i40e_asq_cmd_details *cmd_details)
 {
        struct i40e_aq_desc desc;
@@ -3131,7 +3245,6 @@ enum i40e_status_code i40e_aq_add_macvlan(struct i40e_hw *hw, u16 seid,
                (struct i40e_aqc_macvlan *)&desc.params.raw;
        enum i40e_status_code status;
        u16 buf_size;
-       int i;
 
        if (count == 0 || !mv_list || !hw)
                return I40E_ERR_PARAM;
@@ -3139,17 +3252,12 @@ enum i40e_status_code i40e_aq_add_macvlan(struct i40e_hw *hw, u16 seid,
        buf_size = count * sizeof(*mv_list);
 
        /* prep the rest of the request */
-       i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_add_macvlan);
+       i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_remove_macvlan);
        cmd->num_addresses = CPU_TO_LE16(count);
        cmd->seid[0] = CPU_TO_LE16(I40E_AQC_MACVLAN_CMD_SEID_VALID | seid);
        cmd->seid[1] = 0;
        cmd->seid[2] = 0;
 
-       for (i = 0; i < count; i++)
-               if (I40E_IS_MULTICAST(mv_list[i].mac_addr))
-                       mv_list[i].flags |=
-                           CPU_TO_LE16(I40E_AQC_MACVLAN_ADD_USE_SHARED_MAC);
-
        desc.flags |= CPU_TO_LE16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
        if (buf_size > I40E_AQ_LARGE_BUF)
                desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
@@ -3161,18 +3269,25 @@ enum i40e_status_code i40e_aq_add_macvlan(struct i40e_hw *hw, u16 seid,
 }
 
 /**
- * i40e_aq_remove_macvlan
+ * i40e_aq_remove_macvlan_v2
  * @hw: pointer to the hw struct
  * @seid: VSI for the mac address
  * @mv_list: list of macvlans to be removed
  * @count: length of the list
  * @cmd_details: pointer to command details structure or NULL
+ * @aq_status: pointer to Admin Queue status return value
  *
- * Remove MAC/VLAN addresses from the HW filtering
+ * Remove MAC/VLAN addresses from the HW filtering.
+ * The _v2 version returns the last Admin Queue status in aq_status
+ * to avoid race conditions in access to hw->aq.asq_last_status.
+ * It also calls _v2 versions of asq_send_command functions to
+ * get the aq_status on the stack.
  **/
-enum i40e_status_code i40e_aq_remove_macvlan(struct i40e_hw *hw, u16 seid,
-                       struct i40e_aqc_remove_macvlan_element_data *mv_list,
-                       u16 count, struct i40e_asq_cmd_details *cmd_details)
+enum i40e_status_code
+i40e_aq_remove_macvlan_v2(struct i40e_hw *hw, u16 seid,
+                         struct i40e_aqc_remove_macvlan_element_data *mv_list,
+                         u16 count, struct i40e_asq_cmd_details *cmd_details,
+                         enum i40e_admin_queue_err *aq_status)
 {
        struct i40e_aq_desc desc;
        struct i40e_aqc_macvlan *cmd =
@@ -3196,8 +3311,8 @@ enum i40e_status_code i40e_aq_remove_macvlan(struct i40e_hw *hw, u16 seid,
        if (buf_size > I40E_AQ_LARGE_BUF)
                desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
 
-       status = i40e_asq_send_command(hw, &desc, mv_list, buf_size,
-                                      cmd_details);
+       status = i40e_asq_send_command_v2(hw, &desc, mv_list, buf_size,
+                                         cmd_details, aq_status);
 
        return status;
 }
@@ -4098,7 +4213,7 @@ STATIC void i40e_parse_discover_capabilities(struct i40e_hw *hw, void *buff,
                        p->wr_csr_prot = (u64)number;
                        p->wr_csr_prot |= (u64)logical_id << 32;
                        i40e_debug(hw, I40E_DEBUG_INIT,
-                                  "HW Capability: wr_csr_prot = 0x%llX\n\n",
+                                  "HW Capability: wr_csr_prot = 0x%" PRIX64 "\n\n",
                                   (p->wr_csr_prot & 0xffff));
                        break;
                case I40E_AQ_CAP_ID_DIS_UNUSED_PORTS:
@@ -4715,7 +4830,7 @@ enum i40e_status_code i40e_aq_del_udp_tunnel(struct i40e_hw *hw, u8 index,
 }
 
 /**
- * i40e_aq_get_switch_resource_alloc (0x0204)
+ * i40e_aq_get_switch_resource_alloc - command (0x0204) to get allocations
  * @hw: pointer to the hw struct
  * @num_entries: pointer to u8 to store the number of resource entries returned
  * @buf: pointer to a user supplied buffer.  This buffer must be large enough
@@ -5854,7 +5969,7 @@ enum i40e_status_code i40e_aq_add_cloud_filters(struct i40e_hw *hw,
  * @filter_count: number of filters contained in the buffer
  *
  * Set the cloud filters for a given VSI.  The contents of the
- * i40e_aqc_cloud_filters_element_bb are filled in by the caller of the
+ * i40e_aqc_cloud_filters_element_bb are filled in by the caller of
  * the function.
  *
  **/
@@ -6449,6 +6564,7 @@ enum i40e_status_code i40e_enable_eee(struct i40e_hw *hw, bool enable)
 
        /* Cache current configuration */
        config.phy_type = abilities.phy_type;
+       config.phy_type_ext = abilities.phy_type_ext;
        config.link_speed = abilities.link_speed;
        config.abilities = abilities.abilities |
                           I40E_AQ_PHY_ENABLE_ATOMIC_LINK;
@@ -6861,7 +6977,7 @@ u8 i40e_get_phy_address(struct i40e_hw *hw, u8 dev_num)
 }
 
 /**
- * i40e_blink_phy_led
+ * i40e_blink_phy_link_led
  * @hw: pointer to the HW structure
  * @time: time how long led will blinks in secs
  * @interval: gap between LED on and off in msecs
@@ -7098,15 +7214,23 @@ enum i40e_status_code i40e_get_phy_lpi_status(struct i40e_hw *hw,
                                              struct i40e_hw_port_stats *stat)
 {
        enum i40e_status_code ret = I40E_SUCCESS;
+       bool eee_mrvl_phy;
+       bool eee_bcm_phy;
        u32 val;
 
        stat->rx_lpi_status = 0;
        stat->tx_lpi_status = 0;
 
-       if ((hw->device_id == I40E_DEV_ID_10G_BASE_T_BC ||
-            hw->device_id == I40E_DEV_ID_5G_BASE_T_BC) &&
-           (hw->phy.link_info.link_speed == I40E_LINK_SPEED_2_5GB ||
-            hw->phy.link_info.link_speed == I40E_LINK_SPEED_5GB)) {
+       eee_bcm_phy =
+               (hw->device_id == I40E_DEV_ID_10G_BASE_T_BC ||
+                hw->device_id == I40E_DEV_ID_5G_BASE_T_BC) &&
+               (hw->phy.link_info.link_speed == I40E_LINK_SPEED_2_5GB ||
+                hw->phy.link_info.link_speed == I40E_LINK_SPEED_5GB);
+       eee_mrvl_phy =
+               hw->device_id == I40E_DEV_ID_1G_BASE_T_X722;
+
+       if (eee_bcm_phy || eee_mrvl_phy) {
+               /* read Clause 45 PCS Status 1 register */
                ret = i40e_aq_get_phy_register(hw,
                                               I40E_AQ_PHY_REG_ACCESS_EXTERNAL,
                                               I40E_BCM_PHY_PCS_STATUS1_PAGE,
@@ -7700,7 +7824,7 @@ enum i40e_status_code i40e_aq_set_arp_proxy_config(struct i40e_hw *hw,
 }
 
 /**
- * i40e_aq_opc_set_ns_proxy_table_entry
+ * i40e_aq_set_ns_proxy_table_entry
  * @hw: pointer to the HW structure
  * @ns_proxy_table_entry: pointer to NS table entry command struct
  * @cmd_details: pointer to command details