[v3] net/iavf: add devargs to enable vf auto-reset

Message ID 20230915130249.425790-1-shiyangx.he@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers
Series [v3] net/iavf: add devargs to enable vf auto-reset |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS

Commit Message

Shiyang He Sept. 15, 2023, 1:02 p.m. UTC
  Originally, the iavf PMD does not perform special actions when it
receives a PF-to-VF reset event, resulting in vf being offline and
unavailable.

This patch enables vf auto-reset by setting 'watchdog_period' devargs
to true. The iavf PMD will perform an automatic reset to bring the vf
back online when it receives a PF-to-VF event.

v2: handling reset by event handler
v3: change reset process

Signed-off-by: Shiyang He <shiyangx.he@intel.com>
Signed-off-by: Liang-Min Larry Wang <liang-min.wang@intel.com>
---
 doc/guides/nics/intel_vf.rst           |  3 +
 doc/guides/rel_notes/release_23_11.rst |  3 +
 drivers/net/iavf/iavf.h                |  7 +++
 drivers/net/iavf/iavf_ethdev.c         | 86 +++++++++++++++++++++++---
 drivers/net/iavf/iavf_rxtx.c           | 52 ++++++++++------
 drivers/net/iavf/iavf_vchnl.c          | 11 +++-
 6 files changed, 135 insertions(+), 27 deletions(-)
  

Comments

Bruce Richardson Sept. 26, 2023, 7:48 a.m. UTC | #1
On Fri, Sep 15, 2023 at 01:02:49PM +0000, Shiyang He wrote:
> Originally, the iavf PMD does not perform special actions when it
> receives a PF-to-VF reset event, resulting in vf being offline and
> unavailable.
> 
> This patch enables vf auto-reset by setting 'watchdog_period' devargs
> to true. The iavf PMD will perform an automatic reset to bring the vf
> back online when it receives a PF-to-VF event.
> 
> v2: handling reset by event handler
> v3: change reset process
> 
> Signed-off-by: Shiyang He <shiyangx.he@intel.com>
> Signed-off-by: Liang-Min Larry Wang <liang-min.wang@intel.com>
> ---
>  doc/guides/nics/intel_vf.rst           |  3 +
>  doc/guides/rel_notes/release_23_11.rst |  3 +
>  drivers/net/iavf/iavf.h                |  7 +++
>  drivers/net/iavf/iavf_ethdev.c         | 86 +++++++++++++++++++++++---
>  drivers/net/iavf/iavf_rxtx.c           | 52 ++++++++++------
>  drivers/net/iavf/iavf_vchnl.c          | 11 +++-
>  6 files changed, 135 insertions(+), 27 deletions(-)
> 
> diff --git a/doc/guides/nics/intel_vf.rst b/doc/guides/nics/intel_vf.rst
> index d365dbc185..c0acd2a7f5 100644
> --- a/doc/guides/nics/intel_vf.rst
> +++ b/doc/guides/nics/intel_vf.rst
> @@ -101,6 +101,9 @@ For more detail on SR-IOV, please refer to the following documents:
>      Set ``devargs`` parameter ``watchdog_period`` to adjust the watchdog period in microseconds, or set it to 0 to disable the watchdog,
>      for example, ``-a 18:01.0,watchdog_period=5000`` or ``-a 18:01.0,watchdog_period=0``.
>  
> +    Enable vf auto-reset by setting the ``devargs`` parameter like ``-a 18:01.0,enable_auto_reset=1`` when IAVF is backed
> +    by an Intel® E810 device or an Intel® 700 Series Ethernet device.
> +

Why do we need a devargs for this? If the VF is unavailable - as you
mention in the commit log above - should this behaviour not always be the
case without the user having to ask?

/Bruce
  
Qi Zhang Sept. 26, 2023, 12:15 p.m. UTC | #2
> -----Original Message-----
> From: Bruce Richardson <bruce.richardson@intel.com>
> Sent: Tuesday, September 26, 2023 3:49 PM
> To: He, ShiyangX <shiyangx.he@intel.com>
> Cc: dev@dpdk.org; Zhou, YidingX <yidingx.zhou@intel.com>; Wang, Liang-
> min <liang-min.wang@intel.com>; Su, Simei <simei.su@intel.com>; Wu,
> Wenjun1 <wenjun1.wu@intel.com>; Zhang, Yuying
> <yuying.zhang@intel.com>; Xing, Beilei <beilei.xing@intel.com>; Yang,
> Qiming <qiming.yang@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>
> Subject: Re: [PATCH v3] net/iavf: add devargs to enable vf auto-reset
> 
> On Fri, Sep 15, 2023 at 01:02:49PM +0000, Shiyang He wrote:
> > Originally, the iavf PMD does not perform special actions when it
> > receives a PF-to-VF reset event, resulting in vf being offline and
> > unavailable.
> >
> > This patch enables vf auto-reset by setting 'watchdog_period' devargs
> > to true. The iavf PMD will perform an automatic reset to bring the vf
> > back online when it receives a PF-to-VF event.
> >
> > v2: handling reset by event handler
> > v3: change reset process
> >
> > Signed-off-by: Shiyang He <shiyangx.he@intel.com>
> > Signed-off-by: Liang-Min Larry Wang <liang-min.wang@intel.com>
> > ---
> >  doc/guides/nics/intel_vf.rst           |  3 +
> >  doc/guides/rel_notes/release_23_11.rst |  3 +
> >  drivers/net/iavf/iavf.h                |  7 +++
> >  drivers/net/iavf/iavf_ethdev.c         | 86 +++++++++++++++++++++++---
> >  drivers/net/iavf/iavf_rxtx.c           | 52 ++++++++++------
> >  drivers/net/iavf/iavf_vchnl.c          | 11 +++-
> >  6 files changed, 135 insertions(+), 27 deletions(-)
> >
> > diff --git a/doc/guides/nics/intel_vf.rst
> > b/doc/guides/nics/intel_vf.rst index d365dbc185..c0acd2a7f5 100644
> > --- a/doc/guides/nics/intel_vf.rst
> > +++ b/doc/guides/nics/intel_vf.rst
> > @@ -101,6 +101,9 @@ For more detail on SR-IOV, please refer to the
> following documents:
> >      Set ``devargs`` parameter ``watchdog_period`` to adjust the watchdog
> period in microseconds, or set it to 0 to disable the watchdog,
> >      for example, ``-a 18:01.0,watchdog_period=5000`` or ``-a
> 18:01.0,watchdog_period=0``.
> >
> > +    Enable vf auto-reset by setting the ``devargs`` parameter like ``-a
> 18:01.0,enable_auto_reset=1`` when IAVF is backed
> > +    by an Intel(r) E810 device or an Intel(r) 700 Series Ethernet device.
> > +
> 
> Why do we need a devargs for this? If the VF is unavailable - as you mention
> in the commit log above - should this behaviour not always be the case
> without the user having to ask?

Ideally it does not need, but with below considerations:

1. Not break existing scenario, which still assume some application will call dev_reset /dev_configure/ queue_setup / ...  after receive RTE_ETH_EVENT_INTR_RESET event to recover the VF manually, the devargs make sure application be aware of this new feature and will not call rte_eth_dev_reset which will fail now.

2. intent to ensure a smoother transition, in case some corner case issues evaded our validation, keeping this devargs provides us with the flexibility to remove it once we determine that the implementation is stable enough.  

> 
> /Bruce
  
Bruce Richardson Sept. 26, 2023, 2:05 p.m. UTC | #3
On Tue, Sep 26, 2023 at 01:15:28PM +0100, Zhang, Qi Z wrote:
> 
> 
> > -----Original Message-----
> > From: Bruce Richardson <bruce.richardson@intel.com>
> > Sent: Tuesday, September 26, 2023 3:49 PM
> > To: He, ShiyangX <shiyangx.he@intel.com>
> > Cc: dev@dpdk.org; Zhou, YidingX <yidingx.zhou@intel.com>; Wang, Liang-
> > min <liang-min.wang@intel.com>; Su, Simei <simei.su@intel.com>; Wu,
> > Wenjun1 <wenjun1.wu@intel.com>; Zhang, Yuying
> > <yuying.zhang@intel.com>; Xing, Beilei <beilei.xing@intel.com>; Yang,
> > Qiming <qiming.yang@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>
> > Subject: Re: [PATCH v3] net/iavf: add devargs to enable vf auto-reset
> > 
> > On Fri, Sep 15, 2023 at 01:02:49PM +0000, Shiyang He wrote:
> > > Originally, the iavf PMD does not perform special actions when it
> > > receives a PF-to-VF reset event, resulting in vf being offline and
> > > unavailable.
> > >
> > > This patch enables vf auto-reset by setting 'watchdog_period' devargs
> > > to true. The iavf PMD will perform an automatic reset to bring the vf
> > > back online when it receives a PF-to-VF event.
> > >
> > > v2: handling reset by event handler
> > > v3: change reset process
> > >
> > > Signed-off-by: Shiyang He <shiyangx.he@intel.com>
> > > Signed-off-by: Liang-Min Larry Wang <liang-min.wang@intel.com>
> > > ---
> > >  doc/guides/nics/intel_vf.rst           |  3 +
> > >  doc/guides/rel_notes/release_23_11.rst |  3 +
> > >  drivers/net/iavf/iavf.h                |  7 +++
> > >  drivers/net/iavf/iavf_ethdev.c         | 86 +++++++++++++++++++++++---
> > >  drivers/net/iavf/iavf_rxtx.c           | 52 ++++++++++------
> > >  drivers/net/iavf/iavf_vchnl.c          | 11 +++-
> > >  6 files changed, 135 insertions(+), 27 deletions(-)
> > >
> > > diff --git a/doc/guides/nics/intel_vf.rst
> > > b/doc/guides/nics/intel_vf.rst index d365dbc185..c0acd2a7f5 100644
> > > --- a/doc/guides/nics/intel_vf.rst
> > > +++ b/doc/guides/nics/intel_vf.rst
> > > @@ -101,6 +101,9 @@ For more detail on SR-IOV, please refer to the
> > following documents:
> > >      Set ``devargs`` parameter ``watchdog_period`` to adjust the watchdog
> > period in microseconds, or set it to 0 to disable the watchdog,
> > >      for example, ``-a 18:01.0,watchdog_period=5000`` or ``-a
> > 18:01.0,watchdog_period=0``.
> > >
> > > +    Enable vf auto-reset by setting the ``devargs`` parameter like ``-a
> > 18:01.0,enable_auto_reset=1`` when IAVF is backed
> > > +    by an Intel(r) E810 device or an Intel(r) 700 Series Ethernet device.
> > > +
> > 
> > Why do we need a devargs for this? If the VF is unavailable - as you mention
> > in the commit log above - should this behaviour not always be the case
> > without the user having to ask?
> 
> Ideally it does not need, but with below considerations:
> 
> 1. Not break existing scenario, which still assume some application will call dev_reset /dev_configure/ queue_setup / ...  after receive RTE_ETH_EVENT_INTR_RESET event to recover the VF manually, the devargs make sure application be aware of this new feature and will not call rte_eth_dev_reset which will fail now.
> 
> 2. intent to ensure a smoother transition, in case some corner case issues evaded our validation, keeping this devargs provides us with the flexibility to remove it once we determine that the implementation is stable enough.  
> 
Thanks for the clear explanation.

One small suggestion: in the commit log, at the end of the first paragraph
change "resulting in the VF being offline and unavailable" to "... offline
and unavailable until the application resets the device on receipt of the
RTE_ETH_EVENT_INTR_RESET event". Similarly at the end of the second
paragraph you could add "This change removes the need for the application
to handle the reset event, as it is transparently handled inside the
driver".

Regards,
/Bruce
  
Qi Zhang Sept. 26, 2023, 11:41 p.m. UTC | #4
> -----Original Message-----
> From: Richardson, Bruce <bruce.richardson@intel.com>
> Sent: Tuesday, September 26, 2023 10:06 PM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>
> Cc: He, ShiyangX <shiyangx.he@intel.com>; dev@dpdk.org; Zhou, YidingX
> <yidingx.zhou@intel.com>; Wang, Liang-min <liang-min.wang@intel.com>;
> Su, Simei <simei.su@intel.com>; Wu, Wenjun1 <wenjun1.wu@intel.com>;
> Zhang, Yuying <yuying.zhang@intel.com>; Xing, Beilei
> <beilei.xing@intel.com>; Yang, Qiming <qiming.yang@intel.com>; Wu,
> Jingjing <jingjing.wu@intel.com>
> Subject: Re: [PATCH v3] net/iavf: add devargs to enable vf auto-reset
> 
> On Tue, Sep 26, 2023 at 01:15:28PM +0100, Zhang, Qi Z wrote:
> >
> >
> > > -----Original Message-----
> > > From: Bruce Richardson <bruce.richardson@intel.com>
> > > Sent: Tuesday, September 26, 2023 3:49 PM
> > > To: He, ShiyangX <shiyangx.he@intel.com>
> > > Cc: dev@dpdk.org; Zhou, YidingX <yidingx.zhou@intel.com>; Wang,
> > > Liang- min <liang-min.wang@intel.com>; Su, Simei
> > > <simei.su@intel.com>; Wu,
> > > Wenjun1 <wenjun1.wu@intel.com>; Zhang, Yuying
> > > <yuying.zhang@intel.com>; Xing, Beilei <beilei.xing@intel.com>;
> > > Yang, Qiming <qiming.yang@intel.com>; Wu, Jingjing
> > > <jingjing.wu@intel.com>
> > > Subject: Re: [PATCH v3] net/iavf: add devargs to enable vf
> > > auto-reset
> > >
> > > On Fri, Sep 15, 2023 at 01:02:49PM +0000, Shiyang He wrote:
> > > > Originally, the iavf PMD does not perform special actions when it
> > > > receives a PF-to-VF reset event, resulting in vf being offline and
> > > > unavailable.
> > > >
> > > > This patch enables vf auto-reset by setting 'watchdog_period'
> > > > devargs to true. The iavf PMD will perform an automatic reset to
> > > > bring the vf back online when it receives a PF-to-VF event.
> > > >
> > > > v2: handling reset by event handler
> > > > v3: change reset process
> > > >
> > > > Signed-off-by: Shiyang He <shiyangx.he@intel.com>
> > > > Signed-off-by: Liang-Min Larry Wang <liang-min.wang@intel.com>
> > > > ---
> > > >  doc/guides/nics/intel_vf.rst           |  3 +
> > > >  doc/guides/rel_notes/release_23_11.rst |  3 +
> > > >  drivers/net/iavf/iavf.h                |  7 +++
> > > >  drivers/net/iavf/iavf_ethdev.c         | 86 +++++++++++++++++++++++---
> > > >  drivers/net/iavf/iavf_rxtx.c           | 52 ++++++++++------
> > > >  drivers/net/iavf/iavf_vchnl.c          | 11 +++-
> > > >  6 files changed, 135 insertions(+), 27 deletions(-)
> > > >
> > > > diff --git a/doc/guides/nics/intel_vf.rst
> > > > b/doc/guides/nics/intel_vf.rst index d365dbc185..c0acd2a7f5 100644
> > > > --- a/doc/guides/nics/intel_vf.rst
> > > > +++ b/doc/guides/nics/intel_vf.rst
> > > > @@ -101,6 +101,9 @@ For more detail on SR-IOV, please refer to the
> > > following documents:
> > > >      Set ``devargs`` parameter ``watchdog_period`` to adjust the
> > > > watchdog
> > > period in microseconds, or set it to 0 to disable the watchdog,
> > > >      for example, ``-a 18:01.0,watchdog_period=5000`` or ``-a
> > > 18:01.0,watchdog_period=0``.
> > > >
> > > > +    Enable vf auto-reset by setting the ``devargs`` parameter
> > > > + like ``-a
> > > 18:01.0,enable_auto_reset=1`` when IAVF is backed
> > > > +    by an Intel(r) E810 device or an Intel(r) 700 Series Ethernet device.
> > > > +
> > >
> > > Why do we need a devargs for this? If the VF is unavailable - as you
> > > mention in the commit log above - should this behaviour not always
> > > be the case without the user having to ask?
> >
> > Ideally it does not need, but with below considerations:
> >
> > 1. Not break existing scenario, which still assume some application will call
> dev_reset /dev_configure/ queue_setup / ...  after receive
> RTE_ETH_EVENT_INTR_RESET event to recover the VF manually, the devargs
> make sure application be aware of this new feature and will not call
> rte_eth_dev_reset which will fail now.
> >
> > 2. intent to ensure a smoother transition, in case some corner case issues
> evaded our validation, keeping this devargs provides us with the flexibility to
> remove it once we determine that the implementation is stable enough.
> >
> Thanks for the clear explanation.
> 
> One small suggestion: in the commit log, at the end of the first paragraph
> change "resulting in the VF being offline and unavailable" to "... offline and
> unavailable until the application resets the device on receipt of the
> RTE_ETH_EVENT_INTR_RESET event". Similarly at the end of the second
> paragraph you could add "This change removes the need for the application
> to handle the reset event, as it is transparently handled inside the driver".

Thank you for the suggestion. The commit log has been refined in the dpdk-next-net-intel repo.

Qi

> 
> Regards,
> /Bruce
  
David Marchand Sept. 27, 2023, 6:39 a.m. UTC | #5
On Tue, Sep 26, 2023 at 4:06 PM Bruce Richardson
<bruce.richardson@intel.com> wrote:
>
> On Tue, Sep 26, 2023 at 01:15:28PM +0100, Zhang, Qi Z wrote:
> >
> >
> > > -----Original Message-----
> > > From: Bruce Richardson <bruce.richardson@intel.com>
> > > Sent: Tuesday, September 26, 2023 3:49 PM
> > > To: He, ShiyangX <shiyangx.he@intel.com>
> > > Cc: dev@dpdk.org; Zhou, YidingX <yidingx.zhou@intel.com>; Wang, Liang-
> > > min <liang-min.wang@intel.com>; Su, Simei <simei.su@intel.com>; Wu,
> > > Wenjun1 <wenjun1.wu@intel.com>; Zhang, Yuying
> > > <yuying.zhang@intel.com>; Xing, Beilei <beilei.xing@intel.com>; Yang,
> > > Qiming <qiming.yang@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>
> > > Subject: Re: [PATCH v3] net/iavf: add devargs to enable vf auto-reset
> > >
> > > On Fri, Sep 15, 2023 at 01:02:49PM +0000, Shiyang He wrote:
> > > > Originally, the iavf PMD does not perform special actions when it
> > > > receives a PF-to-VF reset event, resulting in vf being offline and
> > > > unavailable.
> > > >
> > > > This patch enables vf auto-reset by setting 'watchdog_period' devargs
> > > > to true. The iavf PMD will perform an automatic reset to bring the vf
> > > > back online when it receives a PF-to-VF event.
> > > >
> > > > v2: handling reset by event handler
> > > > v3: change reset process
> > > >
> > > > Signed-off-by: Shiyang He <shiyangx.he@intel.com>
> > > > Signed-off-by: Liang-Min Larry Wang <liang-min.wang@intel.com>
> > > > ---
> > > >  doc/guides/nics/intel_vf.rst           |  3 +
> > > >  doc/guides/rel_notes/release_23_11.rst |  3 +
> > > >  drivers/net/iavf/iavf.h                |  7 +++
> > > >  drivers/net/iavf/iavf_ethdev.c         | 86 +++++++++++++++++++++++---
> > > >  drivers/net/iavf/iavf_rxtx.c           | 52 ++++++++++------
> > > >  drivers/net/iavf/iavf_vchnl.c          | 11 +++-
> > > >  6 files changed, 135 insertions(+), 27 deletions(-)
> > > >
> > > > diff --git a/doc/guides/nics/intel_vf.rst
> > > > b/doc/guides/nics/intel_vf.rst index d365dbc185..c0acd2a7f5 100644
> > > > --- a/doc/guides/nics/intel_vf.rst
> > > > +++ b/doc/guides/nics/intel_vf.rst
> > > > @@ -101,6 +101,9 @@ For more detail on SR-IOV, please refer to the
> > > following documents:
> > > >      Set ``devargs`` parameter ``watchdog_period`` to adjust the watchdog
> > > period in microseconds, or set it to 0 to disable the watchdog,
> > > >      for example, ``-a 18:01.0,watchdog_period=5000`` or ``-a
> > > 18:01.0,watchdog_period=0``.
> > > >
> > > > +    Enable vf auto-reset by setting the ``devargs`` parameter like ``-a
> > > 18:01.0,enable_auto_reset=1`` when IAVF is backed
> > > > +    by an Intel(r) E810 device or an Intel(r) 700 Series Ethernet device.
> > > > +
> > >
> > > Why do we need a devargs for this? If the VF is unavailable - as you mention
> > > in the commit log above - should this behaviour not always be the case
> > > without the user having to ask?
> >
> > Ideally it does not need, but with below considerations:
> >
> > 1. Not break existing scenario, which still assume some application will call dev_reset /dev_configure/ queue_setup / ...  after receive RTE_ETH_EVENT_INTR_RESET event to recover the VF manually, the devargs make sure application be aware of this new feature and will not call rte_eth_dev_reset which will fail now.
> >
> > 2. intent to ensure a smoother transition, in case some corner case issues evaded our validation, keeping this devargs provides us with the flexibility to remove it once we determine that the implementation is stable enough.
> >
> Thanks for the clear explanation.
>
> One small suggestion: in the commit log, at the end of the first paragraph
> change "resulting in the VF being offline and unavailable" to "... offline
> and unavailable until the application resets the device on receipt of the
> RTE_ETH_EVENT_INTR_RESET event". Similarly at the end of the second
> paragraph you could add "This change removes the need for the application
> to handle the reset event, as it is transparently handled inside the
> driver".

I did not read the patch.

You mention that rte_eth_dev_reset will fail now when this (horrific)
devargs is passed.
Yet, will the driver send a RTE_ETH_EVENT_INTR_RESET event?

Additionnally, how does the driver make sure that no
application/datapath thread is polling/reconfiguring this hw?
  

Patch

diff --git a/doc/guides/nics/intel_vf.rst b/doc/guides/nics/intel_vf.rst
index d365dbc185..c0acd2a7f5 100644
--- a/doc/guides/nics/intel_vf.rst
+++ b/doc/guides/nics/intel_vf.rst
@@ -101,6 +101,9 @@  For more detail on SR-IOV, please refer to the following documents:
     Set ``devargs`` parameter ``watchdog_period`` to adjust the watchdog period in microseconds, or set it to 0 to disable the watchdog,
     for example, ``-a 18:01.0,watchdog_period=5000`` or ``-a 18:01.0,watchdog_period=0``.
 
+    Enable vf auto-reset by setting the ``devargs`` parameter like ``-a 18:01.0,enable_auto_reset=1`` when IAVF is backed
+    by an Intel® E810 device or an Intel® 700 Series Ethernet device.
+
 The PCIE host-interface of Intel Ethernet Switch FM10000 Series VF infrastructure
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
diff --git a/doc/guides/rel_notes/release_23_11.rst b/doc/guides/rel_notes/release_23_11.rst
index 333e1d95a2..aeddb0d8f6 100644
--- a/doc/guides/rel_notes/release_23_11.rst
+++ b/doc/guides/rel_notes/release_23_11.rst
@@ -78,6 +78,9 @@  New Features
 * build: Optional libraries can now be selected with the new ``enable_libs``
   build option similarly to the existing ``enable_drivers`` build option.
 
+* **Updated Intel iavf driver.**
+
+  * Added support for iavf auto-reset.
 
 Removed Items
 -------------
diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 98861e4242..3641401f38 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -277,6 +277,8 @@  struct iavf_info {
 
 	struct rte_eth_dev *eth_dev;
 
+	bool in_reset_recovery;
+
 	uint32_t ptp_caps;
 	rte_spinlock_t phc_time_aq_lock;
 };
@@ -305,6 +307,7 @@  struct iavf_devargs {
 	uint8_t proto_xtr[IAVF_MAX_QUEUE_NUM];
 	uint16_t quanta_size;
 	uint32_t watchdog_period;
+	uint8_t  enable_auto_reset;
 };
 
 struct iavf_security_ctx;
@@ -426,6 +429,9 @@  _atomic_set_async_response_cmd(struct iavf_info *vf, enum virtchnl_ops ops)
 }
 int iavf_check_api_version(struct iavf_adapter *adapter);
 int iavf_get_vf_resource(struct iavf_adapter *adapter);
+void iavf_dev_event_post(struct rte_eth_dev *dev,
+		enum rte_eth_event_type event,
+		void *param, size_t param_alloc_size);
 void iavf_dev_event_handler_fini(void);
 int iavf_dev_event_handler_init(void);
 void iavf_handle_virtchnl_msg(struct rte_eth_dev *dev);
@@ -501,4 +507,5 @@  int iavf_flow_sub_check(struct iavf_adapter *adapter,
 			struct iavf_fsub_conf *filter);
 void iavf_dev_watchdog_enable(struct iavf_adapter *adapter);
 void iavf_dev_watchdog_disable(struct iavf_adapter *adapter);
+int iavf_handle_hw_reset(struct rte_eth_dev *dev);
 #endif /* _IAVF_ETHDEV_H_ */
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index f2fc5a5621..713461f6cb 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -37,6 +37,7 @@ 
 #define IAVF_PROTO_XTR_ARG         "proto_xtr"
 #define IAVF_QUANTA_SIZE_ARG       "quanta_size"
 #define IAVF_RESET_WATCHDOG_ARG    "watchdog_period"
+#define IAVF_ENABLE_AUTO_RESET_ARG "enable_auto_reset"
 
 uint64_t iavf_timestamp_dynflag;
 int iavf_timestamp_dynfield_offset = -1;
@@ -45,6 +46,7 @@  static const char * const iavf_valid_args[] = {
 	IAVF_PROTO_XTR_ARG,
 	IAVF_QUANTA_SIZE_ARG,
 	IAVF_RESET_WATCHDOG_ARG,
+	IAVF_ENABLE_AUTO_RESET_ARG,
 	NULL
 };
 
@@ -305,8 +307,8 @@  iavf_dev_watchdog(void *cb_arg)
 			adapter->vf.vf_reset = true;
 			adapter->vf.link_up = false;
 
-			rte_eth_dev_callback_process(adapter->vf.eth_dev,
-				RTE_ETH_EVENT_INTR_RESET, NULL);
+			iavf_dev_event_post(adapter->vf.eth_dev, RTE_ETH_EVENT_INTR_RESET,
+				NULL, 0);
 		}
 	}
 
@@ -1092,12 +1094,15 @@  iavf_dev_stop(struct rte_eth_dev *dev)
 	/* Rx interrupt vector mapping free */
 	rte_intr_vec_list_free(intr_handle);
 
-	/* remove all mac addrs */
-	iavf_add_del_all_mac_addr(adapter, false);
+	/* adminq will be disabled when vf is resetting. */
+	if (!vf->in_reset_recovery) {
+		/* remove all mac addrs */
+		iavf_add_del_all_mac_addr(adapter, false);
 
-	/* remove all multicast addresses */
-	iavf_add_del_mc_addr_list(adapter, vf->mc_addrs, vf->mc_addrs_num,
+		/* remove all multicast addresses */
+		iavf_add_del_mc_addr_list(adapter, vf->mc_addrs, vf->mc_addrs_num,
 				  false);
+	}
 
 	iavf_stop_queues(dev);
 
@@ -2210,6 +2215,26 @@  parse_u16(__rte_unused const char *key, const char *value, void *args)
 	return 0;
 }
 
+static int
+parse_bool(const char *key, const char *value, void *args)
+{
+	int *i = (int *)args;
+	char *end;
+	int num;
+
+	num = strtoul(value, &end, 10);
+
+	if (num != 0 && num != 1) {
+		PMD_DRV_LOG(WARNING, "invalid value:\"%s\" for key:\"%s\", "
+			"value must be 0 or 1",
+			value, key);
+		return -1;
+	}
+
+	*i = num;
+	return 0;
+}
+
 static int
 iavf_parse_watchdog_period(__rte_unused const char *key, const char *value, void *args)
 {
@@ -2278,6 +2303,11 @@  static int iavf_parse_devargs(struct rte_eth_dev *dev)
 		goto bail;
 	}
 
+	ret = rte_kvargs_process(kvlist, IAVF_ENABLE_AUTO_RESET_ARG,
+				 &parse_bool, &ad->devargs.enable_auto_reset);
+	if (ret)
+		goto bail;
+
 bail:
 	rte_kvargs_free(kvlist);
 	return ret;
@@ -2841,12 +2871,15 @@  iavf_dev_close(struct rte_eth_dev *dev)
 static int
 iavf_dev_uninit(struct rte_eth_dev *dev)
 {
+	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return -EPERM;
 
 	iavf_dev_close(dev);
 
-	iavf_dev_event_handler_fini();
+	if (!vf->in_reset_recovery)
+		iavf_dev_event_handler_fini();
 
 	return 0;
 }
@@ -2859,6 +2892,7 @@  iavf_dev_reset(struct rte_eth_dev *dev)
 {
 	int ret;
 	struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
 
 	/*
 	 * Check whether the VF reset has been done and inform application,
@@ -2870,6 +2904,7 @@  iavf_dev_reset(struct rte_eth_dev *dev)
 		PMD_DRV_LOG(ERR, "Wait too long for reset done!\n");
 		return ret;
 	}
+	vf->vf_reset = false;
 
 	PMD_DRV_LOG(DEBUG, "Start dev_reset ...\n");
 	ret = iavf_dev_uninit(dev);
@@ -2879,6 +2914,43 @@  iavf_dev_reset(struct rte_eth_dev *dev)
 	return iavf_dev_init(dev);
 }
 
+/*
+ * Handle hardware reset
+ */
+int
+iavf_handle_hw_reset(struct rte_eth_dev *dev)
+{
+	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+	int ret;
+
+	vf->in_reset_recovery = true;
+
+	ret = iavf_dev_reset(dev);
+	if (ret)
+		goto error;
+
+	/* VF states restore */
+	ret = iavf_dev_configure(dev);
+	if (ret)
+		goto error;
+
+	iavf_dev_xstats_reset(dev);
+
+	/* start the device */
+	ret = iavf_dev_start(dev);
+	if (ret)
+		goto error;
+	dev->data->dev_started = 1;
+
+	vf->in_reset_recovery = false;
+	return 0;
+
+error:
+	PMD_DRV_LOG(DEBUG, "RESET recover with error code=%d\n", ret);
+	vf->in_reset_recovery = false;
+	return ret;
+}
+
 static int
 iavf_dcf_cap_check_handler(__rte_unused const char *key,
 			   const char *value, __rte_unused void *opaque)
diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index f7df4665d1..1bea68a3eb 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -1094,15 +1094,44 @@  iavf_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
 	rte_free(q);
 }
 
+static void
+iavf_reset_queues(struct rte_eth_dev *dev)
+{
+	struct iavf_rx_queue *rxq;
+	struct iavf_tx_queue *txq;
+	int i;
+
+	for (i = 0; i < dev->data->nb_tx_queues; i++) {
+		txq = dev->data->tx_queues[i];
+		if (!txq)
+			continue;
+		iavf_txq_release_mbufs_ops[txq->rel_mbufs_type].release_mbufs(txq);
+		reset_tx_queue(txq);
+		dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		rxq = dev->data->rx_queues[i];
+		if (!rxq)
+			continue;
+		iavf_rxq_release_mbufs_ops[rxq->rel_mbufs_type].release_mbufs(rxq);
+		reset_rx_queue(rxq);
+		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+}
+
 void
 iavf_stop_queues(struct rte_eth_dev *dev)
 {
 	struct iavf_adapter *adapter =
 		IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
-	struct iavf_rx_queue *rxq;
-	struct iavf_tx_queue *txq;
-	int ret, i;
+	int ret;
+
+	/* adminq will be disabled when vf is resetting. */
+	if (vf->in_reset_recovery) {
+		iavf_reset_queues(dev);
+		return;
+	}
 
 	/* Stop All queues */
 	if (!vf->lv_enabled) {
@@ -1118,22 +1147,7 @@  iavf_stop_queues(struct rte_eth_dev *dev)
 	if (ret)
 		PMD_DRV_LOG(WARNING, "Fail to stop queues");
 
-	for (i = 0; i < dev->data->nb_tx_queues; i++) {
-		txq = dev->data->tx_queues[i];
-		if (!txq)
-			continue;
-		iavf_txq_release_mbufs_ops[txq->rel_mbufs_type].release_mbufs(txq);
-		reset_tx_queue(txq);
-		dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
-	}
-	for (i = 0; i < dev->data->nb_rx_queues; i++) {
-		rxq = dev->data->rx_queues[i];
-		if (!rxq)
-			continue;
-		iavf_rxq_release_mbufs_ops[rxq->rel_mbufs_type].release_mbufs(rxq);
-		reset_rx_queue(rxq);
-		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
-	}
+	iavf_reset_queues(dev);
 }
 
 #define IAVF_RX_FLEX_ERR0_BITS	\
diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c
index c31a6d5c98..0726dc87be 100644
--- a/drivers/net/iavf/iavf_vchnl.c
+++ b/drivers/net/iavf/iavf_vchnl.c
@@ -79,6 +79,15 @@  iavf_dev_event_handle(void *param __rte_unused)
 		struct iavf_event_element *pos, *save_next;
 		TAILQ_FOREACH_SAFE(pos, &pending, next, save_next) {
 			TAILQ_REMOVE(&pending, pos, next);
+
+			struct iavf_adapter *adapter = pos->dev->data->dev_private;
+			if (pos->event == RTE_ETH_EVENT_INTR_RESET &&
+			    adapter->devargs.enable_auto_reset) {
+				iavf_handle_hw_reset(pos->dev);
+				rte_free(pos);
+				continue;
+			}
+
 			rte_eth_dev_callback_process(pos->dev, pos->event, pos->param);
 			rte_free(pos);
 		}
@@ -87,7 +96,7 @@  iavf_dev_event_handle(void *param __rte_unused)
 	return 0;
 }
 
-static void
+void
 iavf_dev_event_post(struct rte_eth_dev *dev,
 		enum rte_eth_event_type event,
 		void *param, size_t param_alloc_size)