net/i40e/base: update FW AQ API version to 1.7
[dpdk.git] / drivers / net / i40e / base / i40e_common.c
index fbaa0be..9895a77 100644 (file)
@@ -34,7 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
 #include "i40e_type.h"
 #include "i40e_adminq.h"
 #include "i40e_prototype.h"
-#include "i40e_virtchnl.h"
+#include "virtchnl.h"
 
 
 /**
@@ -71,7 +71,6 @@ STATIC enum i40e_status_code i40e_set_mac_type(struct i40e_hw *hw)
                case I40E_DEV_ID_25G_SFP28:
                        hw->mac.type = I40E_MAC_XL710;
                        break;
-#ifdef X722_SUPPORT
 #ifdef X722_A0_SUPPORT
                case I40E_DEV_ID_X722_A0:
 #endif
@@ -83,21 +82,18 @@ STATIC enum i40e_status_code i40e_set_mac_type(struct i40e_hw *hw)
                case I40E_DEV_ID_SFP_I_X722:
                        hw->mac.type = I40E_MAC_X722;
                        break;
-#endif
-#ifdef X722_SUPPORT
 #if defined(INTEGRATED_VF) || defined(VF_DRIVER)
                case I40E_DEV_ID_X722_VF:
-               case I40E_DEV_ID_X722_VF_HV:
 #ifdef X722_A0_SUPPORT
                case I40E_DEV_ID_X722_A0_VF:
 #endif
                        hw->mac.type = I40E_MAC_X722_VF;
                        break;
 #endif /* INTEGRATED_VF || VF_DRIVER */
-#endif /* X722_SUPPORT */
 #if defined(INTEGRATED_VF) || defined(VF_DRIVER)
                case I40E_DEV_ID_VF:
                case I40E_DEV_ID_VF_HV:
+               case I40E_DEV_ID_ADAPTIVE_VF:
                        hw->mac.type = I40E_MAC_VF;
                        break;
 #endif
@@ -114,7 +110,6 @@ STATIC enum i40e_status_code i40e_set_mac_type(struct i40e_hw *hw)
        return status;
 }
 
-#ifndef I40E_NDIS_SUPPORT
 /**
  * i40e_aq_str - convert AQ err code to a string
  * @hw: pointer to the HW structure
@@ -321,7 +316,6 @@ const char *i40e_stat_str(struct i40e_hw *hw, enum i40e_status_code stat_err)
        return hw->err_str;
 }
 
-#endif /* I40E_NDIS_SUPPORT */
 /**
  * i40e_debug_aq
  * @hw: debug mask related to admin queue
@@ -447,7 +441,6 @@ enum i40e_status_code i40e_aq_queue_shutdown(struct i40e_hw *hw,
 
        return status;
 }
-#ifdef X722_SUPPORT
 
 /**
  * i40e_aq_get_set_rss_lut
@@ -606,7 +599,6 @@ enum i40e_status_code i40e_aq_set_rss_key(struct i40e_hw *hw,
 {
        return i40e_aq_get_set_rss_key(hw, vsi_id, key, true);
 }
-#endif /* X722_SUPPORT */
 
 /* The i40e_ptype_lookup table is used to convert from the 8-bit ptype in the
  * hardware to a bit-field that can be used by SW to more easily determine the
@@ -1022,9 +1014,7 @@ enum i40e_status_code i40e_init_shared_code(struct i40e_hw *hw)
 
        switch (hw->mac.type) {
        case I40E_MAC_XL710:
-#ifdef X722_SUPPORT
        case I40E_MAC_X722:
-#endif
                break;
        default:
                return I40E_ERR_DEVICE_NOT_SUPPORTED;
@@ -1044,11 +1034,9 @@ enum i40e_status_code i40e_init_shared_code(struct i40e_hw *hw)
        else
                hw->pf_id = (u8)(func_rid & 0x7);
 
-#ifdef X722_SUPPORT
        if (hw->mac.type == I40E_MAC_X722)
                hw->flags |= I40E_HW_FLAG_AQ_SRCTL_ACCESS_ENABLE;
 
-#endif
        status = i40e_init_nvm(hw);
        return status;
 }
@@ -1126,7 +1114,8 @@ enum i40e_status_code i40e_get_mac_addr(struct i40e_hw *hw, u8 *mac_addr)
        status = i40e_aq_mac_address_read(hw, &flags, &addrs, NULL);
 
        if (flags & I40E_AQC_LAN_ADDR_VALID)
-               memcpy(mac_addr, &addrs.pf_lan_mac, sizeof(addrs.pf_lan_mac));
+               i40e_memcpy(mac_addr, &addrs.pf_lan_mac, sizeof(addrs.pf_lan_mac),
+                       I40E_NONDMA_TO_NONDMA);
 
        return status;
 }
@@ -1149,7 +1138,8 @@ enum i40e_status_code i40e_get_port_mac_addr(struct i40e_hw *hw, u8 *mac_addr)
                return status;
 
        if (flags & I40E_AQC_PORT_ADDR_VALID)
-               memcpy(mac_addr, &addrs.port_mac, sizeof(addrs.port_mac));
+               i40e_memcpy(mac_addr, &addrs.port_mac, sizeof(addrs.port_mac),
+                       I40E_NONDMA_TO_NONDMA);
        else
                status = I40E_ERR_INVALID_MAC_ADDR;
 
@@ -1207,7 +1197,8 @@ enum i40e_status_code i40e_get_san_mac_addr(struct i40e_hw *hw,
                return status;
 
        if (flags & I40E_AQC_SAN_ADDR_VALID)
-               memcpy(mac_addr, &addrs.pf_san_mac, sizeof(addrs.pf_san_mac));
+               i40e_memcpy(mac_addr, &addrs.pf_san_mac, sizeof(addrs.pf_san_mac),
+                       I40E_NONDMA_TO_NONDMA);
        else
                status = I40E_ERR_INVALID_MAC_ADDR;
 
@@ -1305,6 +1296,8 @@ STATIC enum i40e_media_type i40e_get_media_type(struct i40e_hw *hw)
        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;
        case I40E_PHY_TYPE_1000BASE_KX:
@@ -1699,8 +1692,15 @@ enum i40e_status_code i40e_aq_get_phy_capabilities(struct i40e_hw *hw,
                status = I40E_ERR_UNKNOWN_PHY;
 
        if (report_init) {
-               hw->phy.phy_types = LE32_TO_CPU(abilities->phy_type);
-               hw->phy.phy_types |= ((u64)abilities->phy_type_ext << 32);
+               if (hw->mac.type ==  I40E_MAC_XL710 &&
+                   hw->aq.api_maj_ver == I40E_FW_API_VERSION_MAJOR &&
+                   hw->aq.api_min_ver >= I40E_MINOR_VER_GET_LINK_INFO_XL710) {
+                       status = i40e_aq_get_link_info(hw, true, NULL, NULL);
+               } else {
+                       hw->phy.phy_types = LE32_TO_CPU(abilities->phy_type);
+                       hw->phy.phy_types |=
+                                       ((u64)abilities->phy_type_ext << 32);
+               }
        }
 
        return status;
@@ -1798,6 +1798,8 @@ enum i40e_status_code i40e_set_fc(struct i40e_hw *hw, u8 *aq_failures,
                config.eee_capability = abilities.eee_capability;
                config.eeer = abilities.eeer_val;
                config.low_power_ctrl = abilities.d3_lpan;
+               config.fec_config = abilities.fec_cfg_curr_mod_ext_info &
+                                   I40E_AQ_PHY_FEC_CONFIG_MASK;
                status = i40e_aq_set_phy_config(hw, &config, NULL);
 
                if (status)
@@ -1957,8 +1959,10 @@ enum i40e_status_code i40e_aq_get_link_info(struct i40e_hw *hw,
        hw_link_info->link_speed = (enum i40e_aq_link_speed)resp->link_speed;
        hw_link_info->link_info = resp->link_info;
        hw_link_info->an_info = resp->an_info;
+       hw_link_info->fec_info = resp->config & (I40E_AQ_CONFIG_FEC_KR_ENA |
+                                                I40E_AQ_CONFIG_FEC_RS_ENA);
        hw_link_info->ext_info = resp->ext_info;
-       hw_link_info->loopback = resp->loopback;
+       hw_link_info->loopback = resp->loopback & I40E_AQ_LOOPBACK_MASK;
        hw_link_info->max_frame_size = LE16_TO_CPU(resp->max_frame_size);
        hw_link_info->pacing = resp->config & I40E_AQ_CONFIG_PACING_MASK;
 
@@ -1989,6 +1993,12 @@ 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;
 
+       if (hw->aq.api_maj_ver == I40E_FW_API_VERSION_MAJOR &&
+           hw->aq.api_min_ver >= 7) {
+               hw->phy.phy_types = LE32_TO_CPU(*(__le32 *)resp->link_type);
+               hw->phy.phy_types |= ((u64)resp->link_type_ext << 32);
+       }
+
        /* save link status information */
        if (link)
                i40e_memcpy(link, hw_link_info, sizeof(*hw_link_info),
@@ -2349,6 +2359,43 @@ enum i40e_status_code i40e_aq_set_vsi_multicast_promiscuous(struct i40e_hw *hw,
        return status;
 }
 
+/**
+* i40e_aq_set_vsi_full_promiscuous
+* @hw: pointer to the hw struct
+* @seid: VSI number
+* @set: set promiscuous enable/disable
+* @cmd_details: pointer to command details structure or NULL
+**/
+enum i40e_status_code i40e_aq_set_vsi_full_promiscuous(struct i40e_hw *hw,
+                               u16 seid, bool set,
+                               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;
+       u16 flags = 0;
+
+       i40e_fill_default_direct_cmd_desc(&desc,
+               i40e_aqc_opc_set_vsi_promiscuous_modes);
+
+       if (set)
+               flags = I40E_AQC_SET_VSI_PROMISC_UNICAST   |
+                       I40E_AQC_SET_VSI_PROMISC_MULTICAST |
+                       I40E_AQC_SET_VSI_PROMISC_BROADCAST;
+
+       cmd->promiscuous_flags = CPU_TO_LE16(flags);
+
+       cmd->valid_flags = CPU_TO_LE16(I40E_AQC_SET_VSI_PROMISC_UNICAST   |
+                                      I40E_AQC_SET_VSI_PROMISC_MULTICAST |
+                                      I40E_AQC_SET_VSI_PROMISC_BROADCAST);
+
+       cmd->seid = CPU_TO_LE16(seid);
+       status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
+
+       return status;
+}
+
 /**
  * i40e_aq_set_vsi_mc_promisc_on_vlan
  * @hw: pointer to the hw struct
@@ -2417,6 +2464,40 @@ enum i40e_status_code i40e_aq_set_vsi_uc_promisc_on_vlan(struct i40e_hw *hw,
        return status;
 }
 
+/**
+ * i40e_aq_set_vsi_bc_promisc_on_vlan
+ * @hw: pointer to the hw struct
+ * @seid: vsi number
+ * @enable: set broadcast promiscuous enable/disable for a given VLAN
+ * @vid: The VLAN tag filter - capture any broadcast packet with this VLAN tag
+ * @cmd_details: pointer to command details structure or NULL
+ **/
+enum i40e_status_code i40e_aq_set_vsi_bc_promisc_on_vlan(struct i40e_hw *hw,
+                               u16 seid, bool enable, u16 vid,
+                               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;
+       u16 flags = 0;
+
+       i40e_fill_default_direct_cmd_desc(&desc,
+                                       i40e_aqc_opc_set_vsi_promiscuous_modes);
+
+       if (enable)
+               flags |= I40E_AQC_SET_VSI_PROMISC_BROADCAST;
+
+       cmd->promiscuous_flags = CPU_TO_LE16(flags);
+       cmd->valid_flags = CPU_TO_LE16(I40E_AQC_SET_VSI_PROMISC_BROADCAST);
+       cmd->seid = CPU_TO_LE16(seid);
+       cmd->vlan_tag = CPU_TO_LE16(vid | I40E_AQC_SET_VSI_VLAN_VALID);
+
+       status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
+
+       return status;
+}
+
 /**
  * i40e_aq_set_vsi_broadcast
  * @hw: pointer to the hw struct
@@ -2760,8 +2841,12 @@ enum i40e_status_code i40e_update_link_info(struct i40e_hw *hw)
                if (status)
                        return status;
 
-               memcpy(hw->phy.link_info.module_type, &abilities.module_type,
-                       sizeof(hw->phy.link_info.module_type));
+               hw->phy.link_info.req_fec_info =
+                       abilities.fec_cfg_curr_mod_ext_info &
+                       (I40E_AQ_REQUEST_FEC_KR | I40E_AQ_REQUEST_FEC_RS);
+
+               i40e_memcpy(hw->phy.link_info.module_type, &abilities.module_type,
+                       sizeof(hw->phy.link_info.module_type), I40E_NONDMA_TO_NONDMA);
        }
        return status;
 }
@@ -3839,7 +3924,6 @@ STATIC void i40e_parse_discover_capabilities(struct i40e_hw *hw, void *buff,
                        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;
                        hw->wol_proxy_vsi_seid = (u16)logical_id;
@@ -3853,7 +3937,6 @@ STATIC void i40e_parse_discover_capabilities(struct i40e_hw *hw, void *buff,
                                   "HW Capability: WOL proxy filters = %d\n",
                                   hw->num_wol_proxy_filters);
                        break;
-#endif
                default:
                        break;
                }
@@ -3890,8 +3973,10 @@ STATIC void i40e_parse_discover_capabilities(struct i40e_hw *hw, void *buff,
        /* partition id is 1-based, and functions are evenly spread
         * across the ports as partitions
         */
-       hw->partition_id = (hw->pf_id / hw->num_ports) + 1;
-       hw->num_partitions = num_functions / hw->num_ports;
+       if (hw->num_ports != 0) {
+               hw->partition_id = (hw->pf_id / hw->num_ports) + 1;
+               hw->num_partitions = num_functions / hw->num_ports;
+       }
 
        /* additional HW specific goodies that might
         * someday be HW version specific
@@ -4376,11 +4461,15 @@ enum i40e_status_code i40e_aq_start_stop_dcbx(struct i40e_hw *hw,
 /**
  * i40e_aq_add_udp_tunnel
  * @hw: pointer to the hw struct
- * @udp_port: the UDP port to add
+ * @udp_port: the UDP port to add in Host byte order
  * @header_len: length of the tunneling header length in DWords
  * @protocol_index: protocol index type
  * @filter_index: pointer to filter index
  * @cmd_details: pointer to command details structure or NULL
+ *
+ * Note: Firmware expects the udp_port value to be in Little Endian format,
+ * and this function will call CPU_TO_LE16 to convert from Host byte order to
+ * Little Endian order.
  **/
 enum i40e_status_code i40e_aq_add_udp_tunnel(struct i40e_hw *hw,
                                u16 udp_port, u8 protocol_index,
@@ -5454,7 +5543,7 @@ enum i40e_status_code i40e_aq_add_rem_control_packet_filter(struct i40e_hw *hw,
        }
 
        if (mac_addr)
-               i40e_memcpy(cmd->mac, mac_addr, I40E_ETH_LENGTH_OF_ADDRESS,
+               i40e_memcpy(cmd->mac, mac_addr, ETH_ALEN,
                            I40E_NONDMA_TO_NONDMA);
 
        cmd->etype = CPU_TO_LE16(ethtype);
@@ -5563,6 +5652,59 @@ enum i40e_status_code i40e_aq_add_cloud_filters(struct i40e_hw *hw,
        return status;
 }
 
+/**
+ * i40e_aq_add_cloud_filters_big_buffer
+ * @hw: pointer to the hardware structure
+ * @seid: VSI seid to add cloud filters from
+ * @filters: Buffer which contains the filters in big buffer to be added
+ * @filter_count: number of filters contained in the buffer
+ *
+ * Set the cloud filters for a given VSI.  The contents of the
+ * i40e_aqc_add_rm_cloud_filt_elem_ext are filled in by the caller of
+ * the function.
+ *
+ **/
+enum i40e_status_code i40e_aq_add_cloud_filters_big_buffer(struct i40e_hw *hw,
+       u16 seid,
+       struct i40e_aqc_add_rm_cloud_filt_elem_ext *filters,
+       u8 filter_count)
+{
+       struct i40e_aq_desc desc;
+       struct i40e_aqc_add_remove_cloud_filters *cmd =
+       (struct i40e_aqc_add_remove_cloud_filters *)&desc.params.raw;
+       enum i40e_status_code status;
+       u16 buff_len;
+       int i;
+
+       i40e_fill_default_direct_cmd_desc(&desc,
+                                         i40e_aqc_opc_add_cloud_filters);
+
+       buff_len = filter_count * sizeof(*filters);
+       desc.datalen = CPU_TO_LE16(buff_len);
+       desc.flags |= CPU_TO_LE16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
+       cmd->num_filters = filter_count;
+       cmd->seid = CPU_TO_LE16(seid);
+       cmd->big_buffer_flag = I40E_AQC_ADD_REM_CLOUD_CMD_BIG_BUFFER;
+
+       /* adjust Geneve VNI for HW issue */
+       for (i = 0; i < filter_count; i++) {
+               u16 tnl_type;
+               u32 ti;
+
+               tnl_type = (LE16_TO_CPU(filters[i].element.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(filters[i].element.tenant_id);
+                       filters[i].element.tenant_id = CPU_TO_LE32(ti << 8);
+               }
+       }
+
+       status = i40e_asq_send_command(hw, &desc, filters, buff_len, NULL);
+
+       return status;
+}
+
 /**
  * i40e_aq_remove_cloud_filters
  * @hw: pointer to the hardware structure
@@ -5576,9 +5718,9 @@ enum i40e_status_code i40e_aq_add_cloud_filters(struct i40e_hw *hw,
  *
  **/
 enum i40e_status_code i40e_aq_remove_cloud_filters(struct i40e_hw *hw,
-               u16 seid,
-               struct i40e_aqc_add_remove_cloud_filters_element_data *filters,
-               u8 filter_count)
+       u16 seid,
+       struct i40e_aqc_add_remove_cloud_filters_element_data *filters,
+       u8 filter_count)
 {
        struct i40e_aq_desc desc;
        struct i40e_aqc_add_remove_cloud_filters *cmd =
@@ -5602,6 +5744,103 @@ enum i40e_status_code i40e_aq_remove_cloud_filters(struct i40e_hw *hw,
        return status;
 }
 
+/**
+ * i40e_aq_remove_cloud_filters_big_buffer
+ * @hw: pointer to the hardware structure
+ * @seid: VSI seid to remove cloud filters from
+ * @filters: Buffer which contains the filters in big buffer to be removed
+ * @filter_count: number of filters contained in the buffer
+ *
+ * Remove the cloud filters for a given VSI.  The contents of the
+ * i40e_aqc_add_rm_cloud_filt_elem_ext are filled in by the caller of
+ * the function.
+ *
+ **/
+enum i40e_status_code i40e_aq_remove_cloud_filters_big_buffer(
+       struct i40e_hw *hw,
+       u16 seid,
+       struct i40e_aqc_add_rm_cloud_filt_elem_ext *filters,
+       u8 filter_count)
+{
+       struct i40e_aq_desc desc;
+       struct i40e_aqc_add_remove_cloud_filters *cmd =
+       (struct i40e_aqc_add_remove_cloud_filters *)&desc.params.raw;
+       enum i40e_status_code status;
+       u16 buff_len;
+       int i;
+
+       i40e_fill_default_direct_cmd_desc(&desc,
+                                         i40e_aqc_opc_remove_cloud_filters);
+
+       buff_len = filter_count * sizeof(*filters);
+       desc.datalen = CPU_TO_LE16(buff_len);
+       desc.flags |= CPU_TO_LE16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
+       cmd->num_filters = filter_count;
+       cmd->seid = CPU_TO_LE16(seid);
+       cmd->big_buffer_flag = I40E_AQC_ADD_REM_CLOUD_CMD_BIG_BUFFER;
+
+       /* adjust Geneve VNI for HW issue */
+       for (i = 0; i < filter_count; i++) {
+               u16 tnl_type;
+               u32 ti;
+
+               tnl_type = (LE16_TO_CPU(filters[i].element.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(filters[i].element.tenant_id);
+                       filters[i].element.tenant_id = CPU_TO_LE32(ti << 8);
+               }
+       }
+
+       status = i40e_asq_send_command(hw, &desc, filters, buff_len, NULL);
+
+       return status;
+}
+
+/**
+ * i40e_aq_replace_cloud_filters - Replace cloud filter command
+ * @hw: pointer to the hw struct
+ * @filters: pointer to the i40e_aqc_replace_cloud_filter_cmd struct
+ * @cmd_buf: pointer to the i40e_aqc_replace_cloud_filter_cmd_buf struct
+ *
+ **/
+enum
+i40e_status_code i40e_aq_replace_cloud_filters(struct i40e_hw *hw,
+       struct i40e_aqc_replace_cloud_filters_cmd *filters,
+       struct i40e_aqc_replace_cloud_filters_cmd_buf *cmd_buf)
+{
+       struct i40e_aq_desc desc;
+       struct i40e_aqc_replace_cloud_filters_cmd *cmd =
+               (struct i40e_aqc_replace_cloud_filters_cmd *)&desc.params.raw;
+       enum i40e_status_code status = I40E_SUCCESS;
+       int i = 0;
+
+       i40e_fill_default_direct_cmd_desc(&desc,
+                                         i40e_aqc_opc_replace_cloud_filters);
+
+       desc.datalen = CPU_TO_LE16(32);
+       desc.flags |= CPU_TO_LE16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
+       cmd->old_filter_type = filters->old_filter_type;
+       cmd->new_filter_type = filters->new_filter_type;
+       cmd->valid_flags = filters->valid_flags;
+       cmd->tr_bit = filters->tr_bit;
+
+       status = i40e_asq_send_command(hw, &desc, cmd_buf,
+               sizeof(struct i40e_aqc_replace_cloud_filters_cmd_buf),  NULL);
+
+       /* for get cloud filters command */
+       for (i = 0; i < 32; i += 4) {
+               cmd_buf->filters[i / 4].filter_type = cmd_buf->data[i];
+               cmd_buf->filters[i / 4].input[0] = cmd_buf->data[i + 1];
+               cmd_buf->filters[i / 4].input[1] = cmd_buf->data[i + 2];
+               cmd_buf->filters[i / 4].input[2] = cmd_buf->data[i + 3];
+       }
+
+       return status;
+}
+
+
 /**
  * i40e_aq_alternate_write
  * @hw: pointer to the hardware structure
@@ -6565,7 +6804,9 @@ u32 i40e_read_rx_ctl(struct i40e_hw *hw, u32 reg_addr)
        int retry = 5;
        u32 val = 0;
 
-       use_register = (hw->aq.api_maj_ver == 1) && (hw->aq.api_min_ver < 5);
+       use_register = (((hw->aq.api_maj_ver == 1) &&
+                       (hw->aq.api_min_ver < 5)) ||
+                       (hw->mac.type == I40E_MAC_X722));
        if (!use_register) {
 do_retry:
                status = i40e_aq_rx_ctl_read_register(hw, reg_addr, &val, NULL);
@@ -6624,7 +6865,9 @@ void i40e_write_rx_ctl(struct i40e_hw *hw, u32 reg_addr, u32 reg_val)
        bool use_register;
        int retry = 5;
 
-       use_register = (hw->aq.api_maj_ver == 1) && (hw->aq.api_min_ver < 5);
+       use_register = (((hw->aq.api_maj_ver == 1) &&
+                       (hw->aq.api_min_ver < 5)) ||
+                       (hw->mac.type == I40E_MAC_X722));
        if (!use_register) {
 do_retry:
                status = i40e_aq_rx_ctl_write_register(hw, reg_addr,
@@ -6640,6 +6883,76 @@ do_retry:
        if (status || use_register)
                wr32(hw, reg_addr, reg_val);
 }
+
+/**
+ * i40e_aq_set_phy_register
+ * @hw: pointer to the hw struct
+ * @phy_select: select which phy should be accessed
+ * @dev_addr: PHY device address
+ * @reg_addr: PHY register address
+ * @reg_val: new register value
+ * @cmd_details: pointer to command details structure or NULL
+ *
+ * Write the external PHY register.
+ **/
+enum i40e_status_code i40e_aq_set_phy_register(struct i40e_hw *hw,
+                               u8 phy_select, u8 dev_addr,
+                               u32 reg_addr, u32 reg_val,
+                               struct i40e_asq_cmd_details *cmd_details)
+{
+       struct i40e_aq_desc desc;
+       struct i40e_aqc_phy_register_access *cmd =
+               (struct i40e_aqc_phy_register_access *)&desc.params.raw;
+       enum i40e_status_code status;
+
+       i40e_fill_default_direct_cmd_desc(&desc,
+                                         i40e_aqc_opc_set_phy_register);
+
+       cmd->phy_interface = phy_select;
+       cmd->dev_addres = dev_addr;
+       cmd->reg_address = reg_addr;
+       cmd->reg_value = reg_val;
+
+       status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
+
+       return status;
+}
+
+/**
+ * i40e_aq_get_phy_register
+ * @hw: pointer to the hw struct
+ * @phy_select: select which phy should be accessed
+ * @dev_addr: PHY device address
+ * @reg_addr: PHY register address
+ * @reg_val: read register value
+ * @cmd_details: pointer to command details structure or NULL
+ *
+ * Read the external PHY register.
+ **/
+enum i40e_status_code i40e_aq_get_phy_register(struct i40e_hw *hw,
+                               u8 phy_select, u8 dev_addr,
+                               u32 reg_addr, u32 *reg_val,
+                               struct i40e_asq_cmd_details *cmd_details)
+{
+       struct i40e_aq_desc desc;
+       struct i40e_aqc_phy_register_access *cmd =
+               (struct i40e_aqc_phy_register_access *)&desc.params.raw;
+       enum i40e_status_code status;
+
+       i40e_fill_default_direct_cmd_desc(&desc,
+                                         i40e_aqc_opc_get_phy_register);
+
+       cmd->phy_interface = phy_select;
+       cmd->dev_addres = dev_addr;
+       cmd->reg_address = reg_addr;
+
+       status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
+       if (!status)
+               *reg_val = cmd->reg_value;
+
+       return status;
+}
+
 #ifdef VF_DRIVER
 
 /**
@@ -6656,7 +6969,7 @@ do_retry:
  * completion before returning.
  **/
 enum i40e_status_code i40e_aq_send_msg_to_pf(struct i40e_hw *hw,
-                               enum i40e_virtchnl_ops v_opcode,
+                               enum virtchnl_ops v_opcode,
                                enum i40e_status_code v_retval,
                                u8 *msg, u16 msglen,
                                struct i40e_asq_cmd_details *cmd_details)
@@ -6695,9 +7008,9 @@ enum i40e_status_code i40e_aq_send_msg_to_pf(struct i40e_hw *hw,
  * with appropriate information.
  **/
 void i40e_vf_parse_hw_config(struct i40e_hw *hw,
-                            struct i40e_virtchnl_vf_resource *msg)
+                            struct virtchnl_vf_resource *msg)
 {
-       struct i40e_virtchnl_vsi_resource *vsi_res;
+       struct virtchnl_vsi_resource *vsi_res;
        int i;
 
        vsi_res = &msg->vsi_res[0];
@@ -6707,19 +7020,17 @@ void i40e_vf_parse_hw_config(struct i40e_hw *hw,
        hw->dev_caps.num_tx_qp = msg->num_queue_pairs;
        hw->dev_caps.num_msix_vectors_vf = msg->max_vectors;
        hw->dev_caps.dcb = msg->vf_offload_flags &
-                          I40E_VIRTCHNL_VF_OFFLOAD_L2;
-       hw->dev_caps.fcoe = (msg->vf_offload_flags &
-                            I40E_VIRTCHNL_VF_OFFLOAD_FCOE) ? 1 : 0;
+                          VIRTCHNL_VF_OFFLOAD_L2;
        hw->dev_caps.iwarp = (msg->vf_offload_flags &
-                             I40E_VIRTCHNL_VF_OFFLOAD_IWARP) ? 1 : 0;
+                             VIRTCHNL_VF_OFFLOAD_IWARP) ? 1 : 0;
        for (i = 0; i < msg->num_vsis; i++) {
-               if (vsi_res->vsi_type == I40E_VSI_SRIOV) {
+               if (vsi_res->vsi_type == VIRTCHNL_VSI_SRIOV) {
                        i40e_memcpy(hw->mac.perm_addr,
                                    vsi_res->default_mac_addr,
-                                   I40E_ETH_LENGTH_OF_ADDRESS,
+                                   ETH_ALEN,
                                    I40E_NONDMA_TO_NONDMA);
                        i40e_memcpy(hw->mac.addr, vsi_res->default_mac_addr,
-                                   I40E_ETH_LENGTH_OF_ADDRESS,
+                                   ETH_ALEN,
                                    I40E_NONDMA_TO_NONDMA);
                }
                vsi_res++;
@@ -6736,11 +7047,10 @@ void i40e_vf_parse_hw_config(struct i40e_hw *hw,
  **/
 enum i40e_status_code i40e_vf_reset(struct i40e_hw *hw)
 {
-       return i40e_aq_send_msg_to_pf(hw, I40E_VIRTCHNL_OP_RESET_VF,
+       return i40e_aq_send_msg_to_pf(hw, VIRTCHNL_OP_RESET_VF,
                                      I40E_SUCCESS, NULL, 0, NULL);
 }
 #endif /* VF_DRIVER */
-#ifdef X722_SUPPORT
 
 /**
  * i40e_aq_set_arp_proxy_config
@@ -6763,10 +7073,13 @@ enum i40e_status_code i40e_aq_set_arp_proxy_config(struct i40e_hw *hw,
 
        i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_set_proxy_config);
 
+       desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_BUF);
+       desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_RD);
        desc.params.external.addr_high =
                                  CPU_TO_LE32(I40E_HI_DWORD((u64)proxy_config));
        desc.params.external.addr_low =
                                  CPU_TO_LE32(I40E_LO_DWORD((u64)proxy_config));
+       desc.datalen = CPU_TO_LE16(sizeof(struct i40e_aqc_arp_proxy_data));
 
        status = i40e_asq_send_command(hw, &desc, proxy_config,
                                       sizeof(struct i40e_aqc_arp_proxy_data),
@@ -6797,10 +7110,13 @@ enum i40e_status_code i40e_aq_set_ns_proxy_table_entry(struct i40e_hw *hw,
        i40e_fill_default_direct_cmd_desc(&desc,
                                i40e_aqc_opc_set_ns_proxy_table_entry);
 
+       desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_BUF);
+       desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_RD);
        desc.params.external.addr_high =
                CPU_TO_LE32(I40E_HI_DWORD((u64)ns_proxy_table_entry));
        desc.params.external.addr_low =
                CPU_TO_LE32(I40E_LO_DWORD((u64)ns_proxy_table_entry));
+       desc.datalen = CPU_TO_LE16(sizeof(struct i40e_aqc_ns_proxy_data));
 
        status = i40e_asq_send_command(hw, &desc, ns_proxy_table_entry,
                                       sizeof(struct i40e_aqc_ns_proxy_data),
@@ -6847,9 +7163,11 @@ enum i40e_status_code i40e_aq_set_clear_wol_filter(struct i40e_hw *hw,
        if (set_filter) {
                if (!filter)
                        return  I40E_ERR_PARAM;
+
                cmd_flags |= I40E_AQC_SET_WOL_FILTER;
-               buff_len = sizeof(*filter);
+               cmd_flags |= I40E_AQC_SET_WOL_FILTER_WOL_PRESERVE_ON_PFR;
        }
+
        if (no_wol_tco)
                cmd_flags |= I40E_AQC_SET_WOL_FILTER_NO_TCO_WOL;
        cmd->cmd_flags = CPU_TO_LE16(cmd_flags);
@@ -6860,6 +7178,12 @@ enum i40e_status_code i40e_aq_set_clear_wol_filter(struct i40e_hw *hw,
                valid_flags |= I40E_AQC_SET_WOL_FILTER_NO_TCO_ACTION_VALID;
        cmd->valid_flags = CPU_TO_LE16(valid_flags);
 
+       buff_len = sizeof(*filter);
+       desc.datalen = CPU_TO_LE16(buff_len);
+
+       desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_BUF);
+       desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_RD);
+
        cmd->address_high = CPU_TO_LE32(I40E_HI_DWORD((u64)filter));
        cmd->address_low = CPU_TO_LE32(I40E_LO_DWORD((u64)filter));
 
@@ -6896,4 +7220,231 @@ enum i40e_status_code i40e_aq_get_wake_event_reason(struct i40e_hw *hw,
        return status;
 }
 
-#endif /* X722_SUPPORT */
+/**
+* i40e_aq_clear_all_wol_filters
+* @hw: pointer to the hw struct
+* @cmd_details: pointer to command details structure or NULL
+*
+* Get information for the reason of a Wake Up event
+**/
+enum i40e_status_code i40e_aq_clear_all_wol_filters(struct i40e_hw *hw,
+       struct i40e_asq_cmd_details *cmd_details)
+{
+       struct i40e_aq_desc desc;
+       enum i40e_status_code status;
+
+       i40e_fill_default_direct_cmd_desc(&desc,
+                                         i40e_aqc_opc_clear_all_wol_filters);
+
+       status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
+
+       return status;
+}
+
+
+/**
+ * i40e_aq_write_ddp - Write dynamic device personalization (ddp)
+ * @hw: pointer to the hw struct
+ * @buff: command buffer (size in bytes = buff_size)
+ * @buff_size: buffer size in bytes
+ * @track_id: package tracking id
+ * @error_offset: returns error offset
+ * @error_info: returns error information
+ * @cmd_details: pointer to command details structure or NULL
+ **/
+enum
+i40e_status_code i40e_aq_write_ddp(struct i40e_hw *hw, void *buff,
+                                  u16 buff_size, u32 track_id,
+                                  u32 *error_offset, u32 *error_info,
+                                  struct i40e_asq_cmd_details *cmd_details)
+{
+       struct i40e_aq_desc desc;
+       struct i40e_aqc_write_personalization_profile *cmd =
+               (struct i40e_aqc_write_personalization_profile *)
+               &desc.params.raw;
+       struct i40e_aqc_write_ddp_resp *resp;
+       enum i40e_status_code status;
+
+       i40e_fill_default_direct_cmd_desc(&desc,
+                                 i40e_aqc_opc_write_personalization_profile);
+
+       desc.flags |= CPU_TO_LE16(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD);
+       if (buff_size > I40E_AQ_LARGE_BUF)
+               desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
+
+       desc.datalen = CPU_TO_LE16(buff_size);
+
+       cmd->profile_track_id = CPU_TO_LE32(track_id);
+
+       status = i40e_asq_send_command(hw, &desc, buff, buff_size, cmd_details);
+       if (!status) {
+               resp = (struct i40e_aqc_write_ddp_resp *)&desc.params.raw;
+               if (error_offset)
+                       *error_offset = LE32_TO_CPU(resp->error_offset);
+               if (error_info)
+                       *error_info = LE32_TO_CPU(resp->error_info);
+       }
+
+       return status;
+}
+
+/**
+ * i40e_aq_get_ddp_list - Read dynamic device personalization (ddp)
+ * @hw: pointer to the hw struct
+ * @buff: command buffer (size in bytes = buff_size)
+ * @buff_size: buffer size in bytes
+ * @cmd_details: pointer to command details structure or NULL
+ **/
+enum
+i40e_status_code i40e_aq_get_ddp_list(struct i40e_hw *hw, void *buff,
+                                     u16 buff_size, u8 flags,
+                                     struct i40e_asq_cmd_details *cmd_details)
+{
+       struct i40e_aq_desc desc;
+       struct i40e_aqc_get_applied_profiles *cmd =
+               (struct i40e_aqc_get_applied_profiles *)&desc.params.raw;
+       enum i40e_status_code status;
+
+       i40e_fill_default_direct_cmd_desc(&desc,
+                         i40e_aqc_opc_get_personalization_profile_list);
+
+       desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_BUF);
+       if (buff_size > I40E_AQ_LARGE_BUF)
+               desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
+       desc.datalen = CPU_TO_LE16(buff_size);
+
+       cmd->flags = flags;
+
+       status = i40e_asq_send_command(hw, &desc, buff, buff_size, cmd_details);
+
+       return status;
+}
+
+/**
+ * i40e_find_segment_in_package
+ * @segment_type: the segment type to search for (i.e., SEGMENT_TYPE_I40E)
+ * @pkg_hdr: pointer to the package header to be searched
+ *
+ * This function searches a package file for a particular segment type. On
+ * success it returns a pointer to the segment header, otherwise it will
+ * return NULL.
+ **/
+struct i40e_generic_seg_header *
+i40e_find_segment_in_package(u32 segment_type,
+                            struct i40e_package_header *pkg_hdr)
+{
+       struct i40e_generic_seg_header *segment;
+       u32 i;
+
+       /* Search all package segments for the requested segment type */
+       for (i = 0; i < pkg_hdr->segment_count; i++) {
+               segment =
+                       (struct i40e_generic_seg_header *)((u8 *)pkg_hdr +
+                        pkg_hdr->segment_offset[i]);
+
+               if (segment->type == segment_type)
+                       return segment;
+       }
+
+       return NULL;
+}
+
+/**
+ * i40e_write_profile
+ * @hw: pointer to the hardware structure
+ * @profile: pointer to the profile segment of the package to be downloaded
+ * @track_id: package tracking id
+ *
+ * Handles the download of a complete package.
+ */
+enum i40e_status_code
+i40e_write_profile(struct i40e_hw *hw, struct i40e_profile_segment *profile,
+                  u32 track_id)
+{
+       enum i40e_status_code status = I40E_SUCCESS;
+       struct i40e_section_table *sec_tbl;
+       struct i40e_profile_section_header *sec = NULL;
+       u32 dev_cnt;
+       u32 vendor_dev_id;
+       u32 *nvm;
+       u32 section_size = 0;
+       u32 offset = 0, info = 0;
+       u32 i;
+
+       dev_cnt = profile->device_table_count;
+
+       for (i = 0; i < dev_cnt; i++) {
+               vendor_dev_id = profile->device_table[i].vendor_dev_id;
+               if ((vendor_dev_id >> 16) == I40E_INTEL_VENDOR_ID)
+                       if (hw->device_id == (vendor_dev_id & 0xFFFF))
+                               break;
+       }
+       if (i == dev_cnt) {
+               i40e_debug(hw, I40E_DEBUG_PACKAGE, "Device doesn't support DDP");
+               return I40E_ERR_DEVICE_NOT_SUPPORTED;
+       }
+
+       nvm = (u32 *)&profile->device_table[dev_cnt];
+       sec_tbl = (struct i40e_section_table *)&nvm[nvm[0] + 1];
+
+       for (i = 0; i < sec_tbl->section_count; i++) {
+               sec = (struct i40e_profile_section_header *)((u8 *)profile +
+                                            sec_tbl->section_offset[i]);
+
+               /* Skip 'AQ', 'note' and 'name' sections */
+               if (sec->section.type != SECTION_TYPE_MMIO)
+                       continue;
+
+               section_size = sec->section.size +
+                       sizeof(struct i40e_profile_section_header);
+
+               /* Write profile */
+               status = i40e_aq_write_ddp(hw, (void *)sec, (u16)section_size,
+                                          track_id, &offset, &info, NULL);
+               if (status) {
+                       i40e_debug(hw, I40E_DEBUG_PACKAGE,
+                                  "Failed to write profile: offset %d, info %d",
+                                  offset, info);
+                       break;
+               }
+       }
+       return status;
+}
+
+/**
+ * i40e_add_pinfo_to_list
+ * @hw: pointer to the hardware structure
+ * @profile: pointer to the profile segment of the package
+ * @profile_info_sec: buffer for information section
+ * @track_id: package tracking id
+ *
+ * Register a profile to the list of loaded profiles.
+ */
+enum i40e_status_code
+i40e_add_pinfo_to_list(struct i40e_hw *hw,
+                      struct i40e_profile_segment *profile,
+                      u8 *profile_info_sec, u32 track_id)
+{
+       enum i40e_status_code status = I40E_SUCCESS;
+       struct i40e_profile_section_header *sec = NULL;
+       struct i40e_profile_info *pinfo;
+       u32 offset = 0, info = 0;
+
+       sec = (struct i40e_profile_section_header *)profile_info_sec;
+       sec->tbl_size = 1;
+       sec->data_end = sizeof(struct i40e_profile_section_header) +
+                       sizeof(struct i40e_profile_info);
+       sec->section.type = SECTION_TYPE_INFO;
+       sec->section.offset = sizeof(struct i40e_profile_section_header);
+       sec->section.size = sizeof(struct i40e_profile_info);
+       pinfo = (struct i40e_profile_info *)(profile_info_sec +
+                                            sec->section.offset);
+       pinfo->track_id = track_id;
+       pinfo->version = profile->version;
+       pinfo->op = I40E_DDP_ADD_TRACKID;
+       memcpy(pinfo->name, profile->name, I40E_DDP_NAME_SIZE);
+
+       status = i40e_aq_write_ddp(hw, (void *)sec, sec->data_end,
+                                  track_id, &offset, &info, NULL);
+       return status;
+}