When a VF is reset its settings are not restored. These settings include
unicast and multicast promiscuous states. Enable the ability to restore
these settings by introducing a new devarg "auto_reconfig" which accepts
values of zero to disable or one to enable. It is enabled by default.

Signed-off-by: Ciara Loftus <[email protected]>
---
 doc/guides/nics/intel_vf.rst         |  4 +++
 drivers/net/intel/iavf/iavf.h        |  1 +
 drivers/net/intel/iavf/iavf_ethdev.c | 51 ++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+)

diff --git a/doc/guides/nics/intel_vf.rst b/doc/guides/nics/intel_vf.rst
index aec7f11b84..5fa2ddc9ea 100644
--- a/doc/guides/nics/intel_vf.rst
+++ b/doc/guides/nics/intel_vf.rst
@@ -104,6 +104,10 @@ IAVF PMD parameters
     transparently after a reset event, rather than relying on the application 
to do so. To disable
     this functionality, set the ``auto_reset`` devarg to zero: ``-a 
18:01.0,auto_reset=0``
 
+``auto_reconfig``
+    Restore settings (unicast and multicast promiscuous states) on the VF 
after a reset event.
+    Enabled by default. To disable it: ``-a 18:01.0,auto_reconfig=0``
+
 ``no-poll-on-link-down``
     Stop polling Rx/Tx hardware queue when link is down. This is enabled by 
default because it is
     required when ``auto_reset`` is enabled which it is by default. To disable 
it, you must disable
diff --git a/drivers/net/intel/iavf/iavf.h b/drivers/net/intel/iavf/iavf.h
index 403c61e2e8..02fa780e86 100644
--- a/drivers/net/intel/iavf/iavf.h
+++ b/drivers/net/intel/iavf/iavf.h
@@ -319,6 +319,7 @@ struct iavf_devargs {
        uint16_t quanta_size;
        uint32_t watchdog_period;
        int auto_reset;
+       int auto_reconfig;
        int no_poll_on_link_down;
        uint64_t mbuf_check;
 };
diff --git a/drivers/net/intel/iavf/iavf_ethdev.c 
b/drivers/net/intel/iavf/iavf_ethdev.c
index b5abfb1316..111bfa1934 100644
--- a/drivers/net/intel/iavf/iavf_ethdev.c
+++ b/drivers/net/intel/iavf/iavf_ethdev.c
@@ -41,6 +41,7 @@
 #define IAVF_QUANTA_SIZE_ARG       "quanta_size"
 #define IAVF_RESET_WATCHDOG_ARG    "watchdog_period"
 #define IAVF_ENABLE_AUTO_RESET_ARG "auto_reset"
+#define IAVF_ENABLE_AUTO_RECONFIG_ARG "auto_reconfig"
 #define IAVF_NO_POLL_ON_LINK_DOWN_ARG "no-poll-on-link-down"
 #define IAVF_MBUF_CHECK_ARG       "mbuf_check"
 uint64_t iavf_timestamp_dynflag;
@@ -52,6 +53,7 @@ static const char * const iavf_valid_args[] = {
        IAVF_QUANTA_SIZE_ARG,
        IAVF_RESET_WATCHDOG_ARG,
        IAVF_ENABLE_AUTO_RESET_ARG,
+       IAVF_ENABLE_AUTO_RECONFIG_ARG,
        IAVF_NO_POLL_ON_LINK_DOWN_ARG,
        IAVF_MBUF_CHECK_ARG,
        NULL
@@ -2375,6 +2377,7 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
 
        ad->devargs.auto_reset = 1;
        ad->devargs.no_poll_on_link_down = 1;
+       ad->devargs.auto_reconfig = 1;
 
        if (!devargs)
                return 0;
@@ -2437,6 +2440,11 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
                ad->devargs.no_poll_on_link_down = 1;
        }
 
+       ret = rte_kvargs_process(kvlist, IAVF_ENABLE_AUTO_RECONFIG_ARG,
+                                &parse_bool, &ad->devargs.auto_reconfig);
+       if (ret)
+               goto bail;
+
 bail:
        rte_kvargs_free(kvlist);
        return ret;
@@ -3101,6 +3109,34 @@ iavf_is_reset_detected(struct iavf_adapter *adapter)
        return false;
 }
 
+static int
+iavf_post_reset_reconfig(struct rte_eth_dev *dev)
+{
+       int ret, status = 0;
+       bool allmulti = false, allunicast = false;
+       struct iavf_adapter *adapter = 
IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+
+       /* Restore pre-reset unicast promiscuous and multicast promiscuous 
states */
+       if (dev->data->promiscuous)
+               allunicast = true;
+       if (dev->data->all_multicast)
+               allmulti = true;
+       if (allmulti || allunicast) {
+               ret = iavf_config_promisc(adapter, allunicast, allmulti);
+               if (ret)
+                       PMD_DRV_LOG(ERR, "Failed to restore unicast promiscuous 
mode (%s) "
+                                               "and multicast promiscuous mode 
(%s)",
+                                               allunicast ? "on" : "off", 
allmulti ? "on" : "off");
+               else
+                       PMD_DRV_LOG(DEBUG, "Restored unicast promiscuous mode 
(%s) "
+                                               "and multicast promiscuous mode 
(%s)",
+                                               allunicast ? "on" : "off", 
allmulti ? "on" : "off");
+               status |= ret;
+       }
+
+       return status;
+}
+
 /*
  * Handle hardware reset
  */
@@ -3150,6 +3186,21 @@ iavf_handle_hw_reset(struct rte_eth_dev *dev, bool 
vf_initiated_reset)
 
                dev->data->dev_started = 1;
        }
+
+       /* Restore settings after the reset */
+       if (adapter->devargs.auto_reconfig) {
+               ret = iavf_post_reset_reconfig(dev);
+               if (ret) {
+                       PMD_DRV_LOG(ERR, "Failed to restore VF settings after 
reset");
+                       goto error;
+               }
+       } else {
+               dev->data->promiscuous = 0;
+               dev->data->all_multicast = 0;
+               vf->promisc_unicast_enabled = false;
+               vf->promisc_multicast_enabled = false;
+       }
+
        goto exit;
 
 error:
-- 
2.43.0

Reply via email to