DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] net/iavf: support Tx LLDP on scalar and AVX512
@ 2023-12-06  6:08 Zhichao Zeng
  2023-12-14  6:58 ` [PATCH v2 0/3] " Zhichao Zeng
  0 siblings, 1 reply; 27+ messages in thread
From: Zhichao Zeng @ 2023-12-06  6:08 UTC (permalink / raw)
  To: dev
  Cc: qi.z.zhang, Zhichao Zeng, Jingjing Wu, Beilei Xing,
	Bruce Richardson, Konstantin Ananyev

This patch adds a testpmd command "set tx lldp on" which will register
an mbuf dynflag at the application level, currently only supported on.

The IAVF will fills the SWTCH_UPLINK bit in the Tx context descriptor
based on the mbuf dynflag to send the LLDP packets.

For avx512, need to close the Tx port first, then "set tx lldp on",
and reopen the port to select correct path.

Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
 doc/guides/rel_notes/release_24_03.rst  |  3 ++
 drivers/net/iavf/iavf_rxtx.c            | 10 ++++
 drivers/net/iavf/iavf_rxtx.h            |  3 ++
 drivers/net/iavf/iavf_rxtx_vec_avx512.c | 17 +++++++
 drivers/net/iavf/iavf_rxtx_vec_common.h |  6 +++
 drivers/net/iavf/iavf_testpmd.c         | 68 +++++++++++++++++++++++++
 drivers/net/iavf/meson.build            |  3 ++
 drivers/net/iavf/rte_pmd_iavf.h         |  2 +
 8 files changed, 112 insertions(+)
 create mode 100644 drivers/net/iavf/iavf_testpmd.c

diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst
index e9c9717706..46576f62fe 100644
--- a/doc/guides/rel_notes/release_24_03.rst
+++ b/doc/guides/rel_notes/release_24_03.rst
@@ -55,6 +55,9 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Updated Intel iavf driver.**
+
+  * Added support for Tx LLDP packet on scalar and avx512.
 
 Removed Items
 -------------
diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index f19aa14646..a588b769a8 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -2427,6 +2427,8 @@ iavf_calc_context_desc(uint64_t flags, uint8_t vlan_flag)
 	if (flags & RTE_MBUF_F_TX_VLAN &&
 	    vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2)
 		return 1;
+	if (rte_mbuf_dynflag_lookup(IAVF_TX_LLDP_DYNFLAG, NULL) > 0)
+		return 1;
 	return 0;
 }
 
@@ -2445,6 +2447,9 @@ iavf_fill_ctx_desc_cmd_field(volatile uint64_t *field, struct rte_mbuf *m,
 		cmd |= IAVF_TX_CTX_DESC_IL2TAG2
 			<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 	}
+	if (rte_mbuf_dynflag_lookup(IAVF_TX_LLDP_DYNFLAG, NULL) > 0)
+		cmd |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+			<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 
 	*field |= cmd;
 }
@@ -4039,6 +4044,11 @@ iavf_set_tx_function(struct rte_eth_dev *dev)
 				dev->tx_pkt_prepare = iavf_prep_pkts;
 				PMD_DRV_LOG(DEBUG, "Using AVX512 OFFLOAD Vector Tx (port %d).",
 					    dev->data->port_id);
+			} else if (check_ret == IAVF_VECTOR_CTX_PATH) {
+				dev->tx_pkt_burst = iavf_xmit_pkts_vec_avx512_ctx;
+				dev->tx_pkt_prepare = iavf_prep_pkts;
+				PMD_DRV_LOG(DEBUG, "Using AVX512 CONTEXT Vector Tx (port %d).",
+					    dev->data->port_id);
 			} else {
 				dev->tx_pkt_burst = iavf_xmit_pkts_vec_avx512_ctx_offload;
 				dev->tx_pkt_prepare = iavf_prep_pkts;
diff --git a/drivers/net/iavf/iavf_rxtx.h b/drivers/net/iavf/iavf_rxtx.h
index f432f9d956..ee52864915 100644
--- a/drivers/net/iavf/iavf_rxtx.h
+++ b/drivers/net/iavf/iavf_rxtx.h
@@ -66,6 +66,7 @@
 #define IAVF_VECTOR_PATH 0
 #define IAVF_VECTOR_OFFLOAD_PATH 1
 #define IAVF_VECTOR_CTX_OFFLOAD_PATH 2
+#define IAVF_VECTOR_CTX_PATH 3
 
 #define DEFAULT_TX_RS_THRESH     32
 #define DEFAULT_TX_FREE_THRESH   32
@@ -752,6 +753,8 @@ uint16_t iavf_xmit_pkts_vec_avx512_offload(void *tx_queue,
 					   uint16_t nb_pkts);
 uint16_t iavf_xmit_pkts_vec_avx512_ctx_offload(void *tx_queue, struct rte_mbuf **tx_pkts,
 				  uint16_t nb_pkts);
+uint16_t iavf_xmit_pkts_vec_avx512_ctx(void *tx_queue, struct rte_mbuf **tx_pkts,
+				  uint16_t nb_pkts);
 int iavf_txq_vec_setup_avx512(struct iavf_tx_queue *txq);
 
 uint8_t iavf_proto_xtr_type_to_rxdid(uint8_t xtr_type);
diff --git a/drivers/net/iavf/iavf_rxtx_vec_avx512.c b/drivers/net/iavf/iavf_rxtx_vec_avx512.c
index 7a7df6d258..dc3354f331 100644
--- a/drivers/net/iavf/iavf_rxtx_vec_avx512.c
+++ b/drivers/net/iavf/iavf_rxtx_vec_avx512.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2020 Intel Corporation
  */
 
+#include "rte_pmd_iavf.h"
 #include "iavf_rxtx_vec_common.h"
 
 #include <rte_vect.h>
@@ -2206,6 +2207,9 @@ ctx_vtx1(volatile struct iavf_tx_desc *txdp, struct rte_mbuf *pkt,
 			low_ctx_qw |= (uint64_t)pkt->vlan_tci << IAVF_TXD_CTX_QW0_L2TAG2_PARAM;
 		}
 	}
+	if (rte_mbuf_dynflag_lookup(IAVF_TX_LLDP_DYNFLAG, NULL) > 0)
+		high_ctx_qw |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+			<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 	uint64_t high_data_qw = (IAVF_TX_DESC_DTYPE_DATA |
 				((uint64_t)flags  << IAVF_TXD_QW1_CMD_SHIFT) |
 				((uint64_t)pkt->data_len << IAVF_TXD_QW1_TX_BUF_SZ_SHIFT));
@@ -2258,6 +2262,9 @@ ctx_vtx(volatile struct iavf_tx_desc *txdp,
 					(uint64_t)pkt[1]->vlan_tci << IAVF_TXD_QW1_L2TAG1_SHIFT;
 			}
 		}
+		if (rte_mbuf_dynflag_lookup(IAVF_TX_LLDP_DYNFLAG, NULL) > 0)
+			hi_ctx_qw1 |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+				<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 
 		if (pkt[0]->ol_flags & RTE_MBUF_F_TX_VLAN) {
 			if (vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2) {
@@ -2270,6 +2277,9 @@ ctx_vtx(volatile struct iavf_tx_desc *txdp,
 					(uint64_t)pkt[0]->vlan_tci << IAVF_TXD_QW1_L2TAG1_SHIFT;
 			}
 		}
+		if (rte_mbuf_dynflag_lookup(IAVF_TX_LLDP_DYNFLAG, NULL) > 0)
+			hi_ctx_qw0 |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+				<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 
 		if (offload) {
 			iavf_txd_enable_offload(pkt[1], &hi_data_qw1);
@@ -2520,3 +2530,10 @@ iavf_xmit_pkts_vec_avx512_ctx_offload(void *tx_queue, struct rte_mbuf **tx_pkts,
 {
 	return iavf_xmit_pkts_vec_avx512_ctx_cmn(tx_queue, tx_pkts, nb_pkts, true);
 }
+
+uint16_t
+iavf_xmit_pkts_vec_avx512_ctx(void *tx_queue, struct rte_mbuf **tx_pkts,
+				  uint16_t nb_pkts)
+{
+	return iavf_xmit_pkts_vec_avx512_ctx_cmn(tx_queue, tx_pkts, nb_pkts, false);
+}
diff --git a/drivers/net/iavf/iavf_rxtx_vec_common.h b/drivers/net/iavf/iavf_rxtx_vec_common.h
index e18cdc3f11..87e1d6c306 100644
--- a/drivers/net/iavf/iavf_rxtx_vec_common.h
+++ b/drivers/net/iavf/iavf_rxtx_vec_common.h
@@ -10,6 +10,7 @@
 
 #include "iavf.h"
 #include "iavf_rxtx.h"
+#include "rte_pmd_iavf.h"
 
 #ifndef __INTEL_COMPILER
 #pragma GCC diagnostic ignored "-Wcast-qual"
@@ -249,6 +250,11 @@ iavf_tx_vec_queue_default(struct iavf_tx_queue *txq)
 	if (txq->offloads & IAVF_TX_NO_VECTOR_FLAGS)
 		return -1;
 
+	if (rte_mbuf_dynflag_lookup(IAVF_TX_LLDP_DYNFLAG, NULL) > 0) {
+		txq->use_ctx = 1;
+		return IAVF_VECTOR_CTX_PATH;
+	}
+
 	/**
 	 * Vlan tci needs to be inserted via ctx desc, if the vlan_flag is L2TAG2.
 	 * Tunneling parameters and other fields need be configured in ctx desc
diff --git a/drivers/net/iavf/iavf_testpmd.c b/drivers/net/iavf/iavf_testpmd.c
new file mode 100644
index 0000000000..11788ac69e
--- /dev/null
+++ b/drivers/net/iavf/iavf_testpmd.c
@@ -0,0 +1,68 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2016 Intel Corporation.
+ */
+
+#include <stdlib.h>
+
+#include <rte_pmd_iavf.h>
+
+#include <cmdline_parse_num.h>
+#include <cmdline_parse_string.h>
+
+#include "testpmd.h"
+
+struct cmd_enable_tx_lldp_result {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t tx;
+	cmdline_fixed_string_t lldp;
+	cmdline_fixed_string_t what;
+};
+
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_set =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		set, "set");
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_tx =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		tx, "tx");
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_lldp =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		lldp, "lldp");
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_what =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		what, "on#off");
+
+static void
+cmd_enable_tx_lldp_parsed(void *parsed_result,
+	__rte_unused struct cmdline *cl, __rte_unused void *data)
+{
+	struct cmd_enable_tx_lldp_result *res = parsed_result;
+	const struct rte_mbuf_dynflag iavf_tx_lldp = { .name = { IAVF_TX_LLDP_DYNFLAG } };
+
+	if (strcmp(res->what, "on") == 0)
+		rte_mbuf_dynflag_register(&iavf_tx_lldp);
+}
+
+static cmdline_parse_inst_t cmd_enable_tx_lldp = {
+	.f = cmd_enable_tx_lldp_parsed,
+	.data = NULL,
+	.help_str = "set iavf tx lldp on|off",
+	.tokens = {
+		(void *)&cmd_enable_tx_lldp_set,
+		(void *)&cmd_enable_tx_lldp_tx,
+		(void *)&cmd_enable_tx_lldp_lldp,
+		(void *)&cmd_enable_tx_lldp_what,
+		NULL,
+	},
+};
+
+static struct testpmd_driver_commands iavf_cmds = {
+	.commands = {
+	{
+		&cmd_enable_tx_lldp,
+		"set tx lldp (on|off)\n"
+		"    Set iavf Tx lldp packet(currently only supported on)\n\n",
+	},
+	{ NULL, NULL },
+	},
+};
+TESTPMD_ADD_DRIVER_COMMANDS(iavf_cmds)
diff --git a/drivers/net/iavf/meson.build b/drivers/net/iavf/meson.build
index a6ce2725c3..83aebd5596 100644
--- a/drivers/net/iavf/meson.build
+++ b/drivers/net/iavf/meson.build
@@ -8,6 +8,9 @@ endif
 cflags += ['-Wno-strict-aliasing']
 
 includes += include_directories('../../common/iavf')
+
+testpmd_sources = files('iavf_testpmd.c')
+
 deps += ['common_iavf', 'security', 'cryptodev']
 
 sources = files(
diff --git a/drivers/net/iavf/rte_pmd_iavf.h b/drivers/net/iavf/rte_pmd_iavf.h
index 56d453fc4c..2c442b6a05 100644
--- a/drivers/net/iavf/rte_pmd_iavf.h
+++ b/drivers/net/iavf/rte_pmd_iavf.h
@@ -23,6 +23,8 @@
 extern "C" {
 #endif
 
+#define IAVF_TX_LLDP_DYNFLAG "intel_pmd_dynflag_tx_lldp"
+
 /**
  * The supported network flexible descriptor's extraction metadata format.
  */
-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v2 0/3] net/iavf: support Tx LLDP on scalar and AVX512
  2023-12-06  6:08 [PATCH] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
@ 2023-12-14  6:58 ` Zhichao Zeng
  2023-12-14  6:58   ` [PATCH v2 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
                     ` (3 more replies)
  0 siblings, 4 replies; 27+ messages in thread
From: Zhichao Zeng @ 2023-12-14  6:58 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, Zhichao Zeng

This patch set adds an IAVF testpmd command "set tx lldp on|off" which
will register an mbuf dynflag IAVF_TX_LLDP_DYNFLAG at the application
level, currently only supported turning on.

IAVF will fill the SWTCH_UPLINK bit in the Tx context descriptor based on
the mbuf dynflag to send the LLDP packet.

For avx512, need to close the Tx port first, then "set tx lldp on", and
reopen the port to select correct Tx path.

---
v2: split into patch set, refine commit log

Zhichao Zeng (3):
  net/iavf: support Tx LLDP on scalar
  net/iavf: support Tx LLDP on AVX512
  net/iavf: add Tx LLDP command

 doc/guides/rel_notes/release_24_03.rst  |  3 ++
 drivers/net/iavf/iavf_rxtx.c            | 10 ++++
 drivers/net/iavf/iavf_rxtx.h            |  3 ++
 drivers/net/iavf/iavf_rxtx_vec_avx512.c | 17 +++++++
 drivers/net/iavf/iavf_rxtx_vec_common.h |  6 +++
 drivers/net/iavf/iavf_testpmd.c         | 68 +++++++++++++++++++++++++
 drivers/net/iavf/meson.build            |  3 ++
 drivers/net/iavf/rte_pmd_iavf.h         |  2 +
 8 files changed, 112 insertions(+)
 create mode 100644 drivers/net/iavf/iavf_testpmd.c

-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v2 1/3] net/iavf: support Tx LLDP on scalar
  2023-12-14  6:58 ` [PATCH v2 0/3] " Zhichao Zeng
@ 2023-12-14  6:58   ` Zhichao Zeng
  2023-12-14  6:58   ` [PATCH v2 2/3] net/iavf: support Tx LLDP on AVX512 Zhichao Zeng
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 27+ messages in thread
From: Zhichao Zeng @ 2023-12-14  6:58 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, Zhichao Zeng, Jingjing Wu, Beilei Xing

This patch adds an mbuf dynflag IAVF_TX_LLDP_DYNFLAG to determine
whether or not to fill the SWTCH_UPLINK bit in the Tx context descriptor
to send LLDP packet.

Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
 drivers/net/iavf/iavf_rxtx.c    | 5 +++++
 drivers/net/iavf/rte_pmd_iavf.h | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index f19aa14646..c986fa944a 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -2427,6 +2427,8 @@ iavf_calc_context_desc(uint64_t flags, uint8_t vlan_flag)
 	if (flags & RTE_MBUF_F_TX_VLAN &&
 	    vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2)
 		return 1;
+	if (rte_mbuf_dynflag_lookup(IAVF_TX_LLDP_DYNFLAG, NULL) > 0)
+		return 1;
 	return 0;
 }
 
@@ -2445,6 +2447,9 @@ iavf_fill_ctx_desc_cmd_field(volatile uint64_t *field, struct rte_mbuf *m,
 		cmd |= IAVF_TX_CTX_DESC_IL2TAG2
 			<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 	}
+	if (rte_mbuf_dynflag_lookup(IAVF_TX_LLDP_DYNFLAG, NULL) > 0)
+		cmd |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+			<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 
 	*field |= cmd;
 }
diff --git a/drivers/net/iavf/rte_pmd_iavf.h b/drivers/net/iavf/rte_pmd_iavf.h
index 56d453fc4c..2c442b6a05 100644
--- a/drivers/net/iavf/rte_pmd_iavf.h
+++ b/drivers/net/iavf/rte_pmd_iavf.h
@@ -23,6 +23,8 @@
 extern "C" {
 #endif
 
+#define IAVF_TX_LLDP_DYNFLAG "intel_pmd_dynflag_tx_lldp"
+
 /**
  * The supported network flexible descriptor's extraction metadata format.
  */
-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v2 2/3] net/iavf: support Tx LLDP on AVX512
  2023-12-14  6:58 ` [PATCH v2 0/3] " Zhichao Zeng
  2023-12-14  6:58   ` [PATCH v2 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
@ 2023-12-14  6:58   ` Zhichao Zeng
  2023-12-14  6:58   ` [PATCH v2 3/3] net/iavf: add Tx LLDP command Zhichao Zeng
  2023-12-20  9:32   ` [PATCH v3 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
  3 siblings, 0 replies; 27+ messages in thread
From: Zhichao Zeng @ 2023-12-14  6:58 UTC (permalink / raw)
  To: dev
  Cc: qi.z.zhang, Zhichao Zeng, Jingjing Wu, Beilei Xing,
	Bruce Richardson, Konstantin Ananyev

This patch adds an avx512 ctx Tx path that supports context descriptor,
filling in the SWTCH_UPLINK bit based on mbuf dynflag IAVF_TX_LLDP_DYNFLAG
to support sending LLDP packet.

Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
 drivers/net/iavf/iavf_rxtx.c            |  5 +++++
 drivers/net/iavf/iavf_rxtx.h            |  3 +++
 drivers/net/iavf/iavf_rxtx_vec_avx512.c | 17 +++++++++++++++++
 drivers/net/iavf/iavf_rxtx_vec_common.h |  6 ++++++
 4 files changed, 31 insertions(+)

diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index c986fa944a..a588b769a8 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -4044,6 +4044,11 @@ iavf_set_tx_function(struct rte_eth_dev *dev)
 				dev->tx_pkt_prepare = iavf_prep_pkts;
 				PMD_DRV_LOG(DEBUG, "Using AVX512 OFFLOAD Vector Tx (port %d).",
 					    dev->data->port_id);
+			} else if (check_ret == IAVF_VECTOR_CTX_PATH) {
+				dev->tx_pkt_burst = iavf_xmit_pkts_vec_avx512_ctx;
+				dev->tx_pkt_prepare = iavf_prep_pkts;
+				PMD_DRV_LOG(DEBUG, "Using AVX512 CONTEXT Vector Tx (port %d).",
+					    dev->data->port_id);
 			} else {
 				dev->tx_pkt_burst = iavf_xmit_pkts_vec_avx512_ctx_offload;
 				dev->tx_pkt_prepare = iavf_prep_pkts;
diff --git a/drivers/net/iavf/iavf_rxtx.h b/drivers/net/iavf/iavf_rxtx.h
index f432f9d956..ee52864915 100644
--- a/drivers/net/iavf/iavf_rxtx.h
+++ b/drivers/net/iavf/iavf_rxtx.h
@@ -66,6 +66,7 @@
 #define IAVF_VECTOR_PATH 0
 #define IAVF_VECTOR_OFFLOAD_PATH 1
 #define IAVF_VECTOR_CTX_OFFLOAD_PATH 2
+#define IAVF_VECTOR_CTX_PATH 3
 
 #define DEFAULT_TX_RS_THRESH     32
 #define DEFAULT_TX_FREE_THRESH   32
@@ -752,6 +753,8 @@ uint16_t iavf_xmit_pkts_vec_avx512_offload(void *tx_queue,
 					   uint16_t nb_pkts);
 uint16_t iavf_xmit_pkts_vec_avx512_ctx_offload(void *tx_queue, struct rte_mbuf **tx_pkts,
 				  uint16_t nb_pkts);
+uint16_t iavf_xmit_pkts_vec_avx512_ctx(void *tx_queue, struct rte_mbuf **tx_pkts,
+				  uint16_t nb_pkts);
 int iavf_txq_vec_setup_avx512(struct iavf_tx_queue *txq);
 
 uint8_t iavf_proto_xtr_type_to_rxdid(uint8_t xtr_type);
diff --git a/drivers/net/iavf/iavf_rxtx_vec_avx512.c b/drivers/net/iavf/iavf_rxtx_vec_avx512.c
index 7a7df6d258..dc3354f331 100644
--- a/drivers/net/iavf/iavf_rxtx_vec_avx512.c
+++ b/drivers/net/iavf/iavf_rxtx_vec_avx512.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2020 Intel Corporation
  */
 
+#include "rte_pmd_iavf.h"
 #include "iavf_rxtx_vec_common.h"
 
 #include <rte_vect.h>
@@ -2206,6 +2207,9 @@ ctx_vtx1(volatile struct iavf_tx_desc *txdp, struct rte_mbuf *pkt,
 			low_ctx_qw |= (uint64_t)pkt->vlan_tci << IAVF_TXD_CTX_QW0_L2TAG2_PARAM;
 		}
 	}
+	if (rte_mbuf_dynflag_lookup(IAVF_TX_LLDP_DYNFLAG, NULL) > 0)
+		high_ctx_qw |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+			<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 	uint64_t high_data_qw = (IAVF_TX_DESC_DTYPE_DATA |
 				((uint64_t)flags  << IAVF_TXD_QW1_CMD_SHIFT) |
 				((uint64_t)pkt->data_len << IAVF_TXD_QW1_TX_BUF_SZ_SHIFT));
@@ -2258,6 +2262,9 @@ ctx_vtx(volatile struct iavf_tx_desc *txdp,
 					(uint64_t)pkt[1]->vlan_tci << IAVF_TXD_QW1_L2TAG1_SHIFT;
 			}
 		}
+		if (rte_mbuf_dynflag_lookup(IAVF_TX_LLDP_DYNFLAG, NULL) > 0)
+			hi_ctx_qw1 |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+				<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 
 		if (pkt[0]->ol_flags & RTE_MBUF_F_TX_VLAN) {
 			if (vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2) {
@@ -2270,6 +2277,9 @@ ctx_vtx(volatile struct iavf_tx_desc *txdp,
 					(uint64_t)pkt[0]->vlan_tci << IAVF_TXD_QW1_L2TAG1_SHIFT;
 			}
 		}
+		if (rte_mbuf_dynflag_lookup(IAVF_TX_LLDP_DYNFLAG, NULL) > 0)
+			hi_ctx_qw0 |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+				<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 
 		if (offload) {
 			iavf_txd_enable_offload(pkt[1], &hi_data_qw1);
@@ -2520,3 +2530,10 @@ iavf_xmit_pkts_vec_avx512_ctx_offload(void *tx_queue, struct rte_mbuf **tx_pkts,
 {
 	return iavf_xmit_pkts_vec_avx512_ctx_cmn(tx_queue, tx_pkts, nb_pkts, true);
 }
+
+uint16_t
+iavf_xmit_pkts_vec_avx512_ctx(void *tx_queue, struct rte_mbuf **tx_pkts,
+				  uint16_t nb_pkts)
+{
+	return iavf_xmit_pkts_vec_avx512_ctx_cmn(tx_queue, tx_pkts, nb_pkts, false);
+}
diff --git a/drivers/net/iavf/iavf_rxtx_vec_common.h b/drivers/net/iavf/iavf_rxtx_vec_common.h
index e18cdc3f11..87e1d6c306 100644
--- a/drivers/net/iavf/iavf_rxtx_vec_common.h
+++ b/drivers/net/iavf/iavf_rxtx_vec_common.h
@@ -10,6 +10,7 @@
 
 #include "iavf.h"
 #include "iavf_rxtx.h"
+#include "rte_pmd_iavf.h"
 
 #ifndef __INTEL_COMPILER
 #pragma GCC diagnostic ignored "-Wcast-qual"
@@ -249,6 +250,11 @@ iavf_tx_vec_queue_default(struct iavf_tx_queue *txq)
 	if (txq->offloads & IAVF_TX_NO_VECTOR_FLAGS)
 		return -1;
 
+	if (rte_mbuf_dynflag_lookup(IAVF_TX_LLDP_DYNFLAG, NULL) > 0) {
+		txq->use_ctx = 1;
+		return IAVF_VECTOR_CTX_PATH;
+	}
+
 	/**
 	 * Vlan tci needs to be inserted via ctx desc, if the vlan_flag is L2TAG2.
 	 * Tunneling parameters and other fields need be configured in ctx desc
-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v2 3/3] net/iavf: add Tx LLDP command
  2023-12-14  6:58 ` [PATCH v2 0/3] " Zhichao Zeng
  2023-12-14  6:58   ` [PATCH v2 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
  2023-12-14  6:58   ` [PATCH v2 2/3] net/iavf: support Tx LLDP on AVX512 Zhichao Zeng
@ 2023-12-14  6:58   ` Zhichao Zeng
  2023-12-20  9:32   ` [PATCH v3 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
  3 siblings, 0 replies; 27+ messages in thread
From: Zhichao Zeng @ 2023-12-14  6:58 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, Zhichao Zeng, Jingjing Wu, Beilei Xing

This patch adds an IAVF testpmd command "set tx lldp on|off" which
will register an mbuf dynflag IAVF_TX_LLDP_DYNFLAG at the application
level to indicate the need to send LLDP packet. Currently, it only
supports turning on.

For avx512, need to close the Tx port first, then "set tx lldp on",
and reopen the port to select correct Tx path.

Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
 doc/guides/rel_notes/release_24_03.rst |  3 ++
 drivers/net/iavf/iavf_testpmd.c        | 68 ++++++++++++++++++++++++++
 drivers/net/iavf/meson.build           |  3 ++
 3 files changed, 74 insertions(+)
 create mode 100644 drivers/net/iavf/iavf_testpmd.c

diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst
index e9c9717706..46576f62fe 100644
--- a/doc/guides/rel_notes/release_24_03.rst
+++ b/doc/guides/rel_notes/release_24_03.rst
@@ -55,6 +55,9 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Updated Intel iavf driver.**
+
+  * Added support for Tx LLDP packet on scalar and avx512.
 
 Removed Items
 -------------
diff --git a/drivers/net/iavf/iavf_testpmd.c b/drivers/net/iavf/iavf_testpmd.c
new file mode 100644
index 0000000000..11788ac69e
--- /dev/null
+++ b/drivers/net/iavf/iavf_testpmd.c
@@ -0,0 +1,68 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2016 Intel Corporation.
+ */
+
+#include <stdlib.h>
+
+#include <rte_pmd_iavf.h>
+
+#include <cmdline_parse_num.h>
+#include <cmdline_parse_string.h>
+
+#include "testpmd.h"
+
+struct cmd_enable_tx_lldp_result {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t tx;
+	cmdline_fixed_string_t lldp;
+	cmdline_fixed_string_t what;
+};
+
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_set =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		set, "set");
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_tx =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		tx, "tx");
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_lldp =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		lldp, "lldp");
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_what =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		what, "on#off");
+
+static void
+cmd_enable_tx_lldp_parsed(void *parsed_result,
+	__rte_unused struct cmdline *cl, __rte_unused void *data)
+{
+	struct cmd_enable_tx_lldp_result *res = parsed_result;
+	const struct rte_mbuf_dynflag iavf_tx_lldp = { .name = { IAVF_TX_LLDP_DYNFLAG } };
+
+	if (strcmp(res->what, "on") == 0)
+		rte_mbuf_dynflag_register(&iavf_tx_lldp);
+}
+
+static cmdline_parse_inst_t cmd_enable_tx_lldp = {
+	.f = cmd_enable_tx_lldp_parsed,
+	.data = NULL,
+	.help_str = "set iavf tx lldp on|off",
+	.tokens = {
+		(void *)&cmd_enable_tx_lldp_set,
+		(void *)&cmd_enable_tx_lldp_tx,
+		(void *)&cmd_enable_tx_lldp_lldp,
+		(void *)&cmd_enable_tx_lldp_what,
+		NULL,
+	},
+};
+
+static struct testpmd_driver_commands iavf_cmds = {
+	.commands = {
+	{
+		&cmd_enable_tx_lldp,
+		"set tx lldp (on|off)\n"
+		"    Set iavf Tx lldp packet(currently only supported on)\n\n",
+	},
+	{ NULL, NULL },
+	},
+};
+TESTPMD_ADD_DRIVER_COMMANDS(iavf_cmds)
diff --git a/drivers/net/iavf/meson.build b/drivers/net/iavf/meson.build
index a6ce2725c3..83aebd5596 100644
--- a/drivers/net/iavf/meson.build
+++ b/drivers/net/iavf/meson.build
@@ -8,6 +8,9 @@ endif
 cflags += ['-Wno-strict-aliasing']
 
 includes += include_directories('../../common/iavf')
+
+testpmd_sources = files('iavf_testpmd.c')
+
 deps += ['common_iavf', 'security', 'cryptodev']
 
 sources = files(
-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v3 0/3] net/iavf: support Tx LLDP on scalar and AVX512
  2023-12-14  6:58 ` [PATCH v2 0/3] " Zhichao Zeng
                     ` (2 preceding siblings ...)
  2023-12-14  6:58   ` [PATCH v2 3/3] net/iavf: add Tx LLDP command Zhichao Zeng
@ 2023-12-20  9:32   ` Zhichao Zeng
  2023-12-20  9:32     ` [PATCH v3 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
                       ` (2 more replies)
  3 siblings, 3 replies; 27+ messages in thread
From: Zhichao Zeng @ 2023-12-20  9:32 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, Zhichao Zeng

This patch set adds an IAVF testpmd command "set tx lldp on|off" which
will register an mbuf dynfield IAVF_TX_LLDP_DYNFIELD, currently only
supported turning on.

IAVF will fill the SWTCH_UPLINK bit in the Tx context descriptor based on
the mbuf dynfield to send the LLDP packet.

For avx512, need to close the Tx port first, then "set tx lldp on", and
reopen the port to select correct Tx path.

---
v3: non-lldp packet do not use the context descriptor
v2: split into patch set, refine commit log

Zhichao Zeng (3):
  net/iavf: support Tx LLDP on scalar
  net/iavf: support Tx LLDP on AVX512
  net/iavf: add Tx LLDP command

 doc/guides/rel_notes/release_24_03.rst  |  3 +
 drivers/net/iavf/iavf_rxtx.c            | 23 ++++++-
 drivers/net/iavf/iavf_rxtx.h            |  3 +
 drivers/net/iavf/iavf_rxtx_vec_avx512.c | 20 +++++++
 drivers/net/iavf/iavf_rxtx_vec_common.h |  6 ++
 drivers/net/iavf/iavf_testpmd.c         | 80 +++++++++++++++++++++++++
 drivers/net/iavf/meson.build            |  3 +
 drivers/net/iavf/rte_pmd_iavf.h         |  4 ++
 8 files changed, 140 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/iavf/iavf_testpmd.c

-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v3 1/3] net/iavf: support Tx LLDP on scalar
  2023-12-20  9:32   ` [PATCH v3 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
@ 2023-12-20  9:32     ` Zhichao Zeng
  2023-12-21  7:28       ` [PATCH v4 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
  2023-12-20  9:32     ` [PATCH v3 2/3] net/iavf: support Tx LLDP on AVX512 Zhichao Zeng
  2023-12-20  9:32     ` [PATCH v3 3/3] net/iavf: add Tx LLDP command Zhichao Zeng
  2 siblings, 1 reply; 27+ messages in thread
From: Zhichao Zeng @ 2023-12-20  9:32 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, Zhichao Zeng, Jingjing Wu, Beilei Xing

This patch adds an mbuf dynfield IAVF_TX_LLDP_DYNFIELD to determine
whether or not to fill the SWTCH_UPLINK bit in the Tx context descriptor
to send LLDP packet.

Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
 drivers/net/iavf/iavf_rxtx.c    | 18 ++++++++++++++++--
 drivers/net/iavf/rte_pmd_iavf.h |  4 ++++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index f19aa14646..2ecd8637c5 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -85,6 +85,8 @@ uint64_t rte_pmd_ifd_dynflag_proto_xtr_tcp_mask;
 uint64_t rte_pmd_ifd_dynflag_proto_xtr_ip_offset_mask;
 uint64_t rte_pmd_ifd_dynflag_proto_xtr_ipsec_crypto_said_mask;
 
+int iavf_tx_lldp_dynfield_offset = -1;
+
 uint8_t
 iavf_proto_xtr_type_to_rxdid(uint8_t flex_type)
 {
@@ -2418,8 +2420,9 @@ iavf_xmit_cleanup(struct iavf_tx_queue *txq)
 
 /* Check if the context descriptor is needed for TX offloading */
 static inline uint16_t
-iavf_calc_context_desc(uint64_t flags, uint8_t vlan_flag)
+iavf_calc_context_desc(struct rte_mbuf *mb, uint8_t vlan_flag)
 {
+	uint64_t flags = mb->ol_flags;
 	if (flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG |
 	    RTE_MBUF_F_TX_TUNNEL_MASK | RTE_MBUF_F_TX_OUTER_IP_CKSUM |
 	    RTE_MBUF_F_TX_OUTER_UDP_CKSUM))
@@ -2427,6 +2430,12 @@ iavf_calc_context_desc(uint64_t flags, uint8_t vlan_flag)
 	if (flags & RTE_MBUF_F_TX_VLAN &&
 	    vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2)
 		return 1;
+
+	if (iavf_tx_lldp_dynfield_offset ==
+		rte_mbuf_dynfield_lookup(IAVF_TX_LLDP_DYNFIELD, NULL))
+		if (*RTE_MBUF_DYNFIELD(mb,
+			iavf_tx_lldp_dynfield_offset, uint8_t *) > 0)
+			return 1;
 	return 0;
 }
 
@@ -2446,6 +2455,11 @@ iavf_fill_ctx_desc_cmd_field(volatile uint64_t *field, struct rte_mbuf *m,
 			<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 	}
 
+	if (*RTE_MBUF_DYNFIELD(m,
+		iavf_tx_lldp_dynfield_offset, uint8_t *) > 0)
+		cmd |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+			<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
+
 	*field |= cmd;
 }
 
@@ -2826,7 +2840,7 @@ iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 
 		nb_desc_data = mb->nb_segs;
 		nb_desc_ctx =
-			iavf_calc_context_desc(mb->ol_flags, txq->vlan_flag);
+			iavf_calc_context_desc(mb, txq->vlan_flag);
 		nb_desc_ipsec = !!(mb->ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD);
 
 		/**
diff --git a/drivers/net/iavf/rte_pmd_iavf.h b/drivers/net/iavf/rte_pmd_iavf.h
index 56d453fc4c..7d888ce6bd 100644
--- a/drivers/net/iavf/rte_pmd_iavf.h
+++ b/drivers/net/iavf/rte_pmd_iavf.h
@@ -23,6 +23,8 @@
 extern "C" {
 #endif
 
+#define IAVF_TX_LLDP_DYNFIELD "intel_pmd_dynfield_tx_lldp"
+
 /**
  * The supported network flexible descriptor's extraction metadata format.
  */
@@ -95,6 +97,8 @@ extern uint64_t rte_pmd_ifd_dynflag_proto_xtr_tcp_mask;
 extern uint64_t rte_pmd_ifd_dynflag_proto_xtr_ip_offset_mask;
 extern uint64_t rte_pmd_ifd_dynflag_proto_xtr_ipsec_crypto_said_mask;
 
+extern int iavf_tx_lldp_dynfield_offset;
+
 /**
  * The mbuf dynamic field pointer for flexible descriptor's extraction metadata.
  */
-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v3 2/3] net/iavf: support Tx LLDP on AVX512
  2023-12-20  9:32   ` [PATCH v3 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
  2023-12-20  9:32     ` [PATCH v3 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
@ 2023-12-20  9:32     ` Zhichao Zeng
  2023-12-20  9:32     ` [PATCH v3 3/3] net/iavf: add Tx LLDP command Zhichao Zeng
  2 siblings, 0 replies; 27+ messages in thread
From: Zhichao Zeng @ 2023-12-20  9:32 UTC (permalink / raw)
  To: dev
  Cc: qi.z.zhang, Zhichao Zeng, Jingjing Wu, Beilei Xing,
	Bruce Richardson, Konstantin Ananyev

This patch adds an avx512 ctx Tx path that supports context descriptor,
filling in the SWTCH_UPLINK bit based on mbuf dynfield
IAVF_TX_LLDP_DYNFIELD to support sending LLDP packet.

Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
 drivers/net/iavf/iavf_rxtx.c            |  5 +++++
 drivers/net/iavf/iavf_rxtx.h            |  3 +++
 drivers/net/iavf/iavf_rxtx_vec_avx512.c | 20 ++++++++++++++++++++
 drivers/net/iavf/iavf_rxtx_vec_common.h |  6 ++++++
 4 files changed, 34 insertions(+)

diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index 2ecd8637c5..90a2d19c05 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -4053,6 +4053,11 @@ iavf_set_tx_function(struct rte_eth_dev *dev)
 				dev->tx_pkt_prepare = iavf_prep_pkts;
 				PMD_DRV_LOG(DEBUG, "Using AVX512 OFFLOAD Vector Tx (port %d).",
 					    dev->data->port_id);
+			} else if (check_ret == IAVF_VECTOR_CTX_PATH) {
+				dev->tx_pkt_burst = iavf_xmit_pkts_vec_avx512_ctx;
+				dev->tx_pkt_prepare = iavf_prep_pkts;
+				PMD_DRV_LOG(DEBUG, "Using AVX512 CONTEXT Vector Tx (port %d).",
+						dev->data->port_id);
 			} else {
 				dev->tx_pkt_burst = iavf_xmit_pkts_vec_avx512_ctx_offload;
 				dev->tx_pkt_prepare = iavf_prep_pkts;
diff --git a/drivers/net/iavf/iavf_rxtx.h b/drivers/net/iavf/iavf_rxtx.h
index f432f9d956..ee52864915 100644
--- a/drivers/net/iavf/iavf_rxtx.h
+++ b/drivers/net/iavf/iavf_rxtx.h
@@ -66,6 +66,7 @@
 #define IAVF_VECTOR_PATH 0
 #define IAVF_VECTOR_OFFLOAD_PATH 1
 #define IAVF_VECTOR_CTX_OFFLOAD_PATH 2
+#define IAVF_VECTOR_CTX_PATH 3
 
 #define DEFAULT_TX_RS_THRESH     32
 #define DEFAULT_TX_FREE_THRESH   32
@@ -752,6 +753,8 @@ uint16_t iavf_xmit_pkts_vec_avx512_offload(void *tx_queue,
 					   uint16_t nb_pkts);
 uint16_t iavf_xmit_pkts_vec_avx512_ctx_offload(void *tx_queue, struct rte_mbuf **tx_pkts,
 				  uint16_t nb_pkts);
+uint16_t iavf_xmit_pkts_vec_avx512_ctx(void *tx_queue, struct rte_mbuf **tx_pkts,
+				  uint16_t nb_pkts);
 int iavf_txq_vec_setup_avx512(struct iavf_tx_queue *txq);
 
 uint8_t iavf_proto_xtr_type_to_rxdid(uint8_t xtr_type);
diff --git a/drivers/net/iavf/iavf_rxtx_vec_avx512.c b/drivers/net/iavf/iavf_rxtx_vec_avx512.c
index 7a7df6d258..3ae5e4973c 100644
--- a/drivers/net/iavf/iavf_rxtx_vec_avx512.c
+++ b/drivers/net/iavf/iavf_rxtx_vec_avx512.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2020 Intel Corporation
  */
 
+#include "rte_pmd_iavf.h"
 #include "iavf_rxtx_vec_common.h"
 
 #include <rte_vect.h>
@@ -2206,6 +2207,10 @@ ctx_vtx1(volatile struct iavf_tx_desc *txdp, struct rte_mbuf *pkt,
 			low_ctx_qw |= (uint64_t)pkt->vlan_tci << IAVF_TXD_CTX_QW0_L2TAG2_PARAM;
 		}
 	}
+	if (*RTE_MBUF_DYNFIELD(pkt,
+		iavf_tx_lldp_dynfield_offset, uint8_t *) > 0)
+		high_ctx_qw |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+			<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 	uint64_t high_data_qw = (IAVF_TX_DESC_DTYPE_DATA |
 				((uint64_t)flags  << IAVF_TXD_QW1_CMD_SHIFT) |
 				((uint64_t)pkt->data_len << IAVF_TXD_QW1_TX_BUF_SZ_SHIFT));
@@ -2258,6 +2263,10 @@ ctx_vtx(volatile struct iavf_tx_desc *txdp,
 					(uint64_t)pkt[1]->vlan_tci << IAVF_TXD_QW1_L2TAG1_SHIFT;
 			}
 		}
+		if (*RTE_MBUF_DYNFIELD(pkt[1],
+			iavf_tx_lldp_dynfield_offset, uint8_t *) > 0)
+			hi_ctx_qw1 |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+				<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 
 		if (pkt[0]->ol_flags & RTE_MBUF_F_TX_VLAN) {
 			if (vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2) {
@@ -2270,6 +2279,10 @@ ctx_vtx(volatile struct iavf_tx_desc *txdp,
 					(uint64_t)pkt[0]->vlan_tci << IAVF_TXD_QW1_L2TAG1_SHIFT;
 			}
 		}
+		if (*RTE_MBUF_DYNFIELD(pkt[0],
+			iavf_tx_lldp_dynfield_offset, uint8_t *) > 0)
+			hi_ctx_qw0 |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+				<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 
 		if (offload) {
 			iavf_txd_enable_offload(pkt[1], &hi_data_qw1);
@@ -2520,3 +2533,10 @@ iavf_xmit_pkts_vec_avx512_ctx_offload(void *tx_queue, struct rte_mbuf **tx_pkts,
 {
 	return iavf_xmit_pkts_vec_avx512_ctx_cmn(tx_queue, tx_pkts, nb_pkts, true);
 }
+
+uint16_t
+iavf_xmit_pkts_vec_avx512_ctx(void *tx_queue, struct rte_mbuf **tx_pkts,
+				  uint16_t nb_pkts)
+{
+	return iavf_xmit_pkts_vec_avx512_ctx_cmn(tx_queue, tx_pkts, nb_pkts, false);
+}
diff --git a/drivers/net/iavf/iavf_rxtx_vec_common.h b/drivers/net/iavf/iavf_rxtx_vec_common.h
index e18cdc3f11..a453d55335 100644
--- a/drivers/net/iavf/iavf_rxtx_vec_common.h
+++ b/drivers/net/iavf/iavf_rxtx_vec_common.h
@@ -10,6 +10,7 @@
 
 #include "iavf.h"
 #include "iavf_rxtx.h"
+#include "rte_pmd_iavf.h"
 
 #ifndef __INTEL_COMPILER
 #pragma GCC diagnostic ignored "-Wcast-qual"
@@ -249,6 +250,11 @@ iavf_tx_vec_queue_default(struct iavf_tx_queue *txq)
 	if (txq->offloads & IAVF_TX_NO_VECTOR_FLAGS)
 		return -1;
 
+	if (rte_mbuf_dynfield_lookup(IAVF_TX_LLDP_DYNFIELD, NULL) > 0) {
+		txq->use_ctx = 1;
+		return IAVF_VECTOR_CTX_PATH;
+	}
+
 	/**
 	 * Vlan tci needs to be inserted via ctx desc, if the vlan_flag is L2TAG2.
 	 * Tunneling parameters and other fields need be configured in ctx desc
-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v3 3/3] net/iavf: add Tx LLDP command
  2023-12-20  9:32   ` [PATCH v3 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
  2023-12-20  9:32     ` [PATCH v3 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
  2023-12-20  9:32     ` [PATCH v3 2/3] net/iavf: support Tx LLDP on AVX512 Zhichao Zeng
@ 2023-12-20  9:32     ` Zhichao Zeng
  2 siblings, 0 replies; 27+ messages in thread
From: Zhichao Zeng @ 2023-12-20  9:32 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, Zhichao Zeng, Jingjing Wu, Beilei Xing

This patch adds an IAVF testpmd command "set tx lldp on|off" which
will register an mbuf dynfield IAVF_TX_LLDP_DYNFIELD to indicate
the need to send LLDP packet. Currently, it only supports turning on.

For avx512, need to close the Tx port first, then "set tx lldp on",
and reopen the port to select correct Tx path.

Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
 doc/guides/rel_notes/release_24_03.rst |  3 +
 drivers/net/iavf/iavf_testpmd.c        | 80 ++++++++++++++++++++++++++
 drivers/net/iavf/meson.build           |  3 +
 3 files changed, 86 insertions(+)
 create mode 100644 drivers/net/iavf/iavf_testpmd.c

diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst
index 6f8ad27808..f94e18c33a 100644
--- a/doc/guides/rel_notes/release_24_03.rst
+++ b/doc/guides/rel_notes/release_24_03.rst
@@ -55,6 +55,9 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Updated Intel iavf driver.**
+
+  * Added support for Tx LLDP packet on scalar and avx512.
 
 Removed Items
 -------------
diff --git a/drivers/net/iavf/iavf_testpmd.c b/drivers/net/iavf/iavf_testpmd.c
new file mode 100644
index 0000000000..3c4c2e7c3c
--- /dev/null
+++ b/drivers/net/iavf/iavf_testpmd.c
@@ -0,0 +1,80 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2016 Intel Corporation.
+ */
+
+#include <stdlib.h>
+
+#include <rte_pmd_iavf.h>
+
+#include <cmdline_parse_num.h>
+#include <cmdline_parse_string.h>
+
+#include "testpmd.h"
+#include "iavf_log.h"
+
+struct cmd_enable_tx_lldp_result {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t tx;
+	cmdline_fixed_string_t lldp;
+	cmdline_fixed_string_t what;
+};
+
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_set =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		set, "set");
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_tx =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		tx, "tx");
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_lldp =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		lldp, "lldp");
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_what =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		what, "on#off");
+
+static void
+cmd_enable_tx_lldp_parsed(void *parsed_result,
+	__rte_unused struct cmdline *cl, __rte_unused void *data)
+{
+	struct cmd_enable_tx_lldp_result *res = parsed_result;
+	const struct rte_mbuf_dynfield iavf_tx_lldp_dynfield = {
+		.name = IAVF_TX_LLDP_DYNFIELD,
+		.size = sizeof(uint8_t),
+		.align = __alignof__(uint8_t),
+		.flags = 0
+	};
+
+	if (strcmp(res->what, "on") == 0) {
+		iavf_tx_lldp_dynfield_offset =
+			rte_mbuf_dynfield_register(&iavf_tx_lldp_dynfield);
+		PMD_DRV_LOG(DEBUG, "iavf_tx_lldp_dynfield_offset: %d",
+			iavf_tx_lldp_dynfield_offset);
+		if (iavf_tx_lldp_dynfield_offset < 0)
+			PMD_DRV_LOG(ERR, "rte mbuf dynfield register failed");
+	}
+}
+
+static cmdline_parse_inst_t cmd_enable_tx_lldp = {
+	.f = cmd_enable_tx_lldp_parsed,
+	.data = NULL,
+	.help_str = "set iavf tx lldp on|off",
+	.tokens = {
+		(void *)&cmd_enable_tx_lldp_set,
+		(void *)&cmd_enable_tx_lldp_tx,
+		(void *)&cmd_enable_tx_lldp_lldp,
+		(void *)&cmd_enable_tx_lldp_what,
+		NULL,
+	},
+};
+
+static struct testpmd_driver_commands iavf_cmds = {
+	.commands = {
+	{
+		&cmd_enable_tx_lldp,
+		"set tx lldp (on|off)\n"
+		"    Set iavf Tx lldp packet(currently only supported on)\n\n",
+	},
+	{ NULL, NULL },
+	},
+};
+TESTPMD_ADD_DRIVER_COMMANDS(iavf_cmds)
diff --git a/drivers/net/iavf/meson.build b/drivers/net/iavf/meson.build
index a6ce2725c3..83aebd5596 100644
--- a/drivers/net/iavf/meson.build
+++ b/drivers/net/iavf/meson.build
@@ -8,6 +8,9 @@ endif
 cflags += ['-Wno-strict-aliasing']
 
 includes += include_directories('../../common/iavf')
+
+testpmd_sources = files('iavf_testpmd.c')
+
 deps += ['common_iavf', 'security', 'cryptodev']
 
 sources = files(
-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v4 0/3] net/iavf: support Tx LLDP on scalar and AVX512
  2023-12-20  9:32     ` [PATCH v3 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
@ 2023-12-21  7:28       ` Zhichao Zeng
  2023-12-21  7:28         ` [PATCH v4 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
                           ` (3 more replies)
  0 siblings, 4 replies; 27+ messages in thread
From: Zhichao Zeng @ 2023-12-21  7:28 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, Zhichao Zeng

This patch set adds an IAVF testpmd command "set tx lldp on|off" which
will register an mbuf dynfield IAVF_TX_LLDP_DYNFIELD, currently only
supported turning on.

IAVF will fill the SWTCH_UPLINK bit in the Tx context descriptor based on
the mbuf dynfield to send the LLDP packet.

For avx512, need to close the Tx port first, then "set tx lldp on", and
reopen the port to select correct Tx path.

---
v4: fix compile error
v3: non-lldp packet do not use the context descriptor
v2: split into patch set, refine commit log

Zhichao Zeng (3):
  net/iavf: support Tx LLDP on scalar
  net/iavf: support Tx LLDP on AVX512
  net/iavf: add Tx LLDP command

 doc/guides/rel_notes/release_24_03.rst  |  3 +
 drivers/net/iavf/iavf_ethdev.c          |  1 +
 drivers/net/iavf/iavf_rxtx.c            | 21 ++++++-
 drivers/net/iavf/iavf_rxtx.h            |  6 ++
 drivers/net/iavf/iavf_rxtx_vec_avx512.c | 19 ++++++
 drivers/net/iavf/iavf_rxtx_vec_common.h |  5 ++
 drivers/net/iavf/iavf_testpmd.c         | 82 +++++++++++++++++++++++++
 drivers/net/iavf/meson.build            |  3 +
 8 files changed, 138 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/iavf/iavf_testpmd.c

-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v4 1/3] net/iavf: support Tx LLDP on scalar
  2023-12-21  7:28       ` [PATCH v4 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
@ 2023-12-21  7:28         ` Zhichao Zeng
  2023-12-27  4:34           ` Zhang, Qi Z
  2023-12-21  7:28         ` [PATCH v4 2/3] net/iavf: support Tx LLDP on AVX512 Zhichao Zeng
                           ` (2 subsequent siblings)
  3 siblings, 1 reply; 27+ messages in thread
From: Zhichao Zeng @ 2023-12-21  7:28 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, Zhichao Zeng, Jingjing Wu, Beilei Xing

This patch adds an mbuf dynfield IAVF_TX_LLDP_DYNFIELD to determine
whether or not to fill the SWTCH_UPLINK bit in the Tx context descriptor
to send LLDP packet.

Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
 drivers/net/iavf/iavf_ethdev.c |  1 +
 drivers/net/iavf/iavf_rxtx.c   | 16 ++++++++++++++--
 drivers/net/iavf/iavf_rxtx.h   |  3 +++
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index d1edb0dd5c..1be248926c 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -41,6 +41,7 @@
 #define IAVF_NO_POLL_ON_LINK_DOWN_ARG "no-poll-on-link-down"
 uint64_t iavf_timestamp_dynflag;
 int iavf_timestamp_dynfield_offset = -1;
+int iavf_tx_lldp_dynfield_offset = -1;
 
 static const char * const iavf_valid_args[] = {
 	IAVF_PROTO_XTR_ARG,
diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index f19aa14646..3107102911 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -2418,8 +2418,9 @@ iavf_xmit_cleanup(struct iavf_tx_queue *txq)
 
 /* Check if the context descriptor is needed for TX offloading */
 static inline uint16_t
-iavf_calc_context_desc(uint64_t flags, uint8_t vlan_flag)
+iavf_calc_context_desc(struct rte_mbuf *mb, uint8_t vlan_flag)
 {
+	uint64_t flags = mb->ol_flags;
 	if (flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG |
 	    RTE_MBUF_F_TX_TUNNEL_MASK | RTE_MBUF_F_TX_OUTER_IP_CKSUM |
 	    RTE_MBUF_F_TX_OUTER_UDP_CKSUM))
@@ -2427,6 +2428,12 @@ iavf_calc_context_desc(uint64_t flags, uint8_t vlan_flag)
 	if (flags & RTE_MBUF_F_TX_VLAN &&
 	    vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2)
 		return 1;
+
+	if (iavf_tx_lldp_dynfield_offset ==
+		rte_mbuf_dynfield_lookup(IAVF_TX_LLDP_DYNFIELD, NULL))
+		if (*RTE_MBUF_DYNFIELD(mb,
+			iavf_tx_lldp_dynfield_offset, uint8_t *) > 0)
+			return 1;
 	return 0;
 }
 
@@ -2446,6 +2453,11 @@ iavf_fill_ctx_desc_cmd_field(volatile uint64_t *field, struct rte_mbuf *m,
 			<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 	}
 
+	if (*RTE_MBUF_DYNFIELD(m,
+		iavf_tx_lldp_dynfield_offset, uint8_t *) > 0)
+		cmd |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+			<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
+
 	*field |= cmd;
 }
 
@@ -2826,7 +2838,7 @@ iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 
 		nb_desc_data = mb->nb_segs;
 		nb_desc_ctx =
-			iavf_calc_context_desc(mb->ol_flags, txq->vlan_flag);
+			iavf_calc_context_desc(mb, txq->vlan_flag);
 		nb_desc_ipsec = !!(mb->ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD);
 
 		/**
diff --git a/drivers/net/iavf/iavf_rxtx.h b/drivers/net/iavf/iavf_rxtx.h
index f432f9d956..f6954a83c2 100644
--- a/drivers/net/iavf/iavf_rxtx.h
+++ b/drivers/net/iavf/iavf_rxtx.h
@@ -107,8 +107,11 @@
 #define IAVF_MAX_DATA_PER_TXD \
 	(IAVF_TXD_QW1_TX_BUF_SZ_MASK >> IAVF_TXD_QW1_TX_BUF_SZ_SHIFT)
 
+#define IAVF_TX_LLDP_DYNFIELD "intel_pmd_dynfield_tx_lldp"
+
 extern uint64_t iavf_timestamp_dynflag;
 extern int iavf_timestamp_dynfield_offset;
+extern int iavf_tx_lldp_dynfield_offset;
 
 /**
  * Rx Flex Descriptors
-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v4 2/3] net/iavf: support Tx LLDP on AVX512
  2023-12-21  7:28       ` [PATCH v4 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
  2023-12-21  7:28         ` [PATCH v4 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
@ 2023-12-21  7:28         ` Zhichao Zeng
  2023-12-21  7:28         ` [PATCH v4 3/3] net/iavf: add Tx LLDP command Zhichao Zeng
  2023-12-25  3:14         ` [PATCH v4 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
  3 siblings, 0 replies; 27+ messages in thread
From: Zhichao Zeng @ 2023-12-21  7:28 UTC (permalink / raw)
  To: dev
  Cc: qi.z.zhang, Zhichao Zeng, Jingjing Wu, Beilei Xing,
	Bruce Richardson, Konstantin Ananyev

This patch adds an avx512 ctx Tx path that supports context descriptor,
filling in the SWTCH_UPLINK bit based on mbuf
dynfield IAVF_TX_LLDP_DYNFIELD to support sending LLDP packet.

Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
 drivers/net/iavf/iavf_rxtx.c            |  5 +++++
 drivers/net/iavf/iavf_rxtx.h            |  3 +++
 drivers/net/iavf/iavf_rxtx_vec_avx512.c | 19 +++++++++++++++++++
 drivers/net/iavf/iavf_rxtx_vec_common.h |  5 +++++
 4 files changed, 32 insertions(+)

diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index 3107102911..000449fe5c 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -4051,6 +4051,11 @@ iavf_set_tx_function(struct rte_eth_dev *dev)
 				dev->tx_pkt_prepare = iavf_prep_pkts;
 				PMD_DRV_LOG(DEBUG, "Using AVX512 OFFLOAD Vector Tx (port %d).",
 					    dev->data->port_id);
+			} else if (check_ret == IAVF_VECTOR_CTX_PATH) {
+				dev->tx_pkt_burst = iavf_xmit_pkts_vec_avx512_ctx;
+				dev->tx_pkt_prepare = iavf_prep_pkts;
+				PMD_DRV_LOG(DEBUG, "Using AVX512 CONTEXT Vector Tx (port %d).",
+						dev->data->port_id);
 			} else {
 				dev->tx_pkt_burst = iavf_xmit_pkts_vec_avx512_ctx_offload;
 				dev->tx_pkt_prepare = iavf_prep_pkts;
diff --git a/drivers/net/iavf/iavf_rxtx.h b/drivers/net/iavf/iavf_rxtx.h
index f6954a83c2..f0f928928c 100644
--- a/drivers/net/iavf/iavf_rxtx.h
+++ b/drivers/net/iavf/iavf_rxtx.h
@@ -66,6 +66,7 @@
 #define IAVF_VECTOR_PATH 0
 #define IAVF_VECTOR_OFFLOAD_PATH 1
 #define IAVF_VECTOR_CTX_OFFLOAD_PATH 2
+#define IAVF_VECTOR_CTX_PATH 3
 
 #define DEFAULT_TX_RS_THRESH     32
 #define DEFAULT_TX_FREE_THRESH   32
@@ -755,6 +756,8 @@ uint16_t iavf_xmit_pkts_vec_avx512_offload(void *tx_queue,
 					   uint16_t nb_pkts);
 uint16_t iavf_xmit_pkts_vec_avx512_ctx_offload(void *tx_queue, struct rte_mbuf **tx_pkts,
 				  uint16_t nb_pkts);
+uint16_t iavf_xmit_pkts_vec_avx512_ctx(void *tx_queue, struct rte_mbuf **tx_pkts,
+				  uint16_t nb_pkts);
 int iavf_txq_vec_setup_avx512(struct iavf_tx_queue *txq);
 
 uint8_t iavf_proto_xtr_type_to_rxdid(uint8_t xtr_type);
diff --git a/drivers/net/iavf/iavf_rxtx_vec_avx512.c b/drivers/net/iavf/iavf_rxtx_vec_avx512.c
index 7a7df6d258..95fdb26a33 100644
--- a/drivers/net/iavf/iavf_rxtx_vec_avx512.c
+++ b/drivers/net/iavf/iavf_rxtx_vec_avx512.c
@@ -2206,6 +2206,10 @@ ctx_vtx1(volatile struct iavf_tx_desc *txdp, struct rte_mbuf *pkt,
 			low_ctx_qw |= (uint64_t)pkt->vlan_tci << IAVF_TXD_CTX_QW0_L2TAG2_PARAM;
 		}
 	}
+	if (*RTE_MBUF_DYNFIELD(pkt,
+		iavf_tx_lldp_dynfield_offset, uint8_t *) > 0)
+		high_ctx_qw |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+			<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 	uint64_t high_data_qw = (IAVF_TX_DESC_DTYPE_DATA |
 				((uint64_t)flags  << IAVF_TXD_QW1_CMD_SHIFT) |
 				((uint64_t)pkt->data_len << IAVF_TXD_QW1_TX_BUF_SZ_SHIFT));
@@ -2258,6 +2262,10 @@ ctx_vtx(volatile struct iavf_tx_desc *txdp,
 					(uint64_t)pkt[1]->vlan_tci << IAVF_TXD_QW1_L2TAG1_SHIFT;
 			}
 		}
+		if (*RTE_MBUF_DYNFIELD(pkt[1],
+			iavf_tx_lldp_dynfield_offset, uint8_t *) > 0)
+			hi_ctx_qw1 |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+				<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 
 		if (pkt[0]->ol_flags & RTE_MBUF_F_TX_VLAN) {
 			if (vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2) {
@@ -2270,6 +2278,10 @@ ctx_vtx(volatile struct iavf_tx_desc *txdp,
 					(uint64_t)pkt[0]->vlan_tci << IAVF_TXD_QW1_L2TAG1_SHIFT;
 			}
 		}
+		if (*RTE_MBUF_DYNFIELD(pkt[0],
+			iavf_tx_lldp_dynfield_offset, uint8_t *) > 0)
+			hi_ctx_qw0 |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+				<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 
 		if (offload) {
 			iavf_txd_enable_offload(pkt[1], &hi_data_qw1);
@@ -2520,3 +2532,10 @@ iavf_xmit_pkts_vec_avx512_ctx_offload(void *tx_queue, struct rte_mbuf **tx_pkts,
 {
 	return iavf_xmit_pkts_vec_avx512_ctx_cmn(tx_queue, tx_pkts, nb_pkts, true);
 }
+
+uint16_t
+iavf_xmit_pkts_vec_avx512_ctx(void *tx_queue, struct rte_mbuf **tx_pkts,
+				  uint16_t nb_pkts)
+{
+	return iavf_xmit_pkts_vec_avx512_ctx_cmn(tx_queue, tx_pkts, nb_pkts, false);
+}
diff --git a/drivers/net/iavf/iavf_rxtx_vec_common.h b/drivers/net/iavf/iavf_rxtx_vec_common.h
index e18cdc3f11..e4432d1473 100644
--- a/drivers/net/iavf/iavf_rxtx_vec_common.h
+++ b/drivers/net/iavf/iavf_rxtx_vec_common.h
@@ -249,6 +249,11 @@ iavf_tx_vec_queue_default(struct iavf_tx_queue *txq)
 	if (txq->offloads & IAVF_TX_NO_VECTOR_FLAGS)
 		return -1;
 
+	if (rte_mbuf_dynfield_lookup(IAVF_TX_LLDP_DYNFIELD, NULL) > 0) {
+		txq->use_ctx = 1;
+		return IAVF_VECTOR_CTX_PATH;
+	}
+
 	/**
 	 * Vlan tci needs to be inserted via ctx desc, if the vlan_flag is L2TAG2.
 	 * Tunneling parameters and other fields need be configured in ctx desc
-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v4 3/3] net/iavf: add Tx LLDP command
  2023-12-21  7:28       ` [PATCH v4 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
  2023-12-21  7:28         ` [PATCH v4 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
  2023-12-21  7:28         ` [PATCH v4 2/3] net/iavf: support Tx LLDP on AVX512 Zhichao Zeng
@ 2023-12-21  7:28         ` Zhichao Zeng
  2023-12-25  3:14         ` [PATCH v4 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
  3 siblings, 0 replies; 27+ messages in thread
From: Zhichao Zeng @ 2023-12-21  7:28 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, Zhichao Zeng, Jingjing Wu, Beilei Xing

This patch adds an IAVF testpmd command "set tx lldp on|off" which
will register an mbuf dynfield IAVF_TX_LLDP_DYNFIELD to indicate
the need to send LLDP packet. Currently, it only supports turning on.

For avx512, need to close the Tx port first, then "set tx lldp on",
and reopen the port to select correct Tx path.

Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
 doc/guides/rel_notes/release_24_03.rst |  3 +
 drivers/net/iavf/iavf_testpmd.c        | 82 ++++++++++++++++++++++++++
 drivers/net/iavf/meson.build           |  3 +
 3 files changed, 88 insertions(+)
 create mode 100644 drivers/net/iavf/iavf_testpmd.c

diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst
index 6f8ad27808..f94e18c33a 100644
--- a/doc/guides/rel_notes/release_24_03.rst
+++ b/doc/guides/rel_notes/release_24_03.rst
@@ -55,6 +55,9 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Updated Intel iavf driver.**
+
+  * Added support for Tx LLDP packet on scalar and avx512.
 
 Removed Items
 -------------
diff --git a/drivers/net/iavf/iavf_testpmd.c b/drivers/net/iavf/iavf_testpmd.c
new file mode 100644
index 0000000000..470b0ea49c
--- /dev/null
+++ b/drivers/net/iavf/iavf_testpmd.c
@@ -0,0 +1,82 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2016 Intel Corporation.
+ */
+
+#include <stdlib.h>
+
+#include <rte_pmd_iavf.h>
+
+#include <cmdline_parse_num.h>
+#include <cmdline_parse_string.h>
+
+#include "iavf.h"
+#include "testpmd.h"
+#include "iavf_rxtx.h"
+
+struct cmd_enable_tx_lldp_result {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t tx;
+	cmdline_fixed_string_t lldp;
+	cmdline_fixed_string_t what;
+};
+
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_set =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		set, "set");
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_tx =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		tx, "tx");
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_lldp =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		lldp, "lldp");
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_what =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		what, "on#off");
+
+static void
+cmd_enable_tx_lldp_parsed(void *parsed_result,
+	__rte_unused struct cmdline *cl, __rte_unused void *data)
+{
+	struct cmd_enable_tx_lldp_result *res = parsed_result;
+	const struct rte_mbuf_dynfield iavf_tx_lldp_dynfield = {
+		.name = IAVF_TX_LLDP_DYNFIELD,
+		.size = sizeof(uint8_t),
+		.align = __alignof__(uint8_t),
+		.flags = 0
+	};
+
+	if (strncmp(res->what, "on", 2) == 0) {
+		iavf_tx_lldp_dynfield_offset =
+			rte_mbuf_dynfield_register(&iavf_tx_lldp_dynfield);
+		printf("iavf_tx_lldp_dynfield_offset: %d",
+			iavf_tx_lldp_dynfield_offset);
+		if (iavf_tx_lldp_dynfield_offset < 0)
+			fprintf(stderr, "rte mbuf dynfield register failed, offset: %d",
+				iavf_tx_lldp_dynfield_offset);
+	}
+}
+
+static cmdline_parse_inst_t cmd_enable_tx_lldp = {
+	.f = cmd_enable_tx_lldp_parsed,
+	.data = NULL,
+	.help_str = "set iavf tx lldp on|off",
+	.tokens = {
+		(void *)&cmd_enable_tx_lldp_set,
+		(void *)&cmd_enable_tx_lldp_tx,
+		(void *)&cmd_enable_tx_lldp_lldp,
+		(void *)&cmd_enable_tx_lldp_what,
+		NULL,
+	},
+};
+
+static struct testpmd_driver_commands iavf_cmds = {
+	.commands = {
+	{
+		&cmd_enable_tx_lldp,
+		"set tx lldp (on|off)\n"
+		"    Set iavf Tx lldp packet(currently only supported on)\n\n",
+	},
+	{ NULL, NULL },
+	},
+};
+TESTPMD_ADD_DRIVER_COMMANDS(iavf_cmds)
diff --git a/drivers/net/iavf/meson.build b/drivers/net/iavf/meson.build
index a6ce2725c3..83aebd5596 100644
--- a/drivers/net/iavf/meson.build
+++ b/drivers/net/iavf/meson.build
@@ -8,6 +8,9 @@ endif
 cflags += ['-Wno-strict-aliasing']
 
 includes += include_directories('../../common/iavf')
+
+testpmd_sources = files('iavf_testpmd.c')
+
 deps += ['common_iavf', 'security', 'cryptodev']
 
 sources = files(
-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v4 0/3] net/iavf: support Tx LLDP on scalar and AVX512
  2023-12-21  7:28       ` [PATCH v4 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
                           ` (2 preceding siblings ...)
  2023-12-21  7:28         ` [PATCH v4 3/3] net/iavf: add Tx LLDP command Zhichao Zeng
@ 2023-12-25  3:14         ` Zhichao Zeng
  2023-12-25  3:14           ` [PATCH v4 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
                             ` (3 more replies)
  3 siblings, 4 replies; 27+ messages in thread
From: Zhichao Zeng @ 2023-12-25  3:14 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, Zhichao Zeng

This patch set adds an IAVF testpmd command "set tx lldp on|off" which
will register an mbuf dynfield IAVF_TX_LLDP_DYNFIELD, currently only
supported turning on.

IAVF will fill the SWTCH_UPLINK bit in the Tx context descriptor based on
the mbuf dynfield to send the LLDP packet.

For avx512, need to close the Tx port first, then "set tx lldp on", and
reopen the port to select correct Tx path.

---
v4: fix compile error
v3: non-lldp packet do not use the context descriptor
v2: split into patch set, refine commit log

Zhichao Zeng (3):
  net/iavf: support Tx LLDP on scalar
  net/iavf: support Tx LLDP on AVX512
  net/iavf: add Tx LLDP command

 doc/guides/rel_notes/release_24_03.rst  |  3 +
 drivers/net/iavf/iavf_rxtx.c            | 24 ++++++-
 drivers/net/iavf/iavf_rxtx.h            |  6 ++
 drivers/net/iavf/iavf_rxtx_vec_avx512.c | 19 ++++++
 drivers/net/iavf/iavf_rxtx_vec_common.h |  5 ++
 drivers/net/iavf/iavf_testpmd.c         | 84 +++++++++++++++++++++++++
 drivers/net/iavf/meson.build            |  3 +
 drivers/net/iavf/rte_pmd_iavf.h         |  3 +
 drivers/net/iavf/version.map            |  3 +
 9 files changed, 148 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/iavf/iavf_testpmd.c

-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v4 1/3] net/iavf: support Tx LLDP on scalar
  2023-12-25  3:14         ` [PATCH v4 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
@ 2023-12-25  3:14           ` Zhichao Zeng
  2023-12-25  3:14           ` [PATCH v4 2/3] net/iavf: support Tx LLDP on AVX512 Zhichao Zeng
                             ` (2 subsequent siblings)
  3 siblings, 0 replies; 27+ messages in thread
From: Zhichao Zeng @ 2023-12-25  3:14 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, Zhichao Zeng, Jingjing Wu, Beilei Xing

This patch adds an mbuf dynfield IAVF_TX_LLDP_DYNFIELD to determine
whether or not to fill the SWTCH_UPLINK bit in the Tx context descriptor
to send LLDP packet.

Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
 drivers/net/iavf/iavf_rxtx.c    | 19 +++++++++++++++++--
 drivers/net/iavf/iavf_rxtx.h    |  3 +++
 drivers/net/iavf/rte_pmd_iavf.h |  3 +++
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index f19aa14646..736db21ea4 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -85,6 +85,9 @@ uint64_t rte_pmd_ifd_dynflag_proto_xtr_tcp_mask;
 uint64_t rte_pmd_ifd_dynflag_proto_xtr_ip_offset_mask;
 uint64_t rte_pmd_ifd_dynflag_proto_xtr_ipsec_crypto_said_mask;
 
+/* Offset of mbuf dynamic field for transmitting LLDP packet */
+int rte_pmd_iavf_tx_lldp_dynfield_offset = -1;
+
 uint8_t
 iavf_proto_xtr_type_to_rxdid(uint8_t flex_type)
 {
@@ -2418,8 +2421,9 @@ iavf_xmit_cleanup(struct iavf_tx_queue *txq)
 
 /* Check if the context descriptor is needed for TX offloading */
 static inline uint16_t
-iavf_calc_context_desc(uint64_t flags, uint8_t vlan_flag)
+iavf_calc_context_desc(struct rte_mbuf *mb, uint8_t vlan_flag)
 {
+	uint64_t flags = mb->ol_flags;
 	if (flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG |
 	    RTE_MBUF_F_TX_TUNNEL_MASK | RTE_MBUF_F_TX_OUTER_IP_CKSUM |
 	    RTE_MBUF_F_TX_OUTER_UDP_CKSUM))
@@ -2427,6 +2431,12 @@ iavf_calc_context_desc(uint64_t flags, uint8_t vlan_flag)
 	if (flags & RTE_MBUF_F_TX_VLAN &&
 	    vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2)
 		return 1;
+
+	if (rte_pmd_iavf_tx_lldp_dynfield_offset ==
+		rte_mbuf_dynfield_lookup(IAVF_TX_LLDP_DYNFIELD, NULL))
+		if (*RTE_MBUF_DYNFIELD(mb,
+			rte_pmd_iavf_tx_lldp_dynfield_offset, uint8_t *) > 0)
+			return 1;
 	return 0;
 }
 
@@ -2446,6 +2456,11 @@ iavf_fill_ctx_desc_cmd_field(volatile uint64_t *field, struct rte_mbuf *m,
 			<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 	}
 
+	if (*RTE_MBUF_DYNFIELD(m,
+		rte_pmd_iavf_tx_lldp_dynfield_offset, uint8_t *) > 0)
+		cmd |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+			<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
+
 	*field |= cmd;
 }
 
@@ -2826,7 +2841,7 @@ iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 
 		nb_desc_data = mb->nb_segs;
 		nb_desc_ctx =
-			iavf_calc_context_desc(mb->ol_flags, txq->vlan_flag);
+			iavf_calc_context_desc(mb, txq->vlan_flag);
 		nb_desc_ipsec = !!(mb->ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD);
 
 		/**
diff --git a/drivers/net/iavf/iavf_rxtx.h b/drivers/net/iavf/iavf_rxtx.h
index f432f9d956..960618205c 100644
--- a/drivers/net/iavf/iavf_rxtx.h
+++ b/drivers/net/iavf/iavf_rxtx.h
@@ -107,8 +107,11 @@
 #define IAVF_MAX_DATA_PER_TXD \
 	(IAVF_TXD_QW1_TX_BUF_SZ_MASK >> IAVF_TXD_QW1_TX_BUF_SZ_SHIFT)
 
+#define IAVF_TX_LLDP_DYNFIELD "intel_pmd_dynfield_tx_lldp"
+
 extern uint64_t iavf_timestamp_dynflag;
 extern int iavf_timestamp_dynfield_offset;
+extern int rte_pmd_iavf_tx_lldp_dynfield_offset;
 
 /**
  * Rx Flex Descriptors
diff --git a/drivers/net/iavf/rte_pmd_iavf.h b/drivers/net/iavf/rte_pmd_iavf.h
index 56d453fc4c..07d961eaff 100644
--- a/drivers/net/iavf/rte_pmd_iavf.h
+++ b/drivers/net/iavf/rte_pmd_iavf.h
@@ -95,6 +95,9 @@ extern uint64_t rte_pmd_ifd_dynflag_proto_xtr_tcp_mask;
 extern uint64_t rte_pmd_ifd_dynflag_proto_xtr_ip_offset_mask;
 extern uint64_t rte_pmd_ifd_dynflag_proto_xtr_ipsec_crypto_said_mask;
 
+/* Offset of mbuf dynamic field for transmitting LLDP packet */
+extern int rte_pmd_iavf_tx_lldp_dynfield_offset;
+
 /**
  * The mbuf dynamic field pointer for flexible descriptor's extraction metadata.
  */
-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v4 2/3] net/iavf: support Tx LLDP on AVX512
  2023-12-25  3:14         ` [PATCH v4 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
  2023-12-25  3:14           ` [PATCH v4 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
@ 2023-12-25  3:14           ` Zhichao Zeng
  2023-12-25  3:14           ` [PATCH v4 3/3] net/iavf: add Tx LLDP command Zhichao Zeng
  2023-12-28  3:22           ` [PATCH v5 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
  3 siblings, 0 replies; 27+ messages in thread
From: Zhichao Zeng @ 2023-12-25  3:14 UTC (permalink / raw)
  To: dev
  Cc: qi.z.zhang, Zhichao Zeng, Jingjing Wu, Beilei Xing,
	Bruce Richardson, Konstantin Ananyev

This patch adds an avx512 ctx Tx path that supports context descriptor,
filling in the SWTCH_UPLINK bit based on mbuf
dynfield IAVF_TX_LLDP_DYNFIELD to support sending LLDP packet.

Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
 drivers/net/iavf/iavf_rxtx.c            |  5 +++++
 drivers/net/iavf/iavf_rxtx.h            |  3 +++
 drivers/net/iavf/iavf_rxtx_vec_avx512.c | 19 +++++++++++++++++++
 drivers/net/iavf/iavf_rxtx_vec_common.h |  5 +++++
 4 files changed, 32 insertions(+)

diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index 736db21ea4..8e147ad6b1 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -4054,6 +4054,11 @@ iavf_set_tx_function(struct rte_eth_dev *dev)
 				dev->tx_pkt_prepare = iavf_prep_pkts;
 				PMD_DRV_LOG(DEBUG, "Using AVX512 OFFLOAD Vector Tx (port %d).",
 					    dev->data->port_id);
+			} else if (check_ret == IAVF_VECTOR_CTX_PATH) {
+				dev->tx_pkt_burst = iavf_xmit_pkts_vec_avx512_ctx;
+				dev->tx_pkt_prepare = iavf_prep_pkts;
+				PMD_DRV_LOG(DEBUG, "Using AVX512 CONTEXT Vector Tx (port %d).",
+						dev->data->port_id);
 			} else {
 				dev->tx_pkt_burst = iavf_xmit_pkts_vec_avx512_ctx_offload;
 				dev->tx_pkt_prepare = iavf_prep_pkts;
diff --git a/drivers/net/iavf/iavf_rxtx.h b/drivers/net/iavf/iavf_rxtx.h
index 960618205c..4e25aa9000 100644
--- a/drivers/net/iavf/iavf_rxtx.h
+++ b/drivers/net/iavf/iavf_rxtx.h
@@ -66,6 +66,7 @@
 #define IAVF_VECTOR_PATH 0
 #define IAVF_VECTOR_OFFLOAD_PATH 1
 #define IAVF_VECTOR_CTX_OFFLOAD_PATH 2
+#define IAVF_VECTOR_CTX_PATH 3
 
 #define DEFAULT_TX_RS_THRESH     32
 #define DEFAULT_TX_FREE_THRESH   32
@@ -755,6 +756,8 @@ uint16_t iavf_xmit_pkts_vec_avx512_offload(void *tx_queue,
 					   uint16_t nb_pkts);
 uint16_t iavf_xmit_pkts_vec_avx512_ctx_offload(void *tx_queue, struct rte_mbuf **tx_pkts,
 				  uint16_t nb_pkts);
+uint16_t iavf_xmit_pkts_vec_avx512_ctx(void *tx_queue, struct rte_mbuf **tx_pkts,
+				  uint16_t nb_pkts);
 int iavf_txq_vec_setup_avx512(struct iavf_tx_queue *txq);
 
 uint8_t iavf_proto_xtr_type_to_rxdid(uint8_t xtr_type);
diff --git a/drivers/net/iavf/iavf_rxtx_vec_avx512.c b/drivers/net/iavf/iavf_rxtx_vec_avx512.c
index 7a7df6d258..045cb7fd11 100644
--- a/drivers/net/iavf/iavf_rxtx_vec_avx512.c
+++ b/drivers/net/iavf/iavf_rxtx_vec_avx512.c
@@ -2206,6 +2206,10 @@ ctx_vtx1(volatile struct iavf_tx_desc *txdp, struct rte_mbuf *pkt,
 			low_ctx_qw |= (uint64_t)pkt->vlan_tci << IAVF_TXD_CTX_QW0_L2TAG2_PARAM;
 		}
 	}
+	if (*RTE_MBUF_DYNFIELD(pkt,
+		rte_pmd_iavf_tx_lldp_dynfield_offset, uint8_t *) > 0)
+		high_ctx_qw |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+			<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 	uint64_t high_data_qw = (IAVF_TX_DESC_DTYPE_DATA |
 				((uint64_t)flags  << IAVF_TXD_QW1_CMD_SHIFT) |
 				((uint64_t)pkt->data_len << IAVF_TXD_QW1_TX_BUF_SZ_SHIFT));
@@ -2258,6 +2262,10 @@ ctx_vtx(volatile struct iavf_tx_desc *txdp,
 					(uint64_t)pkt[1]->vlan_tci << IAVF_TXD_QW1_L2TAG1_SHIFT;
 			}
 		}
+		if (*RTE_MBUF_DYNFIELD(pkt[1],
+			rte_pmd_iavf_tx_lldp_dynfield_offset, uint8_t *) > 0)
+			hi_ctx_qw1 |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+				<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 
 		if (pkt[0]->ol_flags & RTE_MBUF_F_TX_VLAN) {
 			if (vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2) {
@@ -2270,6 +2278,10 @@ ctx_vtx(volatile struct iavf_tx_desc *txdp,
 					(uint64_t)pkt[0]->vlan_tci << IAVF_TXD_QW1_L2TAG1_SHIFT;
 			}
 		}
+		if (*RTE_MBUF_DYNFIELD(pkt[0],
+			rte_pmd_iavf_tx_lldp_dynfield_offset, uint8_t *) > 0)
+			hi_ctx_qw0 |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+				<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 
 		if (offload) {
 			iavf_txd_enable_offload(pkt[1], &hi_data_qw1);
@@ -2520,3 +2532,10 @@ iavf_xmit_pkts_vec_avx512_ctx_offload(void *tx_queue, struct rte_mbuf **tx_pkts,
 {
 	return iavf_xmit_pkts_vec_avx512_ctx_cmn(tx_queue, tx_pkts, nb_pkts, true);
 }
+
+uint16_t
+iavf_xmit_pkts_vec_avx512_ctx(void *tx_queue, struct rte_mbuf **tx_pkts,
+				  uint16_t nb_pkts)
+{
+	return iavf_xmit_pkts_vec_avx512_ctx_cmn(tx_queue, tx_pkts, nb_pkts, false);
+}
diff --git a/drivers/net/iavf/iavf_rxtx_vec_common.h b/drivers/net/iavf/iavf_rxtx_vec_common.h
index e18cdc3f11..e4432d1473 100644
--- a/drivers/net/iavf/iavf_rxtx_vec_common.h
+++ b/drivers/net/iavf/iavf_rxtx_vec_common.h
@@ -249,6 +249,11 @@ iavf_tx_vec_queue_default(struct iavf_tx_queue *txq)
 	if (txq->offloads & IAVF_TX_NO_VECTOR_FLAGS)
 		return -1;
 
+	if (rte_mbuf_dynfield_lookup(IAVF_TX_LLDP_DYNFIELD, NULL) > 0) {
+		txq->use_ctx = 1;
+		return IAVF_VECTOR_CTX_PATH;
+	}
+
 	/**
 	 * Vlan tci needs to be inserted via ctx desc, if the vlan_flag is L2TAG2.
 	 * Tunneling parameters and other fields need be configured in ctx desc
-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v4 3/3] net/iavf: add Tx LLDP command
  2023-12-25  3:14         ` [PATCH v4 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
  2023-12-25  3:14           ` [PATCH v4 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
  2023-12-25  3:14           ` [PATCH v4 2/3] net/iavf: support Tx LLDP on AVX512 Zhichao Zeng
@ 2023-12-25  3:14           ` Zhichao Zeng
  2023-12-28  3:22           ` [PATCH v5 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
  3 siblings, 0 replies; 27+ messages in thread
From: Zhichao Zeng @ 2023-12-25  3:14 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, Zhichao Zeng, Jingjing Wu, Beilei Xing

This patch adds an IAVF testpmd command "set tx lldp on|off" which
will register an mbuf dynfield IAVF_TX_LLDP_DYNFIELD to indicate
the need to send LLDP packet. Currently, it only supports turning on.

For avx512, need to close the Tx port first, then "set tx lldp on",
and reopen the port to select correct Tx path.

Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
 doc/guides/rel_notes/release_24_03.rst |  3 +
 drivers/net/iavf/iavf_testpmd.c        | 84 ++++++++++++++++++++++++++
 drivers/net/iavf/meson.build           |  3 +
 drivers/net/iavf/version.map           |  3 +
 4 files changed, 93 insertions(+)
 create mode 100644 drivers/net/iavf/iavf_testpmd.c

diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst
index 6f8ad27808..f94e18c33a 100644
--- a/doc/guides/rel_notes/release_24_03.rst
+++ b/doc/guides/rel_notes/release_24_03.rst
@@ -55,6 +55,9 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Updated Intel iavf driver.**
+
+  * Added support for Tx LLDP packet on scalar and avx512.
 
 Removed Items
 -------------
diff --git a/drivers/net/iavf/iavf_testpmd.c b/drivers/net/iavf/iavf_testpmd.c
new file mode 100644
index 0000000000..9d4fbb43ed
--- /dev/null
+++ b/drivers/net/iavf/iavf_testpmd.c
@@ -0,0 +1,84 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2016 Intel Corporation.
+ */
+
+#include <stdlib.h>
+
+#include <rte_pmd_iavf.h>
+
+#include <cmdline_parse_num.h>
+#include <cmdline_parse_string.h>
+
+#include "iavf.h"
+#include "testpmd.h"
+#include "iavf_rxtx.h"
+
+struct cmd_enable_tx_lldp_result {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t tx;
+	cmdline_fixed_string_t lldp;
+	cmdline_fixed_string_t what;
+};
+
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_set =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		set, "set");
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_tx =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		tx, "tx");
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_lldp =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		lldp, "lldp");
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_what =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		what, "on#off");
+
+static void
+cmd_enable_tx_lldp_parsed(void *parsed_result,
+	__rte_unused struct cmdline *cl, __rte_unused void *data)
+{
+	struct cmd_enable_tx_lldp_result *res = parsed_result;
+	const struct rte_mbuf_dynfield iavf_tx_lldp_dynfield = {
+		.name = IAVF_TX_LLDP_DYNFIELD,
+		.size = sizeof(uint8_t),
+		.align = __alignof__(uint8_t),
+		.flags = 0
+	};
+	int ret = 0;
+
+	if (strncmp(res->what, "on", 2) == 0) {
+		rte_pmd_iavf_tx_lldp_dynfield_offset =
+			rte_mbuf_dynfield_register(&iavf_tx_lldp_dynfield);
+		printf("rte_pmd_iavf_tx_lldp_dynfield_offset: %d",
+			rte_pmd_iavf_tx_lldp_dynfield_offset);
+		if (ret < 0)
+			fprintf(stderr,
+				"rte mbuf dynfield register failed, offset: %d",
+				rte_pmd_iavf_tx_lldp_dynfield_offset);
+	}
+}
+
+static cmdline_parse_inst_t cmd_enable_tx_lldp = {
+	.f = cmd_enable_tx_lldp_parsed,
+	.data = NULL,
+	.help_str = "set iavf tx lldp on|off",
+	.tokens = {
+		(void *)&cmd_enable_tx_lldp_set,
+		(void *)&cmd_enable_tx_lldp_tx,
+		(void *)&cmd_enable_tx_lldp_lldp,
+		(void *)&cmd_enable_tx_lldp_what,
+		NULL,
+	},
+};
+
+static struct testpmd_driver_commands iavf_cmds = {
+	.commands = {
+	{
+		&cmd_enable_tx_lldp,
+		"set tx lldp (on|off)\n"
+		"    Set iavf Tx lldp packet(currently only supported on)\n\n",
+	},
+	{ NULL, NULL },
+	},
+};
+TESTPMD_ADD_DRIVER_COMMANDS(iavf_cmds)
diff --git a/drivers/net/iavf/meson.build b/drivers/net/iavf/meson.build
index a6ce2725c3..83aebd5596 100644
--- a/drivers/net/iavf/meson.build
+++ b/drivers/net/iavf/meson.build
@@ -8,6 +8,9 @@ endif
 cflags += ['-Wno-strict-aliasing']
 
 includes += include_directories('../../common/iavf')
+
+testpmd_sources = files('iavf_testpmd.c')
+
 deps += ['common_iavf', 'security', 'cryptodev']
 
 sources = files(
diff --git a/drivers/net/iavf/version.map b/drivers/net/iavf/version.map
index 135a4ccd3d..51e94f32fe 100644
--- a/drivers/net/iavf/version.map
+++ b/drivers/net/iavf/version.map
@@ -16,4 +16,7 @@ EXPERIMENTAL {
 
 	# added in 21.11
 	rte_pmd_ifd_dynflag_proto_xtr_ipsec_crypto_said_mask;
+
+	# added in 24.03
+	rte_pmd_iavf_tx_lldp_dynfield_offset;
 };
-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* RE: [PATCH v4 1/3] net/iavf: support Tx LLDP on scalar
  2023-12-21  7:28         ` [PATCH v4 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
@ 2023-12-27  4:34           ` Zhang, Qi Z
  0 siblings, 0 replies; 27+ messages in thread
From: Zhang, Qi Z @ 2023-12-27  4:34 UTC (permalink / raw)
  To: Zeng, ZhichaoX, dev; +Cc: Wu, Jingjing, Xing, Beilei



> -----Original Message-----
> From: Zeng, ZhichaoX <zhichaox.zeng@intel.com>
> Sent: Thursday, December 21, 2023 3:28 PM
> To: dev@dpdk.org
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; Zeng, ZhichaoX
> <zhichaox.zeng@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; Xing, Beilei
> <beilei.xing@intel.com>
> Subject: [PATCH v4 1/3] net/iavf: support Tx LLDP on scalar
> 
> This patch adds an mbuf dynfield IAVF_TX_LLDP_DYNFIELD to determine
> whether or not to fill the SWTCH_UPLINK bit in the Tx context descriptor to
> send LLDP packet.
> 
> Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
> ---
>  drivers/net/iavf/iavf_ethdev.c |  1 +
>  drivers/net/iavf/iavf_rxtx.c   | 16 ++++++++++++++--
>  drivers/net/iavf/iavf_rxtx.h   |  3 +++
>  3 files changed, 18 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c index
> d1edb0dd5c..1be248926c 100644
> --- a/drivers/net/iavf/iavf_ethdev.c
> +++ b/drivers/net/iavf/iavf_ethdev.c
> @@ -41,6 +41,7 @@
>  #define IAVF_NO_POLL_ON_LINK_DOWN_ARG "no-poll-on-link-down"
>  uint64_t iavf_timestamp_dynflag;
>  int iavf_timestamp_dynfield_offset = -1;
> +int iavf_tx_lldp_dynfield_offset = -1;
> 
>  static const char * const iavf_valid_args[] = {
>  	IAVF_PROTO_XTR_ARG,
> diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c index
> f19aa14646..3107102911 100644
> --- a/drivers/net/iavf/iavf_rxtx.c
> +++ b/drivers/net/iavf/iavf_rxtx.c
> @@ -2418,8 +2418,9 @@ iavf_xmit_cleanup(struct iavf_tx_queue *txq)
> 
>  /* Check if the context descriptor is needed for TX offloading */  static inline
> uint16_t -iavf_calc_context_desc(uint64_t flags, uint8_t vlan_flag)
> +iavf_calc_context_desc(struct rte_mbuf *mb, uint8_t vlan_flag)
>  {
> +	uint64_t flags = mb->ol_flags;
>  	if (flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG |
>  	    RTE_MBUF_F_TX_TUNNEL_MASK |
> RTE_MBUF_F_TX_OUTER_IP_CKSUM |
>  	    RTE_MBUF_F_TX_OUTER_UDP_CKSUM))
> @@ -2427,6 +2428,12 @@ iavf_calc_context_desc(uint64_t flags, uint8_t
> vlan_flag)
>  	if (flags & RTE_MBUF_F_TX_VLAN &&
>  	    vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2)
>  		return 1;
> +
> +	if (iavf_tx_lldp_dynfield_offset ==
> +		rte_mbuf_dynfield_lookup(IAVF_TX_LLDP_DYNFIELD, NULL))
> +		if (*RTE_MBUF_DYNFIELD(mb,

Its not necessary to lookup the dynamic field at data path which consume considerable CPU cycles that impact the performance.
the dynamic field offset can be decided during dev_start.


> +			iavf_tx_lldp_dynfield_offset, uint8_t *) > 0)
> +			return 1;
>  	return 0;
>  }
> 
> @@ -2446,6 +2453,11 @@ iavf_fill_ctx_desc_cmd_field(volatile uint64_t
> *field, struct rte_mbuf *m,
>  			<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
>  	}
> 
> +	if (*RTE_MBUF_DYNFIELD(m,
> +		iavf_tx_lldp_dynfield_offset, uint8_t *) > 0)
> +		cmd |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
> +			<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
> +
>  	*field |= cmd;
>  }
> 
> @@ -2826,7 +2838,7 @@ iavf_xmit_pkts(void *tx_queue, struct rte_mbuf
> **tx_pkts, uint16_t nb_pkts)
> 
>  		nb_desc_data = mb->nb_segs;
>  		nb_desc_ctx =
> -			iavf_calc_context_desc(mb->ol_flags, txq->vlan_flag);
> +			iavf_calc_context_desc(mb, txq->vlan_flag);
>  		nb_desc_ipsec = !!(mb->ol_flags &
> RTE_MBUF_F_TX_SEC_OFFLOAD);
> 
>  		/**
> diff --git a/drivers/net/iavf/iavf_rxtx.h b/drivers/net/iavf/iavf_rxtx.h index
> f432f9d956..f6954a83c2 100644
> --- a/drivers/net/iavf/iavf_rxtx.h
> +++ b/drivers/net/iavf/iavf_rxtx.h
> @@ -107,8 +107,11 @@
>  #define IAVF_MAX_DATA_PER_TXD \
>  	(IAVF_TXD_QW1_TX_BUF_SZ_MASK >>
> IAVF_TXD_QW1_TX_BUF_SZ_SHIFT)
> 
> +#define IAVF_TX_LLDP_DYNFIELD "intel_pmd_dynfield_tx_lldp"
> +
>  extern uint64_t iavf_timestamp_dynflag;  extern int
> iavf_timestamp_dynfield_offset;
> +extern int iavf_tx_lldp_dynfield_offset;

It may not necessary to expose the offset value, as IAVF_TX_LLDP_DYNFIELD is the contract between
application and PMD already.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v5 0/3] net/iavf: support Tx LLDP on scalar and AVX512
  2023-12-25  3:14         ` [PATCH v4 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
                             ` (2 preceding siblings ...)
  2023-12-25  3:14           ` [PATCH v4 3/3] net/iavf: add Tx LLDP command Zhichao Zeng
@ 2023-12-28  3:22           ` Zhichao Zeng
  2023-12-28  3:22             ` [PATCH v5 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
                               ` (4 more replies)
  3 siblings, 5 replies; 27+ messages in thread
From: Zhichao Zeng @ 2023-12-28  3:22 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, Zhichao Zeng

This patch set adds an IAVF testpmd command "set tx lldp on|off" which
will register an mbuf dynfield IAVF_TX_LLDP_DYNFIELD to indicate
the need to send LLDP packet. It needs to close the Tx port first,
then "set tx lldp on", and reopen the port to select correct Tx path,
only supports turning on for now.

IAVF will fill the SWTCH_UPLINK bit in the Tx context descriptor based on
the mbuf dynfield to send the LLDP packet.

---
v5: check dynfield at dev_start
v4: fix compile error
v3: non-lldp packet do not use the context descriptor
v2: split into patch set, refine commit log

Zhichao Zeng (3):
  net/iavf: support Tx LLDP on scalar
  net/iavf: support Tx LLDP on AVX512
  net/iavf: add Tx LLDP command

 doc/guides/rel_notes/release_24_03.rst  |  3 +
 drivers/net/iavf/iavf_ethdev.c          |  5 ++
 drivers/net/iavf/iavf_rxtx.c            | 21 ++++++-
 drivers/net/iavf/iavf_rxtx.h            |  6 ++
 drivers/net/iavf/iavf_rxtx_vec_avx512.c | 19 ++++++
 drivers/net/iavf/iavf_rxtx_vec_common.h |  5 ++
 drivers/net/iavf/iavf_testpmd.c         | 81 +++++++++++++++++++++++++
 drivers/net/iavf/meson.build            |  3 +
 8 files changed, 141 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/iavf/iavf_testpmd.c

-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v5 1/3] net/iavf: support Tx LLDP on scalar
  2023-12-28  3:22           ` [PATCH v5 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
@ 2023-12-28  3:22             ` Zhichao Zeng
  2023-12-28  3:22             ` [PATCH v5 2/3] net/iavf: support Tx LLDP on AVX512 Zhichao Zeng
                               ` (3 subsequent siblings)
  4 siblings, 0 replies; 27+ messages in thread
From: Zhichao Zeng @ 2023-12-28  3:22 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, Zhichao Zeng, Jingjing Wu, Beilei Xing

This patch adds an mbuf dynfield IAVF_TX_LLDP_DYNFIELD to determine
whether or not to fill the SWTCH_UPLINK bit in the Tx context descriptor
to send LLDP packet.

Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
 drivers/net/iavf/iavf_ethdev.c |  5 +++++
 drivers/net/iavf/iavf_rxtx.c   | 16 ++++++++++++++--
 drivers/net/iavf/iavf_rxtx.h   |  3 +++
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index d1edb0dd5c..ef34246d36 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -41,6 +41,7 @@
 #define IAVF_NO_POLL_ON_LINK_DOWN_ARG "no-poll-on-link-down"
 uint64_t iavf_timestamp_dynflag;
 int iavf_timestamp_dynfield_offset = -1;
+int rte_pmd_iavf_tx_lldp_dynfield_offset = -1;
 
 static const char * const iavf_valid_args[] = {
 	IAVF_PROTO_XTR_ARG,
@@ -1017,6 +1018,10 @@ iavf_dev_start(struct rte_eth_dev *dev)
 		}
 	}
 
+	/* Check Tx LLDP dynfield */
+	rte_pmd_iavf_tx_lldp_dynfield_offset =
+		rte_mbuf_dynfield_lookup(IAVF_TX_LLDP_DYNFIELD, NULL);
+
 	if (iavf_init_queues(dev) != 0) {
 		PMD_DRV_LOG(ERR, "failed to do Queue init");
 		return -1;
diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index f19aa14646..53b8990b12 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -2418,8 +2418,9 @@ iavf_xmit_cleanup(struct iavf_tx_queue *txq)
 
 /* Check if the context descriptor is needed for TX offloading */
 static inline uint16_t
-iavf_calc_context_desc(uint64_t flags, uint8_t vlan_flag)
+iavf_calc_context_desc(struct rte_mbuf *mb, uint8_t vlan_flag)
 {
+	uint64_t flags = mb->ol_flags;
 	if (flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG |
 	    RTE_MBUF_F_TX_TUNNEL_MASK | RTE_MBUF_F_TX_OUTER_IP_CKSUM |
 	    RTE_MBUF_F_TX_OUTER_UDP_CKSUM))
@@ -2427,6 +2428,12 @@ iavf_calc_context_desc(uint64_t flags, uint8_t vlan_flag)
 	if (flags & RTE_MBUF_F_TX_VLAN &&
 	    vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2)
 		return 1;
+
+	if (rte_pmd_iavf_tx_lldp_dynfield_offset > 0)
+		if (*RTE_MBUF_DYNFIELD(mb,
+			rte_pmd_iavf_tx_lldp_dynfield_offset, uint8_t *) > 0)
+			return 1;
+
 	return 0;
 }
 
@@ -2446,6 +2453,11 @@ iavf_fill_ctx_desc_cmd_field(volatile uint64_t *field, struct rte_mbuf *m,
 			<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 	}
 
+	if (*RTE_MBUF_DYNFIELD(m,
+		rte_pmd_iavf_tx_lldp_dynfield_offset, uint8_t *) > 0)
+		cmd |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+			<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
+
 	*field |= cmd;
 }
 
@@ -2826,7 +2838,7 @@ iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 
 		nb_desc_data = mb->nb_segs;
 		nb_desc_ctx =
-			iavf_calc_context_desc(mb->ol_flags, txq->vlan_flag);
+			iavf_calc_context_desc(mb, txq->vlan_flag);
 		nb_desc_ipsec = !!(mb->ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD);
 
 		/**
diff --git a/drivers/net/iavf/iavf_rxtx.h b/drivers/net/iavf/iavf_rxtx.h
index f432f9d956..960618205c 100644
--- a/drivers/net/iavf/iavf_rxtx.h
+++ b/drivers/net/iavf/iavf_rxtx.h
@@ -107,8 +107,11 @@
 #define IAVF_MAX_DATA_PER_TXD \
 	(IAVF_TXD_QW1_TX_BUF_SZ_MASK >> IAVF_TXD_QW1_TX_BUF_SZ_SHIFT)
 
+#define IAVF_TX_LLDP_DYNFIELD "intel_pmd_dynfield_tx_lldp"
+
 extern uint64_t iavf_timestamp_dynflag;
 extern int iavf_timestamp_dynfield_offset;
+extern int rte_pmd_iavf_tx_lldp_dynfield_offset;
 
 /**
  * Rx Flex Descriptors
-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v5 2/3] net/iavf: support Tx LLDP on AVX512
  2023-12-28  3:22           ` [PATCH v5 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
  2023-12-28  3:22             ` [PATCH v5 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
@ 2023-12-28  3:22             ` Zhichao Zeng
  2023-12-28  3:22             ` [PATCH v5 3/3] net/iavf: add Tx LLDP command Zhichao Zeng
                               ` (2 subsequent siblings)
  4 siblings, 0 replies; 27+ messages in thread
From: Zhichao Zeng @ 2023-12-28  3:22 UTC (permalink / raw)
  To: dev
  Cc: qi.z.zhang, Zhichao Zeng, Jingjing Wu, Beilei Xing,
	Bruce Richardson, Konstantin Ananyev

This patch adds an avx512 ctx Tx path that supports context descriptor,
filling in the SWTCH_UPLINK bit based on mbuf
dynfield IAVF_TX_LLDP_DYNFIELD to support sending LLDP packet.

Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
 drivers/net/iavf/iavf_rxtx.c            |  5 +++++
 drivers/net/iavf/iavf_rxtx.h            |  3 +++
 drivers/net/iavf/iavf_rxtx_vec_avx512.c | 19 +++++++++++++++++++
 drivers/net/iavf/iavf_rxtx_vec_common.h |  5 +++++
 4 files changed, 32 insertions(+)

diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index 53b8990b12..33c2513b5d 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -4051,6 +4051,11 @@ iavf_set_tx_function(struct rte_eth_dev *dev)
 				dev->tx_pkt_prepare = iavf_prep_pkts;
 				PMD_DRV_LOG(DEBUG, "Using AVX512 OFFLOAD Vector Tx (port %d).",
 					    dev->data->port_id);
+			} else if (check_ret == IAVF_VECTOR_CTX_PATH) {
+				dev->tx_pkt_burst = iavf_xmit_pkts_vec_avx512_ctx;
+				dev->tx_pkt_prepare = iavf_prep_pkts;
+				PMD_DRV_LOG(DEBUG, "Using AVX512 CONTEXT Vector Tx (port %d).",
+						dev->data->port_id);
 			} else {
 				dev->tx_pkt_burst = iavf_xmit_pkts_vec_avx512_ctx_offload;
 				dev->tx_pkt_prepare = iavf_prep_pkts;
diff --git a/drivers/net/iavf/iavf_rxtx.h b/drivers/net/iavf/iavf_rxtx.h
index 960618205c..4e25aa9000 100644
--- a/drivers/net/iavf/iavf_rxtx.h
+++ b/drivers/net/iavf/iavf_rxtx.h
@@ -66,6 +66,7 @@
 #define IAVF_VECTOR_PATH 0
 #define IAVF_VECTOR_OFFLOAD_PATH 1
 #define IAVF_VECTOR_CTX_OFFLOAD_PATH 2
+#define IAVF_VECTOR_CTX_PATH 3
 
 #define DEFAULT_TX_RS_THRESH     32
 #define DEFAULT_TX_FREE_THRESH   32
@@ -755,6 +756,8 @@ uint16_t iavf_xmit_pkts_vec_avx512_offload(void *tx_queue,
 					   uint16_t nb_pkts);
 uint16_t iavf_xmit_pkts_vec_avx512_ctx_offload(void *tx_queue, struct rte_mbuf **tx_pkts,
 				  uint16_t nb_pkts);
+uint16_t iavf_xmit_pkts_vec_avx512_ctx(void *tx_queue, struct rte_mbuf **tx_pkts,
+				  uint16_t nb_pkts);
 int iavf_txq_vec_setup_avx512(struct iavf_tx_queue *txq);
 
 uint8_t iavf_proto_xtr_type_to_rxdid(uint8_t xtr_type);
diff --git a/drivers/net/iavf/iavf_rxtx_vec_avx512.c b/drivers/net/iavf/iavf_rxtx_vec_avx512.c
index 7a7df6d258..045cb7fd11 100644
--- a/drivers/net/iavf/iavf_rxtx_vec_avx512.c
+++ b/drivers/net/iavf/iavf_rxtx_vec_avx512.c
@@ -2206,6 +2206,10 @@ ctx_vtx1(volatile struct iavf_tx_desc *txdp, struct rte_mbuf *pkt,
 			low_ctx_qw |= (uint64_t)pkt->vlan_tci << IAVF_TXD_CTX_QW0_L2TAG2_PARAM;
 		}
 	}
+	if (*RTE_MBUF_DYNFIELD(pkt,
+		rte_pmd_iavf_tx_lldp_dynfield_offset, uint8_t *) > 0)
+		high_ctx_qw |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+			<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 	uint64_t high_data_qw = (IAVF_TX_DESC_DTYPE_DATA |
 				((uint64_t)flags  << IAVF_TXD_QW1_CMD_SHIFT) |
 				((uint64_t)pkt->data_len << IAVF_TXD_QW1_TX_BUF_SZ_SHIFT));
@@ -2258,6 +2262,10 @@ ctx_vtx(volatile struct iavf_tx_desc *txdp,
 					(uint64_t)pkt[1]->vlan_tci << IAVF_TXD_QW1_L2TAG1_SHIFT;
 			}
 		}
+		if (*RTE_MBUF_DYNFIELD(pkt[1],
+			rte_pmd_iavf_tx_lldp_dynfield_offset, uint8_t *) > 0)
+			hi_ctx_qw1 |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+				<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 
 		if (pkt[0]->ol_flags & RTE_MBUF_F_TX_VLAN) {
 			if (vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2) {
@@ -2270,6 +2278,10 @@ ctx_vtx(volatile struct iavf_tx_desc *txdp,
 					(uint64_t)pkt[0]->vlan_tci << IAVF_TXD_QW1_L2TAG1_SHIFT;
 			}
 		}
+		if (*RTE_MBUF_DYNFIELD(pkt[0],
+			rte_pmd_iavf_tx_lldp_dynfield_offset, uint8_t *) > 0)
+			hi_ctx_qw0 |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+				<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 
 		if (offload) {
 			iavf_txd_enable_offload(pkt[1], &hi_data_qw1);
@@ -2520,3 +2532,10 @@ iavf_xmit_pkts_vec_avx512_ctx_offload(void *tx_queue, struct rte_mbuf **tx_pkts,
 {
 	return iavf_xmit_pkts_vec_avx512_ctx_cmn(tx_queue, tx_pkts, nb_pkts, true);
 }
+
+uint16_t
+iavf_xmit_pkts_vec_avx512_ctx(void *tx_queue, struct rte_mbuf **tx_pkts,
+				  uint16_t nb_pkts)
+{
+	return iavf_xmit_pkts_vec_avx512_ctx_cmn(tx_queue, tx_pkts, nb_pkts, false);
+}
diff --git a/drivers/net/iavf/iavf_rxtx_vec_common.h b/drivers/net/iavf/iavf_rxtx_vec_common.h
index e18cdc3f11..5c5220048d 100644
--- a/drivers/net/iavf/iavf_rxtx_vec_common.h
+++ b/drivers/net/iavf/iavf_rxtx_vec_common.h
@@ -249,6 +249,11 @@ iavf_tx_vec_queue_default(struct iavf_tx_queue *txq)
 	if (txq->offloads & IAVF_TX_NO_VECTOR_FLAGS)
 		return -1;
 
+	if (rte_pmd_iavf_tx_lldp_dynfield_offset > 0) {
+		txq->use_ctx = 1;
+		return IAVF_VECTOR_CTX_PATH;
+	}
+
 	/**
 	 * Vlan tci needs to be inserted via ctx desc, if the vlan_flag is L2TAG2.
 	 * Tunneling parameters and other fields need be configured in ctx desc
-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v5 3/3] net/iavf: add Tx LLDP command
  2023-12-28  3:22           ` [PATCH v5 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
  2023-12-28  3:22             ` [PATCH v5 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
  2023-12-28  3:22             ` [PATCH v5 2/3] net/iavf: support Tx LLDP on AVX512 Zhichao Zeng
@ 2023-12-28  3:22             ` Zhichao Zeng
  2024-01-03  7:47             ` [PATCH v6 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
  2024-01-04  0:26             ` [PATCH v5 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhang, Qi Z
  4 siblings, 0 replies; 27+ messages in thread
From: Zhichao Zeng @ 2023-12-28  3:22 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, Zhichao Zeng, Jingjing Wu, Beilei Xing

This patch adds an IAVF testpmd command "set tx lldp on|off" which
will register an mbuf dynfield IAVF_TX_LLDP_DYNFIELD to indicate
the need to send LLDP packet.

It needs to close the Tx port first, then "set tx lldp on", and reopen
the port to select correct Tx path, only supports turning on for now.

Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
 doc/guides/rel_notes/release_24_03.rst |  3 +
 drivers/net/iavf/iavf_testpmd.c        | 81 ++++++++++++++++++++++++++
 drivers/net/iavf/meson.build           |  3 +
 3 files changed, 87 insertions(+)
 create mode 100644 drivers/net/iavf/iavf_testpmd.c

diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst
index 6f8ad27808..f94e18c33a 100644
--- a/doc/guides/rel_notes/release_24_03.rst
+++ b/doc/guides/rel_notes/release_24_03.rst
@@ -55,6 +55,9 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Updated Intel iavf driver.**
+
+  * Added support for Tx LLDP packet on scalar and avx512.
 
 Removed Items
 -------------
diff --git a/drivers/net/iavf/iavf_testpmd.c b/drivers/net/iavf/iavf_testpmd.c
new file mode 100644
index 0000000000..07aac07fc3
--- /dev/null
+++ b/drivers/net/iavf/iavf_testpmd.c
@@ -0,0 +1,81 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2016 Intel Corporation.
+ */
+
+#include <stdlib.h>
+
+#include <rte_pmd_iavf.h>
+
+#include <cmdline_parse_num.h>
+#include <cmdline_parse_string.h>
+
+#include "iavf.h"
+#include "testpmd.h"
+#include "iavf_rxtx.h"
+
+struct cmd_enable_tx_lldp_result {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t tx;
+	cmdline_fixed_string_t lldp;
+	cmdline_fixed_string_t what;
+};
+
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_set =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		set, "set");
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_tx =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		tx, "tx");
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_lldp =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		lldp, "lldp");
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_what =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		what, "on#off");
+
+static void
+cmd_enable_tx_lldp_parsed(void *parsed_result,
+	__rte_unused struct cmdline *cl, __rte_unused void *data)
+{
+	struct cmd_enable_tx_lldp_result *res = parsed_result;
+	const struct rte_mbuf_dynfield iavf_tx_lldp_dynfield = {
+		.name = IAVF_TX_LLDP_DYNFIELD,
+		.size = sizeof(uint8_t),
+		.align = __alignof__(uint8_t),
+		.flags = 0
+	};
+	int offset;
+
+	if (strncmp(res->what, "on", 2) == 0) {
+		offset = rte_mbuf_dynfield_register(&iavf_tx_lldp_dynfield);
+		printf("rte_pmd_iavf_tx_lldp_dynfield_offset: %d", offset);
+		if (offset < 0)
+			fprintf(stderr,
+				"rte mbuf dynfield register failed, offset: %d", offset);
+	}
+}
+
+static cmdline_parse_inst_t cmd_enable_tx_lldp = {
+	.f = cmd_enable_tx_lldp_parsed,
+	.data = NULL,
+	.help_str = "set iavf tx lldp on|off",
+	.tokens = {
+		(void *)&cmd_enable_tx_lldp_set,
+		(void *)&cmd_enable_tx_lldp_tx,
+		(void *)&cmd_enable_tx_lldp_lldp,
+		(void *)&cmd_enable_tx_lldp_what,
+		NULL,
+	},
+};
+
+static struct testpmd_driver_commands iavf_cmds = {
+	.commands = {
+	{
+		&cmd_enable_tx_lldp,
+		"set tx lldp (on|off)\n"
+		"    Set iavf Tx lldp packet(currently only supported on)\n\n",
+	},
+	{ NULL, NULL },
+	},
+};
+TESTPMD_ADD_DRIVER_COMMANDS(iavf_cmds)
diff --git a/drivers/net/iavf/meson.build b/drivers/net/iavf/meson.build
index a6ce2725c3..83aebd5596 100644
--- a/drivers/net/iavf/meson.build
+++ b/drivers/net/iavf/meson.build
@@ -8,6 +8,9 @@ endif
 cflags += ['-Wno-strict-aliasing']
 
 includes += include_directories('../../common/iavf')
+
+testpmd_sources = files('iavf_testpmd.c')
+
 deps += ['common_iavf', 'security', 'cryptodev']
 
 sources = files(
-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v6 0/3] net/iavf: support Tx LLDP on scalar and AVX512
  2023-12-28  3:22           ` [PATCH v5 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
                               ` (2 preceding siblings ...)
  2023-12-28  3:22             ` [PATCH v5 3/3] net/iavf: add Tx LLDP command Zhichao Zeng
@ 2024-01-03  7:47             ` Zhichao Zeng
  2024-01-03  7:47               ` [PATCH v6 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
                                 ` (2 more replies)
  2024-01-04  0:26             ` [PATCH v5 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhang, Qi Z
  4 siblings, 3 replies; 27+ messages in thread
From: Zhichao Zeng @ 2024-01-03  7:47 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, Zhichao Zeng

This patch set adds an IAVF testpmd command "set tx lldp on" which
will register an mbuf dynfield IAVF_TX_LLDP_DYNFIELD to indicate
the need to test TX LLDP packet. It needs to stop and restart Tx port
to select correct Tx path.

IAVF will fill the SWTCH_UPLINK bit in the Tx context descriptor based on
the mbuf dynfield to transmit the LLDP packet.

---
v6: check dynfield before access
v5: check dynfield at dev_start
v4: fix compile error
v3: non-lldp packet do not use the context descriptor
v2: split into patch set, refine commit log

Zhichao Zeng (3):
  net/iavf: support Tx LLDP on scalar
  net/iavf: support Tx LLDP on AVX512
  net/iavf: add Tx LLDP command

 doc/guides/nics/intel_vf.rst            | 17 ++++++
 drivers/net/iavf/iavf_ethdev.c          |  5 ++
 drivers/net/iavf/iavf_rxtx.c            | 18 +++++-
 drivers/net/iavf/iavf_rxtx.h            | 11 ++++
 drivers/net/iavf/iavf_rxtx_vec_avx512.c | 16 +++++
 drivers/net/iavf/iavf_rxtx_vec_common.h |  5 ++
 drivers/net/iavf/iavf_testpmd.c         | 81 +++++++++++++++++++++++++
 drivers/net/iavf/meson.build            |  3 +
 8 files changed, 154 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/iavf/iavf_testpmd.c

-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v6 1/3] net/iavf: support Tx LLDP on scalar
  2024-01-03  7:47             ` [PATCH v6 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
@ 2024-01-03  7:47               ` Zhichao Zeng
  2024-01-03  7:47               ` [PATCH v6 2/3] net/iavf: support Tx LLDP on AVX512 Zhichao Zeng
  2024-01-03  7:47               ` [PATCH v6 3/3] net/iavf: add Tx LLDP command Zhichao Zeng
  2 siblings, 0 replies; 27+ messages in thread
From: Zhichao Zeng @ 2024-01-03  7:47 UTC (permalink / raw)
  To: dev; +Cc: qi.z.zhang, Zhichao Zeng, Jingjing Wu, Beilei Xing

This patch adds an mbuf dynfield IAVF_TX_LLDP_DYNFIELD to determine
whether or not to fill the SWTCH_UPLINK bit in the Tx context descriptor
to transmit LLDP packet.

Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
 drivers/net/iavf/iavf_ethdev.c |  5 +++++
 drivers/net/iavf/iavf_rxtx.c   | 13 +++++++++++--
 drivers/net/iavf/iavf_rxtx.h   |  8 ++++++++
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index d1edb0dd5c..ef34246d36 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -41,6 +41,7 @@
 #define IAVF_NO_POLL_ON_LINK_DOWN_ARG "no-poll-on-link-down"
 uint64_t iavf_timestamp_dynflag;
 int iavf_timestamp_dynfield_offset = -1;
+int rte_pmd_iavf_tx_lldp_dynfield_offset = -1;
 
 static const char * const iavf_valid_args[] = {
 	IAVF_PROTO_XTR_ARG,
@@ -1017,6 +1018,10 @@ iavf_dev_start(struct rte_eth_dev *dev)
 		}
 	}
 
+	/* Check Tx LLDP dynfield */
+	rte_pmd_iavf_tx_lldp_dynfield_offset =
+		rte_mbuf_dynfield_lookup(IAVF_TX_LLDP_DYNFIELD, NULL);
+
 	if (iavf_init_queues(dev) != 0) {
 		PMD_DRV_LOG(ERR, "failed to do Queue init");
 		return -1;
diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index f19aa14646..4329809d1d 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -2418,8 +2418,9 @@ iavf_xmit_cleanup(struct iavf_tx_queue *txq)
 
 /* Check if the context descriptor is needed for TX offloading */
 static inline uint16_t
-iavf_calc_context_desc(uint64_t flags, uint8_t vlan_flag)
+iavf_calc_context_desc(struct rte_mbuf *mb, uint8_t vlan_flag)
 {
+	uint64_t flags = mb->ol_flags;
 	if (flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG |
 	    RTE_MBUF_F_TX_TUNNEL_MASK | RTE_MBUF_F_TX_OUTER_IP_CKSUM |
 	    RTE_MBUF_F_TX_OUTER_UDP_CKSUM))
@@ -2427,6 +2428,10 @@ iavf_calc_context_desc(uint64_t flags, uint8_t vlan_flag)
 	if (flags & RTE_MBUF_F_TX_VLAN &&
 	    vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2)
 		return 1;
+
+	if (IAVF_CHECK_TX_LLDP(mb))
+		return 1;
+
 	return 0;
 }
 
@@ -2446,6 +2451,10 @@ iavf_fill_ctx_desc_cmd_field(volatile uint64_t *field, struct rte_mbuf *m,
 			<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 	}
 
+	if (IAVF_CHECK_TX_LLDP(m))
+		cmd |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+			<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
+
 	*field |= cmd;
 }
 
@@ -2826,7 +2835,7 @@ iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 
 		nb_desc_data = mb->nb_segs;
 		nb_desc_ctx =
-			iavf_calc_context_desc(mb->ol_flags, txq->vlan_flag);
+			iavf_calc_context_desc(mb, txq->vlan_flag);
 		nb_desc_ipsec = !!(mb->ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD);
 
 		/**
diff --git a/drivers/net/iavf/iavf_rxtx.h b/drivers/net/iavf/iavf_rxtx.h
index f432f9d956..25df517bc6 100644
--- a/drivers/net/iavf/iavf_rxtx.h
+++ b/drivers/net/iavf/iavf_rxtx.h
@@ -107,8 +107,16 @@
 #define IAVF_MAX_DATA_PER_TXD \
 	(IAVF_TXD_QW1_TX_BUF_SZ_MASK >> IAVF_TXD_QW1_TX_BUF_SZ_SHIFT)
 
+#define IAVF_TX_LLDP_DYNFIELD "intel_pmd_dynfield_tx_lldp"
+#define IAVF_CHECK_TX_LLDP(m) \
+	((rte_pmd_iavf_tx_lldp_dynfield_offset > 0) && \
+	(*RTE_MBUF_DYNFIELD((m), \
+			rte_pmd_iavf_tx_lldp_dynfield_offset, \
+			uint8_t *)))
+
 extern uint64_t iavf_timestamp_dynflag;
 extern int iavf_timestamp_dynfield_offset;
+extern int rte_pmd_iavf_tx_lldp_dynfield_offset;
 
 /**
  * Rx Flex Descriptors
-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v6 2/3] net/iavf: support Tx LLDP on AVX512
  2024-01-03  7:47             ` [PATCH v6 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
  2024-01-03  7:47               ` [PATCH v6 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
@ 2024-01-03  7:47               ` Zhichao Zeng
  2024-01-03  7:47               ` [PATCH v6 3/3] net/iavf: add Tx LLDP command Zhichao Zeng
  2 siblings, 0 replies; 27+ messages in thread
From: Zhichao Zeng @ 2024-01-03  7:47 UTC (permalink / raw)
  To: dev
  Cc: qi.z.zhang, Zhichao Zeng, Jingjing Wu, Beilei Xing,
	Bruce Richardson, Konstantin Ananyev

This patch adds an avx512 ctx Tx path that supports context descriptor,
filling in the SWTCH_UPLINK bit based on mbuf
dynfield IAVF_TX_LLDP_DYNFIELD to support transmitting LLDP packet.

Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
 drivers/net/iavf/iavf_rxtx.c            |  5 +++++
 drivers/net/iavf/iavf_rxtx.h            |  3 +++
 drivers/net/iavf/iavf_rxtx_vec_avx512.c | 16 ++++++++++++++++
 drivers/net/iavf/iavf_rxtx_vec_common.h |  5 +++++
 4 files changed, 29 insertions(+)

diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index 4329809d1d..e54fb74b79 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -4048,6 +4048,11 @@ iavf_set_tx_function(struct rte_eth_dev *dev)
 				dev->tx_pkt_prepare = iavf_prep_pkts;
 				PMD_DRV_LOG(DEBUG, "Using AVX512 OFFLOAD Vector Tx (port %d).",
 					    dev->data->port_id);
+			} else if (check_ret == IAVF_VECTOR_CTX_PATH) {
+				dev->tx_pkt_burst = iavf_xmit_pkts_vec_avx512_ctx;
+				dev->tx_pkt_prepare = iavf_prep_pkts;
+				PMD_DRV_LOG(DEBUG, "Using AVX512 CONTEXT Vector Tx (port %d).",
+						dev->data->port_id);
 			} else {
 				dev->tx_pkt_burst = iavf_xmit_pkts_vec_avx512_ctx_offload;
 				dev->tx_pkt_prepare = iavf_prep_pkts;
diff --git a/drivers/net/iavf/iavf_rxtx.h b/drivers/net/iavf/iavf_rxtx.h
index 25df517bc6..a8af263d59 100644
--- a/drivers/net/iavf/iavf_rxtx.h
+++ b/drivers/net/iavf/iavf_rxtx.h
@@ -66,6 +66,7 @@
 #define IAVF_VECTOR_PATH 0
 #define IAVF_VECTOR_OFFLOAD_PATH 1
 #define IAVF_VECTOR_CTX_OFFLOAD_PATH 2
+#define IAVF_VECTOR_CTX_PATH 3
 
 #define DEFAULT_TX_RS_THRESH     32
 #define DEFAULT_TX_FREE_THRESH   32
@@ -760,6 +761,8 @@ uint16_t iavf_xmit_pkts_vec_avx512_offload(void *tx_queue,
 					   uint16_t nb_pkts);
 uint16_t iavf_xmit_pkts_vec_avx512_ctx_offload(void *tx_queue, struct rte_mbuf **tx_pkts,
 				  uint16_t nb_pkts);
+uint16_t iavf_xmit_pkts_vec_avx512_ctx(void *tx_queue, struct rte_mbuf **tx_pkts,
+				  uint16_t nb_pkts);
 int iavf_txq_vec_setup_avx512(struct iavf_tx_queue *txq);
 
 uint8_t iavf_proto_xtr_type_to_rxdid(uint8_t xtr_type);
diff --git a/drivers/net/iavf/iavf_rxtx_vec_avx512.c b/drivers/net/iavf/iavf_rxtx_vec_avx512.c
index 7a7df6d258..3bb6f305df 100644
--- a/drivers/net/iavf/iavf_rxtx_vec_avx512.c
+++ b/drivers/net/iavf/iavf_rxtx_vec_avx512.c
@@ -2206,6 +2206,9 @@ ctx_vtx1(volatile struct iavf_tx_desc *txdp, struct rte_mbuf *pkt,
 			low_ctx_qw |= (uint64_t)pkt->vlan_tci << IAVF_TXD_CTX_QW0_L2TAG2_PARAM;
 		}
 	}
+	if (IAVF_CHECK_TX_LLDP(pkt))
+		high_ctx_qw |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+			<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 	uint64_t high_data_qw = (IAVF_TX_DESC_DTYPE_DATA |
 				((uint64_t)flags  << IAVF_TXD_QW1_CMD_SHIFT) |
 				((uint64_t)pkt->data_len << IAVF_TXD_QW1_TX_BUF_SZ_SHIFT));
@@ -2258,6 +2261,9 @@ ctx_vtx(volatile struct iavf_tx_desc *txdp,
 					(uint64_t)pkt[1]->vlan_tci << IAVF_TXD_QW1_L2TAG1_SHIFT;
 			}
 		}
+		if (IAVF_CHECK_TX_LLDP(pkt[1]))
+			hi_ctx_qw1 |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+				<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 
 		if (pkt[0]->ol_flags & RTE_MBUF_F_TX_VLAN) {
 			if (vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2) {
@@ -2270,6 +2276,9 @@ ctx_vtx(volatile struct iavf_tx_desc *txdp,
 					(uint64_t)pkt[0]->vlan_tci << IAVF_TXD_QW1_L2TAG1_SHIFT;
 			}
 		}
+		if (IAVF_CHECK_TX_LLDP(pkt[0]))
+			hi_ctx_qw0 |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
+				<< IAVF_TXD_CTX_QW1_CMD_SHIFT;
 
 		if (offload) {
 			iavf_txd_enable_offload(pkt[1], &hi_data_qw1);
@@ -2520,3 +2529,10 @@ iavf_xmit_pkts_vec_avx512_ctx_offload(void *tx_queue, struct rte_mbuf **tx_pkts,
 {
 	return iavf_xmit_pkts_vec_avx512_ctx_cmn(tx_queue, tx_pkts, nb_pkts, true);
 }
+
+uint16_t
+iavf_xmit_pkts_vec_avx512_ctx(void *tx_queue, struct rte_mbuf **tx_pkts,
+				  uint16_t nb_pkts)
+{
+	return iavf_xmit_pkts_vec_avx512_ctx_cmn(tx_queue, tx_pkts, nb_pkts, false);
+}
diff --git a/drivers/net/iavf/iavf_rxtx_vec_common.h b/drivers/net/iavf/iavf_rxtx_vec_common.h
index e18cdc3f11..5c5220048d 100644
--- a/drivers/net/iavf/iavf_rxtx_vec_common.h
+++ b/drivers/net/iavf/iavf_rxtx_vec_common.h
@@ -249,6 +249,11 @@ iavf_tx_vec_queue_default(struct iavf_tx_queue *txq)
 	if (txq->offloads & IAVF_TX_NO_VECTOR_FLAGS)
 		return -1;
 
+	if (rte_pmd_iavf_tx_lldp_dynfield_offset > 0) {
+		txq->use_ctx = 1;
+		return IAVF_VECTOR_CTX_PATH;
+	}
+
 	/**
 	 * Vlan tci needs to be inserted via ctx desc, if the vlan_flag is L2TAG2.
 	 * Tunneling parameters and other fields need be configured in ctx desc
-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v6 3/3] net/iavf: add Tx LLDP command
  2024-01-03  7:47             ` [PATCH v6 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
  2024-01-03  7:47               ` [PATCH v6 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
  2024-01-03  7:47               ` [PATCH v6 2/3] net/iavf: support Tx LLDP on AVX512 Zhichao Zeng
@ 2024-01-03  7:47               ` Zhichao Zeng
  2 siblings, 0 replies; 27+ messages in thread
From: Zhichao Zeng @ 2024-01-03  7:47 UTC (permalink / raw)
  To: dev
  Cc: qi.z.zhang, Zhichao Zeng, Simei Su, Wenjun Wu, Qiming Yang,
	Yuying Zhang, Beilei Xing, Jingjing Wu

This patch adds an IAVF testpmd command "set tx lldp on" which
will register an mbuf dynfield IAVF_TX_LLDP_DYNFIELD to indicate
the need to test transmit LLDP packet.

It needs to stop and restart Tx port to select correct Tx path.

Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
 doc/guides/nics/intel_vf.rst    | 17 +++++++
 drivers/net/iavf/iavf_testpmd.c | 81 +++++++++++++++++++++++++++++++++
 drivers/net/iavf/meson.build    |  3 ++
 3 files changed, 101 insertions(+)
 create mode 100644 drivers/net/iavf/iavf_testpmd.c

diff --git a/doc/guides/nics/intel_vf.rst b/doc/guides/nics/intel_vf.rst
index ad08198f0f..ce96c2e1f8 100644
--- a/doc/guides/nics/intel_vf.rst
+++ b/doc/guides/nics/intel_vf.rst
@@ -627,6 +627,23 @@ Inline IPsec Support
     documentation.
 
 
+Diagnostic Utilities
+--------------------
+
+Register mbuf dynfield to test Tx LLDP
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Register an mbuf dynfield IAVF_TX_LLDP_DYNFIELD on dev_start to indicate
+the need to send LLDP packet, this dynfield needs to be set to 1 when
+preparing packet.
+
+For dpdk-testpmd application, it needs to stop and restart Tx port
+to take effect.
+
+Usage::
+
+    testpmd>set tx lldp on
+
 Limitations or Knowing issues
 -----------------------------
 
diff --git a/drivers/net/iavf/iavf_testpmd.c b/drivers/net/iavf/iavf_testpmd.c
new file mode 100644
index 0000000000..07aac07fc3
--- /dev/null
+++ b/drivers/net/iavf/iavf_testpmd.c
@@ -0,0 +1,81 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2016 Intel Corporation.
+ */
+
+#include <stdlib.h>
+
+#include <rte_pmd_iavf.h>
+
+#include <cmdline_parse_num.h>
+#include <cmdline_parse_string.h>
+
+#include "iavf.h"
+#include "testpmd.h"
+#include "iavf_rxtx.h"
+
+struct cmd_enable_tx_lldp_result {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t tx;
+	cmdline_fixed_string_t lldp;
+	cmdline_fixed_string_t what;
+};
+
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_set =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		set, "set");
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_tx =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		tx, "tx");
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_lldp =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		lldp, "lldp");
+static cmdline_parse_token_string_t cmd_enable_tx_lldp_what =
+	TOKEN_STRING_INITIALIZER(struct cmd_enable_tx_lldp_result,
+		what, "on#off");
+
+static void
+cmd_enable_tx_lldp_parsed(void *parsed_result,
+	__rte_unused struct cmdline *cl, __rte_unused void *data)
+{
+	struct cmd_enable_tx_lldp_result *res = parsed_result;
+	const struct rte_mbuf_dynfield iavf_tx_lldp_dynfield = {
+		.name = IAVF_TX_LLDP_DYNFIELD,
+		.size = sizeof(uint8_t),
+		.align = __alignof__(uint8_t),
+		.flags = 0
+	};
+	int offset;
+
+	if (strncmp(res->what, "on", 2) == 0) {
+		offset = rte_mbuf_dynfield_register(&iavf_tx_lldp_dynfield);
+		printf("rte_pmd_iavf_tx_lldp_dynfield_offset: %d", offset);
+		if (offset < 0)
+			fprintf(stderr,
+				"rte mbuf dynfield register failed, offset: %d", offset);
+	}
+}
+
+static cmdline_parse_inst_t cmd_enable_tx_lldp = {
+	.f = cmd_enable_tx_lldp_parsed,
+	.data = NULL,
+	.help_str = "set iavf tx lldp on|off",
+	.tokens = {
+		(void *)&cmd_enable_tx_lldp_set,
+		(void *)&cmd_enable_tx_lldp_tx,
+		(void *)&cmd_enable_tx_lldp_lldp,
+		(void *)&cmd_enable_tx_lldp_what,
+		NULL,
+	},
+};
+
+static struct testpmd_driver_commands iavf_cmds = {
+	.commands = {
+	{
+		&cmd_enable_tx_lldp,
+		"set tx lldp (on|off)\n"
+		"    Set iavf Tx lldp packet(currently only supported on)\n\n",
+	},
+	{ NULL, NULL },
+	},
+};
+TESTPMD_ADD_DRIVER_COMMANDS(iavf_cmds)
diff --git a/drivers/net/iavf/meson.build b/drivers/net/iavf/meson.build
index a6ce2725c3..83aebd5596 100644
--- a/drivers/net/iavf/meson.build
+++ b/drivers/net/iavf/meson.build
@@ -8,6 +8,9 @@ endif
 cflags += ['-Wno-strict-aliasing']
 
 includes += include_directories('../../common/iavf')
+
+testpmd_sources = files('iavf_testpmd.c')
+
 deps += ['common_iavf', 'security', 'cryptodev']
 
 sources = files(
-- 
2.34.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* RE: [PATCH v5 0/3] net/iavf: support Tx LLDP on scalar and AVX512
  2023-12-28  3:22           ` [PATCH v5 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
                               ` (3 preceding siblings ...)
  2024-01-03  7:47             ` [PATCH v6 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
@ 2024-01-04  0:26             ` Zhang, Qi Z
  4 siblings, 0 replies; 27+ messages in thread
From: Zhang, Qi Z @ 2024-01-04  0:26 UTC (permalink / raw)
  To: Zeng, ZhichaoX, dev



> -----Original Message-----
> From: Zeng, ZhichaoX <zhichaox.zeng@intel.com>
> Sent: Thursday, December 28, 2023 11:22 AM
> To: dev@dpdk.org
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; Zeng, ZhichaoX
> <zhichaox.zeng@intel.com>
> Subject: [PATCH v5 0/3] net/iavf: support Tx LLDP on scalar and AVX512
> 
> This patch set adds an IAVF testpmd command "set tx lldp on|off" which will
> register an mbuf dynfield IAVF_TX_LLDP_DYNFIELD to indicate the need to
> send LLDP packet. It needs to close the Tx port first, then "set tx lldp on", and
> reopen the port to select correct Tx path, only supports turning on for now.
> 
> IAVF will fill the SWTCH_UPLINK bit in the Tx context descriptor based on the
> mbuf dynfield to send the LLDP packet.
> 
> ---
> v5: check dynfield at dev_start
> v4: fix compile error
> v3: non-lldp packet do not use the context descriptor
> v2: split into patch set, refine commit log
> 
> Zhichao Zeng (3):
>   net/iavf: support Tx LLDP on scalar
>   net/iavf: support Tx LLDP on AVX512
>   net/iavf: add Tx LLDP command
> 
>  doc/guides/rel_notes/release_24_03.rst  |  3 +
>  drivers/net/iavf/iavf_ethdev.c          |  5 ++
>  drivers/net/iavf/iavf_rxtx.c            | 21 ++++++-
>  drivers/net/iavf/iavf_rxtx.h            |  6 ++
>  drivers/net/iavf/iavf_rxtx_vec_avx512.c | 19 ++++++
> drivers/net/iavf/iavf_rxtx_vec_common.h |  5 ++
>  drivers/net/iavf/iavf_testpmd.c         | 81 +++++++++++++++++++++++++
>  drivers/net/iavf/meson.build            |  3 +
>  8 files changed, 141 insertions(+), 2 deletions(-)  create mode 100644
> drivers/net/iavf/iavf_testpmd.c
> 
> --
> 2.34.1

Acked-by: Qi Zhang <qi.z.zhang@intel.com>

Applied to dpdk-next-net-intel.

Thanks
Qi


^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2024-01-04  0:26 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-06  6:08 [PATCH] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
2023-12-14  6:58 ` [PATCH v2 0/3] " Zhichao Zeng
2023-12-14  6:58   ` [PATCH v2 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
2023-12-14  6:58   ` [PATCH v2 2/3] net/iavf: support Tx LLDP on AVX512 Zhichao Zeng
2023-12-14  6:58   ` [PATCH v2 3/3] net/iavf: add Tx LLDP command Zhichao Zeng
2023-12-20  9:32   ` [PATCH v3 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
2023-12-20  9:32     ` [PATCH v3 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
2023-12-21  7:28       ` [PATCH v4 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
2023-12-21  7:28         ` [PATCH v4 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
2023-12-27  4:34           ` Zhang, Qi Z
2023-12-21  7:28         ` [PATCH v4 2/3] net/iavf: support Tx LLDP on AVX512 Zhichao Zeng
2023-12-21  7:28         ` [PATCH v4 3/3] net/iavf: add Tx LLDP command Zhichao Zeng
2023-12-25  3:14         ` [PATCH v4 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
2023-12-25  3:14           ` [PATCH v4 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
2023-12-25  3:14           ` [PATCH v4 2/3] net/iavf: support Tx LLDP on AVX512 Zhichao Zeng
2023-12-25  3:14           ` [PATCH v4 3/3] net/iavf: add Tx LLDP command Zhichao Zeng
2023-12-28  3:22           ` [PATCH v5 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
2023-12-28  3:22             ` [PATCH v5 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
2023-12-28  3:22             ` [PATCH v5 2/3] net/iavf: support Tx LLDP on AVX512 Zhichao Zeng
2023-12-28  3:22             ` [PATCH v5 3/3] net/iavf: add Tx LLDP command Zhichao Zeng
2024-01-03  7:47             ` [PATCH v6 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhichao Zeng
2024-01-03  7:47               ` [PATCH v6 1/3] net/iavf: support Tx LLDP on scalar Zhichao Zeng
2024-01-03  7:47               ` [PATCH v6 2/3] net/iavf: support Tx LLDP on AVX512 Zhichao Zeng
2024-01-03  7:47               ` [PATCH v6 3/3] net/iavf: add Tx LLDP command Zhichao Zeng
2024-01-04  0:26             ` [PATCH v5 0/3] net/iavf: support Tx LLDP on scalar and AVX512 Zhang, Qi Z
2023-12-20  9:32     ` [PATCH v3 2/3] net/iavf: support Tx LLDP on AVX512 Zhichao Zeng
2023-12-20  9:32     ` [PATCH v3 3/3] net/iavf: add Tx LLDP command Zhichao Zeng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).