diff mbox series

[v2,3/3] net/ixgbe: move bypass init in a testpmd command

Message ID 20220617050753.1273320-3-david.marchand@redhat.com (mailing list archive)
State Under Review
Delegated to: Ferruh Yigit
Headers show
Series [v2,1/3] app/testpmd: restore ixgbe bypass commands | expand

Checks

Context Check Description
ci/iol-abi-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

David Marchand June 17, 2022, 5:07 a.m. UTC
Introduce a new command and remove the last part of specific port init
from testpmd.

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 app/test-pmd/meson.build          |  1 -
 app/test-pmd/testpmd.c            |  4 --
 doc/guides/nics/ixgbe.rst         |  7 +++
 drivers/net/ixgbe/ixgbe_testpmd.c | 82 +++++++++++++++++++++++++++++++
 4 files changed, 89 insertions(+), 5 deletions(-)

Comments

Ferruh Yigit June 20, 2022, 7:04 p.m. UTC | #1
On 6/17/2022 6:07 AM, David Marchand wrote:
> Introduce a new command and remove the last part of specific port init
> from testpmd.
> 
> Signed-off-by: David Marchand<david.marchand@redhat.com>
> ---
>   app/test-pmd/meson.build          |  1 -
>   app/test-pmd/testpmd.c            |  4 --
>   doc/guides/nics/ixgbe.rst         |  7 +++
>   drivers/net/ixgbe/ixgbe_testpmd.c | 82 +++++++++++++++++++++++++++++++
>   4 files changed, 89 insertions(+), 5 deletions(-)
> 
> diff --git a/app/test-pmd/meson.build b/app/test-pmd/meson.build
> index 69c7595a45..d13e98125e 100644
> --- a/app/test-pmd/meson.build
> +++ b/app/test-pmd/meson.build
> @@ -68,7 +68,6 @@ if dpdk_conf.has('RTE_NET_I40E')
>       deps += 'net_i40e'
>   endif
>   if dpdk_conf.has('RTE_NET_IXGBE')
> -    cflags += ['-DRTE_LIBRTE_IXGBE_BYPASS']
>       deps += 'net_ixgbe'
>   endif
>   if dpdk_conf.has('RTE_NET_DPAA')
> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
> index 4e8523f961..e11e2e2cb8 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -3949,10 +3949,6 @@ init_port_config(void)
>   		if (ret != 0)
>   			return;
>   
> -#if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
> -		rte_pmd_ixgbe_bypass_init(pid);
> -#endif
> -
>   		if (lsc_interrupt && (*port->dev_info.dev_flags & RTE_ETH_DEV_INTR_LSC))
>   			port->dev_conf.intr_conf.lsc = 1;
>   		if (rmv_interrupt && (*port->dev_info.dev_flags & RTE_ETH_DEV_INTR_RMV))
> diff --git a/doc/guides/nics/ixgbe.rst b/doc/guides/nics/ixgbe.rst
> index ea4684c2dc..d450fc1ca0 100644
> --- a/doc/guides/nics/ixgbe.rst
> +++ b/doc/guides/nics/ixgbe.rst
> @@ -418,6 +418,13 @@ Set all TCs' TX min relative bandwidth (%) globally for all PF and VFs::
>   
>      testpmd> set tc tx min-bandwidth (port_id) (bw1, bw2, ...)
>   
> +port config bypass
> +~~~~~~~~~~~~~~~~~~
> +
> +Enable/disable bypass feature::
> +
> +   port config bypass (port_id) (on|off)
> +

Hi Qiming, Wenjun, Yu,

For me changes looks good but this set changes ixgbe bypass 
configuration in testpmd, instead of it being enabled by default, now an 
explicit command needs to be issued. This also can affect bypass testing.

Can you please test/comment on the set for the ixgbe bypass? For both 
functional and dts testing perspective?

Thanks,
ferruh
Zhang, Qi Z June 23, 2022, 12:35 p.m. UTC | #2
> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@xilinx.com>
> Sent: Tuesday, June 21, 2022 3:04 AM
> To: Yang, Qiming <qiming.yang@intel.com>; Wu, Wenjun1
> <wenjun1.wu@intel.com>; Jiang, YuX <yux.jiang@intel.com>
> Cc: Li, Xiaoyun <xiaoyun.li@intel.com>; Singh, Aman Deep
> <aman.deep.singh@intel.com>; Zhang, Yuying <yuying.zhang@intel.com>;
> dev@dpdk.org; David Marchand <david.marchand@redhat.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>
> Subject: Re: [PATCH v2 3/3] net/ixgbe: move bypass init in a testpmd command
> 
> On 6/17/2022 6:07 AM, David Marchand wrote:
> > Introduce a new command and remove the last part of specific port init
> > from testpmd.
> >
> > Signed-off-by: David Marchand<david.marchand@redhat.com>
> > ---
> >   app/test-pmd/meson.build          |  1 -
> >   app/test-pmd/testpmd.c            |  4 --
> >   doc/guides/nics/ixgbe.rst         |  7 +++
> >   drivers/net/ixgbe/ixgbe_testpmd.c | 82
> +++++++++++++++++++++++++++++++
> >   4 files changed, 89 insertions(+), 5 deletions(-)
> >
> > diff --git a/app/test-pmd/meson.build b/app/test-pmd/meson.build index
> > 69c7595a45..d13e98125e 100644
> > --- a/app/test-pmd/meson.build
> > +++ b/app/test-pmd/meson.build
> > @@ -68,7 +68,6 @@ if dpdk_conf.has('RTE_NET_I40E')
> >       deps += 'net_i40e'
> >   endif
> >   if dpdk_conf.has('RTE_NET_IXGBE')
> > -    cflags += ['-DRTE_LIBRTE_IXGBE_BYPASS']
> >       deps += 'net_ixgbe'
> >   endif
> >   if dpdk_conf.has('RTE_NET_DPAA')
> > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
> > 4e8523f961..e11e2e2cb8 100644
> > --- a/app/test-pmd/testpmd.c
> > +++ b/app/test-pmd/testpmd.c
> > @@ -3949,10 +3949,6 @@ init_port_config(void)
> >   		if (ret != 0)
> >   			return;
> >
> > -#if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
> > -		rte_pmd_ixgbe_bypass_init(pid);
> > -#endif
> > -
> >   		if (lsc_interrupt && (*port->dev_info.dev_flags &
> RTE_ETH_DEV_INTR_LSC))
> >   			port->dev_conf.intr_conf.lsc = 1;
> >   		if (rmv_interrupt && (*port->dev_info.dev_flags &
> > RTE_ETH_DEV_INTR_RMV)) diff --git a/doc/guides/nics/ixgbe.rst
> > b/doc/guides/nics/ixgbe.rst index ea4684c2dc..d450fc1ca0 100644
> > --- a/doc/guides/nics/ixgbe.rst
> > +++ b/doc/guides/nics/ixgbe.rst
> > @@ -418,6 +418,13 @@ Set all TCs' TX min relative bandwidth (%) globally
> for all PF and VFs::
> >
> >      testpmd> set tc tx min-bandwidth (port_id) (bw1, bw2, ...)
> >
> > +port config bypass
> > +~~~~~~~~~~~~~~~~~~
> > +
> > +Enable/disable bypass feature::
> > +
> > +   port config bypass (port_id) (on|off)
> > +
> 
> Hi Qiming, Wenjun, Yu,
> 
> For me changes looks good but this set changes ixgbe bypass configuration in
> testpmd, instead of it being enabled by default, now an explicit command needs
> to be issued. This also can affect bypass testing.
> 
> Can you please test/comment on the set for the ixgbe bypass? For both
> functional and dts testing perspective?

Thanks for capture this, after internal discussion, though we think its low risk but we prefer to hold on this patch merge before get the result of a ixgbe regression test.

If we missed RC2, we should be able to capture it in RC3.

Thanks
Qi

> 
> Thanks,
> ferruh
diff mbox series

Patch

diff --git a/app/test-pmd/meson.build b/app/test-pmd/meson.build
index 69c7595a45..d13e98125e 100644
--- a/app/test-pmd/meson.build
+++ b/app/test-pmd/meson.build
@@ -68,7 +68,6 @@  if dpdk_conf.has('RTE_NET_I40E')
     deps += 'net_i40e'
 endif
 if dpdk_conf.has('RTE_NET_IXGBE')
-    cflags += ['-DRTE_LIBRTE_IXGBE_BYPASS']
     deps += 'net_ixgbe'
 endif
 if dpdk_conf.has('RTE_NET_DPAA')
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 4e8523f961..e11e2e2cb8 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3949,10 +3949,6 @@  init_port_config(void)
 		if (ret != 0)
 			return;
 
-#if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
-		rte_pmd_ixgbe_bypass_init(pid);
-#endif
-
 		if (lsc_interrupt && (*port->dev_info.dev_flags & RTE_ETH_DEV_INTR_LSC))
 			port->dev_conf.intr_conf.lsc = 1;
 		if (rmv_interrupt && (*port->dev_info.dev_flags & RTE_ETH_DEV_INTR_RMV))
diff --git a/doc/guides/nics/ixgbe.rst b/doc/guides/nics/ixgbe.rst
index ea4684c2dc..d450fc1ca0 100644
--- a/doc/guides/nics/ixgbe.rst
+++ b/doc/guides/nics/ixgbe.rst
@@ -418,6 +418,13 @@  Set all TCs' TX min relative bandwidth (%) globally for all PF and VFs::
 
    testpmd> set tc tx min-bandwidth (port_id) (bw1, bw2, ...)
 
+port config bypass
+~~~~~~~~~~~~~~~~~~
+
+Enable/disable bypass feature::
+
+   port config bypass (port_id) (on|off)
+
 set bypass mode
 ~~~~~~~~~~~~~~~
 
diff --git a/drivers/net/ixgbe/ixgbe_testpmd.c b/drivers/net/ixgbe/ixgbe_testpmd.c
index a928d0fb55..e0d161eafe 100644
--- a/drivers/net/ixgbe/ixgbe_testpmd.c
+++ b/drivers/net/ixgbe/ixgbe_testpmd.c
@@ -2,6 +2,9 @@ 
  * Copyright(c) 2010-2016 Intel Corporation.
  */
 
+/* Required for ixgbe internal structures to be aligned with the driver */
+#define RTE_LIBRTE_IXGBE_BYPASS
+
 #include <ethdev_driver.h>
 #include "ixgbe_ethdev.h"
 #include "rte_pmd_ixgbe.h"
@@ -618,6 +621,71 @@  static cmdline_parse_inst_t cmd_tc_min_bw = {
 /* The NIC bypass watchdog timeout. */
 uint32_t bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
 
+static inline bool
+check_bypass_enabled(portid_t port_id)
+{
+	struct ixgbe_adapter *adapter;
+
+	adapter = rte_eth_devices[port_id].data->dev_private;
+	if (adapter->bps.ops.bypass_rw == NULL) {
+		fprintf(stderr, "Bypass is not enabled on this port.\n");
+		return false;
+	}
+
+	return true;
+}
+
+/* Enable bypass mode */
+struct cmd_config_bypass_result {
+	cmdline_fixed_string_t port;
+	cmdline_fixed_string_t config;
+	cmdline_fixed_string_t bypass;
+	portid_t port_id;
+	cmdline_fixed_string_t value;
+};
+
+static void
+cmd_config_bypass_parsed(void *parsed_result,
+		      __rte_unused struct cmdline *cl,
+		      __rte_unused void *data)
+{
+	struct cmd_config_bypass_result *res = parsed_result;
+	portid_t port_id = res->port_id;
+
+	if (ports[port_id].port_status == RTE_PORT_STARTED) {
+		fprintf(stderr, "Cannot change bypass configuration while port is started, please stop it and retry\n");
+		return;
+	}
+
+	if (strcmp(res->value, "on") == 0)
+		rte_pmd_ixgbe_bypass_init(port_id);
+}
+
+static cmdline_parse_token_string_t cmd_config_bypass_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_config_bypass_result, port, "port");
+static cmdline_parse_token_string_t cmd_config_bypass_config =
+	TOKEN_STRING_INITIALIZER(struct cmd_config_bypass_result, config, "config");
+static cmdline_parse_token_string_t cmd_config_bypass_bypass =
+	TOKEN_STRING_INITIALIZER(struct cmd_config_bypass_result, bypass, "bypass");
+static cmdline_parse_token_num_t cmd_config_bypass_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_config_bypass_result, port_id, RTE_UINT16);
+static cmdline_parse_token_string_t cmd_config_bypass_value =
+	TOKEN_STRING_INITIALIZER(struct cmd_config_bypass_result, value, "on#off");
+
+static cmdline_parse_inst_t cmd_config_bypass = {
+	.f = cmd_config_bypass_parsed,
+	.data = NULL,
+	.help_str = "port config bypass <port_id> on|off",
+	.tokens = {
+		(void *)&cmd_config_bypass_port,
+		(void *)&cmd_config_bypass_config,
+		(void *)&cmd_config_bypass_bypass,
+		(void *)&cmd_config_bypass_port_id,
+		(void *)&cmd_config_bypass_value,
+		NULL,
+	},
+};
+
 /* *** SET NIC BYPASS MODE *** */
 struct cmd_set_bypass_mode_result {
 	cmdline_fixed_string_t set;
@@ -636,6 +704,9 @@  cmd_set_bypass_mode_parsed(void *parsed_result,
 	portid_t port_id = res->port_id;
 	int32_t rc = -EINVAL;
 
+	if (!check_bypass_enabled(port_id))
+		return;
+
 	if (!strcmp(res->value, "bypass"))
 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
 	else if (!strcmp(res->value, "isolate"))
@@ -702,6 +773,9 @@  cmd_set_bypass_event_parsed(void *parsed_result,
 	uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
 
+	if (!check_bypass_enabled(port_id))
+		return;
+
 	if (!strcmp(res->event_value, "timeout"))
 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
 	else if (!strcmp(res->event_value, "os_on"))
@@ -878,6 +952,9 @@  cmd_show_bypass_config_parsed(void *parsed_result,
 		"power supply off",
 		"timeout"};
 
+	if (!check_bypass_enabled(port_id))
+		return;
+
 	/* Display the bypass mode.*/
 	if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
 		fprintf(stderr, "\tFailed to get bypass mode for port = %d\n",
@@ -973,6 +1050,11 @@  static struct testpmd_driver_commands ixgbe_cmds = {
 		"set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
 		"    Set all TCs' min bandwidth(%%) for all PF and VFs.\n",
 	},
+	{
+		&cmd_config_bypass,
+		"port config bypass (port_id) (on|off)\n"
+		"   Enable/disable bypass before starting the port\n",
+	},
 	{
 		&cmd_set_bypass_mode,
 		"set bypass mode (normal|bypass|isolate) (port_id)\n"