net/i40e/base: remove unnecessary code
[dpdk.git] / drivers / net / i40e / base / i40e_common.c
index 2383153..aa346d1 100644 (file)
@@ -67,6 +67,8 @@ STATIC enum i40e_status_code i40e_set_mac_type(struct i40e_hw *hw)
                case I40E_DEV_ID_10G_BASE_T4:
                case I40E_DEV_ID_20G_KR2:
                case I40E_DEV_ID_20G_KR2_A:
+               case I40E_DEV_ID_25G_B:
+               case I40E_DEV_ID_25G_SFP28:
                        hw->mac.type = I40E_MAC_XL710;
                        break;
 #ifdef X722_SUPPORT
@@ -78,6 +80,7 @@ STATIC enum i40e_status_code i40e_set_mac_type(struct i40e_hw *hw)
                case I40E_DEV_ID_SFP_X722:
                case I40E_DEV_ID_1G_BASE_T_X722:
                case I40E_DEV_ID_10G_BASE_T_X722:
+               case I40E_DEV_ID_SFP_I_X722:
                        hw->mac.type = I40E_MAC_X722;
                        break;
 #endif
@@ -371,14 +374,15 @@ void i40e_debug_aq(struct i40e_hw *hw, enum i40e_debug_mask mask, void *desc,
                /* the most we could have left is 16 bytes, pad with zeros */
                if (i < len) {
                        char d_buf[16];
-                       int j;
+                       int j, i_sav;
 
+                       i_sav = i;
                        memset(d_buf, 0, sizeof(d_buf));
                        for (j = 0; i < len; j++, i++)
                                d_buf[j] = buf[i];
                        i40e_debug(hw, mask,
                                   "\t0x%04X  %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n",
-                                  i, d_buf[0], d_buf[1], d_buf[2], d_buf[3],
+                                  i_sav, d_buf[0], d_buf[1], d_buf[2], d_buf[3],
                                   d_buf[4], d_buf[5], d_buf[6], d_buf[7],
                                   d_buf[8], d_buf[9], d_buf[10], d_buf[11],
                                   d_buf[12], d_buf[13], d_buf[14], d_buf[15]);
@@ -767,7 +771,7 @@ struct i40e_rx_ptype_decoded i40e_ptype_lookup[] = {
        /* Non Tunneled IPv6 */
        I40E_PTT(88, IP, IPV6, FRG, NONE, NONE, NOF, NONE, PAY3),
        I40E_PTT(89, IP, IPV6, NOF, NONE, NONE, NOF, NONE, PAY3),
-       I40E_PTT(90, IP, IPV6, NOF, NONE, NONE, NOF, UDP,  PAY3),
+       I40E_PTT(90, IP, IPV6, NOF, NONE, NONE, NOF, UDP,  PAY4),
        I40E_PTT_UNUSED_ENTRY(91),
        I40E_PTT(92, IP, IPV6, NOF, NONE, NONE, NOF, TCP,  PAY4),
        I40E_PTT(93, IP, IPV6, NOF, NONE, NONE, NOF, SCTP, PAY4),
@@ -1184,6 +1188,32 @@ void i40e_pre_tx_queue_cfg(struct i40e_hw *hw, u32 queue, bool enable)
        wr32(hw, I40E_GLLAN_TXPRE_QDIS(reg_block), reg_val);
 }
 
+/**
+ * i40e_get_san_mac_addr - get SAN MAC address
+ * @hw: pointer to the HW structure
+ * @mac_addr: pointer to SAN MAC address
+ *
+ * Reads the adapter's SAN MAC address from NVM
+ **/
+enum i40e_status_code i40e_get_san_mac_addr(struct i40e_hw *hw,
+                                           u8 *mac_addr)
+{
+       struct i40e_aqc_mac_address_read_data addrs;
+       enum i40e_status_code status;
+       u16 flags = 0;
+
+       status = i40e_aq_mac_address_read(hw, &flags, &addrs, NULL);
+       if (status)
+               return status;
+
+       if (flags & I40E_AQC_SAN_ADDR_VALID)
+               memcpy(mac_addr, &addrs.pf_san_mac, sizeof(addrs.pf_san_mac));
+       else
+               status = I40E_ERR_INVALID_MAC_ADDR;
+
+       return status;
+}
+
 /**
  *  i40e_read_pba_string - Reads part number string from EEPROM
  *  @hw: pointer to hardware structure
@@ -1316,11 +1346,10 @@ enum i40e_status_code i40e_pf_reset(struct i40e_hw *hw)
        grst_del = (rd32(hw, I40E_GLGEN_RSTCTL) &
                        I40E_GLGEN_RSTCTL_GRSTDEL_MASK) >>
                        I40E_GLGEN_RSTCTL_GRSTDEL_SHIFT;
-#ifdef I40E_ESS_SUPPORT
-       /* It can take upto 15 secs for GRST steady state */
-       grst_del = grst_del * 20; /* bump it to 16 secs max to be safe */
-#endif
-       for (cnt = 0; cnt < grst_del + 10; cnt++) {
+
+       grst_del = grst_del * 20;
+
+       for (cnt = 0; cnt < grst_del; cnt++) {
                reg = rd32(hw, I40E_GLGEN_RSTAT);
                if (!(reg & I40E_GLGEN_RSTAT_DEVSTATE_MASK))
                        break;
@@ -1540,9 +1569,11 @@ u32 i40e_led_get(struct i40e_hw *hw)
                if (!gpio_val)
                        continue;
 
-               /* ignore gpio LED src mode entries related to the activity LEDs */
-               current_mode = ((gpio_val & I40E_GLGEN_GPIO_CTL_LED_MODE_MASK) >>
-                       I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT);
+               /* ignore gpio LED src mode entries related to the activity
+                *  LEDs
+                */
+               current_mode = ((gpio_val & I40E_GLGEN_GPIO_CTL_LED_MODE_MASK)
+                               >> I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT);
                switch (current_mode) {
                case I40E_COMBINED_ACTIVITY:
                case I40E_FILTER_ACTIVITY:
@@ -1586,9 +1617,11 @@ void i40e_led_set(struct i40e_hw *hw, u32 mode, bool blink)
                if (!gpio_val)
                        continue;
 
-               /* ignore gpio LED src mode entries related to the activity LEDs */
-               current_mode = ((gpio_val & I40E_GLGEN_GPIO_CTL_LED_MODE_MASK) >>
-                       I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT);
+               /* ignore gpio LED src mode entries related to the activity
+                * LEDs
+                */
+               current_mode = ((gpio_val & I40E_GLGEN_GPIO_CTL_LED_MODE_MASK)
+                               >> I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT);
                switch (current_mode) {
                case I40E_COMBINED_ACTIVITY:
                case I40E_FILTER_ACTIVITY:
@@ -1661,8 +1694,10 @@ enum i40e_status_code i40e_aq_get_phy_capabilities(struct i40e_hw *hw,
        if (hw->aq.asq_last_status == I40E_AQ_RC_EIO)
                status = I40E_ERR_UNKNOWN_PHY;
 
-       if (report_init)
+       if (report_init) {
                hw->phy.phy_types = LE32_TO_CPU(abilities->phy_type);
+               hw->phy.phy_types |= ((u64)abilities->phy_type_ext << 32);
+       }
 
        return status;
 }
@@ -1754,6 +1789,7 @@ enum i40e_status_code i40e_set_fc(struct i40e_hw *hw, u8 *aq_failures,
                        config.abilities |= I40E_AQ_PHY_ENABLE_ATOMIC_LINK;
                /* Copy over all the old settings */
                config.phy_type = abilities.phy_type;
+               config.phy_type_ext = abilities.phy_type_ext;
                config.link_speed = abilities.link_speed;
                config.eee_capability = abilities.eee_capability;
                config.eeer = abilities.eeer_val;
@@ -2205,16 +2241,46 @@ enum i40e_status_code i40e_aq_set_default_vsi(struct i40e_hw *hw,
        return status;
 }
 
+/**
+ * i40e_aq_clear_default_vsi
+ * @hw: pointer to the hw struct
+ * @seid: vsi number
+ * @cmd_details: pointer to command details structure or NULL
+ **/
+enum i40e_status_code i40e_aq_clear_default_vsi(struct i40e_hw *hw,
+                               u16 seid,
+                               struct i40e_asq_cmd_details *cmd_details)
+{
+       struct i40e_aq_desc desc;
+       struct i40e_aqc_set_vsi_promiscuous_modes *cmd =
+               (struct i40e_aqc_set_vsi_promiscuous_modes *)
+               &desc.params.raw;
+       enum i40e_status_code status;
+
+       i40e_fill_default_direct_cmd_desc(&desc,
+                                       i40e_aqc_opc_set_vsi_promiscuous_modes);
+
+       cmd->promiscuous_flags = CPU_TO_LE16(0);
+       cmd->valid_flags = CPU_TO_LE16(I40E_AQC_SET_VSI_DEFAULT);
+       cmd->seid = CPU_TO_LE16(seid);
+
+       status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
+
+       return status;
+}
+
 /**
  * i40e_aq_set_vsi_unicast_promiscuous
  * @hw: pointer to the hw struct
  * @seid: vsi number
  * @set: set unicast promiscuous enable/disable
  * @cmd_details: pointer to command details structure or NULL
+ * @rx_only_promisc: flag to decide if egress traffic gets mirrored in promisc
  **/
 enum i40e_status_code i40e_aq_set_vsi_unicast_promiscuous(struct i40e_hw *hw,
                                u16 seid, bool set,
-                               struct i40e_asq_cmd_details *cmd_details)
+                               struct i40e_asq_cmd_details *cmd_details,
+                               bool rx_only_promisc)
 {
        struct i40e_aq_desc desc;
        struct i40e_aqc_set_vsi_promiscuous_modes *cmd =
@@ -2225,12 +2291,20 @@ enum i40e_status_code i40e_aq_set_vsi_unicast_promiscuous(struct i40e_hw *hw,
        i40e_fill_default_direct_cmd_desc(&desc,
                                        i40e_aqc_opc_set_vsi_promiscuous_modes);
 
-       if (set)
+       if (set) {
                flags |= I40E_AQC_SET_VSI_PROMISC_UNICAST;
+               if (rx_only_promisc &&
+                   (((hw->aq.api_maj_ver == 1) && (hw->aq.api_min_ver >= 5)) ||
+                    (hw->aq.api_maj_ver > 1)))
+                       flags |= I40E_AQC_SET_VSI_PROMISC_TX;
+       }
 
        cmd->promiscuous_flags = CPU_TO_LE16(flags);
 
        cmd->valid_flags = CPU_TO_LE16(I40E_AQC_SET_VSI_PROMISC_UNICAST);
+       if (((hw->aq.api_maj_ver >= 1) && (hw->aq.api_min_ver >= 5)) ||
+            (hw->aq.api_maj_ver > 1))
+               cmd->valid_flags |= CPU_TO_LE16(I40E_AQC_SET_VSI_PROMISC_TX);
 
        cmd->seid = CPU_TO_LE16(seid);
        status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
@@ -2460,6 +2534,9 @@ enum i40e_status_code i40e_aq_update_vsi_params(struct i40e_hw *hw,
        struct i40e_aq_desc desc;
        struct i40e_aqc_add_get_update_vsi *cmd =
                (struct i40e_aqc_add_get_update_vsi *)&desc.params.raw;
+       struct i40e_aqc_add_get_update_vsi_completion *resp =
+               (struct i40e_aqc_add_get_update_vsi_completion *)
+               &desc.params.raw;
        enum i40e_status_code status;
 
        i40e_fill_default_direct_cmd_desc(&desc,
@@ -2471,6 +2548,9 @@ enum i40e_status_code i40e_aq_update_vsi_params(struct i40e_hw *hw,
        status = i40e_asq_send_command(hw, &desc, &vsi_ctx->info,
                                    sizeof(vsi_ctx->info), cmd_details);
 
+       vsi_ctx->vsis_allocated = LE16_TO_CPU(resp->vsi_used);
+       vsi_ctx->vsis_unallocated = LE16_TO_CPU(resp->vsi_free);
+
        return status;
 }
 
@@ -2808,6 +2888,7 @@ enum i40e_status_code i40e_aq_get_veb_parameters(struct i40e_hw *hw,
                *vebs_free = LE16_TO_CPU(cmd_resp->vebs_free);
        if (floating) {
                u16 flags = LE16_TO_CPU(cmd_resp->veb_flags);
+
                if (flags & I40E_AQC_ADD_VEB_FLOATING)
                        *floating = true;
                else
@@ -3022,10 +3103,7 @@ enum i40e_status_code i40e_aq_delete_mirrorrule(struct i40e_hw *hw, u16 sw_seid,
                        u16 *rules_used, u16 *rules_free)
 {
        /* Rule ID has to be valid except rule_type: INGRESS VLAN mirroring */
-       if (rule_type != I40E_AQC_MIRROR_RULE_TYPE_VLAN) {
-               if (!rule_id)
-                       return I40E_ERR_PARAM;
-       } else {
+       if (rule_type == I40E_AQC_MIRROR_RULE_TYPE_VLAN) {
                /* count and mr_list shall be valid for rule_type INGRESS VLAN
                 * mirroring. For other rule_type, count and rule_type should
                 * not matter.
@@ -3221,67 +3299,6 @@ enum i40e_status_code i40e_aq_debug_write_register(struct i40e_hw *hw,
        return status;
 }
 
-/**
- * i40e_aq_get_hmc_resource_profile
- * @hw: pointer to the hw struct
- * @profile: type of profile the HMC is to be set as
- * @pe_vf_enabled_count: the number of PE enabled VFs the system has
- * @cmd_details: pointer to command details structure or NULL
- *
- * query the HMC profile of the device.
- **/
-enum i40e_status_code i40e_aq_get_hmc_resource_profile(struct i40e_hw *hw,
-                               enum i40e_aq_hmc_profile *profile,
-                               u8 *pe_vf_enabled_count,
-                               struct i40e_asq_cmd_details *cmd_details)
-{
-       struct i40e_aq_desc desc;
-       struct i40e_aq_get_set_hmc_resource_profile *resp =
-               (struct i40e_aq_get_set_hmc_resource_profile *)&desc.params.raw;
-       enum i40e_status_code status;
-
-       i40e_fill_default_direct_cmd_desc(&desc,
-                               i40e_aqc_opc_query_hmc_resource_profile);
-       status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
-
-       *profile = (enum i40e_aq_hmc_profile)(resp->pm_profile &
-                  I40E_AQ_GET_HMC_RESOURCE_PROFILE_PM_MASK);
-       *pe_vf_enabled_count = resp->pe_vf_enabled &
-                              I40E_AQ_GET_HMC_RESOURCE_PROFILE_COUNT_MASK;
-
-       return status;
-}
-
-/**
- * i40e_aq_set_hmc_resource_profile
- * @hw: pointer to the hw struct
- * @profile: type of profile the HMC is to be set as
- * @pe_vf_enabled_count: the number of PE enabled VFs the system has
- * @cmd_details: pointer to command details structure or NULL
- *
- * set the HMC profile of the device.
- **/
-enum i40e_status_code i40e_aq_set_hmc_resource_profile(struct i40e_hw *hw,
-                               enum i40e_aq_hmc_profile profile,
-                               u8 pe_vf_enabled_count,
-                               struct i40e_asq_cmd_details *cmd_details)
-{
-       struct i40e_aq_desc desc;
-       struct i40e_aq_get_set_hmc_resource_profile *cmd =
-               (struct i40e_aq_get_set_hmc_resource_profile *)&desc.params.raw;
-       enum i40e_status_code status;
-
-       i40e_fill_default_direct_cmd_desc(&desc,
-                                       i40e_aqc_opc_set_hmc_resource_profile);
-
-       cmd->pm_profile = (u8)profile;
-       cmd->pe_vf_enabled = pe_vf_enabled_count;
-
-       status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
-
-       return status;
-}
-
 /**
  * i40e_aq_request_resource
  * @hw: pointer to the hw struct
@@ -3710,7 +3727,7 @@ STATIC void i40e_parse_discover_capabilities(struct i40e_hw *hw, void *buff,
                        p->num_msix_vectors = number;
                        i40e_debug(hw, I40E_DEBUG_INIT,
                                   "HW Capability: MSIX vector count = %d\n",
-                                  p->num_msix_vectors_vf);
+                                  p->num_msix_vectors);
                        break;
                case I40E_AQ_CAP_ID_VF_MSIX:
                        p->num_msix_vectors_vf = number;
@@ -3800,6 +3817,12 @@ STATIC void i40e_parse_discover_capabilities(struct i40e_hw *hw, void *buff,
                                   "HW Capability: wr_csr_prot = 0x%llX\n\n",
                                   (p->wr_csr_prot & 0xffff));
                        break;
+               case I40E_AQ_CAP_ID_NVM_MGMT:
+                       if (number & I40E_NVM_MGMT_SEC_REV_DISABLED)
+                               p->sec_rev_disabled = true;
+                       if (number & I40E_NVM_MGMT_UPDATE_DISABLED)
+                               p->update_disabled = true;
+                       break;
 #ifdef X722_SUPPORT
                case I40E_AQ_CAP_ID_WOL_AND_PROXY:
                        hw->num_wol_proxy_filters = (u16)number;
@@ -3810,7 +3833,6 @@ STATIC void i40e_parse_discover_capabilities(struct i40e_hw *hw, void *buff,
                        else
                                p->acpi_prog_method = I40E_ACPI_PROGRAMMING_METHOD_HW_FVL;
                        p->proxy_support = (phys_id & I40E_PROXY_SUPPORT_MASK) ? 1 : 0;
-                       p->proxy_support = p->proxy_support;
                        i40e_debug(hw, I40E_DEBUG_INIT,
                                   "HW Capability: WOL proxy filters = %d\n",
                                   hw->num_wol_proxy_filters);
@@ -3824,16 +3846,8 @@ STATIC void i40e_parse_discover_capabilities(struct i40e_hw *hw, void *buff,
        if (p->fcoe)
                i40e_debug(hw, I40E_DEBUG_ALL, "device is FCoE capable\n");
 
-#ifdef I40E_FCOE_ENA
-       /* Software override ensuring FCoE is disabled if npar or mfp
-        * mode because it is not supported in these modes.
-        */
-       if (p->npar_enable || p->flex10_enable)
-               p->fcoe = false;
-#else
        /* Always disable FCoE if compiled without the I40E_FCOE_ENA flag */
        p->fcoe = false;
-#endif
 
        /* count the enabled ports (aka the "not disabled" ports) */
        hw->num_ports = 0;
@@ -4468,7 +4482,7 @@ enum i40e_status_code i40e_aq_delete_element(struct i40e_hw *hw, u16 seid,
 }
 
 /**
- * i40_aq_add_pvirt - Instantiate a Port Virtualizer on a port
+ * i40e_aq_add_pvirt - Instantiate a Port Virtualizer on a port
  * @hw: pointer to the hw struct
  * @flags: component flags
  * @mac_seid: uplink seid (MAC SEID)
@@ -5338,7 +5352,7 @@ enum i40e_status_code i40e_set_filter_control(struct i40e_hw *hw,
                return ret;
 
        /* Read the PF Queue Filter control register */
-       val = rd32(hw, I40E_PFQF_CTL_0);
+       val = i40e_read_rx_ctl(hw, I40E_PFQF_CTL_0);
 
        /* Program required PE hash buckets for the PF */
        val &= ~I40E_PFQF_CTL_0_PEHSIZE_MASK;
@@ -5375,7 +5389,7 @@ enum i40e_status_code i40e_set_filter_control(struct i40e_hw *hw,
        if (settings->enable_macvlan)
                val |= I40E_PFQF_CTL_0_MACVLAN_ENA_MASK;
 
-       wr32(hw, I40E_PFQF_CTL_0, val);
+       i40e_write_rx_ctl(hw, I40E_PFQF_CTL_0, val);
 
        return I40E_SUCCESS;
 }
@@ -5458,13 +5472,42 @@ void i40e_add_filter_to_drop_tx_flow_control_frames(struct i40e_hw *hw,
        u16 ethtype = I40E_FLOW_CONTROL_ETHTYPE;
        enum i40e_status_code status;
 
-       status = i40e_aq_add_rem_control_packet_filter(hw, 0, ethtype, flag,
+       status = i40e_aq_add_rem_control_packet_filter(hw, NULL, ethtype, flag,
                                                       seid, 0, true, NULL,
                                                       NULL);
        if (status)
                DEBUGOUT("Ethtype Filter Add failed: Error pruning Tx flow control frames\n");
 }
 
+/**
+ * i40e_fix_up_geneve_vni - adjust Geneve VNI for HW issue
+ * @filters: list of cloud filters
+ * @filter_count: length of list
+ *
+ * There's an issue in the device where the Geneve VNI layout needs
+ * to be shifted 1 byte over from the VxLAN VNI
+ **/
+STATIC void i40e_fix_up_geneve_vni(
+       struct i40e_aqc_add_remove_cloud_filters_element_data *filters,
+       u8 filter_count)
+{
+       struct i40e_aqc_add_remove_cloud_filters_element_data *f = filters;
+       int i;
+
+       for (i = 0; i < filter_count; i++) {
+               u16 tnl_type;
+               u32 ti;
+
+               tnl_type = (LE16_TO_CPU(f[i].flags) &
+                          I40E_AQC_ADD_CLOUD_TNL_TYPE_MASK) >>
+                          I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT;
+               if (tnl_type == I40E_AQC_ADD_CLOUD_TNL_TYPE_GENEVE) {
+                       ti = LE32_TO_CPU(f[i].tenant_id);
+                       f[i].tenant_id = CPU_TO_LE32(ti << 8);
+               }
+       }
+}
+
 /**
  * i40e_aq_add_cloud_filters
  * @hw: pointer to the hardware structure
@@ -5485,8 +5528,8 @@ enum i40e_status_code i40e_aq_add_cloud_filters(struct i40e_hw *hw,
        struct i40e_aq_desc desc;
        struct i40e_aqc_add_remove_cloud_filters *cmd =
        (struct i40e_aqc_add_remove_cloud_filters *)&desc.params.raw;
-       u16 buff_len;
        enum i40e_status_code status;
+       u16 buff_len;
 
        i40e_fill_default_direct_cmd_desc(&desc,
                                          i40e_aqc_opc_add_cloud_filters);
@@ -5497,6 +5540,8 @@ enum i40e_status_code i40e_aq_add_cloud_filters(struct i40e_hw *hw,
        cmd->num_filters = filter_count;
        cmd->seid = CPU_TO_LE16(seid);
 
+       i40e_fix_up_geneve_vni(filters, filter_count);
+
        status = i40e_asq_send_command(hw, &desc, filters, buff_len, NULL);
 
        return status;
@@ -5534,6 +5579,8 @@ enum i40e_status_code i40e_aq_remove_cloud_filters(struct i40e_hw *hw,
        cmd->num_filters = filter_count;
        cmd->seid = CPU_TO_LE16(seid);
 
+       i40e_fix_up_geneve_vni(filters, filter_count);
+
        status = i40e_asq_send_command(hw, &desc, filters, buff_len, NULL);
 
        return status;
@@ -5960,9 +6007,6 @@ enum i40e_status_code i40e_aq_configure_partition_bw(struct i40e_hw *hw,
        desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_BUF);
        desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_RD);
 
-       if (bwd_size > I40E_AQ_LARGE_BUF)
-               desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
-
        desc.datalen = CPU_TO_LE16(bwd_size);
 
        status = i40e_asq_send_command(hw, &desc, bw_data, bwd_size, cmd_details);
@@ -6299,6 +6343,128 @@ restore_config:
        return status;
 }
 #endif /* PF_DRIVER */
+
+/**
+ * i40e_aq_rx_ctl_read_register - use FW to read from an Rx control register
+ * @hw: pointer to the hw struct
+ * @reg_addr: register address
+ * @reg_val: ptr to register value
+ * @cmd_details: pointer to command details structure or NULL
+ *
+ * Use the firmware to read the Rx control register,
+ * especially useful if the Rx unit is under heavy pressure
+ **/
+enum i40e_status_code i40e_aq_rx_ctl_read_register(struct i40e_hw *hw,
+                               u32 reg_addr, u32 *reg_val,
+                               struct i40e_asq_cmd_details *cmd_details)
+{
+       struct i40e_aq_desc desc;
+       struct i40e_aqc_rx_ctl_reg_read_write *cmd_resp =
+               (struct i40e_aqc_rx_ctl_reg_read_write *)&desc.params.raw;
+       enum i40e_status_code status;
+
+       if (reg_val == NULL)
+               return I40E_ERR_PARAM;
+
+       i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_rx_ctl_reg_read);
+
+       cmd_resp->address = CPU_TO_LE32(reg_addr);
+
+       status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
+
+       if (status == I40E_SUCCESS)
+               *reg_val = LE32_TO_CPU(cmd_resp->value);
+
+       return status;
+}
+
+/**
+ * i40e_read_rx_ctl - read from an Rx control register
+ * @hw: pointer to the hw struct
+ * @reg_addr: register address
+ **/
+u32 i40e_read_rx_ctl(struct i40e_hw *hw, u32 reg_addr)
+{
+       enum i40e_status_code status = I40E_SUCCESS;
+       bool use_register;
+       int retry = 5;
+       u32 val = 0;
+
+       use_register = (hw->aq.api_maj_ver == 1) && (hw->aq.api_min_ver < 5);
+       if (!use_register) {
+do_retry:
+               status = i40e_aq_rx_ctl_read_register(hw, reg_addr, &val, NULL);
+               if (hw->aq.asq_last_status == I40E_AQ_RC_EAGAIN && retry) {
+                       i40e_msec_delay(1);
+                       retry--;
+                       goto do_retry;
+               }
+       }
+
+       /* if the AQ access failed, try the old-fashioned way */
+       if (status || use_register)
+               val = rd32(hw, reg_addr);
+
+       return val;
+}
+
+/**
+ * i40e_aq_rx_ctl_write_register
+ * @hw: pointer to the hw struct
+ * @reg_addr: register address
+ * @reg_val: register value
+ * @cmd_details: pointer to command details structure or NULL
+ *
+ * Use the firmware to write to an Rx control register,
+ * especially useful if the Rx unit is under heavy pressure
+ **/
+enum i40e_status_code i40e_aq_rx_ctl_write_register(struct i40e_hw *hw,
+                               u32 reg_addr, u32 reg_val,
+                               struct i40e_asq_cmd_details *cmd_details)
+{
+       struct i40e_aq_desc desc;
+       struct i40e_aqc_rx_ctl_reg_read_write *cmd =
+               (struct i40e_aqc_rx_ctl_reg_read_write *)&desc.params.raw;
+       enum i40e_status_code status;
+
+       i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_rx_ctl_reg_write);
+
+       cmd->address = CPU_TO_LE32(reg_addr);
+       cmd->value = CPU_TO_LE32(reg_val);
+
+       status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
+
+       return status;
+}
+
+/**
+ * i40e_write_rx_ctl - write to an Rx control register
+ * @hw: pointer to the hw struct
+ * @reg_addr: register address
+ * @reg_val: register value
+ **/
+void i40e_write_rx_ctl(struct i40e_hw *hw, u32 reg_addr, u32 reg_val)
+{
+       enum i40e_status_code status = I40E_SUCCESS;
+       bool use_register;
+       int retry = 5;
+
+       use_register = (hw->aq.api_maj_ver == 1) && (hw->aq.api_min_ver < 5);
+       if (!use_register) {
+do_retry:
+               status = i40e_aq_rx_ctl_write_register(hw, reg_addr,
+                                                      reg_val, NULL);
+               if (hw->aq.asq_last_status == I40E_AQ_RC_EAGAIN && retry) {
+                       i40e_msec_delay(1);
+                       retry--;
+                       goto do_retry;
+               }
+       }
+
+       /* if the AQ access failed, try the old-fashioned way */
+       if (status || use_register)
+               wr32(hw, reg_addr, reg_val);
+}
 #ifdef VF_DRIVER
 
 /**