[v2,3/3] net/iavf: add Tx LLDP command

Message ID 20231214065857.2142565-4-zhichaox.zeng@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers
Series net/iavf: support Tx LLDP on scalar and AVX512 |

Checks

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

Commit Message

Zhichao Zeng Dec. 14, 2023, 6:58 a.m. UTC
  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
  

Patch

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(