These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / net / ethernet / sfc / ef10.c
index fbb6cfa..e6a084a 100644 (file)
@@ -15,6 +15,7 @@
 #include "nic.h"
 #include "workarounds.h"
 #include "selftest.h"
+#include "ef10_sriov.h"
 #include <linux/in.h>
 #include <linux/jhash.h>
 #include <linux/wait.h>
@@ -30,6 +31,9 @@ enum {
 
 /* The reserved RSS context value */
 #define EFX_EF10_RSS_CONTEXT_INVALID   0xffffffff
+/* The maximum size of a shared RSS context */
+/* TODO: this should really be from the mcdi protocol export */
+#define EFX_EF10_MAX_SHARED_RSS_CONTEXT_SIZE 64UL
 
 /* The filter table(s) are managed by firmware and we have write-only
  * access.  When removing filters we must identify them to the
@@ -45,6 +49,12 @@ enum {
  */
 #define HUNT_FILTER_TBL_ROWS 8192
 
+#define EFX_EF10_FILTER_ID_INVALID 0xffff
+struct efx_ef10_dev_addr {
+       u8 addr[ETH_ALEN];
+       u16 id;
+};
+
 struct efx_ef10_filter_table {
 /* The RX match field masks supported by this fw & hw, in order of priority */
        enum efx_filter_match_flags rx_match_flags[
@@ -65,19 +75,19 @@ struct efx_ef10_filter_table {
 /* Shadow of net_device address lists, guarded by mac_lock */
 #define EFX_EF10_FILTER_DEV_UC_MAX     32
 #define EFX_EF10_FILTER_DEV_MC_MAX     256
-       struct {
-               u8 addr[ETH_ALEN];
-               u16 id;
-       } dev_uc_list[EFX_EF10_FILTER_DEV_UC_MAX],
-         dev_mc_list[EFX_EF10_FILTER_DEV_MC_MAX];
-       int dev_uc_count;               /* negative for PROMISC */
-       int dev_mc_count;               /* negative for PROMISC/ALLMULTI */
+       struct efx_ef10_dev_addr dev_uc_list[EFX_EF10_FILTER_DEV_UC_MAX];
+       struct efx_ef10_dev_addr dev_mc_list[EFX_EF10_FILTER_DEV_MC_MAX];
+       int dev_uc_count;
+       int dev_mc_count;
+/* Indices (like efx_ef10_dev_addr.id) for promisc/allmulti filters */
+       u16 ucdef_id;
+       u16 bcast_id;
+       u16 mcdef_id;
 };
 
 /* An arbitrary search limit for the software hash table */
 #define EFX_EF10_FILTER_SEARCH_LIMIT 200
 
-static void efx_ef10_rx_push_rss_config(struct efx_nic *efx);
 static void efx_ef10_rx_free_indir_table(struct efx_nic *efx);
 static void efx_ef10_filter_table_remove(struct efx_nic *efx);
 
@@ -92,8 +102,54 @@ static int efx_ef10_get_warm_boot_count(struct efx_nic *efx)
 
 static unsigned int efx_ef10_mem_map_size(struct efx_nic *efx)
 {
-       return resource_size(&efx->pci_dev->resource[EFX_MEM_BAR]);
+       int bar;
+
+       bar = efx->type->mem_bar;
+       return resource_size(&efx->pci_dev->resource[bar]);
+}
+
+static bool efx_ef10_is_vf(struct efx_nic *efx)
+{
+       return efx->type->is_vf;
+}
+
+static int efx_ef10_get_pf_index(struct efx_nic *efx)
+{
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_FUNCTION_INFO_OUT_LEN);
+       struct efx_ef10_nic_data *nic_data = efx->nic_data;
+       size_t outlen;
+       int rc;
+
+       rc = efx_mcdi_rpc(efx, MC_CMD_GET_FUNCTION_INFO, NULL, 0, outbuf,
+                         sizeof(outbuf), &outlen);
+       if (rc)
+               return rc;
+       if (outlen < sizeof(outbuf))
+               return -EIO;
+
+       nic_data->pf_index = MCDI_DWORD(outbuf, GET_FUNCTION_INFO_OUT_PF);
+       return 0;
+}
+
+#ifdef CONFIG_SFC_SRIOV
+static int efx_ef10_get_vf_index(struct efx_nic *efx)
+{
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_FUNCTION_INFO_OUT_LEN);
+       struct efx_ef10_nic_data *nic_data = efx->nic_data;
+       size_t outlen;
+       int rc;
+
+       rc = efx_mcdi_rpc(efx, MC_CMD_GET_FUNCTION_INFO, NULL, 0, outbuf,
+                         sizeof(outbuf), &outlen);
+       if (rc)
+               return rc;
+       if (outlen < sizeof(outbuf))
+               return -EIO;
+
+       nic_data->vf_index = MCDI_DWORD(outbuf, GET_FUNCTION_INFO_OUT_VF);
+       return 0;
 }
+#endif
 
 static int efx_ef10_init_datapath_caps(struct efx_nic *efx)
 {
@@ -117,6 +173,13 @@ static int efx_ef10_init_datapath_caps(struct efx_nic *efx)
        nic_data->datapath_caps =
                MCDI_DWORD(outbuf, GET_CAPABILITIES_OUT_FLAGS1);
 
+       /* record the DPCPU firmware IDs to determine VEB vswitching support.
+        */
+       nic_data->rx_dpcpu_fw_id =
+               MCDI_WORD(outbuf, GET_CAPABILITIES_OUT_RX_DPCPU_FW_ID);
+       nic_data->tx_dpcpu_fw_id =
+               MCDI_WORD(outbuf, GET_CAPABILITIES_OUT_TX_DPCPU_FW_ID);
+
        if (!(nic_data->datapath_caps &
              (1 << MC_CMD_GET_CAPABILITIES_OUT_TX_TSO_LBN))) {
                netif_err(efx, drv, efx->net_dev,
@@ -147,7 +210,7 @@ static int efx_ef10_get_sysclk_freq(struct efx_nic *efx)
        return rc > 0 ? rc : -ERANGE;
 }
 
-static int efx_ef10_get_mac_address(struct efx_nic *efx, u8 *mac_address)
+static int efx_ef10_get_mac_address_pf(struct efx_nic *efx, u8 *mac_address)
 {
        MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_MAC_ADDRESSES_OUT_LEN);
        size_t outlen;
@@ -167,19 +230,76 @@ static int efx_ef10_get_mac_address(struct efx_nic *efx, u8 *mac_address)
        return 0;
 }
 
+static int efx_ef10_get_mac_address_vf(struct efx_nic *efx, u8 *mac_address)
+{
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_VPORT_GET_MAC_ADDRESSES_IN_LEN);
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_VPORT_GET_MAC_ADDRESSES_OUT_LENMAX);
+       size_t outlen;
+       int num_addrs, rc;
+
+       MCDI_SET_DWORD(inbuf, VPORT_GET_MAC_ADDRESSES_IN_VPORT_ID,
+                      EVB_PORT_ID_ASSIGNED);
+       rc = efx_mcdi_rpc(efx, MC_CMD_VPORT_GET_MAC_ADDRESSES, inbuf,
+                         sizeof(inbuf), outbuf, sizeof(outbuf), &outlen);
+
+       if (rc)
+               return rc;
+       if (outlen < MC_CMD_VPORT_GET_MAC_ADDRESSES_OUT_LENMIN)
+               return -EIO;
+
+       num_addrs = MCDI_DWORD(outbuf,
+                              VPORT_GET_MAC_ADDRESSES_OUT_MACADDR_COUNT);
+
+       WARN_ON(num_addrs != 1);
+
+       ether_addr_copy(mac_address,
+                       MCDI_PTR(outbuf, VPORT_GET_MAC_ADDRESSES_OUT_MACADDR));
+
+       return 0;
+}
+
+static ssize_t efx_ef10_show_link_control_flag(struct device *dev,
+                                              struct device_attribute *attr,
+                                              char *buf)
+{
+       struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev));
+
+       return sprintf(buf, "%d\n",
+                      ((efx->mcdi->fn_flags) &
+                       (1 << MC_CMD_DRV_ATTACH_EXT_OUT_FLAG_LINKCTRL))
+                      ? 1 : 0);
+}
+
+static ssize_t efx_ef10_show_primary_flag(struct device *dev,
+                                         struct device_attribute *attr,
+                                         char *buf)
+{
+       struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev));
+
+       return sprintf(buf, "%d\n",
+                      ((efx->mcdi->fn_flags) &
+                       (1 << MC_CMD_DRV_ATTACH_EXT_OUT_FLAG_PRIMARY))
+                      ? 1 : 0);
+}
+
+static DEVICE_ATTR(link_control_flag, 0444, efx_ef10_show_link_control_flag,
+                  NULL);
+static DEVICE_ATTR(primary_flag, 0444, efx_ef10_show_primary_flag, NULL);
+
 static int efx_ef10_probe(struct efx_nic *efx)
 {
        struct efx_ef10_nic_data *nic_data;
+       struct net_device *net_dev = efx->net_dev;
        int i, rc;
 
        /* We can have one VI for each 8K region.  However, until we
         * use TX option descriptors we need two TX queues per channel.
         */
-       efx->max_channels =
-               min_t(unsigned int,
-                     EFX_MAX_CHANNELS,
-                     resource_size(&efx->pci_dev->resource[EFX_MEM_BAR]) /
-                     (EFX_VI_PAGE_SIZE * EFX_TXQ_TYPES));
+       efx->max_channels = min_t(unsigned int,
+                                 EFX_MAX_CHANNELS,
+                                 efx_ef10_mem_map_size(efx) /
+                                 (EFX_VI_PAGE_SIZE * EFX_TXQ_TYPES));
+       efx->max_tx_channels = efx->max_channels;
        if (WARN_ON(efx->max_channels == 0))
                return -EIO;
 
@@ -188,6 +308,9 @@ static int efx_ef10_probe(struct efx_nic *efx)
                return -ENOMEM;
        efx->nic_data = nic_data;
 
+       /* we assume later that we can copy from this buffer in dwords */
+       BUILD_BUG_ON(MCDI_CTL_SDU_LEN_MAX_V2 % 4);
+
        rc = efx_nic_alloc_buffer(efx, &nic_data->mcdi_buf,
                                  8 + MCDI_CTL_SDU_LEN_MAX_V2, GFP_KERNEL);
        if (rc)
@@ -209,6 +332,8 @@ static int efx_ef10_probe(struct efx_nic *efx)
 
        nic_data->rx_rss_context = EFX_EF10_RSS_CONTEXT_INVALID;
 
+       nic_data->vport_id = EVB_PORT_ID_ASSIGNED;
+
        /* In case we're recovering from a crash (kexec), we want to
         * cancel any outstanding request by the previous user of this
         * function.  We send a special message using the least
@@ -230,45 +355,85 @@ static int efx_ef10_probe(struct efx_nic *efx)
        if (rc)
                goto fail3;
 
+       rc = device_create_file(&efx->pci_dev->dev,
+                               &dev_attr_link_control_flag);
+       if (rc)
+               goto fail3;
+
+       rc = device_create_file(&efx->pci_dev->dev, &dev_attr_primary_flag);
+       if (rc)
+               goto fail4;
+
+       rc = efx_ef10_get_pf_index(efx);
+       if (rc)
+               goto fail5;
+
        rc = efx_ef10_init_datapath_caps(efx);
        if (rc < 0)
-               goto fail3;
+               goto fail5;
 
        efx->rx_packet_len_offset =
                ES_DZ_RX_PREFIX_PKTLEN_OFST - ES_DZ_RX_PREFIX_SIZE;
 
        rc = efx_mcdi_port_get_number(efx);
        if (rc < 0)
-               goto fail3;
+               goto fail5;
        efx->port_num = rc;
+       net_dev->dev_port = rc;
 
-       rc = efx_ef10_get_mac_address(efx, efx->net_dev->perm_addr);
+       rc = efx->type->get_mac_address(efx, efx->net_dev->perm_addr);
        if (rc)
-               goto fail3;
+               goto fail5;
 
        rc = efx_ef10_get_sysclk_freq(efx);
        if (rc < 0)
-               goto fail3;
+               goto fail5;
        efx->timer_quantum_ns = 1536000 / rc; /* 1536 cycles */
 
-       /* Check whether firmware supports bug 35388 workaround */
-       rc = efx_mcdi_set_workaround(efx, MC_CMD_WORKAROUND_BUG35388, true);
-       if (rc == 0)
+       /* Check whether firmware supports bug 35388 workaround.
+        * First try to enable it, then if we get EPERM, just
+        * ask if it's already enabled
+        */
+       rc = efx_mcdi_set_workaround(efx, MC_CMD_WORKAROUND_BUG35388, true, NULL);
+       if (rc == 0) {
                nic_data->workaround_35388 = true;
-       else if (rc != -ENOSYS && rc != -ENOENT)
-               goto fail3;
+       } else if (rc == -EPERM) {
+               unsigned int enabled;
+
+               rc = efx_mcdi_get_workarounds(efx, NULL, &enabled);
+               if (rc)
+                       goto fail3;
+               nic_data->workaround_35388 = enabled &
+                       MC_CMD_GET_WORKAROUNDS_OUT_BUG35388;
+       } else if (rc != -ENOSYS && rc != -ENOENT) {
+               goto fail5;
+       }
        netif_dbg(efx, probe, efx->net_dev,
                  "workaround for bug 35388 is %sabled\n",
                  nic_data->workaround_35388 ? "en" : "dis");
 
        rc = efx_mcdi_mon_probe(efx);
-       if (rc)
-               goto fail3;
+       if (rc && rc != -EPERM)
+               goto fail5;
 
        efx_ptp_probe(efx, NULL);
 
+#ifdef CONFIG_SFC_SRIOV
+       if ((efx->pci_dev->physfn) && (!efx->pci_dev->is_physfn)) {
+               struct pci_dev *pci_dev_pf = efx->pci_dev->physfn;
+               struct efx_nic *efx_pf = pci_get_drvdata(pci_dev_pf);
+
+               efx_pf->type->get_mac_address(efx_pf, nic_data->port_id);
+       } else
+#endif
+               ether_addr_copy(nic_data->port_id, efx->net_dev->perm_addr);
+
        return 0;
 
+fail5:
+       device_remove_file(&efx->pci_dev->dev, &dev_attr_primary_flag);
+fail4:
+       device_remove_file(&efx->pci_dev->dev, &dev_attr_link_control_flag);
 fail3:
        efx_mcdi_fini(efx);
 fail2:
@@ -281,7 +446,7 @@ fail1:
 
 static int efx_ef10_free_vis(struct efx_nic *efx)
 {
-       MCDI_DECLARE_BUF_OUT_OR_ERR(outbuf, 0);
+       MCDI_DECLARE_BUF_ERR(outbuf);
        size_t outlen;
        int rc = efx_mcdi_rpc_quiet(efx, MC_CMD_FREE_VIS, NULL, 0,
                                    outbuf, sizeof(outbuf), &outlen);
@@ -352,9 +517,9 @@ static int efx_ef10_alloc_piobufs(struct efx_nic *efx, unsigned int n)
 static int efx_ef10_link_piobufs(struct efx_nic *efx)
 {
        struct efx_ef10_nic_data *nic_data = efx->nic_data;
-       MCDI_DECLARE_BUF(inbuf,
-                        max(MC_CMD_LINK_PIOBUF_IN_LEN,
-                            MC_CMD_UNLINK_PIOBUF_IN_LEN));
+       _MCDI_DECLARE_BUF(inbuf,
+                         max(MC_CMD_LINK_PIOBUF_IN_LEN,
+                             MC_CMD_UNLINK_PIOBUF_IN_LEN));
        struct efx_channel *channel;
        struct efx_tx_queue *tx_queue;
        unsigned int offset, index;
@@ -363,6 +528,8 @@ static int efx_ef10_link_piobufs(struct efx_nic *efx)
        BUILD_BUG_ON(MC_CMD_LINK_PIOBUF_OUT_LEN != 0);
        BUILD_BUG_ON(MC_CMD_UNLINK_PIOBUF_OUT_LEN != 0);
 
+       memset(inbuf, 0, sizeof(inbuf));
+
        /* Link a buffer to each VI in the write-combining mapping */
        for (index = 0; index < nic_data->n_piobufs; ++index) {
                MCDI_SET_DWORD(inbuf, LINK_PIOBUF_IN_PIOBUF_HANDLE,
@@ -475,6 +642,25 @@ static void efx_ef10_remove(struct efx_nic *efx)
        struct efx_ef10_nic_data *nic_data = efx->nic_data;
        int rc;
 
+#ifdef CONFIG_SFC_SRIOV
+       struct efx_ef10_nic_data *nic_data_pf;
+       struct pci_dev *pci_dev_pf;
+       struct efx_nic *efx_pf;
+       struct ef10_vf *vf;
+
+       if (efx->pci_dev->is_virtfn) {
+               pci_dev_pf = efx->pci_dev->physfn;
+               if (pci_dev_pf) {
+                       efx_pf = pci_get_drvdata(pci_dev_pf);
+                       nic_data_pf = efx_pf->nic_data;
+                       vf = nic_data_pf->vf + nic_data->vf_index;
+                       vf->efx = NULL;
+               } else
+                       netif_info(efx, drv, efx->net_dev,
+                                  "Could not get the PF id from VF\n");
+       }
+#endif
+
        efx_ptp_remove(efx);
 
        efx_mcdi_mon_remove(efx);
@@ -490,11 +676,120 @@ static void efx_ef10_remove(struct efx_nic *efx)
        if (!nic_data->must_restore_piobufs)
                efx_ef10_free_piobufs(efx);
 
+       device_remove_file(&efx->pci_dev->dev, &dev_attr_primary_flag);
+       device_remove_file(&efx->pci_dev->dev, &dev_attr_link_control_flag);
+
        efx_mcdi_fini(efx);
        efx_nic_free_buffer(efx, &nic_data->mcdi_buf);
        kfree(nic_data);
 }
 
+static int efx_ef10_probe_pf(struct efx_nic *efx)
+{
+       return efx_ef10_probe(efx);
+}
+
+int efx_ef10_vadaptor_alloc(struct efx_nic *efx, unsigned int port_id)
+{
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_VADAPTOR_ALLOC_IN_LEN);
+
+       MCDI_SET_DWORD(inbuf, VADAPTOR_ALLOC_IN_UPSTREAM_PORT_ID, port_id);
+       return efx_mcdi_rpc(efx, MC_CMD_VADAPTOR_ALLOC, inbuf, sizeof(inbuf),
+                           NULL, 0, NULL);
+}
+
+int efx_ef10_vadaptor_free(struct efx_nic *efx, unsigned int port_id)
+{
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_VADAPTOR_FREE_IN_LEN);
+
+       MCDI_SET_DWORD(inbuf, VADAPTOR_FREE_IN_UPSTREAM_PORT_ID, port_id);
+       return efx_mcdi_rpc(efx, MC_CMD_VADAPTOR_FREE, inbuf, sizeof(inbuf),
+                           NULL, 0, NULL);
+}
+
+int efx_ef10_vport_add_mac(struct efx_nic *efx,
+                          unsigned int port_id, u8 *mac)
+{
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_VPORT_ADD_MAC_ADDRESS_IN_LEN);
+
+       MCDI_SET_DWORD(inbuf, VPORT_ADD_MAC_ADDRESS_IN_VPORT_ID, port_id);
+       ether_addr_copy(MCDI_PTR(inbuf, VPORT_ADD_MAC_ADDRESS_IN_MACADDR), mac);
+
+       return efx_mcdi_rpc(efx, MC_CMD_VPORT_ADD_MAC_ADDRESS, inbuf,
+                           sizeof(inbuf), NULL, 0, NULL);
+}
+
+int efx_ef10_vport_del_mac(struct efx_nic *efx,
+                          unsigned int port_id, u8 *mac)
+{
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_VPORT_DEL_MAC_ADDRESS_IN_LEN);
+
+       MCDI_SET_DWORD(inbuf, VPORT_DEL_MAC_ADDRESS_IN_VPORT_ID, port_id);
+       ether_addr_copy(MCDI_PTR(inbuf, VPORT_DEL_MAC_ADDRESS_IN_MACADDR), mac);
+
+       return efx_mcdi_rpc(efx, MC_CMD_VPORT_DEL_MAC_ADDRESS, inbuf,
+                           sizeof(inbuf), NULL, 0, NULL);
+}
+
+#ifdef CONFIG_SFC_SRIOV
+static int efx_ef10_probe_vf(struct efx_nic *efx)
+{
+       int rc;
+       struct pci_dev *pci_dev_pf;
+
+       /* If the parent PF has no VF data structure, it doesn't know about this
+        * VF so fail probe.  The VF needs to be re-created.  This can happen
+        * if the PF driver is unloaded while the VF is assigned to a guest.
+        */
+       pci_dev_pf = efx->pci_dev->physfn;
+       if (pci_dev_pf) {
+               struct efx_nic *efx_pf = pci_get_drvdata(pci_dev_pf);
+               struct efx_ef10_nic_data *nic_data_pf = efx_pf->nic_data;
+
+               if (!nic_data_pf->vf) {
+                       netif_info(efx, drv, efx->net_dev,
+                                  "The VF cannot link to its parent PF; "
+                                  "please destroy and re-create the VF\n");
+                       return -EBUSY;
+               }
+       }
+
+       rc = efx_ef10_probe(efx);
+       if (rc)
+               return rc;
+
+       rc = efx_ef10_get_vf_index(efx);
+       if (rc)
+               goto fail;
+
+       if (efx->pci_dev->is_virtfn) {
+               if (efx->pci_dev->physfn) {
+                       struct efx_nic *efx_pf =
+                               pci_get_drvdata(efx->pci_dev->physfn);
+                       struct efx_ef10_nic_data *nic_data_p = efx_pf->nic_data;
+                       struct efx_ef10_nic_data *nic_data = efx->nic_data;
+
+                       nic_data_p->vf[nic_data->vf_index].efx = efx;
+                       nic_data_p->vf[nic_data->vf_index].pci_dev =
+                               efx->pci_dev;
+               } else
+                       netif_info(efx, drv, efx->net_dev,
+                                  "Could not get the PF id from VF\n");
+       }
+
+       return 0;
+
+fail:
+       efx_ef10_remove(efx);
+       return rc;
+}
+#else
+static int efx_ef10_probe_vf(struct efx_nic *efx __attribute__ ((unused)))
+{
+       return 0;
+}
+#endif
+
 static int efx_ef10_alloc_vis(struct efx_nic *efx,
                              unsigned int min_vis, unsigned int max_vis)
 {
@@ -529,11 +824,13 @@ static int efx_ef10_dimension_resources(struct efx_nic *efx)
 {
        struct efx_ef10_nic_data *nic_data = efx->nic_data;
        unsigned int uc_mem_map_size, wc_mem_map_size;
-       unsigned int min_vis, pio_write_vi_base, max_vis;
+       unsigned int min_vis = max(EFX_TXQ_TYPES,
+                                  efx_separate_tx_channels ? 2 : 1);
+       unsigned int channel_vis, pio_write_vi_base, max_vis;
        void __iomem *membase;
        int rc;
 
-       min_vis = max(efx->n_channels, efx->n_tx_channels * EFX_TXQ_TYPES);
+       channel_vis = max(efx->n_channels, efx->n_tx_channels * EFX_TXQ_TYPES);
 
 #ifdef EFX_USE_PIO
        /* Try to allocate PIO buffers if wanted and if the full
@@ -567,11 +864,11 @@ static int efx_ef10_dimension_resources(struct efx_nic *efx)
         * page size is >4K).  So we may allocate some extra VIs just
         * for writing PIO buffers through.
         *
-        * The UC mapping contains (min_vis - 1) complete VIs and the
+        * The UC mapping contains (channel_vis - 1) complete VIs and the
         * first half of the next VI.  Then the WC mapping begins with
         * the second half of this last VI.
         */
-       uc_mem_map_size = PAGE_ALIGN((min_vis - 1) * EFX_VI_PAGE_SIZE +
+       uc_mem_map_size = PAGE_ALIGN((channel_vis - 1) * EFX_VI_PAGE_SIZE +
                                     ER_DZ_TX_PIOBUF);
        if (nic_data->n_piobufs) {
                /* pio_write_vi_base rounds down to give the number of complete
@@ -586,7 +883,7 @@ static int efx_ef10_dimension_resources(struct efx_nic *efx)
        } else {
                pio_write_vi_base = 0;
                wc_mem_map_size = 0;
-               max_vis = min_vis;
+               max_vis = channel_vis;
        }
 
        /* In case the last attached driver failed to free VIs, do it now */
@@ -598,6 +895,23 @@ static int efx_ef10_dimension_resources(struct efx_nic *efx)
        if (rc != 0)
                return rc;
 
+       if (nic_data->n_allocated_vis < channel_vis) {
+               netif_info(efx, drv, efx->net_dev,
+                          "Could not allocate enough VIs to satisfy RSS"
+                          " requirements. Performance may not be optimal.\n");
+               /* We didn't get the VIs to populate our channels.
+                * We could keep what we got but then we'd have more
+                * interrupts than we need.
+                * Instead calculate new max_channels and restart
+                */
+               efx->max_channels = nic_data->n_allocated_vis;
+               efx->max_tx_channels =
+                       nic_data->n_allocated_vis / EFX_TXQ_TYPES;
+
+               efx_ef10_free_vis(efx);
+               return -EAGAIN;
+       }
+
        /* If we didn't get enough VIs to map all the PIO buffers, free the
         * PIO buffers
         */
@@ -687,19 +1001,41 @@ static int efx_ef10_init_nic(struct efx_nic *efx)
                nic_data->must_restore_piobufs = false;
        }
 
-       efx_ef10_rx_push_rss_config(efx);
+       /* don't fail init if RSS setup doesn't work */
+       efx->type->rx_push_rss_config(efx, false, efx->rx_indir_table);
+
        return 0;
 }
 
 static void efx_ef10_reset_mc_allocations(struct efx_nic *efx)
 {
        struct efx_ef10_nic_data *nic_data = efx->nic_data;
+#ifdef CONFIG_SFC_SRIOV
+       unsigned int i;
+#endif
 
        /* All our allocations have been reset */
        nic_data->must_realloc_vis = true;
        nic_data->must_restore_filters = true;
        nic_data->must_restore_piobufs = true;
        nic_data->rx_rss_context = EFX_EF10_RSS_CONTEXT_INVALID;
+
+       /* Driver-created vswitches and vports must be re-created */
+       nic_data->must_probe_vswitching = true;
+       nic_data->vport_id = EVB_PORT_ID_ASSIGNED;
+#ifdef CONFIG_SFC_SRIOV
+       if (nic_data->vf)
+               for (i = 0; i < efx->vf_count; i++)
+                       nic_data->vf[i].vport_id = 0;
+#endif
+}
+
+static enum reset_type efx_ef10_map_reset_reason(enum reset_type reason)
+{
+       if (reason == RESET_TYPE_MC_FAILURE)
+               return RESET_TYPE_DATAPATH;
+
+       return efx_mcdi_map_reset_reason(reason);
 }
 
 static int efx_ef10_map_reset_flags(u32 *flags)
@@ -736,6 +1072,12 @@ static int efx_ef10_reset(struct efx_nic *efx, enum reset_type reset_type)
 {
        int rc = efx_mcdi_reset(efx, reset_type);
 
+       /* Unprivileged functions return -EPERM, but need to return success
+        * here so that the datapath is brought back up.
+        */
+       if (reset_type == RESET_TYPE_WORLD && rc == -EPERM)
+               rc = 0;
+
        /* If it was a port reset, trigger reallocation of MC resources.
         * Note that on an MC reset nothing needs to be done now because we'll
         * detect the MC reset later and handle it then.
@@ -760,93 +1102,112 @@ static int efx_ef10_reset(struct efx_nic *efx, enum reset_type reset_type)
        [GENERIC_STAT_ ## ext_name] = { #ext_name, 0, 0 }
 
 static const struct efx_hw_stat_desc efx_ef10_stat_desc[EF10_STAT_COUNT] = {
-       EF10_DMA_STAT(tx_bytes, TX_BYTES),
-       EF10_DMA_STAT(tx_packets, TX_PKTS),
-       EF10_DMA_STAT(tx_pause, TX_PAUSE_PKTS),
-       EF10_DMA_STAT(tx_control, TX_CONTROL_PKTS),
-       EF10_DMA_STAT(tx_unicast, TX_UNICAST_PKTS),
-       EF10_DMA_STAT(tx_multicast, TX_MULTICAST_PKTS),
-       EF10_DMA_STAT(tx_broadcast, TX_BROADCAST_PKTS),
-       EF10_DMA_STAT(tx_lt64, TX_LT64_PKTS),
-       EF10_DMA_STAT(tx_64, TX_64_PKTS),
-       EF10_DMA_STAT(tx_65_to_127, TX_65_TO_127_PKTS),
-       EF10_DMA_STAT(tx_128_to_255, TX_128_TO_255_PKTS),
-       EF10_DMA_STAT(tx_256_to_511, TX_256_TO_511_PKTS),
-       EF10_DMA_STAT(tx_512_to_1023, TX_512_TO_1023_PKTS),
-       EF10_DMA_STAT(tx_1024_to_15xx, TX_1024_TO_15XX_PKTS),
-       EF10_DMA_STAT(tx_15xx_to_jumbo, TX_15XX_TO_JUMBO_PKTS),
-       EF10_DMA_STAT(rx_bytes, RX_BYTES),
-       EF10_DMA_INVIS_STAT(rx_bytes_minus_good_bytes, RX_BAD_BYTES),
-       EF10_OTHER_STAT(rx_good_bytes),
-       EF10_OTHER_STAT(rx_bad_bytes),
-       EF10_DMA_STAT(rx_packets, RX_PKTS),
-       EF10_DMA_STAT(rx_good, RX_GOOD_PKTS),
-       EF10_DMA_STAT(rx_bad, RX_BAD_FCS_PKTS),
-       EF10_DMA_STAT(rx_pause, RX_PAUSE_PKTS),
-       EF10_DMA_STAT(rx_control, RX_CONTROL_PKTS),
-       EF10_DMA_STAT(rx_unicast, RX_UNICAST_PKTS),
-       EF10_DMA_STAT(rx_multicast, RX_MULTICAST_PKTS),
-       EF10_DMA_STAT(rx_broadcast, RX_BROADCAST_PKTS),
-       EF10_DMA_STAT(rx_lt64, RX_UNDERSIZE_PKTS),
-       EF10_DMA_STAT(rx_64, RX_64_PKTS),
-       EF10_DMA_STAT(rx_65_to_127, RX_65_TO_127_PKTS),
-       EF10_DMA_STAT(rx_128_to_255, RX_128_TO_255_PKTS),
-       EF10_DMA_STAT(rx_256_to_511, RX_256_TO_511_PKTS),
-       EF10_DMA_STAT(rx_512_to_1023, RX_512_TO_1023_PKTS),
-       EF10_DMA_STAT(rx_1024_to_15xx, RX_1024_TO_15XX_PKTS),
-       EF10_DMA_STAT(rx_15xx_to_jumbo, RX_15XX_TO_JUMBO_PKTS),
-       EF10_DMA_STAT(rx_gtjumbo, RX_GTJUMBO_PKTS),
-       EF10_DMA_STAT(rx_bad_gtjumbo, RX_JABBER_PKTS),
-       EF10_DMA_STAT(rx_overflow, RX_OVERFLOW_PKTS),
-       EF10_DMA_STAT(rx_align_error, RX_ALIGN_ERROR_PKTS),
-       EF10_DMA_STAT(rx_length_error, RX_LENGTH_ERROR_PKTS),
-       EF10_DMA_STAT(rx_nodesc_drops, RX_NODESC_DROPS),
+       EF10_DMA_STAT(port_tx_bytes, TX_BYTES),
+       EF10_DMA_STAT(port_tx_packets, TX_PKTS),
+       EF10_DMA_STAT(port_tx_pause, TX_PAUSE_PKTS),
+       EF10_DMA_STAT(port_tx_control, TX_CONTROL_PKTS),
+       EF10_DMA_STAT(port_tx_unicast, TX_UNICAST_PKTS),
+       EF10_DMA_STAT(port_tx_multicast, TX_MULTICAST_PKTS),
+       EF10_DMA_STAT(port_tx_broadcast, TX_BROADCAST_PKTS),
+       EF10_DMA_STAT(port_tx_lt64, TX_LT64_PKTS),
+       EF10_DMA_STAT(port_tx_64, TX_64_PKTS),
+       EF10_DMA_STAT(port_tx_65_to_127, TX_65_TO_127_PKTS),
+       EF10_DMA_STAT(port_tx_128_to_255, TX_128_TO_255_PKTS),
+       EF10_DMA_STAT(port_tx_256_to_511, TX_256_TO_511_PKTS),
+       EF10_DMA_STAT(port_tx_512_to_1023, TX_512_TO_1023_PKTS),
+       EF10_DMA_STAT(port_tx_1024_to_15xx, TX_1024_TO_15XX_PKTS),
+       EF10_DMA_STAT(port_tx_15xx_to_jumbo, TX_15XX_TO_JUMBO_PKTS),
+       EF10_DMA_STAT(port_rx_bytes, RX_BYTES),
+       EF10_DMA_INVIS_STAT(port_rx_bytes_minus_good_bytes, RX_BAD_BYTES),
+       EF10_OTHER_STAT(port_rx_good_bytes),
+       EF10_OTHER_STAT(port_rx_bad_bytes),
+       EF10_DMA_STAT(port_rx_packets, RX_PKTS),
+       EF10_DMA_STAT(port_rx_good, RX_GOOD_PKTS),
+       EF10_DMA_STAT(port_rx_bad, RX_BAD_FCS_PKTS),
+       EF10_DMA_STAT(port_rx_pause, RX_PAUSE_PKTS),
+       EF10_DMA_STAT(port_rx_control, RX_CONTROL_PKTS),
+       EF10_DMA_STAT(port_rx_unicast, RX_UNICAST_PKTS),
+       EF10_DMA_STAT(port_rx_multicast, RX_MULTICAST_PKTS),
+       EF10_DMA_STAT(port_rx_broadcast, RX_BROADCAST_PKTS),
+       EF10_DMA_STAT(port_rx_lt64, RX_UNDERSIZE_PKTS),
+       EF10_DMA_STAT(port_rx_64, RX_64_PKTS),
+       EF10_DMA_STAT(port_rx_65_to_127, RX_65_TO_127_PKTS),
+       EF10_DMA_STAT(port_rx_128_to_255, RX_128_TO_255_PKTS),
+       EF10_DMA_STAT(port_rx_256_to_511, RX_256_TO_511_PKTS),
+       EF10_DMA_STAT(port_rx_512_to_1023, RX_512_TO_1023_PKTS),
+       EF10_DMA_STAT(port_rx_1024_to_15xx, RX_1024_TO_15XX_PKTS),
+       EF10_DMA_STAT(port_rx_15xx_to_jumbo, RX_15XX_TO_JUMBO_PKTS),
+       EF10_DMA_STAT(port_rx_gtjumbo, RX_GTJUMBO_PKTS),
+       EF10_DMA_STAT(port_rx_bad_gtjumbo, RX_JABBER_PKTS),
+       EF10_DMA_STAT(port_rx_overflow, RX_OVERFLOW_PKTS),
+       EF10_DMA_STAT(port_rx_align_error, RX_ALIGN_ERROR_PKTS),
+       EF10_DMA_STAT(port_rx_length_error, RX_LENGTH_ERROR_PKTS),
+       EF10_DMA_STAT(port_rx_nodesc_drops, RX_NODESC_DROPS),
        GENERIC_SW_STAT(rx_nodesc_trunc),
        GENERIC_SW_STAT(rx_noskb_drops),
-       EF10_DMA_STAT(rx_pm_trunc_bb_overflow, PM_TRUNC_BB_OVERFLOW),
-       EF10_DMA_STAT(rx_pm_discard_bb_overflow, PM_DISCARD_BB_OVERFLOW),
-       EF10_DMA_STAT(rx_pm_trunc_vfifo_full, PM_TRUNC_VFIFO_FULL),
-       EF10_DMA_STAT(rx_pm_discard_vfifo_full, PM_DISCARD_VFIFO_FULL),
-       EF10_DMA_STAT(rx_pm_trunc_qbb, PM_TRUNC_QBB),
-       EF10_DMA_STAT(rx_pm_discard_qbb, PM_DISCARD_QBB),
-       EF10_DMA_STAT(rx_pm_discard_mapping, PM_DISCARD_MAPPING),
-       EF10_DMA_STAT(rx_dp_q_disabled_packets, RXDP_Q_DISABLED_PKTS),
-       EF10_DMA_STAT(rx_dp_di_dropped_packets, RXDP_DI_DROPPED_PKTS),
-       EF10_DMA_STAT(rx_dp_streaming_packets, RXDP_STREAMING_PKTS),
-       EF10_DMA_STAT(rx_dp_hlb_fetch, RXDP_EMERGENCY_FETCH_CONDITIONS),
-       EF10_DMA_STAT(rx_dp_hlb_wait, RXDP_EMERGENCY_WAIT_CONDITIONS),
+       EF10_DMA_STAT(port_rx_pm_trunc_bb_overflow, PM_TRUNC_BB_OVERFLOW),
+       EF10_DMA_STAT(port_rx_pm_discard_bb_overflow, PM_DISCARD_BB_OVERFLOW),
+       EF10_DMA_STAT(port_rx_pm_trunc_vfifo_full, PM_TRUNC_VFIFO_FULL),
+       EF10_DMA_STAT(port_rx_pm_discard_vfifo_full, PM_DISCARD_VFIFO_FULL),
+       EF10_DMA_STAT(port_rx_pm_trunc_qbb, PM_TRUNC_QBB),
+       EF10_DMA_STAT(port_rx_pm_discard_qbb, PM_DISCARD_QBB),
+       EF10_DMA_STAT(port_rx_pm_discard_mapping, PM_DISCARD_MAPPING),
+       EF10_DMA_STAT(port_rx_dp_q_disabled_packets, RXDP_Q_DISABLED_PKTS),
+       EF10_DMA_STAT(port_rx_dp_di_dropped_packets, RXDP_DI_DROPPED_PKTS),
+       EF10_DMA_STAT(port_rx_dp_streaming_packets, RXDP_STREAMING_PKTS),
+       EF10_DMA_STAT(port_rx_dp_hlb_fetch, RXDP_HLB_FETCH_CONDITIONS),
+       EF10_DMA_STAT(port_rx_dp_hlb_wait, RXDP_HLB_WAIT_CONDITIONS),
+       EF10_DMA_STAT(rx_unicast, VADAPTER_RX_UNICAST_PACKETS),
+       EF10_DMA_STAT(rx_unicast_bytes, VADAPTER_RX_UNICAST_BYTES),
+       EF10_DMA_STAT(rx_multicast, VADAPTER_RX_MULTICAST_PACKETS),
+       EF10_DMA_STAT(rx_multicast_bytes, VADAPTER_RX_MULTICAST_BYTES),
+       EF10_DMA_STAT(rx_broadcast, VADAPTER_RX_BROADCAST_PACKETS),
+       EF10_DMA_STAT(rx_broadcast_bytes, VADAPTER_RX_BROADCAST_BYTES),
+       EF10_DMA_STAT(rx_bad, VADAPTER_RX_BAD_PACKETS),
+       EF10_DMA_STAT(rx_bad_bytes, VADAPTER_RX_BAD_BYTES),
+       EF10_DMA_STAT(rx_overflow, VADAPTER_RX_OVERFLOW),
+       EF10_DMA_STAT(tx_unicast, VADAPTER_TX_UNICAST_PACKETS),
+       EF10_DMA_STAT(tx_unicast_bytes, VADAPTER_TX_UNICAST_BYTES),
+       EF10_DMA_STAT(tx_multicast, VADAPTER_TX_MULTICAST_PACKETS),
+       EF10_DMA_STAT(tx_multicast_bytes, VADAPTER_TX_MULTICAST_BYTES),
+       EF10_DMA_STAT(tx_broadcast, VADAPTER_TX_BROADCAST_PACKETS),
+       EF10_DMA_STAT(tx_broadcast_bytes, VADAPTER_TX_BROADCAST_BYTES),
+       EF10_DMA_STAT(tx_bad, VADAPTER_TX_BAD_PACKETS),
+       EF10_DMA_STAT(tx_bad_bytes, VADAPTER_TX_BAD_BYTES),
+       EF10_DMA_STAT(tx_overflow, VADAPTER_TX_OVERFLOW),
 };
 
-#define HUNT_COMMON_STAT_MASK ((1ULL << EF10_STAT_tx_bytes) |          \
-                              (1ULL << EF10_STAT_tx_packets) |         \
-                              (1ULL << EF10_STAT_tx_pause) |           \
-                              (1ULL << EF10_STAT_tx_unicast) |         \
-                              (1ULL << EF10_STAT_tx_multicast) |       \
-                              (1ULL << EF10_STAT_tx_broadcast) |       \
-                              (1ULL << EF10_STAT_rx_bytes) |           \
-                              (1ULL << EF10_STAT_rx_bytes_minus_good_bytes) | \
-                              (1ULL << EF10_STAT_rx_good_bytes) |      \
-                              (1ULL << EF10_STAT_rx_bad_bytes) |       \
-                              (1ULL << EF10_STAT_rx_packets) |         \
-                              (1ULL << EF10_STAT_rx_good) |            \
-                              (1ULL << EF10_STAT_rx_bad) |             \
-                              (1ULL << EF10_STAT_rx_pause) |           \
-                              (1ULL << EF10_STAT_rx_control) |         \
-                              (1ULL << EF10_STAT_rx_unicast) |         \
-                              (1ULL << EF10_STAT_rx_multicast) |       \
-                              (1ULL << EF10_STAT_rx_broadcast) |       \
-                              (1ULL << EF10_STAT_rx_lt64) |            \
-                              (1ULL << EF10_STAT_rx_64) |              \
-                              (1ULL << EF10_STAT_rx_65_to_127) |       \
-                              (1ULL << EF10_STAT_rx_128_to_255) |      \
-                              (1ULL << EF10_STAT_rx_256_to_511) |      \
-                              (1ULL << EF10_STAT_rx_512_to_1023) |     \
-                              (1ULL << EF10_STAT_rx_1024_to_15xx) |    \
-                              (1ULL << EF10_STAT_rx_15xx_to_jumbo) |   \
-                              (1ULL << EF10_STAT_rx_gtjumbo) |         \
-                              (1ULL << EF10_STAT_rx_bad_gtjumbo) |     \
-                              (1ULL << EF10_STAT_rx_overflow) |        \
-                              (1ULL << EF10_STAT_rx_nodesc_drops) |    \
+#define HUNT_COMMON_STAT_MASK ((1ULL << EF10_STAT_port_tx_bytes) |     \
+                              (1ULL << EF10_STAT_port_tx_packets) |    \
+                              (1ULL << EF10_STAT_port_tx_pause) |      \
+                              (1ULL << EF10_STAT_port_tx_unicast) |    \
+                              (1ULL << EF10_STAT_port_tx_multicast) |  \
+                              (1ULL << EF10_STAT_port_tx_broadcast) |  \
+                              (1ULL << EF10_STAT_port_rx_bytes) |      \
+                              (1ULL <<                                 \
+                               EF10_STAT_port_rx_bytes_minus_good_bytes) | \
+                              (1ULL << EF10_STAT_port_rx_good_bytes) | \
+                              (1ULL << EF10_STAT_port_rx_bad_bytes) |  \
+                              (1ULL << EF10_STAT_port_rx_packets) |    \
+                              (1ULL << EF10_STAT_port_rx_good) |       \
+                              (1ULL << EF10_STAT_port_rx_bad) |        \
+                              (1ULL << EF10_STAT_port_rx_pause) |      \
+                              (1ULL << EF10_STAT_port_rx_control) |    \
+                              (1ULL << EF10_STAT_port_rx_unicast) |    \
+                              (1ULL << EF10_STAT_port_rx_multicast) |  \
+                              (1ULL << EF10_STAT_port_rx_broadcast) |  \
+                              (1ULL << EF10_STAT_port_rx_lt64) |       \
+                              (1ULL << EF10_STAT_port_rx_64) |         \
+                              (1ULL << EF10_STAT_port_rx_65_to_127) |  \
+                              (1ULL << EF10_STAT_port_rx_128_to_255) | \
+                              (1ULL << EF10_STAT_port_rx_256_to_511) | \
+                              (1ULL << EF10_STAT_port_rx_512_to_1023) |\
+                              (1ULL << EF10_STAT_port_rx_1024_to_15xx) |\
+                              (1ULL << EF10_STAT_port_rx_15xx_to_jumbo) |\
+                              (1ULL << EF10_STAT_port_rx_gtjumbo) |    \
+                              (1ULL << EF10_STAT_port_rx_bad_gtjumbo) |\
+                              (1ULL << EF10_STAT_port_rx_overflow) |   \
+                              (1ULL << EF10_STAT_port_rx_nodesc_drops) |\
                               (1ULL << GENERIC_STAT_rx_nodesc_trunc) | \
                               (1ULL << GENERIC_STAT_rx_noskb_drops))
 
@@ -854,39 +1215,39 @@ static const struct efx_hw_stat_desc efx_ef10_stat_desc[EF10_STAT_COUNT] = {
  * switchable port we do not expose these because they might not
  * include all the packets they should.
  */
-#define HUNT_10G_ONLY_STAT_MASK ((1ULL << EF10_STAT_tx_control) |      \
-                                (1ULL << EF10_STAT_tx_lt64) |          \
-                                (1ULL << EF10_STAT_tx_64) |            \
-                                (1ULL << EF10_STAT_tx_65_to_127) |     \
-                                (1ULL << EF10_STAT_tx_128_to_255) |    \
-                                (1ULL << EF10_STAT_tx_256_to_511) |    \
-                                (1ULL << EF10_STAT_tx_512_to_1023) |   \
-                                (1ULL << EF10_STAT_tx_1024_to_15xx) |  \
-                                (1ULL << EF10_STAT_tx_15xx_to_jumbo))
+#define HUNT_10G_ONLY_STAT_MASK ((1ULL << EF10_STAT_port_tx_control) | \
+                                (1ULL << EF10_STAT_port_tx_lt64) |     \
+                                (1ULL << EF10_STAT_port_tx_64) |       \
+                                (1ULL << EF10_STAT_port_tx_65_to_127) |\
+                                (1ULL << EF10_STAT_port_tx_128_to_255) |\
+                                (1ULL << EF10_STAT_port_tx_256_to_511) |\
+                                (1ULL << EF10_STAT_port_tx_512_to_1023) |\
+                                (1ULL << EF10_STAT_port_tx_1024_to_15xx) |\
+                                (1ULL << EF10_STAT_port_tx_15xx_to_jumbo))
 
 /* These statistics are only provided by the 40G MAC.  For a 10G/40G
  * switchable port we do expose these because the errors will otherwise
  * be silent.
  */
-#define HUNT_40G_EXTRA_STAT_MASK ((1ULL << EF10_STAT_rx_align_error) | \
-                                 (1ULL << EF10_STAT_rx_length_error))
+#define HUNT_40G_EXTRA_STAT_MASK ((1ULL << EF10_STAT_port_rx_align_error) |\
+                                 (1ULL << EF10_STAT_port_rx_length_error))
 
 /* These statistics are only provided if the firmware supports the
  * capability PM_AND_RXDP_COUNTERS.
  */
 #define HUNT_PM_AND_RXDP_STAT_MASK (                                   \
-       (1ULL << EF10_STAT_rx_pm_trunc_bb_overflow) |                   \
-       (1ULL << EF10_STAT_rx_pm_discard_bb_overflow) |                 \
-       (1ULL << EF10_STAT_rx_pm_trunc_vfifo_full) |                    \
-       (1ULL << EF10_STAT_rx_pm_discard_vfifo_full) |                  \
-       (1ULL << EF10_STAT_rx_pm_trunc_qbb) |                           \
-       (1ULL << EF10_STAT_rx_pm_discard_qbb) |                         \
-       (1ULL << EF10_STAT_rx_pm_discard_mapping) |                     \
-       (1ULL << EF10_STAT_rx_dp_q_disabled_packets) |                  \
-       (1ULL << EF10_STAT_rx_dp_di_dropped_packets) |                  \
-       (1ULL << EF10_STAT_rx_dp_streaming_packets) |                   \
-       (1ULL << EF10_STAT_rx_dp_hlb_fetch) |                           \
-       (1ULL << EF10_STAT_rx_dp_hlb_wait))
+       (1ULL << EF10_STAT_port_rx_pm_trunc_bb_overflow) |              \
+       (1ULL << EF10_STAT_port_rx_pm_discard_bb_overflow) |            \
+       (1ULL << EF10_STAT_port_rx_pm_trunc_vfifo_full) |               \
+       (1ULL << EF10_STAT_port_rx_pm_discard_vfifo_full) |             \
+       (1ULL << EF10_STAT_port_rx_pm_trunc_qbb) |                      \
+       (1ULL << EF10_STAT_port_rx_pm_discard_qbb) |                    \
+       (1ULL << EF10_STAT_port_rx_pm_discard_mapping) |                \
+       (1ULL << EF10_STAT_port_rx_dp_q_disabled_packets) |             \
+       (1ULL << EF10_STAT_port_rx_dp_di_dropped_packets) |             \
+       (1ULL << EF10_STAT_port_rx_dp_streaming_packets) |              \
+       (1ULL << EF10_STAT_port_rx_dp_hlb_fetch) |                      \
+       (1ULL << EF10_STAT_port_rx_dp_hlb_wait))
 
 static u64 efx_ef10_raw_stat_mask(struct efx_nic *efx)
 {
@@ -894,6 +1255,10 @@ static u64 efx_ef10_raw_stat_mask(struct efx_nic *efx)
        u32 port_caps = efx_mcdi_phy_get_caps(efx);
        struct efx_ef10_nic_data *nic_data = efx->nic_data;
 
+       if (!(efx->mcdi->fn_flags &
+             1 << MC_CMD_DRV_ATTACH_EXT_OUT_FLAG_LINKCTRL))
+               return 0;
+
        if (port_caps & (1 << MC_CMD_PHY_CAP_40000FDX_LBN))
                raw_mask |= HUNT_40G_EXTRA_STAT_MASK;
        else
@@ -908,13 +1273,28 @@ static u64 efx_ef10_raw_stat_mask(struct efx_nic *efx)
 
 static void efx_ef10_get_stat_mask(struct efx_nic *efx, unsigned long *mask)
 {
-       u64 raw_mask = efx_ef10_raw_stat_mask(efx);
+       struct efx_ef10_nic_data *nic_data = efx->nic_data;
+       u64 raw_mask[2];
+
+       raw_mask[0] = efx_ef10_raw_stat_mask(efx);
+
+       /* Only show vadaptor stats when EVB capability is present */
+       if (nic_data->datapath_caps &
+           (1 << MC_CMD_GET_CAPABILITIES_OUT_EVB_LBN)) {
+               raw_mask[0] |= ~((1ULL << EF10_STAT_rx_unicast) - 1);
+               raw_mask[1] = (1ULL << (EF10_STAT_COUNT - 63)) - 1;
+       } else {
+               raw_mask[1] = 0;
+       }
 
 #if BITS_PER_LONG == 64
-       mask[0] = raw_mask;
+       mask[0] = raw_mask[0];
+       mask[1] = raw_mask[1];
 #else
-       mask[0] = raw_mask & 0xffffffff;
-       mask[1] = raw_mask >> 32;
+       mask[0] = raw_mask[0] & 0xffffffff;
+       mask[1] = raw_mask[0] >> 32;
+       mask[2] = raw_mask[1] & 0xffffffff;
+       mask[3] = raw_mask[1] >> 32;
 #endif
 }
 
@@ -927,7 +1307,76 @@ static size_t efx_ef10_describe_stats(struct efx_nic *efx, u8 *names)
                                      mask, names);
 }
 
-static int efx_ef10_try_update_nic_stats(struct efx_nic *efx)
+static size_t efx_ef10_update_stats_common(struct efx_nic *efx, u64 *full_stats,
+                                          struct rtnl_link_stats64 *core_stats)
+{
+       DECLARE_BITMAP(mask, EF10_STAT_COUNT);
+       struct efx_ef10_nic_data *nic_data = efx->nic_data;
+       u64 *stats = nic_data->stats;
+       size_t stats_count = 0, index;
+
+       efx_ef10_get_stat_mask(efx, mask);
+
+       if (full_stats) {
+               for_each_set_bit(index, mask, EF10_STAT_COUNT) {
+                       if (efx_ef10_stat_desc[index].name) {
+                               *full_stats++ = stats[index];
+                               ++stats_count;
+                       }
+               }
+       }
+
+       if (!core_stats)
+               return stats_count;
+
+       if (nic_data->datapath_caps &
+                       1 << MC_CMD_GET_CAPABILITIES_OUT_EVB_LBN) {
+               /* Use vadaptor stats. */
+               core_stats->rx_packets = stats[EF10_STAT_rx_unicast] +
+                                        stats[EF10_STAT_rx_multicast] +
+                                        stats[EF10_STAT_rx_broadcast];
+               core_stats->tx_packets = stats[EF10_STAT_tx_unicast] +
+                                        stats[EF10_STAT_tx_multicast] +
+                                        stats[EF10_STAT_tx_broadcast];
+               core_stats->rx_bytes = stats[EF10_STAT_rx_unicast_bytes] +
+                                      stats[EF10_STAT_rx_multicast_bytes] +
+                                      stats[EF10_STAT_rx_broadcast_bytes];
+               core_stats->tx_bytes = stats[EF10_STAT_tx_unicast_bytes] +
+                                      stats[EF10_STAT_tx_multicast_bytes] +
+                                      stats[EF10_STAT_tx_broadcast_bytes];
+               core_stats->rx_dropped = stats[GENERIC_STAT_rx_nodesc_trunc] +
+                                        stats[GENERIC_STAT_rx_noskb_drops];
+               core_stats->multicast = stats[EF10_STAT_rx_multicast];
+               core_stats->rx_crc_errors = stats[EF10_STAT_rx_bad];
+               core_stats->rx_fifo_errors = stats[EF10_STAT_rx_overflow];
+               core_stats->rx_errors = core_stats->rx_crc_errors;
+               core_stats->tx_errors = stats[EF10_STAT_tx_bad];
+       } else {
+               /* Use port stats. */
+               core_stats->rx_packets = stats[EF10_STAT_port_rx_packets];
+               core_stats->tx_packets = stats[EF10_STAT_port_tx_packets];
+               core_stats->rx_bytes = stats[EF10_STAT_port_rx_bytes];
+               core_stats->tx_bytes = stats[EF10_STAT_port_tx_bytes];
+               core_stats->rx_dropped = stats[EF10_STAT_port_rx_nodesc_drops] +
+                                        stats[GENERIC_STAT_rx_nodesc_trunc] +
+                                        stats[GENERIC_STAT_rx_noskb_drops];
+               core_stats->multicast = stats[EF10_STAT_port_rx_multicast];
+               core_stats->rx_length_errors =
+                               stats[EF10_STAT_port_rx_gtjumbo] +
+                               stats[EF10_STAT_port_rx_length_error];
+               core_stats->rx_crc_errors = stats[EF10_STAT_port_rx_bad];
+               core_stats->rx_frame_errors =
+                               stats[EF10_STAT_port_rx_align_error];
+               core_stats->rx_fifo_errors = stats[EF10_STAT_port_rx_overflow];
+               core_stats->rx_errors = (core_stats->rx_length_errors +
+                                        core_stats->rx_crc_errors +
+                                        core_stats->rx_frame_errors);
+       }
+
+       return stats_count;
+}
+
+static int efx_ef10_try_update_nic_stats_pf(struct efx_nic *efx)
 {
        struct efx_ef10_nic_data *nic_data = efx->nic_data;
        DECLARE_BITMAP(mask, EF10_STAT_COUNT);
@@ -952,87 +1401,134 @@ static int efx_ef10_try_update_nic_stats(struct efx_nic *efx)
                return -EAGAIN;
 
        /* Update derived statistics */
-       efx_nic_fix_nodesc_drop_stat(efx, &stats[EF10_STAT_rx_nodesc_drops]);
-       stats[EF10_STAT_rx_good_bytes] =
-               stats[EF10_STAT_rx_bytes] -
-               stats[EF10_STAT_rx_bytes_minus_good_bytes];
-       efx_update_diff_stat(&stats[EF10_STAT_rx_bad_bytes],
-                            stats[EF10_STAT_rx_bytes_minus_good_bytes]);
+       efx_nic_fix_nodesc_drop_stat(efx,
+                                    &stats[EF10_STAT_port_rx_nodesc_drops]);
+       stats[EF10_STAT_port_rx_good_bytes] =
+               stats[EF10_STAT_port_rx_bytes] -
+               stats[EF10_STAT_port_rx_bytes_minus_good_bytes];
+       efx_update_diff_stat(&stats[EF10_STAT_port_rx_bad_bytes],
+                            stats[EF10_STAT_port_rx_bytes_minus_good_bytes]);
        efx_update_sw_stats(efx, stats);
        return 0;
 }
 
 
-static size_t efx_ef10_update_stats(struct efx_nic *efx, u64 *full_stats,
-                                   struct rtnl_link_stats64 *core_stats)
+static size_t efx_ef10_update_stats_pf(struct efx_nic *efx, u64 *full_stats,
+                                      struct rtnl_link_stats64 *core_stats)
 {
-       DECLARE_BITMAP(mask, EF10_STAT_COUNT);
-       struct efx_ef10_nic_data *nic_data = efx->nic_data;
-       u64 *stats = nic_data->stats;
-       size_t stats_count = 0, index;
        int retry;
 
-       efx_ef10_get_stat_mask(efx, mask);
-
        /* If we're unlucky enough to read statistics during the DMA, wait
         * up to 10ms for it to finish (typically takes <500us)
         */
        for (retry = 0; retry < 100; ++retry) {
-               if (efx_ef10_try_update_nic_stats(efx) == 0)
+               if (efx_ef10_try_update_nic_stats_pf(efx) == 0)
                        break;
                udelay(100);
        }
 
-       if (full_stats) {
-               for_each_set_bit(index, mask, EF10_STAT_COUNT) {
-                       if (efx_ef10_stat_desc[index].name) {
-                               *full_stats++ = stats[index];
-                               ++stats_count;
-                       }
-               }
-       }
+       return efx_ef10_update_stats_common(efx, full_stats, core_stats);
+}
 
-       if (core_stats) {
-               core_stats->rx_packets = stats[EF10_STAT_rx_packets];
-               core_stats->tx_packets = stats[EF10_STAT_tx_packets];
-               core_stats->rx_bytes = stats[EF10_STAT_rx_bytes];
-               core_stats->tx_bytes = stats[EF10_STAT_tx_bytes];
-               core_stats->rx_dropped = stats[EF10_STAT_rx_nodesc_drops] +
-                                        stats[GENERIC_STAT_rx_nodesc_trunc] +
-                                        stats[GENERIC_STAT_rx_noskb_drops];
-               core_stats->multicast = stats[EF10_STAT_rx_multicast];
-               core_stats->rx_length_errors =
-                       stats[EF10_STAT_rx_gtjumbo] +
-                       stats[EF10_STAT_rx_length_error];
-               core_stats->rx_crc_errors = stats[EF10_STAT_rx_bad];
-               core_stats->rx_frame_errors = stats[EF10_STAT_rx_align_error];
-               core_stats->rx_fifo_errors = stats[EF10_STAT_rx_overflow];
-               core_stats->rx_errors = (core_stats->rx_length_errors +
-                                        core_stats->rx_crc_errors +
-                                        core_stats->rx_frame_errors);
+static int efx_ef10_try_update_nic_stats_vf(struct efx_nic *efx)
+{
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_MAC_STATS_IN_LEN);
+       struct efx_ef10_nic_data *nic_data = efx->nic_data;
+       DECLARE_BITMAP(mask, EF10_STAT_COUNT);
+       __le64 generation_start, generation_end;
+       u64 *stats = nic_data->stats;
+       u32 dma_len = MC_CMD_MAC_NSTATS * sizeof(u64);
+       struct efx_buffer stats_buf;
+       __le64 *dma_stats;
+       int rc;
+
+       spin_unlock_bh(&efx->stats_lock);
+
+       if (in_interrupt()) {
+               /* If in atomic context, cannot update stats.  Just update the
+                * software stats and return so the caller can continue.
+                */
+               spin_lock_bh(&efx->stats_lock);
+               efx_update_sw_stats(efx, stats);
+               return 0;
        }
 
-       return stats_count;
-}
+       efx_ef10_get_stat_mask(efx, mask);
 
-static void efx_ef10_push_irq_moderation(struct efx_channel *channel)
-{
-       struct efx_nic *efx = channel->efx;
-       unsigned int mode, value;
-       efx_dword_t timer_cmd;
+       rc = efx_nic_alloc_buffer(efx, &stats_buf, dma_len, GFP_ATOMIC);
+       if (rc) {
+               spin_lock_bh(&efx->stats_lock);
+               return rc;
+       }
 
-       if (channel->irq_moderation) {
-               mode = 3;
-               value = channel->irq_moderation - 1;
-       } else {
-               mode = 0;
-               value = 0;
+       dma_stats = stats_buf.addr;
+       dma_stats[MC_CMD_MAC_GENERATION_END] = EFX_MC_STATS_GENERATION_INVALID;
+
+       MCDI_SET_QWORD(inbuf, MAC_STATS_IN_DMA_ADDR, stats_buf.dma_addr);
+       MCDI_POPULATE_DWORD_1(inbuf, MAC_STATS_IN_CMD,
+                             MAC_STATS_IN_DMA, 1);
+       MCDI_SET_DWORD(inbuf, MAC_STATS_IN_DMA_LEN, dma_len);
+       MCDI_SET_DWORD(inbuf, MAC_STATS_IN_PORT_ID, EVB_PORT_ID_ASSIGNED);
+
+       rc = efx_mcdi_rpc_quiet(efx, MC_CMD_MAC_STATS, inbuf, sizeof(inbuf),
+                               NULL, 0, NULL);
+       spin_lock_bh(&efx->stats_lock);
+       if (rc) {
+               /* Expect ENOENT if DMA queues have not been set up */
+               if (rc != -ENOENT || atomic_read(&efx->active_queues))
+                       efx_mcdi_display_error(efx, MC_CMD_MAC_STATS,
+                                              sizeof(inbuf), NULL, 0, rc);
+               goto out;
        }
 
-       if (EFX_EF10_WORKAROUND_35388(efx)) {
-               EFX_POPULATE_DWORD_3(timer_cmd, ERF_DD_EVQ_IND_TIMER_FLAGS,
-                                    EFE_DD_EVQ_IND_TIMER_FLAGS,
-                                    ERF_DD_EVQ_IND_TIMER_MODE, mode,
+       generation_end = dma_stats[MC_CMD_MAC_GENERATION_END];
+       if (generation_end == EFX_MC_STATS_GENERATION_INVALID) {
+               WARN_ON_ONCE(1);
+               goto out;
+       }
+       rmb();
+       efx_nic_update_stats(efx_ef10_stat_desc, EF10_STAT_COUNT, mask,
+                            stats, stats_buf.addr, false);
+       rmb();
+       generation_start = dma_stats[MC_CMD_MAC_GENERATION_START];
+       if (generation_end != generation_start) {
+               rc = -EAGAIN;
+               goto out;
+       }
+
+       efx_update_sw_stats(efx, stats);
+out:
+       efx_nic_free_buffer(efx, &stats_buf);
+       return rc;
+}
+
+static size_t efx_ef10_update_stats_vf(struct efx_nic *efx, u64 *full_stats,
+                                      struct rtnl_link_stats64 *core_stats)
+{
+       if (efx_ef10_try_update_nic_stats_vf(efx))
+               return 0;
+
+       return efx_ef10_update_stats_common(efx, full_stats, core_stats);
+}
+
+static void efx_ef10_push_irq_moderation(struct efx_channel *channel)
+{
+       struct efx_nic *efx = channel->efx;
+       unsigned int mode, value;
+       efx_dword_t timer_cmd;
+
+       if (channel->irq_moderation) {
+               mode = 3;
+               value = channel->irq_moderation - 1;
+       } else {
+               mode = 0;
+               value = 0;
+       }
+
+       if (EFX_EF10_WORKAROUND_35388(efx)) {
+               EFX_POPULATE_DWORD_3(timer_cmd, ERF_DD_EVQ_IND_TIMER_FLAGS,
+                                    EFE_DD_EVQ_IND_TIMER_FLAGS,
+                                    ERF_DD_EVQ_IND_TIMER_MODE, mode,
                                     ERF_DD_EVQ_IND_TIMER_VAL, value);
                efx_writed_page(efx, &timer_cmd, ER_DD_EVQ_INDIRECT,
                                channel->channel);
@@ -1044,6 +1540,14 @@ static void efx_ef10_push_irq_moderation(struct efx_channel *channel)
        }
 }
 
+static void efx_ef10_get_wol_vf(struct efx_nic *efx,
+                               struct ethtool_wolinfo *wol) {}
+
+static int efx_ef10_set_wol_vf(struct efx_nic *efx, u32 type)
+{
+       return -EOPNOTSUPP;
+}
+
 static void efx_ef10_get_wol(struct efx_nic *efx, struct ethtool_wolinfo *wol)
 {
        wol->supported = 0;
@@ -1100,6 +1604,22 @@ efx_ef10_mcdi_read_response(struct efx_nic *efx, efx_dword_t *outbuf,
        memcpy(outbuf, pdu + offset, outlen);
 }
 
+static void efx_ef10_mcdi_reboot_detected(struct efx_nic *efx)
+{
+       struct efx_ef10_nic_data *nic_data = efx->nic_data;
+
+       /* All our allocations have been reset */
+       efx_ef10_reset_mc_allocations(efx);
+
+       /* The datapath firmware might have been changed */
+       nic_data->must_check_datapath_caps = true;
+
+       /* MAC statistics have been cleared on the NIC; clear the local
+        * statistic that we update with efx_update_diff_stat().
+        */
+       nic_data->stats[EF10_STAT_port_rx_bad_bytes] = 0;
+}
+
 static int efx_ef10_mcdi_poll_reboot(struct efx_nic *efx)
 {
        struct efx_ef10_nic_data *nic_data = efx->nic_data;
@@ -1119,17 +1639,7 @@ static int efx_ef10_mcdi_poll_reboot(struct efx_nic *efx)
                return 0;
 
        nic_data->warm_boot_count = rc;
-
-       /* All our allocations have been reset */
-       efx_ef10_reset_mc_allocations(efx);
-
-       /* The datapath firmware might have been changed */
-       nic_data->must_check_datapath_caps = true;
-
-       /* MAC statistics have been cleared on the NIC; clear the local
-        * statistic that we update with efx_update_diff_stat().
-        */
-       nic_data->stats[EF10_STAT_rx_bad_bytes] = 0;
+       efx_ef10_mcdi_reboot_detected(efx);
 
        return -EIO;
 }
@@ -1232,16 +1742,17 @@ static void efx_ef10_tx_init(struct efx_tx_queue *tx_queue)
 {
        MCDI_DECLARE_BUF(inbuf, MC_CMD_INIT_TXQ_IN_LEN(EFX_MAX_DMAQ_SIZE * 8 /
                                                       EFX_BUF_SIZE));
-       MCDI_DECLARE_BUF(outbuf, MC_CMD_INIT_TXQ_OUT_LEN);
        bool csum_offload = tx_queue->queue & EFX_TXQ_TYPE_OFFLOAD;
        size_t entries = tx_queue->txd.buf.len / EFX_BUF_SIZE;
        struct efx_channel *channel = tx_queue->channel;
        struct efx_nic *efx = tx_queue->efx;
-       size_t inlen, outlen;
+       struct efx_ef10_nic_data *nic_data = efx->nic_data;
+       size_t inlen;
        dma_addr_t dma_addr;
        efx_qword_t *txd;
        int rc;
        int i;
+       BUILD_BUG_ON(MC_CMD_INIT_TXQ_OUT_LEN != 0);
 
        MCDI_SET_DWORD(inbuf, INIT_TXQ_IN_SIZE, tx_queue->ptr_mask + 1);
        MCDI_SET_DWORD(inbuf, INIT_TXQ_IN_TARGET_EVQ, channel->channel);
@@ -1251,7 +1762,7 @@ static void efx_ef10_tx_init(struct efx_tx_queue *tx_queue)
                              INIT_TXQ_IN_FLAG_IP_CSUM_DIS, !csum_offload,
                              INIT_TXQ_IN_FLAG_TCP_CSUM_DIS, !csum_offload);
        MCDI_SET_DWORD(inbuf, INIT_TXQ_IN_OWNER_ID, 0);
-       MCDI_SET_DWORD(inbuf, INIT_TXQ_IN_PORT_ID, EVB_PORT_ID_ASSIGNED);
+       MCDI_SET_DWORD(inbuf, INIT_TXQ_IN_PORT_ID, nic_data->vport_id);
 
        dma_addr = tx_queue->txd.buf.dma_addr;
 
@@ -1266,7 +1777,7 @@ static void efx_ef10_tx_init(struct efx_tx_queue *tx_queue)
        inlen = MC_CMD_INIT_TXQ_IN_LEN(entries);
 
        rc = efx_mcdi_rpc(efx, MC_CMD_INIT_TXQ, inbuf, inlen,
-                         outbuf, sizeof(outbuf), &outlen);
+                         NULL, 0, NULL);
        if (rc)
                goto fail;
 
@@ -1299,7 +1810,7 @@ fail:
 static void efx_ef10_tx_fini(struct efx_tx_queue *tx_queue)
 {
        MCDI_DECLARE_BUF(inbuf, MC_CMD_FINI_TXQ_IN_LEN);
-       MCDI_DECLARE_BUF(outbuf, MC_CMD_FINI_TXQ_OUT_LEN);
+       MCDI_DECLARE_BUF_ERR(outbuf);
        struct efx_nic *efx = tx_queue->efx;
        size_t outlen;
        int rc;
@@ -1344,7 +1855,9 @@ static void efx_ef10_tx_write(struct efx_tx_queue *tx_queue)
        unsigned int write_ptr;
        efx_qword_t *txd;
 
-       BUG_ON(tx_queue->write_count == tx_queue->insert_count);
+       tx_queue->xmit_more_available = false;
+       if (unlikely(tx_queue->write_count == tx_queue->insert_count))
+               return;
 
        do {
                write_ptr = tx_queue->write_count & tx_queue->ptr_mask;
@@ -1378,19 +1891,33 @@ static void efx_ef10_tx_write(struct efx_tx_queue *tx_queue)
        }
 }
 
-static int efx_ef10_alloc_rss_context(struct efx_nic *efx, u32 *context)
+static int efx_ef10_alloc_rss_context(struct efx_nic *efx, u32 *context,
+                                     bool exclusive, unsigned *context_size)
 {
        MCDI_DECLARE_BUF(inbuf, MC_CMD_RSS_CONTEXT_ALLOC_IN_LEN);
        MCDI_DECLARE_BUF(outbuf, MC_CMD_RSS_CONTEXT_ALLOC_OUT_LEN);
+       struct efx_ef10_nic_data *nic_data = efx->nic_data;
        size_t outlen;
        int rc;
+       u32 alloc_type = exclusive ?
+                               MC_CMD_RSS_CONTEXT_ALLOC_IN_TYPE_EXCLUSIVE :
+                               MC_CMD_RSS_CONTEXT_ALLOC_IN_TYPE_SHARED;
+       unsigned rss_spread = exclusive ?
+                               efx->rss_spread :
+                               min(rounddown_pow_of_two(efx->rss_spread),
+                                   EFX_EF10_MAX_SHARED_RSS_CONTEXT_SIZE);
+
+       if (!exclusive && rss_spread == 1) {
+               *context = EFX_EF10_RSS_CONTEXT_INVALID;
+               if (context_size)
+                       *context_size = 1;
+               return 0;
+       }
 
        MCDI_SET_DWORD(inbuf, RSS_CONTEXT_ALLOC_IN_UPSTREAM_PORT_ID,
-                      EVB_PORT_ID_ASSIGNED);
-       MCDI_SET_DWORD(inbuf, RSS_CONTEXT_ALLOC_IN_TYPE,
-                      MC_CMD_RSS_CONTEXT_ALLOC_IN_TYPE_EXCLUSIVE);
-       MCDI_SET_DWORD(inbuf, RSS_CONTEXT_ALLOC_IN_NUM_QUEUES,
-                      EFX_MAX_CHANNELS);
+                      nic_data->vport_id);
+       MCDI_SET_DWORD(inbuf, RSS_CONTEXT_ALLOC_IN_TYPE, alloc_type);
+       MCDI_SET_DWORD(inbuf, RSS_CONTEXT_ALLOC_IN_NUM_QUEUES, rss_spread);
 
        rc = efx_mcdi_rpc(efx, MC_CMD_RSS_CONTEXT_ALLOC, inbuf, sizeof(inbuf),
                outbuf, sizeof(outbuf), &outlen);
@@ -1402,6 +1929,9 @@ static int efx_ef10_alloc_rss_context(struct efx_nic *efx, u32 *context)
 
        *context = MCDI_DWORD(outbuf, RSS_CONTEXT_ALLOC_OUT_RSS_CONTEXT_ID);
 
+       if (context_size)
+               *context_size = rss_spread;
+
        return 0;
 }
 
@@ -1418,7 +1948,8 @@ static void efx_ef10_free_rss_context(struct efx_nic *efx, u32 context)
        WARN_ON(rc != 0);
 }
 
-static int efx_ef10_populate_rss_table(struct efx_nic *efx, u32 context)
+static int efx_ef10_populate_rss_table(struct efx_nic *efx, u32 context,
+                                      const u32 *rx_indir_table)
 {
        MCDI_DECLARE_BUF(tablebuf, MC_CMD_RSS_CONTEXT_SET_TABLE_IN_LEN);
        MCDI_DECLARE_BUF(keybuf, MC_CMD_RSS_CONTEXT_SET_KEY_IN_LEN);
@@ -1432,7 +1963,7 @@ static int efx_ef10_populate_rss_table(struct efx_nic *efx, u32 context)
        for (i = 0; i < ARRAY_SIZE(efx->rx_indir_table); ++i)
                MCDI_PTR(tablebuf,
                         RSS_CONTEXT_SET_TABLE_IN_INDIRECTION_TABLE)[i] =
-                               (u8) efx->rx_indir_table[i];
+                               (u8) rx_indir_table[i];
 
        rc = efx_mcdi_rpc(efx, MC_CMD_RSS_CONTEXT_SET_TABLE, tablebuf,
                          sizeof(tablebuf), NULL, 0, NULL);
@@ -1460,27 +1991,119 @@ static void efx_ef10_rx_free_indir_table(struct efx_nic *efx)
        nic_data->rx_rss_context = EFX_EF10_RSS_CONTEXT_INVALID;
 }
 
-static void efx_ef10_rx_push_rss_config(struct efx_nic *efx)
+static int efx_ef10_rx_push_shared_rss_config(struct efx_nic *efx,
+                                             unsigned *context_size)
 {
+       u32 new_rx_rss_context;
        struct efx_ef10_nic_data *nic_data = efx->nic_data;
-       int rc;
+       int rc = efx_ef10_alloc_rss_context(efx, &new_rx_rss_context,
+                                           false, context_size);
 
-       netif_dbg(efx, drv, efx->net_dev, "pushing RSS config\n");
+       if (rc != 0)
+               return rc;
 
-       if (nic_data->rx_rss_context == EFX_EF10_RSS_CONTEXT_INVALID) {
-               rc = efx_ef10_alloc_rss_context(efx, &nic_data->rx_rss_context);
-               if (rc != 0)
-                       goto fail;
+       nic_data->rx_rss_context = new_rx_rss_context;
+       nic_data->rx_rss_context_exclusive = false;
+       efx_set_default_rx_indir_table(efx);
+       return 0;
+}
+
+static int efx_ef10_rx_push_exclusive_rss_config(struct efx_nic *efx,
+                                                const u32 *rx_indir_table)
+{
+       struct efx_ef10_nic_data *nic_data = efx->nic_data;
+       int rc;
+       u32 new_rx_rss_context;
+
+       if (nic_data->rx_rss_context == EFX_EF10_RSS_CONTEXT_INVALID ||
+           !nic_data->rx_rss_context_exclusive) {
+               rc = efx_ef10_alloc_rss_context(efx, &new_rx_rss_context,
+                                               true, NULL);
+               if (rc == -EOPNOTSUPP)
+                       return rc;
+               else if (rc != 0)
+                       goto fail1;
+       } else {
+               new_rx_rss_context = nic_data->rx_rss_context;
        }
 
-       rc = efx_ef10_populate_rss_table(efx, nic_data->rx_rss_context);
+       rc = efx_ef10_populate_rss_table(efx, new_rx_rss_context,
+                                        rx_indir_table);
        if (rc != 0)
-               goto fail;
+               goto fail2;
 
-       return;
+       if (nic_data->rx_rss_context != new_rx_rss_context)
+               efx_ef10_rx_free_indir_table(efx);
+       nic_data->rx_rss_context = new_rx_rss_context;
+       nic_data->rx_rss_context_exclusive = true;
+       if (rx_indir_table != efx->rx_indir_table)
+               memcpy(efx->rx_indir_table, rx_indir_table,
+                      sizeof(efx->rx_indir_table));
+       return 0;
 
-fail:
+fail2:
+       if (new_rx_rss_context != nic_data->rx_rss_context)
+               efx_ef10_free_rss_context(efx, new_rx_rss_context);
+fail1:
        netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
+       return rc;
+}
+
+static int efx_ef10_pf_rx_push_rss_config(struct efx_nic *efx, bool user,
+                                         const u32 *rx_indir_table)
+{
+       int rc;
+
+       if (efx->rss_spread == 1)
+               return 0;
+
+       rc = efx_ef10_rx_push_exclusive_rss_config(efx, rx_indir_table);
+
+       if (rc == -ENOBUFS && !user) {
+               unsigned context_size;
+               bool mismatch = false;
+               size_t i;
+
+               for (i = 0; i < ARRAY_SIZE(efx->rx_indir_table) && !mismatch;
+                    i++)
+                       mismatch = rx_indir_table[i] !=
+                               ethtool_rxfh_indir_default(i, efx->rss_spread);
+
+               rc = efx_ef10_rx_push_shared_rss_config(efx, &context_size);
+               if (rc == 0) {
+                       if (context_size != efx->rss_spread)
+                               netif_warn(efx, probe, efx->net_dev,
+                                          "Could not allocate an exclusive RSS"
+                                          " context; allocated a shared one of"
+                                          " different size."
+                                          " Wanted %u, got %u.\n",
+                                          efx->rss_spread, context_size);
+                       else if (mismatch)
+                               netif_warn(efx, probe, efx->net_dev,
+                                          "Could not allocate an exclusive RSS"
+                                          " context; allocated a shared one but"
+                                          " could not apply custom"
+                                          " indirection.\n");
+                       else
+                               netif_info(efx, probe, efx->net_dev,
+                                          "Could not allocate an exclusive RSS"
+                                          " context; allocated a shared one.\n");
+               }
+       }
+       return rc;
+}
+
+static int efx_ef10_vf_rx_push_rss_config(struct efx_nic *efx, bool user,
+                                         const u32 *rx_indir_table
+                                         __attribute__ ((unused)))
+{
+       struct efx_ef10_nic_data *nic_data = efx->nic_data;
+
+       if (user)
+               return -EOPNOTSUPP;
+       if (nic_data->rx_rss_context != EFX_EF10_RSS_CONTEXT_INVALID)
+               return 0;
+       return efx_ef10_rx_push_shared_rss_config(efx, NULL);
 }
 
 static int efx_ef10_rx_probe(struct efx_rx_queue *rx_queue)
@@ -1496,14 +2119,15 @@ static void efx_ef10_rx_init(struct efx_rx_queue *rx_queue)
        MCDI_DECLARE_BUF(inbuf,
                         MC_CMD_INIT_RXQ_IN_LEN(EFX_MAX_DMAQ_SIZE * 8 /
                                                EFX_BUF_SIZE));
-       MCDI_DECLARE_BUF(outbuf, MC_CMD_INIT_RXQ_OUT_LEN);
        struct efx_channel *channel = efx_rx_queue_channel(rx_queue);
        size_t entries = rx_queue->rxd.buf.len / EFX_BUF_SIZE;
        struct efx_nic *efx = rx_queue->efx;
-       size_t inlen, outlen;
+       struct efx_ef10_nic_data *nic_data = efx->nic_data;
+       size_t inlen;
        dma_addr_t dma_addr;
        int rc;
        int i;
+       BUILD_BUG_ON(MC_CMD_INIT_RXQ_OUT_LEN != 0);
 
        rx_queue->scatter_n = 0;
        rx_queue->scatter_len = 0;
@@ -1517,7 +2141,7 @@ static void efx_ef10_rx_init(struct efx_rx_queue *rx_queue)
                              INIT_RXQ_IN_FLAG_PREFIX, 1,
                              INIT_RXQ_IN_FLAG_TIMESTAMP, 1);
        MCDI_SET_DWORD(inbuf, INIT_RXQ_IN_OWNER_ID, 0);
-       MCDI_SET_DWORD(inbuf, INIT_RXQ_IN_PORT_ID, EVB_PORT_ID_ASSIGNED);
+       MCDI_SET_DWORD(inbuf, INIT_RXQ_IN_PORT_ID, nic_data->vport_id);
 
        dma_addr = rx_queue->rxd.buf.dma_addr;
 
@@ -1532,7 +2156,7 @@ static void efx_ef10_rx_init(struct efx_rx_queue *rx_queue)
        inlen = MC_CMD_INIT_RXQ_IN_LEN(entries);
 
        rc = efx_mcdi_rpc(efx, MC_CMD_INIT_RXQ, inbuf, inlen,
-                         outbuf, sizeof(outbuf), &outlen);
+                         NULL, 0, NULL);
        if (rc)
                netdev_WARN(efx->net_dev, "failed to initialise RXQ %d\n",
                            efx_rx_queue_index(rx_queue));
@@ -1541,7 +2165,7 @@ static void efx_ef10_rx_init(struct efx_rx_queue *rx_queue)
 static void efx_ef10_rx_fini(struct efx_rx_queue *rx_queue)
 {
        MCDI_DECLARE_BUF(inbuf, MC_CMD_FINI_RXQ_IN_LEN);
-       MCDI_DECLARE_BUF(outbuf, MC_CMD_FINI_RXQ_OUT_LEN);
+       MCDI_DECLARE_BUF_ERR(outbuf);
        struct efx_nic *efx = rx_queue->efx;
        size_t outlen;
        int rc;
@@ -1646,6 +2270,29 @@ static int efx_ef10_ev_probe(struct efx_channel *channel)
                                    GFP_KERNEL);
 }
 
+static void efx_ef10_ev_fini(struct efx_channel *channel)
+{
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_FINI_EVQ_IN_LEN);
+       MCDI_DECLARE_BUF_ERR(outbuf);
+       struct efx_nic *efx = channel->efx;
+       size_t outlen;
+       int rc;
+
+       MCDI_SET_DWORD(inbuf, FINI_EVQ_IN_INSTANCE, channel->channel);
+
+       rc = efx_mcdi_rpc_quiet(efx, MC_CMD_FINI_EVQ, inbuf, sizeof(inbuf),
+                         outbuf, sizeof(outbuf), &outlen);
+
+       if (rc && rc != -EALREADY)
+               goto fail;
+
+       return;
+
+fail:
+       efx_mcdi_display_error(efx, MC_CMD_FINI_EVQ, MC_CMD_FINI_EVQ_IN_LEN,
+                              outbuf, outlen, rc);
+}
+
 static int efx_ef10_ev_init(struct efx_channel *channel)
 {
        MCDI_DECLARE_BUF(inbuf,
@@ -1657,6 +2304,7 @@ static int efx_ef10_ev_init(struct efx_channel *channel)
        struct efx_ef10_nic_data *nic_data;
        bool supports_rx_merge;
        size_t inlen, outlen;
+       unsigned int enabled, implemented;
        dma_addr_t dma_addr;
        int rc;
        int i;
@@ -1697,30 +2345,52 @@ static int efx_ef10_ev_init(struct efx_channel *channel)
        rc = efx_mcdi_rpc(efx, MC_CMD_INIT_EVQ, inbuf, inlen,
                          outbuf, sizeof(outbuf), &outlen);
        /* IRQ return is ignored */
-       return rc;
-}
-
-static void efx_ef10_ev_fini(struct efx_channel *channel)
-{
-       MCDI_DECLARE_BUF(inbuf, MC_CMD_FINI_EVQ_IN_LEN);
-       MCDI_DECLARE_BUF(outbuf, MC_CMD_FINI_EVQ_OUT_LEN);
-       struct efx_nic *efx = channel->efx;
-       size_t outlen;
-       int rc;
-
-       MCDI_SET_DWORD(inbuf, FINI_EVQ_IN_INSTANCE, channel->channel);
-
-       rc = efx_mcdi_rpc_quiet(efx, MC_CMD_FINI_EVQ, inbuf, sizeof(inbuf),
-                         outbuf, sizeof(outbuf), &outlen);
+       if (channel->channel || rc)
+               return rc;
 
-       if (rc && rc != -EALREADY)
+       /* Successfully created event queue on channel 0 */
+       rc = efx_mcdi_get_workarounds(efx, &implemented, &enabled);
+       if (rc == -ENOSYS) {
+               /* GET_WORKAROUNDS was implemented before the bug26807
+                * workaround, thus the latter must be unavailable in this fw
+                */
+               nic_data->workaround_26807 = false;
+               rc = 0;
+       } else if (rc) {
                goto fail;
+       } else {
+               nic_data->workaround_26807 =
+                       !!(enabled & MC_CMD_GET_WORKAROUNDS_OUT_BUG26807);
+
+               if (implemented & MC_CMD_GET_WORKAROUNDS_OUT_BUG26807 &&
+                   !nic_data->workaround_26807) {
+                       unsigned int flags;
+
+                       rc = efx_mcdi_set_workaround(efx,
+                                                    MC_CMD_WORKAROUND_BUG26807,
+                                                    true, &flags);
+
+                       if (!rc) {
+                               if (flags &
+                                   1 << MC_CMD_WORKAROUND_EXT_OUT_FLR_DONE_LBN) {
+                                       netif_info(efx, drv, efx->net_dev,
+                                                  "other functions on NIC have been reset\n");
+                                       /* MC's boot count has incremented */
+                                       ++nic_data->warm_boot_count;
+                               }
+                               nic_data->workaround_26807 = true;
+                       } else if (rc == -EPERM) {
+                               rc = 0;
+                       }
+               }
+       }
 
-       return;
+       if (!rc)
+               return 0;
 
 fail:
-       efx_mcdi_display_error(efx, MC_CMD_FINI_EVQ, MC_CMD_FINI_EVQ_IN_LEN,
-                              outbuf, outlen, rc);
+       efx_ef10_ev_fini(channel);
+       return rc;
 }
 
 static void efx_ef10_ev_remove(struct efx_channel *channel)
@@ -2286,11 +2956,12 @@ static void efx_ef10_filter_push_prep(struct efx_nic *efx,
                               match_fields);
        }
 
-       MCDI_SET_DWORD(inbuf, FILTER_OP_IN_PORT_ID, EVB_PORT_ID_ASSIGNED);
+       MCDI_SET_DWORD(inbuf, FILTER_OP_IN_PORT_ID, nic_data->vport_id);
        MCDI_SET_DWORD(inbuf, FILTER_OP_IN_RX_DEST,
                       spec->dmaq_id == EFX_FILTER_RX_DMAQ_ID_DROP ?
                       MC_CMD_FILTER_OP_IN_RX_DEST_DROP :
                       MC_CMD_FILTER_OP_IN_RX_DEST_HOST);
+       MCDI_SET_DWORD(inbuf, FILTER_OP_IN_TX_DOMAIN, 0);
        MCDI_SET_DWORD(inbuf, FILTER_OP_IN_TX_DEST,
                       MC_CMD_FILTER_OP_IN_TX_DEST_DEFAULT);
        MCDI_SET_DWORD(inbuf, FILTER_OP_IN_RX_QUEUE,
@@ -2628,7 +3299,8 @@ static int efx_ef10_filter_remove_internal(struct efx_nic *efx,
 
                new_spec.priority = EFX_FILTER_PRI_AUTO;
                new_spec.flags = (EFX_FILTER_FLAG_RX |
-                                 EFX_FILTER_FLAG_RX_RSS);
+                                 (efx_rss_enabled(efx) ?
+                                  EFX_FILTER_FLAG_RX_RSS : 0));
                new_spec.dmaq_id = 0;
                new_spec.rss_context = EFX_FILTER_RSS_CONTEXT_DEFAULT;
                rc = efx_ef10_filter_push(efx, &new_spec,
@@ -2673,6 +3345,19 @@ static int efx_ef10_filter_remove_safe(struct efx_nic *efx,
                                               filter_id, false);
 }
 
+static u32 efx_ef10_filter_get_unsafe_id(struct efx_nic *efx, u32 filter_id)
+{
+       return filter_id % HUNT_FILTER_TBL_ROWS;
+}
+
+static int efx_ef10_filter_remove_unsafe(struct efx_nic *efx,
+                                        enum efx_filter_priority priority,
+                                        u32 filter_id)
+{
+       return efx_ef10_filter_remove_internal(efx, 1U << priority,
+                                              filter_id, true);
+}
+
 static int efx_ef10_filter_get_safe(struct efx_nic *efx,
                                    enum efx_filter_priority priority,
                                    u32 filter_id, struct efx_filter_spec *spec)
@@ -3046,6 +3731,10 @@ static int efx_ef10_filter_table_probe(struct efx_nic *efx)
                goto fail;
        }
 
+       table->ucdef_id = EFX_EF10_FILTER_ID_INVALID;
+       table->bcast_id = EFX_EF10_FILTER_ID_INVALID;
+       table->mcdef_id = EFX_EF10_FILTER_ID_INVALID;
+
        efx->filter_state = table;
        init_waitqueue_head(&table->waitq);
        return 0;
@@ -3055,6 +3744,9 @@ fail:
        return rc;
 }
 
+/* Caller must hold efx->filter_sem for read if race against
+ * efx_ef10_filter_table_remove() is possible
+ */
 static void efx_ef10_filter_table_restore(struct efx_nic *efx)
 {
        struct efx_ef10_filter_table *table = efx->filter_state;
@@ -3064,9 +3756,14 @@ static void efx_ef10_filter_table_restore(struct efx_nic *efx)
        bool failed = false;
        int rc;
 
+       WARN_ON(!rwsem_is_locked(&efx->filter_sem));
+
        if (!nic_data->must_restore_filters)
                return;
 
+       if (!table)
+               return;
+
        spin_lock_bh(&efx->filter_lock);
 
        for (filter_idx = 0; filter_idx < HUNT_FILTER_TBL_ROWS; filter_idx++) {
@@ -3102,6 +3799,7 @@ static void efx_ef10_filter_table_restore(struct efx_nic *efx)
                nic_data->must_restore_filters = false;
 }
 
+/* Caller must hold efx->filter_sem for write */
 static void efx_ef10_filter_table_remove(struct efx_nic *efx)
 {
        struct efx_ef10_filter_table *table = efx->filter_state;
@@ -3110,6 +3808,10 @@ static void efx_ef10_filter_table_remove(struct efx_nic *efx)
        unsigned int filter_idx;
        int rc;
 
+       efx->filter_state = NULL;
+       if (!table)
+               return;
+
        for (filter_idx = 0; filter_idx < HUNT_FILTER_TBL_ROWS; filter_idx++) {
                spec = efx_ef10_filter_entry_spec(table, filter_idx);
                if (!spec)
@@ -3135,139 +3837,232 @@ static void efx_ef10_filter_table_remove(struct efx_nic *efx)
        kfree(table);
 }
 
-static void efx_ef10_filter_sync_rx_mode(struct efx_nic *efx)
+#define EFX_EF10_FILTER_DO_MARK_OLD(id) \
+               if (id != EFX_EF10_FILTER_ID_INVALID) { \
+                       filter_idx = efx_ef10_filter_get_unsafe_id(efx, id); \
+                       WARN_ON(!table->entry[filter_idx].spec); \
+                       table->entry[filter_idx].spec |= EFX_EF10_FILTER_FLAG_AUTO_OLD; \
+               }
+static void efx_ef10_filter_mark_old(struct efx_nic *efx)
 {
        struct efx_ef10_filter_table *table = efx->filter_state;
-       struct net_device *net_dev = efx->net_dev;
-       struct efx_filter_spec spec;
-       bool remove_failed = false;
-       struct netdev_hw_addr *uc;
-       struct netdev_hw_addr *mc;
-       unsigned int filter_idx;
-       int i, n, rc;
+       unsigned int filter_idx, i;
 
-       if (!efx_dev_registered(efx))
+       if (!table)
                return;
 
        /* Mark old filters that may need to be removed */
        spin_lock_bh(&efx->filter_lock);
-       n = table->dev_uc_count < 0 ? 1 : table->dev_uc_count;
-       for (i = 0; i < n; i++) {
-               filter_idx = table->dev_uc_list[i].id % HUNT_FILTER_TBL_ROWS;
-               table->entry[filter_idx].spec |= EFX_EF10_FILTER_FLAG_AUTO_OLD;
-       }
-       n = table->dev_mc_count < 0 ? 1 : table->dev_mc_count;
-       for (i = 0; i < n; i++) {
-               filter_idx = table->dev_mc_list[i].id % HUNT_FILTER_TBL_ROWS;
-               table->entry[filter_idx].spec |= EFX_EF10_FILTER_FLAG_AUTO_OLD;
-       }
+       for (i = 0; i < table->dev_uc_count; i++)
+               EFX_EF10_FILTER_DO_MARK_OLD(table->dev_uc_list[i].id);
+       for (i = 0; i < table->dev_mc_count; i++)
+               EFX_EF10_FILTER_DO_MARK_OLD(table->dev_mc_list[i].id);
+       EFX_EF10_FILTER_DO_MARK_OLD(table->ucdef_id);
+       EFX_EF10_FILTER_DO_MARK_OLD(table->bcast_id);
+       EFX_EF10_FILTER_DO_MARK_OLD(table->mcdef_id);
        spin_unlock_bh(&efx->filter_lock);
+}
+#undef EFX_EF10_FILTER_DO_MARK_OLD
 
-       /* Copy/convert the address lists; add the primary station
-        * address and broadcast address
-        */
-       netif_addr_lock_bh(net_dev);
-       if (net_dev->flags & IFF_PROMISC ||
-           netdev_uc_count(net_dev) >= EFX_EF10_FILTER_DEV_UC_MAX) {
-               table->dev_uc_count = -1;
-       } else {
-               table->dev_uc_count = 1 + netdev_uc_count(net_dev);
-               ether_addr_copy(table->dev_uc_list[0].addr, net_dev->dev_addr);
-               i = 1;
-               netdev_for_each_uc_addr(uc, net_dev) {
-                       ether_addr_copy(table->dev_uc_list[i].addr, uc->addr);
-                       i++;
+static void efx_ef10_filter_uc_addr_list(struct efx_nic *efx, bool *promisc)
+{
+       struct efx_ef10_filter_table *table = efx->filter_state;
+       struct net_device *net_dev = efx->net_dev;
+       struct netdev_hw_addr *uc;
+       int addr_count;
+       unsigned int i;
+
+       table->ucdef_id = EFX_EF10_FILTER_ID_INVALID;
+       addr_count = netdev_uc_count(net_dev);
+       if (net_dev->flags & IFF_PROMISC)
+               *promisc = true;
+       table->dev_uc_count = 1 + addr_count;
+       ether_addr_copy(table->dev_uc_list[0].addr, net_dev->dev_addr);
+       i = 1;
+       netdev_for_each_uc_addr(uc, net_dev) {
+               if (i >= EFX_EF10_FILTER_DEV_UC_MAX) {
+                       *promisc = true;
+                       break;
                }
+               ether_addr_copy(table->dev_uc_list[i].addr, uc->addr);
+               table->dev_uc_list[i].id = EFX_EF10_FILTER_ID_INVALID;
+               i++;
        }
-       if (net_dev->flags & (IFF_PROMISC | IFF_ALLMULTI) ||
-           netdev_mc_count(net_dev) >= EFX_EF10_FILTER_DEV_MC_MAX) {
-               table->dev_mc_count = -1;
-       } else {
-               table->dev_mc_count = 1 + netdev_mc_count(net_dev);
-               eth_broadcast_addr(table->dev_mc_list[0].addr);
-               i = 1;
-               netdev_for_each_mc_addr(mc, net_dev) {
-                       ether_addr_copy(table->dev_mc_list[i].addr, mc->addr);
-                       i++;
+}
+
+static void efx_ef10_filter_mc_addr_list(struct efx_nic *efx, bool *promisc)
+{
+       struct efx_ef10_filter_table *table = efx->filter_state;
+       struct net_device *net_dev = efx->net_dev;
+       struct netdev_hw_addr *mc;
+       unsigned int i, addr_count;
+
+       table->mcdef_id = EFX_EF10_FILTER_ID_INVALID;
+       table->bcast_id = EFX_EF10_FILTER_ID_INVALID;
+       if (net_dev->flags & (IFF_PROMISC | IFF_ALLMULTI))
+               *promisc = true;
+
+       addr_count = netdev_mc_count(net_dev);
+       i = 0;
+       netdev_for_each_mc_addr(mc, net_dev) {
+               if (i >= EFX_EF10_FILTER_DEV_MC_MAX) {
+                       *promisc = true;
+                       break;
                }
+               ether_addr_copy(table->dev_mc_list[i].addr, mc->addr);
+               table->dev_mc_list[i].id = EFX_EF10_FILTER_ID_INVALID;
+               i++;
        }
-       netif_addr_unlock_bh(net_dev);
 
-       /* Insert/renew unicast filters */
-       if (table->dev_uc_count >= 0) {
-               for (i = 0; i < table->dev_uc_count; i++) {
-                       efx_filter_init_rx(&spec, EFX_FILTER_PRI_AUTO,
-                                          EFX_FILTER_FLAG_RX_RSS,
-                                          0);
-                       efx_filter_set_eth_local(&spec, EFX_FILTER_VID_UNSPEC,
-                                                table->dev_uc_list[i].addr);
-                       rc = efx_ef10_filter_insert(efx, &spec, true);
-                       if (rc < 0) {
-                               /* Fall back to unicast-promisc */
-                               while (i--)
-                                       efx_ef10_filter_remove_safe(
+       table->dev_mc_count = i;
+}
+
+static int efx_ef10_filter_insert_addr_list(struct efx_nic *efx,
+                                            bool multicast, bool rollback)
+{
+       struct efx_ef10_filter_table *table = efx->filter_state;
+       struct efx_ef10_dev_addr *addr_list;
+       enum efx_filter_flags filter_flags;
+       struct efx_filter_spec spec;
+       u8 baddr[ETH_ALEN];
+       unsigned int i, j;
+       int addr_count;
+       int rc;
+
+       if (multicast) {
+               addr_list = table->dev_mc_list;
+               addr_count = table->dev_mc_count;
+       } else {
+               addr_list = table->dev_uc_list;
+               addr_count = table->dev_uc_count;
+       }
+
+       filter_flags = efx_rss_enabled(efx) ? EFX_FILTER_FLAG_RX_RSS : 0;
+
+       /* Insert/renew filters */
+       for (i = 0; i < addr_count; i++) {
+               efx_filter_init_rx(&spec, EFX_FILTER_PRI_AUTO, filter_flags, 0);
+               efx_filter_set_eth_local(&spec, EFX_FILTER_VID_UNSPEC,
+                                        addr_list[i].addr);
+               rc = efx_ef10_filter_insert(efx, &spec, true);
+               if (rc < 0) {
+                       if (rollback) {
+                               netif_info(efx, drv, efx->net_dev,
+                                          "efx_ef10_filter_insert failed rc=%d\n",
+                                          rc);
+                               /* Fall back to promiscuous */
+                               for (j = 0; j < i; j++) {
+                                       if (addr_list[j].id == EFX_EF10_FILTER_ID_INVALID)
+                                               continue;
+                                       efx_ef10_filter_remove_unsafe(
                                                efx, EFX_FILTER_PRI_AUTO,
-                                               table->dev_uc_list[i].id);
-                               table->dev_uc_count = -1;
-                               break;
+                                               addr_list[j].id);
+                                       addr_list[j].id = EFX_EF10_FILTER_ID_INVALID;
+                               }
+                               return rc;
+                       } else {
+                               /* mark as not inserted, and carry on */
+                               rc = EFX_EF10_FILTER_ID_INVALID;
                        }
-                       table->dev_uc_list[i].id = rc;
                }
+               addr_list[i].id = efx_ef10_filter_get_unsafe_id(efx, rc);
        }
-       if (table->dev_uc_count < 0) {
-               efx_filter_init_rx(&spec, EFX_FILTER_PRI_AUTO,
-                                  EFX_FILTER_FLAG_RX_RSS,
-                                  0);
-               efx_filter_set_uc_def(&spec);
+
+       if (multicast && rollback) {
+               /* Also need an Ethernet broadcast filter */
+               efx_filter_init_rx(&spec, EFX_FILTER_PRI_AUTO, filter_flags, 0);
+               eth_broadcast_addr(baddr);
+               efx_filter_set_eth_local(&spec, EFX_FILTER_VID_UNSPEC, baddr);
                rc = efx_ef10_filter_insert(efx, &spec, true);
                if (rc < 0) {
-                       WARN_ON(1);
-                       table->dev_uc_count = 0;
+                       netif_warn(efx, drv, efx->net_dev,
+                                  "Broadcast filter insert failed rc=%d\n", rc);
+                       /* Fall back to promiscuous */
+                       for (j = 0; j < i; j++) {
+                               if (addr_list[j].id == EFX_EF10_FILTER_ID_INVALID)
+                                       continue;
+                               efx_ef10_filter_remove_unsafe(
+                                       efx, EFX_FILTER_PRI_AUTO,
+                                       addr_list[j].id);
+                               addr_list[j].id = EFX_EF10_FILTER_ID_INVALID;
+                       }
+                       return rc;
                } else {
-                       table->dev_uc_list[0].id = rc;
+                       table->bcast_id = efx_ef10_filter_get_unsafe_id(efx, rc);
                }
        }
 
-       /* Insert/renew multicast filters */
-       if (table->dev_mc_count >= 0) {
-               for (i = 0; i < table->dev_mc_count; i++) {
+       return 0;
+}
+
+static int efx_ef10_filter_insert_def(struct efx_nic *efx, bool multicast,
+                                     bool rollback)
+{
+       struct efx_ef10_filter_table *table = efx->filter_state;
+       struct efx_ef10_nic_data *nic_data = efx->nic_data;
+       enum efx_filter_flags filter_flags;
+       struct efx_filter_spec spec;
+       u8 baddr[ETH_ALEN];
+       int rc;
+
+       filter_flags = efx_rss_enabled(efx) ? EFX_FILTER_FLAG_RX_RSS : 0;
+
+       efx_filter_init_rx(&spec, EFX_FILTER_PRI_AUTO, filter_flags, 0);
+
+       if (multicast)
+               efx_filter_set_mc_def(&spec);
+       else
+               efx_filter_set_uc_def(&spec);
+
+       rc = efx_ef10_filter_insert(efx, &spec, true);
+       if (rc < 0) {
+               netif_warn(efx, drv, efx->net_dev,
+                          "%scast mismatch filter insert failed rc=%d\n",
+                          multicast ? "Multi" : "Uni", rc);
+       } else if (multicast) {
+               table->mcdef_id = efx_ef10_filter_get_unsafe_id(efx, rc);
+               if (!nic_data->workaround_26807) {
+                       /* Also need an Ethernet broadcast filter */
                        efx_filter_init_rx(&spec, EFX_FILTER_PRI_AUTO,
-                                          EFX_FILTER_FLAG_RX_RSS,
-                                          0);
+                                          filter_flags, 0);
+                       eth_broadcast_addr(baddr);
                        efx_filter_set_eth_local(&spec, EFX_FILTER_VID_UNSPEC,
-                                                table->dev_mc_list[i].addr);
+                                                baddr);
                        rc = efx_ef10_filter_insert(efx, &spec, true);
                        if (rc < 0) {
-                               /* Fall back to multicast-promisc */
-                               while (i--)
-                                       efx_ef10_filter_remove_safe(
-                                               efx, EFX_FILTER_PRI_AUTO,
-                                               table->dev_mc_list[i].id);
-                               table->dev_mc_count = -1;
-                               break;
+                               netif_warn(efx, drv, efx->net_dev,
+                                          "Broadcast filter insert failed rc=%d\n",
+                                          rc);
+                               if (rollback) {
+                                       /* Roll back the mc_def filter */
+                                       efx_ef10_filter_remove_unsafe(
+                                                       efx, EFX_FILTER_PRI_AUTO,
+                                                       table->mcdef_id);
+                                       table->mcdef_id = EFX_EF10_FILTER_ID_INVALID;
+                                       return rc;
+                               }
+                       } else {
+                               table->bcast_id = efx_ef10_filter_get_unsafe_id(efx, rc);
                        }
-                       table->dev_mc_list[i].id = rc;
-               }
-       }
-       if (table->dev_mc_count < 0) {
-               efx_filter_init_rx(&spec, EFX_FILTER_PRI_AUTO,
-                                  EFX_FILTER_FLAG_RX_RSS,
-                                  0);
-               efx_filter_set_mc_def(&spec);
-               rc = efx_ef10_filter_insert(efx, &spec, true);
-               if (rc < 0) {
-                       WARN_ON(1);
-                       table->dev_mc_count = 0;
-               } else {
-                       table->dev_mc_list[0].id = rc;
                }
+               rc = 0;
+       } else {
+               table->ucdef_id = rc;
+               rc = 0;
        }
+       return rc;
+}
+
+/* Remove filters that weren't renewed.  Since nothing else changes the AUTO_OLD
+ * flag or removes these filters, we don't need to hold the filter_lock while
+ * scanning for these filters.
+ */
+static void efx_ef10_filter_remove_old(struct efx_nic *efx)
+{
+       struct efx_ef10_filter_table *table = efx->filter_state;
+       bool remove_failed = false;
+       int i;
 
-       /* Remove filters that weren't renewed.  Since nothing else
-        * changes the AUTO_OLD flag or removes these filters, we
-        * don't need to hold the filter_lock while scanning for
-        * these filters.
-        */
        for (i = 0; i < HUNT_FILTER_TBL_ROWS; i++) {
                if (ACCESS_ONCE(table->entry[i].spec) &
                    EFX_EF10_FILTER_FLAG_AUTO_OLD) {
@@ -3280,6 +4075,230 @@ static void efx_ef10_filter_sync_rx_mode(struct efx_nic *efx)
        WARN_ON(remove_failed);
 }
 
+static int efx_ef10_vport_set_mac_address(struct efx_nic *efx)
+{
+       struct efx_ef10_nic_data *nic_data = efx->nic_data;
+       u8 mac_old[ETH_ALEN];
+       int rc, rc2;
+
+       /* Only reconfigure a PF-created vport */
+       if (is_zero_ether_addr(nic_data->vport_mac))
+               return 0;
+
+       efx_device_detach_sync(efx);
+       efx_net_stop(efx->net_dev);
+       down_write(&efx->filter_sem);
+       efx_ef10_filter_table_remove(efx);
+       up_write(&efx->filter_sem);
+
+       rc = efx_ef10_vadaptor_free(efx, nic_data->vport_id);
+       if (rc)
+               goto restore_filters;
+
+       ether_addr_copy(mac_old, nic_data->vport_mac);
+       rc = efx_ef10_vport_del_mac(efx, nic_data->vport_id,
+                                   nic_data->vport_mac);
+       if (rc)
+               goto restore_vadaptor;
+
+       rc = efx_ef10_vport_add_mac(efx, nic_data->vport_id,
+                                   efx->net_dev->dev_addr);
+       if (!rc) {
+               ether_addr_copy(nic_data->vport_mac, efx->net_dev->dev_addr);
+       } else {
+               rc2 = efx_ef10_vport_add_mac(efx, nic_data->vport_id, mac_old);
+               if (rc2) {
+                       /* Failed to add original MAC, so clear vport_mac */
+                       eth_zero_addr(nic_data->vport_mac);
+                       goto reset_nic;
+               }
+       }
+
+restore_vadaptor:
+       rc2 = efx_ef10_vadaptor_alloc(efx, nic_data->vport_id);
+       if (rc2)
+               goto reset_nic;
+restore_filters:
+       down_write(&efx->filter_sem);
+       rc2 = efx_ef10_filter_table_probe(efx);
+       up_write(&efx->filter_sem);
+       if (rc2)
+               goto reset_nic;
+
+       rc2 = efx_net_open(efx->net_dev);
+       if (rc2)
+               goto reset_nic;
+
+       netif_device_attach(efx->net_dev);
+
+       return rc;
+
+reset_nic:
+       netif_err(efx, drv, efx->net_dev,
+                 "Failed to restore when changing MAC address - scheduling reset\n");
+       efx_schedule_reset(efx, RESET_TYPE_DATAPATH);
+
+       return rc ? rc : rc2;
+}
+
+/* Caller must hold efx->filter_sem for read if race against
+ * efx_ef10_filter_table_remove() is possible
+ */
+static void efx_ef10_filter_sync_rx_mode(struct efx_nic *efx)
+{
+       struct efx_ef10_filter_table *table = efx->filter_state;
+       struct efx_ef10_nic_data *nic_data = efx->nic_data;
+       struct net_device *net_dev = efx->net_dev;
+       bool uc_promisc = false, mc_promisc = false;
+
+       if (!efx_dev_registered(efx))
+               return;
+
+       if (!table)
+               return;
+
+       efx_ef10_filter_mark_old(efx);
+
+       /* Copy/convert the address lists; add the primary station
+        * address and broadcast address
+        */
+       netif_addr_lock_bh(net_dev);
+       efx_ef10_filter_uc_addr_list(efx, &uc_promisc);
+       efx_ef10_filter_mc_addr_list(efx, &mc_promisc);
+       netif_addr_unlock_bh(net_dev);
+
+       /* Insert/renew unicast filters */
+       if (uc_promisc) {
+               efx_ef10_filter_insert_def(efx, false, false);
+               efx_ef10_filter_insert_addr_list(efx, false, false);
+       } else {
+               /* If any of the filters failed to insert, fall back to
+                * promiscuous mode - add in the uc_def filter.  But keep
+                * our individual unicast filters.
+                */
+               if (efx_ef10_filter_insert_addr_list(efx, false, false))
+                       efx_ef10_filter_insert_def(efx, false, false);
+       }
+
+       /* Insert/renew multicast filters */
+       /* If changing promiscuous state with cascaded multicast filters, remove
+        * old filters first, so that packets are dropped rather than duplicated
+        */
+       if (nic_data->workaround_26807 && efx->mc_promisc != mc_promisc)
+               efx_ef10_filter_remove_old(efx);
+       if (mc_promisc) {
+               if (nic_data->workaround_26807) {
+                       /* If we failed to insert promiscuous filters, rollback
+                        * and fall back to individual multicast filters
+                        */
+                       if (efx_ef10_filter_insert_def(efx, true, true)) {
+                               /* Changing promisc state, so remove old filters */
+                               efx_ef10_filter_remove_old(efx);
+                               efx_ef10_filter_insert_addr_list(efx, true, false);
+                       }
+               } else {
+                       /* If we failed to insert promiscuous filters, don't
+                        * rollback.  Regardless, also insert the mc_list
+                        */
+                       efx_ef10_filter_insert_def(efx, true, false);
+                       efx_ef10_filter_insert_addr_list(efx, true, false);
+               }
+       } else {
+               /* If any filters failed to insert, rollback and fall back to
+                * promiscuous mode - mc_def filter and maybe broadcast.  If
+                * that fails, roll back again and insert as many of our
+                * individual multicast filters as we can.
+                */
+               if (efx_ef10_filter_insert_addr_list(efx, true, true)) {
+                       /* Changing promisc state, so remove old filters */
+                       if (nic_data->workaround_26807)
+                               efx_ef10_filter_remove_old(efx);
+                       if (efx_ef10_filter_insert_def(efx, true, true))
+                               efx_ef10_filter_insert_addr_list(efx, true, false);
+               }
+       }
+
+       efx_ef10_filter_remove_old(efx);
+       efx->mc_promisc = mc_promisc;
+}
+
+static int efx_ef10_set_mac_address(struct efx_nic *efx)
+{
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_VADAPTOR_SET_MAC_IN_LEN);
+       struct efx_ef10_nic_data *nic_data = efx->nic_data;
+       bool was_enabled = efx->port_enabled;
+       int rc;
+
+       efx_device_detach_sync(efx);
+       efx_net_stop(efx->net_dev);
+       down_write(&efx->filter_sem);
+       efx_ef10_filter_table_remove(efx);
+
+       ether_addr_copy(MCDI_PTR(inbuf, VADAPTOR_SET_MAC_IN_MACADDR),
+                       efx->net_dev->dev_addr);
+       MCDI_SET_DWORD(inbuf, VADAPTOR_SET_MAC_IN_UPSTREAM_PORT_ID,
+                      nic_data->vport_id);
+       rc = efx_mcdi_rpc_quiet(efx, MC_CMD_VADAPTOR_SET_MAC, inbuf,
+                               sizeof(inbuf), NULL, 0, NULL);
+
+       efx_ef10_filter_table_probe(efx);
+       up_write(&efx->filter_sem);
+       if (was_enabled)
+               efx_net_open(efx->net_dev);
+       netif_device_attach(efx->net_dev);
+
+#ifdef CONFIG_SFC_SRIOV
+       if (efx->pci_dev->is_virtfn && efx->pci_dev->physfn) {
+               struct pci_dev *pci_dev_pf = efx->pci_dev->physfn;
+
+               if (rc == -EPERM) {
+                       struct efx_nic *efx_pf;
+
+                       /* Switch to PF and change MAC address on vport */
+                       efx_pf = pci_get_drvdata(pci_dev_pf);
+
+                       rc = efx_ef10_sriov_set_vf_mac(efx_pf,
+                                                      nic_data->vf_index,
+                                                      efx->net_dev->dev_addr);
+               } else if (!rc) {
+                       struct efx_nic *efx_pf = pci_get_drvdata(pci_dev_pf);
+                       struct efx_ef10_nic_data *nic_data = efx_pf->nic_data;
+                       unsigned int i;
+
+                       /* MAC address successfully changed by VF (with MAC
+                        * spoofing) so update the parent PF if possible.
+                        */
+                       for (i = 0; i < efx_pf->vf_count; ++i) {
+                               struct ef10_vf *vf = nic_data->vf + i;
+
+                               if (vf->efx == efx) {
+                                       ether_addr_copy(vf->mac,
+                                                       efx->net_dev->dev_addr);
+                                       return 0;
+                               }
+                       }
+               }
+       } else
+#endif
+       if (rc == -EPERM) {
+               netif_err(efx, drv, efx->net_dev,
+                         "Cannot change MAC address; use sfboot to enable"
+                         " mac-spoofing on this interface\n");
+       } else if (rc == -ENOSYS && !efx_ef10_is_vf(efx)) {
+               /* If the active MCFW does not support MC_CMD_VADAPTOR_SET_MAC
+                * fall-back to the method of changing the MAC address on the
+                * vport.  This only applies to PFs because such versions of
+                * MCFW do not support VFs.
+                */
+               rc = efx_ef10_vport_set_mac_address(efx);
+       } else {
+               efx_mcdi_display_error(efx, MC_CMD_VADAPTOR_SET_MAC,
+                                      sizeof(inbuf), NULL, 0, rc);
+       }
+
+       return rc;
+}
+
 static int efx_ef10_mac_reconfigure(struct efx_nic *efx)
 {
        efx_ef10_filter_sync_rx_mode(efx);
@@ -3287,6 +4306,13 @@ static int efx_ef10_mac_reconfigure(struct efx_nic *efx)
        return efx_mcdi_set_mac(efx);
 }
 
+static int efx_ef10_mac_reconfigure_vf(struct efx_nic *efx)
+{
+       efx_ef10_filter_sync_rx_mode(efx);
+
+       return 0;
+}
+
 static int efx_ef10_start_bist(struct efx_nic *efx, u32 bist_type)
 {
        MCDI_DECLARE_BUF(inbuf, MC_CMD_START_BIST_IN_LEN);
@@ -3364,6 +4390,8 @@ efx_ef10_test_chip(struct efx_nic *efx, struct efx_self_tests *tests)
        rc = efx_mcdi_reset(efx, RESET_TYPE_WORLD);
 
 out:
+       if (rc == -EPERM)
+               rc = 0;
        rc2 = efx_reset_up(efx, RESET_TYPE_WORLD, rc == 0);
        return rc ? rc : rc2;
 }
@@ -3494,6 +4522,9 @@ static void efx_ef10_ptp_write_host_time(struct efx_nic *efx, u32 host_time)
        _efx_writed(efx, cpu_to_le32(host_time), ER_DZ_MC_DB_LWRD);
 }
 
+static void efx_ef10_ptp_write_host_time_vf(struct efx_nic *efx,
+                                           u32 host_time) {}
+
 static int efx_ef10_rx_enable_timestamping(struct efx_channel *channel,
                                           bool temp)
 {
@@ -3571,6 +4602,12 @@ static int efx_ef10_ptp_set_ts_sync_events(struct efx_nic *efx, bool en,
        return 0;
 }
 
+static int efx_ef10_ptp_set_ts_config_vf(struct efx_nic *efx,
+                                        struct hwtstamp_config *init)
+{
+       return -EOPNOTSUPP;
+}
+
 static int efx_ef10_ptp_set_ts_config(struct efx_nic *efx,
                                      struct hwtstamp_config *init)
 {
@@ -3607,14 +4644,119 @@ static int efx_ef10_ptp_set_ts_config(struct efx_nic *efx,
        }
 }
 
+const struct efx_nic_type efx_hunt_a0_vf_nic_type = {
+       .is_vf = true,
+       .mem_bar = EFX_MEM_VF_BAR,
+       .mem_map_size = efx_ef10_mem_map_size,
+       .probe = efx_ef10_probe_vf,
+       .remove = efx_ef10_remove,
+       .dimension_resources = efx_ef10_dimension_resources,
+       .init = efx_ef10_init_nic,
+       .fini = efx_port_dummy_op_void,
+       .map_reset_reason = efx_ef10_map_reset_reason,
+       .map_reset_flags = efx_ef10_map_reset_flags,
+       .reset = efx_ef10_reset,
+       .probe_port = efx_mcdi_port_probe,
+       .remove_port = efx_mcdi_port_remove,
+       .fini_dmaq = efx_ef10_fini_dmaq,
+       .prepare_flr = efx_ef10_prepare_flr,
+       .finish_flr = efx_port_dummy_op_void,
+       .describe_stats = efx_ef10_describe_stats,
+       .update_stats = efx_ef10_update_stats_vf,
+       .start_stats = efx_port_dummy_op_void,
+       .pull_stats = efx_port_dummy_op_void,
+       .stop_stats = efx_port_dummy_op_void,
+       .set_id_led = efx_mcdi_set_id_led,
+       .push_irq_moderation = efx_ef10_push_irq_moderation,
+       .reconfigure_mac = efx_ef10_mac_reconfigure_vf,
+       .check_mac_fault = efx_mcdi_mac_check_fault,
+       .reconfigure_port = efx_mcdi_port_reconfigure,
+       .get_wol = efx_ef10_get_wol_vf,
+       .set_wol = efx_ef10_set_wol_vf,
+       .resume_wol = efx_port_dummy_op_void,
+       .mcdi_request = efx_ef10_mcdi_request,
+       .mcdi_poll_response = efx_ef10_mcdi_poll_response,
+       .mcdi_read_response = efx_ef10_mcdi_read_response,
+       .mcdi_poll_reboot = efx_ef10_mcdi_poll_reboot,
+       .mcdi_reboot_detected = efx_ef10_mcdi_reboot_detected,
+       .irq_enable_master = efx_port_dummy_op_void,
+       .irq_test_generate = efx_ef10_irq_test_generate,
+       .irq_disable_non_ev = efx_port_dummy_op_void,
+       .irq_handle_msi = efx_ef10_msi_interrupt,
+       .irq_handle_legacy = efx_ef10_legacy_interrupt,
+       .tx_probe = efx_ef10_tx_probe,
+       .tx_init = efx_ef10_tx_init,
+       .tx_remove = efx_ef10_tx_remove,
+       .tx_write = efx_ef10_tx_write,
+       .rx_push_rss_config = efx_ef10_vf_rx_push_rss_config,
+       .rx_probe = efx_ef10_rx_probe,
+       .rx_init = efx_ef10_rx_init,
+       .rx_remove = efx_ef10_rx_remove,
+       .rx_write = efx_ef10_rx_write,
+       .rx_defer_refill = efx_ef10_rx_defer_refill,
+       .ev_probe = efx_ef10_ev_probe,
+       .ev_init = efx_ef10_ev_init,
+       .ev_fini = efx_ef10_ev_fini,
+       .ev_remove = efx_ef10_ev_remove,
+       .ev_process = efx_ef10_ev_process,
+       .ev_read_ack = efx_ef10_ev_read_ack,
+       .ev_test_generate = efx_ef10_ev_test_generate,
+       .filter_table_probe = efx_ef10_filter_table_probe,
+       .filter_table_restore = efx_ef10_filter_table_restore,
+       .filter_table_remove = efx_ef10_filter_table_remove,
+       .filter_update_rx_scatter = efx_ef10_filter_update_rx_scatter,
+       .filter_insert = efx_ef10_filter_insert,
+       .filter_remove_safe = efx_ef10_filter_remove_safe,
+       .filter_get_safe = efx_ef10_filter_get_safe,
+       .filter_clear_rx = efx_ef10_filter_clear_rx,
+       .filter_count_rx_used = efx_ef10_filter_count_rx_used,
+       .filter_get_rx_id_limit = efx_ef10_filter_get_rx_id_limit,
+       .filter_get_rx_ids = efx_ef10_filter_get_rx_ids,
+#ifdef CONFIG_RFS_ACCEL
+       .filter_rfs_insert = efx_ef10_filter_rfs_insert,
+       .filter_rfs_expire_one = efx_ef10_filter_rfs_expire_one,
+#endif
+#ifdef CONFIG_SFC_MTD
+       .mtd_probe = efx_port_dummy_op_int,
+#endif
+       .ptp_write_host_time = efx_ef10_ptp_write_host_time_vf,
+       .ptp_set_ts_config = efx_ef10_ptp_set_ts_config_vf,
+#ifdef CONFIG_SFC_SRIOV
+       .vswitching_probe = efx_ef10_vswitching_probe_vf,
+       .vswitching_restore = efx_ef10_vswitching_restore_vf,
+       .vswitching_remove = efx_ef10_vswitching_remove_vf,
+       .sriov_get_phys_port_id = efx_ef10_sriov_get_phys_port_id,
+#endif
+       .get_mac_address = efx_ef10_get_mac_address_vf,
+       .set_mac_address = efx_ef10_set_mac_address,
+
+       .revision = EFX_REV_HUNT_A0,
+       .max_dma_mask = DMA_BIT_MASK(ESF_DZ_TX_KER_BUF_ADDR_WIDTH),
+       .rx_prefix_size = ES_DZ_RX_PREFIX_SIZE,
+       .rx_hash_offset = ES_DZ_RX_PREFIX_HASH_OFST,
+       .rx_ts_offset = ES_DZ_RX_PREFIX_TSTAMP_OFST,
+       .can_rx_scatter = true,
+       .always_rx_scatter = true,
+       .max_interrupt_mode = EFX_INT_MODE_MSIX,
+       .timer_period_max = 1 << ERF_DD_EVQ_IND_TIMER_VAL_WIDTH,
+       .offload_features = (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
+                            NETIF_F_RXHASH | NETIF_F_NTUPLE),
+       .mcdi_max_ver = 2,
+       .max_rx_ip_filters = HUNT_FILTER_TBL_ROWS,
+       .hwtstamp_filters = 1 << HWTSTAMP_FILTER_NONE |
+                           1 << HWTSTAMP_FILTER_ALL,
+};
+
 const struct efx_nic_type efx_hunt_a0_nic_type = {
+       .is_vf = false,
+       .mem_bar = EFX_MEM_BAR,
        .mem_map_size = efx_ef10_mem_map_size,
-       .probe = efx_ef10_probe,
+       .probe = efx_ef10_probe_pf,
        .remove = efx_ef10_remove,
        .dimension_resources = efx_ef10_dimension_resources,
        .init = efx_ef10_init_nic,
        .fini = efx_port_dummy_op_void,
-       .map_reset_reason = efx_mcdi_map_reset_reason,
+       .map_reset_reason = efx_ef10_map_reset_reason,
        .map_reset_flags = efx_ef10_map_reset_flags,
        .reset = efx_ef10_reset,
        .probe_port = efx_mcdi_port_probe,
@@ -3623,7 +4765,7 @@ const struct efx_nic_type efx_hunt_a0_nic_type = {
        .prepare_flr = efx_ef10_prepare_flr,
        .finish_flr = efx_port_dummy_op_void,
        .describe_stats = efx_ef10_describe_stats,
-       .update_stats = efx_ef10_update_stats,
+       .update_stats = efx_ef10_update_stats_pf,
        .start_stats = efx_mcdi_mac_start_stats,
        .pull_stats = efx_mcdi_mac_pull_stats,
        .stop_stats = efx_mcdi_mac_stop_stats,
@@ -3641,6 +4783,7 @@ const struct efx_nic_type efx_hunt_a0_nic_type = {
        .mcdi_poll_response = efx_ef10_mcdi_poll_response,
        .mcdi_read_response = efx_ef10_mcdi_read_response,
        .mcdi_poll_reboot = efx_ef10_mcdi_poll_reboot,
+       .mcdi_reboot_detected = efx_ef10_mcdi_reboot_detected,
        .irq_enable_master = efx_port_dummy_op_void,
        .irq_test_generate = efx_ef10_irq_test_generate,
        .irq_disable_non_ev = efx_port_dummy_op_void,
@@ -3650,7 +4793,7 @@ const struct efx_nic_type efx_hunt_a0_nic_type = {
        .tx_init = efx_ef10_tx_init,
        .tx_remove = efx_ef10_tx_remove,
        .tx_write = efx_ef10_tx_write,
-       .rx_push_rss_config = efx_ef10_rx_push_rss_config,
+       .rx_push_rss_config = efx_ef10_pf_rx_push_rss_config,
        .rx_probe = efx_ef10_rx_probe,
        .rx_init = efx_ef10_rx_init,
        .rx_remove = efx_ef10_rx_remove,
@@ -3689,11 +4832,24 @@ const struct efx_nic_type efx_hunt_a0_nic_type = {
        .ptp_write_host_time = efx_ef10_ptp_write_host_time,
        .ptp_set_ts_sync_events = efx_ef10_ptp_set_ts_sync_events,
        .ptp_set_ts_config = efx_ef10_ptp_set_ts_config,
+#ifdef CONFIG_SFC_SRIOV
+       .sriov_configure = efx_ef10_sriov_configure,
        .sriov_init = efx_ef10_sriov_init,
        .sriov_fini = efx_ef10_sriov_fini,
-       .sriov_mac_address_changed = efx_ef10_sriov_mac_address_changed,
        .sriov_wanted = efx_ef10_sriov_wanted,
        .sriov_reset = efx_ef10_sriov_reset,
+       .sriov_flr = efx_ef10_sriov_flr,
+       .sriov_set_vf_mac = efx_ef10_sriov_set_vf_mac,
+       .sriov_set_vf_vlan = efx_ef10_sriov_set_vf_vlan,
+       .sriov_set_vf_spoofchk = efx_ef10_sriov_set_vf_spoofchk,
+       .sriov_get_vf_config = efx_ef10_sriov_get_vf_config,
+       .sriov_set_vf_link_state = efx_ef10_sriov_set_vf_link_state,
+       .vswitching_probe = efx_ef10_vswitching_probe_pf,
+       .vswitching_restore = efx_ef10_vswitching_restore_pf,
+       .vswitching_remove = efx_ef10_vswitching_remove_pf,
+#endif
+       .get_mac_address = efx_ef10_get_mac_address_pf,
+       .set_mac_address = efx_ef10_set_mac_address,
 
        .revision = EFX_REV_HUNT_A0,
        .max_dma_mask = DMA_BIT_MASK(ESF_DZ_TX_KER_BUF_ADDR_WIDTH),