[PATCH v3] net/iavf: support no data path polling mode

2023-10-12 Thread Mingjin Ye
Currently, during a PF to VF reset due to an action such as changing
trust settings on a VF, the DPDK application running with iavf PMD
loses connectivity, and the only solution is to reset the DPDK
application.

Instead of forcing a reset of the DPDK application to restore
connectivity, the iavf PMD driver handles the PF to VF reset event
normally by performing all necessary steps to bring the VF back
online.

To minimize downtime, a devargs "no-poll-on-link-down" is introduced
in iavf PMD. When this flag is set, the PMD switches to no-poll mode
when the link state is down (rx/tx bursts return to 0 immediately).
When the link state returns to normal, the PMD switches to normal
rx/tx burst state.

NOTE: The DPDK application needs to handle the
RTE_ETH_EVENT_INTR_RESET event posted by the iavf PMD and reset
the vf upon receipt of this event.

Signed-off-by: Mingjin Ye 
---
V3: Remove redundant code.
---
 doc/guides/nics/intel_vf.rst   |  3 ++
 drivers/net/iavf/iavf.h|  4 +++
 drivers/net/iavf/iavf_ethdev.c | 16 +-
 drivers/net/iavf/iavf_rxtx.c   | 53 ++
 drivers/net/iavf/iavf_rxtx.h   |  1 +
 drivers/net/iavf/iavf_vchnl.c  | 20 +
 6 files changed, 96 insertions(+), 1 deletion(-)

diff --git a/doc/guides/nics/intel_vf.rst b/doc/guides/nics/intel_vf.rst
index 7613e1c5e5..19c461c3de 100644
--- a/doc/guides/nics/intel_vf.rst
+++ b/doc/guides/nics/intel_vf.rst
@@ -104,6 +104,9 @@ For more detail on SR-IOV, please refer to the following 
documents:
 Enable vf auto-reset by setting the ``devargs`` parameter like ``-a 
18:01.0,auto_reset=1`` when IAVF is backed
 by an Intel® E810 device or an Intel® 700 Series Ethernet device.
 
+Enable vf no-poll-on-link-down by setting the ``devargs`` parameter like 
``-a 18:01.0,no-poll-on-link-down=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 FM1 Series VF 
infrastructure
 
^
 
diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 04774ce124..c115f3444e 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -308,6 +308,7 @@ struct iavf_devargs {
uint16_t quanta_size;
uint32_t watchdog_period;
uint8_t  auto_reset;
+   uint16_t no_poll_on_link_down;
 };
 
 struct iavf_security_ctx;
@@ -326,6 +327,9 @@ struct iavf_adapter {
uint32_t ptype_tbl[IAVF_MAX_PKT_TYPE] __rte_cache_min_aligned;
bool stopped;
bool closed;
+   bool no_poll;
+   eth_rx_burst_t rx_pkt_burst;
+   eth_tx_burst_t tx_pkt_burst;
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 5b2634a4e3..98cc5c8ea8 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -38,7 +38,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_NO_POLL_ON_LINK_DOWN_ARG "no-poll-on-link-down"
 uint64_t iavf_timestamp_dynflag;
 int iavf_timestamp_dynfield_offset = -1;
 
@@ -47,6 +47,7 @@ static const char * const iavf_valid_args[] = {
IAVF_QUANTA_SIZE_ARG,
IAVF_RESET_WATCHDOG_ARG,
IAVF_ENABLE_AUTO_RESET_ARG,
+   IAVF_NO_POLL_ON_LINK_DOWN_ARG,
NULL
 };
 
@@ -2291,6 +2292,7 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
struct rte_kvargs *kvlist;
int ret;
int watchdog_period = -1;
+   uint16_t no_poll_on_link_down;
 
if (!devargs)
return 0;
@@ -2324,6 +2326,15 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
else
ad->devargs.watchdog_period = watchdog_period;
 
+   ret = rte_kvargs_process(kvlist, IAVF_NO_POLL_ON_LINK_DOWN_ARG,
+&parse_u16, &no_poll_on_link_down);
+   if (ret)
+   goto bail;
+   if (no_poll_on_link_down == 0)
+   ad->devargs.no_poll_on_link_down = 0;
+   else
+   ad->devargs.no_poll_on_link_down = 1;
+
if (ad->devargs.quanta_size != 0 &&
(ad->devargs.quanta_size < 256 || ad->devargs.quanta_size > 4096 ||
 ad->devargs.quanta_size & 0x40)) {
@@ -2337,6 +2348,9 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
if (ret)
goto bail;
 
+   if (ad->devargs.auto_reset != 0)
+   ad->devargs.no_poll_on_link_down = 1;
+
 bail:
rte_kvargs_free(kvlist);
return ret;
diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index 0484988d13..7feadee7d0 100644
--- a/drivers/net/iavf/iavf_rxtx.c

[PATCH v4] net/iavf: support no data path polling mode

2023-10-16 Thread Mingjin Ye
Currently, during a PF to VF reset due to an action such as changing
trust settings on a VF, the DPDK application running with iavf PMD
loses connectivity, and the only solution is to reset the DPDK
application.

Instead of forcing a reset of the DPDK application to restore
connectivity, the iavf PMD driver handles the PF to VF reset event
normally by performing all necessary steps to bring the VF back
online.

To minimize downtime, a devargs "no-poll-on-link-down" is introduced
in iavf PMD. When this flag is set, the PMD switches to no-poll mode
when the link state is down (rx/tx bursts return to 0 immediately).
When the link state returns to normal, the PMD switches to normal
rx/tx burst state.

Signed-off-by: Mingjin Ye 
---
V3: Remove redundant code.
---
v4: Delete the git log note.
---
 doc/guides/nics/intel_vf.rst   |  3 ++
 drivers/net/iavf/iavf.h|  4 +++
 drivers/net/iavf/iavf_ethdev.c | 16 +-
 drivers/net/iavf/iavf_rxtx.c   | 53 ++
 drivers/net/iavf/iavf_rxtx.h   |  1 +
 drivers/net/iavf/iavf_vchnl.c  | 20 +
 6 files changed, 96 insertions(+), 1 deletion(-)

diff --git a/doc/guides/nics/intel_vf.rst b/doc/guides/nics/intel_vf.rst
index 7613e1c5e5..19c461c3de 100644
--- a/doc/guides/nics/intel_vf.rst
+++ b/doc/guides/nics/intel_vf.rst
@@ -104,6 +104,9 @@ For more detail on SR-IOV, please refer to the following 
documents:
 Enable vf auto-reset by setting the ``devargs`` parameter like ``-a 
18:01.0,auto_reset=1`` when IAVF is backed
 by an Intel?? E810 device or an Intel?? 700 Series Ethernet device.
 
+Enable vf no-poll-on-link-down by setting the ``devargs`` parameter like 
``-a 18:01.0,no-poll-on-link-down=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 FM1 Series VF 
infrastructure
 
^
 
diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 04774ce124..c115f3444e 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -308,6 +308,7 @@ struct iavf_devargs {
uint16_t quanta_size;
uint32_t watchdog_period;
uint8_t  auto_reset;
+   uint16_t no_poll_on_link_down;
 };
 
 struct iavf_security_ctx;
@@ -326,6 +327,9 @@ struct iavf_adapter {
uint32_t ptype_tbl[IAVF_MAX_PKT_TYPE] __rte_cache_min_aligned;
bool stopped;
bool closed;
+   bool no_poll;
+   eth_rx_burst_t rx_pkt_burst;
+   eth_tx_burst_t tx_pkt_burst;
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 5b2634a4e3..98cc5c8ea8 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -38,7 +38,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_NO_POLL_ON_LINK_DOWN_ARG "no-poll-on-link-down"
 uint64_t iavf_timestamp_dynflag;
 int iavf_timestamp_dynfield_offset = -1;
 
@@ -47,6 +47,7 @@ static const char * const iavf_valid_args[] = {
IAVF_QUANTA_SIZE_ARG,
IAVF_RESET_WATCHDOG_ARG,
IAVF_ENABLE_AUTO_RESET_ARG,
+   IAVF_NO_POLL_ON_LINK_DOWN_ARG,
NULL
 };
 
@@ -2291,6 +2292,7 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
struct rte_kvargs *kvlist;
int ret;
int watchdog_period = -1;
+   uint16_t no_poll_on_link_down;
 
if (!devargs)
return 0;
@@ -2324,6 +2326,15 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
else
ad->devargs.watchdog_period = watchdog_period;
 
+   ret = rte_kvargs_process(kvlist, IAVF_NO_POLL_ON_LINK_DOWN_ARG,
+&parse_u16, &no_poll_on_link_down);
+   if (ret)
+   goto bail;
+   if (no_poll_on_link_down == 0)
+   ad->devargs.no_poll_on_link_down = 0;
+   else
+   ad->devargs.no_poll_on_link_down = 1;
+
if (ad->devargs.quanta_size != 0 &&
(ad->devargs.quanta_size < 256 || ad->devargs.quanta_size > 4096 ||
 ad->devargs.quanta_size & 0x40)) {
@@ -2337,6 +2348,9 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
if (ret)
goto bail;
 
+   if (ad->devargs.auto_reset != 0)
+   ad->devargs.no_poll_on_link_down = 1;
+
 bail:
rte_kvargs_free(kvlist);
return ret;
diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index c6ef6af1d8..72263870a4 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -777,6 +777,7 @@ iavf_dev_tx_queue_setup(struct rte_eth_dev *dev,
IAVF_DEV_PRIVATE_TO_ADA

[PATCH v4] net/iavf: support no data path polling mode

2023-10-16 Thread Mingjin Ye
Currently, during a PF to VF reset due to an action such as changing
trust settings on a VF, the DPDK application running with iavf PMD
loses connectivity, and the only solution is to reset the DPDK
application.

Instead of forcing a reset of the DPDK application to restore
connectivity, the iavf PMD driver handles the PF to VF reset event
normally by performing all necessary steps to bring the VF back
online.

To minimize downtime, a devargs "no-poll-on-link-down" is introduced
in iavf PMD. When this flag is set, the PMD switches to no-poll mode
when the link state is down (rx/tx bursts return to 0 immediately).
When the link state returns to normal, the PMD switches to normal
rx/tx burst state.

Signed-off-by: Mingjin Ye 
---
V3: Remove redundant code.
---
v4: Delete the git log note.
---
 doc/guides/nics/intel_vf.rst   |  3 ++
 drivers/net/iavf/iavf.h|  4 +++
 drivers/net/iavf/iavf_ethdev.c | 16 +-
 drivers/net/iavf/iavf_rxtx.c   | 53 ++
 drivers/net/iavf/iavf_rxtx.h   |  1 +
 drivers/net/iavf/iavf_vchnl.c  | 20 +
 6 files changed, 96 insertions(+), 1 deletion(-)

diff --git a/doc/guides/nics/intel_vf.rst b/doc/guides/nics/intel_vf.rst
index e06d62a873..df298c6086 100644
--- a/doc/guides/nics/intel_vf.rst
+++ b/doc/guides/nics/intel_vf.rst
@@ -107,6 +107,9 @@ For more detail on SR-IOV, please refer to the following 
documents:
 when IAVF is backed by an Intel\ |reg| E810 device
 or an Intel\ |reg| 700 Series Ethernet device.
 
+Enable vf no-poll-on-link-down by setting the ``devargs`` parameter like 
``-a 18:01.0,no-poll-on-link-down=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 FM1 Series VF 
infrastructure
 
^
 
diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 04774ce124..c115f3444e 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -308,6 +308,7 @@ struct iavf_devargs {
uint16_t quanta_size;
uint32_t watchdog_period;
uint8_t  auto_reset;
+   uint16_t no_poll_on_link_down;
 };
 
 struct iavf_security_ctx;
@@ -326,6 +327,9 @@ struct iavf_adapter {
uint32_t ptype_tbl[IAVF_MAX_PKT_TYPE] __rte_cache_min_aligned;
bool stopped;
bool closed;
+   bool no_poll;
+   eth_rx_burst_t rx_pkt_burst;
+   eth_tx_burst_t tx_pkt_burst;
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 5b2634a4e3..98cc5c8ea8 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -38,7 +38,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_NO_POLL_ON_LINK_DOWN_ARG "no-poll-on-link-down"
 uint64_t iavf_timestamp_dynflag;
 int iavf_timestamp_dynfield_offset = -1;
 
@@ -47,6 +47,7 @@ static const char * const iavf_valid_args[] = {
IAVF_QUANTA_SIZE_ARG,
IAVF_RESET_WATCHDOG_ARG,
IAVF_ENABLE_AUTO_RESET_ARG,
+   IAVF_NO_POLL_ON_LINK_DOWN_ARG,
NULL
 };
 
@@ -2291,6 +2292,7 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
struct rte_kvargs *kvlist;
int ret;
int watchdog_period = -1;
+   uint16_t no_poll_on_link_down;
 
if (!devargs)
return 0;
@@ -2324,6 +2326,15 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
else
ad->devargs.watchdog_period = watchdog_period;
 
+   ret = rte_kvargs_process(kvlist, IAVF_NO_POLL_ON_LINK_DOWN_ARG,
+&parse_u16, &no_poll_on_link_down);
+   if (ret)
+   goto bail;
+   if (no_poll_on_link_down == 0)
+   ad->devargs.no_poll_on_link_down = 0;
+   else
+   ad->devargs.no_poll_on_link_down = 1;
+
if (ad->devargs.quanta_size != 0 &&
(ad->devargs.quanta_size < 256 || ad->devargs.quanta_size > 4096 ||
 ad->devargs.quanta_size & 0x40)) {
@@ -2337,6 +2348,9 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
if (ret)
goto bail;
 
+   if (ad->devargs.auto_reset != 0)
+   ad->devargs.no_poll_on_link_down = 1;
+
 bail:
rte_kvargs_free(kvlist);
return ret;
diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index c6ef6af1d8..72263870a4 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -777,6 +777,7 @@ iavf_dev_tx_queue_setup(struct rte_eth_dev *dev,
IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
struct iavf_info *vf =
  

[PATCH v5] net/iavf: data paths support no-polling mode

2023-10-19 Thread Mingjin Ye
In a scenario involving a hot firmware upgrade, the network device on
the host side need to be reset, potentially causing the hardware queues
to become unreachable. In a VM, continuing to run VF PMD Rx/Tx during
this process can lead to application crash.

The solution is to implement a 'no-polling' Rx and Tx wrapper. This
wrapper will check the link status and return immediately if the link
is down. This is especially important because the link down events will
continue to be sent from the PF to the VF during firmware hot upgrades,
and the event will always occur before the RESET IMPENDING event.

The no-polling rx/tx mechanism will only be active when the
devarg "no-poll-on-link-down" is enabled. This devarg is typically
recommended for use in this specific hot upgrade scenario.
Ideally, "no-poll-on-link-down" should be used in conjunction with
the devarg "auto-reset" to provide a seamless and user-friendly
experience within the VM.

Signed-off-by: Mingjin Ye 
---
V3: Remove redundant code.
---
v4: Delete the git log note.
---
v5: Optimize the commit log
---
 doc/guides/nics/intel_vf.rst   |  3 ++
 drivers/net/iavf/iavf.h|  4 +++
 drivers/net/iavf/iavf_ethdev.c | 16 +-
 drivers/net/iavf/iavf_rxtx.c   | 53 ++
 drivers/net/iavf/iavf_rxtx.h   |  1 +
 drivers/net/iavf/iavf_vchnl.c  | 20 +
 6 files changed, 96 insertions(+), 1 deletion(-)

diff --git a/doc/guides/nics/intel_vf.rst b/doc/guides/nics/intel_vf.rst
index e06d62a873..df298c6086 100644
--- a/doc/guides/nics/intel_vf.rst
+++ b/doc/guides/nics/intel_vf.rst
@@ -107,6 +107,9 @@ For more detail on SR-IOV, please refer to the following 
documents:
 when IAVF is backed by an Intel\ |reg| E810 device
 or an Intel\ |reg| 700 Series Ethernet device.
 
+Enable vf no-poll-on-link-down by setting the ``devargs`` parameter like 
``-a 18:01.0,no-poll-on-link-down=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 FM1 Series VF 
infrastructure
 
^
 
diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 04774ce124..c115f3444e 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -308,6 +308,7 @@ struct iavf_devargs {
uint16_t quanta_size;
uint32_t watchdog_period;
uint8_t  auto_reset;
+   uint16_t no_poll_on_link_down;
 };
 
 struct iavf_security_ctx;
@@ -326,6 +327,9 @@ struct iavf_adapter {
uint32_t ptype_tbl[IAVF_MAX_PKT_TYPE] __rte_cache_min_aligned;
bool stopped;
bool closed;
+   bool no_poll;
+   eth_rx_burst_t rx_pkt_burst;
+   eth_tx_burst_t tx_pkt_burst;
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 5b2634a4e3..98cc5c8ea8 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -38,7 +38,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_NO_POLL_ON_LINK_DOWN_ARG "no-poll-on-link-down"
 uint64_t iavf_timestamp_dynflag;
 int iavf_timestamp_dynfield_offset = -1;
 
@@ -47,6 +47,7 @@ static const char * const iavf_valid_args[] = {
IAVF_QUANTA_SIZE_ARG,
IAVF_RESET_WATCHDOG_ARG,
IAVF_ENABLE_AUTO_RESET_ARG,
+   IAVF_NO_POLL_ON_LINK_DOWN_ARG,
NULL
 };
 
@@ -2291,6 +2292,7 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
struct rte_kvargs *kvlist;
int ret;
int watchdog_period = -1;
+   uint16_t no_poll_on_link_down;
 
if (!devargs)
return 0;
@@ -2324,6 +2326,15 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
else
ad->devargs.watchdog_period = watchdog_period;
 
+   ret = rte_kvargs_process(kvlist, IAVF_NO_POLL_ON_LINK_DOWN_ARG,
+&parse_u16, &no_poll_on_link_down);
+   if (ret)
+   goto bail;
+   if (no_poll_on_link_down == 0)
+   ad->devargs.no_poll_on_link_down = 0;
+   else
+   ad->devargs.no_poll_on_link_down = 1;
+
if (ad->devargs.quanta_size != 0 &&
(ad->devargs.quanta_size < 256 || ad->devargs.quanta_size > 4096 ||
 ad->devargs.quanta_size & 0x40)) {
@@ -2337,6 +2348,9 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
if (ret)
goto bail;
 
+   if (ad->devargs.auto_reset != 0)
+   ad->devargs.no_poll_on_link_down = 1;
+
 bail:
rte_kvargs_free(kvlist);
return ret;
diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/i

[PATCH] net/iavf: fix crash on closing representor ports

2023-10-26 Thread Mingjin Ye
Since the representor port needs to access the resources of the
associated DCF when it is closed. Therefore, the correct close
port operation is to close all the representor ports first, and
then close the associated DCF port.

If the DCF port is closed before the representor port on pmd exit.
This will result in accessing freed resources and eventually a
core dump will occur.

This patch fixes this issue by notifying all presentor ports
that DCF is not accessible when the DCF port is closed.
And when the presentor port is closed, it determines if the DCF
resources are accessible. If it can't be accessed, it will
report an error and return.

Fixes: 5674465a32c8 ("net/ice: add DCF VLAN handling")
Fixes: 295968d17407 ("ethdev: add namespace")
Fixes: da9cdcd1f372 ("net/ice: fix crash on representor port closing")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 drivers/net/ice/ice_dcf_ethdev.h |  1 +
 drivers/net/ice/ice_dcf_vf_representor.c | 12 +++-
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ice/ice_dcf_ethdev.h b/drivers/net/ice/ice_dcf_ethdev.h
index 4baaec4b8b..d94ef10244 100644
--- a/drivers/net/ice/ice_dcf_ethdev.h
+++ b/drivers/net/ice/ice_dcf_ethdev.h
@@ -60,6 +60,7 @@ struct ice_dcf_vf_repr {
struct rte_ether_addr mac_addr;
uint16_t switch_domain_id;
uint16_t vf_id;
+   bool dcf_valid;
 
struct ice_dcf_vlan outer_vlan_info; /* DCF always handle outer VLAN */
 };
diff --git a/drivers/net/ice/ice_dcf_vf_representor.c 
b/drivers/net/ice/ice_dcf_vf_representor.c
index b9fcfc80ad..b4a94427df 100644
--- a/drivers/net/ice/ice_dcf_vf_representor.c
+++ b/drivers/net/ice/ice_dcf_vf_representor.c
@@ -45,6 +45,8 @@ ice_dcf_vf_repr_dev_start(struct rte_eth_dev *dev)
 static int
 ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev)
 {
+   struct ice_dcf_vf_repr *repr = dev->data->dev_private;
+   repr->dcf_valid = false;
dev->data->dev_link.link_status = RTE_ETH_LINK_DOWN;
 
return 0;
@@ -111,14 +113,13 @@ ice_dcf_vf_repr_link_update(__rte_unused struct 
rte_eth_dev *ethdev,
 static __rte_always_inline struct ice_dcf_hw *
 ice_dcf_vf_repr_hw(struct ice_dcf_vf_repr *repr)
 {
-   struct ice_dcf_adapter *dcf_adapter =
-   repr->dcf_eth_dev->data->dev_private;
-
-   if (!dcf_adapter) {
+   struct ice_dcf_adapter *dcf_adapter;
+   if (!repr->dcf_valid) {
PMD_DRV_LOG(ERR, "DCF for VF representor has been released\n");
return NULL;
}
-
+dcf_adapter =
+   repr->dcf_eth_dev->data->dev_private;
return &dcf_adapter->real_hw;
 }
 
@@ -414,6 +415,7 @@ ice_dcf_vf_repr_init(struct rte_eth_dev *vf_rep_eth_dev, 
void *init_param)
repr->dcf_eth_dev = param->dcf_eth_dev;
repr->switch_domain_id = param->switch_domain_id;
repr->vf_id = param->vf_id;
+   repr->dcf_valid = true;
repr->outer_vlan_info.port_vlan_ena = false;
repr->outer_vlan_info.stripping_ena = false;
repr->outer_vlan_info.tpid = RTE_ETHER_TYPE_VLAN;
-- 
2.25.1



[PATCH v2] app/dma-perf: fix lcores array out of bounds access

2023-10-26 Thread Mingjin Ye
The default size of the lcores array in the lcore dma map
is MAX_WORKER_NB. However, when parsing configuration
parameters, MAX_LCORE_NB is used as a constraint.
Since MAX_LCORE_NB is greater than MAX_WORKER_NB, this
causes array access to go out of bounds when the value
of the `lcore_dma/lcore` configuration item in the
parameter file is greater than MAX_WORKER_NB.

This patch fixes the issue by removing the MAX_LCORE_NB
macro and using MAX_WORKER_NB consistently.

Fixes: 623dc9364dc6 ("app/dma-perf: introduce DMA performance test")

Signed-off-by: Mingjin Ye 
---
v2:A better solution.
---
 app/test-dma-perf/main.c | 4 ++--
 app/test-dma-perf/main.h | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/app/test-dma-perf/main.c b/app/test-dma-perf/main.c
index e5bccc27da..5f8bab8f45 100644
--- a/app/test-dma-perf/main.c
+++ b/app/test-dma-perf/main.c
@@ -177,7 +177,7 @@ parse_lcore(struct test_configure *test_case, const char 
*value)
 
char *token = strtok(input, ", ");
while (token != NULL) {
-   if (lcore_dma_map->cnt >= MAX_LCORE_NB) {
+   if (lcore_dma_map->cnt >= MAX_WORKER_NB) {
free(input);
return -1;
}
@@ -248,7 +248,7 @@ parse_lcore_dma(struct test_configure *test_case, const 
char *value)
}
 
lcore_dma_map = &test_case->lcore_dma_map;
-   if (lcore_dma_map->cnt >= MAX_LCORE_NB) {
+   if (lcore_dma_map->cnt >= MAX_WORKER_NB) {
fprintf(stderr, "lcores count error\n");
ret = -1;
break;
diff --git a/app/test-dma-perf/main.h b/app/test-dma-perf/main.h
index f65e264378..62085e6e8f 100644
--- a/app/test-dma-perf/main.h
+++ b/app/test-dma-perf/main.h
@@ -14,7 +14,6 @@
 #define MAX_OUTPUT_STR_LEN 512
 
 #define MAX_DMA_NB 128
-#define MAX_LCORE_NB 256
 
 extern char output_str[MAX_WORKER_NB + 1][MAX_OUTPUT_STR_LEN];
 
-- 
2.25.1



[PATCH] net/ice: support vxlan gpe tunnel offload

2022-10-17 Thread Mingjin Ye
PMD does not support VXLAN_GPE tunnel offloading, therefore, it will cause
the tx queues overflow and stop working when sending such packets.

This patch adds support for the vxlan gpe.

Fixes: daa02b5cddbb ("mbuf: add namespace to offload flags")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 drivers/net/ice/ice_rxtx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c
index 697251c603..0a2b0376ac 100644
--- a/drivers/net/ice/ice_rxtx.c
+++ b/drivers/net/ice/ice_rxtx.c
@@ -2690,6 +2690,7 @@ ice_parse_tunneling_params(uint64_t ol_flags,
/* for non UDP / GRE tunneling, set to 00b */
break;
case RTE_MBUF_F_TX_TUNNEL_VXLAN:
+   case RTE_MBUF_F_TX_TUNNEL_VXLAN_GPE:
case RTE_MBUF_F_TX_TUNNEL_GTP:
case RTE_MBUF_F_TX_TUNNEL_GENEVE:
*cd_tunneling |= ICE_TXD_CTX_UDP_TUNNELING;
-- 
2.34.1



[PATCH v2 1/2] app/testpmd: fix vlan offload of rxq

2022-10-19 Thread Mingjin Ye
After setting vlan offload in testpmd, the result is not updated
to rxq. Therefore, the queue needs to be reconfigured after
executing the "vlan offload" related commands.

Fixes: a47aa8b97afe ("app/testpmd: add vlan offload support")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 app/test-pmd/cmdline.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 17be2de402..ce125f549f 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -4133,6 +4133,7 @@ cmd_vlan_offload_parsed(void *parsed_result,
else
vlan_extend_set(port_id, on);
 
+   cmd_reconfig_device_queue(port_id, 1, 1);
return;
 }
 
-- 
2.34.1



[PATCH v2 2/2] net/ice: fix vlan offload

2022-10-19 Thread Mingjin Ye
The vlan tag and flag in Rx descriptor are not processed on vector path,
then the upper application cann't fetch the tci from mbuf.

This commit add handling of vlan RX offloading.

Fixes: c68a52b8b38c ("net/ice: support vector SSE in Rx")
Fixes: ece1f8a8f1c8 ("net/ice: switch to flexible descriptor in SSE path")
Fixes: 12443386a0b0 ("net/ice: support flex Rx descriptor RxDID22")
Fixes: 214f452f7d5f ("net/ice: add AVX2 offload Rx")
Fixes: 7f85d5ebcfe1 ("net/ice: add AVX512 vector path")
Fixes: 295968d17407 ("ethdev: add namespace")
Fixes: 808a17b3c1e6 ("net/ice: add Rx AVX512 offload path")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 drivers/net/ice/ice_rxtx_vec_avx2.c   | 136 +-
 drivers/net/ice/ice_rxtx_vec_avx512.c | 155 +-
 drivers/net/ice/ice_rxtx_vec_sse.c| 131 --
 3 files changed, 333 insertions(+), 89 deletions(-)

diff --git a/drivers/net/ice/ice_rxtx_vec_avx2.c 
b/drivers/net/ice/ice_rxtx_vec_avx2.c
index 31d6af42fd..6ebc9dab9b 100644
--- a/drivers/net/ice/ice_rxtx_vec_avx2.c
+++ b/drivers/net/ice/ice_rxtx_vec_avx2.c
@@ -238,6 +238,20 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, 
struct rte_mbuf **rx_pkts,
RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED,
RTE_MBUF_F_RX_RSS_HASH, 0);
 
+   const __m256i l2tag2_flags_shuf =
+   _mm256_set_epi8(0, 0, 0, 0,
+   0, 0, 0, 0,
+   0, 0, 0, 0,
+   0, 0, 0, 0,
+   /* end up 128-bits */
+   0, 0, 0, 0,
+   0, 0, 0, 0,
+   0, 0, 0, 0,
+   0, 0,
+   RTE_MBUF_F_RX_VLAN |
+   RTE_MBUF_F_RX_VLAN_STRIPPED,
+   0);
+
RTE_SET_USED(avx_aligned); /* for 32B descriptors we don't use this */
 
uint16_t i, received;
@@ -474,7 +488,7 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, 
struct rte_mbuf **rx_pkts,
 * will cause performance drop to get into this context.
 */
if 
(rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
-   RTE_ETH_RX_OFFLOAD_RSS_HASH) {
+   (RTE_ETH_RX_OFFLOAD_RSS_HASH | 
RTE_ETH_RX_OFFLOAD_VLAN)) {
/* load bottom half of every 32B desc */
const __m128i raw_desc_bh7 =
_mm_load_si128
@@ -529,33 +543,99 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, 
struct rte_mbuf **rx_pkts,
 * to shift the 32b RSS hash value to the
 * highest 32b of each 128b before mask
 */
-   __m256i rss_hash6_7 =
-   _mm256_slli_epi64(raw_desc_bh6_7, 32);
-   __m256i rss_hash4_5 =
-   _mm256_slli_epi64(raw_desc_bh4_5, 32);
-   __m256i rss_hash2_3 =
-   _mm256_slli_epi64(raw_desc_bh2_3, 32);
-   __m256i rss_hash0_1 =
-   _mm256_slli_epi64(raw_desc_bh0_1, 32);
-
-   __m256i rss_hash_msk =
-   _mm256_set_epi32(0x, 0, 0, 0,
-0x, 0, 0, 0);
-
-   rss_hash6_7 = _mm256_and_si256
-   (rss_hash6_7, rss_hash_msk);
-   rss_hash4_5 = _mm256_and_si256
-   (rss_hash4_5, rss_hash_msk);
-   rss_hash2_3 = _mm256_and_si256
-   (rss_hash2_3, rss_hash_msk);
-   rss_hash0_1 = _mm256_and_si256
-   (rss_hash0_1, rss_hash_msk);
-
-   mb6_7 = _mm256_or_si256(mb6_7, rss_hash6_7);
-   mb4_5 = _mm256_or_si256(mb4_5, rss_hash4_5);
-   mb2_3 = _mm256_or_si256(mb2_3, rss_hash2_3);
-   mb0_1 = _mm256_or_si256(mb0_1, rss_hash0_1);
-   } /* if() on RSS hash parsing */
+   if 
(rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
+   RTE_ETH_RX_OFFLOAD_RSS_HASH) {
+  

[PATCH] net/i40e: fix outer checksum flags

2022-10-20 Thread Mingjin Ye
When receiving tunnel packets, the testpmd terminal output log shows
'ol_flags' value always as 'RTE_MBUF_F_RX_OUTER_L4_CKSUM_UNKNOWN',
but what we expected should be 'RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD'
or 'RTE_MBUF_F_RX_OUTER_L4_CKSUM_BAD'.

Adding 'RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD' and
'RTE_MBUF_F_RX_OUTER_L4_CKSUM_BAD' flags for normal path,
which are also added to 'l3_l4_flags_shuf' for AVX2 and AVX512
vector path and 'cksum_flags' for SSE vector path to ensure
the 'ol_flags' can match correct flags.

Fixes: 4861cde46116 ("i40e: new poll mode driver")
Fixes: daa02b5cddbb ("mbuf: add namespace to offload flags")
Fixes: e6a6a138919f ("net/i40e: add AVX512 vector path")
Fixes: dafadd73762e ("net/i40e: add AVX2 Rx function")
Fixes: 9966a00a0688 ("net/i40e: enable bad checksum flags in vector Rx")
Fixes: f3a85f4ce04d ("net/i40e: fix checksum flag in x86 vector Rx")
Fixes: f4356d7ca168 ("net/i40e: eliminate mbuf write on rearm")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 drivers/net/i40e/i40e_rxtx.c|   6 +-
 drivers/net/i40e/i40e_rxtx_vec_avx2.c   | 119 +---
 drivers/net/i40e/i40e_rxtx_vec_avx512.c | 113 --
 drivers/net/i40e/i40e_rxtx_vec_sse.c|  73 ++-
 4 files changed, 228 insertions(+), 83 deletions(-)

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 788ffb51c2..e8903007f0 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -169,7 +169,9 @@ i40e_rxd_error_to_pkt_flags(uint64_t qword)
 
 #define I40E_RX_ERR_BITS 0x3f
if (likely((error_bits & I40E_RX_ERR_BITS) == 0)) {
-   flags |= (RTE_MBUF_F_RX_IP_CKSUM_GOOD | 
RTE_MBUF_F_RX_L4_CKSUM_GOOD);
+   flags |= (RTE_MBUF_F_RX_IP_CKSUM_GOOD |
+   RTE_MBUF_F_RX_L4_CKSUM_GOOD |
+   RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD);
return flags;
}
 
@@ -185,6 +187,8 @@ i40e_rxd_error_to_pkt_flags(uint64_t qword)
 
if (unlikely(error_bits & (1 << I40E_RX_DESC_ERROR_EIPE_SHIFT)))
flags |= RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD;
+   else
+   flags |= RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD;
 
return flags;
 }
diff --git a/drivers/net/i40e/i40e_rxtx_vec_avx2.c 
b/drivers/net/i40e/i40e_rxtx_vec_avx2.c
index 761edb9d20..348dad4293 100644
--- a/drivers/net/i40e/i40e_rxtx_vec_avx2.c
+++ b/drivers/net/i40e/i40e_rxtx_vec_avx2.c
@@ -202,7 +202,7 @@ _recv_raw_pkts_vec_avx2(struct i40e_rx_queue *rxq, struct 
rte_mbuf **rx_pkts,
 * field (bits 22-24) are for IP/L4 checksum errors
 */
const __m256i flags_mask = _mm256_set1_epi32(
-   (1 << 2) | (1 << 11) | (3 << 12) | (7 << 22));
+   (0xF << 4) | (1 << 12) | (1 << 13));
/*
 * data to be shuffled by result of flag mask. If VLAN bit is set,
 * (bit 2), then position 4 in this array will be used in the
@@ -228,39 +228,83 @@ _recv_raw_pkts_vec_avx2(struct i40e_rx_queue *rxq, struct 
rte_mbuf **rx_pkts,
 * data to be shuffled by the result of the flags mask shifted by 22
 * bits.  This gives use the l3_l4 flags.
 */
-   const __m256i l3_l4_flags_shuf = _mm256_set_epi8(0, 0, 0, 0, 0, 0, 0, 0,
-   /* shift right 1 bit to make sure it not exceed 255 */
-   (RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD | 
RTE_MBUF_F_RX_L4_CKSUM_BAD  |
-RTE_MBUF_F_RX_IP_CKSUM_BAD) >> 1,
-   (RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD | 
RTE_MBUF_F_RX_L4_CKSUM_BAD  |
-RTE_MBUF_F_RX_IP_CKSUM_GOOD) >> 1,
-   (RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD | 
RTE_MBUF_F_RX_L4_CKSUM_GOOD |
-RTE_MBUF_F_RX_IP_CKSUM_BAD) >> 1,
-   (RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD | 
RTE_MBUF_F_RX_L4_CKSUM_GOOD |
-RTE_MBUF_F_RX_IP_CKSUM_GOOD) >> 1,
-   (RTE_MBUF_F_RX_L4_CKSUM_BAD  | 
RTE_MBUF_F_RX_IP_CKSUM_BAD) >> 1,
-   (RTE_MBUF_F_RX_L4_CKSUM_BAD  | 
RTE_MBUF_F_RX_IP_CKSUM_GOOD) >> 1,
-   (RTE_MBUF_F_RX_L4_CKSUM_GOOD | 
RTE_MBUF_F_RX_IP_CKSUM_BAD) >> 1,
-   (RTE_MBUF_F_RX_L4_CKSUM_GOOD | 
RTE_MBUF_F_RX_IP_CKSUM_GOOD) >> 1,
-   /* second 128-bits */
-   0, 0, 0, 0, 0, 0, 0, 0,
-   (RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD | 
RTE_MBUF_F_RX_L4_CKSUM_BAD  |
-RTE_MBUF_F_RX_IP_CKSUM_BAD) >> 1,
-   (RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD | 
RTE_MBUF_F_RX_L4_CKSUM_BAD  |
-RTE

[PATCH v2] net/ice: support vxlan gpe tunnel offload

2022-10-20 Thread Mingjin Ye
PMD tx path does not support VXLAN_GPE tunnel offload. Because it does not
process RTE_MBUF_F_TX_TUNNEL_VXLAN_GPE flag in mbuf, and then the "L4TUNT"
field will not be set in Tx context descriptor.

This patch is to add the RTE_MBUF_F_TX_TUNNEL_VXLAN_GPE flag to
support Tx VXLAN_GPE offload under the scenario if the offload tso
and VXLAN_GPE tunnel are both required, so that it would avoid
tx queue overflowing.

Fixes: daa02b5cddbb ("mbuf: add namespace to offload flags")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 drivers/net/ice/ice_rxtx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c
index 697251c603..0a2b0376ac 100644
--- a/drivers/net/ice/ice_rxtx.c
+++ b/drivers/net/ice/ice_rxtx.c
@@ -2690,6 +2690,7 @@ ice_parse_tunneling_params(uint64_t ol_flags,
/* for non UDP / GRE tunneling, set to 00b */
break;
case RTE_MBUF_F_TX_TUNNEL_VXLAN:
+   case RTE_MBUF_F_TX_TUNNEL_VXLAN_GPE:
case RTE_MBUF_F_TX_TUNNEL_GTP:
case RTE_MBUF_F_TX_TUNNEL_GENEVE:
*cd_tunneling |= ICE_TXD_CTX_UDP_TUNNELING;
-- 
2.34.1



[PATCH v3 1/2] app/testpmd: fix vlan offload of rxq

2022-10-21 Thread Mingjin Ye
After setting vlan offload in testpmd, the result is not updated
to rxq. Therefore, the queue needs to be reconfigured after
executing the "vlan offload" related commands.

Fixes: a47aa8b97afe ("app/testpmd: add vlan offload support")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 app/test-pmd/cmdline.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 17be2de402..ce125f549f 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -4133,6 +4133,7 @@ cmd_vlan_offload_parsed(void *parsed_result,
else
vlan_extend_set(port_id, on);
 
+   cmd_reconfig_device_queue(port_id, 1, 1);
return;
 }
 
-- 
2.34.1



[PATCH v3 2/2] net/ice: fix vlan offload

2022-10-21 Thread Mingjin Ye
The vlan tag and flag in Rx descriptor are not processed on vector path,
then the upper application cann't fetch the tci from mbuf.

This commit add handling of vlan RX offloading.

Fixes: c68a52b8b38c ("net/ice: support vector SSE in Rx")
Fixes: ece1f8a8f1c8 ("net/ice: switch to flexible descriptor in SSE path")
Fixes: 12443386a0b0 ("net/ice: support flex Rx descriptor RxDID22")
Fixes: 214f452f7d5f ("net/ice: add AVX2 offload Rx")
Fixes: 7f85d5ebcfe1 ("net/ice: add AVX512 vector path")
Fixes: 295968d17407 ("ethdev: add namespace")
Fixes: 808a17b3c1e6 ("net/ice: add Rx AVX512 offload path")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 

v3:
* Fix macros in ice_rxtx_vec_sse.c source file.
---
 drivers/net/ice/ice_rxtx_vec_avx2.c   | 136 +-
 drivers/net/ice/ice_rxtx_vec_avx512.c | 155 +-
 drivers/net/ice/ice_rxtx_vec_sse.c| 131 --
 3 files changed, 333 insertions(+), 89 deletions(-)

diff --git a/drivers/net/ice/ice_rxtx_vec_avx2.c 
b/drivers/net/ice/ice_rxtx_vec_avx2.c
index 31d6af42fd..6ebc9dab9b 100644
--- a/drivers/net/ice/ice_rxtx_vec_avx2.c
+++ b/drivers/net/ice/ice_rxtx_vec_avx2.c
@@ -238,6 +238,20 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, 
struct rte_mbuf **rx_pkts,
RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED,
RTE_MBUF_F_RX_RSS_HASH, 0);
 
+   const __m256i l2tag2_flags_shuf =
+   _mm256_set_epi8(0, 0, 0, 0,
+   0, 0, 0, 0,
+   0, 0, 0, 0,
+   0, 0, 0, 0,
+   /* end up 128-bits */
+   0, 0, 0, 0,
+   0, 0, 0, 0,
+   0, 0, 0, 0,
+   0, 0,
+   RTE_MBUF_F_RX_VLAN |
+   RTE_MBUF_F_RX_VLAN_STRIPPED,
+   0);
+
RTE_SET_USED(avx_aligned); /* for 32B descriptors we don't use this */
 
uint16_t i, received;
@@ -474,7 +488,7 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, 
struct rte_mbuf **rx_pkts,
 * will cause performance drop to get into this context.
 */
if 
(rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
-   RTE_ETH_RX_OFFLOAD_RSS_HASH) {
+   (RTE_ETH_RX_OFFLOAD_RSS_HASH | 
RTE_ETH_RX_OFFLOAD_VLAN)) {
/* load bottom half of every 32B desc */
const __m128i raw_desc_bh7 =
_mm_load_si128
@@ -529,33 +543,99 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, 
struct rte_mbuf **rx_pkts,
 * to shift the 32b RSS hash value to the
 * highest 32b of each 128b before mask
 */
-   __m256i rss_hash6_7 =
-   _mm256_slli_epi64(raw_desc_bh6_7, 32);
-   __m256i rss_hash4_5 =
-   _mm256_slli_epi64(raw_desc_bh4_5, 32);
-   __m256i rss_hash2_3 =
-   _mm256_slli_epi64(raw_desc_bh2_3, 32);
-   __m256i rss_hash0_1 =
-   _mm256_slli_epi64(raw_desc_bh0_1, 32);
-
-   __m256i rss_hash_msk =
-   _mm256_set_epi32(0x, 0, 0, 0,
-0x, 0, 0, 0);
-
-   rss_hash6_7 = _mm256_and_si256
-   (rss_hash6_7, rss_hash_msk);
-   rss_hash4_5 = _mm256_and_si256
-   (rss_hash4_5, rss_hash_msk);
-   rss_hash2_3 = _mm256_and_si256
-   (rss_hash2_3, rss_hash_msk);
-   rss_hash0_1 = _mm256_and_si256
-   (rss_hash0_1, rss_hash_msk);
-
-   mb6_7 = _mm256_or_si256(mb6_7, rss_hash6_7);
-   mb4_5 = _mm256_or_si256(mb4_5, rss_hash4_5);
-   mb2_3 = _mm256_or_si256(mb2_3, rss_hash2_3);
-   mb0_1 = _mm256_or_si256(mb0_1, rss_hash0_1);
-   } /* if() on RSS hash parsing */
+   if 
(rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
+ 

[PATCH v4 1/2] app/testpmd: fix vlan offload of rxq

2022-10-24 Thread Mingjin Ye
After setting vlan offload in testpmd, the result is not updated
to rxq. Therefore, the queue needs to be reconfigured after
executing the "vlan offload" related commands.

Fixes: a47aa8b97afe ("app/testpmd: add vlan offload support")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 app/test-pmd/cmdline.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 17be2de402..ce125f549f 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -4133,6 +4133,7 @@ cmd_vlan_offload_parsed(void *parsed_result,
else
vlan_extend_set(port_id, on);
 
+   cmd_reconfig_device_queue(port_id, 1, 1);
return;
 }
 
-- 
2.34.1



[PATCH v4 2/2] net/ice: fix vlan offload

2022-10-24 Thread Mingjin Ye
The vlan tag and flag in Rx descriptor are not processed on vector path,
then the upper application cann't fetch the tci from mbuf.

This commit add handling of vlan RX offloading.

Fixes: c68a52b8b38c ("net/ice: support vector SSE in Rx")
Fixes: ece1f8a8f1c8 ("net/ice: switch to flexible descriptor in SSE path")
Fixes: 12443386a0b0 ("net/ice: support flex Rx descriptor RxDID22")
Fixes: 214f452f7d5f ("net/ice: add AVX2 offload Rx")
Fixes: 7f85d5ebcfe1 ("net/ice: add AVX512 vector path")
Fixes: 295968d17407 ("ethdev: add namespace")
Fixes: 808a17b3c1e6 ("net/ice: add Rx AVX512 offload path")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 

v3:
* Fix macros in ice_rxtx_vec_sse.c source file.
v4:
* Fix ice_rx_desc_to_olflags_v define in ice_rxtx_vec_sse.c source file.
---
 drivers/net/ice/ice_rxtx_vec_avx2.c   | 136 +-
 drivers/net/ice/ice_rxtx_vec_avx512.c | 156 +-
 drivers/net/ice/ice_rxtx_vec_sse.c| 132 --
 3 files changed, 335 insertions(+), 89 deletions(-)

diff --git a/drivers/net/ice/ice_rxtx_vec_avx2.c 
b/drivers/net/ice/ice_rxtx_vec_avx2.c
index 31d6af42fd..888666f206 100644
--- a/drivers/net/ice/ice_rxtx_vec_avx2.c
+++ b/drivers/net/ice/ice_rxtx_vec_avx2.c
@@ -238,6 +238,7 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, 
struct rte_mbuf **rx_pkts,
RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED,
RTE_MBUF_F_RX_RSS_HASH, 0);
 
+
RTE_SET_USED(avx_aligned); /* for 32B descriptors we don't use this */
 
uint16_t i, received;
@@ -474,7 +475,7 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, 
struct rte_mbuf **rx_pkts,
 * will cause performance drop to get into this context.
 */
if 
(rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
-   RTE_ETH_RX_OFFLOAD_RSS_HASH) {
+   (RTE_ETH_RX_OFFLOAD_RSS_HASH | 
RTE_ETH_RX_OFFLOAD_VLAN)) {
/* load bottom half of every 32B desc */
const __m128i raw_desc_bh7 =
_mm_load_si128
@@ -529,33 +530,112 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, 
struct rte_mbuf **rx_pkts,
 * to shift the 32b RSS hash value to the
 * highest 32b of each 128b before mask
 */
-   __m256i rss_hash6_7 =
-   _mm256_slli_epi64(raw_desc_bh6_7, 32);
-   __m256i rss_hash4_5 =
-   _mm256_slli_epi64(raw_desc_bh4_5, 32);
-   __m256i rss_hash2_3 =
-   _mm256_slli_epi64(raw_desc_bh2_3, 32);
-   __m256i rss_hash0_1 =
-   _mm256_slli_epi64(raw_desc_bh0_1, 32);
-
-   __m256i rss_hash_msk =
-   _mm256_set_epi32(0x, 0, 0, 0,
-0x, 0, 0, 0);
-
-   rss_hash6_7 = _mm256_and_si256
-   (rss_hash6_7, rss_hash_msk);
-   rss_hash4_5 = _mm256_and_si256
-   (rss_hash4_5, rss_hash_msk);
-   rss_hash2_3 = _mm256_and_si256
-   (rss_hash2_3, rss_hash_msk);
-   rss_hash0_1 = _mm256_and_si256
-   (rss_hash0_1, rss_hash_msk);
-
-   mb6_7 = _mm256_or_si256(mb6_7, rss_hash6_7);
-   mb4_5 = _mm256_or_si256(mb4_5, rss_hash4_5);
-   mb2_3 = _mm256_or_si256(mb2_3, rss_hash2_3);
-   mb0_1 = _mm256_or_si256(mb0_1, rss_hash0_1);
-   } /* if() on RSS hash parsing */
+   if 
(rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
+   RTE_ETH_RX_OFFLOAD_RSS_HASH) {
+   __m256i rss_hash6_7 =
+   
_mm256_slli_epi64(raw_desc_bh6_7, 32);
+   __m256i rss_hash4_5 =
+   
_mm256_slli_epi64(raw_desc_bh4_5, 32);
+   __m256i rss_hash2_3 =
+   
_mm256_slli_epi64(raw_desc_bh2_3, 32);
+  

[PATCH v4 1/2] app/testpmd: fix vlan offload of rxq

2022-10-24 Thread Mingjin Ye
After setting vlan offload in testpmd, the result is not updated
to rxq. Therefore, the queue needs to be reconfigured after
executing the "vlan offload" related commands.

Fixes: a47aa8b97afe ("app/testpmd: add vlan offload support")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 app/test-pmd/cmdline.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 17be2de402..ce125f549f 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -4133,6 +4133,7 @@ cmd_vlan_offload_parsed(void *parsed_result,
else
vlan_extend_set(port_id, on);
 
+   cmd_reconfig_device_queue(port_id, 1, 1);
return;
 }
 
-- 
2.34.1



[PATCH v4 2/2] net/ice: fix vlan offload

2022-10-24 Thread Mingjin Ye
The vlan tag and flag in Rx descriptor are not processed on vector path,
then the upper application cann't fetch the tci from mbuf.

This commit add handling of vlan RX offloading.

Fixes: c68a52b8b38c ("net/ice: support vector SSE in Rx")
Fixes: ece1f8a8f1c8 ("net/ice: switch to flexible descriptor in SSE path")
Fixes: 12443386a0b0 ("net/ice: support flex Rx descriptor RxDID22")
Fixes: 214f452f7d5f ("net/ice: add AVX2 offload Rx")
Fixes: 7f85d5ebcfe1 ("net/ice: add AVX512 vector path")
Fixes: 295968d17407 ("ethdev: add namespace")
Fixes: 808a17b3c1e6 ("net/ice: add Rx AVX512 offload path")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 

v3:
* Fix macros in ice_rxtx_vec_sse.c source file.
v4:
* Fix ice_rx_desc_to_olflags_v define in ice_rxtx_vec_sse.c source file.
---
 drivers/net/ice/ice_rxtx_vec_avx2.c   | 136 +-
 drivers/net/ice/ice_rxtx_vec_avx512.c | 156 +-
 drivers/net/ice/ice_rxtx_vec_sse.c| 133 --
 3 files changed, 335 insertions(+), 90 deletions(-)

diff --git a/drivers/net/ice/ice_rxtx_vec_avx2.c 
b/drivers/net/ice/ice_rxtx_vec_avx2.c
index 31d6af42fd..888666f206 100644
--- a/drivers/net/ice/ice_rxtx_vec_avx2.c
+++ b/drivers/net/ice/ice_rxtx_vec_avx2.c
@@ -238,6 +238,7 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, 
struct rte_mbuf **rx_pkts,
RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED,
RTE_MBUF_F_RX_RSS_HASH, 0);
 
+
RTE_SET_USED(avx_aligned); /* for 32B descriptors we don't use this */
 
uint16_t i, received;
@@ -474,7 +475,7 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, 
struct rte_mbuf **rx_pkts,
 * will cause performance drop to get into this context.
 */
if 
(rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
-   RTE_ETH_RX_OFFLOAD_RSS_HASH) {
+   (RTE_ETH_RX_OFFLOAD_RSS_HASH | 
RTE_ETH_RX_OFFLOAD_VLAN)) {
/* load bottom half of every 32B desc */
const __m128i raw_desc_bh7 =
_mm_load_si128
@@ -529,33 +530,112 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, 
struct rte_mbuf **rx_pkts,
 * to shift the 32b RSS hash value to the
 * highest 32b of each 128b before mask
 */
-   __m256i rss_hash6_7 =
-   _mm256_slli_epi64(raw_desc_bh6_7, 32);
-   __m256i rss_hash4_5 =
-   _mm256_slli_epi64(raw_desc_bh4_5, 32);
-   __m256i rss_hash2_3 =
-   _mm256_slli_epi64(raw_desc_bh2_3, 32);
-   __m256i rss_hash0_1 =
-   _mm256_slli_epi64(raw_desc_bh0_1, 32);
-
-   __m256i rss_hash_msk =
-   _mm256_set_epi32(0x, 0, 0, 0,
-0x, 0, 0, 0);
-
-   rss_hash6_7 = _mm256_and_si256
-   (rss_hash6_7, rss_hash_msk);
-   rss_hash4_5 = _mm256_and_si256
-   (rss_hash4_5, rss_hash_msk);
-   rss_hash2_3 = _mm256_and_si256
-   (rss_hash2_3, rss_hash_msk);
-   rss_hash0_1 = _mm256_and_si256
-   (rss_hash0_1, rss_hash_msk);
-
-   mb6_7 = _mm256_or_si256(mb6_7, rss_hash6_7);
-   mb4_5 = _mm256_or_si256(mb4_5, rss_hash4_5);
-   mb2_3 = _mm256_or_si256(mb2_3, rss_hash2_3);
-   mb0_1 = _mm256_or_si256(mb0_1, rss_hash0_1);
-   } /* if() on RSS hash parsing */
+   if 
(rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
+   RTE_ETH_RX_OFFLOAD_RSS_HASH) {
+   __m256i rss_hash6_7 =
+   
_mm256_slli_epi64(raw_desc_bh6_7, 32);
+   __m256i rss_hash4_5 =
+   
_mm256_slli_epi64(raw_desc_bh4_5, 32);
+   __m256i rss_hash2_3 =
+   
_mm256_slli_epi64(raw_desc_bh2_3, 32);
+  

[PATCH v4 1/2] app/testpmd: fix vlan offload of rxq

2022-10-24 Thread Mingjin Ye
After setting vlan offload in testpmd, the result is not updated
to rxq. Therefore, the queue needs to be reconfigured after
executing the "vlan offload" related commands.

Fixes: a47aa8b97afe ("app/testpmd: add vlan offload support")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 app/test-pmd/cmdline.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 17be2de402..ce125f549f 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -4133,6 +4133,7 @@ cmd_vlan_offload_parsed(void *parsed_result,
else
vlan_extend_set(port_id, on);
 
+   cmd_reconfig_device_queue(port_id, 1, 1);
return;
 }
 
-- 
2.34.1



[PATCH v4 2/2] net/ice: fix vlan offload

2022-10-24 Thread Mingjin Ye
The vlan tag and flag in Rx descriptor are not processed on vector path,
then the upper application cann't fetch the tci from mbuf.

This commit add handling of vlan RX offloading.

Fixes: c68a52b8b38c ("net/ice: support vector SSE in Rx")
Fixes: ece1f8a8f1c8 ("net/ice: switch to flexible descriptor in SSE path")
Fixes: 12443386a0b0 ("net/ice: support flex Rx descriptor RxDID22")
Fixes: 214f452f7d5f ("net/ice: add AVX2 offload Rx")
Fixes: 7f85d5ebcfe1 ("net/ice: add AVX512 vector path")
Fixes: 295968d17407 ("ethdev: add namespace")
Fixes: 808a17b3c1e6 ("net/ice: add Rx AVX512 offload path")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 

v3:
* Fix macros in ice_rxtx_vec_sse.c source file.
v4:
* Fix ice_rx_desc_to_olflags_v define in ice_rxtx_vec_sse.c source file.
---
 drivers/net/ice/ice_rxtx_vec_avx2.c   | 136 +-
 drivers/net/ice/ice_rxtx_vec_avx512.c | 156 +-
 drivers/net/ice/ice_rxtx_vec_sse.c| 132 --
 3 files changed, 335 insertions(+), 89 deletions(-)

diff --git a/drivers/net/ice/ice_rxtx_vec_avx2.c 
b/drivers/net/ice/ice_rxtx_vec_avx2.c
index 31d6af42fd..888666f206 100644
--- a/drivers/net/ice/ice_rxtx_vec_avx2.c
+++ b/drivers/net/ice/ice_rxtx_vec_avx2.c
@@ -238,6 +238,7 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, 
struct rte_mbuf **rx_pkts,
RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED,
RTE_MBUF_F_RX_RSS_HASH, 0);
 
+
RTE_SET_USED(avx_aligned); /* for 32B descriptors we don't use this */
 
uint16_t i, received;
@@ -474,7 +475,7 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, 
struct rte_mbuf **rx_pkts,
 * will cause performance drop to get into this context.
 */
if 
(rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
-   RTE_ETH_RX_OFFLOAD_RSS_HASH) {
+   (RTE_ETH_RX_OFFLOAD_RSS_HASH | 
RTE_ETH_RX_OFFLOAD_VLAN)) {
/* load bottom half of every 32B desc */
const __m128i raw_desc_bh7 =
_mm_load_si128
@@ -529,33 +530,112 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, 
struct rte_mbuf **rx_pkts,
 * to shift the 32b RSS hash value to the
 * highest 32b of each 128b before mask
 */
-   __m256i rss_hash6_7 =
-   _mm256_slli_epi64(raw_desc_bh6_7, 32);
-   __m256i rss_hash4_5 =
-   _mm256_slli_epi64(raw_desc_bh4_5, 32);
-   __m256i rss_hash2_3 =
-   _mm256_slli_epi64(raw_desc_bh2_3, 32);
-   __m256i rss_hash0_1 =
-   _mm256_slli_epi64(raw_desc_bh0_1, 32);
-
-   __m256i rss_hash_msk =
-   _mm256_set_epi32(0x, 0, 0, 0,
-0x, 0, 0, 0);
-
-   rss_hash6_7 = _mm256_and_si256
-   (rss_hash6_7, rss_hash_msk);
-   rss_hash4_5 = _mm256_and_si256
-   (rss_hash4_5, rss_hash_msk);
-   rss_hash2_3 = _mm256_and_si256
-   (rss_hash2_3, rss_hash_msk);
-   rss_hash0_1 = _mm256_and_si256
-   (rss_hash0_1, rss_hash_msk);
-
-   mb6_7 = _mm256_or_si256(mb6_7, rss_hash6_7);
-   mb4_5 = _mm256_or_si256(mb4_5, rss_hash4_5);
-   mb2_3 = _mm256_or_si256(mb2_3, rss_hash2_3);
-   mb0_1 = _mm256_or_si256(mb0_1, rss_hash0_1);
-   } /* if() on RSS hash parsing */
+   if 
(rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
+   RTE_ETH_RX_OFFLOAD_RSS_HASH) {
+   __m256i rss_hash6_7 =
+   
_mm256_slli_epi64(raw_desc_bh6_7, 32);
+   __m256i rss_hash4_5 =
+   
_mm256_slli_epi64(raw_desc_bh4_5, 32);
+   __m256i rss_hash2_3 =
+   
_mm256_slli_epi64(raw_desc_bh2_3, 32);
+  

[PATCH] net/ice: support vxlan gpe tunnel offload

2022-10-24 Thread Mingjin Ye
PMD does not support VXLAN_GPE tunnel offloading, therefore, it will cause
the tx queues overflow and stop working when sending such packets.

This patch adds support for the vxlan gpe.

Fixes: daa02b5cddbb ("mbuf: add namespace to offload flags")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 drivers/net/ice/ice_rxtx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c
index 697251c603..0a2b0376ac 100644
--- a/drivers/net/ice/ice_rxtx.c
+++ b/drivers/net/ice/ice_rxtx.c
@@ -2690,6 +2690,7 @@ ice_parse_tunneling_params(uint64_t ol_flags,
/* for non UDP / GRE tunneling, set to 00b */
break;
case RTE_MBUF_F_TX_TUNNEL_VXLAN:
+   case RTE_MBUF_F_TX_TUNNEL_VXLAN_GPE:
case RTE_MBUF_F_TX_TUNNEL_GTP:
case RTE_MBUF_F_TX_TUNNEL_GENEVE:
*cd_tunneling |= ICE_TXD_CTX_UDP_TUNNELING;
-- 
2.34.1



[PATCH] net/ice: support vxlan gpe tunnel offload

2022-10-24 Thread Mingjin Ye
PMD does not support VXLAN_GPE tunnel offloading, therefore, it will cause
the tx queues overflow and stop working when sending such packets.

This patch adds support for the vxlan gpe.

Fixes: daa02b5cddbb ("mbuf: add namespace to offload flags")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 drivers/net/ice/ice_rxtx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c
index 697251c603..0a2b0376ac 100644
--- a/drivers/net/ice/ice_rxtx.c
+++ b/drivers/net/ice/ice_rxtx.c
@@ -2690,6 +2690,7 @@ ice_parse_tunneling_params(uint64_t ol_flags,
/* for non UDP / GRE tunneling, set to 00b */
break;
case RTE_MBUF_F_TX_TUNNEL_VXLAN:
+   case RTE_MBUF_F_TX_TUNNEL_VXLAN_GPE:
case RTE_MBUF_F_TX_TUNNEL_GTP:
case RTE_MBUF_F_TX_TUNNEL_GENEVE:
*cd_tunneling |= ICE_TXD_CTX_UDP_TUNNELING;
-- 
2.34.1



[PATCH v4 1/2] app/testpmd: fix vlan offload of rxq

2022-10-26 Thread Mingjin Ye
After setting vlan offload in testpmd, the result is not updated
to rxq. Therefore, the queue needs to be reconfigured after
executing the "vlan offload" related commands.

Fixes: a47aa8b97afe ("app/testpmd: add vlan offload support")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 app/test-pmd/cmdline.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 17be2de402..ce125f549f 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -4133,6 +4133,7 @@ cmd_vlan_offload_parsed(void *parsed_result,
else
vlan_extend_set(port_id, on);
 
+   cmd_reconfig_device_queue(port_id, 1, 1);
return;
 }
 
-- 
2.34.1



[PATCH v4 2/2] net/ice: fix vlan offload

2022-10-26 Thread Mingjin Ye
The vlan tag and flag in Rx descriptor are not processed on vector path,
then the upper application can't fetch the tci from mbuf.

This commit add handling of vlan RX offloading.

Fixes: c68a52b8b38c ("net/ice: support vector SSE in Rx")
Fixes: ece1f8a8f1c8 ("net/ice: switch to flexible descriptor in SSE path")
Fixes: 12443386a0b0 ("net/ice: support flex Rx descriptor RxDID22")
Fixes: 214f452f7d5f ("net/ice: add AVX2 offload Rx")
Fixes: 7f85d5ebcfe1 ("net/ice: add AVX512 vector path")
Fixes: 295968d17407 ("ethdev: add namespace")
Fixes: 808a17b3c1e6 ("net/ice: add Rx AVX512 offload path")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 

v3:
* Fix macros in ice_rxtx_vec_sse.c source file.
v4:
* Fix ice_rx_desc_to_olflags_v define in ice_rxtx_vec_sse.c source file.
---
 drivers/net/ice/ice_rxtx_vec_avx2.c   | 136 +-
 drivers/net/ice/ice_rxtx_vec_avx512.c | 156 +-
 drivers/net/ice/ice_rxtx_vec_sse.c| 132 --
 3 files changed, 335 insertions(+), 89 deletions(-)

diff --git a/drivers/net/ice/ice_rxtx_vec_avx2.c 
b/drivers/net/ice/ice_rxtx_vec_avx2.c
index 31d6af42fd..888666f206 100644
--- a/drivers/net/ice/ice_rxtx_vec_avx2.c
+++ b/drivers/net/ice/ice_rxtx_vec_avx2.c
@@ -238,6 +238,7 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, 
struct rte_mbuf **rx_pkts,
RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED,
RTE_MBUF_F_RX_RSS_HASH, 0);
 
+
RTE_SET_USED(avx_aligned); /* for 32B descriptors we don't use this */
 
uint16_t i, received;
@@ -474,7 +475,7 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, 
struct rte_mbuf **rx_pkts,
 * will cause performance drop to get into this context.
 */
if 
(rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
-   RTE_ETH_RX_OFFLOAD_RSS_HASH) {
+   (RTE_ETH_RX_OFFLOAD_RSS_HASH | 
RTE_ETH_RX_OFFLOAD_VLAN)) {
/* load bottom half of every 32B desc */
const __m128i raw_desc_bh7 =
_mm_load_si128
@@ -529,33 +530,112 @@ _ice_recv_raw_pkts_vec_avx2(struct ice_rx_queue *rxq, 
struct rte_mbuf **rx_pkts,
 * to shift the 32b RSS hash value to the
 * highest 32b of each 128b before mask
 */
-   __m256i rss_hash6_7 =
-   _mm256_slli_epi64(raw_desc_bh6_7, 32);
-   __m256i rss_hash4_5 =
-   _mm256_slli_epi64(raw_desc_bh4_5, 32);
-   __m256i rss_hash2_3 =
-   _mm256_slli_epi64(raw_desc_bh2_3, 32);
-   __m256i rss_hash0_1 =
-   _mm256_slli_epi64(raw_desc_bh0_1, 32);
-
-   __m256i rss_hash_msk =
-   _mm256_set_epi32(0x, 0, 0, 0,
-0x, 0, 0, 0);
-
-   rss_hash6_7 = _mm256_and_si256
-   (rss_hash6_7, rss_hash_msk);
-   rss_hash4_5 = _mm256_and_si256
-   (rss_hash4_5, rss_hash_msk);
-   rss_hash2_3 = _mm256_and_si256
-   (rss_hash2_3, rss_hash_msk);
-   rss_hash0_1 = _mm256_and_si256
-   (rss_hash0_1, rss_hash_msk);
-
-   mb6_7 = _mm256_or_si256(mb6_7, rss_hash6_7);
-   mb4_5 = _mm256_or_si256(mb4_5, rss_hash4_5);
-   mb2_3 = _mm256_or_si256(mb2_3, rss_hash2_3);
-   mb0_1 = _mm256_or_si256(mb0_1, rss_hash0_1);
-   } /* if() on RSS hash parsing */
+   if 
(rxq->vsi->adapter->pf.dev_data->dev_conf.rxmode.offloads &
+   RTE_ETH_RX_OFFLOAD_RSS_HASH) {
+   __m256i rss_hash6_7 =
+   
_mm256_slli_epi64(raw_desc_bh6_7, 32);
+   __m256i rss_hash4_5 =
+   
_mm256_slli_epi64(raw_desc_bh4_5, 32);
+   __m256i rss_hash2_3 =
+   
_mm256_slli_epi64(raw_desc_bh2_3, 32);
+  

[PATCH v2] net/ice: fix rx scalar path offload parse

2022-10-27 Thread Mingjin Ye
The status_0 field of the rx descriptor is incorrectly parsed as the error
field, resulting in a parsing error of offload features.

This patch fixes parsing of wrong fields.

Fixes: daa02b5cddbb ("mbuf: add namespace to offload flags")
Fixes: dbf3c0e77a22 ("net/ice: handle Rx flex descriptor")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 drivers/net/ice/ice_rxtx.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c
index 71e5c6f5d6..3c558b32bd 100644
--- a/drivers/net/ice/ice_rxtx.c
+++ b/drivers/net/ice/ice_rxtx.c
@@ -1485,36 +1485,36 @@ ice_rx_queue_count(void *rx_queue)
 (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S) |  \
 (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S) | \
 (1 << ICE_RX_FLEX_DESC_STATUS0_RXE_S))
-
+#define ICE_RXD_QW1_ERROR_SHIFT19
 /* Rx L3/L4 checksum */
 static inline uint64_t
 ice_rxd_error_to_pkt_flags(uint16_t stat_err0)
 {
uint64_t flags = 0;
 
-   /* check if HW has decoded the packet and checksum */
-   if (unlikely(!(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_L3L4P_S
-   return 0;
+   uint64_t error_bits = (stat_err0 >> ICE_RXD_QW1_ERROR_SHIFT) & 0x7D;
 
-   if (likely(!(stat_err0 & ICE_RX_FLEX_ERR0_BITS))) {
-   flags |= (RTE_MBUF_F_RX_IP_CKSUM_GOOD | 
RTE_MBUF_F_RX_L4_CKSUM_GOOD);
+   if (likely(!(error_bits & ICE_RX_FLEX_ERR0_BITS))) {
+   flags |= (RTE_MBUF_F_RX_IP_CKSUM_GOOD |
+   RTE_MBUF_F_RX_L4_CKSUM_GOOD |
+   RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD);
return flags;
}
 
-   if (unlikely(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_IPE_S)))
+   if (unlikely(error_bits & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_IPE_S)))
flags |= RTE_MBUF_F_RX_IP_CKSUM_BAD;
else
flags |= RTE_MBUF_F_RX_IP_CKSUM_GOOD;
 
-   if (unlikely(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_L4E_S)))
+   if (unlikely(error_bits & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_L4E_S)))
flags |= RTE_MBUF_F_RX_L4_CKSUM_BAD;
else
flags |= RTE_MBUF_F_RX_L4_CKSUM_GOOD;
 
-   if (unlikely(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S)))
+   if (unlikely(error_bits & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S)))
flags |= RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD;
 
-   if (unlikely(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S)))
+   if (unlikely(error_bits & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S)))
flags |= RTE_MBUF_F_RX_OUTER_L4_CKSUM_BAD;
else
flags |= RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD;
-- 
2.34.1



[PATCH v2] net/ice: fix rx scalar path offload parse

2022-10-27 Thread Mingjin Ye
The status_0 field of the rx descriptor is incorrectly parsed as the error
field, which causes the parsing error of offload features.

This patch is to fixe the parsing of wrong fields.

Fixes: daa02b5cddbb ("mbuf: add namespace to offload flags")
Fixes: dbf3c0e77a22 ("net/ice: handle Rx flex descriptor")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 drivers/net/ice/ice_rxtx.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c
index 71e5c6f5d6..3c558b32bd 100644
--- a/drivers/net/ice/ice_rxtx.c
+++ b/drivers/net/ice/ice_rxtx.c
@@ -1485,36 +1485,36 @@ ice_rx_queue_count(void *rx_queue)
 (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S) |  \
 (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S) | \
 (1 << ICE_RX_FLEX_DESC_STATUS0_RXE_S))
-
+#define ICE_RXD_QW1_ERROR_SHIFT19
 /* Rx L3/L4 checksum */
 static inline uint64_t
 ice_rxd_error_to_pkt_flags(uint16_t stat_err0)
 {
uint64_t flags = 0;
 
-   /* check if HW has decoded the packet and checksum */
-   if (unlikely(!(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_L3L4P_S
-   return 0;
+   uint64_t error_bits = (stat_err0 >> ICE_RXD_QW1_ERROR_SHIFT) & 0x7D;
 
-   if (likely(!(stat_err0 & ICE_RX_FLEX_ERR0_BITS))) {
-   flags |= (RTE_MBUF_F_RX_IP_CKSUM_GOOD | 
RTE_MBUF_F_RX_L4_CKSUM_GOOD);
+   if (likely(!(error_bits & ICE_RX_FLEX_ERR0_BITS))) {
+   flags |= (RTE_MBUF_F_RX_IP_CKSUM_GOOD |
+   RTE_MBUF_F_RX_L4_CKSUM_GOOD |
+   RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD);
return flags;
}
 
-   if (unlikely(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_IPE_S)))
+   if (unlikely(error_bits & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_IPE_S)))
flags |= RTE_MBUF_F_RX_IP_CKSUM_BAD;
else
flags |= RTE_MBUF_F_RX_IP_CKSUM_GOOD;
 
-   if (unlikely(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_L4E_S)))
+   if (unlikely(error_bits & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_L4E_S)))
flags |= RTE_MBUF_F_RX_L4_CKSUM_BAD;
else
flags |= RTE_MBUF_F_RX_L4_CKSUM_GOOD;
 
-   if (unlikely(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S)))
+   if (unlikely(error_bits & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S)))
flags |= RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD;
 
-   if (unlikely(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S)))
+   if (unlikely(error_bits & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S)))
flags |= RTE_MBUF_F_RX_OUTER_L4_CKSUM_BAD;
else
flags |= RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD;
-- 
2.34.1



[PATCH v8] doc: add PMD known issue

2023-01-27 Thread Mingjin Ye
Add a known issue: Rx path dynamic change is not supported for PMD.

Fixes: de853a3bb151 ("net/ice: disable DDP package on Windows")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 doc/guides/nics/ice.rst | 12 
 1 file changed, 12 insertions(+)

diff --git a/doc/guides/nics/ice.rst b/doc/guides/nics/ice.rst
index ce075e067c..115625523e 100644
--- a/doc/guides/nics/ice.rst
+++ b/doc/guides/nics/ice.rst
@@ -395,3 +395,15 @@ file is used by both the kernel driver and the DPDK PMD.
 
   Windows support: The DDP package is not supported on Windows so,
   loading of the package is disabled on Windows.
+
+ice: Rx path does not support dynamic change
+
+
+The ice driver supports fast and offload rx path. When pmd is initialized,
+the fast rx path is selected by default. Even if offload is subsequently
+enabled through the API, which will not work because the past rx path is
+still used.
+
+The ice driver does not support to change the rx path after application
+is initialized. If HW offload is required, the ``--rx-offloads`` parameter
+should be used to choose the offload Rx path by default.
-- 
2.34.1



[PATCH] net/iavf: add check for mbuf

2023-01-30 Thread Mingjin Ye
The scalar Tx path would send wrong mbuf that causes the kernel driver to
fire the MDD event.

This patch adds mbuf detection in tx_prepare to fix this issue, rte_errno
will be set to EINVAL and returned if the verification fails.

Fixes: 3fd32df381f8 ("net/iavf: check Tx packet with correct UP and queue")
Fixes: 12b435bf8f2f ("net/iavf: support flex desc metadata extraction")
Fixes: f28fbd1e6b50 ("net/iavf: check max SIMD bitwidth")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 drivers/net/iavf/iavf_rxtx.c | 592 +++
 1 file changed, 592 insertions(+)

diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index 8d49967538..e1f2ced990 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -24,12 +24,48 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #include "iavf.h"
 #include "iavf_rxtx.h"
 #include "iavf_ipsec_crypto.h"
 #include "rte_pmd_iavf.h"
 
+#define GRE_CHECKSUM_PRESENT   0x8000
+#define GRE_KEY_PRESENT0x2000
+#define GRE_SEQUENCE_PRESENT   0x1000
+#define GRE_EXT_LEN4
+#define GRE_SUPPORTED_FIELDS   (GRE_CHECKSUM_PRESENT | GRE_KEY_PRESENT |\
+GRE_SEQUENCE_PRESENT)
+
+static uint16_t vxlan_gpe_udp_port = RTE_VXLAN_GPE_DEFAULT_PORT;
+static uint16_t geneve_udp_port = RTE_GENEVE_DEFAULT_PORT;
+
+struct simple_gre_hdr {
+   uint16_t flags;
+   uint16_t proto;
+} __rte_packed;
+
+/* structure that caches offload info for the current packet */
+struct offload_info {
+   uint16_t ethertype;
+   uint8_t gso_enable;
+   uint16_t l2_len;
+   uint16_t l3_len;
+   uint16_t l4_len;
+   uint8_t l4_proto;
+   uint8_t is_tunnel;
+   uint16_t outer_ethertype;
+   uint16_t outer_l2_len;
+   uint16_t outer_l3_len;
+   uint8_t outer_l4_proto;
+   uint16_t tso_segsz;
+   uint16_t tunnel_tso_segsz;
+   uint32_t pkt_len;
+};
+
 /* Offset of mbuf dynamic field for protocol extraction's metadata */
 int rte_pmd_ifd_dynfield_proto_xtr_metadata_offs = -1;
 
@@ -2949,6 +2985,555 @@ iavf_check_vlan_up2tc(struct iavf_tx_queue *txq, struct 
rte_mbuf *m)
}
 }
 
+/* Parse an IPv4 header to fill l3_len, l4_len, and l4_proto */
+static inline void
+parse_ipv4(struct rte_ipv4_hdr *ipv4_hdr, struct offload_info *info)
+{
+   struct rte_tcp_hdr *tcp_hdr;
+
+   info->l3_len = rte_ipv4_hdr_len(ipv4_hdr);
+   info->l4_proto = ipv4_hdr->next_proto_id;
+
+   /* only fill l4_len for TCP, it's useful for TSO */
+   if (info->l4_proto == IPPROTO_TCP) {
+   tcp_hdr = (struct rte_tcp_hdr *)
+   ((char *)ipv4_hdr + info->l3_len);
+   info->l4_len = (tcp_hdr->data_off & 0xf0) >> 2;
+   } else if (info->l4_proto == IPPROTO_UDP) {
+   info->l4_len = sizeof(struct rte_udp_hdr);
+   } else {
+   info->l4_len = 0;
+   }
+}
+
+/* Parse an IPv6 header to fill l3_len, l4_len, and l4_proto */
+static inline void
+parse_ipv6(struct rte_ipv6_hdr *ipv6_hdr, struct offload_info *info)
+{
+   struct rte_tcp_hdr *tcp_hdr;
+
+   info->l3_len = sizeof(struct rte_ipv6_hdr);
+   info->l4_proto = ipv6_hdr->proto;
+
+   /* only fill l4_len for TCP, it's useful for TSO */
+   if (info->l4_proto == IPPROTO_TCP) {
+   tcp_hdr = (struct rte_tcp_hdr *)
+   ((char *)ipv6_hdr + info->l3_len);
+   info->l4_len = (tcp_hdr->data_off & 0xf0) >> 2;
+   } else if (info->l4_proto == IPPROTO_UDP) {
+   info->l4_len = sizeof(struct rte_udp_hdr);
+   } else {
+   info->l4_len = 0;
+   }
+}
+
+/*
+ * Parse an ethernet header to fill the ethertype, l2_len, l3_len and
+ * ipproto. This function is able to recognize IPv4/IPv6 with optional VLAN
+ * headers. The l4_len argument is only set in case of TCP (useful for TSO).
+ */
+static inline void
+parse_ethernet(struct rte_ether_hdr *eth_hdr, struct offload_info *info)
+{
+   struct rte_ipv4_hdr *ipv4_hdr;
+   struct rte_ipv6_hdr *ipv6_hdr;
+   struct rte_vlan_hdr *vlan_hdr;
+
+   info->l2_len = sizeof(struct rte_ether_hdr);
+   info->ethertype = eth_hdr->ether_type;
+
+   while (info->ethertype == rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN) ||
+  info->ethertype == rte_cpu_to_be_16(RTE_ETHER_TYPE_QINQ)) {
+   vlan_hdr = (struct rte_vlan_hdr *)
+   ((char *)eth_hdr + info->l2_len);
+   info->l2_len  += sizeof(struct rte_vlan_hdr);
+   info->ethertype = vlan_hdr->eth_proto;
+   }
+
+   switch (info->ethertype) {
+   case RTE_STATIC_BSWAP16(RTE_ETHER_TYPE_IPV4):
+   ipv4_hdr = (struct rte_ipv4_hdr *)
+   

[PATCH] net/iavf: add check for mbuf

2023-01-31 Thread Mingjin Ye
The scalar Tx path would send wrong mbuf that causes the kernel driver to
fire the MDD event.

This patch adds mbuf detection in tx_prepare to fix this issue, rte_errno
will be set to EINVAL and returned if the verification fails.

Fixes: 3fd32df381f8 ("net/iavf: check Tx packet with correct UP and queue")
Fixes: 12b435bf8f2f ("net/iavf: support flex desc metadata extraction")
Fixes: f28fbd1e6b50 ("net/iavf: check max SIMD bitwidth")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 drivers/net/iavf/iavf_rxtx.c | 599 +++
 1 file changed, 599 insertions(+)

diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index 8d49967538..63012fdc28 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -24,12 +24,55 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #include "iavf.h"
 #include "iavf_rxtx.h"
 #include "iavf_ipsec_crypto.h"
 #include "rte_pmd_iavf.h"
 
+#define GRE_CHECKSUM_PRESENT   0x8000
+#define GRE_KEY_PRESENT0x2000
+#define GRE_SEQUENCE_PRESENT   0x1000
+#define GRE_EXT_LEN4
+#define GRE_SUPPORTED_FIELDS   (GRE_CHECKSUM_PRESENT | GRE_KEY_PRESENT |\
+GRE_SEQUENCE_PRESENT)
+
+#ifndef IPPROTO_IPIP
+#define IPPROTO_IPIP 4
+#endif
+#ifndef IPPROTO_GRE
+#define IPPROTO_GRE47
+#endif
+
+static uint16_t vxlan_gpe_udp_port = RTE_VXLAN_GPE_DEFAULT_PORT;
+static uint16_t geneve_udp_port = RTE_GENEVE_DEFAULT_PORT;
+
+struct simple_gre_hdr {
+   uint16_t flags;
+   uint16_t proto;
+} __rte_packed;
+
+/* structure that caches offload info for the current packet */
+struct offload_info {
+   uint16_t ethertype;
+   uint8_t gso_enable;
+   uint16_t l2_len;
+   uint16_t l3_len;
+   uint16_t l4_len;
+   uint8_t l4_proto;
+   uint8_t is_tunnel;
+   uint16_t outer_ethertype;
+   uint16_t outer_l2_len;
+   uint16_t outer_l3_len;
+   uint8_t outer_l4_proto;
+   uint16_t tso_segsz;
+   uint16_t tunnel_tso_segsz;
+   uint32_t pkt_len;
+};
+
 /* Offset of mbuf dynamic field for protocol extraction's metadata */
 int rte_pmd_ifd_dynfield_proto_xtr_metadata_offs = -1;
 
@@ -2949,6 +2992,555 @@ iavf_check_vlan_up2tc(struct iavf_tx_queue *txq, struct 
rte_mbuf *m)
}
 }
 
+/* Parse an IPv4 header to fill l3_len, l4_len, and l4_proto */
+static inline void
+parse_ipv4(struct rte_ipv4_hdr *ipv4_hdr, struct offload_info *info)
+{
+   struct rte_tcp_hdr *tcp_hdr;
+
+   info->l3_len = rte_ipv4_hdr_len(ipv4_hdr);
+   info->l4_proto = ipv4_hdr->next_proto_id;
+
+   /* only fill l4_len for TCP, it's useful for TSO */
+   if (info->l4_proto == IPPROTO_TCP) {
+   tcp_hdr = (struct rte_tcp_hdr *)
+   ((char *)ipv4_hdr + info->l3_len);
+   info->l4_len = (tcp_hdr->data_off & 0xf0) >> 2;
+   } else if (info->l4_proto == IPPROTO_UDP) {
+   info->l4_len = sizeof(struct rte_udp_hdr);
+   } else {
+   info->l4_len = 0;
+   }
+}
+
+/* Parse an IPv6 header to fill l3_len, l4_len, and l4_proto */
+static inline void
+parse_ipv6(struct rte_ipv6_hdr *ipv6_hdr, struct offload_info *info)
+{
+   struct rte_tcp_hdr *tcp_hdr;
+
+   info->l3_len = sizeof(struct rte_ipv6_hdr);
+   info->l4_proto = ipv6_hdr->proto;
+
+   /* only fill l4_len for TCP, it's useful for TSO */
+   if (info->l4_proto == IPPROTO_TCP) {
+   tcp_hdr = (struct rte_tcp_hdr *)
+   ((char *)ipv6_hdr + info->l3_len);
+   info->l4_len = (tcp_hdr->data_off & 0xf0) >> 2;
+   } else if (info->l4_proto == IPPROTO_UDP) {
+   info->l4_len = sizeof(struct rte_udp_hdr);
+   } else {
+   info->l4_len = 0;
+   }
+}
+
+/*
+ * Parse an ethernet header to fill the ethertype, l2_len, l3_len and
+ * ipproto. This function is able to recognize IPv4/IPv6 with optional VLAN
+ * headers. The l4_len argument is only set in case of TCP (useful for TSO).
+ */
+static inline void
+parse_ethernet(struct rte_ether_hdr *eth_hdr, struct offload_info *info)
+{
+   struct rte_ipv4_hdr *ipv4_hdr;
+   struct rte_ipv6_hdr *ipv6_hdr;
+   struct rte_vlan_hdr *vlan_hdr;
+
+   info->l2_len = sizeof(struct rte_ether_hdr);
+   info->ethertype = eth_hdr->ether_type;
+
+   while (info->ethertype == rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN) ||
+  info->ethertype == rte_cpu_to_be_16(RTE_ETHER_TYPE_QINQ)) {
+   vlan_hdr = (struct rte_vlan_hdr *)
+   ((char *)eth_hdr + info->l2_len);
+   info->l2_len  += sizeof(struct rte_vlan_hdr);
+   info->ethertype = vlan_hdr->eth_proto;
+   }
+
+   switch (info->etherty

[PATCH v2] net/iavf: add check for mbuf

2023-02-02 Thread Mingjin Ye
The scalar Tx path would send wrong mbuf that causes the kernel driver to
fire the MDD event.

This patch adds mbuf detection in tx_prepare to fix this issue, rte_errno
will be set to EINVAL and returned if the verification fails.

Fixes: 3fd32df381f8 ("net/iavf: check Tx packet with correct UP and queue")
Fixes: 12b435bf8f2f ("net/iavf: support flex desc metadata extraction")
Fixes: f28fbd1e6b50 ("net/iavf: check max SIMD bitwidth")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 drivers/net/iavf/iavf_rxtx.c | 647 +++
 1 file changed, 647 insertions(+)

diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index 8d49967538..93138edf01 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -24,12 +24,55 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #include "iavf.h"
 #include "iavf_rxtx.h"
 #include "iavf_ipsec_crypto.h"
 #include "rte_pmd_iavf.h"
 
+#define GRE_CHECKSUM_PRESENT   0x8000
+#define GRE_KEY_PRESENT0x2000
+#define GRE_SEQUENCE_PRESENT   0x1000
+#define GRE_EXT_LEN4
+#define GRE_SUPPORTED_FIELDS   (GRE_CHECKSUM_PRESENT | GRE_KEY_PRESENT |\
+GRE_SEQUENCE_PRESENT)
+
+#ifndef IPPROTO_IPIP
+#define IPPROTO_IPIP 4
+#endif
+#ifndef IPPROTO_GRE
+#define IPPROTO_GRE47
+#endif
+
+static uint16_t vxlan_gpe_udp_port = RTE_VXLAN_GPE_DEFAULT_PORT;
+static uint16_t geneve_udp_port = RTE_GENEVE_DEFAULT_PORT;
+
+struct simple_gre_hdr {
+   uint16_t flags;
+   uint16_t proto;
+} __rte_packed;
+
+/* structure that caches offload info for the current packet */
+struct offload_info {
+   uint16_t ethertype;
+   uint8_t gso_enable;
+   uint16_t l2_len;
+   uint16_t l3_len;
+   uint16_t l4_len;
+   uint8_t l4_proto;
+   uint8_t is_tunnel;
+   uint16_t outer_ethertype;
+   uint16_t outer_l2_len;
+   uint16_t outer_l3_len;
+   uint8_t outer_l4_proto;
+   uint16_t tso_segsz;
+   uint16_t tunnel_tso_segsz;
+   uint32_t pkt_len;
+};
+
 /* Offset of mbuf dynamic field for protocol extraction's metadata */
 int rte_pmd_ifd_dynfield_proto_xtr_metadata_offs = -1;
 
@@ -2949,6 +2992,603 @@ iavf_check_vlan_up2tc(struct iavf_tx_queue *txq, struct 
rte_mbuf *m)
}
 }
 
+/* Parse an IPv4 header to fill l3_len, l4_len, and l4_proto */
+static inline void
+parse_ipv4(struct rte_ipv4_hdr *ipv4_hdr, struct offload_info *info)
+{
+   struct rte_tcp_hdr *tcp_hdr;
+
+   info->l3_len = rte_ipv4_hdr_len(ipv4_hdr);
+   info->l4_proto = ipv4_hdr->next_proto_id;
+
+   /* only fill l4_len for TCP, it's useful for TSO */
+   if (info->l4_proto == IPPROTO_TCP) {
+   tcp_hdr = (struct rte_tcp_hdr *)
+   ((char *)ipv4_hdr + info->l3_len);
+   info->l4_len = (tcp_hdr->data_off & 0xf0) >> 2;
+   } else if (info->l4_proto == IPPROTO_UDP) {
+   info->l4_len = sizeof(struct rte_udp_hdr);
+   } else {
+   info->l4_len = 0;
+   }
+}
+
+/* Parse an IPv6 header to fill l3_len, l4_len, and l4_proto */
+static inline void
+parse_ipv6(struct rte_ipv6_hdr *ipv6_hdr, struct offload_info *info)
+{
+   struct rte_tcp_hdr *tcp_hdr;
+
+   info->l3_len = sizeof(struct rte_ipv6_hdr);
+   info->l4_proto = ipv6_hdr->proto;
+
+   /* only fill l4_len for TCP, it's useful for TSO */
+   if (info->l4_proto == IPPROTO_TCP) {
+   tcp_hdr = (struct rte_tcp_hdr *)
+   ((char *)ipv6_hdr + info->l3_len);
+   info->l4_len = (tcp_hdr->data_off & 0xf0) >> 2;
+   } else if (info->l4_proto == IPPROTO_UDP) {
+   info->l4_len = sizeof(struct rte_udp_hdr);
+   } else {
+   info->l4_len = 0;
+   }
+}
+
+/*
+ * Parse an ethernet header to fill the ethertype, l2_len, l3_len and
+ * ipproto. This function is able to recognize IPv4/IPv6 with optional VLAN
+ * headers. The l4_len argument is only set in case of TCP (useful for TSO).
+ */
+static inline void
+parse_ethernet(struct rte_ether_hdr *eth_hdr, struct offload_info *info)
+{
+   struct rte_ipv4_hdr *ipv4_hdr;
+   struct rte_ipv6_hdr *ipv6_hdr;
+   struct rte_vlan_hdr *vlan_hdr;
+
+   info->l2_len = sizeof(struct rte_ether_hdr);
+   info->ethertype = eth_hdr->ether_type;
+
+   while (info->ethertype == rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN) ||
+  info->ethertype == rte_cpu_to_be_16(RTE_ETHER_TYPE_QINQ)) {
+   vlan_hdr = (struct rte_vlan_hdr *)
+   ((char *)eth_hdr + info->l2_len);
+   info->l2_len  += sizeof(struct rte_vlan_hdr);
+   info->ethertype = vlan_hdr->eth_proto;
+   }
+
+   switch (info->etherty

[PATCH] net/ice: fix get link status timeout

2023-02-05 Thread Mingjin Ye
When hw is just started, it will immediately obtain the link status, and
the longest attempt is 1 second. Some NICs are slow to initialize, which
make it fails to obtain the link status.

The patch fixes this issue by modifying the longest attempt to 5 seconds.

Fixes: cf911d90e366 ("net/ice: support link update")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 drivers/net/ice/ice_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 0bc739daf0..eaa556f45c 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -3927,7 +3927,7 @@ static int
 ice_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 {
 #define CHECK_INTERVAL 100  /* 100ms */
-#define MAX_REPEAT_TIME 10  /* 1s (10 * 100ms) in total */
+#define MAX_REPEAT_TIME 50  /* 5s (50 * 100ms) in total */
struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
struct ice_link_status link_status;
struct rte_eth_link link, old;
-- 
2.25.1



[PATCH] bus/vdev: fix devargs memory leak

2023-09-01 Thread Mingjin Ye
When a device is created by a secondary process, an empty devargs is
temporarily generated and bound to it. This causes the device to not
be associated with the correct devargs, and the empty devargs are not
released when the resource is freed.

This patch fixes the issue by matching the devargs when inserting a
device in secondary process.

Fixes: dda987315ca2 ("vdev: make virtual bus use its device struct")
Fixes: a16040453968 ("eal: extract vdev infra")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 drivers/bus/vdev/vdev.c | 22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index 7974b27295..fe39a98a9c 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -259,6 +259,22 @@ alloc_devargs(const char *name, const char *args)
return devargs;
 }
 
+static struct rte_devargs *
+vdev_devargs_lookup(const char *name)
+{
+   struct rte_devargs *devargs;
+   char dev_name[32];
+
+   RTE_EAL_DEVARGS_FOREACH("vdev", devargs) {
+   devargs->bus->parse(devargs->name, &dev_name);
+   if (strcmp(dev_name, name) == 0) {
+   VDEV_LOG(INFO, "**Devargs matched %s", dev_name);
+   return devargs;
+   }
+   }
+   return NULL;
+}
+
 static int
 insert_vdev(const char *name, const char *args,
struct rte_vdev_device **p_dev,
@@ -271,7 +287,11 @@ insert_vdev(const char *name, const char *args,
if (name == NULL)
return -EINVAL;
 
-   devargs = alloc_devargs(name, args);
+   if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+   devargs = alloc_devargs(name, args);
+   else
+   devargs = vdev_devargs_lookup(name);
+
if (!devargs)
return -ENOMEM;
 
-- 
2.25.1



[PATCH v3] app/test: secondary process passes allow parameters

2023-09-25 Thread Mingjin Ye
In EAL related test cases, the allow parameters are not passed to
the secondary process, resulting in unexpected NICs being loaded.

This patch fixes this issue by appending the allow parameters to
the secondary process.

Fixes: 086eb64db39e ("test/pdump: add unit test for pdump library")
Fixes: 148f963fb532 ("xen: core library changes")
Fixes: af75078fece3 ("first public release")
Fixes: b8d5e544e73e ("test: add procfs error message for multi-process launch")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
v3:new solution.
---
 app/test/process.h | 52 --
 1 file changed, 50 insertions(+), 2 deletions(-)

diff --git a/app/test/process.h b/app/test/process.h
index 1f073b9c5c..57d58309d8 100644
--- a/app/test/process.h
+++ b/app/test/process.h
@@ -18,6 +18,8 @@
 
 #include  /* strlcpy */
 
+#include 
+
 #ifdef RTE_EXEC_ENV_FREEBSD
 #define self "curproc"
 #define exe "file"
@@ -34,6 +36,44 @@ extern uint16_t flag_for_send_pkts;
 #endif
 #endif
 
+#define PREFIX_A "-a"
+
+static int
+add_parameter_a(char **argv, int max_capacity)
+{
+   struct rte_devargs *devargs;
+   int count = 0;
+   int name_length, data_length;
+   char *dev;
+   int malloc_szie;
+
+   RTE_EAL_DEVARGS_FOREACH(NULL, devargs) {
+   if (count >= max_capacity)
+   return count;
+
+   name_length = strlen(devargs->name);
+   if (devargs->data != NULL)
+   data_length = strlen(devargs->data);
+   else
+   data_length = 0;
+
+   malloc_szie = name_length + data_length + 1;
+   dev = malloc(malloc_szie);
+
+   strncpy(dev, devargs->name, name_length);
+   if (data_length > 0)
+   strncpy(dev + name_length, devargs->data, data_length);
+   memset(dev + malloc_szie - 1, 0, 1);
+
+   *(argv + count) =  strdup(PREFIX_A);
+   count++;
+
+   *(argv + count) = dev;
+   count++;
+   }
+   return count;
+}
+
 /*
  * launches a second copy of the test process using the given argv parameters,
  * which should include argv[0] as the process name. To identify in the
@@ -44,7 +84,7 @@ static inline int
 process_dup(const char *const argv[], int numargs, const char *env_value)
 {
int num;
-   char *argv_cpy[numargs + 1];
+   char *argv_cpy[numargs + RTE_MAX_ETHPORTS * 2 + 1];
int i, status;
char path[32];
 #ifdef RTE_LIB_PDUMP
@@ -58,11 +98,12 @@ process_dup(const char *const argv[], int numargs, const 
char *env_value)
if (pid < 0)
return -1;
else if (pid == 0) {
+   memset(argv_cpy, 0, numargs + RTE_MAX_ETHPORTS * 2 + 1);
/* make a copy of the arguments to be passed to exec */
for (i = 0; i < numargs; i++)
argv_cpy[i] = strdup(argv[i]);
-   argv_cpy[i] = NULL;
num = numargs;
+   num += add_parameter_a(&argv_cpy[i], RTE_MAX_ETHPORTS * 2);
 
 #ifdef RTE_EXEC_ENV_LINUX
{
@@ -131,6 +172,13 @@ process_dup(const char *const argv[], int numargs, const 
char *env_value)
}
rte_panic("Cannot exec: %s\n", strerror(errno));
}
+
+   for (i = 0; i < num; i++) {
+   if (argv_cpy[i] != NULL) {
+   free(argv_cpy[i]);
+   argv_cpy[i] = NULL;
+   }
+   }
}
/* parent process does a wait */
 #ifdef RTE_LIB_PDUMP
-- 
2.25.1



[PATCH v2] net/iavf: support no data path polling mode

2023-09-26 Thread Mingjin Ye
Currently, during a PF to VF reset due to an action such as changing
trust settings on a VF, the DPDK application running with iavf PMD
loses connectivity, and the only solution is to reset the DPDK
application.

Instead of forcing a reset of the DPDK application to restore
connectivity, the iavf PMD driver handles the PF to VF reset event
normally by performing all necessary steps to bring the VF back
online.

To minimize downtime, a devargs "no-poll-on-link-down" is introduced
in iavf PMD. When this flag is set, the PMD switches to no-poll mode
when the link state is down (rx/tx bursts return to 0 immediately).
When the link state returns to normal, the PMD switches to normal
rx/tx burst state.

Signed-off-by: Mingjin Ye 
---
 doc/guides/nics/intel_vf.rst|  3 ++
 drivers/net/iavf/iavf.h |  2 ++
 drivers/net/iavf/iavf_ethdev.c  | 16 +-
 drivers/net/iavf/iavf_rxtx.c| 29 +++--
 drivers/net/iavf/iavf_rxtx.h|  1 +
 drivers/net/iavf/iavf_rxtx_vec_avx2.c   | 29 ++---
 drivers/net/iavf/iavf_rxtx_vec_avx512.c | 42 ++---
 drivers/net/iavf/iavf_rxtx_vec_sse.c| 21 -
 drivers/net/iavf/iavf_vchnl.c   | 20 
 9 files changed, 150 insertions(+), 13 deletions(-)

diff --git a/doc/guides/nics/intel_vf.rst b/doc/guides/nics/intel_vf.rst
index 7613e1c5e5..19c461c3de 100644
--- a/doc/guides/nics/intel_vf.rst
+++ b/doc/guides/nics/intel_vf.rst
@@ -104,6 +104,9 @@ For more detail on SR-IOV, please refer to the following 
documents:
 Enable vf auto-reset by setting the ``devargs`` parameter like ``-a 
18:01.0,auto_reset=1`` when IAVF is backed
 by an Intel® E810 device or an Intel® 700 Series Ethernet device.
 
+Enable vf no-poll-on-link-down by setting the ``devargs`` parameter like 
``-a 18:01.0,no-poll-on-link-down=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 FM1 Series VF 
infrastructure
 
^
 
diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 04774ce124..71cb08f0b1 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -308,6 +308,7 @@ struct iavf_devargs {
uint16_t quanta_size;
uint32_t watchdog_period;
uint8_t  auto_reset;
+   uint16_t no_poll_on_link_down;
 };
 
 struct iavf_security_ctx;
@@ -326,6 +327,7 @@ struct iavf_adapter {
uint32_t ptype_tbl[IAVF_MAX_PKT_TYPE] __rte_cache_min_aligned;
bool stopped;
bool closed;
+   bool no_poll;
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 5b2634a4e3..98cc5c8ea8 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -38,7 +38,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_NO_POLL_ON_LINK_DOWN_ARG "no-poll-on-link-down"
 uint64_t iavf_timestamp_dynflag;
 int iavf_timestamp_dynfield_offset = -1;
 
@@ -47,6 +47,7 @@ static const char * const iavf_valid_args[] = {
IAVF_QUANTA_SIZE_ARG,
IAVF_RESET_WATCHDOG_ARG,
IAVF_ENABLE_AUTO_RESET_ARG,
+   IAVF_NO_POLL_ON_LINK_DOWN_ARG,
NULL
 };
 
@@ -2291,6 +2292,7 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
struct rte_kvargs *kvlist;
int ret;
int watchdog_period = -1;
+   uint16_t no_poll_on_link_down;
 
if (!devargs)
return 0;
@@ -2324,6 +2326,15 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
else
ad->devargs.watchdog_period = watchdog_period;
 
+   ret = rte_kvargs_process(kvlist, IAVF_NO_POLL_ON_LINK_DOWN_ARG,
+&parse_u16, &no_poll_on_link_down);
+   if (ret)
+   goto bail;
+   if (no_poll_on_link_down == 0)
+   ad->devargs.no_poll_on_link_down = 0;
+   else
+   ad->devargs.no_poll_on_link_down = 1;
+
if (ad->devargs.quanta_size != 0 &&
(ad->devargs.quanta_size < 256 || ad->devargs.quanta_size > 4096 ||
 ad->devargs.quanta_size & 0x40)) {
@@ -2337,6 +2348,9 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
if (ret)
goto bail;
 
+   if (ad->devargs.auto_reset != 0)
+   ad->devargs.no_poll_on_link_down = 1;
+
 bail:
rte_kvargs_free(kvlist);
return ret;
diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index 0484988d13..a5f63ce30d 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -777,6 +77

[PATCH v4] app/test: append 'allow' parameters to secondary processes

2023-09-26 Thread Mingjin Ye
The 'allow' parameters are not passed to the secondary process, and all
devices will be loaded by default. When the primary process specifies
the 'allow' parameters and does not specify all devices that use the
vfio-pci driver, the secondary process will not load the devices as
expected, which will return incorrect test results.

This patch fixes this issue by appending the 'allow' parameters to the
secondary process.

Fixes: 086eb64db39e ("test/pdump: add unit test for pdump library")
Fixes: 148f963fb532 ("xen: core library changes")
Fixes: af75078fece3 ("first public release")
Fixes: b8d5e544e73e ("test: add procfs error message for multi-process launch")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
v4: Resolve patch conflicts and optimize code.
---
 app/test/process.h | 60 +++---
 1 file changed, 57 insertions(+), 3 deletions(-)

diff --git a/app/test/process.h b/app/test/process.h
index af7bc3e0de..1cdf28752e 100644
--- a/app/test/process.h
+++ b/app/test/process.h
@@ -18,6 +18,8 @@
 
 #include  /* strlcpy */
 
+#include 
+
 #ifdef RTE_EXEC_ENV_FREEBSD
 #define self "curproc"
 #define exe "file"
@@ -34,6 +36,47 @@ extern uint16_t flag_for_send_pkts;
 #endif
 #endif
 
+#define PREFIX_ALLOW "--allow"
+
+static int
+add_parameter_allow(char **argv, int max_capacity)
+{
+   struct rte_devargs *devargs;
+   int count = 0;
+   int name_length, data_length;
+   char *dev;
+   int malloc_size;
+
+   RTE_EAL_DEVARGS_FOREACH(NULL, devargs) {
+   if (count >= max_capacity)
+   return count;
+
+   name_length = strlen(devargs->name);
+   if (name_length == 0)
+   continue;
+
+   if (devargs->data != NULL)
+   data_length = strlen(devargs->data);
+   else
+   data_length = 0;
+
+   malloc_size = name_length + data_length + 1;
+   dev = malloc(malloc_size);
+
+   memcpy(dev, devargs->name, name_length);
+   if (data_length > 0)
+   memcpy(dev + name_length, devargs->data, data_length);
+   memset(dev + malloc_size - 1, 0, 1);
+
+   *(argv + count) =  strdup(PREFIX_ALLOW);
+   count++;
+
+   *(argv + count) = dev;
+   count++;
+   }
+   return count;
+}
+
 /*
  * launches a second copy of the test process using the given argv parameters,
  * which should include argv[0] as the process name. To identify in the
@@ -44,7 +87,9 @@ static inline int
 process_dup(const char *const argv[], int numargs, const char *env_value)
 {
int num;
-   char *argv_cpy[numargs + 1];
+   char **argv_cpy;
+   unsigned int allow_num;
+   unsigned int argv_num;
int i, status;
char path[32];
 #ifdef RTE_LIB_PDUMP
@@ -58,12 +103,15 @@ process_dup(const char *const argv[], int numargs, const 
char *env_value)
if (pid < 0)
return -1;
else if (pid == 0) {
+   allow_num = rte_devargs_type_count(RTE_DEVTYPE_ALLOWED);
+   argv_num = numargs + allow_num * 2 + 1;
+   argv_cpy = malloc(argv_num * sizeof(char *));
/* make a copy of the arguments to be passed to exec */
for (i = 0; i < numargs; i++)
argv_cpy[i] = strdup(argv[i]);
-   argv_cpy[i] = NULL;
num = numargs;
-
+   num += add_parameter_allow(&argv_cpy[i], allow_num * 2);
+   argv_cpy[argv_num - 1] = NULL;
 #ifdef RTE_EXEC_ENV_LINUX
{
const char *procdir = "/proc/" self "/fd/";
@@ -131,6 +179,12 @@ process_dup(const char *const argv[], int numargs, const 
char *env_value)
}
rte_panic("Cannot exec: %s\n", strerror(errno));
}
+
+   for (i = 0; i < num; i++) {
+   if (argv_cpy[i] != NULL)
+   free(argv_cpy[i]);
+   }
+   free(argv_cpy);
}
/* parent process does a wait */
 #ifdef RTE_LIB_PDUMP
-- 
2.25.1



[PATCH v2] net/vdev: fix insert vdev core dump

2024-07-16 Thread Mingjin Ye
In secondary processes, insert_vdev() may be called multiple times on the
same device due to multi-process hot-plugging of the vdev bus and EAL
parameters to add the same vdev.

In this case, when rte_devargs_insert() is called, the devargs->name
reference will be invalidated because rte_devargs_insert() destroys the
just-allocated devargs and replaces the pointer from the devargs list.
As a result, the reference to devargs->name stored in dev->device.name
will be invalid.

This patch fixes the issue by setting the device name after calling
rte_devargs_insert().

Fixes: cdb068f031c6 ("bus/vdev: scan by multi-process channel")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
v2: Modify commit log.
---
 drivers/bus/vdev/vdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index 38d05a9fe9..ec7abe7cda 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -288,7 +288,6 @@ insert_vdev(const char *name, const char *args,
 
dev->device.bus = &rte_vdev_bus;
dev->device.numa_node = SOCKET_ID_ANY;
-   dev->device.name = devargs->name;
 
if (find_vdev(name)) {
/*
@@ -303,6 +302,7 @@ insert_vdev(const char *name, const char *args,
if (init)
rte_devargs_insert(&devargs);
dev->device.devargs = devargs;
+   dev->device.name = devargs->name;
TAILQ_INSERT_TAIL(&vdev_device_list, dev, next);
 
if (p_dev)
-- 
2.25.1



[PATCH v3] net/iavf: add debug checks for mbuf

2023-02-13 Thread Mingjin Ye
The scalar Tx path would send wrong mbuf that causes the kernel driver to
fire the MDD event.

This patch adds mbuf detection in tx_prepare and enables it by defining
`RTE_ETHDEV_DEBUG_TX` macro to fix this issue. If validation fails,
rte_errno will be set to EINVAL and returned.

Fixes: 3fd32df381f8 ("net/iavf: check Tx packet with correct UP and queue")
Fixes: 12b435bf8f2f ("net/iavf: support flex desc metadata extraction")
Fixes: f28fbd1e6b50 ("net/iavf: check max SIMD bitwidth")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 drivers/net/iavf/iavf_rxtx.c | 645 +++
 1 file changed, 645 insertions(+)

diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index 8d49967538..6a2ddf2aca 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -24,12 +24,55 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #include "iavf.h"
 #include "iavf_rxtx.h"
 #include "iavf_ipsec_crypto.h"
 #include "rte_pmd_iavf.h"
 
+#define GRE_CHECKSUM_PRESENT   0x8000
+#define GRE_KEY_PRESENT0x2000
+#define GRE_SEQUENCE_PRESENT   0x1000
+#define GRE_EXT_LEN4
+#define GRE_SUPPORTED_FIELDS   (GRE_CHECKSUM_PRESENT | GRE_KEY_PRESENT |\
+GRE_SEQUENCE_PRESENT)
+
+#ifndef IPPROTO_IPIP
+#define IPPROTO_IPIP 4
+#endif
+#ifndef IPPROTO_GRE
+#define IPPROTO_GRE47
+#endif
+
+static uint16_t vxlan_gpe_udp_port = RTE_VXLAN_GPE_DEFAULT_PORT;
+static uint16_t geneve_udp_port = RTE_GENEVE_DEFAULT_PORT;
+
+struct simple_gre_hdr {
+   uint16_t flags;
+   uint16_t proto;
+} __rte_packed;
+
+/* structure that caches offload info for the current packet */
+struct offload_info {
+   uint16_t ethertype;
+   uint8_t gso_enable;
+   uint16_t l2_len;
+   uint16_t l3_len;
+   uint16_t l4_len;
+   uint8_t l4_proto;
+   uint8_t is_tunnel;
+   uint16_t outer_ethertype;
+   uint16_t outer_l2_len;
+   uint16_t outer_l3_len;
+   uint8_t outer_l4_proto;
+   uint16_t tso_segsz;
+   uint16_t tunnel_tso_segsz;
+   uint32_t pkt_len;
+};
+
 /* Offset of mbuf dynamic field for protocol extraction's metadata */
 int rte_pmd_ifd_dynfield_proto_xtr_metadata_offs = -1;
 
@@ -2949,6 +2992,600 @@ iavf_check_vlan_up2tc(struct iavf_tx_queue *txq, struct 
rte_mbuf *m)
}
 }
 
+/* Parse an IPv4 header to fill l3_len, l4_len, and l4_proto */
+static inline void
+parse_ipv4(struct rte_ipv4_hdr *ipv4_hdr, struct offload_info *info)
+{
+   struct rte_tcp_hdr *tcp_hdr;
+
+   info->l3_len = rte_ipv4_hdr_len(ipv4_hdr);
+   info->l4_proto = ipv4_hdr->next_proto_id;
+
+   /* only fill l4_len for TCP, it's useful for TSO */
+   if (info->l4_proto == IPPROTO_TCP) {
+   tcp_hdr = (struct rte_tcp_hdr *)
+   ((char *)ipv4_hdr + info->l3_len);
+   info->l4_len = (tcp_hdr->data_off & 0xf0) >> 2;
+   } else if (info->l4_proto == IPPROTO_UDP) {
+   info->l4_len = sizeof(struct rte_udp_hdr);
+   } else {
+   info->l4_len = 0;
+   }
+}
+
+/* Parse an IPv6 header to fill l3_len, l4_len, and l4_proto */
+static inline void
+parse_ipv6(struct rte_ipv6_hdr *ipv6_hdr, struct offload_info *info)
+{
+   struct rte_tcp_hdr *tcp_hdr;
+
+   info->l3_len = sizeof(struct rte_ipv6_hdr);
+   info->l4_proto = ipv6_hdr->proto;
+
+   /* only fill l4_len for TCP, it's useful for TSO */
+   if (info->l4_proto == IPPROTO_TCP) {
+   tcp_hdr = (struct rte_tcp_hdr *)
+   ((char *)ipv6_hdr + info->l3_len);
+   info->l4_len = (tcp_hdr->data_off & 0xf0) >> 2;
+   } else if (info->l4_proto == IPPROTO_UDP) {
+   info->l4_len = sizeof(struct rte_udp_hdr);
+   } else {
+   info->l4_len = 0;
+   }
+}
+
+/*
+ * Parse an ethernet header to fill the ethertype, l2_len, l3_len and
+ * ipproto. This function is able to recognize IPv4/IPv6 with optional VLAN
+ * headers. The l4_len argument is only set in case of TCP (useful for TSO).
+ */
+static inline void
+parse_ethernet(struct rte_ether_hdr *eth_hdr, struct offload_info *info)
+{
+   struct rte_ipv4_hdr *ipv4_hdr;
+   struct rte_ipv6_hdr *ipv6_hdr;
+   struct rte_vlan_hdr *vlan_hdr;
+
+   info->l2_len = sizeof(struct rte_ether_hdr);
+   info->ethertype = eth_hdr->ether_type;
+
+   while (info->ethertype == rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN) ||
+  info->ethertype == rte_cpu_to_be_16(RTE_ETHER_TYPE_QINQ)) {
+   vlan_hdr = (struct rte_vlan_hdr *)
+   ((char *)eth_hdr + info->l2_len);
+   info->l2_len  += sizeof(struct rte_vlan_hdr);
+   info->ethertype = vlan_hdr->eth_proto;

[RFC] net/ice: CVL support double vlan

2023-02-20 Thread Mingjin Ye
Aligned with kernel driver, optimized for inner and outer VLAN handling
in DPDK, and implemented double vlan insertion and stripping support.

1.adjust vlan stripping
Remove the judgment on dvm, vlan stripping only operates inner vlan.

2.support QinQ stripping
This patch support ice outer vlan strip on and off in QinQ mode with mask
bit of DEV_RX_OFFLOAD_QINQ_STRIP, users canuse "vlan set qinq_strip on 0"
to enable or "vlan setqinq_strip off 0" to disable ice outer vlan strip
when try with testpmd app.
Note: Due to hardware limitations, QinQ stripping containing two tagged RX
packets with the same EtherType (for example, two VLANs with EtherType =`
ETH_P_8021Q`) is not supported.

3.Support outer tag type switching
Add implementation of ethdev `vlan_tpid_set` api to enable Outer tags supp
-ort processing `ETH_P_8021Q` `ETH_P_8021AD` `ETH_P_QINQ1` outer tag types.

4.Support outer port insertion
If dvm is enabled, will support outer port vlan. User can use "tx_vlan set
pvid 0 45 on" to enable or "tx_vlan set pvid 0 45 off" to disable ice outer
vlan insertion try with testpmd app.

Signed-off-by: Mingjin Ye 
---
 drivers/net/ice/ice_ethdev.c | 444 +--
 drivers/net/ice/ice_ethdev.h |   1 +
 2 files changed, 430 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 0d011bbffa..3b43ca8c58 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -56,6 +56,24 @@ static const char * const ice_valid_args[] = {
 
 #define PPS_OUT_DELAY_NS  1
 
+/* Maximun number of VSI */
+#define ICE_MAX_NUM_VSIS  (768UL)
+
+/* The 119 bit offset of the LAN Rx queue context is the L2TSEL control bit. */
+#define ICE_L2TSEL_QRX_CONTEXT_REG_IDX 3
+#define ICE_L2TSEL_BIT_OFFSET  23
+enum ice_l2tsel {
+   ICE_L2TSEL_EXTRACT_FIRST_TAG_L2TAG2_2ND,
+   ICE_L2TSEL_EXTRACT_FIRST_TAG_L2TAG1,
+};
+
+/* 802.1Q VLAN Extended Header */
+#define ETH_P_8021Q0x8100
+/* 802.1ad Service VLAN */
+#define ETH_P_8021AD   0x88A8
+/* deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] */
+#define ETH_P_QINQ10x9100
+
 struct proto_xtr_ol_flag {
const struct rte_mbuf_dynflag param;
bool required;
@@ -130,6 +148,9 @@ static int ice_fw_version_get(struct rte_eth_dev *dev, char 
*fw_version,
  size_t fw_size);
 static int ice_vlan_pvid_set(struct rte_eth_dev *dev,
 uint16_t pvid, int on);
+static int ice_vlan_tpid_set(struct rte_eth_dev *dev,
+  enum rte_vlan_type vlan_type,
+  uint16_t tpid);
 static int ice_get_eeprom_length(struct rte_eth_dev *dev);
 static int ice_get_eeprom(struct rte_eth_dev *dev,
  struct rte_dev_eeprom_info *eeprom);
@@ -252,6 +273,7 @@ static const struct eth_dev_ops ice_eth_dev_ops = {
.rx_queue_intr_disable= ice_rx_queue_intr_disable,
.fw_version_get   = ice_fw_version_get,
.vlan_pvid_set= ice_vlan_pvid_set,
+   .vlan_tpid_set= ice_vlan_tpid_set,
.rxq_info_get = ice_rxq_info_get,
.txq_info_get = ice_txq_info_get,
.rx_burst_mode_get= ice_rx_burst_mode_get,
@@ -1588,6 +1610,9 @@ ice_setup_vsi(struct ice_pf *pf, enum ice_vsi_type type)
hw->func_caps.common_cap.rss_table_size;
pf->flags |= ICE_FLAG_RSS_AQ_CAPABLE;
 
+   /* Defines the type of outer tag expected */
+   pf->outer_ethertype = ETH_P_8021Q;
+
memset(&vsi_ctx, 0, sizeof(vsi_ctx));
switch (type) {
case ICE_VSI_PF:
@@ -1612,6 +1637,8 @@ ice_setup_vsi(struct ice_pf *pf, enum ice_vsi_type type)
 ICE_AQ_VSI_OUTER_VLAN_TX_MODE_S) &
ICE_AQ_VSI_OUTER_VLAN_TX_MODE_M;
vsi_ctx.info.outer_vlan_flags |=
+   (ICE_AQ_VSI_OUTER_VLAN_EMODE_NOTHING <<
+   ICE_AQ_VSI_OUTER_VLAN_EMODE_S) |
(ICE_AQ_VSI_OUTER_TAG_VLAN_8100 <<
 ICE_AQ_VSI_OUTER_TAG_TYPE_S) &
ICE_AQ_VSI_OUTER_TAG_TYPE_M;
@@ -4420,11 +4447,86 @@ ice_vsi_dis_inner_stripping(struct ice_vsi *vsi)
return ice_vsi_manage_vlan_stripping(vsi, false);
 }
 
-static int ice_vsi_ena_outer_stripping(struct ice_vsi *vsi)
+/**
+ * tpid_to_vsi_outer_vlan_type - convert from TPID to VSI context based 
tag_type
+ * @tpid: tpid used to translate into VSI context based tag_type
+ * @tag_type: output variable to hold the VSI context based tag type
+ */
+static int tpid_to_vsi_outer_vlan_type(u16 tpid, u8 *tag_type)
+{
+   switch (tpid) {
+   case ETH_P_8021Q:
+   *tag_type = ICE_AQ_VSI_OUTER_TAG_VLAN_8100;
+ 

[RFC] net/ice: CVL support double vlan

2023-02-20 Thread Mingjin Ye
Aligned with kernel driver, optimized for inner and outer VLAN handling
in DPDK, and implemented double vlan insertion and stripping support.

1.adjust vlan stripping
Remove the judgment on dvm, vlan stripping only operates inner vlan.

2.support QinQ stripping
This patch support ice outer vlan strip on and off in QinQ mode with mask
bit of DEV_RX_OFFLOAD_QINQ_STRIP, users canuse "vlan set qinq_strip on 0"
to enable or "vlan setqinq_strip off 0" to disable ice outer vlan strip
when try with testpmd app.
Note: Due to hardware limitations, QinQ stripping containing two tagged RX
packets with the same EtherType (for example, two VLANs with EtherType =`
ETH_P_8021Q`) is not supported.

3.Support outer tag type switching
Add implementation of ethdev `vlan_tpid_set` api to enable Outer tags supp
-ort processing `ETH_P_8021Q` `ETH_P_8021AD` `ETH_P_QINQ1` outer tag types.

4.Support outer port insertion
If dvm is enabled, will support outer port vlan. User can use "tx_vlan set
pvid 0 45 on" to enable or "tx_vlan set pvid 0 45 off" to disable ice outer
vlan insertion try with testpmd app.

Signed-off-by: Mingjin Ye 
---
 drivers/net/ice/ice_ethdev.c | 448 +--
 drivers/net/ice/ice_ethdev.h |   1 +
 2 files changed, 432 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 0d011bbffa..01d1b8dde8 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -56,6 +56,24 @@ static const char * const ice_valid_args[] = {
 
 #define PPS_OUT_DELAY_NS  1
 
+/* Maximun number of VSI */
+#define ICE_MAX_NUM_VSIS  (768UL)
+
+/* The 119 bit offset of the LAN Rx queue context is the L2TSEL control bit. */
+#define ICE_L2TSEL_QRX_CONTEXT_REG_IDX 3
+#define ICE_L2TSEL_BIT_OFFSET  23
+enum ice_l2tsel {
+   ICE_L2TSEL_EXTRACT_FIRST_TAG_L2TAG2_2ND,
+   ICE_L2TSEL_EXTRACT_FIRST_TAG_L2TAG1,
+};
+
+/* 802.1Q VLAN Extended Header */
+#define ETH_P_8021Q0x8100
+/* 802.1ad Service VLAN */
+#define ETH_P_8021AD   0x88A8
+/* deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] */
+#define ETH_P_QINQ10x9100
+
 struct proto_xtr_ol_flag {
const struct rte_mbuf_dynflag param;
bool required;
@@ -130,6 +148,9 @@ static int ice_fw_version_get(struct rte_eth_dev *dev, char 
*fw_version,
  size_t fw_size);
 static int ice_vlan_pvid_set(struct rte_eth_dev *dev,
 uint16_t pvid, int on);
+static int ice_vlan_tpid_set(struct rte_eth_dev *dev,
+  enum rte_vlan_type vlan_type,
+  uint16_t tpid);
 static int ice_get_eeprom_length(struct rte_eth_dev *dev);
 static int ice_get_eeprom(struct rte_eth_dev *dev,
  struct rte_dev_eeprom_info *eeprom);
@@ -252,6 +273,7 @@ static const struct eth_dev_ops ice_eth_dev_ops = {
.rx_queue_intr_disable= ice_rx_queue_intr_disable,
.fw_version_get   = ice_fw_version_get,
.vlan_pvid_set= ice_vlan_pvid_set,
+   .vlan_tpid_set= ice_vlan_tpid_set,
.rxq_info_get = ice_rxq_info_get,
.txq_info_get = ice_txq_info_get,
.rx_burst_mode_get= ice_rx_burst_mode_get,
@@ -1588,6 +1610,9 @@ ice_setup_vsi(struct ice_pf *pf, enum ice_vsi_type type)
hw->func_caps.common_cap.rss_table_size;
pf->flags |= ICE_FLAG_RSS_AQ_CAPABLE;
 
+   /* Defines the type of outer tag expected */
+   pf->outer_ethertype = ETH_P_8021Q;
+
memset(&vsi_ctx, 0, sizeof(vsi_ctx));
switch (type) {
case ICE_VSI_PF:
@@ -1612,9 +1637,11 @@ ice_setup_vsi(struct ice_pf *pf, enum ice_vsi_type type)
 ICE_AQ_VSI_OUTER_VLAN_TX_MODE_S) &
ICE_AQ_VSI_OUTER_VLAN_TX_MODE_M;
vsi_ctx.info.outer_vlan_flags |=
-   (ICE_AQ_VSI_OUTER_TAG_VLAN_8100 <<
+   (ICE_AQ_VSI_OUTER_VLAN_EMODE_NOTHING <<
+   ICE_AQ_VSI_OUTER_VLAN_EMODE_S) |
+   ((ICE_AQ_VSI_OUTER_TAG_VLAN_8100 <<
 ICE_AQ_VSI_OUTER_TAG_TYPE_S) &
-   ICE_AQ_VSI_OUTER_TAG_TYPE_M;
+   ICE_AQ_VSI_OUTER_TAG_TYPE_M);
}
 
/* FDIR */
@@ -4420,11 +4447,86 @@ ice_vsi_dis_inner_stripping(struct ice_vsi *vsi)
return ice_vsi_manage_vlan_stripping(vsi, false);
 }
 
-static int ice_vsi_ena_outer_stripping(struct ice_vsi *vsi)
+/**
+ * tpid_to_vsi_outer_vlan_type - convert from TPID to VSI context based 
tag_type
+ * @tpid: tpid used to translate into VSI context based tag_type
+ * @tag_type: output variable to hold the VSI context based tag type
+ */
+static 

[PATCH v2] doc: add PMD known issue

2023-05-06 Thread Mingjin Ye
Add a known issue: The ixgbe_vf driver is not multi-process safe.

Signed-off-by: Mingjin Ye 
---
v2: Modify issue description reason.
---
 doc/guides/nics/ixgbe.rst | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/doc/guides/nics/ixgbe.rst b/doc/guides/nics/ixgbe.rst
index b1d77ab7ab..9fb3c39bf4 100644
--- a/doc/guides/nics/ixgbe.rst
+++ b/doc/guides/nics/ixgbe.rst
@@ -461,3 +461,18 @@ show bypass config
 Show the bypass configuration for a bypass enabled NIC using the lowest port 
on the NIC::
 
testpmd> show bypass config (port_id)
+
+VF driver is not multi-process safe
+~~~
+
+Core dump may occur when we start secondary processes on the VF port.
+Mainstream Linux distributions have the ASLR feature enabled by default,
+and the text segment of the process memory space is randomized.
+The secondary process calls the function address shared by the primary
+process, resulting in a core dump.
+
+   .. Note::
+
+  Support for ASLR features varies by distribution. Redhat and
+  Centos series distributions work fine. Ubuntu distributions
+  will core dump, other Linux distributions are unknown.
-- 
2.25.1



[PATCH v2] net/ice: support double vlan

2023-05-06 Thread Mingjin Ye
Aligned with kernel driver, optimized for inner and outer VLAN handling
in DPDK, and implemented double vlan insertion and stripping support.
NIC must work in double vlan mode(DVM), depending on FW/SW.

1. Adjust vlan stripping
The vlan stripping enable/disable is applied to the inner vlan.

2. Support QinQ stripping
The ice outer vlan strip is enabled/disabled by the mask bit
of `RTE_ETH_RX_OFFLOAD_QINQ_STRIP`, and the user can
use "vlan set qinq_strip on 0" to enable or "vlan setqinq_strip
off 0" to disable the ice outer vlan strip in testpmd.

3. Support outer tag type switching
Implement the ethdev `vlan_tpid_set` api to enable outer tag support to
handle `RTE_ETHER_TYPE_VLAN`` RTE_ETHER_TYPE_QINQ`` RTE_ETHER_TYPE_QINQ1`
outer tag types.

4. Support outer port-based vlan insertion
Implement port-based outer vlan insertion. User can use "tx_vlan set
pvid 0 45 on" to enable or "tx_vlan set pvid 0 45 off" to disable the
outer vlan insertion in testpmd.

Signed-off-by: Mingjin Ye 
---
v2: Apply QinQ when initializing vlan offload.
---
 drivers/net/ice/ice_ethdev.c | 422 +--
 drivers/net/ice/ice_ethdev.h |   1 +
 2 files changed, 408 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 9a88cf9796..f79dcff3d5 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -56,6 +56,17 @@ static const char * const ice_valid_args[] = {
 
 #define PPS_OUT_DELAY_NS  1
 
+/* Maximum number of VSI */
+#define ICE_MAX_NUM_VSIS  (768UL)
+
+/* The 119 bit offset of the LAN Rx queue context is the L2TSEL control bit. */
+#define ICE_L2TSEL_QRX_CONTEXT_REG_IDX 3
+#define ICE_L2TSEL_BIT_OFFSET 23
+enum ice_l2tsel {
+   ICE_L2TSEL_EXTRACT_FIRST_TAG_L2TAG2_2ND,
+   ICE_L2TSEL_EXTRACT_FIRST_TAG_L2TAG1,
+};
+
 struct proto_xtr_ol_flag {
const struct rte_mbuf_dynflag param;
bool required;
@@ -130,6 +141,9 @@ static int ice_fw_version_get(struct rte_eth_dev *dev, char 
*fw_version,
  size_t fw_size);
 static int ice_vlan_pvid_set(struct rte_eth_dev *dev,
 uint16_t pvid, int on);
+static int ice_vlan_tpid_set(struct rte_eth_dev *dev,
+  enum rte_vlan_type vlan_type,
+  uint16_t tpid);
 static int ice_get_eeprom_length(struct rte_eth_dev *dev);
 static int ice_get_eeprom(struct rte_eth_dev *dev,
  struct rte_dev_eeprom_info *eeprom);
@@ -252,6 +266,7 @@ static const struct eth_dev_ops ice_eth_dev_ops = {
.rx_queue_intr_disable= ice_rx_queue_intr_disable,
.fw_version_get   = ice_fw_version_get,
.vlan_pvid_set= ice_vlan_pvid_set,
+   .vlan_tpid_set= ice_vlan_tpid_set,
.rxq_info_get = ice_rxq_info_get,
.txq_info_get = ice_txq_info_get,
.rx_burst_mode_get= ice_rx_burst_mode_get,
@@ -1588,6 +1603,9 @@ ice_setup_vsi(struct ice_pf *pf, enum ice_vsi_type type)
hw->func_caps.common_cap.rss_table_size;
pf->flags |= ICE_FLAG_RSS_AQ_CAPABLE;
 
+   /* Defines the type of outer tag expected */
+   pf->outer_ethertype = RTE_ETHER_TYPE_VLAN;
+
memset(&vsi_ctx, 0, sizeof(vsi_ctx));
switch (type) {
case ICE_VSI_PF:
@@ -1615,6 +1633,9 @@ ice_setup_vsi(struct ice_pf *pf, enum ice_vsi_type type)
(ICE_AQ_VSI_OUTER_TAG_VLAN_8100 <<
 ICE_AQ_VSI_OUTER_TAG_TYPE_S) &
ICE_AQ_VSI_OUTER_TAG_TYPE_M;
+   vsi_ctx.info.outer_vlan_flags |=
+   (ICE_AQ_VSI_OUTER_VLAN_EMODE_NOTHING <<
+   ICE_AQ_VSI_OUTER_VLAN_EMODE_S);
}
 
/* FDIR */
@@ -3698,7 +3719,7 @@ ice_dev_start(struct rte_eth_dev *dev)
ice_set_tx_function(dev);
 
mask = RTE_ETH_VLAN_STRIP_MASK | RTE_ETH_VLAN_FILTER_MASK |
-   RTE_ETH_VLAN_EXTEND_MASK;
+   RTE_ETH_VLAN_EXTEND_MASK | RTE_ETH_QINQ_STRIP_MASK;
ret = ice_vlan_offload_set(dev, mask);
if (ret) {
PMD_INIT_LOG(ERR, "Unable to set VLAN offload");
@@ -4431,11 +4452,86 @@ ice_vsi_dis_inner_stripping(struct ice_vsi *vsi)
return ice_vsi_manage_vlan_stripping(vsi, false);
 }
 
-static int ice_vsi_ena_outer_stripping(struct ice_vsi *vsi)
+/**
+ * tpid_to_vsi_outer_vlan_type - convert from TPID to VSI context based 
tag_type
+ * @tpid: tpid used to translate into VSI context based tag_type
+ * @tag_type: output variable to hold the VSI context based tag type
+ */
+static int tpid_to_vsi_outer_vlan_type(u16 tpid, u8 *tag_type)
+{
+   switch (tpid) {
+   case RTE_ETHER_TYPE_VLAN:
+   

[PATCH] net/ice: fix statistics

2023-05-10 Thread Mingjin Ye
When the stats_get api is called for the first time in pmd, the offset
of the stats register is not recorded. That results in all the obtained
count values being 0.

This patch adds reset statistics before dev_init returning. That avoids
some noise being counted.

Fixes: 12443386a0b0 ("net/ice: support flex Rx descriptor RxDID22")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 drivers/net/ice/ice_ethdev.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 9a88cf9796..1116880485 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -2440,6 +2440,9 @@ ice_dev_init(struct rte_eth_dev *dev)
 
pf->supported_rxdid = ice_get_supported_rxdid(hw);
 
+   /* reset all stats of the device, including pf and main vsi */
+   ice_stats_reset(dev);
+
return 0;
 
 err_flow_init:
-- 
2.25.1



[PATCH v3] doc: comment VF does not support multi-process

2023-05-16 Thread Mingjin Ye
Announcing that multi-process is not supported

Signed-off-by: Mingjin Ye 
---
v2: Modify issue description reason.
---
V3: Modify description.
---
 doc/guides/nics/ixgbe.rst | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/doc/guides/nics/ixgbe.rst b/doc/guides/nics/ixgbe.rst
index b1d77ab7ab..816d614c33 100644
--- a/doc/guides/nics/ixgbe.rst
+++ b/doc/guides/nics/ixgbe.rst
@@ -461,3 +461,9 @@ show bypass config
 Show the bypass configuration for a bypass enabled NIC using the lowest port 
on the NIC::
 
testpmd> show bypass config (port_id)
+
+VF driver does not support multi-process
+
+
+The VF driver does not support multi-process. And some function pointers
+in the case of multi-process are not set correctly.
-- 
2.25.1



[PATCH] net/ice: DCF adds default RSS

2023-05-16 Thread Mingjin Ye
When dcf and iavf ports are used together, the default configuration of
ipv4[6] rss for dcf ports is lost.

This patch adds RSS configuration to the dcf port. Any kernel PF-enabled
default RSS will be disabled at initialization.

In addition, the default RSS will be configured based on
rte_eth_rss_conf->rss_hf. Currently supported default rss_type:
ipv4[6], ipv4[6]_udp, ipv4[6]_tcp, ipv4[6]_sctp.

Fixes: 79b1f7ab462d ("net/ice: support RSS RETA configuration in DCF mode")
Fixes: 7564d5509611 ("net/ice: add DCF hardware initialization")
Fixes: 3a6bfc37eaf4 ("net/ice: support QoS config VF bandwidth in DCF")
Fixes: 3220d865382c ("net/ice: init RSS during DCF start")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 drivers/net/ice/ice_dcf.c| 259 ++-
 drivers/net/ice/ice_dcf.h|   4 +
 drivers/net/ice/ice_dcf_ethdev.c |  24 ++-
 3 files changed, 285 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ice/ice_dcf.c b/drivers/net/ice/ice_dcf.c
index 1c3d22ae0f..4575d831e1 100644
--- a/drivers/net/ice/ice_dcf.c
+++ b/drivers/net/ice/ice_dcf.c
@@ -36,6 +36,130 @@
(sizeof(struct virtchnl_vf_resource) +  \
IAVF_MAX_VF_VSI * sizeof(struct virtchnl_vsi_resource))
 
+#define FIELD_SELECTOR(proto_hdr_field) \
+   (1UL << ((proto_hdr_field) & PROTO_HDR_FIELD_MASK))
+#define BUFF_NOUSED0
+
+#define proto_hdr_eth { \
+   VIRTCHNL_PROTO_HDR_ETH, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_ETH_SRC) | \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_ETH_DST), {BUFF_NOUSED} }
+
+#define proto_hdr_svlan { \
+   VIRTCHNL_PROTO_HDR_S_VLAN, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_S_VLAN_ID), {BUFF_NOUSED} }
+
+#define proto_hdr_cvlan { \
+   VIRTCHNL_PROTO_HDR_C_VLAN, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_C_VLAN_ID), {BUFF_NOUSED} }
+
+#define proto_hdr_ipv4 { \
+   VIRTCHNL_PROTO_HDR_IPV4, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_SRC) | \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_DST), {BUFF_NOUSED} }
+
+#define proto_hdr_ipv4_with_prot { \
+   VIRTCHNL_PROTO_HDR_IPV4, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_SRC) | \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_DST) | \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_PROT), {BUFF_NOUSED} }
+
+#define proto_hdr_ipv6 { \
+   VIRTCHNL_PROTO_HDR_IPV6, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_SRC) | \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_DST), {BUFF_NOUSED} }
+
+#define proto_hdr_ipv6_frag { \
+   VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG_PKID), {BUFF_NOUSED} }
+
+#define proto_hdr_ipv6_with_prot { \
+   VIRTCHNL_PROTO_HDR_IPV6, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_SRC) | \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_DST) | \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_PROT), {BUFF_NOUSED} }
+
+#define proto_hdr_udp { \
+   VIRTCHNL_PROTO_HDR_UDP, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_UDP_SRC_PORT) | \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_UDP_DST_PORT), {BUFF_NOUSED} }
+
+#define proto_hdr_tcp { \
+   VIRTCHNL_PROTO_HDR_TCP, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_TCP_SRC_PORT) | \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_TCP_DST_PORT), {BUFF_NOUSED} }
+
+#define proto_hdr_sctp { \
+   VIRTCHNL_PROTO_HDR_SCTP, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT) | \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_SCTP_DST_PORT), {BUFF_NOUSED} }
+
+#define proto_hdr_esp { \
+   VIRTCHNL_PROTO_HDR_ESP, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_ESP_SPI), {BUFF_NOUSED} }
+
+#define proto_hdr_ah { \
+   VIRTCHNL_PROTO_HDR_AH, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_AH_SPI), {BUFF_NOUSED} }
+
+#define proto_hdr_l2tpv3 { \
+   VIRTCHNL_PROTO_HDR_L2TPV3, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_L2TPV3_SESS_ID), {BUFF_NOUSED} }
+
+#define proto_hdr_pfcp { \
+   VIRTCHNL_PROTO_HDR_PFCP, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_PFCP_SEID), {BUFF_NOUSED} }
+
+#define proto_hdr_gtpc { \
+   VIRTCHNL_PROTO_HDR_GTPC, 0, {BUFF_NOUSED} }
+
+#define proto_hdr_ecpri { \
+   VIRTCHNL_PROTO_HDR_ECPRI, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_ECPRI_PC_RTC_ID), {BUFF_NOUSED} }
+
+#define proto_hdr_l2tpv2 { \
+   VIRTCHNL_PROTO_HDR_L2TPV2, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_L2TPV2_SESS_ID) | \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_L2TPV2_LEN_SESS_ID), {BUFF_NOUSED} }
+
+#define proto_hdr_ppp { \
+   VIRTCHNL_PROTO_HDR_PPP, 0, {BUFF_NOUSED} }
+
+#define TUNNEL_LEVEL_OUTER 0
+#define TUNNEL_LEVEL_INNER 1
+
+struct virtchnl_proto_hdrs ice_dcf_inner_ipv4_tmplt = {
+   TUNNEL_LEVEL_INNER, 1, {{proto_hdr_ipv4}}
+};
+
+struct virtchnl_proto_hdrs ice_dcf_inner_ipv4_udp_tmplt = {
+   TUNNEL_LEVEL_INNER, 2, {{proto_hdr_ipv4_with_prot, proto_hdr_udp}}
+};
+
+struct virtchnl_proto_hdrs ice_dcf_i

[PATCH v4] doc: update ixgbe VF features list

2023-05-17 Thread Mingjin Ye
The ixgbe VF driver is not multi-process aware. Some function pointers are
not set correctly in multi-process situations.

Remove the multiprocess aware feature from the features list.

Signed-off-by: Mingjin Ye 
---
v2: Modify issue description reason.
---
V3: Modify description.
---
V4: Removed the multiprocess aware feature.
---
 doc/guides/nics/features/ixgbe_vf.ini | 1 -
 1 file changed, 1 deletion(-)

diff --git a/doc/guides/nics/features/ixgbe_vf.ini 
b/doc/guides/nics/features/ixgbe_vf.ini
index e14325045c..299ccd4b61 100644
--- a/doc/guides/nics/features/ixgbe_vf.ini
+++ b/doc/guides/nics/features/ixgbe_vf.ini
@@ -32,7 +32,6 @@ Tx descriptor status = Y
 Basic stats  = Y
 Extended stats   = Y
 Registers dump   = Y
-Multiprocess aware   = Y
 FreeBSD  = Y
 Linux= Y
 Windows  = Y
-- 
2.25.1



[PATCH v2] net/ice: DCF adds default RSS

2023-05-24 Thread Mingjin Ye
The default RSS configured by the kernel driver for the DCF port does not
work properly when the DCF and iavf ports are used together.

This patch clears the RSS configured by the kernel driver and reconfigures
the default RSS for it when the DCF port is initialized.

Signed-off-by: Mingjin Ye 
---
v2: Refine the commit log.
---
 drivers/net/ice/ice_dcf.c| 259 ++-
 drivers/net/ice/ice_dcf.h|   4 +
 drivers/net/ice/ice_dcf_ethdev.c |  24 ++-
 3 files changed, 285 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ice/ice_dcf.c b/drivers/net/ice/ice_dcf.c
index 6f7e103c3b..8837f84026 100644
--- a/drivers/net/ice/ice_dcf.c
+++ b/drivers/net/ice/ice_dcf.c
@@ -38,6 +38,130 @@
(sizeof(struct virtchnl_vf_resource) +  \
IAVF_MAX_VF_VSI * sizeof(struct virtchnl_vsi_resource))
 
+#define FIELD_SELECTOR(proto_hdr_field) \
+   (1UL << ((proto_hdr_field) & PROTO_HDR_FIELD_MASK))
+#define BUFF_NOUSED0
+
+#define proto_hdr_eth { \
+   VIRTCHNL_PROTO_HDR_ETH, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_ETH_SRC) | \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_ETH_DST), {BUFF_NOUSED} }
+
+#define proto_hdr_svlan { \
+   VIRTCHNL_PROTO_HDR_S_VLAN, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_S_VLAN_ID), {BUFF_NOUSED} }
+
+#define proto_hdr_cvlan { \
+   VIRTCHNL_PROTO_HDR_C_VLAN, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_C_VLAN_ID), {BUFF_NOUSED} }
+
+#define proto_hdr_ipv4 { \
+   VIRTCHNL_PROTO_HDR_IPV4, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_SRC) | \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_DST), {BUFF_NOUSED} }
+
+#define proto_hdr_ipv4_with_prot { \
+   VIRTCHNL_PROTO_HDR_IPV4, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_SRC) | \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_DST) | \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_PROT), {BUFF_NOUSED} }
+
+#define proto_hdr_ipv6 { \
+   VIRTCHNL_PROTO_HDR_IPV6, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_SRC) | \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_DST), {BUFF_NOUSED} }
+
+#define proto_hdr_ipv6_frag { \
+   VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG_PKID), {BUFF_NOUSED} }
+
+#define proto_hdr_ipv6_with_prot { \
+   VIRTCHNL_PROTO_HDR_IPV6, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_SRC) | \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_DST) | \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_PROT), {BUFF_NOUSED} }
+
+#define proto_hdr_udp { \
+   VIRTCHNL_PROTO_HDR_UDP, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_UDP_SRC_PORT) | \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_UDP_DST_PORT), {BUFF_NOUSED} }
+
+#define proto_hdr_tcp { \
+   VIRTCHNL_PROTO_HDR_TCP, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_TCP_SRC_PORT) | \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_TCP_DST_PORT), {BUFF_NOUSED} }
+
+#define proto_hdr_sctp { \
+   VIRTCHNL_PROTO_HDR_SCTP, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT) | \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_SCTP_DST_PORT), {BUFF_NOUSED} }
+
+#define proto_hdr_esp { \
+   VIRTCHNL_PROTO_HDR_ESP, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_ESP_SPI), {BUFF_NOUSED} }
+
+#define proto_hdr_ah { \
+   VIRTCHNL_PROTO_HDR_AH, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_AH_SPI), {BUFF_NOUSED} }
+
+#define proto_hdr_l2tpv3 { \
+   VIRTCHNL_PROTO_HDR_L2TPV3, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_L2TPV3_SESS_ID), {BUFF_NOUSED} }
+
+#define proto_hdr_pfcp { \
+   VIRTCHNL_PROTO_HDR_PFCP, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_PFCP_SEID), {BUFF_NOUSED} }
+
+#define proto_hdr_gtpc { \
+   VIRTCHNL_PROTO_HDR_GTPC, 0, {BUFF_NOUSED} }
+
+#define proto_hdr_ecpri { \
+   VIRTCHNL_PROTO_HDR_ECPRI, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_ECPRI_PC_RTC_ID), {BUFF_NOUSED} }
+
+#define proto_hdr_l2tpv2 { \
+   VIRTCHNL_PROTO_HDR_L2TPV2, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_L2TPV2_SESS_ID) | \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_L2TPV2_LEN_SESS_ID), {BUFF_NOUSED} }
+
+#define proto_hdr_ppp { \
+   VIRTCHNL_PROTO_HDR_PPP, 0, {BUFF_NOUSED} }
+
+#define TUNNEL_LEVEL_OUTER 0
+#define TUNNEL_LEVEL_INNER 1
+
+struct virtchnl_proto_hdrs ice_dcf_inner_ipv4_tmplt = {
+   TUNNEL_LEVEL_INNER, 1, {{proto_hdr_ipv4}}
+};
+
+struct virtchnl_proto_hdrs ice_dcf_inner_ipv4_udp_tmplt = {
+   TUNNEL_LEVEL_INNER, 2, {{proto_hdr_ipv4_with_prot, proto_hdr_udp}}
+};
+
+struct virtchnl_proto_hdrs ice_dcf_inner_ipv4_tcp_tmplt = {
+   TUNNEL_LEVEL_INNER, 2, {{proto_hdr_ipv4_with_prot, proto_hdr_tcp}}
+};
+
+struct virtchnl_proto_hdrs ice_dcf_inner_ipv4_sctp_tmplt = {
+   TUNNEL_LEVEL_INNER, 2, {{proto_hdr_ipv4, proto_hdr_sctp}}
+};
+
+struct virtchnl_proto_hdrs ice_dcf_inner_ipv6_tmplt = {
+   TUNNEL_LEVEL_INNER, 1, {{proto_hdr_ipv6}}
+};
+
+struct virtchnl_proto_hdrs ice_dcf_inner_ipv6_udp_tmplt = {
+   TUNNEL_LEVE

[PATCH v12] net/iavf: add diagnostic support in TX path

2024-02-19 Thread Mingjin Ye
Implemented a Tx wrapper to perform a thorough check on mbufs,
categorizing and counting invalid cases by types for diagnostic
purposes. The count of invalid cases is accessible through xstats_get.

Also, the devarg option "mbuf_check" was introduced to configure the
diagnostic parameters to enable the appropriate diagnostic features.

supported cases: mbuf, size, segment, offload.
 1. mbuf: check for corrupted mbuf.
 2. size: check min/max packet length according to hw spec.
 3. segment: check number of mbuf segments not exceed hw limitation.
 4. offload: check any unsupported offload flag.

parameter format: "mbuf_check=" or "mbuf_check=[,]"
eg: dpdk-testpmd -a :81:01.0,mbuf_check=[mbuf,size] -- -i

Signed-off-by: Mingjin Ye 
---
v2: Remove call chain.
---
v3: Optimisation implementation.
---
v4: Fix Windows os compilation error.
---
v5: Split Patch.
---
v6: remove strict.
---
v9: Modify the description document.
---
v10: Modify vf rst document.
---
v11: modify comment log.
---
v12: Fix buggy logs and add necessary notes.
---
 doc/guides/nics/intel_vf.rst   | 11 
 drivers/net/iavf/iavf.h| 11 
 drivers/net/iavf/iavf_ethdev.c | 79 +++
 drivers/net/iavf/iavf_rxtx.c   | 98 ++
 drivers/net/iavf/iavf_rxtx.h   |  2 +
 5 files changed, 201 insertions(+)

diff --git a/doc/guides/nics/intel_vf.rst b/doc/guides/nics/intel_vf.rst
index ce96c2e1f8..b84ea214d4 100644
--- a/doc/guides/nics/intel_vf.rst
+++ b/doc/guides/nics/intel_vf.rst
@@ -111,6 +111,17 @@ For more detail on SR-IOV, please refer to the following 
documents:
 by setting the ``devargs`` parameter like ``-a 
18:01.0,no-poll-on-link-down=1``
 when IAVF is backed by an Intel\ |reg| E810 device or an Intel\ |reg| 700 
Series Ethernet device.
 
+When IAVF is backed by an Intel?? E810 device or an Intel?? 700 Series 
Ethernet device.
+Set the ``devargs`` parameter ``mbuf_check`` to enable TX diagnostics. For 
example,
+``-a 18:01.0,mbuf_check=`` or ``-a 
18:01.0,mbuf_check=[,...]``. Also,
+``xstats_get`` can be used to get the error counts, which are collected in 
``tx_mbuf_error_packets``
+xstats. For example, ``testpmd> show port xstats all``. Supported cases:
+
+*   mbuf: Check for corrupted mbuf.
+*   size: Check min/max packet length according to hw spec.
+*   segment: Check number of mbuf segments not exceed hw limitation.
+*   offload: Check any unsupported offload flag.
+
 The PCIE host-interface of Intel Ethernet Switch FM1 Series VF 
infrastructure
 
^
 
diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index ab24cb02c3..824ae4aa02 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -114,9 +114,14 @@ struct iavf_ipsec_crypto_stats {
} ierrors;
 };
 
+struct iavf_mbuf_stats {
+   uint64_t tx_pkt_errors;
+};
+
 struct iavf_eth_xstats {
struct virtchnl_eth_stats eth_stats;
struct iavf_ipsec_crypto_stats ips_stats;
+   struct iavf_mbuf_stats mbuf_stats;
 };
 
 /* Structure that defines a VSI, associated with a adapter. */
@@ -310,6 +315,7 @@ struct iavf_devargs {
uint32_t watchdog_period;
int auto_reset;
int no_poll_on_link_down;
+   uint64_t mbuf_check;
 };
 
 struct iavf_security_ctx;
@@ -353,6 +359,11 @@ enum iavf_tx_burst_type {
IAVF_TX_AVX512_CTX_OFFLOAD,
 };
 
+#define IAVF_MBUF_CHECK_F_TX_MBUF(1ULL << 0)
+#define IAVF_MBUF_CHECK_F_TX_SIZE(1ULL << 1)
+#define IAVF_MBUF_CHECK_F_TX_SEGMENT (1ULL << 2)
+#define IAVF_MBUF_CHECK_F_TX_OFFLOAD (1ULL << 3)
+
 /* Structure to store private data for each VF instance. */
 struct iavf_adapter {
struct iavf_hw hw;
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 1fb876e827..3fb255d748 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -39,6 +40,7 @@
 #define IAVF_RESET_WATCHDOG_ARG"watchdog_period"
 #define IAVF_ENABLE_AUTO_RESET_ARG "auto_reset"
 #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;
 int iavf_timestamp_dynfield_offset = -1;
 int rte_pmd_iavf_tx_lldp_dynfield_offset = -1;
@@ -49,6 +51,7 @@ static const char * const iavf_valid_args[] = {
IAVF_RESET_WATCHDOG_ARG,
IAVF_ENABLE_AUTO_RESET_ARG,
IAVF_NO_POLL_ON_LINK_DOWN_ARG,
+   IAVF_MBUF_CHECK_ARG,
NULL
 };
 
@@ -175,6 +178,7 @@ static const struct rte_iavf_xstats_name_off 
rte_iavf_stats_strings[] = {
{"tx_broadcast_packets", _OFF_OF(eth_stats.tx_broadcast)},
{"tx_dropped_packets", _OFF_OF(eth_stats

[PATCH v5] net/i40e: add diagnostic support in TX path

2024-03-01 Thread Mingjin Ye
Implemented a Tx wrapper to perform a thorough check on mbufs,
categorizing and counting invalid cases by types for diagnostic
purposes. The count of invalid cases is accessible through xstats_get.

Also, the devarg option "mbuf_check" was introduced to configure the
diagnostic parameters to enable the appropriate diagnostic features.

supported cases: mbuf, size, segment, offload.
 1. mbuf: check for corrupted mbuf.
 2. size: check min/max packet length according to hw spec.
 3. segment: check number of mbuf segments not exceed hw limitation.
 4. offload: check any unsupported offload flag.

parameter format: "mbuf_check=" or "mbuf_check=[,]"
eg: dpdk-testpmd -a :81:01.0,mbuf_check=[mbuf,size] -- -i

Signed-off-by: Mingjin Ye 
---
v2: remove strict.
---
v3: optimised.
---
v4: rebase.
---
v5: fix ci error.
---
 doc/guides/nics/i40e.rst   |  13 +++
 drivers/net/i40e/i40e_ethdev.c | 138 -
 drivers/net/i40e/i40e_ethdev.h |  28 ++
 drivers/net/i40e/i40e_rxtx.c   | 153 +++--
 drivers/net/i40e/i40e_rxtx.h   |   2 +
 5 files changed, 326 insertions(+), 8 deletions(-)

diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index 15689ac958..bf1d1e5d60 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -275,6 +275,19 @@ Runtime Configuration
 
   -a 84:00.0,vf_msg_cfg=80@120:180
 
+- ``Support TX diagnostics`` (default ``not enabled``)
+
+  Set the ``devargs`` parameter ``mbuf_check`` to enable TX diagnostics. For 
example,
+  ``-a 18:01.0,mbuf_check=`` or ``-a 
18:01.0,mbuf_check=[,...]``. Also,
+  ``xstats_get`` can be used to get the error counts, which are collected in
+  ``tx_mbuf_error_packets`` xstats. For example, ``testpmd> show port xstats 
all``.
+  Supported cases:
+
+  *   mbuf: Check for corrupted mbuf.
+  *   size: Check min/max packet length according to hw spec.
+  *   segment: Check number of mbuf segments not exceed hw limitation.
+  *   offload: Check any unsupported offload flag.
+
 Vector RX Pre-conditions
 
 For Vector RX it is assumed that the number of descriptor rings will be a power
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 3ca226156b..f23f80fd16 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -48,6 +48,7 @@
 #define ETH_I40E_SUPPORT_MULTI_DRIVER  "support-multi-driver"
 #define ETH_I40E_QUEUE_NUM_PER_VF_ARG  "queue-num-per-vf"
 #define ETH_I40E_VF_MSG_CFG"vf_msg_cfg"
+#define ETH_I40E_MBUF_CHECK_ARG   "mbuf_check"
 
 #define I40E_CLEAR_PXE_WAIT_MS 200
 #define I40E_VSI_TSR_QINQ_STRIP0x4010
@@ -412,6 +413,7 @@ static const char *const valid_keys[] = {
ETH_I40E_SUPPORT_MULTI_DRIVER,
ETH_I40E_QUEUE_NUM_PER_VF_ARG,
ETH_I40E_VF_MSG_CFG,
+   ETH_I40E_MBUF_CHECK_ARG,
NULL};
 
 static const struct rte_pci_id pci_id_i40e_map[] = {
@@ -545,6 +547,14 @@ static const struct rte_i40e_xstats_name_off 
rte_i40e_stats_strings[] = {
 #define I40E_NB_ETH_XSTATS (sizeof(rte_i40e_stats_strings) / \
sizeof(rte_i40e_stats_strings[0]))
 
+static const struct rte_i40e_xstats_name_off i40e_mbuf_strings[] = {
+   {"tx_mbuf_error_packets", offsetof(struct i40e_mbuf_stats,
+   tx_pkt_errors)},
+};
+
+#define I40E_NB_MBUF_XSTATS (sizeof(i40e_mbuf_strings) / \
+   sizeof(i40e_mbuf_strings[0]))
+
 static const struct rte_i40e_xstats_name_off rte_i40e_hw_port_strings[] = {
{"tx_link_down_dropped", offsetof(struct i40e_hw_port_stats,
tx_dropped_link_down)},
@@ -1373,6 +1383,88 @@ read_vf_msg_config(__rte_unused const char *key,
return 0;
 }
 
+static int
+read_mbuf_check_config(__rte_unused const char *key, const char *value, void 
*args)
+{
+   char *cur;
+   char *tmp;
+   int str_len;
+   int valid_len;
+
+   int ret = 0;
+   uint64_t *mc_flags = args;
+   char *str2 = strdup(value);
+   if (str2 == NULL)
+   return -1;
+
+   str_len = strlen(str2);
+   if (str2[0] == '[' && str2[str_len - 1] == ']') {
+   if (str_len < 3) {
+   ret = -1;
+   goto mdd_end;
+   }
+   valid_len = str_len - 2;
+   memmove(str2, str2 + 1, valid_len);
+   memset(str2 + valid_len, '\0', 2);
+   }
+   cur = strtok_r(str2, ",", &tmp);
+   while (cur != NULL) {
+   if (!strcmp(cur, "mbuf"))
+   *mc_flags |= I40E_MBUF_CHECK_F_TX_MBUF;
+   else if (!strcmp(cur, "size"))
+   *mc_flags |= I40E_MBUF_CHECK_F_TX_SIZE;
+   else if (!strcmp(cur, "segment"))
+   *m

[PATCH v3] net/ice: add diagnostic support in TX path

2024-03-01 Thread Mingjin Ye
Implemented a Tx wrapper to perform a thorough check on mbufs,
categorizing and counting invalid cases by types for diagnostic
purposes. The count of invalid cases is accessible through xstats_get.

Also, the devarg option "mbuf_check" was introduced to configure the
diagnostic parameters to enable the appropriate diagnostic features.

supported cases: mbuf, size, segment, offload.
 1. mbuf: check for corrupted mbuf.
 2. size: check min/max packet length according to hw spec.
 3. segment: check number of mbuf segments not exceed hw limitation.
 4. offload: check any unsupported offload flag.

parameter format: "mbuf_check=" or "mbuf_check=[,]"
eg: dpdk-testpmd -a :81:01.0,mbuf_check=[mbuf,size] -- -i

Signed-off-by: Mingjin Ye 
---
v2: rebase.
---
v3: Modify comment log.
---
 doc/guides/nics/ice.rst  |  13 +++
 drivers/net/ice/ice_ethdev.c | 108 +++-
 drivers/net/ice/ice_ethdev.h |  23 +
 drivers/net/ice/ice_rxtx.c   | 158 ---
 drivers/net/ice/ice_rxtx.h   |  20 +
 5 files changed, 311 insertions(+), 11 deletions(-)

diff --git a/doc/guides/nics/ice.rst b/doc/guides/nics/ice.rst
index bafb3ba022..d1aee811b3 100644
--- a/doc/guides/nics/ice.rst
+++ b/doc/guides/nics/ice.rst
@@ -257,6 +257,19 @@ Runtime Configuration
   As a trade-off, this configuration may cause the packet processing 
performance
   degradation due to the PCI bandwidth limitation.
 
+- ``Tx diagnostics`` (default ``not enabled``)
+
+  Set the ``devargs`` parameter ``mbuf_check`` to enable TX diagnostics. For 
example,
+  ``-a 18:01.0,mbuf_check=`` or ``-a 
18:01.0,mbuf_check=[,...]``.
+  Also, ``xstats_get`` can be used to get the error counts, which are 
collected in
+  ``tx_mbuf_error_packets`` xstats. For example, ``testpmd> show port xstats 
all``.
+  Supported cases:
+
+  *   mbuf: Check for corrupted mbuf.
+  *   size: Check min/max packet length according to hw spec.
+  *   segment: Check number of mbuf segments not exceed hw limitation.
+  *   offload: Check any unsupported offload flag.
+
 Driver compilation and testing
 --
 
diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 72e13f95f8..d28e205375 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -12,6 +12,7 @@
 #include 
 
 #include 
+#include 
 
 #include "eal_firmware.h"
 
@@ -34,6 +35,7 @@
 #define ICE_HW_DEBUG_MASK_ARG "hw_debug_mask"
 #define ICE_ONE_PPS_OUT_ARG   "pps_out"
 #define ICE_RX_LOW_LATENCY_ARG"rx_low_latency"
+#define ICE_MBUF_CHECK_ARG   "mbuf_check"
 
 #define ICE_CYCLECOUNTER_MASK  0xULL
 
@@ -49,6 +51,7 @@ static const char * const ice_valid_args[] = {
ICE_ONE_PPS_OUT_ARG,
ICE_RX_LOW_LATENCY_ARG,
ICE_DEFAULT_MAC_DISABLE,
+   ICE_MBUF_CHECK_ARG,
NULL
 };
 
@@ -319,6 +322,14 @@ static const struct ice_xstats_name_off 
ice_stats_strings[] = {
 #define ICE_NB_ETH_XSTATS (sizeof(ice_stats_strings) / \
sizeof(ice_stats_strings[0]))
 
+static const struct ice_xstats_name_off ice_mbuf_strings[] = {
+   {"tx_mbuf_error_packets", offsetof(struct ice_mbuf_stats,
+   tx_pkt_errors)},
+};
+
+#define ICE_NB_MBUF_XSTATS (sizeof(ice_mbuf_strings) / \
+   sizeof(ice_mbuf_strings[0]))
+
 static const struct ice_xstats_name_off ice_hw_port_strings[] = {
{"tx_link_down_dropped", offsetof(struct ice_hw_port_stats,
tx_dropped_link_down)},
@@ -2061,6 +2072,58 @@ handle_pps_out_arg(__rte_unused const char *key, const 
char *value,
return 0;
 }
 
+static int
+ice_parse_mbuf_check(__rte_unused const char *key, const char *value, void 
*args)
+{
+   char *cur;
+   char *tmp;
+   int str_len;
+   int valid_len;
+
+   int ret = 0;
+   uint64_t *mc_flags = args;
+   char *str2 = strdup(value);
+   if (str2 == NULL)
+   return -1;
+
+   str_len = strlen(str2);
+   if (str_len == 0) {
+   ret = -1;
+   goto err_end;
+   }
+
+   /* Try stripping the outer square brackets of the parameter string. */
+   str_len = strlen(str2);
+   if (str2[0] == '[' && str2[str_len - 1] == ']') {
+   if (str_len < 3) {
+   ret = -1;
+   goto err_end;
+   }
+   valid_len = str_len - 2;
+   memmove(str2, str2 + 1, valid_len);
+   memset(str2 + valid_len, '\0', 2);
+   }
+
+   cur = strtok_r(str2, ",", &tmp);
+   while (cur != NULL) {
+   if (!strcmp(cur, "mbuf"))
+   *mc_flags |= ICE_MBUF_CHECK_F_TX_MBUF;
+   else if (!strcmp(cur, "size"))
+   *mc_flags |= ICE_MBUF_C

[PATCH v2] net/iavf: fix no polling mode switch

2023-12-14 Thread Mingjin Ye
PMD does not switch to no polling mode when the PF triggers a reset event
or the watchdog detects a reset event. In this scenario, data path will
access the freed resources and cause a core dump.

This patch fixes this issue by automatically switching modes on VF reset.

Fixes: 5b3124a0a6ef ("net/iavf: support no polling when link down")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
v2: Increase reset completion wait count.
---
 drivers/net/iavf/iavf.h|  3 ++-
 drivers/net/iavf/iavf_ethdev.c | 27 +++
 drivers/net/iavf/iavf_vchnl.c  | 24 ++--
 3 files changed, 35 insertions(+), 19 deletions(-)

diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 10868f2c30..5bfe85dabd 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -18,7 +18,7 @@
 
 #define IAVF_AQ_LEN   32
 #define IAVF_AQ_BUF_SZ4096
-#define IAVF_RESET_WAIT_CNT   500
+#define IAVF_RESET_WAIT_CNT   2000
 #define IAVF_BUF_SIZE_MIN 1024
 #define IAVF_FRAME_SIZE_MAX   9728
 #define IAVF_QUEUE_BASE_ADDR_UNIT 128
@@ -512,4 +512,5 @@ int iavf_flow_sub_check(struct iavf_adapter *adapter,
 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);
+void iavf_set_no_poll(struct iavf_adapter *adapter, bool link_change);
 #endif /* _IAVF_ETHDEV_H_ */
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index d1edb0dd5c..0952998304 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -296,6 +296,7 @@ iavf_dev_watchdog(void *cb_arg)
PMD_DRV_LOG(INFO, "VF \"%s\" reset has completed",
adapter->vf.eth_dev->data->name);
adapter->vf.vf_reset = false;
+   iavf_set_no_poll(adapter, false);
}
/* If not in reset then poll vfr_inprogress register for VFLR event */
} else {
@@ -308,6 +309,7 @@ iavf_dev_watchdog(void *cb_arg)
 
/* enter reset state with VFLR event */
adapter->vf.vf_reset = true;
+   iavf_set_no_poll(adapter, false);
adapter->vf.link_up = false;
 
iavf_dev_event_post(adapter->vf.eth_dev, 
RTE_ETH_EVENT_INTR_RESET,
@@ -2916,8 +2918,10 @@ iavf_dev_close(struct rte_eth_dev *dev)
 * effect.
 */
 out:
-   if (vf->vf_reset && !rte_pci_set_bus_master(pci_dev, true))
+   if (vf->vf_reset && !rte_pci_set_bus_master(pci_dev, true)) {
vf->vf_reset = false;
+   iavf_set_no_poll(adapter, false);
+   }
 
/* disable watchdog */
iavf_dev_watchdog_disable(adapter);
@@ -2948,6 +2952,8 @@ static int
 iavf_dev_reset(struct rte_eth_dev *dev)
 {
int ret;
+   struct iavf_adapter *adapter =
+   IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
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);
 
@@ -2962,6 +2968,7 @@ iavf_dev_reset(struct rte_eth_dev *dev)
return ret;
}
vf->vf_reset = false;
+   iavf_set_no_poll(adapter, false);
 
PMD_DRV_LOG(DEBUG, "Start dev_reset ...\n");
ret = iavf_dev_uninit(dev);
@@ -2977,10 +2984,13 @@ iavf_dev_reset(struct rte_eth_dev *dev)
 int
 iavf_handle_hw_reset(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);
int ret;
 
vf->in_reset_recovery = true;
+   iavf_set_no_poll(adapter, false);
 
ret = iavf_dev_reset(dev);
if (ret)
@@ -2998,16 +3008,25 @@ iavf_handle_hw_reset(struct rte_eth_dev *dev)
if (ret)
goto error;
dev->data->dev_started = 1;
-
-   vf->in_reset_recovery = false;
-   return 0;
+   goto exit;
 
 error:
PMD_DRV_LOG(DEBUG, "RESET recover with error code=%d\n", ret);
+exit:
vf->in_reset_recovery = false;
+   iavf_set_no_poll(adapter, false);
return ret;
 }
 
+void
+iavf_set_no_poll(struct iavf_adapter *adapter, bool link_change)
+{
+   struct iavf_info *vf = &adapter->vf;
+
+   adapter->no_poll = (link_change & !vf->link_up) ||
+   vf->vf_reset || vf->in_reset_recovery;
+}
+
 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_vchnl.c b/drivers/net/iavf/iavf_vchnl.c
inde

[v20.11] net/iavf: support flow rule with raw pattern

2023-12-15 Thread Mingjin Ye
Add raw pattern support to VF, including FDIR/RSS flow rule.

This patch is based on DPDK v20.11.9
[ece54855816f1d03ef8ae08dedcb02318a97f3fb], for customer cherry-pick.

Signed-off-by: Mingjin Ye 
---
 drivers/common/iavf/virtchnl.h   |   38 +-
 drivers/net/iavf/iavf.h  |   13 +-
 drivers/net/iavf/iavf_ethdev.c   |  223 +-
 drivers/net/iavf/iavf_fdir.c |  213 +-
 drivers/net/iavf/iavf_generic_flow.c | 1021 +++---
 drivers/net/iavf/iavf_generic_flow.h |  137 
 drivers/net/iavf/iavf_hash.c |  498 ++---
 drivers/net/iavf/iavf_vchnl.c|   47 ++
 drivers/net/ice/ice_dcf_ethdev.c |   55 ++
 9 files changed, 2001 insertions(+), 244 deletions(-)

diff --git a/drivers/common/iavf/virtchnl.h b/drivers/common/iavf/virtchnl.h
index 4c34d35ba7..3880d4a67b 100644
--- a/drivers/common/iavf/virtchnl.h
+++ b/drivers/common/iavf/virtchnl.h
@@ -828,6 +828,7 @@ enum virtchnl_vfr_states {
 };
 
 #define VIRTCHNL_MAX_NUM_PROTO_HDRS32
+#define VIRTCHNL_MAX_SIZE_RAW_PACKET   1024
 #define PROTO_HDR_SHIFT5
 #define PROTO_HDR_FIELD_START(proto_hdr_type) \
(proto_hdr_type << PROTO_HDR_SHIFT)
@@ -890,6 +891,13 @@ enum virtchnl_proto_hdr_type {
VIRTCHNL_PROTO_HDR_AH,
VIRTCHNL_PROTO_HDR_PFCP,
VIRTCHNL_PROTO_HDR_GTPC,
+   /* IPv4 and IPv6 Fragment header types are only associated to
+* VIRTCHNL_PROTO_HDR_IPV4 and VIRTCHNL_PROTO_HDR_IPV6 respectively,
+* cannot be used independently.
+*/
+   VIRTCHNL_PROTO_HDR_IPV4_FRAG,
+   VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG,
+   VIRTCHNL_PROTO_HDR_GRE,
 };
 
 /* Protocol header field within a protocol header. */
@@ -970,6 +978,17 @@ enum virtchnl_proto_hdr_field {
/* GTPC */
VIRTCHNL_PROTO_HDR_GTPC_TEID =
PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPC),
+   /* GTPU_DWN/UP */
+   VIRTCHNL_PROTO_HDR_GTPU_DWN_QFI =
+   PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN),
+   VIRTCHNL_PROTO_HDR_GTPU_UP_QFI =
+   PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP),
+   /* IPv4 Dummy Fragment */
+   VIRTCHNL_PROTO_HDR_IPV4_FRAG_PKID =
+   PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV4_FRAG),
+   /* IPv6 Extension Fragment */
+   VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG_PKID =
+   PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG),
 };
 
 struct virtchnl_proto_hdr {
@@ -989,13 +1008,26 @@ struct virtchnl_proto_hdrs {
u8 tunnel_level;
/**
 * specify where protocol header start from.
+* must be 0 when sending a raw packet request.
 * 0 - from the outer layer
 * 1 - from the first inner layer
 * 2 - from the second inner layer
 * 
-**/
-   int count; /* the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS */
-   struct virtchnl_proto_hdr proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
+*/
+   int count;
+   /**
+* number of proto layers, must < VIRTCHNL_MAX_NUM_PROTO_HDRS
+* must be 0 for a raw packet request.
+*/
+   union {
+   struct virtchnl_proto_hdr
+   proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
+   struct {
+   u16 pkt_len;
+   u8 spec[VIRTCHNL_MAX_SIZE_RAW_PACKET];
+   u8 mask[VIRTCHNL_MAX_SIZE_RAW_PACKET];
+   } raw;
+   };
 };
 
 VIRTCHNL_CHECK_STRUCT_LEN(2312, virtchnl_proto_hdrs);
diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index f0408c2b40..06f80e7066 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -46,11 +46,18 @@
VIRTCHNL_VF_OFFLOAD_RX_POLLING)
 
 #define IAVF_RSS_OFFLOAD_ALL ( \
+   ETH_RSS_IPV4 | \
ETH_RSS_FRAG_IPV4 | \
ETH_RSS_NONFRAG_IPV4_TCP |  \
ETH_RSS_NONFRAG_IPV4_UDP |  \
ETH_RSS_NONFRAG_IPV4_SCTP | \
-   ETH_RSS_NONFRAG_IPV4_OTHER)
+   ETH_RSS_NONFRAG_IPV4_OTHER | \
+   ETH_RSS_IPV6 | \
+   ETH_RSS_FRAG_IPV6 | \
+   ETH_RSS_NONFRAG_IPV6_TCP | \
+   ETH_RSS_NONFRAG_IPV6_UDP | \
+   ETH_RSS_NONFRAG_IPV6_SCTP | \
+   ETH_RSS_NONFRAG_IPV6_OTHER)
 
 #define IAVF_MISC_VEC_IDRTE_INTR_VEC_ZERO_OFFSET
 #define IAVF_RX_VEC_START   RTE_INTR_VEC_RXTX_OFFSET
@@ -154,6 +161,7 @@ struct iavf_info {
 
uint8_t *rss_lut;
uint8_t *rss_key;
+   uint64_t rss_hf;
uint16_t nb_msix;   /* number of MSI-X interrupts on Rx */
uint16_t msix_base; /* msix vector base from */
uint16_t max_rss_qregion; /* max RSS queue region supported by PF */
@@ -325,6 +333,9 @@ int iavf_fdir_check(struct iavf_adapter *adapter,
struct iavf_fdir_conf *filter);
 int iavf_add_del_rss_cfg(struct iavf_adapter *adapter,
 struct virt

[PATCH] net/iavf: add diagnostic support in TX path

2023-12-21 Thread Mingjin Ye
The only way to enable diagnostics for TX paths is to modify the
application source code. Making it difficult to diagnose faults.

In this patch, the devarg option "mbuf_check" is introduced and the
parameters are configured to enable the corresponding diagnostics.

supported cases: mbuf, size, segment, offload, strict.
 1. mbuf: check for corrupted mbuf.
 2. size: check min/max packet length according to hw spec.
 3. segment: check number of mbuf segments not exceed hw limitation.
 4. offload: check any unsupported offload flag.
 5. strict: check protocol headers.

parameter format: mbuf_check=[mbuf,,]
eg: dpdk-testpmd -a :81:01.0,mbuf_check=[mbuf,size] -- -i

Signed-off-by: Mingjin Ye 
---
 drivers/net/iavf/iavf.h|  26 ++-
 drivers/net/iavf/iavf_ethdev.c |  74 
 drivers/net/iavf/iavf_rxtx.c   | 337 +
 drivers/net/iavf/iavf_rxtx.h   |   8 +
 4 files changed, 402 insertions(+), 43 deletions(-)

diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 10868f2c30..428b20b8e4 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -113,9 +113,15 @@ struct iavf_ipsec_crypto_stats {
} ierrors;
 };
 
+struct iavf_mdd_stats {
+   uint64_t mdd_mbuf_err_count;
+   uint64_t mdd_pkt_err_count;
+};
+
 struct iavf_eth_xstats {
struct virtchnl_eth_stats eth_stats;
struct iavf_ipsec_crypto_stats ips_stats;
+   struct iavf_mdd_stats mdd_stats;
 };
 
 /* Structure that defines a VSI, associated with a adapter. */
@@ -299,6 +305,7 @@ enum iavf_proto_xtr_type {
IAVF_PROTO_XTR_MAX,
 };
 
+
 /**
  * Cache devargs parse result.
  */
@@ -309,10 +316,27 @@ struct iavf_devargs {
uint32_t watchdog_period;
int auto_reset;
int no_poll_on_link_down;
+   int mbuf_check;
 };
 
 struct iavf_security_ctx;
 
+struct iavf_rx_burst_elem {
+   TAILQ_ENTRY(iavf_rx_burst_elem) next;
+   eth_rx_burst_t rx_pkt_burst;
+};
+
+struct iavf_tx_burst_elem {
+   TAILQ_ENTRY(iavf_tx_burst_elem) next;
+   eth_tx_burst_t tx_pkt_burst;
+};
+
+#define IAVF_MDD_CHECK_F_TX_MBUF(1ULL << 0)
+#define IAVF_MDD_CHECK_F_TX_SIZE(1ULL << 1)
+#define IAVF_MDD_CHECK_F_TX_SEGMENT (1ULL << 2)
+#define IAVF_MDD_CHECK_F_TX_OFFLOAD (1ULL << 3)
+#define IAVF_MDD_CHECK_F_TX_STRICT  (1ULL << 4)
+
 /* Structure to store private data for each VF instance. */
 struct iavf_adapter {
struct iavf_hw hw;
@@ -329,7 +353,7 @@ struct iavf_adapter {
bool closed;
bool no_poll;
eth_rx_burst_t rx_pkt_burst;
-   eth_tx_burst_t tx_pkt_burst;
+   uint64_t mc_flags; /* mdd check flags. */
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index d1edb0dd5c..f2af228042 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -39,6 +39,8 @@
 #define IAVF_RESET_WATCHDOG_ARG"watchdog_period"
 #define IAVF_ENABLE_AUTO_RESET_ARG "auto_reset"
 #define IAVF_NO_POLL_ON_LINK_DOWN_ARG "no-poll-on-link-down"
+#define IAVF_MDD_CHECK_ARG   "mbuf_check"
+
 uint64_t iavf_timestamp_dynflag;
 int iavf_timestamp_dynfield_offset = -1;
 
@@ -48,6 +50,7 @@ static const char * const iavf_valid_args[] = {
IAVF_RESET_WATCHDOG_ARG,
IAVF_ENABLE_AUTO_RESET_ARG,
IAVF_NO_POLL_ON_LINK_DOWN_ARG,
+   IAVF_MDD_CHECK_ARG,
NULL
 };
 
@@ -188,6 +191,8 @@ static const struct rte_iavf_xstats_name_off 
rte_iavf_stats_strings[] = {
_OFF_OF(ips_stats.ierrors.ipsec_length)},
{"inline_ipsec_crypto_ierrors_misc",
_OFF_OF(ips_stats.ierrors.misc)},
+   {"mdd_mbuf_error_packets", _OFF_OF(mdd_stats.mdd_mbuf_err_count)},
+   {"mdd_pkt_error_packets", _OFF_OF(mdd_stats.mdd_pkt_err_count)},
 };
 #undef _OFF_OF
 
@@ -1881,6 +1886,9 @@ static int iavf_dev_xstats_get(struct rte_eth_dev *dev,
 {
int ret;
unsigned int i;
+   struct iavf_tx_queue *txq;
+   uint64_t mdd_mbuf_err_count = 0;
+   uint64_t mdd_pkt_err_count = 0;
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);
@@ -1904,6 +1912,16 @@ static int iavf_dev_xstats_get(struct rte_eth_dev *dev,
if (iavf_ipsec_crypto_supported(adapter))
iavf_dev_update_ipsec_xstats(dev, &iavf_xtats.ips_stats);
 
+   if (adapter->devargs.mbuf_check) {
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
+   txq = dev->data->tx_queues[i];
+   mdd_mbuf_err_count += txq->mdd_mbuf_err_count;
+   mdd_pkt_err_count += txq->mdd_pkt_err_count;

[PATCH] net/i40e: add diagnostic support in TX path

2023-12-21 Thread Mingjin Ye
The only way to enable diagnostics for TX paths is to modify the
application source code. Making it difficult to diagnose faults.

In this patch, the devarg option "mbuf_check" is introduced and the
parameters are configured to enable the corresponding diagnostics.

supported cases: mbuf, size, segment, offload, strict.
 1. mbuf: check for corrupted mbuf.
 2. size: check min/max packet length according to hw spec.
 3. segment: check number of mbuf segments not exceed hw limitation.
 4. offload: check any unsupported offload flag.
 5. strict: check protocol headers.

parameter format: mbuf_check=[mbuf,,]
eg: dpdk-testpmd -a :81:01.0,mbuf_check=[mbuf,size] -- -i

Signed-off-by: Mingjin Ye 
---
 drivers/net/i40e/i40e_ethdev.c | 108 +++-
 drivers/net/i40e/i40e_ethdev.h |  32 ++
 drivers/net/i40e/i40e_rxtx.c   | 916 +
 drivers/net/i40e/i40e_rxtx.h   |  10 +
 4 files changed, 1064 insertions(+), 2 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 3ca226156b..d4a2b4b277 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -48,6 +48,7 @@
 #define ETH_I40E_SUPPORT_MULTI_DRIVER  "support-multi-driver"
 #define ETH_I40E_QUEUE_NUM_PER_VF_ARG  "queue-num-per-vf"
 #define ETH_I40E_VF_MSG_CFG"vf_msg_cfg"
+#define ETH_I40E_MDD_CHECK_ARG   "mbuf_check"
 
 #define I40E_CLEAR_PXE_WAIT_MS 200
 #define I40E_VSI_TSR_QINQ_STRIP0x4010
@@ -412,6 +413,7 @@ static const char *const valid_keys[] = {
ETH_I40E_SUPPORT_MULTI_DRIVER,
ETH_I40E_QUEUE_NUM_PER_VF_ARG,
ETH_I40E_VF_MSG_CFG,
+   ETH_I40E_MDD_CHECK_ARG,
NULL};
 
 static const struct rte_pci_id pci_id_i40e_map[] = {
@@ -545,6 +547,16 @@ static const struct rte_i40e_xstats_name_off 
rte_i40e_stats_strings[] = {
 #define I40E_NB_ETH_XSTATS (sizeof(rte_i40e_stats_strings) / \
sizeof(rte_i40e_stats_strings[0]))
 
+static const struct rte_i40e_xstats_name_off i40e_mdd_strings[] = {
+   {"mdd_mbuf_error_packets", offsetof(struct i40e_mdd_stats,
+   mdd_mbuf_err_count)},
+   {"mdd_pkt_error_packets", offsetof(struct i40e_mdd_stats,
+   mdd_pkt_err_count)},
+};
+
+#define I40E_NB_MDD_XSTATS (sizeof(i40e_mdd_strings) / \
+   sizeof(i40e_mdd_strings[0]))
+
 static const struct rte_i40e_xstats_name_off rte_i40e_hw_port_strings[] = {
{"tx_link_down_dropped", offsetof(struct i40e_hw_port_stats,
tx_dropped_link_down)},
@@ -1373,10 +1385,58 @@ read_vf_msg_config(__rte_unused const char *key,
return 0;
 }
 
+static int
+i40e_parse_mdd_checker(__rte_unused const char *key, const char *value, void 
*args)
+{
+   char *cur;
+   char *tmp;
+   int str_len;
+   int valid_len;
+
+   int ret = 0;
+   uint64_t *mc_flags = args;
+   char *str2 = strdup(value);
+   if (str2 == NULL)
+   return -1;
+
+   str_len = strlen(str2);
+   if (str2[0] == '[' && str2[str_len - 1] == ']') {
+   if (str_len < 3) {
+   ret = -1;
+   goto mdd_end;
+   }
+   valid_len = str_len - 2;
+   memmove(str2, str2 + 1, valid_len);
+   memset(str2 + valid_len, '\0', 2);
+   }
+   cur = strtok_r(str2, ",", &tmp);
+   while (cur != NULL) {
+   if (!strcmp(cur, "mbuf"))
+   *mc_flags |= I40E_MDD_CHECK_F_TX_MBUF;
+   else if (!strcmp(cur, "size"))
+   *mc_flags |= I40E_MDD_CHECK_F_TX_SIZE;
+   else if (!strcmp(cur, "segment"))
+   *mc_flags |= I40E_MDD_CHECK_F_TX_SEGMENT;
+   else if (!strcmp(cur, "offload"))
+   *mc_flags |= I40E_MDD_CHECK_F_TX_OFFLOAD;
+   else if (!strcmp(cur, "strict"))
+   *mc_flags |= I40E_MDD_CHECK_F_TX_STRICT;
+   else
+   PMD_DRV_LOG(ERR, "Unsupported mdd check type: %s", cur);
+   cur = strtok_r(NULL, ",", &tmp);
+   }
+
+mdd_end:
+   free(str2);
+   return ret;
+}
+
 static int
 i40e_parse_vf_msg_config(struct rte_eth_dev *dev,
struct i40e_vf_msg_cfg *msg_cfg)
 {
+   struct i40e_adapter *ad =
+   I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
struct rte_kvargs *kvlist;
int kvargs_count;
int ret = 0;
@@ -1401,6 +1461,14 @@ i40e_parse_vf_msg_config(struct rte_eth_dev *dev,
goto free_end;
}
 
+   ret = rte_kvargs_process(kvlist, ETH_I40E_MDD_CHECK_ARG,
+&i40e_parse_mdd_checker, &ad->mc_flags);
+   if (

[PATCH] net/ice: add diagnostic support in TX path

2023-12-21 Thread Mingjin Ye
The only way to enable diagnostics for TX paths is to modify the
application source code. Making it difficult to diagnose faults.

In this patch, the devarg option "mbuf_check" is introduced and the
parameters are configured to enable the corresponding diagnostics.

supported cases: mbuf, size, segment, offload, strict.
 1. mbuf: check for corrupted mbuf.
 2. size: check min/max packet length according to hw spec.
 3. segment: check number of mbuf segments not exceed hw limitation.
 4. offload: check any unsupported offload flag.
 5. strict: check protocol headers.

parameter format: mbuf_check=[mbuf,,]
eg: dpdk-testpmd -a :81:01.0,mbuf_check=[mbuf,size] -- -i

Signed-off-by: Mingjin Ye 
---
 drivers/net/ice/ice_ethdev.c | 102 +++-
 drivers/net/ice/ice_ethdev.h |  26 +
 drivers/net/ice/ice_rxtx.c   | 944 ++-
 drivers/net/ice/ice_rxtx.h   |  29 ++
 4 files changed, 1099 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 3ccba4db80..6f9e0d9181 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -34,6 +34,7 @@
 #define ICE_HW_DEBUG_MASK_ARG "hw_debug_mask"
 #define ICE_ONE_PPS_OUT_ARG   "pps_out"
 #define ICE_RX_LOW_LATENCY_ARG"rx_low_latency"
+#define ICE_MDD_CHECK_ARG   "mbuf_check"
 
 #define ICE_CYCLECOUNTER_MASK  0xULL
 
@@ -49,6 +50,7 @@ static const char * const ice_valid_args[] = {
ICE_ONE_PPS_OUT_ARG,
ICE_RX_LOW_LATENCY_ARG,
ICE_DEFAULT_MAC_DISABLE,
+   ICE_MDD_CHECK_ARG,
NULL
 };
 
@@ -319,6 +321,16 @@ static const struct ice_xstats_name_off 
ice_stats_strings[] = {
 #define ICE_NB_ETH_XSTATS (sizeof(ice_stats_strings) / \
sizeof(ice_stats_strings[0]))
 
+static const struct ice_xstats_name_off ice_mdd_strings[] = {
+   {"mdd_mbuf_error_packets", offsetof(struct ice_mdd_stats,
+   mdd_mbuf_err_count)},
+   {"mdd_pkt_error_packets", offsetof(struct ice_mdd_stats,
+   mdd_pkt_err_count)},
+};
+
+#define ICE_NB_MDD_XSTATS (sizeof(ice_mdd_strings) / \
+   sizeof(ice_mdd_strings[0]))
+
 static const struct ice_xstats_name_off ice_hw_port_strings[] = {
{"tx_link_down_dropped", offsetof(struct ice_hw_port_stats,
tx_dropped_link_down)},
@@ -2060,6 +2072,52 @@ handle_pps_out_arg(__rte_unused const char *key, const 
char *value,
return 0;
 }
 
+static int
+ice_parse_mdd_checker(__rte_unused const char *key, const char *value, void 
*args)
+{
+   char *cur;
+   char *tmp;
+   int str_len;
+   int valid_len;
+
+   int ret = 0;
+   uint64_t *mc_flags = args;
+   char *str2 = strdup(value);
+   if (str2 == NULL)
+   return -1;
+
+   str_len = strlen(str2);
+   if (str2[0] == '[' && str2[str_len - 1] == ']') {
+   if (str_len < 3) {
+   ret = -1;
+   goto mdd_end;
+   }
+   valid_len = str_len - 2;
+   memmove(str2, str2 + 1, valid_len);
+   memset(str2 + valid_len, '\0', 2);
+   }
+   cur = strtok_r(str2, ",", &tmp);
+   while (cur != NULL) {
+   if (!strcmp(cur, "mbuf"))
+   *mc_flags |= ICE_MDD_CHECK_F_TX_MBUF;
+   else if (!strcmp(cur, "size"))
+   *mc_flags |= ICE_MDD_CHECK_F_TX_SIZE;
+   else if (!strcmp(cur, "segment"))
+   *mc_flags |= ICE_MDD_CHECK_F_TX_SEGMENT;
+   else if (!strcmp(cur, "offload"))
+   *mc_flags |= ICE_MDD_CHECK_F_TX_OFFLOAD;
+   else if (!strcmp(cur, "strict"))
+   *mc_flags |= ICE_MDD_CHECK_F_TX_STRICT;
+   else
+   PMD_DRV_LOG(ERR, "Unsupported mdd check type: %s", cur);
+   cur = strtok_r(NULL, ",", &tmp);
+   }
+
+mdd_end:
+   free(str2);
+   return ret;
+}
+
 static int ice_parse_devargs(struct rte_eth_dev *dev)
 {
struct ice_adapter *ad =
@@ -2116,6 +2174,14 @@ static int ice_parse_devargs(struct rte_eth_dev *dev)
if (ret)
goto bail;
 
+   ret = rte_kvargs_process(kvlist, ICE_MDD_CHECK_ARG,
+&ice_parse_mdd_checker, &ad->mc_flags);
+   if (ret)
+   goto bail;
+
+   if (ad->mc_flags)
+   ad->devargs.mbuf_check = 1;
+
ret = rte_kvargs_process(kvlist, ICE_RX_LOW_LATENCY_ARG,
 &parse_bool, &ad->devargs.rx_low_latency);
 
@@ -2291,6 +2357,7 @@ ice_dev_init(struct rte_eth_dev *dev)
dev->rx_pkt_burst = ice_recv_pkts;
dev->tx_pkt_burst = ice_x

[PATCH v2] net/iavf: add diagnostic support in TX path

2023-12-22 Thread Mingjin Ye
The only way to enable diagnostics for TX paths is to modify the
application source code. Making it difficult to diagnose faults.

In this patch, the devarg option "mbuf_check" is introduced and the
parameters are configured to enable the corresponding diagnostics.

supported cases: mbuf, size, segment, offload, strict.
 1. mbuf: check for corrupted mbuf.
 2. size: check min/max packet length according to hw spec.
 3. segment: check number of mbuf segments not exceed hw limitation.
 4. offload: check any unsupported offload flag.
 5. strict: check protocol headers.

parameter format: mbuf_check=[mbuf,,]
eg: dpdk-testpmd -a :81:01.0,mbuf_check=[mbuf,size] -- -i

Signed-off-by: Mingjin Ye 
---
v2: Remove call chain.
---
 drivers/net/iavf/iavf.h|  25 -
 drivers/net/iavf/iavf_ethdev.c |  69 
 drivers/net/iavf/iavf_rxtx.c   | 186 ++---
 drivers/net/iavf/iavf_rxtx.h   |   6 ++
 4 files changed, 246 insertions(+), 40 deletions(-)

diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 10868f2c30..ab80388422 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -113,9 +113,14 @@ struct iavf_ipsec_crypto_stats {
} ierrors;
 };
 
+struct iavf_mdd_stats {
+   uint64_t tx_pkt_errors;
+};
+
 struct iavf_eth_xstats {
struct virtchnl_eth_stats eth_stats;
struct iavf_ipsec_crypto_stats ips_stats;
+   struct iavf_mdd_stats mdd_stats;
 };
 
 /* Structure that defines a VSI, associated with a adapter. */
@@ -309,10 +314,27 @@ struct iavf_devargs {
uint32_t watchdog_period;
int auto_reset;
int no_poll_on_link_down;
+   int mbuf_check;
 };
 
 struct iavf_security_ctx;
 
+struct iavf_rx_burst_elem {
+   TAILQ_ENTRY(iavf_rx_burst_elem) next;
+   eth_rx_burst_t rx_pkt_burst;
+};
+
+struct iavf_tx_burst_elem {
+   TAILQ_ENTRY(iavf_tx_burst_elem) next;
+   eth_tx_burst_t tx_pkt_burst;
+};
+
+#define IAVF_MDD_CHECK_F_TX_MBUF(1ULL << 0)
+#define IAVF_MDD_CHECK_F_TX_SIZE(1ULL << 1)
+#define IAVF_MDD_CHECK_F_TX_SEGMENT (1ULL << 2)
+#define IAVF_MDD_CHECK_F_TX_OFFLOAD (1ULL << 3)
+#define IAVF_MDD_CHECK_F_TX_STRICT  (1ULL << 4)
+
 /* Structure to store private data for each VF instance. */
 struct iavf_adapter {
struct iavf_hw hw;
@@ -328,8 +350,7 @@ struct iavf_adapter {
bool stopped;
bool closed;
bool no_poll;
-   eth_rx_burst_t rx_pkt_burst;
-   eth_tx_burst_t tx_pkt_burst;
+   uint64_t mc_flags; /* mdd check flags. */
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index d1edb0dd5c..6f4dd54602 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -39,6 +39,8 @@
 #define IAVF_RESET_WATCHDOG_ARG"watchdog_period"
 #define IAVF_ENABLE_AUTO_RESET_ARG "auto_reset"
 #define IAVF_NO_POLL_ON_LINK_DOWN_ARG "no-poll-on-link-down"
+#define IAVF_MDD_CHECK_ARG   "mbuf_check"
+
 uint64_t iavf_timestamp_dynflag;
 int iavf_timestamp_dynfield_offset = -1;
 
@@ -48,6 +50,7 @@ static const char * const iavf_valid_args[] = {
IAVF_RESET_WATCHDOG_ARG,
IAVF_ENABLE_AUTO_RESET_ARG,
IAVF_NO_POLL_ON_LINK_DOWN_ARG,
+   IAVF_MDD_CHECK_ARG,
NULL
 };
 
@@ -174,6 +177,7 @@ static const struct rte_iavf_xstats_name_off 
rte_iavf_stats_strings[] = {
{"tx_broadcast_packets", _OFF_OF(eth_stats.tx_broadcast)},
{"tx_dropped_packets", _OFF_OF(eth_stats.tx_discards)},
{"tx_error_packets", _OFF_OF(eth_stats.tx_errors)},
+   {"tx_mdd_error_packets", _OFF_OF(mdd_stats.tx_pkt_errors)},
 
{"inline_ipsec_crypto_ipackets", _OFF_OF(ips_stats.icount)},
{"inline_ipsec_crypto_ibytes", _OFF_OF(ips_stats.ibytes)},
@@ -1881,6 +1885,8 @@ static int iavf_dev_xstats_get(struct rte_eth_dev *dev,
 {
int ret;
unsigned int i;
+   struct iavf_tx_queue *txq;
+   uint64_t mdd_pkt_errors = 0;
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);
@@ -1904,6 +1910,15 @@ static int iavf_dev_xstats_get(struct rte_eth_dev *dev,
if (iavf_ipsec_crypto_supported(adapter))
iavf_dev_update_ipsec_xstats(dev, &iavf_xtats.ips_stats);
 
+   if (adapter->devargs.mbuf_check) {
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
+   txq = dev->data->tx_queues[i];
+   mdd_pkt_errors += __atomic_load_n(&txq->mdd_pkt_errors,
+   __ATOMIC_RELAXED);
+   }
+   iavf_xtats.mdd_stats.tx_pkt_errors = mdd_pkt

[PATCH v3] net/iavf: add diagnostic support in TX path

2023-12-26 Thread Mingjin Ye
The only way to enable diagnostics for TX paths is to modify the
application source code. Making it difficult to diagnose faults.

In this patch, the devarg option "mbuf_check" is introduced and the
parameters are configured to enable the corresponding diagnostics.

supported cases: mbuf, size, segment, offload, strict.
 1. mbuf: check for corrupted mbuf.
 2. size: check min/max packet length according to hw spec.
 3. segment: check number of mbuf segments not exceed hw limitation.
 4. offload: check any unsupported offload flag.
 5. strict: check protocol headers.

parameter format: mbuf_check=[mbuf,,]
eg: dpdk-testpmd -a :81:01.0,mbuf_check=[mbuf,size] -- -i

Signed-off-by: Mingjin Ye 
---
v2: Remove call chain.
---
v3: Optimisation implementation.
---
 drivers/net/iavf/iavf.h|  25 +-
 drivers/net/iavf/iavf_ethdev.c |  69 +
 drivers/net/iavf/iavf_rxtx.c   | 138 -
 drivers/net/iavf/iavf_rxtx.h   |   5 ++
 4 files changed, 233 insertions(+), 4 deletions(-)

diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 10868f2c30..b81329bb56 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -113,9 +113,14 @@ struct iavf_ipsec_crypto_stats {
} ierrors;
 };
 
+struct iavf_mbuf_stats {
+   uint64_t tx_pkt_errors;
+};
+
 struct iavf_eth_xstats {
struct virtchnl_eth_stats eth_stats;
struct iavf_ipsec_crypto_stats ips_stats;
+   struct iavf_mbuf_stats mbuf_stats;
 };
 
 /* Structure that defines a VSI, associated with a adapter. */
@@ -309,10 +314,27 @@ struct iavf_devargs {
uint32_t watchdog_period;
int auto_reset;
int no_poll_on_link_down;
+   int mbuf_check;
 };
 
 struct iavf_security_ctx;
 
+#define IAVF_MBUF_CHECK_F_TX_MBUF(1ULL << 0)
+#define IAVF_MBUF_CHECK_F_TX_SIZE(1ULL << 1)
+#define IAVF_MBUF_CHECK_F_TX_SEGMENT (1ULL << 2)
+#define IAVF_MBUF_CHECK_F_TX_OFFLOAD (1ULL << 3)
+#define IAVF_MBUF_CHECK_F_TX_STRICT  (1ULL << 4)
+
+enum iavf_tx_pkt_burst_type {
+   IAVF_PKT_BURST_DEFAULT  = 0,
+   IAVF_PKT_BURST_VEC  = 1,
+   IAVF_PKT_BURST_VEC_AVX2 = 2,
+   IAVF_PKT_BURST_VEC_AVX2_OFFLOAD = 3,
+   IAVF_PKT_BURST_VEC_AVX512   = 4,
+   IAVF_PKT_BURST_VEC_AVX512_OFFLOAD   = 5,
+   IAVF_PKT_BURST_VEC_AVX512_CTX_OFFLOAD   = 6,
+};
+
 /* Structure to store private data for each VF instance. */
 struct iavf_adapter {
struct iavf_hw hw;
@@ -329,7 +351,8 @@ struct iavf_adapter {
bool closed;
bool no_poll;
eth_rx_burst_t rx_pkt_burst;
-   eth_tx_burst_t tx_pkt_burst;
+   enum iavf_tx_pkt_burst_type tx_burst_type;
+   uint64_t mc_flags; /* mbuf check flags. */
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index d1edb0dd5c..8d1aadfae8 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -39,6 +39,8 @@
 #define IAVF_RESET_WATCHDOG_ARG"watchdog_period"
 #define IAVF_ENABLE_AUTO_RESET_ARG "auto_reset"
 #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;
 int iavf_timestamp_dynfield_offset = -1;
 
@@ -48,6 +50,7 @@ static const char * const iavf_valid_args[] = {
IAVF_RESET_WATCHDOG_ARG,
IAVF_ENABLE_AUTO_RESET_ARG,
IAVF_NO_POLL_ON_LINK_DOWN_ARG,
+   IAVF_MBUF_CHECK_ARG,
NULL
 };
 
@@ -174,6 +177,7 @@ static const struct rte_iavf_xstats_name_off 
rte_iavf_stats_strings[] = {
{"tx_broadcast_packets", _OFF_OF(eth_stats.tx_broadcast)},
{"tx_dropped_packets", _OFF_OF(eth_stats.tx_discards)},
{"tx_error_packets", _OFF_OF(eth_stats.tx_errors)},
+   {"tx_mbuf_error_packets", _OFF_OF(mbuf_stats.tx_pkt_errors)},
 
{"inline_ipsec_crypto_ipackets", _OFF_OF(ips_stats.icount)},
{"inline_ipsec_crypto_ibytes", _OFF_OF(ips_stats.ibytes)},
@@ -1881,6 +1885,8 @@ static int iavf_dev_xstats_get(struct rte_eth_dev *dev,
 {
int ret;
unsigned int i;
+   struct iavf_tx_queue *txq;
+   uint64_t mbuf_errors = 0;
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);
@@ -1904,6 +1910,15 @@ static int iavf_dev_xstats_get(struct rte_eth_dev *dev,
if (iavf_ipsec_crypto_supported(adapter))
iavf_dev_update_ipsec_xstats(dev, &iavf_xtats.ips_stats);
 
+   if (adapter->devargs.mbuf_check) {
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
+

[PATCH v4 1/2] net/iavf: add diagnostic support in TX path

2023-12-27 Thread Mingjin Ye
The only way to enable diagnostics for TX paths is to modify the
application source code. Making it difficult to diagnose faults.

In this patch, the devarg option "mbuf_check" is introduced and the
parameters are configured to enable the corresponding diagnostics.

supported cases: mbuf, size, segment, offload, strict.
 1. mbuf: check for corrupted mbuf.
 2. size: check min/max packet length according to hw spec.
 3. segment: check number of mbuf segments not exceed hw limitation.
 4. offload: check any unsupported offload flag.
 5. strict: check protocol headers.

parameter format: mbuf_check=[mbuf,,]
eg: dpdk-testpmd -a :81:01.0,mbuf_check=[mbuf,size] -- -i

Signed-off-by: Mingjin Ye 
---
v2: Remove call chain.
---
v3: Optimisation implementation.
---
v4: Fix Windows os compilation error.
---
 drivers/net/iavf/iavf.h|  25 +-
 drivers/net/iavf/iavf_ethdev.c |  70 +
 drivers/net/iavf/iavf_rxtx.c   | 138 -
 drivers/net/iavf/iavf_rxtx.h   |   5 ++
 4 files changed, 234 insertions(+), 4 deletions(-)

diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 10868f2c30..b81329bb56 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -113,9 +113,14 @@ struct iavf_ipsec_crypto_stats {
} ierrors;
 };
 
+struct iavf_mbuf_stats {
+   uint64_t tx_pkt_errors;
+};
+
 struct iavf_eth_xstats {
struct virtchnl_eth_stats eth_stats;
struct iavf_ipsec_crypto_stats ips_stats;
+   struct iavf_mbuf_stats mbuf_stats;
 };
 
 /* Structure that defines a VSI, associated with a adapter. */
@@ -309,10 +314,27 @@ struct iavf_devargs {
uint32_t watchdog_period;
int auto_reset;
int no_poll_on_link_down;
+   int mbuf_check;
 };
 
 struct iavf_security_ctx;
 
+#define IAVF_MBUF_CHECK_F_TX_MBUF(1ULL << 0)
+#define IAVF_MBUF_CHECK_F_TX_SIZE(1ULL << 1)
+#define IAVF_MBUF_CHECK_F_TX_SEGMENT (1ULL << 2)
+#define IAVF_MBUF_CHECK_F_TX_OFFLOAD (1ULL << 3)
+#define IAVF_MBUF_CHECK_F_TX_STRICT  (1ULL << 4)
+
+enum iavf_tx_pkt_burst_type {
+   IAVF_PKT_BURST_DEFAULT  = 0,
+   IAVF_PKT_BURST_VEC  = 1,
+   IAVF_PKT_BURST_VEC_AVX2 = 2,
+   IAVF_PKT_BURST_VEC_AVX2_OFFLOAD = 3,
+   IAVF_PKT_BURST_VEC_AVX512   = 4,
+   IAVF_PKT_BURST_VEC_AVX512_OFFLOAD   = 5,
+   IAVF_PKT_BURST_VEC_AVX512_CTX_OFFLOAD   = 6,
+};
+
 /* Structure to store private data for each VF instance. */
 struct iavf_adapter {
struct iavf_hw hw;
@@ -329,7 +351,8 @@ struct iavf_adapter {
bool closed;
bool no_poll;
eth_rx_burst_t rx_pkt_burst;
-   eth_tx_burst_t tx_pkt_burst;
+   enum iavf_tx_pkt_burst_type tx_burst_type;
+   uint64_t mc_flags; /* mbuf check flags. */
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index d1edb0dd5c..5398d2783f 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -39,6 +40,8 @@
 #define IAVF_RESET_WATCHDOG_ARG"watchdog_period"
 #define IAVF_ENABLE_AUTO_RESET_ARG "auto_reset"
 #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;
 int iavf_timestamp_dynfield_offset = -1;
 
@@ -48,6 +51,7 @@ static const char * const iavf_valid_args[] = {
IAVF_RESET_WATCHDOG_ARG,
IAVF_ENABLE_AUTO_RESET_ARG,
IAVF_NO_POLL_ON_LINK_DOWN_ARG,
+   IAVF_MBUF_CHECK_ARG,
NULL
 };
 
@@ -174,6 +178,7 @@ static const struct rte_iavf_xstats_name_off 
rte_iavf_stats_strings[] = {
{"tx_broadcast_packets", _OFF_OF(eth_stats.tx_broadcast)},
{"tx_dropped_packets", _OFF_OF(eth_stats.tx_discards)},
{"tx_error_packets", _OFF_OF(eth_stats.tx_errors)},
+   {"tx_mbuf_error_packets", _OFF_OF(mbuf_stats.tx_pkt_errors)},
 
{"inline_ipsec_crypto_ipackets", _OFF_OF(ips_stats.icount)},
{"inline_ipsec_crypto_ibytes", _OFF_OF(ips_stats.ibytes)},
@@ -1881,6 +1886,8 @@ static int iavf_dev_xstats_get(struct rte_eth_dev *dev,
 {
int ret;
unsigned int i;
+   struct iavf_tx_queue *txq;
+   uint64_t mbuf_errors = 0;
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);
@@ -1904,6 +1911,15 @@ static int iavf_dev_xstats_get(struct rte_eth_dev *dev,
if (iavf_ipsec_crypto_supported(adapter))
iavf_dev_update_ipsec_xstats(dev, &iavf_xtats.ips_stats);
 
+   if (adapter->devargs.mbuf_check) {
+   for

[PATCH v5 0/2] net/iavf: add diagnostics and fix error

2023-12-28 Thread Mingjin Ye
1. Fix multi-process error in Tx path.
2. Add diagnostics to Tx path.

Mingjin Ye (2):
  net/iavf: fix Tx path error in multi-process
  net/iavf: add diagnostic support in TX path

 doc/guides/nics/intel_vf.rst   |   4 +
 drivers/net/iavf/iavf.h|  25 +-
 drivers/net/iavf/iavf_ethdev.c |  70 +
 drivers/net/iavf/iavf_rxtx.c   | 138 -
 drivers/net/iavf/iavf_rxtx.h   |   5 ++
 5 files changed, 238 insertions(+), 4 deletions(-)

-- 
2.25.1



[PATCH v5 1/2] net/iavf: fix Tx path error in multi-process

2023-12-28 Thread Mingjin Ye
In a multi-process environment, a secondary process operates on shared
memory and changes the PMD transmit function pointer of the primary
process, causing the primary process to send pkts without being able
to find the function address, resulting in a crash.

Fixes: 5b3124a0a6ef ("net/iavf: support no polling when link down")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 drivers/net/iavf/iavf.h  | 12 +++-
 drivers/net/iavf/iavf_rxtx.c | 34 +++---
 drivers/net/iavf/iavf_rxtx.h |  3 +++
 3 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 10868f2c30..4cd5bea167 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -313,6 +313,16 @@ struct iavf_devargs {
 
 struct iavf_security_ctx;
 
+enum iavf_tx_pkt_burst_type {
+   IAVF_PKT_BURST_DEFAULT  = 0,
+   IAVF_PKT_BURST_VEC  = 1,
+   IAVF_PKT_BURST_VEC_AVX2 = 2,
+   IAVF_PKT_BURST_VEC_AVX2_OFFLOAD = 3,
+   IAVF_PKT_BURST_VEC_AVX512   = 4,
+   IAVF_PKT_BURST_VEC_AVX512_OFFLOAD   = 5,
+   IAVF_PKT_BURST_VEC_AVX512_CTX_OFFLOAD   = 6,
+};
+
 /* Structure to store private data for each VF instance. */
 struct iavf_adapter {
struct iavf_hw hw;
@@ -329,7 +339,7 @@ struct iavf_adapter {
bool closed;
bool no_poll;
eth_rx_burst_t rx_pkt_burst;
-   eth_tx_burst_t tx_pkt_burst;
+   enum iavf_tx_pkt_burst_type tx_burst_type;
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index f19aa14646..0d95447054 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -425,6 +425,23 @@ struct iavf_txq_ops iavf_txq_release_mbufs_ops[] = {
 
 };
 
+static const
+struct iavf_tx_burst_ops iavf_tx_pkt_burst_ops[] = {
+   [IAVF_PKT_BURST_DEFAULT].tx_pkt_burst = iavf_xmit_pkts,
+#ifdef RTE_ARCH_X86
+   [IAVF_PKT_BURST_VEC].tx_pkt_burst = iavf_xmit_pkts_vec,
+   [IAVF_PKT_BURST_VEC_AVX2].tx_pkt_burst = iavf_xmit_pkts_vec_avx2,
+   [IAVF_PKT_BURST_VEC_AVX2_OFFLOAD].tx_pkt_burst = 
iavf_xmit_pkts_vec_avx2_offload,
+#ifdef CC_AVX512_SUPPORT
+   [IAVF_PKT_BURST_VEC_AVX512].tx_pkt_burst = iavf_xmit_pkts_vec_avx512,
+   [IAVF_PKT_BURST_VEC_AVX512_OFFLOAD].tx_pkt_burst =
+   iavf_xmit_pkts_vec_avx512_offload,
+   [IAVF_PKT_BURST_VEC_AVX512_CTX_OFFLOAD].tx_pkt_burst =
+   iavf_xmit_pkts_vec_avx512_ctx_offload,
+#endif
+#endif
+};
+
 static inline void
 iavf_rxd_to_pkt_fields_by_comms_ovs(__rte_unused struct iavf_rx_queue *rxq,
struct rte_mbuf *mb,
@@ -3724,10 +3741,13 @@ iavf_xmit_pkts_no_poll(void *tx_queue, struct rte_mbuf 
**tx_pkts,
uint16_t nb_pkts)
 {
struct iavf_tx_queue *txq = tx_queue;
+   enum iavf_tx_pkt_burst_type tx_burst_type =
+   txq->vsi->adapter->tx_burst_type;
+
if (!txq->vsi || txq->vsi->adapter->no_poll)
return 0;
 
-   return txq->vsi->adapter->tx_pkt_burst(tx_queue,
+   return iavf_tx_pkt_burst_ops[tx_burst_type].tx_pkt_burst(tx_queue,
tx_pkts, 
nb_pkts);
 }
 
@@ -3975,6 +3995,7 @@ iavf_set_tx_function(struct rte_eth_dev *dev)
 {
struct iavf_adapter *adapter =
IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+   enum iavf_tx_pkt_burst_type tx_burst_type;
int no_poll_on_link_down = adapter->devargs.no_poll_on_link_down;
 #ifdef RTE_ARCH_X86
struct iavf_tx_queue *txq;
@@ -4011,10 +4032,12 @@ iavf_set_tx_function(struct rte_eth_dev *dev)
PMD_DRV_LOG(DEBUG, "Using Vector Tx (port %d).",
dev->data->port_id);
dev->tx_pkt_burst = iavf_xmit_pkts_vec;
+   tx_burst_type = IAVF_PKT_BURST_VEC;
}
if (use_avx2) {
if (check_ret == IAVF_VECTOR_PATH) {
dev->tx_pkt_burst = iavf_xmit_pkts_vec_avx2;
+   tx_burst_type = IAVF_PKT_BURST_VEC_AVX2;
PMD_DRV_LOG(DEBUG, "Using AVX2 Vector Tx (port 
%d).",
dev->data->port_id);
} else if (check_ret == IAVF_VECTOR_CTX_OFFLOAD_PATH) {
@@ -4023,6 +4046,7 @@ iavf_set_tx_function(struct rte_eth_dev *dev)
goto normal;
} else {
dev->tx_pkt_burst = 
iavf_xmit_pkts_vec_avx2_offload;
+   tx_burst_type = IAVF_PKT_BURST_VEC_AVX2_OFFLOAD;
dev->tx_pkt_prepare = iavf_prep_pkt

[PATCH v5 2/2] net/iavf: add diagnostic support in TX path

2023-12-28 Thread Mingjin Ye
The only way to enable diagnostics for TX paths is to modify the
application source code. Making it difficult to diagnose faults.

In this patch, the devarg option "mbuf_check" is introduced and the
parameters are configured to enable the corresponding diagnostics.

supported cases: mbuf, size, segment, offload, strict.
 1. mbuf: check for corrupted mbuf.
 2. size: check min/max packet length according to hw spec.
 3. segment: check number of mbuf segments not exceed hw limitation.
 4. offload: check any unsupported offload flag.
 5. strict: check protocol headers.

parameter format: mbuf_check=[mbuf,,]
eg: dpdk-testpmd -a :81:01.0,mbuf_check=[mbuf,size] -- -i

Signed-off-by: Mingjin Ye 
---
v2: Remove call chain.
---
v3: Optimisation implementation.
---
v4: Fix Windows os compilation error.
---
v5: Split Patch.
---
 doc/guides/nics/intel_vf.rst   |   4 ++
 drivers/net/iavf/iavf.h|  13 +
 drivers/net/iavf/iavf_ethdev.c |  70 ++
 drivers/net/iavf/iavf_rxtx.c   | 104 +
 drivers/net/iavf/iavf_rxtx.h   |   2 +
 5 files changed, 193 insertions(+)

diff --git a/doc/guides/nics/intel_vf.rst b/doc/guides/nics/intel_vf.rst
index ad08198f0f..8e39bc831c 100644
--- a/doc/guides/nics/intel_vf.rst
+++ b/doc/guides/nics/intel_vf.rst
@@ -111,6 +111,10 @@ For more detail on SR-IOV, please refer to the following 
documents:
 by setting the ``devargs`` parameter like ``-a 
18:01.0,no-poll-on-link-down=1``
 when IAVF is backed by an Intel\ |reg| E810 device or an Intel\ |reg| 700 
Series Ethernet device.
 
+Enable mbuf check for Tx diagnostics by setting the devargs parameter like
+``-a 18:01.0,mbuf_check=[mbuf,,]`` when IAVF is backed by an
+Intel\ |reg| E810 device or an Intel\ |reg| 700 Series Ethernet device.
+
 The PCIE host-interface of Intel Ethernet Switch FM1 Series VF 
infrastructure
 
^
 
diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 4cd5bea167..b81329bb56 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -113,9 +113,14 @@ struct iavf_ipsec_crypto_stats {
} ierrors;
 };
 
+struct iavf_mbuf_stats {
+   uint64_t tx_pkt_errors;
+};
+
 struct iavf_eth_xstats {
struct virtchnl_eth_stats eth_stats;
struct iavf_ipsec_crypto_stats ips_stats;
+   struct iavf_mbuf_stats mbuf_stats;
 };
 
 /* Structure that defines a VSI, associated with a adapter. */
@@ -309,10 +314,17 @@ struct iavf_devargs {
uint32_t watchdog_period;
int auto_reset;
int no_poll_on_link_down;
+   int mbuf_check;
 };
 
 struct iavf_security_ctx;
 
+#define IAVF_MBUF_CHECK_F_TX_MBUF(1ULL << 0)
+#define IAVF_MBUF_CHECK_F_TX_SIZE(1ULL << 1)
+#define IAVF_MBUF_CHECK_F_TX_SEGMENT (1ULL << 2)
+#define IAVF_MBUF_CHECK_F_TX_OFFLOAD (1ULL << 3)
+#define IAVF_MBUF_CHECK_F_TX_STRICT  (1ULL << 4)
+
 enum iavf_tx_pkt_burst_type {
IAVF_PKT_BURST_DEFAULT  = 0,
IAVF_PKT_BURST_VEC  = 1,
@@ -340,6 +352,7 @@ struct iavf_adapter {
bool no_poll;
eth_rx_burst_t rx_pkt_burst;
enum iavf_tx_pkt_burst_type tx_burst_type;
+   uint64_t mc_flags; /* mbuf check flags. */
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index d1edb0dd5c..5398d2783f 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -39,6 +40,8 @@
 #define IAVF_RESET_WATCHDOG_ARG"watchdog_period"
 #define IAVF_ENABLE_AUTO_RESET_ARG "auto_reset"
 #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;
 int iavf_timestamp_dynfield_offset = -1;
 
@@ -48,6 +51,7 @@ static const char * const iavf_valid_args[] = {
IAVF_RESET_WATCHDOG_ARG,
IAVF_ENABLE_AUTO_RESET_ARG,
IAVF_NO_POLL_ON_LINK_DOWN_ARG,
+   IAVF_MBUF_CHECK_ARG,
NULL
 };
 
@@ -174,6 +178,7 @@ static const struct rte_iavf_xstats_name_off 
rte_iavf_stats_strings[] = {
{"tx_broadcast_packets", _OFF_OF(eth_stats.tx_broadcast)},
{"tx_dropped_packets", _OFF_OF(eth_stats.tx_discards)},
{"tx_error_packets", _OFF_OF(eth_stats.tx_errors)},
+   {"tx_mbuf_error_packets", _OFF_OF(mbuf_stats.tx_pkt_errors)},
 
{"inline_ipsec_crypto_ipackets", _OFF_OF(ips_stats.icount)},
{"inline_ipsec_crypto_ibytes", _OFF_OF(ips_stats.ibytes)},
@@ -1881,6 +1886,8 @@ static int iavf_dev_xstats_get(struct rte_eth_dev *dev,
 {
int ret;
unsigned int i;
+   struct iavf_tx_queue *txq;
+   uint64_t

[PATCH v6 0/2] net/iavf: fix Rx/Tx burst and add diagnostics

2023-12-29 Thread Mingjin Ye
Fixed Rx/Tx crash in multi-process environment and added
Tx diagnostic feature.

Mingjin Ye (2):
  net/iavf: fix Rx/Tx burst in multi-process
  net/iavf: add diagnostic support in TX path

 doc/guides/nics/intel_vf.rst   |   4 +
 drivers/net/iavf/iavf.h|  54 ++-
 drivers/net/iavf/iavf_ethdev.c |  68 
 drivers/net/iavf/iavf_rxtx.c   | 282 +
 drivers/net/iavf/iavf_rxtx.h   |  10 ++
 5 files changed, 389 insertions(+), 29 deletions(-)

-- 
2.25.1



[PATCH v6 1/2] net/iavf: fix Rx/Tx burst in multi-process

2023-12-29 Thread Mingjin Ye
In a multi-process environment, a secondary process operates on shared
memory and changes the function pointer of the primary process, resulting
in a crash when the primary process cannot find the function address
during an Rx/Tx burst.

Fixes: 5b3124a0a6ef ("net/iavf: support no polling when link down")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
v2: Add fix for Rx burst.
---
 drivers/net/iavf/iavf.h  |  42 +++-
 drivers/net/iavf/iavf_rxtx.c | 184 ++-
 drivers/net/iavf/iavf_rxtx.h |   8 ++
 3 files changed, 205 insertions(+), 29 deletions(-)

diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 10868f2c30..8db9f3d7cd 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -313,6 +313,44 @@ struct iavf_devargs {
 
 struct iavf_security_ctx;
 
+enum iavf_rx_burst_type {
+   IAVF_RX_BURST_DEFAULT,
+   IAVF_RX_BURST_FRXD,
+   IAVF_RX_BURST_BULK_ALLOC,
+   IAVF_RX_BURST_SCATTERED,
+   IAVF_RX_BURST_SFRXD,
+   IAVF_RX_BURST_VEC_SSE,
+   IAVF_RX_BURST_VEC_AVX2,
+   IAVF_RX_BURST_VEC_AVX2_OFFLOAD,
+   IAVF_RX_BURST_VEC_SSE_FRXD,
+   IAVF_RX_BURST_VEC_AVX2_FRXD,
+   IAVF_RX_BURST_VEC_AVX2_FRXD_OFFLOAD,
+   IAVF_RX_BURST_VEC_SSE_SCATTERED,
+   IAVF_RX_BURST_VEC_AVX2_SCATTERED,
+   IAVF_RX_BURST_VEC_AVX2_SCATTERED_OFFLOAD,
+   IAVF_RX_BURST_VEC_SSE_SFLEX_RXD,
+   IAVF_RX_BURST_VEC_AVX2_SFLEX_RXD,
+   IAVF_RX_BURST_VEC_AVX2_SFRXD_OFFLOAD,
+   IAVF_RX_BURST_VEC_AVX512,
+   IAVF_RX_BURST_VEC_AVX512_OFFLOAD,
+   IAVF_RX_BURST_VEC_AVX512_FRXD,
+   IAVF_RX_BURST_VEC_AVX512_FRXD_OFFLOAD,
+   IAVF_RX_BURST_VEC_AVX512_SCATTERED,
+   IAVF_RX_BURST_VEC_AVX512_SCATTERED_OFFLOAD,
+   IAVF_RX_BURST_VEC_AVX512_SFLEX_RXD,
+   IAVF_RX_BURST_VEC_AVX512_SFRXD_OFFLOAD,
+};
+
+enum iavf_tx_burst_type {
+   IAVF_TX_BURST_DEFAULT,
+   IAVF_TX_BURST_VEC_SSE,
+   IAVF_TX_BURST_VEC_AVX2,
+   IAVF_TX_BURST_VEC_AVX2_OFFLOAD,
+   IAVF_TX_BURST_VEC_AVX512,
+   IAVF_TX_BURST_VEC_AVX512_OFFLOAD,
+   IAVF_TX_BURST_VEC_AVX512_CTX_OFFLOAD,
+};
+
 /* Structure to store private data for each VF instance. */
 struct iavf_adapter {
struct iavf_hw hw;
@@ -328,8 +366,8 @@ struct iavf_adapter {
bool stopped;
bool closed;
bool no_poll;
-   eth_rx_burst_t rx_pkt_burst;
-   eth_tx_burst_t tx_pkt_burst;
+   enum iavf_rx_burst_type rx_burst_type;
+   enum iavf_tx_burst_type tx_burst_type;
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index f19aa14646..152f755206 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -3707,15 +3707,88 @@ iavf_prep_pkts(__rte_unused void *tx_queue, struct 
rte_mbuf **tx_pkts,
return i;
 }
 
+static const
+struct iavf_rx_burst_ops iavf_rx_pkt_burst_ops[] = {
+   [IAVF_RX_BURST_DEFAULT].rx_pkt_burst = iavf_recv_pkts,
+   [IAVF_RX_BURST_FRXD].rx_pkt_burst = iavf_recv_pkts_flex_rxd,
+   [IAVF_RX_BURST_BULK_ALLOC].rx_pkt_burst = iavf_recv_pkts_bulk_alloc,
+   [IAVF_RX_BURST_SCATTERED].rx_pkt_burst = iavf_recv_scattered_pkts,
+   [IAVF_RX_BURST_SFRXD].rx_pkt_burst =
+   iavf_recv_scattered_pkts_flex_rxd,
+#ifdef RTE_ARCH_X86
+   [IAVF_RX_BURST_VEC_SSE].rx_pkt_burst = iavf_recv_pkts_vec,
+   [IAVF_RX_BURST_VEC_AVX2].rx_pkt_burst = iavf_recv_pkts_vec_avx2,
+   [IAVF_RX_BURST_VEC_AVX2_OFFLOAD].rx_pkt_burst =
+   iavf_recv_pkts_vec_avx2_offload,
+   [IAVF_RX_BURST_VEC_SSE_FRXD].rx_pkt_burst =
+   iavf_recv_pkts_vec_flex_rxd,
+   [IAVF_RX_BURST_VEC_AVX2_FRXD].rx_pkt_burst =
+   iavf_recv_pkts_vec_avx2_flex_rxd,
+   [IAVF_RX_BURST_VEC_AVX2_FRXD_OFFLOAD].rx_pkt_burst =
+   iavf_recv_pkts_vec_avx2_flex_rxd_offload,
+   [IAVF_RX_BURST_VEC_SSE_SCATTERED].rx_pkt_burst =
+   iavf_recv_scattered_pkts_vec,
+   [IAVF_RX_BURST_VEC_AVX2_SCATTERED].rx_pkt_burst =
+   iavf_recv_scattered_pkts_vec_avx2,
+   [IAVF_RX_BURST_VEC_AVX2_SCATTERED_OFFLOAD].rx_pkt_burst =
+   iavf_recv_scattered_pkts_vec_avx2_offload,
+   [IAVF_RX_BURST_VEC_SSE_SFLEX_RXD].rx_pkt_burst =
+   iavf_recv_scattered_pkts_vec_flex_rxd,
+   [IAVF_RX_BURST_VEC_AVX2_SFLEX_RXD].rx_pkt_burst =
+   iavf_recv_scattered_pkts_vec_avx2_flex_rxd,
+   [IAVF_RX_BURST_VEC_AVX2_SFRXD_OFFLOAD].rx_pkt_burst =
+   iavf_recv_scattered_pkts_vec_avx2_flex_rxd_offload,
+#ifdef CC_AVX512_SUPPORT
+   [IAVF_RX_BURST_VEC_AVX512].rx_pkt_burst = iavf_recv_pkts_vec_avx512,
+   [IAVF_RX_BURST_VEC_AVX512_OFFLOAD].rx_pkt_burst =
+   iavf_recv_pkts_vec_avx512_offload,
+   [IAVF_RX_BURST_VEC_AVX512_FRXD].rx_pkt_burst =
+   iavf_recv_pkts_vec_avx512_flex_rxd,
+   [IAVF_RX_BURST_VEC_AVX512_FR

[PATCH v6 2/2] net/iavf: add diagnostic support in TX path

2023-12-29 Thread Mingjin Ye
The only way to enable diagnostics for TX paths is to modify the
application source code. Making it difficult to diagnose faults.

In this patch, the devarg option "mbuf_check" is introduced and the
parameters are configured to enable the corresponding diagnostics.

supported cases: mbuf, size, segment, offload.
 1. mbuf: check for corrupted mbuf.
 2. size: check min/max packet length according to hw spec.
 3. segment: check number of mbuf segments not exceed hw limitation.
 4. offload: check any unsupported offload flag.

parameter format: mbuf_check=[mbuf,,]
eg: dpdk-testpmd -a :81:01.0,mbuf_check=[mbuf,size] -- -i

Signed-off-by: Mingjin Ye 
---
v2: Remove call chain.
---
v3: Optimisation implementation.
---
v4: Fix Windows os compilation error.
---
v5: Split Patch.
---
v6: remove strict.
---
 doc/guides/nics/intel_vf.rst   |  4 ++
 drivers/net/iavf/iavf.h| 12 +
 drivers/net/iavf/iavf_ethdev.c | 68 +++
 drivers/net/iavf/iavf_rxtx.c   | 98 ++
 drivers/net/iavf/iavf_rxtx.h   |  2 +
 5 files changed, 184 insertions(+)

diff --git a/doc/guides/nics/intel_vf.rst b/doc/guides/nics/intel_vf.rst
index ad08198f0f..8e39bc831c 100644
--- a/doc/guides/nics/intel_vf.rst
+++ b/doc/guides/nics/intel_vf.rst
@@ -111,6 +111,10 @@ For more detail on SR-IOV, please refer to the following 
documents:
 by setting the ``devargs`` parameter like ``-a 
18:01.0,no-poll-on-link-down=1``
 when IAVF is backed by an Intel\ |reg| E810 device or an Intel\ |reg| 700 
Series Ethernet device.
 
+Enable mbuf check for Tx diagnostics by setting the devargs parameter like
+``-a 18:01.0,mbuf_check=[mbuf,,]`` when IAVF is backed by an
+Intel\ |reg| E810 device or an Intel\ |reg| 700 Series Ethernet device.
+
 The PCIE host-interface of Intel Ethernet Switch FM1 Series VF 
infrastructure
 
^
 
diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 8db9f3d7cd..0a7053e311 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -113,9 +113,14 @@ struct iavf_ipsec_crypto_stats {
} ierrors;
 };
 
+struct iavf_mbuf_stats {
+   uint64_t tx_pkt_errors;
+};
+
 struct iavf_eth_xstats {
struct virtchnl_eth_stats eth_stats;
struct iavf_ipsec_crypto_stats ips_stats;
+   struct iavf_mbuf_stats mbuf_stats;
 };
 
 /* Structure that defines a VSI, associated with a adapter. */
@@ -309,10 +314,16 @@ struct iavf_devargs {
uint32_t watchdog_period;
int auto_reset;
int no_poll_on_link_down;
+   int mbuf_check;
 };
 
 struct iavf_security_ctx;
 
+#define IAVF_MBUF_CHECK_F_TX_MBUF(1ULL << 0)
+#define IAVF_MBUF_CHECK_F_TX_SIZE(1ULL << 1)
+#define IAVF_MBUF_CHECK_F_TX_SEGMENT (1ULL << 2)
+#define IAVF_MBUF_CHECK_F_TX_OFFLOAD (1ULL << 3)
+
 enum iavf_rx_burst_type {
IAVF_RX_BURST_DEFAULT,
IAVF_RX_BURST_FRXD,
@@ -368,6 +379,7 @@ struct iavf_adapter {
bool no_poll;
enum iavf_rx_burst_type rx_burst_type;
enum iavf_tx_burst_type tx_burst_type;
+   uint64_t mc_flags; /* mbuf check flags. */
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index d1edb0dd5c..a7a0d99868 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -39,6 +40,8 @@
 #define IAVF_RESET_WATCHDOG_ARG"watchdog_period"
 #define IAVF_ENABLE_AUTO_RESET_ARG "auto_reset"
 #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;
 int iavf_timestamp_dynfield_offset = -1;
 
@@ -48,6 +51,7 @@ static const char * const iavf_valid_args[] = {
IAVF_RESET_WATCHDOG_ARG,
IAVF_ENABLE_AUTO_RESET_ARG,
IAVF_NO_POLL_ON_LINK_DOWN_ARG,
+   IAVF_MBUF_CHECK_ARG,
NULL
 };
 
@@ -174,6 +178,7 @@ static const struct rte_iavf_xstats_name_off 
rte_iavf_stats_strings[] = {
{"tx_broadcast_packets", _OFF_OF(eth_stats.tx_broadcast)},
{"tx_dropped_packets", _OFF_OF(eth_stats.tx_discards)},
{"tx_error_packets", _OFF_OF(eth_stats.tx_errors)},
+   {"tx_mbuf_error_packets", _OFF_OF(mbuf_stats.tx_pkt_errors)},
 
{"inline_ipsec_crypto_ipackets", _OFF_OF(ips_stats.icount)},
{"inline_ipsec_crypto_ibytes", _OFF_OF(ips_stats.ibytes)},
@@ -1881,6 +1886,8 @@ static int iavf_dev_xstats_get(struct rte_eth_dev *dev,
 {
int ret;
unsigned int i;
+   struct iavf_tx_queue *txq;
+   uint64_t mbuf_errors = 0;
struct iavf_adapter *adapter =
IAVF_DEV_PRIVATE_TO_ADAPTER(dev

[PATCH v7 0/2] net/iavf: fix Rx/Tx burst and add diagnostics

2024-01-02 Thread Mingjin Ye
Fixed Rx/Tx crash in multi-process environment and
added Tx diagnostic feature.

Mingjin Ye (2):
  net/iavf: fix Rx/Tx burst in multi-process
  net/iavf: add diagnostic support in TX path

 doc/guides/nics/intel_vf.rst   |   4 +
 drivers/net/iavf/iavf.h|  54 ++-
 drivers/net/iavf/iavf_ethdev.c |  72 +
 drivers/net/iavf/iavf_rxtx.c   | 271 ++---
 drivers/net/iavf/iavf_rxtx.h   |   2 +
 5 files changed, 345 insertions(+), 58 deletions(-)

-- 
2.25.1



[PATCH v7 1/2] net/iavf: fix Rx/Tx burst in multi-process

2024-01-02 Thread Mingjin Ye
In a multi-process environment, a secondary process operates on shared
memory and changes the function pointer of the primary process, resulting
in a crash when the primary process cannot find the function address
during an Rx/Tx burst.

Fixes: 5b3124a0a6ef ("net/iavf: support no polling when link down")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
v2: Add fix for Rx burst.
---
v3: fix Rx/Tx routing.
---
 drivers/net/iavf/iavf.h  |  42 -
 drivers/net/iavf/iavf_rxtx.c | 173 +++
 2 files changed, 157 insertions(+), 58 deletions(-)

diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 10868f2c30..73a089c199 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -313,6 +313,44 @@ struct iavf_devargs {
 
 struct iavf_security_ctx;
 
+enum iavf_rx_burst_type {
+   IAVF_RX_DEFAULT,
+   IAVF_RX_FLEX_RXD,
+   IAVF_RX_BULK_ALLOC,
+   IAVF_RX_SCATTERED,
+   IAVF_RX_SCATTERED_FLEX_RXD,
+   IAVF_RX_SSE,
+   IAVF_RX_AVX2,
+   IAVF_RX_AVX2_OFFLOAD,
+   IAVF_RX_SSE_FLEX_RXD,
+   IAVF_RX_AVX2_FLEX_RXD,
+   IAVF_RX_AVX2_FLEX_RXD_OFFLOAD,
+   IAVF_RX_SSE_SCATTERED,
+   IAVF_RX_AVX2_SCATTERED,
+   IAVF_RX_AVX2_SCATTERED_OFFLOAD,
+   IAVF_RX_SSE_SCATTERED_FLEX_RXD,
+   IAVF_RX_AVX2_SCATTERED_FLEX_RXD,
+   IAVF_RX_AVX2_SCATTERED_FLEX_RXD_OFFLOAD,
+   IAVF_RX_AVX512,
+   IAVF_RX_AVX512_OFFLOAD,
+   IAVF_RX_AVX512_FLEX_RXD,
+   IAVF_RX_AVX512_FLEX_RXD_OFFLOAD,
+   IAVF_RX_AVX512_SCATTERED,
+   IAVF_RX_AVX512_SCATTERED_OFFLOAD,
+   IAVF_RX_AVX512_SCATTERED_FLEX_RXD,
+   IAVF_RX_AVX512_SCATTERED_FLEX_RXD_OFFLOAD,
+};
+
+enum iavf_tx_burst_type {
+   IAVF_TX_DEFAULT,
+   IAVF_TX_SSE,
+   IAVF_TX_AVX2,
+   IAVF_TX_AVX2_OFFLOAD,
+   IAVF_TX_AVX512,
+   IAVF_TX_AVX512_OFFLOAD,
+   IAVF_TX_AVX512_CTX_OFFLOAD,
+};
+
 /* Structure to store private data for each VF instance. */
 struct iavf_adapter {
struct iavf_hw hw;
@@ -328,8 +366,8 @@ struct iavf_adapter {
bool stopped;
bool closed;
bool no_poll;
-   eth_rx_burst_t rx_pkt_burst;
-   eth_tx_burst_t tx_pkt_burst;
+   enum iavf_rx_burst_type rx_burst_type;
+   enum iavf_tx_burst_type tx_burst_type;
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index f19aa14646..13b932ad85 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -3707,15 +3707,68 @@ iavf_prep_pkts(__rte_unused void *tx_queue, struct 
rte_mbuf **tx_pkts,
return i;
 }
 
+static
+const eth_rx_burst_t iavf_rx_pkt_burst_ops[] = {
+   iavf_recv_pkts,
+   iavf_recv_pkts_flex_rxd,
+   iavf_recv_pkts_bulk_alloc,
+   iavf_recv_scattered_pkts,
+   iavf_recv_scattered_pkts_flex_rxd,
+#ifdef RTE_ARCH_X86
+   iavf_recv_pkts_vec,
+   iavf_recv_pkts_vec_avx2,
+   iavf_recv_pkts_vec_avx2_offload,
+   iavf_recv_pkts_vec_flex_rxd,
+   iavf_recv_pkts_vec_avx2_flex_rxd,
+   iavf_recv_pkts_vec_avx2_flex_rxd_offload,
+   iavf_recv_scattered_pkts_vec,
+   iavf_recv_scattered_pkts_vec_avx2,
+   iavf_recv_scattered_pkts_vec_avx2_offload,
+   iavf_recv_scattered_pkts_vec_flex_rxd,
+   iavf_recv_scattered_pkts_vec_avx2_flex_rxd,
+   iavf_recv_scattered_pkts_vec_avx2_flex_rxd_offload,
+#ifdef CC_AVX512_SUPPORT
+   iavf_recv_pkts_vec_avx512,
+   iavf_recv_pkts_vec_avx512_offload,
+   iavf_recv_pkts_vec_avx512_flex_rxd,
+   iavf_recv_pkts_vec_avx512_flex_rxd_offload,
+   iavf_recv_scattered_pkts_vec_avx512,
+   iavf_recv_scattered_pkts_vec_avx512_offload,
+   iavf_recv_scattered_pkts_vec_avx512_flex_rxd,
+   iavf_recv_scattered_pkts_vec_avx512_flex_rxd_offload,
+#endif
+#elif defined RTE_ARCH_ARM
+   iavf_recv_pkts_vec,
+#endif
+};
+
+static
+const eth_tx_burst_t iavf_tx_pkt_burst_ops[] = {
+   iavf_xmit_pkts,
+#ifdef RTE_ARCH_X86
+   iavf_xmit_pkts_vec,
+   iavf_xmit_pkts_vec_avx2,
+   iavf_xmit_pkts_vec_avx2_offload,
+#ifdef CC_AVX512_SUPPORT
+   iavf_xmit_pkts_vec_avx512,
+   iavf_xmit_pkts_vec_avx512_offload,
+   iavf_xmit_pkts_vec_avx512_ctx_offload,
+#endif
+#endif
+};
+
 static uint16_t
 iavf_recv_pkts_no_poll(void *rx_queue, struct rte_mbuf **rx_pkts,
uint16_t nb_pkts)
 {
struct iavf_rx_queue *rxq = rx_queue;
+   enum iavf_rx_burst_type rx_burst_type =
+   rxq->vsi->adapter->rx_burst_type;
+
if (!rxq->vsi || rxq->vsi->adapter->no_poll)
return 0;
 
-   return rxq->vsi->adapter->rx_pkt_burst(rx_queue,
+   return iavf_rx_pkt_burst_ops[rx_burst_type](rx_queue,
rx_pkts, 
nb_pkts);
 }
 
@@ -3724,10 +3777,13 @@ iavf_xmit_pkts_no_poll(vo

[PATCH v7 2/2] net/iavf: add diagnostic support in TX path

2024-01-02 Thread Mingjin Ye
The only way to enable diagnostics for TX paths is to modify the
application source code. Making it difficult to diagnose faults.

In this patch, the devarg option "mbuf_check" is introduced and the
parameters are configured to enable the corresponding diagnostics.

supported cases: mbuf, size, segment, offload.
 1. mbuf: check for corrupted mbuf.
 2. size: check min/max packet length according to hw spec.
 3. segment: check number of mbuf segments not exceed hw limitation.
 4. offload: check any unsupported offload flag.

parameter format: mbuf_check=[mbuf,,]
eg: dpdk-testpmd -a :81:01.0,mbuf_check=[mbuf,size] -- -i

Signed-off-by: Mingjin Ye 
---
v2: Remove call chain.
---
v3: Optimisation implementation.
---
v4: Fix Windows os compilation error.
---
v5: Split Patch.
---
v6: remove strict.
---
 doc/guides/nics/intel_vf.rst   |  4 ++
 drivers/net/iavf/iavf.h| 12 +
 drivers/net/iavf/iavf_ethdev.c | 72 +
 drivers/net/iavf/iavf_rxtx.c   | 98 ++
 drivers/net/iavf/iavf_rxtx.h   |  2 +
 5 files changed, 188 insertions(+)

diff --git a/doc/guides/nics/intel_vf.rst b/doc/guides/nics/intel_vf.rst
index ad08198f0f..8e39bc831c 100644
--- a/doc/guides/nics/intel_vf.rst
+++ b/doc/guides/nics/intel_vf.rst
@@ -111,6 +111,10 @@ For more detail on SR-IOV, please refer to the following 
documents:
 by setting the ``devargs`` parameter like ``-a 
18:01.0,no-poll-on-link-down=1``
 when IAVF is backed by an Intel\ |reg| E810 device or an Intel\ |reg| 700 
Series Ethernet device.
 
+Enable mbuf check for Tx diagnostics by setting the devargs parameter like
+``-a 18:01.0,mbuf_check=[mbuf,,]`` when IAVF is backed by an
+Intel\ |reg| E810 device or an Intel\ |reg| 700 Series Ethernet device.
+
 The PCIE host-interface of Intel Ethernet Switch FM1 Series VF 
infrastructure
 
^
 
diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 73a089c199..6535b624cb 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -113,9 +113,14 @@ struct iavf_ipsec_crypto_stats {
} ierrors;
 };
 
+struct iavf_mbuf_stats {
+   uint64_t tx_pkt_errors;
+};
+
 struct iavf_eth_xstats {
struct virtchnl_eth_stats eth_stats;
struct iavf_ipsec_crypto_stats ips_stats;
+   struct iavf_mbuf_stats mbuf_stats;
 };
 
 /* Structure that defines a VSI, associated with a adapter. */
@@ -309,6 +314,7 @@ struct iavf_devargs {
uint32_t watchdog_period;
int auto_reset;
int no_poll_on_link_down;
+   int mbuf_check;
 };
 
 struct iavf_security_ctx;
@@ -351,6 +357,11 @@ enum iavf_tx_burst_type {
IAVF_TX_AVX512_CTX_OFFLOAD,
 };
 
+#define IAVF_MBUF_CHECK_F_TX_MBUF(1ULL << 0)
+#define IAVF_MBUF_CHECK_F_TX_SIZE(1ULL << 1)
+#define IAVF_MBUF_CHECK_F_TX_SEGMENT (1ULL << 2)
+#define IAVF_MBUF_CHECK_F_TX_OFFLOAD (1ULL << 3)
+
 /* Structure to store private data for each VF instance. */
 struct iavf_adapter {
struct iavf_hw hw;
@@ -368,6 +379,7 @@ struct iavf_adapter {
bool no_poll;
enum iavf_rx_burst_type rx_burst_type;
enum iavf_tx_burst_type tx_burst_type;
+   uint64_t mc_flags; /* mbuf check flags. */
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index d1edb0dd5c..25938b9558 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -39,6 +40,8 @@
 #define IAVF_RESET_WATCHDOG_ARG"watchdog_period"
 #define IAVF_ENABLE_AUTO_RESET_ARG "auto_reset"
 #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;
 int iavf_timestamp_dynfield_offset = -1;
 
@@ -48,6 +51,7 @@ static const char * const iavf_valid_args[] = {
IAVF_RESET_WATCHDOG_ARG,
IAVF_ENABLE_AUTO_RESET_ARG,
IAVF_NO_POLL_ON_LINK_DOWN_ARG,
+   IAVF_MBUF_CHECK_ARG,
NULL
 };
 
@@ -174,6 +178,7 @@ static const struct rte_iavf_xstats_name_off 
rte_iavf_stats_strings[] = {
{"tx_broadcast_packets", _OFF_OF(eth_stats.tx_broadcast)},
{"tx_dropped_packets", _OFF_OF(eth_stats.tx_discards)},
{"tx_error_packets", _OFF_OF(eth_stats.tx_errors)},
+   {"tx_mbuf_error_packets", _OFF_OF(mbuf_stats.tx_pkt_errors)},
 
{"inline_ipsec_crypto_ipackets", _OFF_OF(ips_stats.icount)},
{"inline_ipsec_crypto_ibytes", _OFF_OF(ips_stats.ibytes)},
@@ -1837,6 +1842,9 @@ iavf_dev_xstats_reset(struct rte_eth_dev *dev)
iavf_dev_stats_reset(dev);
memset(&vf->vsi.eth_stats_offset.ips_stats, 0,
  

[PATCH v8 0/2] net/iavf: fix Rx/Tx burst and add diagnostics

2024-01-03 Thread Mingjin Ye
Fixed Rx/Tx crash in multi-process environment and added
Tx diagnostic feature.

Mingjin Ye (2):
  net/iavf: fix Rx/Tx burst in multi-process
  net/iavf: add diagnostic support in TX path

 doc/guides/nics/intel_vf.rst   |   9 ++
 drivers/net/iavf/iavf.h|  54 ++-
 drivers/net/iavf/iavf_ethdev.c |  76 +
 drivers/net/iavf/iavf_rxtx.c   | 280 ++---
 drivers/net/iavf/iavf_rxtx.h   |   2 +
 5 files changed, 363 insertions(+), 58 deletions(-)

-- 
2.25.1



[PATCH v8 1/2] net/iavf: fix Rx/Tx burst in multi-process

2024-01-03 Thread Mingjin Ye
In a multi-process environment, a secondary process operates on shared
memory and changes the function pointer of the primary process, resulting
in a crash when the primary process cannot find the function address
during an Rx/Tx burst.

Fixes: 5b3124a0a6ef ("net/iavf: support no polling when link down")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
v2: Add fix for Rx burst.
---
v3: fix Rx/Tx routing.
---
v4: Fix the ops array.
---
 drivers/net/iavf/iavf.h  |  42 +++-
 drivers/net/iavf/iavf_rxtx.c | 182 ---
 2 files changed, 166 insertions(+), 58 deletions(-)

diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 10868f2c30..73a089c199 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -313,6 +313,44 @@ struct iavf_devargs {
 
 struct iavf_security_ctx;
 
+enum iavf_rx_burst_type {
+   IAVF_RX_DEFAULT,
+   IAVF_RX_FLEX_RXD,
+   IAVF_RX_BULK_ALLOC,
+   IAVF_RX_SCATTERED,
+   IAVF_RX_SCATTERED_FLEX_RXD,
+   IAVF_RX_SSE,
+   IAVF_RX_AVX2,
+   IAVF_RX_AVX2_OFFLOAD,
+   IAVF_RX_SSE_FLEX_RXD,
+   IAVF_RX_AVX2_FLEX_RXD,
+   IAVF_RX_AVX2_FLEX_RXD_OFFLOAD,
+   IAVF_RX_SSE_SCATTERED,
+   IAVF_RX_AVX2_SCATTERED,
+   IAVF_RX_AVX2_SCATTERED_OFFLOAD,
+   IAVF_RX_SSE_SCATTERED_FLEX_RXD,
+   IAVF_RX_AVX2_SCATTERED_FLEX_RXD,
+   IAVF_RX_AVX2_SCATTERED_FLEX_RXD_OFFLOAD,
+   IAVF_RX_AVX512,
+   IAVF_RX_AVX512_OFFLOAD,
+   IAVF_RX_AVX512_FLEX_RXD,
+   IAVF_RX_AVX512_FLEX_RXD_OFFLOAD,
+   IAVF_RX_AVX512_SCATTERED,
+   IAVF_RX_AVX512_SCATTERED_OFFLOAD,
+   IAVF_RX_AVX512_SCATTERED_FLEX_RXD,
+   IAVF_RX_AVX512_SCATTERED_FLEX_RXD_OFFLOAD,
+};
+
+enum iavf_tx_burst_type {
+   IAVF_TX_DEFAULT,
+   IAVF_TX_SSE,
+   IAVF_TX_AVX2,
+   IAVF_TX_AVX2_OFFLOAD,
+   IAVF_TX_AVX512,
+   IAVF_TX_AVX512_OFFLOAD,
+   IAVF_TX_AVX512_CTX_OFFLOAD,
+};
+
 /* Structure to store private data for each VF instance. */
 struct iavf_adapter {
struct iavf_hw hw;
@@ -328,8 +366,8 @@ struct iavf_adapter {
bool stopped;
bool closed;
bool no_poll;
-   eth_rx_burst_t rx_pkt_burst;
-   eth_tx_burst_t tx_pkt_burst;
+   enum iavf_rx_burst_type rx_burst_type;
+   enum iavf_tx_burst_type tx_burst_type;
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index f19aa14646..89db82c694 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -3707,15 +3707,77 @@ iavf_prep_pkts(__rte_unused void *tx_queue, struct 
rte_mbuf **tx_pkts,
return i;
 }
 
+static
+const eth_rx_burst_t iavf_rx_pkt_burst_ops[] = {
+   [IAVF_RX_DEFAULT] = iavf_recv_pkts,
+   [IAVF_RX_FLEX_RXD] = iavf_recv_pkts_flex_rxd,
+   [IAVF_RX_BULK_ALLOC] = iavf_recv_pkts_bulk_alloc,
+   [IAVF_RX_SCATTERED] = iavf_recv_scattered_pkts,
+   [IAVF_RX_SCATTERED_FLEX_RXD] = iavf_recv_scattered_pkts_flex_rxd,
+#ifdef RTE_ARCH_X86
+   [IAVF_RX_SSE] = iavf_recv_pkts_vec,
+   [IAVF_RX_AVX2] = iavf_recv_pkts_vec_avx2,
+   [IAVF_RX_AVX2_OFFLOAD] = iavf_recv_pkts_vec_avx2_offload,
+   [IAVF_RX_SSE_FLEX_RXD] = iavf_recv_pkts_vec_flex_rxd,
+   [IAVF_RX_AVX2_FLEX_RXD] = iavf_recv_pkts_vec_avx2_flex_rxd,
+   [IAVF_RX_AVX2_FLEX_RXD_OFFLOAD] =
+   iavf_recv_pkts_vec_avx2_flex_rxd_offload,
+   [IAVF_RX_SSE_SCATTERED] = iavf_recv_scattered_pkts_vec,
+   [IAVF_RX_AVX2_SCATTERED] = iavf_recv_scattered_pkts_vec_avx2,
+   [IAVF_RX_AVX2_SCATTERED_OFFLOAD] =
+   iavf_recv_scattered_pkts_vec_avx2_offload,
+   [IAVF_RX_SSE_SCATTERED_FLEX_RXD] =
+   iavf_recv_scattered_pkts_vec_flex_rxd,
+   [IAVF_RX_AVX2_SCATTERED_FLEX_RXD] =
+   iavf_recv_scattered_pkts_vec_avx2_flex_rxd,
+   [IAVF_RX_AVX2_SCATTERED_FLEX_RXD_OFFLOAD] =
+   iavf_recv_scattered_pkts_vec_avx2_flex_rxd_offload,
+#ifdef CC_AVX512_SUPPORT
+   [IAVF_RX_AVX512] = iavf_recv_pkts_vec_avx512,
+   [IAVF_RX_AVX512_OFFLOAD] = iavf_recv_pkts_vec_avx512_offload,
+   [IAVF_RX_AVX512_FLEX_RXD] = iavf_recv_pkts_vec_avx512_flex_rxd,
+   [IAVF_RX_AVX512_FLEX_RXD_OFFLOAD] =
+   iavf_recv_pkts_vec_avx512_flex_rxd_offload,
+   [IAVF_RX_AVX512_SCATTERED] = iavf_recv_scattered_pkts_vec_avx512,
+   [IAVF_RX_AVX512_SCATTERED_OFFLOAD] =
+   iavf_recv_scattered_pkts_vec_avx512_offload,
+   [IAVF_RX_AVX512_SCATTERED_FLEX_RXD] =
+   iavf_recv_scattered_pkts_vec_avx512_flex_rxd,
+   [IAVF_RX_AVX512_SCATTERED_FLEX_RXD_OFFLOAD] =
+   iavf_recv_scattered_pkts_vec_avx512_flex_rxd_offload,
+#endif
+#elif defined RTE_ARCH_ARM
+   [IAVF_RX_SSE] = iavf_recv_pkts_vec,
+#endif
+};
+
+static
+const eth_tx_burst_t iavf_tx_pkt_burst_ops[] = {
+   [IAVF_TX_DEFAULT] = iavf_xmit_pkts,
+#ifdef RTE_ARCH_X86
+   [I

[PATCH v8 2/2] net/iavf: add diagnostic support in TX path

2024-01-03 Thread Mingjin Ye
The only way to enable diagnostics for TX paths is to modify the
application source code. Making it difficult to diagnose faults.

In this patch, the devarg option "mbuf_check" is introduced and the
parameters are configured to enable the corresponding diagnostics.

supported cases: mbuf, size, segment, offload.
 1. mbuf: check for corrupted mbuf.
 2. size: check min/max packet length according to hw spec.
 3. segment: check number of mbuf segments not exceed hw limitation.
 4. offload: check any unsupported offload flag.

parameter format: mbuf_check=[mbuf,,]
eg: dpdk-testpmd -a :81:01.0,mbuf_check=[mbuf,size] -- -i

Signed-off-by: Mingjin Ye 
---
v2: Remove call chain.
---
v3: Optimisation implementation.
---
v4: Fix Windows os compilation error.
---
v5: Split Patch.
---
v6: remove strict.
---
v7: Modify the description document.
---
 doc/guides/nics/intel_vf.rst   |  9 
 drivers/net/iavf/iavf.h| 12 +
 drivers/net/iavf/iavf_ethdev.c | 76 ++
 drivers/net/iavf/iavf_rxtx.c   | 98 ++
 drivers/net/iavf/iavf_rxtx.h   |  2 +
 5 files changed, 197 insertions(+)

diff --git a/doc/guides/nics/intel_vf.rst b/doc/guides/nics/intel_vf.rst
index ad08198f0f..bda6648726 100644
--- a/doc/guides/nics/intel_vf.rst
+++ b/doc/guides/nics/intel_vf.rst
@@ -111,6 +111,15 @@ For more detail on SR-IOV, please refer to the following 
documents:
 by setting the ``devargs`` parameter like ``-a 
18:01.0,no-poll-on-link-down=1``
 when IAVF is backed by an Intel\ |reg| E810 device or an Intel\ |reg| 700 
Series Ethernet device.
 
+When IAVF is backed by an Intel\ |reg| E810 device or an Intel\ |reg| 700 
series Ethernet devices.
+Set the ``devargs`` parameter ``mbuf_check`` to enable TX diagnostics. For 
example,
+``-a 18:01.0,mbuf_check=mbuf`` or ``-a 18:01.0,mbuf_check=[mbuf,size]``. 
Supported cases:
+
+*   mbuf: Check for corrupted mbuf.
+*   size: Check min/max packet length according to hw spec.
+*   segment: Check number of mbuf segments not exceed hw limitation.
+*   offload: Check any unsupported offload flag.
+
 The PCIE host-interface of Intel Ethernet Switch FM1 Series VF 
infrastructure
 
^
 
diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 73a089c199..6535b624cb 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -113,9 +113,14 @@ struct iavf_ipsec_crypto_stats {
} ierrors;
 };
 
+struct iavf_mbuf_stats {
+   uint64_t tx_pkt_errors;
+};
+
 struct iavf_eth_xstats {
struct virtchnl_eth_stats eth_stats;
struct iavf_ipsec_crypto_stats ips_stats;
+   struct iavf_mbuf_stats mbuf_stats;
 };
 
 /* Structure that defines a VSI, associated with a adapter. */
@@ -309,6 +314,7 @@ struct iavf_devargs {
uint32_t watchdog_period;
int auto_reset;
int no_poll_on_link_down;
+   int mbuf_check;
 };
 
 struct iavf_security_ctx;
@@ -351,6 +357,11 @@ enum iavf_tx_burst_type {
IAVF_TX_AVX512_CTX_OFFLOAD,
 };
 
+#define IAVF_MBUF_CHECK_F_TX_MBUF(1ULL << 0)
+#define IAVF_MBUF_CHECK_F_TX_SIZE(1ULL << 1)
+#define IAVF_MBUF_CHECK_F_TX_SEGMENT (1ULL << 2)
+#define IAVF_MBUF_CHECK_F_TX_OFFLOAD (1ULL << 3)
+
 /* Structure to store private data for each VF instance. */
 struct iavf_adapter {
struct iavf_hw hw;
@@ -368,6 +379,7 @@ struct iavf_adapter {
bool no_poll;
enum iavf_rx_burst_type rx_burst_type;
enum iavf_tx_burst_type tx_burst_type;
+   uint64_t mc_flags; /* mbuf check flags. */
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index d1edb0dd5c..7d1cd9050b 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -39,6 +40,8 @@
 #define IAVF_RESET_WATCHDOG_ARG"watchdog_period"
 #define IAVF_ENABLE_AUTO_RESET_ARG "auto_reset"
 #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;
 int iavf_timestamp_dynfield_offset = -1;
 
@@ -48,6 +51,7 @@ static const char * const iavf_valid_args[] = {
IAVF_RESET_WATCHDOG_ARG,
IAVF_ENABLE_AUTO_RESET_ARG,
IAVF_NO_POLL_ON_LINK_DOWN_ARG,
+   IAVF_MBUF_CHECK_ARG,
NULL
 };
 
@@ -174,6 +178,7 @@ static const struct rte_iavf_xstats_name_off 
rte_iavf_stats_strings[] = {
{"tx_broadcast_packets", _OFF_OF(eth_stats.tx_broadcast)},
{"tx_dropped_packets", _OFF_OF(eth_stats.tx_discards)},
{"tx_error_packets", _OFF_OF(eth_stats.tx_errors)},
+   {"tx_mbuf_error_pack

[PATCH v9 0/2] net/iavf: fix Rx/Tx burst and add diagnostics

2024-01-04 Thread Mingjin Ye
Fixed Rx/Tx crash in multi-process environment and
added Tx diagnostic feature.

Mingjin Ye (2):
  net/iavf: fix Rx/Tx burst in multi-process
  net/iavf: add diagnostic support in TX path

 doc/guides/nics/intel_vf.rst   |   9 ++
 drivers/net/iavf/iavf.h|  55 ++-
 drivers/net/iavf/iavf_ethdev.c |  75 +
 drivers/net/iavf/iavf_rxtx.c   | 283 ++---
 drivers/net/iavf/iavf_rxtx.h   |   2 +
 5 files changed, 365 insertions(+), 59 deletions(-)

-- 
2.25.1



[PATCH v9 1/2] net/iavf: fix Rx/Tx burst in multi-process

2024-01-04 Thread Mingjin Ye
In a multi-process environment, a secondary process operates on shared
memory and changes the function pointer of the primary process, resulting
in a crash when the primary process cannot find the function address
during an Rx/Tx burst.

Fixes: 5b3124a0a6ef ("net/iavf: support no polling when link down")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
v2: Add fix for Rx burst.
---
v3: fix Rx/Tx routing.
---
v4: Fix the ops array.
---
v5: rebase.
---
 drivers/net/iavf/iavf.h  |  43 +++-
 drivers/net/iavf/iavf_rxtx.c | 185 ---
 2 files changed, 169 insertions(+), 59 deletions(-)

diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index d273d884f5..ab24cb02c3 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -314,6 +314,45 @@ struct iavf_devargs {
 
 struct iavf_security_ctx;
 
+enum iavf_rx_burst_type {
+   IAVF_RX_DEFAULT,
+   IAVF_RX_FLEX_RXD,
+   IAVF_RX_BULK_ALLOC,
+   IAVF_RX_SCATTERED,
+   IAVF_RX_SCATTERED_FLEX_RXD,
+   IAVF_RX_SSE,
+   IAVF_RX_AVX2,
+   IAVF_RX_AVX2_OFFLOAD,
+   IAVF_RX_SSE_FLEX_RXD,
+   IAVF_RX_AVX2_FLEX_RXD,
+   IAVF_RX_AVX2_FLEX_RXD_OFFLOAD,
+   IAVF_RX_SSE_SCATTERED,
+   IAVF_RX_AVX2_SCATTERED,
+   IAVF_RX_AVX2_SCATTERED_OFFLOAD,
+   IAVF_RX_SSE_SCATTERED_FLEX_RXD,
+   IAVF_RX_AVX2_SCATTERED_FLEX_RXD,
+   IAVF_RX_AVX2_SCATTERED_FLEX_RXD_OFFLOAD,
+   IAVF_RX_AVX512,
+   IAVF_RX_AVX512_OFFLOAD,
+   IAVF_RX_AVX512_FLEX_RXD,
+   IAVF_RX_AVX512_FLEX_RXD_OFFLOAD,
+   IAVF_RX_AVX512_SCATTERED,
+   IAVF_RX_AVX512_SCATTERED_OFFLOAD,
+   IAVF_RX_AVX512_SCATTERED_FLEX_RXD,
+   IAVF_RX_AVX512_SCATTERED_FLEX_RXD_OFFLOAD,
+};
+
+enum iavf_tx_burst_type {
+   IAVF_TX_DEFAULT,
+   IAVF_TX_SSE,
+   IAVF_TX_AVX2,
+   IAVF_TX_AVX2_OFFLOAD,
+   IAVF_TX_AVX512,
+   IAVF_TX_AVX512_OFFLOAD,
+   IAVF_TX_AVX512_CTX,
+   IAVF_TX_AVX512_CTX_OFFLOAD,
+};
+
 /* Structure to store private data for each VF instance. */
 struct iavf_adapter {
struct iavf_hw hw;
@@ -329,8 +368,8 @@ struct iavf_adapter {
bool stopped;
bool closed;
bool no_poll;
-   eth_rx_burst_t rx_pkt_burst;
-   eth_tx_burst_t tx_pkt_burst;
+   enum iavf_rx_burst_type rx_burst_type;
+   enum iavf_tx_burst_type tx_burst_type;
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index e54fb74b79..f044ad3f26 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -3716,15 +3716,78 @@ iavf_prep_pkts(__rte_unused void *tx_queue, struct 
rte_mbuf **tx_pkts,
return i;
 }
 
+static
+const eth_rx_burst_t iavf_rx_pkt_burst_ops[] = {
+   [IAVF_RX_DEFAULT] = iavf_recv_pkts,
+   [IAVF_RX_FLEX_RXD] = iavf_recv_pkts_flex_rxd,
+   [IAVF_RX_BULK_ALLOC] = iavf_recv_pkts_bulk_alloc,
+   [IAVF_RX_SCATTERED] = iavf_recv_scattered_pkts,
+   [IAVF_RX_SCATTERED_FLEX_RXD] = iavf_recv_scattered_pkts_flex_rxd,
+#ifdef RTE_ARCH_X86
+   [IAVF_RX_SSE] = iavf_recv_pkts_vec,
+   [IAVF_RX_AVX2] = iavf_recv_pkts_vec_avx2,
+   [IAVF_RX_AVX2_OFFLOAD] = iavf_recv_pkts_vec_avx2_offload,
+   [IAVF_RX_SSE_FLEX_RXD] = iavf_recv_pkts_vec_flex_rxd,
+   [IAVF_RX_AVX2_FLEX_RXD] = iavf_recv_pkts_vec_avx2_flex_rxd,
+   [IAVF_RX_AVX2_FLEX_RXD_OFFLOAD] =
+   iavf_recv_pkts_vec_avx2_flex_rxd_offload,
+   [IAVF_RX_SSE_SCATTERED] = iavf_recv_scattered_pkts_vec,
+   [IAVF_RX_AVX2_SCATTERED] = iavf_recv_scattered_pkts_vec_avx2,
+   [IAVF_RX_AVX2_SCATTERED_OFFLOAD] =
+   iavf_recv_scattered_pkts_vec_avx2_offload,
+   [IAVF_RX_SSE_SCATTERED_FLEX_RXD] =
+   iavf_recv_scattered_pkts_vec_flex_rxd,
+   [IAVF_RX_AVX2_SCATTERED_FLEX_RXD] =
+   iavf_recv_scattered_pkts_vec_avx2_flex_rxd,
+   [IAVF_RX_AVX2_SCATTERED_FLEX_RXD_OFFLOAD] =
+   iavf_recv_scattered_pkts_vec_avx2_flex_rxd_offload,
+#ifdef CC_AVX512_SUPPORT
+   [IAVF_RX_AVX512] = iavf_recv_pkts_vec_avx512,
+   [IAVF_RX_AVX512_OFFLOAD] = iavf_recv_pkts_vec_avx512_offload,
+   [IAVF_RX_AVX512_FLEX_RXD] = iavf_recv_pkts_vec_avx512_flex_rxd,
+   [IAVF_RX_AVX512_FLEX_RXD_OFFLOAD] =
+   iavf_recv_pkts_vec_avx512_flex_rxd_offload,
+   [IAVF_RX_AVX512_SCATTERED] = iavf_recv_scattered_pkts_vec_avx512,
+   [IAVF_RX_AVX512_SCATTERED_OFFLOAD] =
+   iavf_recv_scattered_pkts_vec_avx512_offload,
+   [IAVF_RX_AVX512_SCATTERED_FLEX_RXD] =
+   iavf_recv_scattered_pkts_vec_avx512_flex_rxd,
+   [IAVF_RX_AVX512_SCATTERED_FLEX_RXD_OFFLOAD] =
+   iavf_recv_scattered_pkts_vec_avx512_flex_rxd_offload,
+#endif
+#elif defined RTE_ARCH_ARM
+   [IAVF_RX_SSE] = iavf_recv_pkts_vec,
+#endif
+};
+
+static
+const eth_tx_burst_t iavf_tx_pkt_burst_ops[] = {
+   [IAVF_TX_DEFAULT] = iavf

[PATCH v9 2/2] net/iavf: add diagnostic support in TX path

2024-01-04 Thread Mingjin Ye
The only way to enable diagnostics for TX paths is to modify the
application source code. Making it difficult to diagnose faults.

In this patch, the devarg option "mbuf_check" is introduced and the
parameters are configured to enable the corresponding diagnostics.

supported cases: mbuf, size, segment, offload.
 1. mbuf: check for corrupted mbuf.
 2. size: check min/max packet length according to hw spec.
 3. segment: check number of mbuf segments not exceed hw limitation.
 4. offload: check any unsupported offload flag.

parameter format: mbuf_check=[mbuf,,]
eg: dpdk-testpmd -a :81:01.0,mbuf_check=[mbuf,size] -- -i

Signed-off-by: Mingjin Ye 
---
v2: Remove call chain.
---
v3: Optimisation implementation.
---
v4: Fix Windows os compilation error.
---
v5: Split Patch.
---
v6: remove strict.
---
v8: Modify the description document.
---
 doc/guides/nics/intel_vf.rst   |  9 
 drivers/net/iavf/iavf.h| 12 +
 drivers/net/iavf/iavf_ethdev.c | 75 ++
 drivers/net/iavf/iavf_rxtx.c   | 98 ++
 drivers/net/iavf/iavf_rxtx.h   |  2 +
 5 files changed, 196 insertions(+)

diff --git a/doc/guides/nics/intel_vf.rst b/doc/guides/nics/intel_vf.rst
index ce96c2e1f8..bf6936082e 100644
--- a/doc/guides/nics/intel_vf.rst
+++ b/doc/guides/nics/intel_vf.rst
@@ -111,6 +111,15 @@ For more detail on SR-IOV, please refer to the following 
documents:
 by setting the ``devargs`` parameter like ``-a 
18:01.0,no-poll-on-link-down=1``
 when IAVF is backed by an Intel\ |reg| E810 device or an Intel\ |reg| 700 
Series Ethernet device.
 
+When IAVF is backed by an Intel\ |reg| E810 device or an Intel\ |reg| 700 
series Ethernet devices.
+Set the ``devargs`` parameter ``mbuf_check`` to enable TX diagnostics. For 
example,
+``-a 18:01.0,mbuf_check=mbuf`` or ``-a 18:01.0,mbuf_check=[mbuf,size]``. 
Supported cases:
+
+*   mbuf: Check for corrupted mbuf.
+*   size: Check min/max packet length according to hw spec.
+*   segment: Check number of mbuf segments not exceed hw limitation.
+*   offload: Check any unsupported offload flag.
+
 The PCIE host-interface of Intel Ethernet Switch FM1 Series VF 
infrastructure
 
^
 
diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index ab24cb02c3..23c0496d54 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -114,9 +114,14 @@ struct iavf_ipsec_crypto_stats {
} ierrors;
 };
 
+struct iavf_mbuf_stats {
+   uint64_t tx_pkt_errors;
+};
+
 struct iavf_eth_xstats {
struct virtchnl_eth_stats eth_stats;
struct iavf_ipsec_crypto_stats ips_stats;
+   struct iavf_mbuf_stats mbuf_stats;
 };
 
 /* Structure that defines a VSI, associated with a adapter. */
@@ -310,6 +315,7 @@ struct iavf_devargs {
uint32_t watchdog_period;
int auto_reset;
int no_poll_on_link_down;
+   int mbuf_check;
 };
 
 struct iavf_security_ctx;
@@ -353,6 +359,11 @@ enum iavf_tx_burst_type {
IAVF_TX_AVX512_CTX_OFFLOAD,
 };
 
+#define IAVF_MBUF_CHECK_F_TX_MBUF(1ULL << 0)
+#define IAVF_MBUF_CHECK_F_TX_SIZE(1ULL << 1)
+#define IAVF_MBUF_CHECK_F_TX_SEGMENT (1ULL << 2)
+#define IAVF_MBUF_CHECK_F_TX_OFFLOAD (1ULL << 3)
+
 /* Structure to store private data for each VF instance. */
 struct iavf_adapter {
struct iavf_hw hw;
@@ -370,6 +381,7 @@ struct iavf_adapter {
bool no_poll;
enum iavf_rx_burst_type rx_burst_type;
enum iavf_tx_burst_type tx_burst_type;
+   uint64_t mc_flags; /* mbuf check flags. */
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 1fb876e827..903a43d004 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -39,6 +40,7 @@
 #define IAVF_RESET_WATCHDOG_ARG"watchdog_period"
 #define IAVF_ENABLE_AUTO_RESET_ARG "auto_reset"
 #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;
 int iavf_timestamp_dynfield_offset = -1;
 int rte_pmd_iavf_tx_lldp_dynfield_offset = -1;
@@ -49,6 +51,7 @@ static const char * const iavf_valid_args[] = {
IAVF_RESET_WATCHDOG_ARG,
IAVF_ENABLE_AUTO_RESET_ARG,
IAVF_NO_POLL_ON_LINK_DOWN_ARG,
+   IAVF_MBUF_CHECK_ARG,
NULL
 };
 
@@ -175,6 +178,7 @@ static const struct rte_iavf_xstats_name_off 
rte_iavf_stats_strings[] = {
{"tx_broadcast_packets", _OFF_OF(eth_stats.tx_broadcast)},
{"tx_dropped_packets", _OFF_OF(eth_stats.tx_discards)},
{"tx_error_packets", _OFF_OF(eth_stats.tx_errors)},
+   {"t

[PATCH v3] net/i40e: add diagnostic support in TX path

2024-01-04 Thread Mingjin Ye
The only way to enable diagnostics for TX paths is to modify the
application source code. Making it difficult to diagnose faults.

In this patch, the devarg option "mbuf_check" is introduced and the
parameters are configured to enable the corresponding diagnostics.

supported cases: mbuf, size, segment, offload.
 1. mbuf: check for corrupted mbuf.
 2. size: check min/max packet length according to hw spec.
 3. segment: check number of mbuf segments not exceed hw limitation.
 4. offload: check any unsupported offload flag.

parameter format: mbuf_check=[mbuf,,]
eg: dpdk-testpmd -a :81:01.0,mbuf_check=[mbuf,size] -- -i

Signed-off-by: Mingjin Ye 
---
v2: remove strict.
---
v3: optimised.
---
 doc/guides/nics/i40e.rst   |  11 +++
 drivers/net/i40e/i40e_ethdev.c | 137 -
 drivers/net/i40e/i40e_ethdev.h |  28 ++
 drivers/net/i40e/i40e_rxtx.c   | 153 +++--
 drivers/net/i40e/i40e_rxtx.h   |   2 +
 5 files changed, 323 insertions(+), 8 deletions(-)

diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index 15689ac958..b15b5b61c5 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -275,6 +275,17 @@ Runtime Configuration
 
   -a 84:00.0,vf_msg_cfg=80@120:180
 
+- ``Support TX diagnostics`` (default ``not enabled``)
+
+  Set the ``devargs`` parameter ``mbuf_check`` to enable TX diagnostics. For 
example,
+  ``-a 18:01.0,mbuf_check=mbuf`` or ``-a 18:01.0,mbuf_check=[mbuf,size]``.
+  Supported cases:
+
+  *   mbuf: Check for corrupted mbuf.
+  *   size: Check min/max packet length according to hw spec.
+  *   segment: Check number of mbuf segments not exceed hw limitation.
+  *   offload: Check any unsupported offload flag.
+
 Vector RX Pre-conditions
 
 For Vector RX it is assumed that the number of descriptor rings will be a power
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 3ca226156b..e554bae1ab 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -48,6 +48,7 @@
 #define ETH_I40E_SUPPORT_MULTI_DRIVER  "support-multi-driver"
 #define ETH_I40E_QUEUE_NUM_PER_VF_ARG  "queue-num-per-vf"
 #define ETH_I40E_VF_MSG_CFG"vf_msg_cfg"
+#define ETH_I40E_MBUF_CHECK_ARG   "mbuf_check"
 
 #define I40E_CLEAR_PXE_WAIT_MS 200
 #define I40E_VSI_TSR_QINQ_STRIP0x4010
@@ -412,6 +413,7 @@ static const char *const valid_keys[] = {
ETH_I40E_SUPPORT_MULTI_DRIVER,
ETH_I40E_QUEUE_NUM_PER_VF_ARG,
ETH_I40E_VF_MSG_CFG,
+   ETH_I40E_MBUF_CHECK_ARG,
NULL};
 
 static const struct rte_pci_id pci_id_i40e_map[] = {
@@ -545,6 +547,14 @@ static const struct rte_i40e_xstats_name_off 
rte_i40e_stats_strings[] = {
 #define I40E_NB_ETH_XSTATS (sizeof(rte_i40e_stats_strings) / \
sizeof(rte_i40e_stats_strings[0]))
 
+static const struct rte_i40e_xstats_name_off i40e_mbuf_strings[] = {
+   {"tx_mbuf_error_packets", offsetof(struct i40e_mbuf_stats,
+   tx_pkt_errors)},
+};
+
+#define I40E_NB_MBUF_XSTATS (sizeof(i40e_mbuf_strings) / \
+   sizeof(i40e_mbuf_strings[0]))
+
 static const struct rte_i40e_xstats_name_off rte_i40e_hw_port_strings[] = {
{"tx_link_down_dropped", offsetof(struct i40e_hw_port_stats,
tx_dropped_link_down)},
@@ -1373,6 +1383,88 @@ read_vf_msg_config(__rte_unused const char *key,
return 0;
 }
 
+static int
+read_mbuf_check_config(__rte_unused const char *key, const char *value, void 
*args)
+{
+   char *cur;
+   char *tmp;
+   int str_len;
+   int valid_len;
+
+   int ret = 0;
+   uint64_t *mc_flags = args;
+   char *str2 = strdup(value);
+   if (str2 == NULL)
+   return -1;
+
+   str_len = strlen(str2);
+   if (str2[0] == '[' && str2[str_len - 1] == ']') {
+   if (str_len < 3) {
+   ret = -1;
+   goto mdd_end;
+   }
+   valid_len = str_len - 2;
+   memmove(str2, str2 + 1, valid_len);
+   memset(str2 + valid_len, '\0', 2);
+   }
+   cur = strtok_r(str2, ",", &tmp);
+   while (cur != NULL) {
+   if (!strcmp(cur, "mbuf"))
+   *mc_flags |= I40E_MBUF_CHECK_F_TX_MBUF;
+   else if (!strcmp(cur, "size"))
+   *mc_flags |= I40E_MBUF_CHECK_F_TX_SIZE;
+   else if (!strcmp(cur, "segment"))
+   *mc_flags |= I40E_MBUF_CHECK_F_TX_SEGMENT;
+   else if (!strcmp(cur, "offload"))
+   *mc_flags |= I40E_MBUF_CHECK_F_TX_OFFLOAD;
+   else
+   PMD_DRV_LOG(ERR, "Unsupported mdd check type: %s", cur);
+   cur = strtok_r(NULL

[PATCH v10] net/iavf: add diagnostic support in TX path

2024-01-05 Thread Mingjin Ye
The only way to enable diagnostics for TX paths is to modify the
application source code. Making it difficult to diagnose faults.

In this patch, the devarg option "mbuf_check" is introduced and the
parameters are configured to enable the corresponding diagnostics.

supported cases: mbuf, size, segment, offload.
 1. mbuf: check for corrupted mbuf.
 2. size: check min/max packet length according to hw spec.
 3. segment: check number of mbuf segments not exceed hw limitation.
 4. offload: check any unsupported offload flag.

parameter format: mbuf_check=[mbuf,,]
eg: dpdk-testpmd -a :81:01.0,mbuf_check=[mbuf,size] -- -i

Signed-off-by: Mingjin Ye 
---
v2: Remove call chain.
---
v3: Optimisation implementation.
---
v4: Fix Windows os compilation error.
---
v5: Split Patch.
---
v6: remove strict.
---
v9: Modify the description document.
---
v10: Modify vf rst document.
---
 doc/guides/nics/intel_vf.rst   | 11 
 drivers/net/iavf/iavf.h| 12 +
 drivers/net/iavf/iavf_ethdev.c | 75 ++
 drivers/net/iavf/iavf_rxtx.c   | 98 ++
 drivers/net/iavf/iavf_rxtx.h   |  2 +
 5 files changed, 198 insertions(+)

diff --git a/doc/guides/nics/intel_vf.rst b/doc/guides/nics/intel_vf.rst
index ce96c2e1f8..f62bb4233c 100644
--- a/doc/guides/nics/intel_vf.rst
+++ b/doc/guides/nics/intel_vf.rst
@@ -111,6 +111,17 @@ For more detail on SR-IOV, please refer to the following 
documents:
 by setting the ``devargs`` parameter like ``-a 
18:01.0,no-poll-on-link-down=1``
 when IAVF is backed by an Intel\ |reg| E810 device or an Intel\ |reg| 700 
Series Ethernet device.
 
+When IAVF is backed by an Intel\ |reg| E810 device or an Intel\ |reg| 700 
series Ethernet devices.
+Set the ``devargs`` parameter ``mbuf_check`` to enable TX diagnostics. For 
example,
+``-a 18:01.0,mbuf_check=`` or ``-a 
18:01.0,mbuf_check=[,...]``. Also,
+``xstats_get`` can be used to get the error counts, which are collected in 
``tx_mbuf_error_packets``
+xstats. For example, ``testpmd> show port xstats all``. Supported cases:
+
+*   mbuf: Check for corrupted mbuf.
+*   size: Check min/max packet length according to hw spec.
+*   segment: Check number of mbuf segments not exceed hw limitation.
+*   offload: Check any unsupported offload flag.
+
 The PCIE host-interface of Intel Ethernet Switch FM1 Series VF 
infrastructure
 
^
 
diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index ab24cb02c3..23c0496d54 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -114,9 +114,14 @@ struct iavf_ipsec_crypto_stats {
} ierrors;
 };
 
+struct iavf_mbuf_stats {
+   uint64_t tx_pkt_errors;
+};
+
 struct iavf_eth_xstats {
struct virtchnl_eth_stats eth_stats;
struct iavf_ipsec_crypto_stats ips_stats;
+   struct iavf_mbuf_stats mbuf_stats;
 };
 
 /* Structure that defines a VSI, associated with a adapter. */
@@ -310,6 +315,7 @@ struct iavf_devargs {
uint32_t watchdog_period;
int auto_reset;
int no_poll_on_link_down;
+   int mbuf_check;
 };
 
 struct iavf_security_ctx;
@@ -353,6 +359,11 @@ enum iavf_tx_burst_type {
IAVF_TX_AVX512_CTX_OFFLOAD,
 };
 
+#define IAVF_MBUF_CHECK_F_TX_MBUF(1ULL << 0)
+#define IAVF_MBUF_CHECK_F_TX_SIZE(1ULL << 1)
+#define IAVF_MBUF_CHECK_F_TX_SEGMENT (1ULL << 2)
+#define IAVF_MBUF_CHECK_F_TX_OFFLOAD (1ULL << 3)
+
 /* Structure to store private data for each VF instance. */
 struct iavf_adapter {
struct iavf_hw hw;
@@ -370,6 +381,7 @@ struct iavf_adapter {
bool no_poll;
enum iavf_rx_burst_type rx_burst_type;
enum iavf_tx_burst_type tx_burst_type;
+   uint64_t mc_flags; /* mbuf check flags. */
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 1fb876e827..903a43d004 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -39,6 +40,7 @@
 #define IAVF_RESET_WATCHDOG_ARG"watchdog_period"
 #define IAVF_ENABLE_AUTO_RESET_ARG "auto_reset"
 #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;
 int iavf_timestamp_dynfield_offset = -1;
 int rte_pmd_iavf_tx_lldp_dynfield_offset = -1;
@@ -49,6 +51,7 @@ static const char * const iavf_valid_args[] = {
IAVF_RESET_WATCHDOG_ARG,
IAVF_ENABLE_AUTO_RESET_ARG,
IAVF_NO_POLL_ON_LINK_DOWN_ARG,
+   IAVF_MBUF_CHECK_ARG,
NULL
 };
 
@@ -175,6 +178,7 @@ static const struct rte_iavf_xstats_name_off 
rte_iavf_stats_strings[] = {
{"tx_broadcast_

[PATCH v4] net/i40e: add diagnostic support in TX path

2024-01-05 Thread Mingjin Ye
The only way to enable diagnostics for TX paths is to modify the
application source code. Making it difficult to diagnose faults.

In this patch, the devarg option "mbuf_check" is introduced and the
parameters are configured to enable the corresponding diagnostics.

supported cases: mbuf, size, segment, offload.
 1. mbuf: check for corrupted mbuf.
 2. size: check min/max packet length according to hw spec.
 3. segment: check number of mbuf segments not exceed hw limitation.
 4. offload: check any unsupported offload flag.

parameter format: mbuf_check=[mbuf,,]
eg: dpdk-testpmd -a :81:01.0,mbuf_check=[mbuf,size] -- -i

Signed-off-by: Mingjin Ye 
---
v2: remove strict.
---
v3: optimised.
---
v4: rebase.
---
 doc/guides/nics/i40e.rst   |  13 +++
 drivers/net/i40e/i40e_ethdev.c | 138 -
 drivers/net/i40e/i40e_ethdev.h |  28 ++
 drivers/net/i40e/i40e_rxtx.c   | 153 +++--
 drivers/net/i40e/i40e_rxtx.h   |   2 +
 5 files changed, 326 insertions(+), 8 deletions(-)

diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index 15689ac958..bf1d1e5d60 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -275,6 +275,19 @@ Runtime Configuration
 
   -a 84:00.0,vf_msg_cfg=80@120:180
 
+- ``Support TX diagnostics`` (default ``not enabled``)
+
+  Set the ``devargs`` parameter ``mbuf_check`` to enable TX diagnostics. For 
example,
+  ``-a 18:01.0,mbuf_check=`` or ``-a 
18:01.0,mbuf_check=[,...]``. Also,
+  ``xstats_get`` can be used to get the error counts, which are collected in
+  ``tx_mbuf_error_packets`` xstats. For example, ``testpmd> show port xstats 
all``.
+  Supported cases:
+
+  *   mbuf: Check for corrupted mbuf.
+  *   size: Check min/max packet length according to hw spec.
+  *   segment: Check number of mbuf segments not exceed hw limitation.
+  *   offload: Check any unsupported offload flag.
+
 Vector RX Pre-conditions
 
 For Vector RX it is assumed that the number of descriptor rings will be a power
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 3ca226156b..f23f80fd16 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -48,6 +48,7 @@
 #define ETH_I40E_SUPPORT_MULTI_DRIVER  "support-multi-driver"
 #define ETH_I40E_QUEUE_NUM_PER_VF_ARG  "queue-num-per-vf"
 #define ETH_I40E_VF_MSG_CFG"vf_msg_cfg"
+#define ETH_I40E_MBUF_CHECK_ARG   "mbuf_check"
 
 #define I40E_CLEAR_PXE_WAIT_MS 200
 #define I40E_VSI_TSR_QINQ_STRIP0x4010
@@ -412,6 +413,7 @@ static const char *const valid_keys[] = {
ETH_I40E_SUPPORT_MULTI_DRIVER,
ETH_I40E_QUEUE_NUM_PER_VF_ARG,
ETH_I40E_VF_MSG_CFG,
+   ETH_I40E_MBUF_CHECK_ARG,
NULL};
 
 static const struct rte_pci_id pci_id_i40e_map[] = {
@@ -545,6 +547,14 @@ static const struct rte_i40e_xstats_name_off 
rte_i40e_stats_strings[] = {
 #define I40E_NB_ETH_XSTATS (sizeof(rte_i40e_stats_strings) / \
sizeof(rte_i40e_stats_strings[0]))
 
+static const struct rte_i40e_xstats_name_off i40e_mbuf_strings[] = {
+   {"tx_mbuf_error_packets", offsetof(struct i40e_mbuf_stats,
+   tx_pkt_errors)},
+};
+
+#define I40E_NB_MBUF_XSTATS (sizeof(i40e_mbuf_strings) / \
+   sizeof(i40e_mbuf_strings[0]))
+
 static const struct rte_i40e_xstats_name_off rte_i40e_hw_port_strings[] = {
{"tx_link_down_dropped", offsetof(struct i40e_hw_port_stats,
tx_dropped_link_down)},
@@ -1373,6 +1383,88 @@ read_vf_msg_config(__rte_unused const char *key,
return 0;
 }
 
+static int
+read_mbuf_check_config(__rte_unused const char *key, const char *value, void 
*args)
+{
+   char *cur;
+   char *tmp;
+   int str_len;
+   int valid_len;
+
+   int ret = 0;
+   uint64_t *mc_flags = args;
+   char *str2 = strdup(value);
+   if (str2 == NULL)
+   return -1;
+
+   str_len = strlen(str2);
+   if (str2[0] == '[' && str2[str_len - 1] == ']') {
+   if (str_len < 3) {
+   ret = -1;
+   goto mdd_end;
+   }
+   valid_len = str_len - 2;
+   memmove(str2, str2 + 1, valid_len);
+   memset(str2 + valid_len, '\0', 2);
+   }
+   cur = strtok_r(str2, ",", &tmp);
+   while (cur != NULL) {
+   if (!strcmp(cur, "mbuf"))
+   *mc_flags |= I40E_MBUF_CHECK_F_TX_MBUF;
+   else if (!strcmp(cur, "size"))
+   *mc_flags |= I40E_MBUF_CHECK_F_TX_SIZE;
+   else if (!strcmp(cur, "segment"))
+   *mc_flags |= I40E_MBUF_CHECK_F_TX_SEGMENT;
+   else if (!strcmp(cur, "offload"))
+   *mc_flags |=

[PATCH v2] net/ice: add diagnostic support in TX path

2024-01-05 Thread Mingjin Ye
The only way to enable diagnostics for TX paths is to modify the
application source code. Making it difficult to diagnose faults.

In this patch, the devarg option "mbuf_check" is introduced and the
parameters are configured to enable the corresponding diagnostics.

supported cases: mbuf, size, segment, offload.
 1. mbuf: check for corrupted mbuf.
 2. size: check min/max packet length according to hw spec.
 3. segment: check number of mbuf segments not exceed hw limitation.
 4. offload: check any unsupported offload flag.

parameter format: mbuf_check=[mbuf,,]
eg: dpdk-testpmd -a :81:01.0,mbuf_check=[mbuf,size] -- -i

Signed-off-by: Mingjin Ye 
---
v2: rebase.
---
 doc/guides/nics/ice.rst  |  13 +++
 drivers/net/ice/ice_ethdev.c | 104 ++-
 drivers/net/ice/ice_ethdev.h |  24 ++
 drivers/net/ice/ice_rxtx.c   | 158 ---
 drivers/net/ice/ice_rxtx.h   |  20 +
 5 files changed, 308 insertions(+), 11 deletions(-)

diff --git a/doc/guides/nics/ice.rst b/doc/guides/nics/ice.rst
index bafb3ba022..d1aee811b3 100644
--- a/doc/guides/nics/ice.rst
+++ b/doc/guides/nics/ice.rst
@@ -257,6 +257,19 @@ Runtime Configuration
   As a trade-off, this configuration may cause the packet processing 
performance
   degradation due to the PCI bandwidth limitation.
 
+- ``Tx diagnostics`` (default ``not enabled``)
+
+  Set the ``devargs`` parameter ``mbuf_check`` to enable TX diagnostics. For 
example,
+  ``-a 18:01.0,mbuf_check=`` or ``-a 
18:01.0,mbuf_check=[,...]``.
+  Also, ``xstats_get`` can be used to get the error counts, which are 
collected in
+  ``tx_mbuf_error_packets`` xstats. For example, ``testpmd> show port xstats 
all``.
+  Supported cases:
+
+  *   mbuf: Check for corrupted mbuf.
+  *   size: Check min/max packet length according to hw spec.
+  *   segment: Check number of mbuf segments not exceed hw limitation.
+  *   offload: Check any unsupported offload flag.
+
 Driver compilation and testing
 --
 
diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 72e13f95f8..254993b813 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -12,6 +12,7 @@
 #include 
 
 #include 
+#include 
 
 #include "eal_firmware.h"
 
@@ -34,6 +35,7 @@
 #define ICE_HW_DEBUG_MASK_ARG "hw_debug_mask"
 #define ICE_ONE_PPS_OUT_ARG   "pps_out"
 #define ICE_RX_LOW_LATENCY_ARG"rx_low_latency"
+#define ICE_MBUF_CHECK_ARG   "mbuf_check"
 
 #define ICE_CYCLECOUNTER_MASK  0xULL
 
@@ -49,6 +51,7 @@ static const char * const ice_valid_args[] = {
ICE_ONE_PPS_OUT_ARG,
ICE_RX_LOW_LATENCY_ARG,
ICE_DEFAULT_MAC_DISABLE,
+   ICE_MBUF_CHECK_ARG,
NULL
 };
 
@@ -319,6 +322,14 @@ static const struct ice_xstats_name_off 
ice_stats_strings[] = {
 #define ICE_NB_ETH_XSTATS (sizeof(ice_stats_strings) / \
sizeof(ice_stats_strings[0]))
 
+static const struct ice_xstats_name_off ice_mbuf_strings[] = {
+   {"tx_mbuf_error_packets", offsetof(struct ice_mbuf_stats,
+   tx_pkt_errors)},
+};
+
+#define ICE_NB_MBUF_XSTATS (sizeof(ice_mbuf_strings) / \
+   sizeof(ice_mbuf_strings[0]))
+
 static const struct ice_xstats_name_off ice_hw_port_strings[] = {
{"tx_link_down_dropped", offsetof(struct ice_hw_port_stats,
tx_dropped_link_down)},
@@ -2061,6 +2072,50 @@ handle_pps_out_arg(__rte_unused const char *key, const 
char *value,
return 0;
 }
 
+static int
+ice_parse_mbuf_check(__rte_unused const char *key, const char *value, void 
*args)
+{
+   char *cur;
+   char *tmp;
+   int str_len;
+   int valid_len;
+
+   int ret = 0;
+   uint64_t *mc_flags = args;
+   char *str2 = strdup(value);
+   if (str2 == NULL)
+   return -1;
+
+   str_len = strlen(str2);
+   if (str2[0] == '[' && str2[str_len - 1] == ']') {
+   if (str_len < 3) {
+   ret = -1;
+   goto mdd_end;
+   }
+   valid_len = str_len - 2;
+   memmove(str2, str2 + 1, valid_len);
+   memset(str2 + valid_len, '\0', 2);
+   }
+   cur = strtok_r(str2, ",", &tmp);
+   while (cur != NULL) {
+   if (!strcmp(cur, "mbuf"))
+   *mc_flags |= ICE_MBUF_CHECK_F_TX_MBUF;
+   else if (!strcmp(cur, "size"))
+   *mc_flags |= ICE_MBUF_CHECK_F_TX_SIZE;
+   else if (!strcmp(cur, "segment"))
+   *mc_flags |= ICE_MBUF_CHECK_F_TX_SEGMENT;
+   else if (!strcmp(cur, "offload"))
+   *mc_flags |= ICE_MBUF_CHECK_F_TX_OFFLOAD;
+   else
+   PMD_DRV_LOG(ERR, "Unsuppor

[PATCH v11] net/iavf: add diagnostic support in TX path

2024-01-09 Thread Mingjin Ye
Implemented a Tx wrapper to perform a thorough check on mbufs,
categorizing and counting invalid cases by types for diagnostic
purposes. The count of invalid cases is accessible through xstats_get.

Also, the devarg option "mbuf_check" was introduced to configure the
diagnostic parameters to enable the appropriate diagnostic features.

supported cases: mbuf, size, segment, offload.
 1. mbuf: check for corrupted mbuf.
 2. size: check min/max packet length according to hw spec.
 3. segment: check number of mbuf segments not exceed hw limitation.
 4. offload: check any unsupported offload flag.

parameter format: "mbuf_check=" or "mbuf_check=[,]"
eg: dpdk-testpmd -a :81:01.0,mbuf_check=[mbuf,size] -- -i

Signed-off-by: Mingjin Ye 
---
v2: Remove call chain.
---
v3: Optimisation implementation.
---
v4: Fix Windows os compilation error.
---
v5: Split Patch.
---
v6: remove strict.
---
v9: Modify the description document.
---
v10: Modify vf rst document.
---
v11: modify comment log.
---
 doc/guides/nics/intel_vf.rst   | 11 
 drivers/net/iavf/iavf.h| 11 
 drivers/net/iavf/iavf_ethdev.c | 72 +
 drivers/net/iavf/iavf_rxtx.c   | 98 ++
 drivers/net/iavf/iavf_rxtx.h   |  2 +
 5 files changed, 194 insertions(+)

diff --git a/doc/guides/nics/intel_vf.rst b/doc/guides/nics/intel_vf.rst
index ce96c2e1f8..f62bb4233c 100644
--- a/doc/guides/nics/intel_vf.rst
+++ b/doc/guides/nics/intel_vf.rst
@@ -111,6 +111,17 @@ For more detail on SR-IOV, please refer to the following 
documents:
 by setting the ``devargs`` parameter like ``-a 
18:01.0,no-poll-on-link-down=1``
 when IAVF is backed by an Intel\ |reg| E810 device or an Intel\ |reg| 700 
Series Ethernet device.
 
+When IAVF is backed by an Intel\ |reg| E810 device or an Intel\ |reg| 700 
series Ethernet devices.
+Set the ``devargs`` parameter ``mbuf_check`` to enable TX diagnostics. For 
example,
+``-a 18:01.0,mbuf_check=`` or ``-a 
18:01.0,mbuf_check=[,...]``. Also,
+``xstats_get`` can be used to get the error counts, which are collected in 
``tx_mbuf_error_packets``
+xstats. For example, ``testpmd> show port xstats all``. Supported cases:
+
+*   mbuf: Check for corrupted mbuf.
+*   size: Check min/max packet length according to hw spec.
+*   segment: Check number of mbuf segments not exceed hw limitation.
+*   offload: Check any unsupported offload flag.
+
 The PCIE host-interface of Intel Ethernet Switch FM1 Series VF 
infrastructure
 
^
 
diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index ab24cb02c3..824ae4aa02 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -114,9 +114,14 @@ struct iavf_ipsec_crypto_stats {
} ierrors;
 };
 
+struct iavf_mbuf_stats {
+   uint64_t tx_pkt_errors;
+};
+
 struct iavf_eth_xstats {
struct virtchnl_eth_stats eth_stats;
struct iavf_ipsec_crypto_stats ips_stats;
+   struct iavf_mbuf_stats mbuf_stats;
 };
 
 /* Structure that defines a VSI, associated with a adapter. */
@@ -310,6 +315,7 @@ struct iavf_devargs {
uint32_t watchdog_period;
int auto_reset;
int no_poll_on_link_down;
+   uint64_t mbuf_check;
 };
 
 struct iavf_security_ctx;
@@ -353,6 +359,11 @@ enum iavf_tx_burst_type {
IAVF_TX_AVX512_CTX_OFFLOAD,
 };
 
+#define IAVF_MBUF_CHECK_F_TX_MBUF(1ULL << 0)
+#define IAVF_MBUF_CHECK_F_TX_SIZE(1ULL << 1)
+#define IAVF_MBUF_CHECK_F_TX_SEGMENT (1ULL << 2)
+#define IAVF_MBUF_CHECK_F_TX_OFFLOAD (1ULL << 3)
+
 /* Structure to store private data for each VF instance. */
 struct iavf_adapter {
struct iavf_hw hw;
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 1fb876e827..fca57b50b3 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -39,6 +40,7 @@
 #define IAVF_RESET_WATCHDOG_ARG"watchdog_period"
 #define IAVF_ENABLE_AUTO_RESET_ARG "auto_reset"
 #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;
 int iavf_timestamp_dynfield_offset = -1;
 int rte_pmd_iavf_tx_lldp_dynfield_offset = -1;
@@ -49,6 +51,7 @@ static const char * const iavf_valid_args[] = {
IAVF_RESET_WATCHDOG_ARG,
IAVF_ENABLE_AUTO_RESET_ARG,
IAVF_NO_POLL_ON_LINK_DOWN_ARG,
+   IAVF_MBUF_CHECK_ARG,
NULL
 };
 
@@ -175,6 +178,7 @@ static const struct rte_iavf_xstats_name_off 
rte_iavf_stats_strings[] = {
{"tx_broadcast_packets", _OFF_OF(eth_stats.tx_broadcast)},
{"tx_dropped_packets", _OFF_OF(eth_stats.tx_discards)},
{

[PATCH v11] net/iavf: add diagnostic support in TX path

2024-01-09 Thread Mingjin Ye
Implemented a Tx wrapper to perform a thorough check on mbufs,
categorizing and counting invalid cases by types for diagnostic
purposes. The count of invalid cases is accessible through xstats_get.

Also, the devarg option "mbuf_check" was introduced to configure the
diagnostic parameters to enable the appropriate diagnostic features.

supported cases: mbuf, size, segment, offload.
 1. mbuf: check for corrupted mbuf.
 2. size: check min/max packet length according to hw spec.
 3. segment: check number of mbuf segments not exceed hw limitation.
 4. offload: check any unsupported offload flag.

parameter format: "mbuf_check=" or "mbuf_check=[,]"
eg: dpdk-testpmd -a :81:01.0,mbuf_check=[mbuf,size] -- -i

Signed-off-by: Mingjin Ye 
---
v2: Remove call chain.
---
v3: Optimisation implementation.
---
v4: Fix Windows os compilation error.
---
v5: Split Patch.
---
v6: remove strict.
---
v9: Modify the description document.
---
v10: Modify vf rst document.
---
v11: modify comment log.
---
 doc/guides/nics/intel_vf.rst   | 11 
 drivers/net/iavf/iavf.h| 11 
 drivers/net/iavf/iavf_ethdev.c | 72 +
 drivers/net/iavf/iavf_rxtx.c   | 98 ++
 drivers/net/iavf/iavf_rxtx.h   |  2 +
 5 files changed, 194 insertions(+)

diff --git a/doc/guides/nics/intel_vf.rst b/doc/guides/nics/intel_vf.rst
index ce96c2e1f8..f62bb4233c 100644
--- a/doc/guides/nics/intel_vf.rst
+++ b/doc/guides/nics/intel_vf.rst
@@ -111,6 +111,17 @@ For more detail on SR-IOV, please refer to the following 
documents:
 by setting the ``devargs`` parameter like ``-a 
18:01.0,no-poll-on-link-down=1``
 when IAVF is backed by an Intel\ |reg| E810 device or an Intel\ |reg| 700 
Series Ethernet device.
 
+When IAVF is backed by an Intel\ |reg| E810 device or an Intel\ |reg| 700 
series Ethernet devices.
+Set the ``devargs`` parameter ``mbuf_check`` to enable TX diagnostics. For 
example,
+``-a 18:01.0,mbuf_check=`` or ``-a 
18:01.0,mbuf_check=[,...]``. Also,
+``xstats_get`` can be used to get the error counts, which are collected in 
``tx_mbuf_error_packets``
+xstats. For example, ``testpmd> show port xstats all``. Supported cases:
+
+*   mbuf: Check for corrupted mbuf.
+*   size: Check min/max packet length according to hw spec.
+*   segment: Check number of mbuf segments not exceed hw limitation.
+*   offload: Check any unsupported offload flag.
+
 The PCIE host-interface of Intel Ethernet Switch FM1 Series VF 
infrastructure
 
^
 
diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index ab24cb02c3..824ae4aa02 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -114,9 +114,14 @@ struct iavf_ipsec_crypto_stats {
} ierrors;
 };
 
+struct iavf_mbuf_stats {
+   uint64_t tx_pkt_errors;
+};
+
 struct iavf_eth_xstats {
struct virtchnl_eth_stats eth_stats;
struct iavf_ipsec_crypto_stats ips_stats;
+   struct iavf_mbuf_stats mbuf_stats;
 };
 
 /* Structure that defines a VSI, associated with a adapter. */
@@ -310,6 +315,7 @@ struct iavf_devargs {
uint32_t watchdog_period;
int auto_reset;
int no_poll_on_link_down;
+   uint64_t mbuf_check;
 };
 
 struct iavf_security_ctx;
@@ -353,6 +359,11 @@ enum iavf_tx_burst_type {
IAVF_TX_AVX512_CTX_OFFLOAD,
 };
 
+#define IAVF_MBUF_CHECK_F_TX_MBUF(1ULL << 0)
+#define IAVF_MBUF_CHECK_F_TX_SIZE(1ULL << 1)
+#define IAVF_MBUF_CHECK_F_TX_SEGMENT (1ULL << 2)
+#define IAVF_MBUF_CHECK_F_TX_OFFLOAD (1ULL << 3)
+
 /* Structure to store private data for each VF instance. */
 struct iavf_adapter {
struct iavf_hw hw;
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 1fb876e827..fca57b50b3 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -39,6 +40,7 @@
 #define IAVF_RESET_WATCHDOG_ARG"watchdog_period"
 #define IAVF_ENABLE_AUTO_RESET_ARG "auto_reset"
 #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;
 int iavf_timestamp_dynfield_offset = -1;
 int rte_pmd_iavf_tx_lldp_dynfield_offset = -1;
@@ -49,6 +51,7 @@ static const char * const iavf_valid_args[] = {
IAVF_RESET_WATCHDOG_ARG,
IAVF_ENABLE_AUTO_RESET_ARG,
IAVF_NO_POLL_ON_LINK_DOWN_ARG,
+   IAVF_MBUF_CHECK_ARG,
NULL
 };
 
@@ -175,6 +178,7 @@ static const struct rte_iavf_xstats_name_off 
rte_iavf_stats_strings[] = {
{"tx_broadcast_packets", _OFF_OF(eth_stats.tx_broadcast)},
{"tx_dropped_packets", _OFF_OF(eth_stats.tx_discards)},
{

[PATCH] net/iavf: fix access to null value

2024-01-23 Thread Mingjin Ye
The "vsi" may be null, so it needs to be used after checking.

Fixes: ab28aad9c24f ("net/iavf: fix Rx Tx burst in multi-process")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 drivers/net/iavf/iavf_rxtx.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index 5ba4527ae3..8992e728cd 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -3781,12 +3781,13 @@ iavf_recv_pkts_no_poll(void *rx_queue, struct rte_mbuf 
**rx_pkts,
uint16_t nb_pkts)
 {
struct iavf_rx_queue *rxq = rx_queue;
-   enum iavf_rx_burst_type rx_burst_type =
-   rxq->vsi->adapter->rx_burst_type;
+   enum iavf_rx_burst_type rx_burst_type;
 
if (!rxq->vsi || rxq->vsi->adapter->no_poll)
return 0;
 
+   rx_burst_type = rxq->vsi->adapter->rx_burst_type;
+
return iavf_rx_pkt_burst_ops[rx_burst_type](rx_queue,
rx_pkts, 
nb_pkts);
 }
@@ -3796,12 +3797,13 @@ iavf_xmit_pkts_no_poll(void *tx_queue, struct rte_mbuf 
**tx_pkts,
uint16_t nb_pkts)
 {
struct iavf_tx_queue *txq = tx_queue;
-   enum iavf_tx_burst_type tx_burst_type =
-   txq->vsi->adapter->tx_burst_type;
+   enum iavf_tx_burst_type tx_burst_type;
 
if (!txq->vsi || txq->vsi->adapter->no_poll)
return 0;
 
+   tx_burst_type = txq->vsi->adapter->tx_burst_type;
+
return iavf_tx_pkt_burst_ops[tx_burst_type](tx_queue,
tx_pkts, 
nb_pkts);
 }
-- 
2.25.1



[PATCH] buildtools: fix invalid symbols

2024-06-27 Thread Mingjin Ye
ELF files generated by higher version compilers wrap multiple
symbols prefixed with "this_pmd_name".

This patch fixes the issue by filtering invalid symbols.

Bugzilla ID: 1466
Fixes: 6c4bf8f42432 ("buildtools: add Python pmdinfogen")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 buildtools/pmdinfogen.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/buildtools/pmdinfogen.py b/buildtools/pmdinfogen.py
index 2a44f17bda..6ea97caec7 100755
--- a/buildtools/pmdinfogen.py
+++ b/buildtools/pmdinfogen.py
@@ -200,7 +200,8 @@ def dump(self, file):
 def load_drivers(image):
 drivers = []
 for symbol in image.find_by_prefix("this_pmd_name"):
-drivers.append(Driver.load(image, symbol))
+if len(symbol.string_value) != 0:
+drivers.append(Driver.load(image, symbol))
 return drivers
 
 
-- 
2.25.1



[PATCH v2] buildtools: fix invalid symbols

2024-07-01 Thread Mingjin Ye
Elf files generated by higher version compilers wrap multiple
symbols prefixed with "this_pmd_name".

The patch uses the regex "^this_pmd_name[0-9]+$" to match the
symbol name.

Bugzilla ID: 1466
Fixes: 6c4bf8f42432 ("buildtools: add Python pmdinfogen")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
v2: Use regex ^this_pmd_name[0-9]+$ to filter symbols *names*
---
 buildtools/pmdinfogen.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/buildtools/pmdinfogen.py b/buildtools/pmdinfogen.py
index 2a44f17bda..0fbcc697ed 100755
--- a/buildtools/pmdinfogen.py
+++ b/buildtools/pmdinfogen.py
@@ -6,6 +6,7 @@
 import argparse
 import ctypes
 import json
+import re
 import sys
 import tempfile
 
@@ -70,7 +71,7 @@ def find_by_prefix(self, prefix):
 prefix = prefix.encode("utf-8") if self._legacy_elftools else prefix
 for i in range(self._symtab.num_symbols()):
 symbol = self._symtab.get_symbol(i)
-if symbol.name.startswith(prefix):
+if re.match(prefix, symbol.name):
 yield ELFSymbol(self._image, symbol)
 
 
@@ -199,7 +200,7 @@ def dump(self, file):
 
 def load_drivers(image):
 drivers = []
-for symbol in image.find_by_prefix("this_pmd_name"):
+for symbol in image.find_by_prefix("^this_pmd_name[0-9]+$"):
 drivers.append(Driver.load(image, symbol))
 return drivers
 
-- 
2.25.1



[PATCH v2] net/ice: support FEC feature

2024-07-02 Thread Mingjin Ye
This patch enable three Forward Error Correction(FEC) related ops
in ice driver. As no speed information can get from HW, this patch
only show FEC capability.

Signed-off-by: Qiming Yang 
Signed-off-by: Mingjin Ye 
---
v2: fix some logic
---
 doc/guides/nics/features/ice.ini |   1 +
 doc/guides/nics/ice.rst  |   5 +
 drivers/net/ice/ice_ethdev.c | 292 +++
 3 files changed, 298 insertions(+)

diff --git a/doc/guides/nics/features/ice.ini b/doc/guides/nics/features/ice.ini
index 62869ef0a0..9c8569740a 100644
--- a/doc/guides/nics/features/ice.ini
+++ b/doc/guides/nics/features/ice.ini
@@ -11,6 +11,7 @@ Speed capabilities   = Y
 Link speed configuration = Y
 Link status  = Y
 Link status event= Y
+FEC  = Y
 Rx interrupt = Y
 Fast mbuf free   = P
 Queue start/stop = Y
diff --git a/doc/guides/nics/ice.rst b/doc/guides/nics/ice.rst
index 3deeea9e6c..3d7e4ed7f1 100644
--- a/doc/guides/nics/ice.rst
+++ b/doc/guides/nics/ice.rst
@@ -323,6 +323,11 @@ The DCF PMD needs to advertise and acquire DCF capability 
which allows DCF to
 send AdminQ commands that it would like to execute over to the PF and receive
 responses for the same from PF.
 
+Forward Error Correction (FEC)
+
+
+Supports get/set FEC mode and get FEC capability.
+
 Generic Flow Support
 
 
diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 194109b0f6..3caacfa48a 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -181,6 +181,10 @@ static int ice_timesync_read_time(struct rte_eth_dev *dev,
 static int ice_timesync_write_time(struct rte_eth_dev *dev,
   const struct timespec *timestamp);
 static int ice_timesync_disable(struct rte_eth_dev *dev);
+static int ice_fec_get_capability(struct rte_eth_dev *dev, struct 
rte_eth_fec_capa *speed_fec_capa,
+  unsigned int num);
+static int ice_fec_get(struct rte_eth_dev *dev, uint32_t *fec_capa);
+static int ice_fec_set(struct rte_eth_dev *dev, uint32_t fec_capa);
 static const uint32_t *ice_buffer_split_supported_hdr_ptypes_get(struct 
rte_eth_dev *dev,
size_t *no_of_elements);
 
@@ -298,6 +302,9 @@ static const struct eth_dev_ops ice_eth_dev_ops = {
.timesync_write_time  = ice_timesync_write_time,
.timesync_disable = ice_timesync_disable,
.tm_ops_get   = ice_tm_ops_get,
+   .fec_get_capability   = ice_fec_get_capability,
+   .fec_get  = ice_fec_get,
+   .fec_set  = ice_fec_set,
.buffer_split_supported_hdr_ptypes_get = 
ice_buffer_split_supported_hdr_ptypes_get,
 };
 
@@ -6677,6 +6684,291 @@ ice_buffer_split_supported_hdr_ptypes_get(struct 
rte_eth_dev *dev __rte_unused,
return ptypes;
 }
 
+static unsigned int
+ice_fec_get_capa_num(struct ice_aqc_get_phy_caps_data *pcaps,
+  struct rte_eth_fec_capa *speed_fec_capa)
+{
+   unsigned int num = 0;
+   int auto_fec = (pcaps->caps & ICE_AQC_PHY_EN_AUTO_FEC) ?
+   RTE_ETH_FEC_MODE_CAPA_MASK(AUTO) : 0;
+   int link_nofec = (pcaps->link_fec_options & ICE_AQC_PHY_FEC_DIS) ?
+   RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC) : 0;
+
+   if (pcaps->eee_cap & ICE_AQC_PHY_EEE_EN_100BASE_TX) {
+   if (speed_fec_capa) {
+   speed_fec_capa[num].speed = RTE_ETH_SPEED_NUM_100M;
+   speed_fec_capa[num].capa = 
RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC);
+   }
+   num++;
+   }
+
+   if (pcaps->eee_cap & (ICE_AQC_PHY_EEE_EN_1000BASE_T |
+   ICE_AQC_PHY_EEE_EN_1000BASE_KX)) {
+   if (speed_fec_capa) {
+   speed_fec_capa[num].speed = RTE_ETH_SPEED_NUM_1G;
+   speed_fec_capa[num].capa = 
RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC);
+   }
+   num++;
+   }
+
+   if (pcaps->eee_cap & (ICE_AQC_PHY_EEE_EN_10GBASE_T |
+   ICE_AQC_PHY_EEE_EN_10GBASE_KR)) {
+   if (speed_fec_capa) {
+   speed_fec_capa[num].speed = RTE_ETH_SPEED_NUM_10G;
+   speed_fec_capa[num].capa = auto_fec | link_nofec;
+
+   if (pcaps->link_fec_options & 
ICE_AQC_PHY_FEC_10G_KR_40G_KR4_EN)
+   speed_fec_capa[num].capa |= 
RTE_ETH_FEC_MODE_CAPA_MASK(BASER);
+   }
+   num++;
+   }
+
+   if (pcaps->eee_cap & ICE_AQC_PHY_EEE_EN_25GBASE_KR) {
+   if (speed_fec_capa) {
+   speed_fec_capa[num].speed = RTE_ETH_SPEED_NUM_25G;
+   speed_fec_capa[num].capa = auto_fec | link_nofec;
+
+   if (pcaps->li

[PATCH v3] net/ice: support FEC feature

2024-07-04 Thread Mingjin Ye
This patch enable three Forward Error Correction(FEC) related ops
in ice driver. As no speed information can get from HW, this patch
only show FEC capability.

Signed-off-by: Qiming Yang 
Signed-off-by: Mingjin Ye 

---
v3: optimize code details
---
v2: fix some logic
---
 doc/guides/nics/features/ice.ini   |   1 +
 doc/guides/nics/ice.rst|   5 +
 doc/guides/rel_notes/release_24_07.rst |   5 +
 drivers/net/ice/ice_ethdev.c   | 289 +
 4 files changed, 300 insertions(+)

diff --git a/doc/guides/nics/features/ice.ini b/doc/guides/nics/features/ice.ini
index 62869ef0a0..9c8569740a 100644
--- a/doc/guides/nics/features/ice.ini
+++ b/doc/guides/nics/features/ice.ini
@@ -11,6 +11,7 @@ Speed capabilities   = Y
 Link speed configuration = Y
 Link status  = Y
 Link status event= Y
+FEC  = Y
 Rx interrupt = Y
 Fast mbuf free   = P
 Queue start/stop = Y
diff --git a/doc/guides/nics/ice.rst b/doc/guides/nics/ice.rst
index 3deeea9e6c..3d7e4ed7f1 100644
--- a/doc/guides/nics/ice.rst
+++ b/doc/guides/nics/ice.rst
@@ -323,6 +323,11 @@ The DCF PMD needs to advertise and acquire DCF capability 
which allows DCF to
 send AdminQ commands that it would like to execute over to the PF and receive
 responses for the same from PF.
 
+Forward Error Correction (FEC)
+
+
+Supports get/set FEC mode and get FEC capability.
+
 Generic Flow Support
 
 
diff --git a/doc/guides/rel_notes/release_24_07.rst 
b/doc/guides/rel_notes/release_24_07.rst
index 56c03ed6c9..4867c5fc4a 100644
--- a/doc/guides/rel_notes/release_24_07.rst
+++ b/doc/guides/rel_notes/release_24_07.rst
@@ -87,6 +87,11 @@ New Features
 
   * Updated base code with E610 device family support.
 
+* **Updated Intel ice driver.**
+
+  * Added support for configuring the Forward Error Correction(FEC) mode, 
querying
+  * FEC capabilities and current FEC mode from a device.
+
 * **Updated Marvell cnxk net driver.**
 
   * Added support disabling custom meta aura
diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 194109b0f6..219fbfae30 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -181,6 +181,10 @@ static int ice_timesync_read_time(struct rte_eth_dev *dev,
 static int ice_timesync_write_time(struct rte_eth_dev *dev,
   const struct timespec *timestamp);
 static int ice_timesync_disable(struct rte_eth_dev *dev);
+static int ice_fec_get_capability(struct rte_eth_dev *dev, struct 
rte_eth_fec_capa *speed_fec_capa,
+  unsigned int num);
+static int ice_fec_get(struct rte_eth_dev *dev, uint32_t *fec_capa);
+static int ice_fec_set(struct rte_eth_dev *dev, uint32_t fec_capa);
 static const uint32_t *ice_buffer_split_supported_hdr_ptypes_get(struct 
rte_eth_dev *dev,
size_t *no_of_elements);
 
@@ -298,6 +302,9 @@ static const struct eth_dev_ops ice_eth_dev_ops = {
.timesync_write_time  = ice_timesync_write_time,
.timesync_disable = ice_timesync_disable,
.tm_ops_get   = ice_tm_ops_get,
+   .fec_get_capability   = ice_fec_get_capability,
+   .fec_get  = ice_fec_get,
+   .fec_set  = ice_fec_set,
.buffer_split_supported_hdr_ptypes_get = 
ice_buffer_split_supported_hdr_ptypes_get,
 };
 
@@ -6677,6 +6684,288 @@ ice_buffer_split_supported_hdr_ptypes_get(struct 
rte_eth_dev *dev __rte_unused,
return ptypes;
 }
 
+static unsigned int
+ice_fec_get_capa_num(struct ice_aqc_get_phy_caps_data *pcaps,
+  struct rte_eth_fec_capa *speed_fec_capa)
+{
+   unsigned int num = 0;
+   int auto_fec = (pcaps->caps & ICE_AQC_PHY_EN_AUTO_FEC) ?
+   RTE_ETH_FEC_MODE_CAPA_MASK(AUTO) : 0;
+   int link_nofec = (pcaps->link_fec_options & ICE_AQC_PHY_FEC_DIS) ?
+   RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC) : 0;
+
+   if (pcaps->eee_cap & ICE_AQC_PHY_EEE_EN_100BASE_TX) {
+   if (speed_fec_capa) {
+   speed_fec_capa[num].speed = RTE_ETH_SPEED_NUM_100M;
+   speed_fec_capa[num].capa = 
RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC);
+   }
+   num++;
+   }
+
+   if (pcaps->eee_cap & (ICE_AQC_PHY_EEE_EN_1000BASE_T |
+   ICE_AQC_PHY_EEE_EN_1000BASE_KX)) {
+   if (speed_fec_capa) {
+   speed_fec_capa[num].speed = RTE_ETH_SPEED_NUM_1G;
+   speed_fec_capa[num].capa = 
RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC);
+   }
+   num++;
+   }
+
+   if (pcaps->eee_cap & (ICE_AQC_PHY_EEE_EN_10GBASE_T |
+   ICE_AQC_PHY_EEE_EN_10GBASE_KR)) {
+   if (speed_fec_capa) {
+   speed_fec_capa

[PATCH v3] buildtools: fix invalid symbols

2024-07-05 Thread Mingjin Ye
In scenarios where a higher clang compiler is used and ASAN is enabled,
the generated ELF file will additionally insert undefined debug symbols
with the same prefix. This causes duplicate C code to be generated.

This patch fixes this issue by skipping the unspecified symbol type.

Fixes: 6c4bf8f42432 ("buildtools: add Python pmdinfogen")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 buildtools/pmdinfogen.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/buildtools/pmdinfogen.py b/buildtools/pmdinfogen.py
index 2a44f17bda..9896f107dc 100755
--- a/buildtools/pmdinfogen.py
+++ b/buildtools/pmdinfogen.py
@@ -70,6 +70,9 @@ def find_by_prefix(self, prefix):
 prefix = prefix.encode("utf-8") if self._legacy_elftools else prefix
 for i in range(self._symtab.num_symbols()):
 symbol = self._symtab.get_symbol(i)
+# Skip unspecified symbol type
+if symbol.entry.st_info['type'] == "STT_NOTYPE":
+continue
 if symbol.name.startswith(prefix):
 yield ELFSymbol(self._image, symbol)
 
-- 
2.25.1



[POC] net/iavf: support no data path polling mode

2023-07-17 Thread Mingjin Ye
Introduces a devargs "no-poll-on-link-down" in iavf PMD. When this
flag is set, the PMD switches to no-poll mode when the link state is
down (rx/tx burst returns to 0 immediately). When the link state
returns to normal, PMD switches to normal rx/tx burst state.

Signed-off-by: Mingjin Ye 
---
 drivers/net/iavf/iavf.h |  2 ++
 drivers/net/iavf/iavf_ethdev.c  | 10 ++
 drivers/net/iavf/iavf_rxtx.c| 29 +++--
 drivers/net/iavf/iavf_rxtx.h|  1 +
 drivers/net/iavf/iavf_rxtx_vec_avx2.c   | 29 ++---
 drivers/net/iavf/iavf_rxtx_vec_avx512.c | 42 ++---
 drivers/net/iavf/iavf_rxtx_vec_sse.c| 21 -
 drivers/net/iavf/iavf_vchnl.c   | 19 +++
 8 files changed, 141 insertions(+), 12 deletions(-)

diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 98861e4242..30b05d25b6 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -305,6 +305,7 @@ struct iavf_devargs {
uint8_t proto_xtr[IAVF_MAX_QUEUE_NUM];
uint16_t quanta_size;
uint32_t watchdog_period;
+   uint16_t no_poll_on_link_down;
 };
 
 struct iavf_security_ctx;
@@ -323,6 +324,7 @@ struct iavf_adapter {
uint32_t ptype_tbl[IAVF_MAX_PKT_TYPE] __rte_cache_min_aligned;
bool stopped;
bool closed;
+   bool no_poll;
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index ac7154d720..41a8947f61 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_NO_POLL_ON_LINK_DOWN_ARG   "no-poll-on-link-down"
 
 uint64_t iavf_timestamp_dynflag;
 int iavf_timestamp_dynfield_offset = -1;
@@ -2237,6 +2238,7 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
struct rte_kvargs *kvlist;
int ret;
int watchdog_period = -1;
+   uint16_t no_poll_on_link_down;
 
if (!devargs)
return 0;
@@ -2270,6 +2272,14 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
else
ad->devargs.watchdog_period = watchdog_period;
 
+   no_poll_on_link_down = rte_kvargs_count(kvlist,
+   IAVF_NO_POLL_ON_LINK_DOWN_ARG);
+
+   if (no_poll_on_link_down == 0)
+   ad->devargs.no_poll_on_link_down = 0;
+   else
+   ad->devargs.no_poll_on_link_down = 1;
+
if (ad->devargs.quanta_size != 0 &&
(ad->devargs.quanta_size < 256 || ad->devargs.quanta_size > 4096 ||
 ad->devargs.quanta_size & 0x40)) {
diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index f7df4665d1..447e306fee 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -770,6 +770,7 @@ iavf_dev_tx_queue_setup(struct rte_eth_dev *dev,
IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
struct iavf_info *vf =
IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+   struct iavf_vsi *vsi = &vf->vsi;
struct iavf_tx_queue *txq;
const struct rte_memzone *mz;
uint32_t ring_size;
@@ -843,6 +844,7 @@ iavf_dev_tx_queue_setup(struct rte_eth_dev *dev,
txq->port_id = dev->data->port_id;
txq->offloads = offloads;
txq->tx_deferred_start = tx_conf->tx_deferred_start;
+   txq->vsi = vsi;
 
if (iavf_ipsec_crypto_supported(adapter))
txq->ipsec_crypto_pkt_md_offset =
@@ -1406,9 +1408,12 @@ iavf_recv_pkts(void *rx_queue, struct rte_mbuf 
**rx_pkts, uint16_t nb_pkts)
uint64_t pkt_flags;
const uint32_t *ptype_tbl;
 
+   rxq = rx_queue;
+   if (!rxq->vsi || rxq->vsi->adapter->no_poll)
+   return 0;
+
nb_rx = 0;
nb_hold = 0;
-   rxq = rx_queue;
rx_id = rxq->rx_tail;
rx_ring = rxq->rx_ring;
ptype_tbl = rxq->vsi->adapter->ptype_tbl;
@@ -1515,9 +1520,12 @@ iavf_recv_pkts_flex_rxd(void *rx_queue,
const uint32_t *ptype_tbl;
uint64_t ts_ns;
 
+   rxq = rx_queue;
+   if (!rxq->vsi || rxq->vsi->adapter->no_poll)
+   return 0;
+
nb_rx = 0;
nb_hold = 0;
-   rxq = rx_queue;
rx_id = rxq->rx_tail;
rx_ring = rxq->rx_ring;
ptype_tbl = rxq->vsi->adapter->ptype_tbl;
@@ -1641,6 +1649,9 @@ iavf_recv_scattered_pkts_flex_rxd(void *rx_queue, struct 
rte_mbuf **rx_pkts,
volatile union iavf_rx_flex_desc *rxdp;
const uint32_t *ptype_tbl = rxq->vsi->adapter->ptype_tbl;
 
+   if (!rxq->vsi || rxq->v

[POC v2] net/iavf: support no data path polling mode

2023-07-20 Thread Mingjin Ye
Introduces a devargs "no-poll-on-link-down" in iavf PMD. When this
flag is set, the PMD switches to no-poll mode when the link state is
down (rx/tx burst returns to 0 immediately). When the link state
returns to normal, PMD switches to normal rx/tx burst state.

Signed-off-by: Mingjin Ye 
---
V2: Add IAVF_NO_POLL_ON_LINK_DOWN_ARG macro to iavf_valid_args.
---
 drivers/net/iavf/iavf.h |  2 ++
 drivers/net/iavf/iavf_ethdev.c  | 11 +++
 drivers/net/iavf/iavf_rxtx.c| 29 +++--
 drivers/net/iavf/iavf_rxtx.h|  1 +
 drivers/net/iavf/iavf_rxtx_vec_avx2.c   | 29 ++---
 drivers/net/iavf/iavf_rxtx_vec_avx512.c | 42 ++---
 drivers/net/iavf/iavf_rxtx_vec_sse.c| 21 -
 drivers/net/iavf/iavf_vchnl.c   | 19 +++
 8 files changed, 142 insertions(+), 12 deletions(-)

diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 98861e4242..30b05d25b6 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -305,6 +305,7 @@ struct iavf_devargs {
uint8_t proto_xtr[IAVF_MAX_QUEUE_NUM];
uint16_t quanta_size;
uint32_t watchdog_period;
+   uint16_t no_poll_on_link_down;
 };
 
 struct iavf_security_ctx;
@@ -323,6 +324,7 @@ struct iavf_adapter {
uint32_t ptype_tbl[IAVF_MAX_PKT_TYPE] __rte_cache_min_aligned;
bool stopped;
bool closed;
+   bool no_poll;
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index ac7154d720..c922c64838 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_NO_POLL_ON_LINK_DOWN_ARG   "no-poll-on-link-down"
 
 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_NO_POLL_ON_LINK_DOWN_ARG,
NULL
 };
 
@@ -2237,6 +2239,7 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
struct rte_kvargs *kvlist;
int ret;
int watchdog_period = -1;
+   uint16_t no_poll_on_link_down;
 
if (!devargs)
return 0;
@@ -2270,6 +2273,14 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
else
ad->devargs.watchdog_period = watchdog_period;
 
+   no_poll_on_link_down = rte_kvargs_count(kvlist,
+   IAVF_NO_POLL_ON_LINK_DOWN_ARG);
+
+   if (no_poll_on_link_down == 0)
+   ad->devargs.no_poll_on_link_down = 0;
+   else
+   ad->devargs.no_poll_on_link_down = 1;
+
if (ad->devargs.quanta_size != 0 &&
(ad->devargs.quanta_size < 256 || ad->devargs.quanta_size > 4096 ||
 ad->devargs.quanta_size & 0x40)) {
diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index f7df4665d1..447e306fee 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -770,6 +770,7 @@ iavf_dev_tx_queue_setup(struct rte_eth_dev *dev,
IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
struct iavf_info *vf =
IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+   struct iavf_vsi *vsi = &vf->vsi;
struct iavf_tx_queue *txq;
const struct rte_memzone *mz;
uint32_t ring_size;
@@ -843,6 +844,7 @@ iavf_dev_tx_queue_setup(struct rte_eth_dev *dev,
txq->port_id = dev->data->port_id;
txq->offloads = offloads;
txq->tx_deferred_start = tx_conf->tx_deferred_start;
+   txq->vsi = vsi;
 
if (iavf_ipsec_crypto_supported(adapter))
txq->ipsec_crypto_pkt_md_offset =
@@ -1406,9 +1408,12 @@ iavf_recv_pkts(void *rx_queue, struct rte_mbuf 
**rx_pkts, uint16_t nb_pkts)
uint64_t pkt_flags;
const uint32_t *ptype_tbl;
 
+   rxq = rx_queue;
+   if (!rxq->vsi || rxq->vsi->adapter->no_poll)
+   return 0;
+
nb_rx = 0;
nb_hold = 0;
-   rxq = rx_queue;
rx_id = rxq->rx_tail;
rx_ring = rxq->rx_ring;
ptype_tbl = rxq->vsi->adapter->ptype_tbl;
@@ -1515,9 +1520,12 @@ iavf_recv_pkts_flex_rxd(void *rx_queue,
const uint32_t *ptype_tbl;
uint64_t ts_ns;
 
+   rxq = rx_queue;
+   if (!rxq->vsi || rxq->vsi->adapter->no_poll)
+   return 0;
+
nb_rx = 0;
nb_hold = 0;
-   rxq = rx_queue;
rx_id = rxq->rx_tail;
rx_ring = rxq->rx_ring;
ptype_tbl = rxq->vsi->adapter

[PATCH] app/dma-perf: fix dma mapping access overruns

2023-07-20 Thread Mingjin Ye
The dma map supports a maximum of `MAX_WORKER_NB=128`. Initializing
the dma map allows a maximum support of `MAX_WORKER_NB=256`. This results
in memory access out-of-bounds when the actual dma entries exceed
MAX_WORKER_NB.

This patch talks about MAX_WORKER_NB and MAX_WORKER_NB size set to 256 to
fix this.

Signed-off-by: Mingjin Ye 
---
 app/test-dma-perf/main.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/app/test-dma-perf/main.h b/app/test-dma-perf/main.h
index f65e264378..602ecac858 100644
--- a/app/test-dma-perf/main.h
+++ b/app/test-dma-perf/main.h
@@ -10,11 +10,12 @@
 #include 
 #include 
 
-#define MAX_WORKER_NB 128
+#define MAX_WORKER_NB 256
 #define MAX_OUTPUT_STR_LEN 512
 
 #define MAX_DMA_NB 128
-#define MAX_LCORE_NB 256
+/* Note that MAX_LCORE_NB <= MAX_WORKER_NB */
+#define MAX_LCORE_NB MAX_WORKER_NB
 
 extern char output_str[MAX_WORKER_NB + 1][MAX_OUTPUT_STR_LEN];
 
-- 
2.25.1



[POC v3] net/iavf: support no data path polling mode

2023-07-21 Thread Mingjin Ye
Currently, during a PF to VF reset due to an action such as changing
trust settings on a VF, the DPDK application running with iavf PMD
loses connectivity, and the only solution is to reset the DPDK
application.

Instead of forcing a reset of the DPDK application to restore
connectivity, the iavf PMD driver handles the PF to VF reset event
normally by performing all necessary steps to bring the VF back
online.

To minimize downtime, a devargs "no-poll-on-link-down" is introduced
in iavf PMD. When this flag is set, the PMD switches to no-poll mode
when the link state is down (rx/tx bursts return to 0 immediately).
When the link state returns to normal, the PMD switches to normal
rx/tx burst state.

NOTE: The DPDK application needs to handle the
RTE_ETH_EVENT_INTR_RESET event posted by the iavf PMD and reset
the vf upon receipt of this event.

Signed-off-by: Mingjin Ye 
---
V2: Add IAVF_NO_POLL_ON_LINK_DOWN_ARG macro to iavf_valid_args.
---
V3: Improve commit log.
---
 drivers/net/iavf/iavf.h |  2 ++
 drivers/net/iavf/iavf_ethdev.c  | 11 +++
 drivers/net/iavf/iavf_rxtx.c| 29 +++--
 drivers/net/iavf/iavf_rxtx.h|  1 +
 drivers/net/iavf/iavf_rxtx_vec_avx2.c   | 29 ++---
 drivers/net/iavf/iavf_rxtx_vec_avx512.c | 42 ++---
 drivers/net/iavf/iavf_rxtx_vec_sse.c| 21 -
 drivers/net/iavf/iavf_vchnl.c   | 17 ++
 8 files changed, 140 insertions(+), 12 deletions(-)

diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 98861e4242..30b05d25b6 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -305,6 +305,7 @@ struct iavf_devargs {
uint8_t proto_xtr[IAVF_MAX_QUEUE_NUM];
uint16_t quanta_size;
uint32_t watchdog_period;
+   uint16_t no_poll_on_link_down;
 };
 
 struct iavf_security_ctx;
@@ -323,6 +324,7 @@ struct iavf_adapter {
uint32_t ptype_tbl[IAVF_MAX_PKT_TYPE] __rte_cache_min_aligned;
bool stopped;
bool closed;
+   bool no_poll;
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index ac7154d720..c922c64838 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_NO_POLL_ON_LINK_DOWN_ARG   "no-poll-on-link-down"
 
 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_NO_POLL_ON_LINK_DOWN_ARG,
NULL
 };
 
@@ -2237,6 +2239,7 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
struct rte_kvargs *kvlist;
int ret;
int watchdog_period = -1;
+   uint16_t no_poll_on_link_down;
 
if (!devargs)
return 0;
@@ -2270,6 +2273,14 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
else
ad->devargs.watchdog_period = watchdog_period;
 
+   no_poll_on_link_down = rte_kvargs_count(kvlist,
+   IAVF_NO_POLL_ON_LINK_DOWN_ARG);
+
+   if (no_poll_on_link_down == 0)
+   ad->devargs.no_poll_on_link_down = 0;
+   else
+   ad->devargs.no_poll_on_link_down = 1;
+
if (ad->devargs.quanta_size != 0 &&
(ad->devargs.quanta_size < 256 || ad->devargs.quanta_size > 4096 ||
 ad->devargs.quanta_size & 0x40)) {
diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index f7df4665d1..447e306fee 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -770,6 +770,7 @@ iavf_dev_tx_queue_setup(struct rte_eth_dev *dev,
IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
struct iavf_info *vf =
IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+   struct iavf_vsi *vsi = &vf->vsi;
struct iavf_tx_queue *txq;
const struct rte_memzone *mz;
uint32_t ring_size;
@@ -843,6 +844,7 @@ iavf_dev_tx_queue_setup(struct rte_eth_dev *dev,
txq->port_id = dev->data->port_id;
txq->offloads = offloads;
txq->tx_deferred_start = tx_conf->tx_deferred_start;
+   txq->vsi = vsi;
 
if (iavf_ipsec_crypto_supported(adapter))
txq->ipsec_crypto_pkt_md_offset =
@@ -1406,9 +1408,12 @@ iavf_recv_pkts(void *rx_queue, struct rte_mbuf 
**rx_pkts, uint16_t nb_pkts)
uint64_t pkt_flags;
const uint32_t *ptype_tbl;
 
+   rxq = rx_queue;
+   if (!rxq->vsi || rxq->vsi->adapter->no_poll)
+   

[PATCH] net/iavf: support no data path polling mode

2023-08-10 Thread Mingjin Ye
Currently, during a PF to VF reset due to an action such as changing
trust settings on a VF, the DPDK application running with iavf PMD
loses connectivity, and the only solution is to reset the DPDK
application.

Instead of forcing a reset of the DPDK application to restore
connectivity, the iavf PMD driver handles the PF to VF reset event
normally by performing all necessary steps to bring the VF back
online.

To minimize downtime, a devargs "no-poll-on-link-down" is introduced
in iavf PMD. When this flag is set, the PMD switches to no-poll mode
when the link state is down (rx/tx bursts return to 0 immediately).
When the link state returns to normal, the PMD switches to normal
rx/tx burst state.

Signed-off-by: Mingjin Ye 
---
 doc/guides/nics/intel_vf.rst|  3 ++
 drivers/net/iavf/iavf.h |  2 ++
 drivers/net/iavf/iavf_ethdev.c  | 12 +++
 drivers/net/iavf/iavf_rxtx.c| 29 +++--
 drivers/net/iavf/iavf_rxtx.h|  1 +
 drivers/net/iavf/iavf_rxtx_vec_avx2.c   | 29 ++---
 drivers/net/iavf/iavf_rxtx_vec_avx512.c | 42 ++---
 drivers/net/iavf/iavf_rxtx_vec_sse.c| 21 -
 drivers/net/iavf/iavf_vchnl.c   | 20 
 9 files changed, 147 insertions(+), 12 deletions(-)

diff --git a/doc/guides/nics/intel_vf.rst b/doc/guides/nics/intel_vf.rst
index d365dbc185..54cfb688b3 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 no-poll-on-link-down by setting the ``devargs`` parameter like 
``-a 18:01.0,no_poll_on_link_down=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 FM1 Series VF 
infrastructure
 
^
 
diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 98861e4242..30b05d25b6 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -305,6 +305,7 @@ struct iavf_devargs {
uint8_t proto_xtr[IAVF_MAX_QUEUE_NUM];
uint16_t quanta_size;
uint32_t watchdog_period;
+   uint16_t no_poll_on_link_down;
 };
 
 struct iavf_security_ctx;
@@ -323,6 +324,7 @@ struct iavf_adapter {
uint32_t ptype_tbl[IAVF_MAX_PKT_TYPE] __rte_cache_min_aligned;
bool stopped;
bool closed;
+   bool no_poll;
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index f2fc5a5621..2fdc845204 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_NO_POLL_ON_LINK_DOWN_ARG   "no_poll_on_link_down"
 
 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_NO_POLL_ON_LINK_DOWN_ARG,
NULL
 };
 
@@ -2237,6 +2239,7 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
struct rte_kvargs *kvlist;
int ret;
int watchdog_period = -1;
+   uint16_t no_poll_on_link_down;
 
if (!devargs)
return 0;
@@ -2270,6 +2273,15 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
else
ad->devargs.watchdog_period = watchdog_period;
 
+   ret = rte_kvargs_process(kvlist, IAVF_NO_POLL_ON_LINK_DOWN_ARG,
+&parse_u16, &no_poll_on_link_down);
+   if (ret)
+   goto bail;
+   if (no_poll_on_link_down == 0)
+   ad->devargs.no_poll_on_link_down = 0;
+   else
+   ad->devargs.no_poll_on_link_down = 1;
+
if (ad->devargs.quanta_size != 0 &&
(ad->devargs.quanta_size < 256 || ad->devargs.quanta_size > 4096 ||
 ad->devargs.quanta_size & 0x40)) {
diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index f7df4665d1..447e306fee 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -770,6 +770,7 @@ iavf_dev_tx_queue_setup(struct rte_eth_dev *dev,
IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
struct iavf_info *vf =
IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+  

[PATCH v2] net/iavf: fix crash on closing representor ports

2023-10-29 Thread Mingjin Ye
Since the representor port needs to access the resources of the
associated DCF when it is closed. Therefore, the correct close
port operation is to close all the representor ports first, and
then close the associated DCF port.

If the DCF port is closed before the representor port on pmd exit.
This will result in accessing freed resources and eventually a
core dump will occur.

This patch fixes this issue by notifying all presentor ports
that DCF is not accessible when the DCF port is closed.
And when the presentor port is closed, it determines if the DCF
resources are accessible. If it can't be accessed, it will
report an error and return.

Fixes: 5674465a32c8 ("net/ice: add DCF VLAN handling")
Fixes: da9cdcd1f372 ("net/ice: fix crash on representor port closing")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
v2: Reformat code to remove unneeded fixlines.
---
 drivers/net/ice/ice_dcf_ethdev.h |  1 +
 drivers/net/ice/ice_dcf_vf_representor.c | 11 ---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ice/ice_dcf_ethdev.h b/drivers/net/ice/ice_dcf_ethdev.h
index 4baaec4b8b..d94ef10244 100644
--- a/drivers/net/ice/ice_dcf_ethdev.h
+++ b/drivers/net/ice/ice_dcf_ethdev.h
@@ -60,6 +60,7 @@ struct ice_dcf_vf_repr {
struct rte_ether_addr mac_addr;
uint16_t switch_domain_id;
uint16_t vf_id;
+   bool dcf_valid;
 
struct ice_dcf_vlan outer_vlan_info; /* DCF always handle outer VLAN */
 };
diff --git a/drivers/net/ice/ice_dcf_vf_representor.c 
b/drivers/net/ice/ice_dcf_vf_representor.c
index b9fcfc80ad..eb49eae4e4 100644
--- a/drivers/net/ice/ice_dcf_vf_representor.c
+++ b/drivers/net/ice/ice_dcf_vf_representor.c
@@ -45,6 +45,9 @@ ice_dcf_vf_repr_dev_start(struct rte_eth_dev *dev)
 static int
 ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev)
 {
+   struct ice_dcf_vf_repr *repr = dev->data->dev_private;
+
+   repr->dcf_valid = false;
dev->data->dev_link.link_status = RTE_ETH_LINK_DOWN;
 
return 0;
@@ -111,14 +114,15 @@ ice_dcf_vf_repr_link_update(__rte_unused struct 
rte_eth_dev *ethdev,
 static __rte_always_inline struct ice_dcf_hw *
 ice_dcf_vf_repr_hw(struct ice_dcf_vf_repr *repr)
 {
-   struct ice_dcf_adapter *dcf_adapter =
-   repr->dcf_eth_dev->data->dev_private;
+   struct ice_dcf_adapter *dcf_adapter;
 
-   if (!dcf_adapter) {
+   if (!repr->dcf_valid) {
PMD_DRV_LOG(ERR, "DCF for VF representor has been released\n");
return NULL;
}
 
+   dcf_adapter = repr->dcf_eth_dev->data->dev_private;
+
return &dcf_adapter->real_hw;
 }
 
@@ -414,6 +418,7 @@ ice_dcf_vf_repr_init(struct rte_eth_dev *vf_rep_eth_dev, 
void *init_param)
repr->dcf_eth_dev = param->dcf_eth_dev;
repr->switch_domain_id = param->switch_domain_id;
repr->vf_id = param->vf_id;
+   repr->dcf_valid = true;
repr->outer_vlan_info.port_vlan_ena = false;
repr->outer_vlan_info.stripping_ena = false;
repr->outer_vlan_info.tpid = RTE_ETHER_TYPE_VLAN;
-- 
2.25.1



[PATCH v2] net/ice: fix crash on closing representor ports

2023-10-30 Thread Mingjin Ye
Since the representor port needs to access the resources of the
associated DCF when it is closed. Therefore, the correct close
port operation is to close all the representor ports first, and
then close the associated DCF port.

If the DCF port is closed before the representor port on pmd exit.
This will result in accessing freed resources and eventually a
core dump will occur.

This patch fixes this issue by notifying all presentor ports
that DCF is not accessible when the DCF port is closed.
And when the presentor port is closed, it determines if the DCF
resources are accessible. If it can't be accessed, it will
report an error and return.

Fixes: 5674465a32c8 ("net/ice: add DCF VLAN handling")
Fixes: da9cdcd1f372 ("net/ice: fix crash on representor port closing")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
v2: Reformat code to remove unneeded fixlines.
---
 drivers/net/ice/ice_dcf_ethdev.h |  1 +
 drivers/net/ice/ice_dcf_vf_representor.c | 11 ---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ice/ice_dcf_ethdev.h b/drivers/net/ice/ice_dcf_ethdev.h
index 4baaec4b8b..d94ef10244 100644
--- a/drivers/net/ice/ice_dcf_ethdev.h
+++ b/drivers/net/ice/ice_dcf_ethdev.h
@@ -60,6 +60,7 @@ struct ice_dcf_vf_repr {
struct rte_ether_addr mac_addr;
uint16_t switch_domain_id;
uint16_t vf_id;
+   bool dcf_valid;
 
struct ice_dcf_vlan outer_vlan_info; /* DCF always handle outer VLAN */
 };
diff --git a/drivers/net/ice/ice_dcf_vf_representor.c 
b/drivers/net/ice/ice_dcf_vf_representor.c
index b9fcfc80ad..eb49eae4e4 100644
--- a/drivers/net/ice/ice_dcf_vf_representor.c
+++ b/drivers/net/ice/ice_dcf_vf_representor.c
@@ -45,6 +45,9 @@ ice_dcf_vf_repr_dev_start(struct rte_eth_dev *dev)
 static int
 ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev)
 {
+   struct ice_dcf_vf_repr *repr = dev->data->dev_private;
+
+   repr->dcf_valid = false;
dev->data->dev_link.link_status = RTE_ETH_LINK_DOWN;
 
return 0;
@@ -111,14 +114,15 @@ ice_dcf_vf_repr_link_update(__rte_unused struct 
rte_eth_dev *ethdev,
 static __rte_always_inline struct ice_dcf_hw *
 ice_dcf_vf_repr_hw(struct ice_dcf_vf_repr *repr)
 {
-   struct ice_dcf_adapter *dcf_adapter =
-   repr->dcf_eth_dev->data->dev_private;
+   struct ice_dcf_adapter *dcf_adapter;
 
-   if (!dcf_adapter) {
+   if (!repr->dcf_valid) {
PMD_DRV_LOG(ERR, "DCF for VF representor has been released\n");
return NULL;
}
 
+   dcf_adapter = repr->dcf_eth_dev->data->dev_private;
+
return &dcf_adapter->real_hw;
 }
 
@@ -414,6 +418,7 @@ ice_dcf_vf_repr_init(struct rte_eth_dev *vf_rep_eth_dev, 
void *init_param)
repr->dcf_eth_dev = param->dcf_eth_dev;
repr->switch_domain_id = param->switch_domain_id;
repr->vf_id = param->vf_id;
+   repr->dcf_valid = true;
repr->outer_vlan_info.port_vlan_ena = false;
repr->outer_vlan_info.stripping_ena = false;
repr->outer_vlan_info.tpid = RTE_ETHER_TYPE_VLAN;
-- 
2.25.1



[PATCH v3] net/ice: fix crash on closing representor ports

2023-11-01 Thread Mingjin Ye
The data resource in struct rte_eth_dev is cleared and points to NULL
when the DCF port is closed.

If the DCF representor port is closed after the DCF port is closed,
a segmentation fault occurs because the representor port accesses
the data resource released by the DCF port.

This patch checks if the resource is present before accessing.

Fixes: 5674465a32c8 ("net/ice: add DCF VLAN handling")
Fixes: da9cdcd1f372 ("net/ice: fix crash on representor port closing")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
v3: New solution.
---
 drivers/net/ice/ice_dcf_vf_representor.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ice/ice_dcf_vf_representor.c 
b/drivers/net/ice/ice_dcf_vf_representor.c
index b9fcfc80ad..8c45e28f02 100644
--- a/drivers/net/ice/ice_dcf_vf_representor.c
+++ b/drivers/net/ice/ice_dcf_vf_representor.c
@@ -111,14 +111,16 @@ ice_dcf_vf_repr_link_update(__rte_unused struct 
rte_eth_dev *ethdev,
 static __rte_always_inline struct ice_dcf_hw *
 ice_dcf_vf_repr_hw(struct ice_dcf_vf_repr *repr)
 {
-   struct ice_dcf_adapter *dcf_adapter =
-   repr->dcf_eth_dev->data->dev_private;
+   struct rte_eth_dev_data *dcf_data = repr->dcf_eth_dev->data;
+   struct ice_dcf_adapter *dcf_adapter;
 
-   if (!dcf_adapter) {
+   if (!dcf_data || !dcf_data->dev_private) {
PMD_DRV_LOG(ERR, "DCF for VF representor has been released\n");
return NULL;
}
 
+   dcf_adapter = dcf_data->dev_private;
+
return &dcf_adapter->real_hw;
 }
 
-- 
2.25.1



[PATCH v4] net/ice: fix crash on closing representor ports

2023-11-02 Thread Mingjin Ye
Since the representor port needs to access the resource of the
associated DCF when it is closing. Therefore, all the representor
port should be closed first, and then close the associated DCF port.

If the DCF port is closed before the representor port on PMD exit.
This will result in accessing freed resources and eventually a
core dump will occur.

This patch fixes this issue by notifying each other to unassociate
when the DCF port and the representor port are closed.

Fixes: 5674465a32c8 ("net/ice: add DCF VLAN handling")
Fixes: c7e1a1a3bfeb ("net/ice: refactor DCF VLAN handling")
Fixes: da9cdcd1f372 ("net/ice: fix crash on representor port closing")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
v2: Reformat code to remove unneeded fixlines.
---
v3: New solution.
---
v4: Optimize v2 patch.
---
 drivers/net/ice/ice_dcf_ethdev.c | 20 
 drivers/net/ice/ice_dcf_ethdev.h |  2 ++
 drivers/net/ice/ice_dcf_vf_representor.c | 23 ++-
 3 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c
index 065ec728c2..63e63a23de 100644
--- a/drivers/net/ice/ice_dcf_ethdev.c
+++ b/drivers/net/ice/ice_dcf_ethdev.c
@@ -1618,6 +1618,26 @@ ice_dcf_free_repr_info(struct ice_dcf_adapter 
*dcf_adapter)
}
 }
 
+int
+ice_dcf_handle_vf_repr_uninit(struct ice_dcf_adapter *dcf_adapter,
+   uint16_t vf_id)
+{
+   struct ice_dcf_repr_info *vf_rep_info;
+
+   if (dcf_adapter->num_reprs >= vf_id) {
+   PMD_DRV_LOG(ERR, "Invalid VF id: %d", vf_id);
+   return -1;
+   }
+
+   if (!dcf_adapter->repr_infos)
+   return 0;
+
+   vf_rep_info = &dcf_adapter->repr_infos[vf_id];
+   vf_rep_info->vf_rep_eth_dev = NULL;
+
+   return 0;
+}
+
 static int
 ice_dcf_init_repr_info(struct ice_dcf_adapter *dcf_adapter)
 {
diff --git a/drivers/net/ice/ice_dcf_ethdev.h b/drivers/net/ice/ice_dcf_ethdev.h
index 4baaec4b8b..094e2a36db 100644
--- a/drivers/net/ice/ice_dcf_ethdev.h
+++ b/drivers/net/ice/ice_dcf_ethdev.h
@@ -60,6 +60,7 @@ struct ice_dcf_vf_repr {
struct rte_ether_addr mac_addr;
uint16_t switch_domain_id;
uint16_t vf_id;
+   bool dcf_valid;
 
struct ice_dcf_vlan outer_vlan_info; /* DCF always handle outer VLAN */
 };
@@ -81,5 +82,6 @@ int ice_dcf_vf_repr_uninit(struct rte_eth_dev 
*vf_rep_eth_dev);
 int ice_dcf_vf_repr_init_vlan(struct rte_eth_dev *vf_rep_eth_dev);
 void ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter *dcf_adapter);
 bool ice_dcf_adminq_need_retry(struct ice_adapter *ad);
+int ice_dcf_handle_vf_repr_uninit(struct ice_dcf_adapter *dcf_adapter, 
uint16_t vf_id);
 
 #endif /* _ICE_DCF_ETHDEV_H_ */
diff --git a/drivers/net/ice/ice_dcf_vf_representor.c 
b/drivers/net/ice/ice_dcf_vf_representor.c
index b9fcfc80ad..167abaa780 100644
--- a/drivers/net/ice/ice_dcf_vf_representor.c
+++ b/drivers/net/ice/ice_dcf_vf_representor.c
@@ -45,6 +45,9 @@ ice_dcf_vf_repr_dev_start(struct rte_eth_dev *dev)
 static int
 ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev)
 {
+   struct ice_dcf_vf_repr *repr = dev->data->dev_private;
+
+   repr->dcf_valid = false;
dev->data->dev_link.link_status = RTE_ETH_LINK_DOWN;
 
return 0;
@@ -111,14 +114,15 @@ ice_dcf_vf_repr_link_update(__rte_unused struct 
rte_eth_dev *ethdev,
 static __rte_always_inline struct ice_dcf_hw *
 ice_dcf_vf_repr_hw(struct ice_dcf_vf_repr *repr)
 {
-   struct ice_dcf_adapter *dcf_adapter =
-   repr->dcf_eth_dev->data->dev_private;
+   struct ice_dcf_adapter *dcf_adapter;
 
-   if (!dcf_adapter) {
+   if (!repr->dcf_valid) {
PMD_DRV_LOG(ERR, "DCF for VF representor has been released\n");
return NULL;
}
 
+   dcf_adapter = repr->dcf_eth_dev->data->dev_private;
+
return &dcf_adapter->real_hw;
 }
 
@@ -414,6 +418,7 @@ ice_dcf_vf_repr_init(struct rte_eth_dev *vf_rep_eth_dev, 
void *init_param)
repr->dcf_eth_dev = param->dcf_eth_dev;
repr->switch_domain_id = param->switch_domain_id;
repr->vf_id = param->vf_id;
+   repr->dcf_valid = true;
repr->outer_vlan_info.port_vlan_ena = false;
repr->outer_vlan_info.stripping_ena = false;
repr->outer_vlan_info.tpid = RTE_ETHER_TYPE_VLAN;
@@ -437,6 +442,14 @@ ice_dcf_vf_repr_init(struct rte_eth_dev *vf_rep_eth_dev, 
void *init_param)
 int
 ice_dcf_vf_repr_uninit(struct rte_eth_dev *vf_rep_eth_dev)
 {
+   struct ice_dcf_vf_repr *repr = vf_rep_eth_dev->data->dev_private;
+   struct ice_dcf_adapter *dcf_adapter;
+
+   if (repr->dcf_valid) {
+   dcf_adapter = repr->dcf_eth_dev->data->dev_private;
+   ice_dcf_handle_vf_repr_uninit(

[PATCH v5] net/ice: fix crash on closing representor ports

2023-11-06 Thread Mingjin Ye
The data resource in struct rte_eth_dev is cleared and points to NULL
when the DCF port is closed.

If the DCF representor port is closed after the DCF port is closed,
a segmentation fault occurs because the representor port accesses the
data resource released by the DCF port.

This patch fixes this issue by synchronizing the state of DCF ports and
representor ports to the peer in real time when their state changes.

Fixes: 5674465a32c8 ("net/ice: add DCF VLAN handling")
Fixes: da9cdcd1f372 ("net/ice: fix crash on representor port closing")
Fixes: 7564d5509611 ("net/ice: add DCF hardware initialization")
Fixes: c7e1a1a3bfeb ("net/ice: refactor DCF VLAN handling")
Fixes: 1a86f4dbdf42 ("net/ice: support DCF device reset")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
v2: Reformat code to remove unneeded fixlines.
---
v3: New solution.
---
v4: Optimize v2 patch.
---
v5: optimization.
---
 drivers/net/ice/ice_dcf_ethdev.c | 30 --
 drivers/net/ice/ice_dcf_ethdev.h |  3 ++
 drivers/net/ice/ice_dcf_vf_representor.c | 50 ++--
 3 files changed, 77 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c
index 065ec728c2..eea24ee3a9 100644
--- a/drivers/net/ice/ice_dcf_ethdev.c
+++ b/drivers/net/ice/ice_dcf_ethdev.c
@@ -1618,6 +1618,26 @@ ice_dcf_free_repr_info(struct ice_dcf_adapter 
*dcf_adapter)
}
 }
 
+int
+ice_dcf_handle_vf_repr_close(struct ice_dcf_adapter *dcf_adapter,
+   uint16_t vf_id)
+{
+   struct ice_dcf_repr_info *vf_rep_info;
+
+   if (dcf_adapter->num_reprs >= vf_id) {
+   PMD_DRV_LOG(ERR, "Invalid VF id: %d", vf_id);
+   return -1;
+   }
+
+   if (!dcf_adapter->repr_infos)
+   return 0;
+
+   vf_rep_info = &dcf_adapter->repr_infos[vf_id];
+   vf_rep_info->vf_rep_eth_dev = NULL;
+
+   return 0;
+}
+
 static int
 ice_dcf_init_repr_info(struct ice_dcf_adapter *dcf_adapter)
 {
@@ -1641,11 +1661,10 @@ ice_dcf_dev_close(struct rte_eth_dev *dev)
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return 0;
 
+   ice_dcf_vf_repr_notify_all(adapter, false);
(void)ice_dcf_dev_stop(dev);
 
ice_free_queues(dev);
-
-   ice_dcf_free_repr_info(adapter);
ice_dcf_uninit_parent_adapter(dev);
ice_dcf_uninit_hw(dev, &adapter->real_hw);
 
@@ -1835,7 +1854,7 @@ ice_dcf_dev_reset(struct rte_eth_dev *dev)
ice_dcf_reset_hw(dev, hw);
}
 
-   ret = ice_dcf_dev_uninit(dev);
+   ret = ice_dcf_dev_close(dev);
if (ret)
return ret;
 
@@ -1938,12 +1957,17 @@ ice_dcf_dev_init(struct rte_eth_dev *eth_dev)
}
 
dcf_config_promisc(adapter, false, false);
+   ice_dcf_vf_repr_notify_all(adapter, true);
+
return 0;
 }
 
 static int
 ice_dcf_dev_uninit(struct rte_eth_dev *eth_dev)
 {
+   struct ice_dcf_adapter *adapter = eth_dev->data->dev_private;
+
+   ice_dcf_free_repr_info(adapter);
ice_dcf_dev_close(eth_dev);
 
return 0;
diff --git a/drivers/net/ice/ice_dcf_ethdev.h b/drivers/net/ice/ice_dcf_ethdev.h
index 4baaec4b8b..6dcbaac5eb 100644
--- a/drivers/net/ice/ice_dcf_ethdev.h
+++ b/drivers/net/ice/ice_dcf_ethdev.h
@@ -60,6 +60,7 @@ struct ice_dcf_vf_repr {
struct rte_ether_addr mac_addr;
uint16_t switch_domain_id;
uint16_t vf_id;
+   bool dcf_valid;
 
struct ice_dcf_vlan outer_vlan_info; /* DCF always handle outer VLAN */
 };
@@ -80,6 +81,8 @@ int ice_dcf_vf_repr_init(struct rte_eth_dev *vf_rep_eth_dev, 
void *init_param);
 int ice_dcf_vf_repr_uninit(struct rte_eth_dev *vf_rep_eth_dev);
 int ice_dcf_vf_repr_init_vlan(struct rte_eth_dev *vf_rep_eth_dev);
 void ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter *dcf_adapter);
+void ice_dcf_vf_repr_notify_all(struct ice_dcf_adapter *dcf_adapter, bool 
valid);
+int ice_dcf_handle_vf_repr_close(struct ice_dcf_adapter *dcf_adapter, uint16_t 
vf_id);
 bool ice_dcf_adminq_need_retry(struct ice_adapter *ad);
 
 #endif /* _ICE_DCF_ETHDEV_H_ */
diff --git a/drivers/net/ice/ice_dcf_vf_representor.c 
b/drivers/net/ice/ice_dcf_vf_representor.c
index b9fcfc80ad..6c342798ac 100644
--- a/drivers/net/ice/ice_dcf_vf_representor.c
+++ b/drivers/net/ice/ice_dcf_vf_representor.c
@@ -50,9 +50,32 @@ ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev)
return 0;
 }
 
+static bool
+ice_dcf_vf_repr_set_dcf_valid(struct rte_eth_dev *dev, bool valid)
+{
+   struct ice_dcf_vf_repr *repr = dev->data->dev_private;
+
+   if (!repr)
+   return false;
+
+   repr->dcf_valid = valid;
+
+   return true;
+}
+
 static int
 ice_dcf_vf_repr_dev_close(struct rte_eth_dev *dev)
 {
+   struct ice_dcf_vf_repr *repr = dev->data->dev_private;
+   struct ice_dcf_adapter *dcf_a

[PATCH] net/iavf: MDD fault diagnostics support on TX paths

2023-11-06 Thread Mingjin Ye
When an MDD packet is detected, hardware will shutdown the queue.
In a Tx path troubleshooting scenario, modifying the application
code to reselect the Tx path is the only way to enable mbuf
legitimacy check, which makes troubleshooting difficult.

In this patch, the devargs option "mbuf_check" is introduced and the
corresponding diagnostic function is enabled by configuring MDD case.

Argument format: mbuf_check=generic,,
Currently support MDD case: generic, segment, offload, careful.

Signed-off-by: Mingjin Ye 
---
 drivers/net/iavf/iavf.h|  26 +
 drivers/net/iavf/iavf_ethdev.c |  99 ++
 drivers/net/iavf/iavf_rxtx.c   | 182 +
 drivers/net/iavf/iavf_rxtx.h   |   4 +
 4 files changed, 311 insertions(+)

diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 04774ce124..ad46fdeddd 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -113,9 +113,15 @@ struct iavf_ipsec_crypto_stats {
} ierrors;
 };
 
+struct iavf_mdd_stats {
+   uint64_t mdd_mbuf_err_count;
+   uint64_t mdd_pkt_err_count;
+};
+
 struct iavf_eth_xstats {
struct virtchnl_eth_stats eth_stats;
struct iavf_ipsec_crypto_stats ips_stats;
+   struct iavf_mdd_stats mdd_stats;
 };
 
 /* Structure that defines a VSI, associated with a adapter. */
@@ -299,6 +305,13 @@ enum iavf_proto_xtr_type {
IAVF_PROTO_XTR_MAX,
 };
 
+enum iavf_mdd_check_type {
+   IAVF_MDD_CHECK_GENERAL,
+   IAVF_MDD_CHECK_SEGMENT,
+   IAVF_MDD_CHECK_OFFLOAD,
+   IAVF_MDD_CHECK_CAREFUL,
+};
+
 /**
  * Cache devargs parse result.
  */
@@ -308,10 +321,21 @@ struct iavf_devargs {
uint16_t quanta_size;
uint32_t watchdog_period;
uint8_t  auto_reset;
+   uint16_t mbuf_check;
 };
 
 struct iavf_security_ctx;
 
+struct iavf_tx_burst_element {
+   TAILQ_ENTRY(iavf_tx_burst_element) next;
+   eth_tx_burst_t tx_pkt_burst;
+};
+
+#define IAVF_MDD_CHECK_F_TX_GENERAL (1ULL << 0)
+#define IAVF_MDD_CHECK_F_TX_SEGMENT (1ULL << 1)
+#define IAVF_MDD_CHECK_F_TX_OFFLOAD (1ULL << 2)
+#define IAVF_MDD_CHECK_F_TX_CAREFUL (1ULL << 3)
+
 /* Structure to store private data for each VF instance. */
 struct iavf_adapter {
struct iavf_hw hw;
@@ -326,6 +350,8 @@ struct iavf_adapter {
uint32_t ptype_tbl[IAVF_MAX_PKT_TYPE] __rte_cache_min_aligned;
bool stopped;
bool closed;
+   uint64_t mc_flags; /* mdd check flags. */
+   TAILQ_HEAD(tx_pkt_burst_list, iavf_tx_burst_element) list_tx_pkt_burst;
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 5b2634a4e3..cb0b7491e5 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_MDD_CHECK_ARG   "mbuf_check"
 #define IAVF_ENABLE_AUTO_RESET_ARG "auto_reset"
 
 uint64_t iavf_timestamp_dynflag;
@@ -46,6 +47,7 @@ static const char * const iavf_valid_args[] = {
IAVF_PROTO_XTR_ARG,
IAVF_QUANTA_SIZE_ARG,
IAVF_RESET_WATCHDOG_ARG,
+   IAVF_MDD_CHECK_ARG,
IAVF_ENABLE_AUTO_RESET_ARG,
NULL
 };
@@ -187,6 +189,8 @@ static const struct rte_iavf_xstats_name_off 
rte_iavf_stats_strings[] = {
_OFF_OF(ips_stats.ierrors.ipsec_length)},
{"inline_ipsec_crypto_ierrors_misc",
_OFF_OF(ips_stats.ierrors.misc)},
+   {"mdd_mbuf_error_packets", _OFF_OF(mdd_stats.mdd_mbuf_err_count)},
+   {"mdd_pkt_error_packets", _OFF_OF(mdd_stats.mdd_pkt_err_count)},
 };
 #undef _OFF_OF
 
@@ -1878,6 +1882,9 @@ static int iavf_dev_xstats_get(struct rte_eth_dev *dev,
 {
int ret;
unsigned int i;
+   struct iavf_tx_queue *txq;
+   uint64_t mdd_mbuf_err_count = 0;
+   uint64_t mdd_pkt_err_count = 0;
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);
@@ -1901,6 +1908,17 @@ static int iavf_dev_xstats_get(struct rte_eth_dev *dev,
if (iavf_ipsec_crypto_supported(adapter))
iavf_dev_update_ipsec_xstats(dev, &iavf_xtats.ips_stats);
 
+
+   if (adapter->devargs.mbuf_check) {
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
+   txq = dev->data->tx_queues[i];
+   mdd_mbuf_err_count += txq->mdd_mbuf_err_count;
+   mdd_pkt_err_count += txq->mdd_pkt_err_count;
+   }
+   iavf_xtats.mdd_stats.mdd_mbuf_err_count = mdd_mbuf_err_count;
+  

[PATCH v6] net/ice: fix crash on closing representor ports

2023-11-07 Thread Mingjin Ye
The data resource in struct rte_eth_dev is cleared and points to NULL
when the DCF port is closed.

If the DCF representor port is closed after the DCF port is closed,
a segmentation fault occurs because the representor port accesses the
data resource released by the DCF port.

This patch fixes this issue by synchronizing the state of DCF ports and
representor ports to the peer in real time when their state changes.

Fixes: da9cdcd1f372 ("net/ice: fix crash on representor port closing")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
v2: Reformat code to remove unneeded fixlines.
---
v3: New solution.
---
v4: Optimize v2 patch.
---
v5: optimization.
---
v6: Optimize and resolve conflicts.
---
 drivers/net/ice/ice_dcf_ethdev.c | 30 --
 drivers/net/ice/ice_dcf_ethdev.h |  3 ++
 drivers/net/ice/ice_dcf_vf_representor.c | 51 ++--
 3 files changed, 78 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c
index 29699c2c32..5d845bba31 100644
--- a/drivers/net/ice/ice_dcf_ethdev.c
+++ b/drivers/net/ice/ice_dcf_ethdev.c
@@ -1618,6 +1618,26 @@ ice_dcf_free_repr_info(struct ice_dcf_adapter 
*dcf_adapter)
}
 }
 
+int
+ice_dcf_handle_vf_repr_close(struct ice_dcf_adapter *dcf_adapter,
+   uint16_t vf_id)
+{
+   struct ice_dcf_repr_info *vf_rep_info;
+
+   if (dcf_adapter->num_reprs >= vf_id) {
+   PMD_DRV_LOG(ERR, "Invalid VF id: %d", vf_id);
+   return -1;
+   }
+
+   if (!dcf_adapter->repr_infos)
+   return 0;
+
+   vf_rep_info = &dcf_adapter->repr_infos[vf_id];
+   vf_rep_info->vf_rep_eth_dev = NULL;
+
+   return 0;
+}
+
 static int
 ice_dcf_init_repr_info(struct ice_dcf_adapter *dcf_adapter)
 {
@@ -1641,11 +1661,10 @@ ice_dcf_dev_close(struct rte_eth_dev *dev)
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return 0;
 
+   ice_dcf_vf_repr_notify_all(adapter, false);
(void)ice_dcf_dev_stop(dev);
 
ice_free_queues(dev);
-
-   ice_dcf_free_repr_info(adapter);
ice_dcf_uninit_parent_adapter(dev);
ice_dcf_uninit_hw(dev, &adapter->real_hw);
 
@@ -1835,7 +1854,7 @@ ice_dcf_dev_reset(struct rte_eth_dev *dev)
ice_dcf_reset_hw(dev, hw);
}
 
-   ret = ice_dcf_dev_uninit(dev);
+   ret = ice_dcf_dev_close(dev);
if (ret)
return ret;
 
@@ -1940,12 +1959,17 @@ ice_dcf_dev_init(struct rte_eth_dev *eth_dev)
ice_dcf_stats_reset(eth_dev);
 
dcf_config_promisc(adapter, false, false);
+   ice_dcf_vf_repr_notify_all(adapter, true);
+
return 0;
 }
 
 static int
 ice_dcf_dev_uninit(struct rte_eth_dev *eth_dev)
 {
+   struct ice_dcf_adapter *adapter = eth_dev->data->dev_private;
+
+   ice_dcf_free_repr_info(adapter);
ice_dcf_dev_close(eth_dev);
 
return 0;
diff --git a/drivers/net/ice/ice_dcf_ethdev.h b/drivers/net/ice/ice_dcf_ethdev.h
index 4baaec4b8b..6dcbaac5eb 100644
--- a/drivers/net/ice/ice_dcf_ethdev.h
+++ b/drivers/net/ice/ice_dcf_ethdev.h
@@ -60,6 +60,7 @@ struct ice_dcf_vf_repr {
struct rte_ether_addr mac_addr;
uint16_t switch_domain_id;
uint16_t vf_id;
+   bool dcf_valid;
 
struct ice_dcf_vlan outer_vlan_info; /* DCF always handle outer VLAN */
 };
@@ -80,6 +81,8 @@ int ice_dcf_vf_repr_init(struct rte_eth_dev *vf_rep_eth_dev, 
void *init_param);
 int ice_dcf_vf_repr_uninit(struct rte_eth_dev *vf_rep_eth_dev);
 int ice_dcf_vf_repr_init_vlan(struct rte_eth_dev *vf_rep_eth_dev);
 void ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter *dcf_adapter);
+void ice_dcf_vf_repr_notify_all(struct ice_dcf_adapter *dcf_adapter, bool 
valid);
+int ice_dcf_handle_vf_repr_close(struct ice_dcf_adapter *dcf_adapter, uint16_t 
vf_id);
 bool ice_dcf_adminq_need_retry(struct ice_adapter *ad);
 
 #endif /* _ICE_DCF_ETHDEV_H_ */
diff --git a/drivers/net/ice/ice_dcf_vf_representor.c 
b/drivers/net/ice/ice_dcf_vf_representor.c
index b9fcfc80ad..00dc322b30 100644
--- a/drivers/net/ice/ice_dcf_vf_representor.c
+++ b/drivers/net/ice/ice_dcf_vf_representor.c
@@ -50,9 +50,30 @@ ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev)
return 0;
 }
 
+static int
+ice_dcf_vf_repr_set_dcf_valid(struct rte_eth_dev *dev, bool valid)
+{
+   struct ice_dcf_vf_repr *repr = dev->data->dev_private;
+
+   repr->dcf_valid = valid;
+
+   return 0;
+}
+
 static int
 ice_dcf_vf_repr_dev_close(struct rte_eth_dev *dev)
 {
+   struct ice_dcf_vf_repr *repr = dev->data->dev_private;
+   struct ice_dcf_adapter *dcf_adapter;
+   int err;
+
+   if (repr->dcf_valid) {
+   dcf_adapter = repr->dcf_eth_dev->data->dev_private;
+   err = ice_dcf_handle_vf_repr_close(dcf_adapter, repr->vf_id);
+   if (err)
+   

[PATCH v7] net/ice: fix crash on closing representor ports

2023-11-08 Thread Mingjin Ye
The data resource in struct rte_eth_dev is cleared and points to NULL
when the DCF port is closed.

If the DCF representor port is closed after the DCF port is closed,
a segmentation fault occurs because the representor port accesses the
data resource released by the DCF port.

This patch fixes this issue by synchronizing the state of DCF ports and
representor ports to the peer in real time when their state changes.

Fixes: c7e1a1a3bfeb ("net/ice: refactor DCF VLAN handling")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
v2: Reformat code to remove unneeded fixlines.
---
v3: New solution.
---
v4: Optimize v2 patch.
---
v5: optimization.
---
v6: Optimize and resolve conflicts.
---
v7: optimization.
---
 drivers/net/ice/ice_dcf_ethdev.c | 30 ++--
 drivers/net/ice/ice_dcf_ethdev.h |  3 ++
 drivers/net/ice/ice_dcf_vf_representor.c | 46 ++--
 3 files changed, 73 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c
index 29699c2c32..5d845bba31 100644
--- a/drivers/net/ice/ice_dcf_ethdev.c
+++ b/drivers/net/ice/ice_dcf_ethdev.c
@@ -1618,6 +1618,26 @@ ice_dcf_free_repr_info(struct ice_dcf_adapter 
*dcf_adapter)
}
 }
 
+int
+ice_dcf_handle_vf_repr_close(struct ice_dcf_adapter *dcf_adapter,
+   uint16_t vf_id)
+{
+   struct ice_dcf_repr_info *vf_rep_info;
+
+   if (dcf_adapter->num_reprs >= vf_id) {
+   PMD_DRV_LOG(ERR, "Invalid VF id: %d", vf_id);
+   return -1;
+   }
+
+   if (!dcf_adapter->repr_infos)
+   return 0;
+
+   vf_rep_info = &dcf_adapter->repr_infos[vf_id];
+   vf_rep_info->vf_rep_eth_dev = NULL;
+
+   return 0;
+}
+
 static int
 ice_dcf_init_repr_info(struct ice_dcf_adapter *dcf_adapter)
 {
@@ -1641,11 +1661,10 @@ ice_dcf_dev_close(struct rte_eth_dev *dev)
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return 0;
 
+   ice_dcf_vf_repr_notify_all(adapter, false);
(void)ice_dcf_dev_stop(dev);
 
ice_free_queues(dev);
-
-   ice_dcf_free_repr_info(adapter);
ice_dcf_uninit_parent_adapter(dev);
ice_dcf_uninit_hw(dev, &adapter->real_hw);
 
@@ -1835,7 +1854,7 @@ ice_dcf_dev_reset(struct rte_eth_dev *dev)
ice_dcf_reset_hw(dev, hw);
}
 
-   ret = ice_dcf_dev_uninit(dev);
+   ret = ice_dcf_dev_close(dev);
if (ret)
return ret;
 
@@ -1940,12 +1959,17 @@ ice_dcf_dev_init(struct rte_eth_dev *eth_dev)
ice_dcf_stats_reset(eth_dev);
 
dcf_config_promisc(adapter, false, false);
+   ice_dcf_vf_repr_notify_all(adapter, true);
+
return 0;
 }
 
 static int
 ice_dcf_dev_uninit(struct rte_eth_dev *eth_dev)
 {
+   struct ice_dcf_adapter *adapter = eth_dev->data->dev_private;
+
+   ice_dcf_free_repr_info(adapter);
ice_dcf_dev_close(eth_dev);
 
return 0;
diff --git a/drivers/net/ice/ice_dcf_ethdev.h b/drivers/net/ice/ice_dcf_ethdev.h
index 4baaec4b8b..6dcbaac5eb 100644
--- a/drivers/net/ice/ice_dcf_ethdev.h
+++ b/drivers/net/ice/ice_dcf_ethdev.h
@@ -60,6 +60,7 @@ struct ice_dcf_vf_repr {
struct rte_ether_addr mac_addr;
uint16_t switch_domain_id;
uint16_t vf_id;
+   bool dcf_valid;
 
struct ice_dcf_vlan outer_vlan_info; /* DCF always handle outer VLAN */
 };
@@ -80,6 +81,8 @@ int ice_dcf_vf_repr_init(struct rte_eth_dev *vf_rep_eth_dev, 
void *init_param);
 int ice_dcf_vf_repr_uninit(struct rte_eth_dev *vf_rep_eth_dev);
 int ice_dcf_vf_repr_init_vlan(struct rte_eth_dev *vf_rep_eth_dev);
 void ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter *dcf_adapter);
+void ice_dcf_vf_repr_notify_all(struct ice_dcf_adapter *dcf_adapter, bool 
valid);
+int ice_dcf_handle_vf_repr_close(struct ice_dcf_adapter *dcf_adapter, uint16_t 
vf_id);
 bool ice_dcf_adminq_need_retry(struct ice_adapter *ad);
 
 #endif /* _ICE_DCF_ETHDEV_H_ */
diff --git a/drivers/net/ice/ice_dcf_vf_representor.c 
b/drivers/net/ice/ice_dcf_vf_representor.c
index b9fcfc80ad..af281f069a 100644
--- a/drivers/net/ice/ice_dcf_vf_representor.c
+++ b/drivers/net/ice/ice_dcf_vf_representor.c
@@ -50,9 +50,28 @@ ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev)
return 0;
 }
 
+static void
+ice_dcf_vf_repr_notify_one(struct rte_eth_dev *dev, bool valid)
+{
+   struct ice_dcf_vf_repr *repr = dev->data->dev_private;
+
+   repr->dcf_valid = valid;
+}
+
 static int
 ice_dcf_vf_repr_dev_close(struct rte_eth_dev *dev)
 {
+   struct ice_dcf_vf_repr *repr = dev->data->dev_private;
+   struct ice_dcf_adapter *dcf_adapter;
+   int err;
+
+   if (repr->dcf_valid) {
+   dcf_adapter = repr->dcf_eth_dev->data->dev_private;
+   err = ice_dcf_handle_vf_repr_close(dcf_adapter, repr->vf_id);
+   if (err)
+   PMD_DRV_LOG(ERR

[PATCH] net/iavf: fix error devargs parsing

2023-11-10 Thread Mingjin Ye
This patch fixes an unknown parsing result without
devarg "no-poll-on-link-down".

Fixes: 5b3124a0a6ef ("net/iavf: support no polling when link down")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 drivers/net/iavf/iavf_ethdev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 0c6ab4ac5a..6448c799e7 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -2294,7 +2294,7 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
struct rte_kvargs *kvlist;
int ret;
int watchdog_period = -1;
-   uint16_t no_poll_on_link_down;
+   int no_poll_on_link_down = -1;
 
if (!devargs)
return 0;
@@ -2329,10 +2329,10 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
ad->devargs.watchdog_period = watchdog_period;
 
ret = rte_kvargs_process(kvlist, IAVF_NO_POLL_ON_LINK_DOWN_ARG,
-&parse_u16, &no_poll_on_link_down);
+&parse_bool, &no_poll_on_link_down);
if (ret)
goto bail;
-   if (no_poll_on_link_down == 0)
+   if (no_poll_on_link_down == -1)
ad->devargs.no_poll_on_link_down = 0;
else
ad->devargs.no_poll_on_link_down = 1;
-- 
2.25.1



[PATCH v5] app/test: secondary process passes allow parameters

2023-11-10 Thread Mingjin Ye
In EAL related test cases, the allow parameters are not passed to
the secondary process, resulting in unexpected NICs being loaded.

This patch fixes this issue by appending the allow parameters to
the secondary process.

Fixes: af75078fece3 ("first public release")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
v5: Optimized.
---
 app/test/process.h | 74 +++---
 1 file changed, 70 insertions(+), 4 deletions(-)

diff --git a/app/test/process.h b/app/test/process.h
index af7bc3e0de..f8beb3c36f 100644
--- a/app/test/process.h
+++ b/app/test/process.h
@@ -18,6 +18,8 @@
 
 #include  /* strlcpy */
 
+#include 
+
 #ifdef RTE_EXEC_ENV_FREEBSD
 #define self "curproc"
 #define exe "file"
@@ -34,6 +36,57 @@ extern uint16_t flag_for_send_pkts;
 #endif
 #endif
 
+#define PREFIX_ALLOW "--allow="
+
+static int
+add_parameter_allow(char **argv, int max_capacity)
+{
+   struct rte_devargs *devargs;
+   int count = 0;
+   char *dev;
+   int malloc_size;
+   int allow_size = strlen(PREFIX_ALLOW);
+   int offset;
+
+   RTE_EAL_DEVARGS_FOREACH(NULL, devargs) {
+   int name_length = 0;
+   int data_length = 0;
+
+   if (count >= max_capacity)
+   return count;
+
+   name_length = strlen(devargs->name);
+   if (name_length == 0)
+   continue;
+
+   if (devargs->data != NULL)
+   data_length = strlen(devargs->data);
+   else
+   data_length = 0;
+
+   malloc_size = allow_size + name_length + data_length + 1;
+   dev = malloc(malloc_size);
+   if (!dev)
+   return count;
+
+   offset = 0;
+   memcpy(dev + offset, PREFIX_ALLOW, allow_size);
+   offset += allow_size;
+   memcpy(dev + offset, devargs->name, name_length);
+   offset += name_length;
+   if (data_length > 0) {
+   memcpy(dev + offset, devargs->data, data_length);
+   offset += data_length;
+   }
+   memset(dev + offset, 0x00, 1);
+
+   *(argv + count) = dev;
+   count++;
+   }
+
+   return count;
+}
+
 /*
  * launches a second copy of the test process using the given argv parameters,
  * which should include argv[0] as the process name. To identify in the
@@ -44,7 +97,9 @@ static inline int
 process_dup(const char *const argv[], int numargs, const char *env_value)
 {
int num;
-   char *argv_cpy[numargs + 1];
+   char **argv_cpy;
+   int allow_num;
+   int argv_num;
int i, status;
char path[32];
 #ifdef RTE_LIB_PDUMP
@@ -58,12 +113,17 @@ process_dup(const char *const argv[], int numargs, const 
char *env_value)
if (pid < 0)
return -1;
else if (pid == 0) {
+   allow_num = rte_devargs_type_count(RTE_DEVTYPE_ALLOWED);
+   argv_num = numargs + allow_num + 1;
+   argv_cpy = malloc(argv_num * sizeof(char *));
/* make a copy of the arguments to be passed to exec */
for (i = 0; i < numargs; i++)
argv_cpy[i] = strdup(argv[i]);
-   argv_cpy[i] = NULL;
-   num = numargs;
-
+   num = add_parameter_allow(&argv_cpy[i], allow_num);
+   if (num != allow_num)
+   rte_panic("Fill allow parameter incomplete\n");
+   num += numargs;
+   argv_cpy[argv_num - 1] = NULL;
 #ifdef RTE_EXEC_ENV_LINUX
{
const char *procdir = "/proc/" self "/fd/";
@@ -131,6 +191,12 @@ process_dup(const char *const argv[], int numargs, const 
char *env_value)
}
rte_panic("Cannot exec: %s\n", strerror(errno));
}
+
+   for (i = 0; i < num; i++) {
+   if (argv_cpy[i] != NULL)
+   free(argv_cpy[i]);
+   }
+   free(argv_cpy);
}
/* parent process does a wait */
 #ifdef RTE_LIB_PDUMP
-- 
2.25.1



[PATCH v6] app/test: secondary process passes allow parameters

2023-11-13 Thread Mingjin Ye
In EAL related test cases, the allow parameters are not passed to
the secondary process, resulting in unexpected NICs being loaded.

This patch fixes this issue by appending the allow parameters to
the secondary process.

Fixes: af75078fece3 ("first public release")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
v5: Optimized.
---
v6: Optimized.
---
 app/test/process.h | 52 +++---
 1 file changed, 49 insertions(+), 3 deletions(-)

diff --git a/app/test/process.h b/app/test/process.h
index af7bc3e0de..cd3603b7bb 100644
--- a/app/test/process.h
+++ b/app/test/process.h
@@ -18,6 +18,8 @@
 
 #include  /* strlcpy */
 
+#include 
+
 #ifdef RTE_EXEC_ENV_FREEBSD
 #define self "curproc"
 #define exe "file"
@@ -34,6 +36,34 @@ extern uint16_t flag_for_send_pkts;
 #endif
 #endif
 
+#define PREFIX_ALLOW "--allow="
+
+static int
+add_parameter_allow(char **argv, int max_capacity)
+{
+   struct rte_devargs *devargs;
+   int count = 0;
+
+   RTE_EAL_DEVARGS_FOREACH(NULL, devargs) {
+   if (strlen(devargs->name) == 0)
+   continue;
+
+   if (strlen(devargs->data) == 0) {
+   if (asprintf(&argv[count], PREFIX_ALLOW"%s", 
devargs->name) < 0)
+   break;
+   } else {
+   if (asprintf(&argv[count], PREFIX_ALLOW"%s,%s",
+devargs->name, devargs->data) < 0)
+   break;
+   }
+
+   if (++count == max_capacity)
+   break;
+   }
+
+   return count;
+}
+
 /*
  * launches a second copy of the test process using the given argv parameters,
  * which should include argv[0] as the process name. To identify in the
@@ -44,7 +74,9 @@ static inline int
 process_dup(const char *const argv[], int numargs, const char *env_value)
 {
int num;
-   char *argv_cpy[numargs + 1];
+   char **argv_cpy;
+   int allow_num;
+   int argv_num;
int i, status;
char path[32];
 #ifdef RTE_LIB_PDUMP
@@ -58,12 +90,21 @@ process_dup(const char *const argv[], int numargs, const 
char *env_value)
if (pid < 0)
return -1;
else if (pid == 0) {
+   allow_num = rte_devargs_type_count(RTE_DEVTYPE_ALLOWED);
+   argv_num = numargs + allow_num + 1;
+   argv_cpy = malloc(argv_num * sizeof(char *));
+   if (!argv_cpy)
+   rte_panic("Memory allocation failed\n");
+
/* make a copy of the arguments to be passed to exec */
for (i = 0; i < numargs; i++)
argv_cpy[i] = strdup(argv[i]);
-   argv_cpy[i] = NULL;
-   num = numargs;
+   num = add_parameter_allow(&argv_cpy[i], allow_num);
+   if (num != allow_num)
+   rte_panic("Fill allow parameter incomplete\n");
 
+   num += numargs;
+   argv_cpy[argv_num - 1] = NULL;
 #ifdef RTE_EXEC_ENV_LINUX
{
const char *procdir = "/proc/" self "/fd/";
@@ -131,6 +172,11 @@ process_dup(const char *const argv[], int numargs, const 
char *env_value)
}
rte_panic("Cannot exec: %s\n", strerror(errno));
}
+
+   for (i = 0; i < num; i++)
+   free(argv_cpy[i]);
+
+   free(argv_cpy);
}
/* parent process does a wait */
 #ifdef RTE_LIB_PDUMP
-- 
2.25.1



[PATCH] net/iavf: fix error devargs parsing

2023-11-13 Thread Mingjin Ye
This patch fixes an unknown parsing result without
devarg "no-poll-on-link-down".

Fixes: 5b3124a0a6ef ("net/iavf: support no polling when link down")
Cc: sta...@dpdk.org

Signed-off-by: Mingjin Ye 
---
 drivers/net/iavf/iavf_ethdev.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 0c6ab4ac5a..d1edb0dd5c 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -2294,7 +2294,6 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
struct rte_kvargs *kvlist;
int ret;
int watchdog_period = -1;
-   uint16_t no_poll_on_link_down;
 
if (!devargs)
return 0;
@@ -2329,13 +2328,9 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
ad->devargs.watchdog_period = watchdog_period;
 
ret = rte_kvargs_process(kvlist, IAVF_NO_POLL_ON_LINK_DOWN_ARG,
-&parse_u16, &no_poll_on_link_down);
+&parse_bool, 
&ad->devargs.no_poll_on_link_down);
if (ret)
goto bail;
-   if (no_poll_on_link_down == 0)
-   ad->devargs.no_poll_on_link_down = 0;
-   else
-   ad->devargs.no_poll_on_link_down = 1;
 
if (ad->devargs.quanta_size != 0 &&
(ad->devargs.quanta_size < 256 || ad->devargs.quanta_size > 4096 ||
-- 
2.25.1



  1   2   3   >