[v1] app/testpmd: fix dynamic config error for max-pkt-len

Message ID 20201222081335.17419-1-stevex.yang@intel.com (mailing list archive)
State Superseded, archived
Headers
Series [v1] app/testpmd: fix dynamic config error for max-pkt-len |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-testing success Testing PASS

Commit Message

Steve Yang Dec. 22, 2020, 8:13 a.m. UTC
  When 'max-pkt-len' value caused the 'rx_offloads' flag change, the all
offloads of rx queues ('rx_conf[qid].offloads') weren't synchronized,
that will cause the offloads check failed with 'rx_queue_offload_capa'
within 'rte_eth_rx_queue_setup'.

Apply rx offloads configuration once it changed when 'max-pkt-len'
command parsed.

Fixes: 384161e00627 ("app/testpmd: adjust on the fly VLAN configuration")

Signed-off-by: Steve Yang <stevex.yang@intel.com>
---
 app/test-pmd/cmdline.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
  

Comments

Li, Xiaoyun Dec. 23, 2020, 2:27 a.m. UTC | #1
Hi
Comments inline

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Steve Yang
> Sent: Tuesday, December 22, 2020 16:14
> To: dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Xing, Beilei <beilei.xing@intel.com>;
> Iremonger, Bernard <bernard.iremonger@intel.com>; Yang, SteveX
> <stevex.yang@intel.com>
> Subject: [dpdk-dev] [PATCH v1] app/testpmd: fix dynamic config error for max-
> pkt-len
> 
> When 'max-pkt-len' value caused the 'rx_offloads' flag change, the all offloads
> of rx queues ('rx_conf[qid].offloads') weren't synchronized, that will cause the
> offloads check failed with 'rx_queue_offload_capa'
> within 'rte_eth_rx_queue_setup'.
> 
> Apply rx offloads configuration once it changed when 'max-pkt-len'
> command parsed.

Grammar and tense inconsistence...
You can phrase like the following:

Configuring 'max-pkt-len' would change 'rx_offloads' in dev_conf while rx_conf.offloads of each queue still kept the old value.
It would cause the failure of offloads check in ''rte_eth_rx_queue_setup'.

This patch applied rx offloads configuration for each queue once it changed.

> 
> Fixes: 384161e00627 ("app/testpmd: adjust on the fly VLAN configuration")
> 
> Signed-off-by: Steve Yang <stevex.yang@intel.com>
> ---
>  app/test-pmd/cmdline.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index
> 2ccbaa039e..d72a40d7de 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c
> @@ -1902,7 +1902,23 @@ cmd_config_max_pkt_len_parsed(void
> *parsed_result,
>  				rx_offloads |=
> DEV_RX_OFFLOAD_JUMBO_FRAME;
>  			else
>  				rx_offloads &=
> ~DEV_RX_OFFLOAD_JUMBO_FRAME;
> -			port->dev_conf.rxmode.offloads = rx_offloads;

I understand what you're doing here. But I think there's a better place to do this.
This config cmd will call init_port_config() later. And rxtx_port_config() will be called in it.
I think you should do this in rxtx_port_config().
Check if rx_conf  is equal to dev_conf, and if it's not consistent, apply dev_conf.

Although if you insist on your way doing this, there're some issues too. See below.

> +
> +			if (rx_offloads != port->dev_conf.rxmode.offloads) {
> +				uint16_t k;
> +				int ret;
> +
> +				port->dev_conf.rxmode.offloads = rx_offloads;
> +				/* Apply Rx offloads configuration */
> +				ret = eth_dev_info_get_print_err(pid,
> +							&port->dev_info);
> +				if (ret != 0)
> +					rte_exit(EXIT_FAILURE,
> +					    "rte_eth_dev_info_get() failed\n");

rte_exit if for the main process of the application not for cmdline.
Because rte_exit will just terminate the application and return to the shell. You wouldn't want that.
You only needs to 'return;' or maybe printf a error message and return.

> +
> +				for (k = 0;

Why are you using 'k'? There's no problem of this just looks a bit weird. There's no 'i' used in this function so why not just use 'i'.

> +				     k < port->dev_info.nb_rx_queues; k++)
> +					port->rx_conf[k].offloads =
> rx_offloads;
> +			}
>  		} else {
>  			printf("Unknown parameter\n");
>  			return;
> --
> 2.17.1
  

Patch

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 2ccbaa039e..d72a40d7de 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -1902,7 +1902,23 @@  cmd_config_max_pkt_len_parsed(void *parsed_result,
 				rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
 			else
 				rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
-			port->dev_conf.rxmode.offloads = rx_offloads;
+
+			if (rx_offloads != port->dev_conf.rxmode.offloads) {
+				uint16_t k;
+				int ret;
+
+				port->dev_conf.rxmode.offloads = rx_offloads;
+				/* Apply Rx offloads configuration */
+				ret = eth_dev_info_get_print_err(pid,
+							&port->dev_info);
+				if (ret != 0)
+					rte_exit(EXIT_FAILURE,
+					    "rte_eth_dev_info_get() failed\n");
+
+				for (k = 0;
+				     k < port->dev_info.nb_rx_queues; k++)
+					port->rx_conf[k].offloads = rx_offloads;
+			}
 		} else {
 			printf("Unknown parameter\n");
 			return;