Skip to contentSkip to conversation

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

PATCH Superseded Steve Yang 7 participants 38 messages Dec 22, 2020 – Jan 29, 2021 1 message not in the archive

lore
Share & tools
lore

Steve Yang

author
#0 lore raw

PATCH 1/1 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.

Fixes 384161e00627 ("app/testpmd: adjust on the fly VLAN configuration")
---
 app/test-pmd/cmdline.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
app/test-pmd/cmdline.c +17 -1
index 2ccbaa039e..d72a40d7de 100644
@@ -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;
Signature · 1 line
2.17.1
#1 lore raw

Hi
Comments inline

Quoted 10 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Steve Yang
Sent: Tuesday, December 22, 2020 16:14
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Xing, Beilei <[email protected]>; Iremonger, Bernard <[email protected]>; Yang, SteveX <[email protected]>
Subject: [dpdk-dev] [PATCH v1] app/testpmd: fix dynamic config error for max- pkt-len

Quoted 7 lines

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.

Quoted 13 lines
Fixes 384161e00627 ("app/testpmd: adjust on the fly VLAN configuration")
---
 app/test-pmd/cmdline.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
app/test-pmd/cmdline.c index renamed from app/test-pmd/cmdline.c +0 -0

2ccbaa039e..d72a40d7de 100644

app/test-pmd/cmdline.c cmd_config_max_pkt_len_parsed(void · line 1908

Quoted 7 lines
app/test-pmd/cmdline.c +0 -1
@@ -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.

app/test-pmd/cmdline.c cmd_config_max_pkt_len_parsed(void *parsed_result, · line 1916

Quoted 12 lines
app/test-pmd/cmdline.c +12 -0
+
+			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.

app/test-pmd/cmdline.c cmd_config_max_pkt_len_parsed(void · line 1921

Quoted 2 lines
app/test-pmd/cmdline.c +2 -0
+
+				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'.

Quoted 9 lines
app/test-pmd/cmdline.c +2 -0
+				     k < port->dev_info.nb_rx_queues; k++)
+					port->rx_conf[k].offloads =

rx_offloads;

app/test-pmd/cmdline.c +1 -1
+			}
 		} else {
 			printf("Unknown parameter\n");
 			return;
--

2.17.1

author
#2 lore raw

PATCH v2 1/1 app/testpmd: fix dynamic config error

In reply to Steve Yang

The offloads of 'tx/rx_conf' didn't keep up with the corresponding offloads of 'dev_conf', it would cause the configuration invalid.

For example:
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 tx/rx offloads configuration for each queue once it changed.

Fixes 5e91aeef218c ("app/testpmd: fix offload flags after port config")

---
v2:
* moved the update logic to 'rxtx_port_config';
* added the 'tx_conf' part;
* optimized the 'default' assignment;

---
 app/test-pmd/testpmd.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
app/test-pmd/testpmd.c +10 -6
index 33a060dffd..6ee28e3797 100644
@@ -3288,9 +3288,11 @@ rxtx_port_config(struct rte_port *port)
 
 	for (qid = 0; qid < nb_rxq; qid++) {
 		offloads = port->rx_conf[qid].offloads;
-		port->rx_conf[qid] = port->dev_info.default_rxconf;
-		if (offloads != 0)
-			port->rx_conf[qid].offloads = offloads;
+		if (offloads != port->dev_conf.rxmode.offloads)
+			port->rx_conf[qid].offloads =
+				port->dev_conf.rxmode.offloads;
+		if (!offloads)
+			port->rx_conf[qid] = port->dev_info.default_rxconf;
 
 		/* Check if any Rx parameters have been passed */
 		if (rx_pthresh != RTE_PMD_PARAM_UNSET)
@@ -3313,9 +3315,11 @@ rxtx_port_config(struct rte_port *port)
 
 	for (qid = 0; qid < nb_txq; qid++) {
 		offloads = port->tx_conf[qid].offloads;
-		port->tx_conf[qid] = port->dev_info.default_txconf;
-		if (offloads != 0)
-			port->tx_conf[qid].offloads = offloads;
+		if (offloads != port->dev_conf.txmode.offloads)
+			port->tx_conf[qid].offloads =
+				port->dev_conf.txmode.offloads;
+		if (!offloads)
+			port->tx_conf[qid] = port->dev_info.default_txconf;
 
 		/* Check if any Tx parameters have been passed */
 		if (tx_pthresh != RTE_PMD_PARAM_UNSET)
Signature · 1 line
2.17.1
Acked-by on v2 1/1
#3 lore raw

Re: [dpdk-dev] [PATCH v2] app/testpmd: fix dynamic config error

Quoted 68 lines

-----Original Message-----
From: Steve Yang <[email protected]>
Sent: Wednesday, December 23, 2020 16:52
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Xing, Beilei <[email protected]>; Iremonger, Bernard <[email protected]>; Li, Xiaoyun <[email protected]>; Yang, Qiming <[email protected]>; Yang, SteveX <[email protected]>
Subject: [PATCH v2] app/testpmd: fix dynamic config error

The offloads of 'tx/rx_conf' didn't keep up with the corresponding offloads of 'dev_conf', it would cause the configuration invalid.

For example:
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 tx/rx offloads configuration for each queue once it changed.

Fixes 5e91aeef218c ("app/testpmd: fix offload flags after port config")

---
v2:
* moved the update logic to 'rxtx_port_config';
* added the 'tx_conf' part;
* optimized the 'default' assignment;

---
 app/test-pmd/testpmd.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0 -0

33a060dffd..6ee28e3797 100644

app/test-pmd/testpmd.c +11 -7
@@ -3288,9 +3288,11 @@ rxtx_port_config(struct rte_port *port)
 
 	for (qid = 0; qid < nb_rxq; qid++) {
 		offloads = port->rx_conf[qid].offloads;
-		port->rx_conf[qid] = port->dev_info.default_rxconf;
-		if (offloads != 0)
-			port->rx_conf[qid].offloads = offloads;
+		if (offloads != port->dev_conf.rxmode.offloads)
+			port->rx_conf[qid].offloads =
+				port->dev_conf.rxmode.offloads;
+		if (!offloads)
+			port->rx_conf[qid] = port->dev_info.default_rxconf;
 
 		/* Check if any Rx parameters have been passed */
 		if (rx_pthresh != RTE_PMD_PARAM_UNSET) @@ -3313,9
+3315,11 @@ rxtx_port_config(struct rte_port *port)
 
 	for (qid = 0; qid < nb_txq; qid++) {
 		offloads = port->tx_conf[qid].offloads;
-		port->tx_conf[qid] = port->dev_info.default_txconf;
-		if (offloads != 0)
-			port->tx_conf[qid].offloads = offloads;
+		if (offloads != port->dev_conf.txmode.offloads)
+			port->tx_conf[qid].offloads =
+				port->dev_conf.txmode.offloads;
+		if (!offloads)
+			port->tx_conf[qid] = port->dev_info.default_txconf;
 
 		/* Check if any Tx parameters have been passed */
 		if (tx_pthresh != RTE_PMD_PARAM_UNSET)
--

2.17.1

Tested-by on v2 1/1
#4 lore raw

Re: [dpdk-dev] [PATCH v2] app/testpmd: fix dynamic config error

In reply to Steve Yang

Regards,
Chen Bo

Quoted 69 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Steve Yang
Sent: December 23, 2020 16:52
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Xing, Beilei <[email protected]>; Iremonger, Bernard <[email protected]>; Li, Xiaoyun <[email protected]>; Yang, Qiming <[email protected]>; Yang, SteveX <[email protected]>
Subject: [dpdk-dev] [PATCH v2] app/testpmd: fix dynamic config error

The offloads of 'tx/rx_conf' didn't keep up with the corresponding offloads of 'dev_conf', it would cause the configuration invalid.

For example:
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 tx/rx offloads configuration for each queue once it changed.

Fixes 5e91aeef218c ("app/testpmd: fix offload flags after port config")

---
v2:
* moved the update logic to 'rxtx_port_config';
* added the 'tx_conf' part;
* optimized the 'default' assignment;

---
 app/test-pmd/testpmd.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0 -0

33a060dffd..6ee28e3797 100644

app/test-pmd/testpmd.c +11 -7
@@ -3288,9 +3288,11 @@ rxtx_port_config(struct rte_port *port)
 
 	for (qid = 0; qid < nb_rxq; qid++) {
 		offloads = port->rx_conf[qid].offloads;
-		port->rx_conf[qid] = port->dev_info.default_rxconf;
-		if (offloads != 0)
-			port->rx_conf[qid].offloads = offloads;
+		if (offloads != port->dev_conf.rxmode.offloads)
+			port->rx_conf[qid].offloads =
+				port->dev_conf.rxmode.offloads;
+		if (!offloads)
+			port->rx_conf[qid] = port->dev_info.default_rxconf;
 
 		/* Check if any Rx parameters have been passed */
 		if (rx_pthresh != RTE_PMD_PARAM_UNSET) @@ -3313,9
+3315,11 @@ rxtx_port_config(struct rte_port *port)
 
 	for (qid = 0; qid < nb_txq; qid++) {
 		offloads = port->tx_conf[qid].offloads;
-		port->tx_conf[qid] = port->dev_info.default_txconf;
-		if (offloads != 0)
-			port->tx_conf[qid].offloads = offloads;
+		if (offloads != port->dev_conf.txmode.offloads)
+			port->tx_conf[qid].offloads =
+				port->dev_conf.txmode.offloads;
+		if (!offloads)
+			port->tx_conf[qid] = port->dev_info.default_txconf;
 
 		/* Check if any Tx parameters have been passed */
 		if (tx_pthresh != RTE_PMD_PARAM_UNSET)
--

2.17.1

#5 lore raw

Re: [dpdk-dev] [PATCH v2] app/testpmd: fix dynamic config error

In reply to Steve Yang
Quoted 8 lines · Steve Yang

The offloads of 'tx/rx_conf' didn't keep up with the corresponding offloads of 'dev_conf', it would cause the configuration invalid.

For example:
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'.

Can you please give some details how can I reproduce the issue?

Quoted 20 lines

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

Fixes 5e91aeef218c ("app/testpmd: fix offload flags after port config")

---
v2:
* moved the update logic to 'rxtx_port_config';
* added the 'tx_conf' part;
* optimized the 'default' assignment;

---
  app/test-pmd/testpmd.c | 16 ++++++++++------
  1 file changed, 10 insertions(+), 6 deletions(-)
app/test-pmd/testpmd.c +0 -0
index 33a060dffd..6ee28e3797 100644

app/test-pmd/testpmd.c rxtx_port_config(struct rte_port *port) · line 3293

Quoted 9 lines
app/test-pmd/testpmd.c +3 -3
@@ -3288,9 +3288,11 @@ rxtx_port_config(struct rte_port *port)
 
  	for (qid = 0; qid < nb_rxq; qid++) {
  		offloads = port->rx_conf[qid].offloads;
-		port->rx_conf[qid] = port->dev_info.default_rxconf;
-		if (offloads != 0)
-			port->rx_conf[qid].offloads = offloads;
+		if (offloads != port->dev_conf.rxmode.offloads)
+			port->rx_conf[qid].offloads =
+				port->dev_conf.rxmode.offloads;

Isn't 'rxmode.offloads' for the port, but the 'rx_conf[qid].offloads' for the queue, can this cause problem if the queue level offloads used?

app/test-pmd/testpmd.c rxtx_port_config(struct rte_port *port) · line 3295

Quoted 2 lines
app/test-pmd/testpmd.c +2 -0
+		if (!offloads)
+			port->rx_conf[qid] = port->dev_info.default_rxconf;

Can you please explain this, why the default config is used, only if the 'offload' is zero? The original code is always using the default config, but overwriting the 'offloads' if needed.

Quoted 19 lines
app/test-pmd/testpmd.c +5 -3
  		/* Check if any Rx parameters have been passed */
  		if (rx_pthresh != RTE_PMD_PARAM_UNSET)
@@ -3313,9 +3315,11 @@ rxtx_port_config(struct rte_port *port)
 
  	for (qid = 0; qid < nb_txq; qid++) {
  		offloads = port->tx_conf[qid].offloads;
-		port->tx_conf[qid] = port->dev_info.default_txconf;
-		if (offloads != 0)
-			port->tx_conf[qid].offloads = offloads;
+		if (offloads != port->dev_conf.txmode.offloads)
+			port->tx_conf[qid].offloads =
+				port->dev_conf.txmode.offloads;
+		if (!offloads)
+			port->tx_conf[qid] = port->dev_info.default_txconf;
 
  		/* Check if any Tx parameters have been passed */
  		if (tx_pthresh != RTE_PMD_PARAM_UNSET)
author
#6 lore raw

v3 cover fix 'max-pkt-len' errors

In reply to Steve Yang

Here fixed 3 issues for 'max-pkt-len':
1. When cmdline option '--max-pkt-len' set the value less then '1500 + overhead', the app/testpmd will force to resize the 'max-pkt-len' to '1500 + overhead'. However, the user really want to configure 'max-pkt-len' to a specified value (< 1500 + overhead);

2. If the large value of '--max-pkt-len' gave (e.g.: 8000), and user want to reset the value to a small one (e.g.: 1400), it will became invalid due to JUMBO_FRAME offload state doesn't change before port started;

3. When rx/tx queue offloads capabilities aren't specified, the rx/tx queue setup will be failed once the port offloads changed.

---
v3:
* rebased code to latest;
* splited to 3 commits;

v2:
* moved the update logic to 'rxtx_port_config';
* added the 'tx_conf' part;
* optimized the 'default' assignment;
---

Steve Yang (3):
ethdev: fix MTU doesn't update when jumbo frame disabled app/testpmd: fix max-pkt-len option invalid app/testpmd: fix dynamic config error

 app/test-pmd/cmdline.c         |  1 +
 app/test-pmd/parameters.c      |  1 +
 app/test-pmd/testpmd.c         | 59 +++++++++++++++++++++++-----------
 app/test-pmd/testpmd.h         |  2 ++
 lib/librte_ethdev/rte_ethdev.c |  8 ++---
 5 files changed, 48 insertions(+), 23 deletions(-)
Signature · 1 line
2.17.1
author
#7 lore raw

PATCH v3 1/3 ethdev: fix MTU doesn't update when jumbo frame disabled

The MTU value should be updated to 'max_rx_pkt_len - overhead' no matter if the JUMBO FRAME offload enabled. If not update this MTU, use will get the wrong MTU info via some command.
E.g.: 'show port info all' in testpmd tool.

Actually, the 'max_rx_pkt_len' has been used for other purposes in many places now, even though the 'max_rx_pkt_len' is expected 'Only used if JUMBO_FRAME enabled'.

For examples,
'max_rx_pkt_len' perhaps can be used as the 'rx_ctx.rxmax' in i40e.

Fixes bf0f90d92d30 ("ethdev: fix max Rx packet length check")
---
 lib/librte_ethdev/rte_ethdev.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/librte_ethdev/rte_ethdev.c +4 -4
index daf5f24f7e..42857e3b67 100644
@@ -1421,10 +1421,6 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 			ret = -EINVAL;
 			goto rollback;
 		}
-
-		/* Scale the MTU size to adapt max_rx_pkt_len */
-		dev->data->mtu = dev->data->dev_conf.rxmode.max_rx_pkt_len -
-				overhead_len;
 	} else {
 		uint16_t pktlen = dev_conf->rxmode.max_rx_pkt_len;
 		if (pktlen < RTE_ETHER_MIN_MTU + overhead_len ||
@@ -1434,6 +1430,10 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 						RTE_ETHER_MTU + overhead_len;
 	}
 
+	/* Scale the MTU size to adapt max_rx_pkt_len */
+	dev->data->mtu = dev->data->dev_conf.rxmode.max_rx_pkt_len -
+				overhead_len;
+
 	/*
 	 * If LRO is enabled, check that the maximum aggregated packet
 	 * size is supported by the configured device.
Signature · 1 line
2.17.1
#8 lore raw

Re: [dpdk-dev] [PATCH v3 1/3] ethdev: fix MTU doesn't update when jumbo frame disabled

Hi Steve,

In the current modification, the MTU is updated based on 'max_rx_pkt_len' regardless of whether jumbo frame is enabled.

Now, MTU is correct when jumbo frmae is disabled. However, when jumbo frame is enabled, the MTU value may be inconsistent with

the definition of the enabled jumbo frame. Like:

1/ DEV_RX_OFFLOAD_JUMBO_FRAME is set;

2/ max_rx_pkt_len = 1200

3/ dev->data->mtu = 1200 - overhead_len(18) = 1182

In rte_eth_dev_configure API, the check for 'max_rx_pkt_len' is as follows:

if (dev_conf->rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {  //jumbo frame enabled if (dev_conf->rxmode.max_rx_pkt_len > dev_info.max_rx_pktlen) { xxxx
            goto rollback;
        } else if (*dev_conf->rxmode.max_rx_pkt_len < RTE_ETHER_MIN_LEN*) { xxxx
            goto rollback;
        }
} else { //jumbo frame disabled

        if (pktlen < RTE_ETHER_MIN_MTU + overhead_len ||
                    pktlen > RTE_ETHER_MTU + overhead_len)
                        /* Use default value */ dev->data->dev_conf.rxmode.max_rx_pkt_len =
                                                RTE_ETHER_MTU + overhead_len;

}

Since the applicatin sets DEV_RX_OFFLOAD_JUMBO_FRAME to enable jumbo frame, and the framework API needs to update

the MTU based on 'max_rx_pkt_len', but the framework API uses *RTE_ETHER_MIN_LEN(64)* to verify the boundary value of

'max_rx_pkt_len', instead of "RTE_ETHER_MTU + overhead_len".  As far as I know, if the applicatin sets DEV_RX_OFFLOAD_JUMBO_FRAME

and 'max_rx_pkt_len' is 1200, the framework API or driver should return a failure. As mentioned in this patch set, the jumbo frame

offload is set only when 'max_rx_pkt_len' requested is greater than "RTE_ETHER_MTU + eth_overhead" in testpmd.

I really don't understand it.  How do you understand this behavior?

Thanks.

Quoted 45 lines · Steve Yang

The MTU value should be updated to 'max_rx_pkt_len - overhead' no matter if the JUMBO FRAME offload enabled. If not update this MTU, use will get the wrong MTU info via some command.
E.g.: 'show port info all' in testpmd tool.

Actually, the 'max_rx_pkt_len' has been used for other purposes in many places now, even though the 'max_rx_pkt_len' is expected 'Only used if JUMBO_FRAME enabled'.

For examples,
'max_rx_pkt_len' perhaps can be used as the 'rx_ctx.rxmax' in i40e.

Fixes bf0f90d92d30 ("ethdev: fix max Rx packet length check")
---
  lib/librte_ethdev/rte_ethdev.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
lib/librte_ethdev/rte_ethdev.c +4 -4
index daf5f24f7e..42857e3b67 100644
@@ -1421,10 +1421,6 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
  			ret = -EINVAL;
  			goto rollback;
  		}
-
-		/* Scale the MTU size to adapt max_rx_pkt_len */
-		dev->data->mtu = dev->data->dev_conf.rxmode.max_rx_pkt_len -
-				overhead_len;
  	} else {
  		uint16_t pktlen = dev_conf->rxmode.max_rx_pkt_len;
  		if (pktlen < RTE_ETHER_MIN_MTU + overhead_len ||
@@ -1434,6 +1430,10 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
  						RTE_ETHER_MTU + overhead_len;
  	}
 
+	/* Scale the MTU size to adapt max_rx_pkt_len */
+	dev->data->mtu = dev->data->dev_conf.rxmode.max_rx_pkt_len -
+				overhead_len;
+
  	/*
  	 * If LRO is enabled, check that the maximum aggregated packet
  	 * size is supported by the configured device.

A message that is not in the archive (sent off-list or not yet received): DM6PR11MB43628A600BAAEC75FFF1343BF9BD9@DM6PR11MB4362.namprd11.prod.outlook.com

#10 lore raw

Re: [dpdk-dev] [PATCH v3 1/3] ethdev: fix MTU doesn't update when jumbo frame disabled

Quoted 4 lines · SteveX

Hi Huisong,

Thanks for your review.

Quoted 9 lines

The validity of the pair <DEV_RX_OFFLOAD_JUMBO_FRAME, max_rx_pkt_len> should be checked from application layer (e.g.: testpmd),

and the RTE layer should keep open enough to adapt the high-layer requirement.

I’m not sure if exists some applications/NICs that treat ‘packet size < 1500’ as JUMBO_FRAME. If so, that also can work as expect with current code.

@Yigit, Ferruh <mailto:[email protected]>, please correct me if something understand wrong.

Hi Huisong,

Agree that there is a grey area in the API, the question is if 'JUMBO_FRAME' is set, can application set the 'max_rx_pkt_len' less than "RTE_ETHER_MTU + overhead_len". Lijun (cc'ed) has the same concern.

The API documentation, and checks in the 'rte_eth_dev_configure()' enables setting this for a long time, I am reluctant to add this limitation now. Although agree that application should set 'JUMBO_FRAME' properly based on requested 'MTU' value.

Quoted 144 lines

BTW, there perhaps are some confused problems about jumbo frame and max_rx_pkt_len, and Ferruh has scheduled to re-factor this part at release 21.11.

If you’re interesting about it, please refer to following link: [RFC,v2] doc: announce max Rx packet len field deprecation - Patchwork (dpdk.org) <http://patches.dpdk.org/patch/84522/>

Thanks & Regards,

Steve Yang.

*From:* Huisong Li <[email protected]>
*Sent:* Monday, January 25, 2021 3:12 PM
*To:* Yang, SteveX <[email protected]>; [email protected]
*Cc:* Lu, Wenzhuo <[email protected]>; Li, Xiaoyun <[email protected]>; Iremonger, Bernard <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; [email protected]; Yang, Qiming <[email protected]>; [email protected]; [email protected] *Subject:* Re: [dpdk-dev] [PATCH v3 1/3] ethdev: fix MTU doesn't update when jumbo frame disabled

Hi Steve,

In the current modification, the MTU is updated based on 'max_rx_pkt_len' regardless of whether jumbo frame is enabled.

Now, MTU is correct when jumbo frmae is disabled. However, when jumbo frame is enabled, the MTU value may be inconsistent with

the definition of the enabled jumbo frame. Like:

1/ DEV_RX_OFFLOAD_JUMBO_FRAME is set;

2/ max_rx_pkt_len = 1200

3/ dev->data->mtu = 1200 - overhead_len(18) = 1182

In rte_eth_dev_configure API, the check for 'max_rx_pkt_len' is as follows:

if (dev_conf->rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {  //jumbo frame enabled
        if (dev_conf->rxmode.max_rx_pkt_len > dev_info.max_rx_pktlen) { xxxx
            goto rollback;
        } else if (*dev_conf->rxmode.max_rx_pkt_len < RTE_ETHER_MIN_LEN*) { xxxx
            goto rollback;
        }
} else { //jumbo frame disabled

        if (pktlen < RTE_ETHER_MIN_MTU + overhead_len ||
                    pktlen > RTE_ETHER_MTU + overhead_len)
                        /* Use default value */ dev->data->dev_conf.rxmode.max_rx_pkt_len = RTE_ETHER_MTU + overhead_len;

}

Since the applicatin sets DEV_RX_OFFLOAD_JUMBO_FRAME to enable jumbo frame, and the framework API needs to update

the MTU based on 'max_rx_pkt_len', but the framework API uses *RTE_ETHER_MIN_LEN(64)* to verify the boundary value of

'max_rx_pkt_len', instead of "RTE_ETHER_MTU + overhead_len".  As far as I know, if the applicatin sets DEV_RX_OFFLOAD_JUMBO_FRAME

and 'max_rx_pkt_len' is 1200, the framework API or driver should return a failure. As mentioned in this patch set, the jumbo frame

offload is set only when 'max_rx_pkt_len' requested is greater than "RTE_ETHER_MTU + eth_overhead" in testpmd.

I really don't understand it.  How do you understand this behavior?

Thanks.

在 2021/1/22 17:01, Steve Yang 写道:

    The MTU value should be updated to 'max_rx_pkt_len - overhead'

    no matter if the JUMBO FRAME offload enabled. If not update this MTU,

    use will get the wrong MTU info via some command.

    E.g.: 'show port info all' in testpmd tool.

    Actually, the 'max_rx_pkt_len' has been used for other purposes in many

    places now, even though the 'max_rx_pkt_len' is expected 'Only used if

    JUMBO_FRAME enabled'.

    For examples,

    'max_rx_pkt_len' perhaps can be used as the 'rx_ctx.rxmax' in i40e.

    Fixes: bf0f90d92d30 ("ethdev: fix max Rx packet length check")

    Signed-off-by: Steve Yang<[email protected]>  <mailto:[email protected]>

    ---

      lib/librte_ethdev/rte_ethdev.c | 8 ++++----

      1 file changed, 4 insertions(+), 4 deletions(-)

    diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c

    index daf5f24f7e..42857e3b67 100644

    --- a/lib/librte_ethdev/rte_ethdev.c

    +++ b/lib/librte_ethdev/rte_ethdev.c

    @@ -1421,10 +1421,6 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,

                             ret = -EINVAL;

                             goto rollback;

                     }

    -

    -               /* Scale the MTU size to adapt max_rx_pkt_len */

    -               dev->data->mtu = dev->data->dev_conf.rxmode.max_rx_pkt_len -

    -                              overhead_len;

             } else {

                     uint16_t pktlen = dev_conf->rxmode.max_rx_pkt_len;

                     if (pktlen < RTE_ETHER_MIN_MTU + overhead_len ||

    @@ -1434,6 +1430,10 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,

                                                    RTE_ETHER_MTU + overhead_len;

             }

      

    +       /* Scale the MTU size to adapt max_rx_pkt_len */

    +       dev->data->mtu = dev->data->dev_conf.rxmode.max_rx_pkt_len -

    +                              overhead_len;

    +

             /*

              * If LRO is enabled, check that the maximum aggregated packet

              * size is supported by the configured device.
author
#11 lore raw

PATCH v3 2/3 app/testpmd: fix max-pkt-len option invalid

In reply to Steve Yang

Moved the setting of 'DEV_RX_OFFLOAD_JUMBO_FRAME' from 'cmd_config_max_pkt_len_parsed()' to 'init_config()' caused fail the case where 'max_rx_pkt_len' is changed from the command line via "port config all max-pkt-len".

The 'init_config()' function is only called when testpmd is started, but the DEV_RX_OFFLOAD_JUMBO_FRAME setting needs to be recomputed whenever 'max_rx_pkt_len' changes.

Define the 'update_jumbo_frame_offload()' function for both 'init_config()' and 'cmd_config_max_pkt_len_parsed()', and detect if 'max_rx_pkt_len' should be update to 1500 + overhead as default configuration.

Fixes 761c4d6690 ("app/testpmd: fix max Rx packet length for VLAN packets")
---
 app/test-pmd/cmdline.c    |  1 +
 app/test-pmd/parameters.c |  1 +
 app/test-pmd/testpmd.c    | 47 +++++++++++++++++++++++++--------------
 app/test-pmd/testpmd.h    |  2 ++
 4 files changed, 34 insertions(+), 17 deletions(-)
app/test-pmd/cmdline.c +1 -0
index 89034c8b72..600e0f8943 100644
@@ -1901,6 +1901,7 @@ cmd_config_max_pkt_len_parsed(void *parsed_result,
 			printf("Unknown parameter\n");
 			return;
 		}
+		update_jumbo_frame_offload(port, false);
 	}
 
 	init_port_config();
app/test-pmd/parameters.c +1 -0
index df5eb10d84..1c63156ddd 100644
@@ -833,6 +833,7 @@ launch_args_parse(int argc, char** argv)
 						 "total-num-mbufs should be > 1024\n");
 			}
 			if (!strcmp(lgopts[opt_idx].name, "max-pkt-len")) {
+				default_max_pktlen = false;
 				n = atoi(optarg);
 				if (n >= RTE_ETHER_MIN_LEN)
 					rx_mode.max_rx_pkt_len = (uint32_t) n;
app/test-pmd/testpmd.c +30 -17

71 lines not on this page · raw message

app/test-pmd/testpmd.h +2 -0
index 5f23162107..aac7b69735 100644
@@ -304,6 +304,7 @@ extern cmdline_parse_inst_t cmd_show_set_raw_all;
 
 extern uint16_t mempool_flags;
 
+extern bool default_max_pktlen;
 /**
  * Forwarding Configuration
  *
@@ -1005,6 +1006,7 @@ uint16_t tx_pkt_set_dynf(uint16_t port_id, __rte_unused uint16_t queue,
 			 __rte_unused void *user_param);
 void add_tx_dynf_callback(portid_t portid);
 void remove_tx_dynf_callback(portid_t portid);
+void update_jumbo_frame_offload(struct rte_port *port, bool def_max_pktlen);
 
 /*
  * Work-around of a compilation error with ICC on invocations of the
Signature · 1 line
2.17.1
author
#12 lore raw

PATCH v3 3/3 app/testpmd: fix dynamic config error

In reply to Steve Yang

The offloads of 'tx/rx_conf' didn't keep up with the corresponding offloads of 'dev_conf' if rx queue capability was 0, it would cause the configuration invalid.

For example:
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 tx/rx offloads configuration for each queue once it changed and corresponding tx/rx queue capability was 0.

Fixes 5e91aeef218c ("app/testpmd: fix offload flags after port config")
---
 app/test-pmd/testpmd.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
app/test-pmd/testpmd.c +10 -2
index a2c9aad960..8307c7f9e9 100644
@@ -3296,7 +3296,11 @@ rxtx_port_config(struct rte_port *port)
 	for (qid = 0; qid < nb_rxq; qid++) {
 		offloads = port->rx_conf[qid].offloads;
 		port->rx_conf[qid] = port->dev_info.default_rxconf;
-		if (offloads != 0)
+		if (port->dev_info.rx_queue_offload_capa == 0 &&
+		    offloads != port->dev_conf.rxmode.offloads)
+			port->rx_conf[qid].offloads =
+				port->dev_conf.rxmode.offloads;
+		else if (offloads != 0)
 			port->rx_conf[qid].offloads = offloads;
 
 		/* Check if any Rx parameters have been passed */
@@ -3321,7 +3325,11 @@ rxtx_port_config(struct rte_port *port)
 	for (qid = 0; qid < nb_txq; qid++) {
 		offloads = port->tx_conf[qid].offloads;
 		port->tx_conf[qid] = port->dev_info.default_txconf;
-		if (offloads != 0)
+		if (port->dev_info.tx_queue_offload_capa == 0 &&
+		    offloads != port->dev_conf.txmode.offloads)
+			port->tx_conf[qid].offloads =
+				port->dev_conf.txmode.offloads;
+		else if (offloads != 0)
 			port->tx_conf[qid].offloads = offloads;
 
 		/* Check if any Tx parameters have been passed */
Signature · 1 line
2.17.1
#13 lore raw

Re: [dpdk-dev] [PATCH v3 3/3] app/testpmd: fix dynamic config error

Quoted 24 lines · Steve Yang

The offloads of 'tx/rx_conf' didn't keep up with the corresponding offloads of 'dev_conf' if rx queue capability was 0, it would cause the configuration invalid.

For example:
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 tx/rx offloads configuration for each queue once it changed and corresponding tx/rx queue capability was 0.

Fixes 5e91aeef218c ("app/testpmd: fix offload flags after port config")
---
  app/test-pmd/testpmd.c | 12 ++++++++++--
  1 file changed, 10 insertions(+), 2 deletions(-)
app/test-pmd/testpmd.c +0 -0
index a2c9aad960..8307c7f9e9 100644

app/test-pmd/testpmd.c rxtx_port_config(struct rte_port *port) · line 3304

Quoted 10 lines
app/test-pmd/testpmd.c +5 -1
@@ -3296,7 +3296,11 @@ rxtx_port_config(struct rte_port *port)
  	for (qid = 0; qid < nb_rxq; qid++) {
  		offloads = port->rx_conf[qid].offloads;
  		port->rx_conf[qid] = port->dev_info.default_rxconf;
-		if (offloads != 0)
+		if (port->dev_info.rx_queue_offload_capa == 0 &&
+		    offloads != port->dev_conf.rxmode.offloads)
+			port->rx_conf[qid].offloads =
+				port->dev_conf.rxmode.offloads;
+		else if (offloads != 0)
  			port->rx_conf[qid].offloads = offloads;

I am still concerned to use port offloads to set the queue specific offloads, this may lead unexpected result.

Below is what Steve provided as reproduce steps [1], I think that is application (testpmd) miss-configuration to update 'max-pkt-len' but not update the JUMBO_FRAME offload flag and MTU accordingly.

What do you think update the JUMBO_FRAME offload flag (both for port and queues) according and set MTU according on the testpmd command where 'max-pkt-len' is set? This is more like your first version.

[1]
----------------------------------------------

# x86_64-native-linuxapp-gcc/app/dpdk-testpmd  -c 0xf -n 4  -- -i --max-pkt-len=9000 --tx-offloads=0x8000 --rxq=4 --txq=4 --disable-rss
testpmd>  set verbose 3
testpmd>  start
testpmd>  stop
testpmd>  port stop all
testpmd>  port config all max-pkt-len 1518
testpmd> port start all
Configuring Port 0 (socket 1)
Ethdev port_id=0 rx_queue_id=0, new added offloads 0x800 must be within per-queue offload capabilities 0x0 in rte_eth_rx_queue_setup()
Fail to configure port 0 rx queues//<-- Fail error info;
------------------------------------------------
Quoted 16 lines
app/test-pmd/testpmd.c +5 -1
  		/* Check if any Rx parameters have been passed */
@@ -3321,7 +3325,11 @@ rxtx_port_config(struct rte_port *port)
  	for (qid = 0; qid < nb_txq; qid++) {
  		offloads = port->tx_conf[qid].offloads;
  		port->tx_conf[qid] = port->dev_info.default_txconf;
-		if (offloads != 0)
+		if (port->dev_info.tx_queue_offload_capa == 0 &&
+		    offloads != port->dev_conf.txmode.offloads)
+			port->tx_conf[qid].offloads =
+				port->dev_conf.txmode.offloads;
+		else if (offloads != 0)
  			port->tx_conf[qid].offloads = offloads;
 
  		/* Check if any Tx parameters have been passed */
#14 lore raw

Re: [dpdk-dev] [PATCH v3 3/3] app/testpmd: fix dynamic config error

Quoted 44 lines · Ferruh Yigit
Quoted 24 lines · Steve Yang

The offloads of 'tx/rx_conf' didn't keep up with the corresponding offloads of 'dev_conf' if rx queue capability was 0, it would cause the configuration invalid.

For example:
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 tx/rx offloads configuration for each queue once it changed and corresponding tx/rx queue capability was 0.

Fixes 5e91aeef218c ("app/testpmd: fix offload flags after port config")

---
  app/test-pmd/testpmd.c | 12 ++++++++++--

  1 file changed, 10 insertions(+), 2 deletions(-)
app/test-pmd/testpmd.c +0 -0
index a2c9aad960..8307c7f9e9 100644

app/test-pmd/testpmd.c rxtx_port_config(struct rte_port *port) · line 3304

Quoted 10 lines
app/test-pmd/testpmd.c +5 -1
@@ -3296,7 +3296,11 @@ rxtx_port_config(struct rte_port *port)
       for (qid = 0; qid < nb_rxq; qid++) {
           offloads = port->rx_conf[qid].offloads;
           port->rx_conf[qid] = port->dev_info.default_rxconf;
-        if (offloads != 0)
+        if (port->dev_info.rx_queue_offload_capa == 0 &&
+            offloads != port->dev_conf.rxmode.offloads)
+            port->rx_conf[qid].offloads =
+                port->dev_conf.rxmode.offloads;
+        else if (offloads != 0)
               port->rx_conf[qid].offloads = offloads;

I am still concerned to use port offloads to set the queue specific offloads, this may lead unexpected result.

Below is what Steve provided as reproduce steps [1], I think that is application (testpmd) miss-configuration to update 'max-pkt-len' but not update the JUMBO_FRAME offload flag and MTU accordingly.

What do you think update the JUMBO_FRAME offload flag (both for port and queues) according and set MTU according on the testpmd command where 'max-pkt-len' is set? This is more like your first version.

Quoted 15 lines

[1]
----------------------------------------------
# x86_64-native-linuxapp-gcc/app/dpdk-testpmd  -c 0xf -n 4  -- -i
--max-pkt-len=9000 --tx-offloads=0x8000 --rxq=4 --txq=4 --disable-rss
testpmd>  set verbose 3
testpmd>  start
testpmd>  stop
testpmd>  port stop all
testpmd>  port config all max-pkt-len 1518
testpmd> port start all
Configuring Port 0 (socket 1)
Ethdev port_id=0 rx_queue_id=0, new added offloads 0x800 must be within per-queue offload capabilities 0x0 in rte_eth_rx_queue_setup() Fail to configure port 0 rx queues//<-- Fail error info;
------------------------------------------------

Indeed first patch of this series solves the MTU problem with "port config all max-pkt-len" command (although it ignores 'max_rx_pkt_len' is only valid when JUMBO_FRAME flag is set)

And second patch updates the JUMBO_FRAME flag in the command function, same as I suggested above.
Only if second patch extended to update JUMBO_FRAME flag for all queues in 'update_jumbo_frame_offload()', this patch can be dropped, what do you think?

author
#15 lore raw

v4 cover fix 'max-pkt-len' errors

In reply to Steve Yang

Here fixed 3 issues for 'max-pkt-len':
1. When cmdline option '--max-pkt-len' set the value less then '1500 + overhead', the app/testpmd will force to resize the 'max-pkt-len' to '1500 + overhead'. However, the user really want to configure 'max-pkt-len' to a specified value (< 1500 + overhead);

2. If the large value of '--max-pkt-len' gave (e.g.: 8000), and user want to reset the value to a small one (e.g.: 1400), it will became invalid due to JUMBO_FRAME offload state doesn't change before port started;

3. When rx/tx queue offloads capabilities aren't specified, the rx/tx queue setup will be failed once the port offloads changed.

---
v4:
* combined testpmd patches;
* updated the commit log for patch 2;
v3:
* rebased code to latest;
* splited to 3 commits;

v2:
* moved the update logic to 'rxtx_port_config';
* added the 'tx_conf' part;
* optimized the 'default' assignment;
---

Steve Yang (2):
ethdev: fix MTU doesn't update when jumbo frame disabled app/testpmd: fix max-pkt-len option invalid

 app/test-pmd/cmdline.c         |  1 +
 app/test-pmd/parameters.c      |  1 +
 app/test-pmd/testpmd.c         | 63 +++++++++++++++++++++++++---------
 app/test-pmd/testpmd.h         |  2 ++
 lib/librte_ethdev/rte_ethdev.c |  8 ++---
 5 files changed, 54 insertions(+), 21 deletions(-)
Signature · 1 line
2.17.1
author
#16 lore raw

PATCH v4 1/2 ethdev: fix MTU doesn't update when jumbo frame disabled

The MTU value should be updated to 'max_rx_pkt_len - overhead' no matter if the JUMBO FRAME offload enabled. If not update this MTU, use will get the wrong MTU info via some command.
E.g.: 'show port info all' in testpmd tool.

Actually, the 'max_rx_pkt_len' has been used for other purposes in many places now, even though the 'max_rx_pkt_len' is expected 'Only used if JUMBO_FRAME enabled'.

For examples,
'max_rx_pkt_len' perhaps can be used as the 'rx_ctx.rxmax' in i40e.

Fixes bf0f90d92d30 ("ethdev: fix max Rx packet length check")
---
 lib/librte_ethdev/rte_ethdev.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/librte_ethdev/rte_ethdev.c +4 -4
index daf5f24f7e..42857e3b67 100644
@@ -1421,10 +1421,6 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 			ret = -EINVAL;
 			goto rollback;
 		}
-
-		/* Scale the MTU size to adapt max_rx_pkt_len */
-		dev->data->mtu = dev->data->dev_conf.rxmode.max_rx_pkt_len -
-				overhead_len;
 	} else {
 		uint16_t pktlen = dev_conf->rxmode.max_rx_pkt_len;
 		if (pktlen < RTE_ETHER_MIN_MTU + overhead_len ||
@@ -1434,6 +1430,10 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 						RTE_ETHER_MTU + overhead_len;
 	}
 
+	/* Scale the MTU size to adapt max_rx_pkt_len */
+	dev->data->mtu = dev->data->dev_conf.rxmode.max_rx_pkt_len -
+				overhead_len;
+
 	/*
 	 * If LRO is enabled, check that the maximum aggregated packet
 	 * size is supported by the configured device.
Signature · 1 line
2.17.1
#17 lore raw

Re: [dpdk-dev] [PATCH v4 1/2] ethdev: fix MTU doesn't update when jumbo frame disabled

Quoted 36 lines · Steve Yang

The MTU value should be updated to 'max_rx_pkt_len - overhead' no matter if the JUMBO FRAME offload enabled. If not update this MTU, use will get the wrong MTU info via some command.
E.g.: 'show port info all' in testpmd tool.

Actually, the 'max_rx_pkt_len' has been used for other purposes in many places now, even though the 'max_rx_pkt_len' is expected 'Only used if JUMBO_FRAME enabled'.

For examples,
'max_rx_pkt_len' perhaps can be used as the 'rx_ctx.rxmax' in i40e.

Fixes bf0f90d92d30 ("ethdev: fix max Rx packet length check")
---
  lib/librte_ethdev/rte_ethdev.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
lib/librte_ethdev/rte_ethdev.c +0 -4
index daf5f24f7e..42857e3b67 100644
@@ -1421,10 +1421,6 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
  			ret = -EINVAL;
  			goto rollback;
  		}
-
-		/* Scale the MTU size to adapt max_rx_pkt_len */
-		dev->data->mtu = dev->data->dev_conf.rxmode.max_rx_pkt_len -
-				overhead_len;
  	} else {
  		uint16_t pktlen = dev_conf->rxmode.max_rx_pkt_len;
  		if (pktlen < RTE_ETHER_MIN_MTU + overhead_len ||

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, · line 1439

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +4 -0
@@ -1434,6 +1430,10 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
  						RTE_ETHER_MTU + overhead_len;
  	}
 
+	/* Scale the MTU size to adapt max_rx_pkt_len */
+	dev->data->mtu = dev->data->dev_conf.rxmode.max_rx_pkt_len -
+				overhead_len;
+
  	/*
  	 * If LRO is enabled, check that the maximum aggregated packet
  	 * size is supported by the configured device.

This will cause 'max_rx_pkt_len' taken into account even 'JUMBO_FRAME' is not set, this is against the API documentation.

PMD can ignore the 'max_rx_pkt_len' when 'JUMBO_FRAME' is not set, so updating the 'max_rx_pkt_len' is relatively harmless, but updating 'MTU' can have affect.

Instead what do you think explicitly call 'rte_eth_dev_set_mtu()' in the testpmd when the MTU of the port needs to be changed because of "port config all max-pkt-len" command?

author
#18 lore raw

PATCH v4 2/2 app/testpmd: fix max-pkt-len option invalid

In reply to Steve Yang

Moved the setting of 'DEV_RX_OFFLOAD_JUMBO_FRAME' from 'cmd_config_max_pkt_len_parsed()' to 'init_config()' caused fail the case where 'max_rx_pkt_len' is changed from the command line via "port config all max-pkt-len".

The 'init_config()' function is only called when testpmd is started, but the DEV_RX_OFFLOAD_JUMBO_FRAME setting needs to be recomputed whenever 'max_rx_pkt_len' changes.

Define the 'update_jumbo_frame_offload()' function for both 'init_config()' and 'cmd_config_max_pkt_len_parsed()', and detect if 'max_rx_pkt_len' should be update to 1500 + overhead as default configuration. At the same time, the offloads of rx queue also should update the value once port offloads changed (e.g.: disabled JUMBO_FRAME offload via changed max-pkt-len, reproduce steps [1]), otherwise, it would cause unexpected result.

[1]
--------------------------------------------------------------------------
./x86_64-native-linuxapp-gcc/app/dpdk-testpmd -c 0xf -n 4 -- -i

    --max-pkt-len=9000 --tx-offloads=0x8000 --rxq=4 --txq=4 --disable-rss
testpmd>  set verbose 3
testpmd>  port stop all
testpmd>  port config all max-pkt-len 1518  port start all

// Got fail error info without this patch
Configuring Port 0 (socket 1)
Ethdev port_id=0 rx_queue_id=0, new added offloads 0x800 must be within per-queue offload capabilities 0x0 in rte_eth_rx_queue_setup() Fail to configure port 0 rx queues //<-- Fail error info;
--------------------------------------------------------------------------

Fixes 761c4d6690 ("app/testpmd: fix max Rx packet length for VLAN packets")
---
 app/test-pmd/cmdline.c    |  1 +
 app/test-pmd/parameters.c |  1 +
 app/test-pmd/testpmd.c    | 63 ++++++++++++++++++++++++++++-----------
 app/test-pmd/testpmd.h    |  2 ++
 4 files changed, 50 insertions(+), 17 deletions(-)
app/test-pmd/cmdline.c +1 -0
index 89034c8b72..8b6b7b6206 100644
@@ -1901,6 +1901,7 @@ cmd_config_max_pkt_len_parsed(void *parsed_result,
 			printf("Unknown parameter\n");
 			return;
 		}
+		update_jumbo_frame_offload(pid, false);
 	}
 
 	init_port_config();
app/test-pmd/parameters.c +1 -0
index df5eb10d84..1c63156ddd 100644
@@ -833,6 +833,7 @@ launch_args_parse(int argc, char** argv)
 						 "total-num-mbufs should be > 1024\n");
 			}
 			if (!strcmp(lgopts[opt_idx].name, "max-pkt-len")) {
+				default_max_pktlen = false;
 				n = atoi(optarg);
 				if (n >= RTE_ETHER_MIN_LEN)
 					rx_mode.max_rx_pkt_len = (uint32_t) n;
app/test-pmd/testpmd.c +46 -17

87 lines not on this page · raw message

app/test-pmd/testpmd.h +2 -0
index 5f23162107..16f6fbefef 100644
@@ -304,6 +304,7 @@ extern cmdline_parse_inst_t cmd_show_set_raw_all;
 
 extern uint16_t mempool_flags;
 
+extern bool default_max_pktlen;
 /**
  * Forwarding Configuration
  *
@@ -1005,6 +1006,7 @@ uint16_t tx_pkt_set_dynf(uint16_t port_id, __rte_unused uint16_t queue,
 			 __rte_unused void *user_param);
 void add_tx_dynf_callback(portid_t portid);
 void remove_tx_dynf_callback(portid_t portid);
+void update_jumbo_frame_offload(portid_t portid, bool def_max_pktlen);
 
 /*
  * Work-around of a compilation error with ICC on invocations of the
Signature · 1 line
2.17.1
#19 lore raw

Re: [dpdk-dev] [PATCH v4 2/2] app/testpmd: fix max-pkt-len option invalid

Quoted 123 lines · Steve Yang

Moved the setting of 'DEV_RX_OFFLOAD_JUMBO_FRAME' from 'cmd_config_max_pkt_len_parsed()' to 'init_config()' caused fail the case where 'max_rx_pkt_len' is changed from the command line via "port config all max-pkt-len".

The 'init_config()' function is only called when testpmd is started, but the DEV_RX_OFFLOAD_JUMBO_FRAME setting needs to be recomputed whenever 'max_rx_pkt_len' changes.

Define the 'update_jumbo_frame_offload()' function for both 'init_config()' and 'cmd_config_max_pkt_len_parsed()', and detect if 'max_rx_pkt_len' should be update to 1500 + overhead as default configuration. At the same time, the offloads of rx queue also should update the value once port offloads changed (e.g.: disabled JUMBO_FRAME offload via changed max-pkt-len, reproduce steps [1]), otherwise, it would cause unexpected result.

[1]
--------------------------------------------------------------------------
./x86_64-native-linuxapp-gcc/app/dpdk-testpmd -c 0xf -n 4 -- -i

     --max-pkt-len=9000 --tx-offloads=0x8000 --rxq=4 --txq=4 --disable-rss
testpmd>  set verbose 3
testpmd>  port stop all
testpmd>  port config all max-pkt-len 1518  port start all

// Got fail error info without this patch
Configuring Port 0 (socket 1)
Ethdev port_id=0 rx_queue_id=0, new added offloads 0x800 must be within per-queue offload capabilities 0x0 in rte_eth_rx_queue_setup() Fail to configure port 0 rx queues //<-- Fail error info;
--------------------------------------------------------------------------

Fixes 761c4d6690 ("app/testpmd: fix max Rx packet length for VLAN packets")
---
  app/test-pmd/cmdline.c    |  1 +
  app/test-pmd/parameters.c |  1 +
  app/test-pmd/testpmd.c    | 63 ++++++++++++++++++++++++++++-----------
  app/test-pmd/testpmd.h    |  2 ++
  4 files changed, 50 insertions(+), 17 deletions(-)
app/test-pmd/cmdline.c +1 -0
index 89034c8b72..8b6b7b6206 100644
@@ -1901,6 +1901,7 @@ cmd_config_max_pkt_len_parsed(void *parsed_result,
  			printf("Unknown parameter\n");
  			return;
  		}
+		update_jumbo_frame_offload(pid, false);
  	}
 
  	init_port_config();
app/test-pmd/parameters.c +1 -0
index df5eb10d84..1c63156ddd 100644
@@ -833,6 +833,7 @@ launch_args_parse(int argc, char** argv)
  						 "total-num-mbufs should be > 1024\n");
  			}
  			if (!strcmp(lgopts[opt_idx].name, "max-pkt-len")) {
+				default_max_pktlen = false;
  				n = atoi(optarg);
  				if (n >= RTE_ETHER_MIN_LEN)
  					rx_mode.max_rx_pkt_len = (uint32_t) n;
app/test-pmd/testpmd.c +11 -17
index c256e719ae..f22d2be46d 100644
@@ -531,6 +531,8 @@ uint16_t gso_max_segment_size = RTE_ETHER_MAX_LEN - RTE_ETHER_CRC_LEN;
  /* Holds the registered mbuf dynamic flags names. */
  char dynf_names[64][RTE_MBUF_DYN_NAMESIZE];
 
+bool default_max_pktlen = true;
+
  /*
   * Helper function to check if socket is already discovered.
   * If yes, return positive value. If not, return zero.
@@ -1410,7 +1412,6 @@ init_config(void)
  	struct rte_gro_param gro_param;
  	uint32_t gso_types;
  	uint16_t data_size;
-	uint16_t eth_overhead;
  	bool warning = 0;
  	int k;
  	int ret;
@@ -1447,22 +1448,7 @@ init_config(void)
  			rte_exit(EXIT_FAILURE,
  				 "rte_eth_dev_info_get() failed\n");
 
-		/* Update the max_rx_pkt_len to have MTU as RTE_ETHER_MTU */
-		if (port->dev_info.max_mtu != UINT16_MAX &&
-		    port->dev_info.max_rx_pktlen > port->dev_info.max_mtu)
-			eth_overhead = port->dev_info.max_rx_pktlen -
-				port->dev_info.max_mtu;
-		else
-			eth_overhead =
-				RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
-
-		if (port->dev_conf.rxmode.max_rx_pkt_len <=
-			(uint32_t)(RTE_ETHER_MTU + eth_overhead))
-			port->dev_conf.rxmode.max_rx_pkt_len =
-					RTE_ETHER_MTU + eth_overhead;
-		else
-			port->dev_conf.rxmode.offloads |=
-					DEV_RX_OFFLOAD_JUMBO_FRAME;
+		update_jumbo_frame_offload(pid, default_max_pktlen);
 
  		if (!(port->dev_info.tx_offload_capa &
  		      DEV_TX_OFFLOAD_MBUF_FAST_FREE))
@@ -3358,6 +3344,49 @@ rxtx_port_config(struct rte_port *port)
  	}
  }
 
+void
+update_jumbo_frame_offload(portid_t portid, bool def_max_pktlen)
+{
+	struct rte_port *port = &ports[portid];
+	uint32_t eth_overhead;
+	uint64_t rx_offloads;
+
+	/* Update the max_rx_pkt_len to have MTU as RTE_ETHER_MTU */

app/test-pmd/testpmd.c rxtx_port_config(struct rte_port *port) · line 3364

Quoted 10 lines
app/test-pmd/testpmd.c +10 -0
+	if (port->dev_info.max_mtu != UINT16_MAX &&
+	    port->dev_info.max_rx_pktlen > port->dev_info.max_mtu)
+		eth_overhead = port->dev_info.max_rx_pktlen -
+				port->dev_info.max_mtu;
+	else
+		eth_overhead = RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
+
+	rx_offloads = port->dev_conf.rxmode.offloads;
+	if (port->dev_conf.rxmode.max_rx_pkt_len <=
+		RTE_ETHER_MTU + eth_overhead) {

This check is also used to decide if expansion is required, but the check is generic, with "port config all max-pkt-len" command this condition always can be created.

The target is make testpmd set "RTE_ETHER_MTU + eth_overhead" instead of fixed 'RTE_ETHER_MAX_LEN' value, so why not set initial '.max_rx_pkt_len' value to zero, to say extend it to the default value.

app/test-pmd/testpmd.c rxtx_port_config(struct rte_port *port) · line 3371

Quoted 7 lines
app/test-pmd/testpmd.c +7 -0
+		/*
+		 * If command line option doesn't include --max-pkt-len,
+		 * the default max_rx_pkt_len should be set to 1500 + overhead.
+		 */
+		if (def_max_pktlen)
+			port->dev_conf.rxmode.max_rx_pkt_len =
+						RTE_ETHER_MTU + eth_overhead;

What if '--max-pkt-len' is not provided, but "port config all max-pkt-len" command issued, won't is discard the command and always set to default?

Quoted 5 lines
app/test-pmd/testpmd.c +5 -0
+		rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
+	} else
+		rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+
+	/* Apply Rx offloads configuration to Rx queue(s) */

app/test-pmd/testpmd.c rxtx_port_config(struct rte_port *port) · line 3386

Quoted 10 lines
app/test-pmd/testpmd.c +10 -0
+	if (rx_offloads != port->dev_conf.rxmode.offloads) {
+		uint16_t qid;
+
+		port->dev_conf.rxmode.offloads = rx_offloads;
+		if (eth_dev_info_get_print_err(portid, &port->dev_info) != 0)
+			rte_exit(EXIT_FAILURE,
+				"rte_eth_dev_info_get() failed\n");
+
+		for (qid = 0; qid < port->dev_info.nb_rx_queues; qid++)
+			port->rx_conf[qid].offloads = rx_offloads;

As said before, there is a concept of queue specific offloads, you can't just assume the queue offloads will always be same as the port offloads. Instead it can be possible to add/remove JUMBO_FRAME offload to queues based on condition.

Quoted 27 lines
app/test-pmd/testpmd.c +3 -0
+	}
+}
+
  void
  init_port_config(void)
  {
app/test-pmd/testpmd.h +2 -0
index 5f23162107..16f6fbefef 100644
@@ -304,6 +304,7 @@ extern cmdline_parse_inst_t cmd_show_set_raw_all;
 
  extern uint16_t mempool_flags;
 
+extern bool default_max_pktlen;
  /**
   * Forwarding Configuration
   *
@@ -1005,6 +1006,7 @@ uint16_t tx_pkt_set_dynf(uint16_t port_id, __rte_unused uint16_t queue,
  			 __rte_unused void *user_param);
  void add_tx_dynf_callback(portid_t portid);
  void remove_tx_dynf_callback(portid_t portid);
+void update_jumbo_frame_offload(portid_t portid, bool def_max_pktlen);
 
  /*
   * Work-around of a compilation error with ICC on invocations of the
#20 lore raw

Re: [dpdk-dev] [PATCH v4 2/2] app/testpmd: fix max-pkt-len option invalid

In reply to Steve Yang
Quoted 48 lines · Steve Yang

Moved the setting of 'DEV_RX_OFFLOAD_JUMBO_FRAME' from 'cmd_config_max_pkt_len_parsed()' to 'init_config()' caused fail the case where 'max_rx_pkt_len' is changed from the command line via "port config all max-pkt-len".

The 'init_config()' function is only called when testpmd is started, but the DEV_RX_OFFLOAD_JUMBO_FRAME setting needs to be recomputed whenever 'max_rx_pkt_len' changes.

Define the 'update_jumbo_frame_offload()' function for both 'init_config()' and 'cmd_config_max_pkt_len_parsed()', and detect if 'max_rx_pkt_len' should be update to 1500 + overhead as default configuration. At the same time, the offloads of rx queue also should update the value once port offloads changed (e.g.: disabled JUMBO_FRAME offload via changed max-pkt-len, reproduce steps [1]), otherwise, it would cause unexpected result.

[1]
--------------------------------------------------------------------------
./x86_64-native-linuxapp-gcc/app/dpdk-testpmd -c 0xf -n 4 -- -i

    --max-pkt-len=9000 --tx-offloads=0x8000 --rxq=4 --txq=4 --disable-rss
testpmd>  set verbose 3
testpmd>  port stop all
testpmd>  port config all max-pkt-len 1518  port start all

// Got fail error info without this patch
Configuring Port 0 (socket 1)
Ethdev port_id=0 rx_queue_id=0, new added offloads 0x800 must be within per-queue offload capabilities 0x0 in rte_eth_rx_queue_setup() Fail to configure port 0 rx queues //<-- Fail error info;
--------------------------------------------------------------------------

Fixes 761c4d6690 ("app/testpmd: fix max Rx packet length for VLAN packets")
---
 app/test-pmd/cmdline.c    |  1 +
 app/test-pmd/parameters.c |  1 +
 app/test-pmd/testpmd.c    | 63 ++++++++++++++++++++++++++++-----------
 app/test-pmd/testpmd.h    |  2 ++
 4 files changed, 50 insertions(+), 17 deletions(-)
app/test-pmd/cmdline.c +0 -0
index 89034c8b72..8b6b7b6206 100644

app/test-pmd/cmdline.c cmd_config_max_pkt_len_parsed(void *parsed_result, · line 1904

Quoted 4 lines
app/test-pmd/cmdline.c +1 -0
@@ -1901,6 +1901,7 @@ cmd_config_max_pkt_len_parsed(void *parsed_result,
                        printf("Unknown parameter\n");
                        return;
                }
+               update_jumbo_frame_offload(pid, false);

I'm probably missing something, but why isn't this a matter of simply calling port_mtu_set() here (with mtu computed from max pkt len) and keeping init_config() as currently implemented?

Quoted 3 lines
app/test-pmd/cmdline.c +0 -0
        }
 
        init_port_config();
#21 lore raw

Re: [dpdk-dev] [PATCH v4 2/2] app/testpmd: fix max-pkt-len option invalid

Quoted 44 lines · Lance Richardson
Quoted 43 lines · Steve Yang

Moved the setting of 'DEV_RX_OFFLOAD_JUMBO_FRAME' from 'cmd_config_max_pkt_len_parsed()' to 'init_config()' caused fail the case where 'max_rx_pkt_len' is changed from the command line via "port config all max-pkt-len".

The 'init_config()' function is only called when testpmd is started, but the DEV_RX_OFFLOAD_JUMBO_FRAME setting needs to be recomputed whenever 'max_rx_pkt_len' changes.

Define the 'update_jumbo_frame_offload()' function for both 'init_config()' and 'cmd_config_max_pkt_len_parsed()', and detect if 'max_rx_pkt_len' should be update to 1500 + overhead as default configuration. At the same time, the offloads of rx queue also should update the value once port offloads changed (e.g.: disabled JUMBO_FRAME offload via changed max-pkt-len, reproduce steps [1]), otherwise, it would cause unexpected result.

[1]
--------------------------------------------------------------------------
./x86_64-native-linuxapp-gcc/app/dpdk-testpmd -c 0xf -n 4 -- -i

     --max-pkt-len=9000 --tx-offloads=0x8000 --rxq=4 --txq=4 --disable-rss
testpmd>  set verbose 3
testpmd>  port stop all
testpmd>  port config all max-pkt-len 1518  port start all

// Got fail error info without this patch
Configuring Port 0 (socket 1)
Ethdev port_id=0 rx_queue_id=0, new added offloads 0x800 must be within per-queue offload capabilities 0x0 in rte_eth_rx_queue_setup() Fail to configure port 0 rx queues //<-- Fail error info;
--------------------------------------------------------------------------

Fixes 761c4d6690 ("app/testpmd: fix max Rx packet length for VLAN packets")
---
  app/test-pmd/cmdline.c    |  1 +
  app/test-pmd/parameters.c |  1 +
  app/test-pmd/testpmd.c    | 63 ++++++++++++++++++++++++++++-----------
  app/test-pmd/testpmd.h    |  2 ++
  4 files changed, 50 insertions(+), 17 deletions(-)
Quoted 14 lines

app/test-pmd/cmdline.c cmd_config_max_pkt_len_parsed(void *parsed_result, · line 1904

Quoted 9 lines
app/test-pmd/cmdline.c +1 -0
index 89034c8b72..8b6b7b6206 100644
@@ -1901,6 +1901,7 @@ cmd_config_max_pkt_len_parsed(void *parsed_result,
                         printf("Unknown parameter\n");
                         return;
                 }
+               update_jumbo_frame_offload(pid, false);

I'm probably missing something, but why isn't this a matter of simply calling port_mtu_set() here (with mtu computed from max pkt len) and keeping init_config() as currently implemented?

They are very similar, calling the 'port_mtu_set()' can be an option, but it is headache to get dev->info first and calculate overhead to be able to call 'port_mtu_set()'; Since this is already done in 'init_config()', converting it to a function and reuse it also looks valid as done here.

I am updating that function and sending a new version soon.

#22 lore raw

PATCH v5 1/1 app/testpmd: fix setting maximum packet length

In reply to Steve Yang

From: Steve Yang <[email protected]>

"port config all max-pkt-len" command fails because it doesn't set the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag properly.

Commit in the fixes line moved the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag update from 'cmd_config_max_pkt_len_parsed()' to 'init_config()'. 'init_config()' function is only called during testpmd startup, but the flag status needs to be calculated whenever 'max_rx_pkt_len' changes.

The issue can be reproduce as [1], where the 'max-pkt-len' reduced and 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag should be cleared but it didn't.

Adding the 'update_jumbo_frame_offload()' helper function to update 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag and 'max_rx_pkt_len'. This function is called both by 'init_config()' and 'cmd_config_max_pkt_len_parsed()'.

Default 'max-pkt-len' value set to zero, 'update_jumbo_frame_offload()' updates it to "RTE_ETHER_MTU + PMD specific Ethernet overhead" when it is zero.
If '--max-pkt-len=N' argument provided, it will be used instead. And with each "port config all max-pkt-len" command, the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag, 'max-pkt-len' and MTU is updated.

[1]
--------------------------------------------------------------------------
dpdk-testpmd -c 0xf -n 4 -- -i --max-pkt-len=9000 --tx-offloads=0x8000

	--rxq=4 --txq=4 --disable-rss
testpmd>  set verbose 3
testpmd>  port stop all
testpmd>  port config all max-pkt-len 1518
testpmd>  port start all

// Got fail error info without this patch
Configuring Port 0 (socket 1)
Ethdev port_id=0 rx_queue_id=0, new added offloads 0x800 must be within per-queue offload capabilities 0x0 in rte_eth_rx_queue_setup() Fail to configure port 0 rx queues //<-- Fail error info;
--------------------------------------------------------------------------

Fixes 761c4d66900f ("app/testpmd: fix max Rx packet length for VLAN packets")

---

v5:
* 'update_jumbo_frame_offload()' helper updated
* check zero 'max-pkt-len' value
* Update how queue offload flags updated
* Update MTU if JUMBO_FRAME flag is not set
* Default testpmd 'max-pkt-len' value set to zero

---
 app/test-pmd/cmdline.c |  13 ++++++
 app/test-pmd/testpmd.c | 102 +++++++++++++++++++++++++++++++++--------
 app/test-pmd/testpmd.h |   1 +
 3 files changed, 97 insertions(+), 19 deletions(-)
app/test-pmd/cmdline.c +13 -0
index 89034c8b7272..9ada4316c6c0 100644
@@ -1877,7 +1877,9 @@ cmd_config_max_pkt_len_parsed(void *parsed_result,
 				__rte_unused void *data)
 {
 	struct cmd_config_max_pkt_len_result *res = parsed_result;
+	uint32_t max_rx_pkt_len_backup = 0;
 	portid_t pid;
+	int ret;
 
 	if (!all_ports_stopped()) {
 		printf("Please stop all ports first\n");
@@ -1896,7 +1898,18 @@ cmd_config_max_pkt_len_parsed(void *parsed_result,
 			if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
 				return;
 
+			ret = eth_dev_info_get_print_err(pid, &port->dev_info);
+			if (ret != 0) {
+				printf("rte_eth_dev_info_get() failed for port %u\n",
+					pid);
+				return;
+			}
+
+			max_rx_pkt_len_backup = port->dev_conf.rxmode.max_rx_pkt_len;
+
 			port->dev_conf.rxmode.max_rx_pkt_len = res->value;
+			if (update_jumbo_frame_offload(pid) != 0)
+				port->dev_conf.rxmode.max_rx_pkt_len = max_rx_pkt_len_backup;
 		} else {
 			printf("Unknown parameter\n");
 			return;
app/test-pmd/testpmd.c +83 -19

126 lines not on this page · raw message

app/test-pmd/testpmd.h +1 -0
index 5f2316210726..2f8f5a92e46a 100644
@@ -1005,6 +1005,7 @@ uint16_t tx_pkt_set_dynf(uint16_t port_id, __rte_unused uint16_t queue,
 			 __rte_unused void *user_param);
 void add_tx_dynf_callback(portid_t portid);
 void remove_tx_dynf_callback(portid_t portid);
+int update_jumbo_frame_offload(portid_t portid);
 
 /*
  * Work-around of a compilation error with ICC on invocations of the
Signature · 1 line
2.29.2
#23 lore raw

Re: [dpdk-dev] [PATCH v5] app/testpmd: fix setting maximum packet length

Quoted 29 lines · Ferruh Yigit

From: Steve Yang <[email protected]>

"port config all max-pkt-len" command fails because it doesn't set the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag properly.

Commit in the fixes line moved the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag update from 'cmd_config_max_pkt_len_parsed()' to 'init_config()'. 'init_config()' function is only called during testpmd startup, but the flag status needs to be calculated whenever 'max_rx_pkt_len' changes.

The issue can be reproduce as [1], where the 'max-pkt-len' reduced and 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag should be cleared but it didn't.

Adding the 'update_jumbo_frame_offload()' helper function to update 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag and 'max_rx_pkt_len'. This function is called both by 'init_config()' and 'cmd_config_max_pkt_len_parsed()'.

Default 'max-pkt-len' value set to zero, 'update_jumbo_frame_offload()' updates it to "RTE_ETHER_MTU + PMD specific Ethernet overhead" when it is zero.
If '--max-pkt-len=N' argument provided, it will be used instead. And with each "port config all max-pkt-len" command, the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag, 'max-pkt-len' and MTU is updated.

[1]

<snip>

Quoted 5 lines

+/*
+ * Helper function to arrange max_rx_pktlen value and JUMBO_FRAME offload,
+ * MTU is also aligned if JUMBO_FRAME offload is not set.
+ *
+ * port->dev_info should be get before calling this function.

Should this be "port->dev_info should be set ..." instead?

<snip>

app/test-pmd/testpmd.c rxtx_port_config(struct rte_port *port) · line 3407

Quoted 12 lines
app/test-pmd/testpmd.c +12 -0
+       if (rx_offloads != port->dev_conf.rxmode.offloads) {
+               uint16_t qid;
+
+               port->dev_conf.rxmode.offloads = rx_offloads;
+
+               /* Apply JUMBO_FRAME offload configuration to Rx queue(s) */
+               for (qid = 0; qid < port->dev_info.nb_rx_queues; qid++) {
+                       if (on)
+                               port->rx_conf[qid].offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+                       else
+                               port->rx_conf[qid].offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
+               }

Is it correct to set per-queue offloads that aren't advertised by the PMD as supported in rx_queue_offload_capa?

Quoted 7 lines
app/test-pmd/testpmd.c +7 -0
+       }
+
+       /* If JUMBO_FRAME is set MTU conversion done by ethdev layer,
+        * if unset do it here
+        */
+       if ((rx_offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) == 0) {
+               ret = rte_eth_dev_set_mtu(portid,

app/test-pmd/testpmd.c rxtx_port_config(struct rte_port *port) · line 3424

Quoted 10 lines
app/test-pmd/testpmd.c +10 -0
+                               port->dev_conf.rxmode.max_rx_pkt_len - eth_overhead);
+               if (ret)
+                       printf("Failed to set MTU to %u for port %u\n",
+                               port->dev_conf.rxmode.max_rx_pkt_len - eth_overhead,
+                               portid);
+       }
+
+       return 0;
+}
+

Applied and tested with a few iterations of configuring max packet size back and forth between jumbo and non-jumbo sizes, also tried setting max packet size using the command-line option, all seems good based on rx offloads and packet forwarding.

Two minor questions above, otherwise LGTM.

#24 lore raw

Re: [dpdk-dev] [PATCH v5] app/testpmd: fix setting maximum packet length

Quoted 33 lines · Lance Richardson
Quoted 29 lines · Ferruh Yigit

From: Steve Yang <[email protected]>

"port config all max-pkt-len" command fails because it doesn't set the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag properly.

Commit in the fixes line moved the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag update from 'cmd_config_max_pkt_len_parsed()' to 'init_config()'. 'init_config()' function is only called during testpmd startup, but the flag status needs to be calculated whenever 'max_rx_pkt_len' changes.

The issue can be reproduce as [1], where the 'max-pkt-len' reduced and 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag should be cleared but it didn't.

Adding the 'update_jumbo_frame_offload()' helper function to update 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag and 'max_rx_pkt_len'. This function is called both by 'init_config()' and 'cmd_config_max_pkt_len_parsed()'.

Default 'max-pkt-len' value set to zero, 'update_jumbo_frame_offload()' updates it to "RTE_ETHER_MTU + PMD specific Ethernet overhead" when it is zero.
If '--max-pkt-len=N' argument provided, it will be used instead. And with each "port config all max-pkt-len" command, the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag, 'max-pkt-len' and MTU is updated.

[1]

<snip>

Quoted 8 lines
Quoted 5 lines

+/*
+ * Helper function to arrange max_rx_pktlen value and JUMBO_FRAME offload,
+ * MTU is also aligned if JUMBO_FRAME offload is not set.
+ *
+ * port->dev_info should be get before calling this function.

Should this be "port->dev_info should be set ..." instead?

Ack.

Quoted 19 lines

<snip>

app/test-pmd/testpmd.c rxtx_port_config(struct rte_port *port) · line 3407

Quoted 12 lines
app/test-pmd/testpmd.c +12 -0
+       if (rx_offloads != port->dev_conf.rxmode.offloads) {
+               uint16_t qid;
+
+               port->dev_conf.rxmode.offloads = rx_offloads;
+
+               /* Apply JUMBO_FRAME offload configuration to Rx queue(s) */
+               for (qid = 0; qid < port->dev_info.nb_rx_queues; qid++) {
+                       if (on)
+                               port->rx_conf[qid].offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+                       else
+                               port->rx_conf[qid].offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
+               }

Is it correct to set per-queue offloads that aren't advertised by the PMD as supported in rx_queue_offload_capa?

'port->rx_conf[]' is testpmd struct, and 'port->dev_conf.rxmode.offloads' values are reflected to 'port->rx_conf[].offloads' for all queues.

We should set the offload in 'port->rx_conf[].offloads' if it is set in 'port->dev_conf.rxmode.offloads'.

If a port has capability for 'JUMBO_FRAME', 'port->rx_conf[].offloads' can have it. And the port level capability is already checked above.

Quoted 23 lines
Quoted 7 lines
app/test-pmd/testpmd.c +7 -0
+       }
+
+       /* If JUMBO_FRAME is set MTU conversion done by ethdev layer,
+        * if unset do it here
+        */
+       if ((rx_offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) == 0) {
+               ret = rte_eth_dev_set_mtu(portid,

app/test-pmd/testpmd.c rxtx_port_config(struct rte_port *port) · line 3424

Quoted 10 lines
app/test-pmd/testpmd.c +10 -0
+                               port->dev_conf.rxmode.max_rx_pkt_len - eth_overhead);
+               if (ret)
+                       printf("Failed to set MTU to %u for port %u\n",
+                               port->dev_conf.rxmode.max_rx_pkt_len - eth_overhead,
+                               portid);
+       }
+
+       return 0;
+}
+

Applied and tested with a few iterations of configuring max packet size back and forth between jumbo and non-jumbo sizes, also tried setting max packet size using the command-line option, all seems good based on rx offloads and packet forwarding.

Quoted 2 lines

Two minor questions above, otherwise LGTM.

Thanks for testing. I will wait for more comments before new version.

#25 lore raw

Re: [dpdk-dev] [PATCH v5] app/testpmd: fix setting maximum packet length

Thanks,
Lance

Quoted 102 lines · Ferruh Yigit
Quoted 33 lines · Lance Richardson
Quoted 29 lines · Ferruh Yigit

From: Steve Yang <[email protected]>

"port config all max-pkt-len" command fails because it doesn't set the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag properly.

Commit in the fixes line moved the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag update from 'cmd_config_max_pkt_len_parsed()' to 'init_config()'. 'init_config()' function is only called during testpmd startup, but the flag status needs to be calculated whenever 'max_rx_pkt_len' changes.

The issue can be reproduce as [1], where the 'max-pkt-len' reduced and 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag should be cleared but it didn't.

Adding the 'update_jumbo_frame_offload()' helper function to update 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag and 'max_rx_pkt_len'. This function is called both by 'init_config()' and 'cmd_config_max_pkt_len_parsed()'.

Default 'max-pkt-len' value set to zero, 'update_jumbo_frame_offload()' updates it to "RTE_ETHER_MTU + PMD specific Ethernet overhead" when it is zero.
If '--max-pkt-len=N' argument provided, it will be used instead. And with each "port config all max-pkt-len" command, the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag, 'max-pkt-len' and MTU is updated.

[1]

<snip>

Quoted 8 lines
Quoted 5 lines

+/*
+ * Helper function to arrange max_rx_pktlen value and JUMBO_FRAME offload,
+ * MTU is also aligned if JUMBO_FRAME offload is not set.
+ *
+ * port->dev_info should be get before calling this function.

Should this be "port->dev_info should be set ..." instead?

Ack.

Quoted 19 lines

<snip>

app/test-pmd/testpmd.c rxtx_port_config(struct rte_port *port) · line 3407

Quoted 12 lines
app/test-pmd/testpmd.c +12 -0
+       if (rx_offloads != port->dev_conf.rxmode.offloads) {
+               uint16_t qid;
+
+               port->dev_conf.rxmode.offloads = rx_offloads;
+
+               /* Apply JUMBO_FRAME offload configuration to Rx queue(s) */
+               for (qid = 0; qid < port->dev_info.nb_rx_queues; qid++) {
+                       if (on)
+                               port->rx_conf[qid].offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+                       else
+                               port->rx_conf[qid].offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
+               }

Is it correct to set per-queue offloads that aren't advertised by the PMD as supported in rx_queue_offload_capa?

'port->rx_conf[]' is testpmd struct, and 'port->dev_conf.rxmode.offloads' values are reflected to 'port->rx_conf[].offloads' for all queues.

We should set the offload in 'port->rx_conf[].offloads' if it is set in 'port->dev_conf.rxmode.offloads'.

If a port has capability for 'JUMBO_FRAME', 'port->rx_conf[].offloads' can have it. And the port level capability is already checked above.

Quoted 23 lines
Quoted 7 lines
app/test-pmd/testpmd.c +7 -0
+       }
+
+       /* If JUMBO_FRAME is set MTU conversion done by ethdev layer,
+        * if unset do it here
+        */
+       if ((rx_offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) == 0) {
+               ret = rte_eth_dev_set_mtu(portid,

app/test-pmd/testpmd.c rxtx_port_config(struct rte_port *port) · line 3424

Quoted 10 lines
app/test-pmd/testpmd.c +10 -0
+                               port->dev_conf.rxmode.max_rx_pkt_len - eth_overhead);
+               if (ret)
+                       printf("Failed to set MTU to %u for port %u\n",
+                               port->dev_conf.rxmode.max_rx_pkt_len - eth_overhead,
+                               portid);
+       }
+
+       return 0;
+}
+

Applied and tested with a few iterations of configuring max packet size back and forth between jumbo and non-jumbo sizes, also tried setting max packet size using the command-line option, all seems good based on rx offloads and packet forwarding.

Quoted 2 lines

Two minor questions above, otherwise LGTM.

Thanks for testing. I will wait for more comments before new version.

#26 lore raw

Re: [dpdk-dev] [PATCH v5] app/testpmd: fix setting maximum packet length

In reply to Ferruh Yigit
Quoted 18 lines · Ferruh Yigit
Quoted 17 lines

app/test-pmd/testpmd.c rxtx_port_config(struct rte_port *port) · line 3407

Quoted 13 lines
app/test-pmd/testpmd.c +12 -0
+       if (rx_offloads != port->dev_conf.rxmode.offloads) {
+               uint16_t qid;
+
+               port->dev_conf.rxmode.offloads = rx_offloads;
+
+               /* Apply JUMBO_FRAME offload configuration to Rx queue(s) */
+               for (qid = 0; qid < port->dev_info.nb_rx_queues; qid++) {
+                       if (on)
+                               port->rx_conf[qid].offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+                       else
+                               port->rx_conf[qid].offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
+               }

Is it correct to set per-queue offloads that aren't advertised by the PMD as supported in rx_queue_offload_capa?

Quoted 9 lines

'port->rx_conf[]' is testpmd struct, and 'port->dev_conf.rxmode.offloads' values are reflected to 'port->rx_conf[].offloads' for all queues.

We should set the offload in 'port->rx_conf[].offloads' if it is set in 'port->dev_conf.rxmode.offloads'.

If a port has capability for 'JUMBO_FRAME', 'port->rx_conf[].offloads' can have it. And the port level capability is already checked above.

I'm still not 100% clear about the per-queue offload question.

With this patch, and jumbo max packet size configured (on the command line in this case), I see:

testpmd> show port 0 rx_offload configuration
Rx Offloading Configuration of port 0 :
Port : JUMBO_FRAME
Queue[ 0] : JUMBO_FRAME

testpmd> show port 0 rx_offload capabilities
Rx Offloading Capabilities of port 0 :
Per Queue :
Per Port : VLAN_STRIP IPV4_CKSUM UDP_CKSUM TCP_CKSUM TCP_LRO
OUTER_IPV4_CKSUM VLAN_FILTER VLAN_EXTEND JUMBO_FRAME SCATTER TIMESTAMP KEEP_CRC OUTER_UDP_CKSUM RSS_HASH

Yet if I configure a jumbo MTU starting with standard max packet size, jumbo is only enabled at the port level:
testpmd> port config mtu 0 9000
testpmd> port start all

testpmd> show port 0 rx_offload configuration
Rx Offloading Configuration of port 0 :
Port : JUMBO_FRAME
Queue[ 0] :

It still seems odd for a per-queue offload to be enabled on a PMD that doesn't support per-queue receive offloads.

#27 lore raw

Re: [dpdk-dev] [PATCH v5] app/testpmd: fix setting maximum packet length

Quoted 68 lines

-----Original Message-----
From: Lance Richardson <[email protected]>
Sent: Tuesday, January 26, 2021 11:45
To: Yigit, Ferruh <[email protected]>
Cc: Lu, Wenzhuo <[email protected]>; Li, Xiaoyun <[email protected]>; Iremonger, Bernard <[email protected]>; Yang, SteveX <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v5] app/testpmd: fix setting maximum packet length

Quoted 10 lines · Ferruh Yigit
Quoted 10 lines

app/test-pmd/testpmd.c rxtx_port_config(struct rte_port *port)

Quoted 10 lines
app/test-pmd/testpmd.c +9 -0
+       if (rx_offloads != port->dev_conf.rxmode.offloads) {
+               uint16_t qid;
+
+               port->dev_conf.rxmode.offloads = rx_offloads;
+
+               /* Apply JUMBO_FRAME offload configuration to Rx queue(s) */
+               for (qid = 0; qid < port->dev_info.nb_rx_queues; qid++) {
+                       if (on)
+                               port->rx_conf[qid].offloads |=

DEV_RX_OFFLOAD_JUMBO_FRAME;

Quoted 2 lines
Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+                       else
+                               port->rx_conf[qid].offloads &=

~DEV_RX_OFFLOAD_JUMBO_FRAME;

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

+ }

Is it correct to set per-queue offloads that aren't advertised by the PMD as supported in rx_queue_offload_capa?

'port->rx_conf[]' is testpmd struct, and 'port->dev_conf.rxmode.offloads'

values

Quoted 6 lines

are reflected to 'port->rx_conf[].offloads' for all queues.

We should set the offload in 'port->rx_conf[].offloads' if it is set in 'port->dev_conf.rxmode.offloads'.

If a port has capability for 'JUMBO_FRAME', 'port->rx_conf[].offloads' can

have

Quoted 2 lines

it. And the port level capability is already checked above.

I'm still not 100% clear about the per-queue offload question.

With this patch, and jumbo max packet size configured (on the command line in this case), I see:

testpmd> show port 0 rx_offload configuration
Rx Offloading Configuration of port 0 :
Port : JUMBO_FRAME
Queue[ 0] : JUMBO_FRAME

testpmd> show port 0 rx_offload capabilities
Rx Offloading Capabilities of port 0 :
Per Queue :
Per Port : VLAN_STRIP IPV4_CKSUM UDP_CKSUM TCP_CKSUM TCP_LRO
OUTER_IPV4_CKSUM VLAN_FILTER VLAN_EXTEND JUMBO_FRAME SCATTER TIMESTAMP
KEEP_CRC OUTER_UDP_CKSUM RSS_HASH

Yet if I configure a jumbo MTU starting with standard max packet size, jumbo is only enabled at the port level:
testpmd> port config mtu 0 9000
testpmd> port start all

Quoted 7 lines

testpmd> show port 0 rx_offload configuration
Rx Offloading Configuration of port 0 :
Port : JUMBO_FRAME
Queue[ 0] :

It still seems odd for a per-queue offload to be enabled on a PMD that doesn't support per-queue receive offloads.

In struct rte_eth_dev_info, rx_offload_capa means All RX offload capabilities including all per-queue ones. And rx_queue_offload_capa means Device per-queue RX offload capabilities.

The meaning of rx_queue_offload_capa is a bit of confusing between here and driver. I think here rx_queue_offload_capa means whether a queue supports offloads.

But some drivers like i40e don't use rx_queue_offload_capa, set this as 0 and only use global rx_offload_capa. I guess it's because the driver doesn't want to support different offloads settings for different queues? Then rx_queue_offload_capa means differently.

Actually for i40e, it can support different offloads for different queues since there is 'offloads' in struct i40e_rx_queue. I40e can just set rx_queue_offload_capa as the value for rx_offload_capa.
But maybe some drivers really don't want this? Not sure on this.

#28 lore raw

Re: [dpdk-dev] [PATCH v5] app/testpmd: fix setting maximum packet length

In reply to Lance Richardson
Quoted 39 lines · Lance Richardson
Quoted 18 lines · Ferruh Yigit
Quoted 17 lines

app/test-pmd/testpmd.c rxtx_port_config(struct rte_port *port) · line 3407

Quoted 13 lines
app/test-pmd/testpmd.c +12 -0
+       if (rx_offloads != port->dev_conf.rxmode.offloads) {
+               uint16_t qid;
+
+               port->dev_conf.rxmode.offloads = rx_offloads;
+
+               /* Apply JUMBO_FRAME offload configuration to Rx queue(s) */
+               for (qid = 0; qid < port->dev_info.nb_rx_queues; qid++) {
+                       if (on)
+                               port->rx_conf[qid].offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+                       else
+                               port->rx_conf[qid].offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
+               }

Is it correct to set per-queue offloads that aren't advertised by the PMD as supported in rx_queue_offload_capa?

Quoted 9 lines

'port->rx_conf[]' is testpmd struct, and 'port->dev_conf.rxmode.offloads' values are reflected to 'port->rx_conf[].offloads' for all queues.

We should set the offload in 'port->rx_conf[].offloads' if it is set in 'port->dev_conf.rxmode.offloads'.

If a port has capability for 'JUMBO_FRAME', 'port->rx_conf[].offloads' can have it. And the port level capability is already checked above.

I'm still not 100% clear about the per-queue offload question.

With this patch, and jumbo max packet size configured (on the command line in this case), I see:

testpmd> show port 0 rx_offload configuration
Rx Offloading Configuration of port 0 :
Port : JUMBO_FRAME
Queue[ 0] : JUMBO_FRAME

Quoted 7 lines

testpmd> show port 0 rx_offload capabilities
Rx Offloading Capabilities of port 0 :
Per Queue :
Per Port : VLAN_STRIP IPV4_CKSUM UDP_CKSUM TCP_CKSUM TCP_LRO
OUTER_IPV4_CKSUM VLAN_FILTER VLAN_EXTEND JUMBO_FRAME SCATTER TIMESTAMP KEEP_CRC OUTER_UDP_CKSUM RSS_HASH

The port level offload is applied to all queues on the port, testpmd config structure reflects this logic in implementation. If Rx offload X is set for a port, it is set for all Rx queue offloads, this is not new behavior and not related to this patch.

In the ethdev, lets assume X & Y are port level offloads,
after X, Y are set via 'rte_eth_dev_configure()'
if user calls 'rte_eth_rx_queue_setup()' with X & Y offload, this is a valid call and API will return success, since those offloads already enabled in port level means they are enabled for all queues.

Because of above ethdev behavior, testpmd keeps all enabled port level offload in the queue level offload too, and display them as enabled offloads for the queue.

To request a queue specific offload, it is added to specific queue's config before calling queue setup. Lets say that queue specific offload is Z, after setup testpmd config struct will show that specific queue has X, Y & Z offloads.

I hope it is more clear now.

Quoted 5 lines

Yet if I configure a jumbo MTU starting with standard max packet size, jumbo is only enabled at the port level:
testpmd> port config mtu 0 9000
testpmd> port start all

Quoted 8 lines

testpmd> show port 0 rx_offload configuration
Rx Offloading Configuration of port 0 :
Port : JUMBO_FRAME
Queue[ 0] :

It still seems odd for a per-queue offload to be enabled on a PMD that doesn't support per-queue receive offloads.

"port config mtu" should take queue offloads into account, it looks wrong right now.

#29 lore raw

Re: [dpdk-dev] [PATCH v5] app/testpmd: fix setting maximum packet length

Quoted 49 lines · Ferruh Yigit
Quoted 39 lines · Lance Richardson
Quoted 18 lines · Ferruh Yigit
Quoted 17 lines

app/test-pmd/testpmd.c rxtx_port_config(struct rte_port *port) · line 3407

Quoted 13 lines
app/test-pmd/testpmd.c +12 -0
+       if (rx_offloads != port->dev_conf.rxmode.offloads) {
+               uint16_t qid;
+
+               port->dev_conf.rxmode.offloads = rx_offloads;
+
+               /* Apply JUMBO_FRAME offload configuration to Rx queue(s) */
+               for (qid = 0; qid < port->dev_info.nb_rx_queues; qid++) {
+                       if (on)
+                               port->rx_conf[qid].offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+                       else
+                               port->rx_conf[qid].offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
+               }

Is it correct to set per-queue offloads that aren't advertised by the PMD as supported in rx_queue_offload_capa?

Quoted 9 lines

'port->rx_conf[]' is testpmd struct, and 'port->dev_conf.rxmode.offloads' values are reflected to 'port->rx_conf[].offloads' for all queues.

We should set the offload in 'port->rx_conf[].offloads' if it is set in 'port->dev_conf.rxmode.offloads'.

If a port has capability for 'JUMBO_FRAME', 'port->rx_conf[].offloads' can have it. And the port level capability is already checked above.

I'm still not 100% clear about the per-queue offload question.

With this patch, and jumbo max packet size configured (on the command line in this case), I see:

testpmd> show port 0 rx_offload configuration
Rx Offloading Configuration of port 0 :
Port : JUMBO_FRAME
Queue[ 0] : JUMBO_FRAME

Quoted 7 lines

testpmd> show port 0 rx_offload capabilities
Rx Offloading Capabilities of port 0 :
Per Queue :
Per Port : VLAN_STRIP IPV4_CKSUM UDP_CKSUM TCP_CKSUM TCP_LRO
OUTER_IPV4_CKSUM VLAN_FILTER VLAN_EXTEND JUMBO_FRAME SCATTER TIMESTAMP KEEP_CRC OUTER_UDP_CKSUM RSS_HASH

Quoted 5 lines

The port level offload is applied to all queues on the port, testpmd config structure reflects this logic in implementation.
If Rx offload X is set for a port, it is set for all Rx queue offloads, this is not new behavior and not related to this patch.

OK, is this purely for display purposes within testpmd? I ask because it appears that all PMDs supporting per-queue offload configuration already take care of combining port-level and per-queue offloads within their tx_queue_setup()/rx_queue_setup() functions and then track the combined set of offloads within a per-queue field, e.g. this line is common to e1000/i40e/ionic/ixgbe/octeontx2/thunderx/txgbe rx_queue_setup() implementations:

    offloads = rx_conf->offloads | dev->data->dev_conf.rxmode.offloads;

And rte_ethdev.h says:
No need to repeat any bit in rx_conf->offloads which has already been enabled in rte_eth_dev_configure() at port level. An offloading enabled
at port level can't be disabled at queue level.

Which I suppose confirms that if testpmd is combining per-port and per- queue offloads, it's just for the purposes of testpmd.

Apologies for worrying at this even more, I just wanted to be sure that I understand what the PMD is expected to do.

Regards,
Lance

#30 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v5] app/testpmd: fix setting maximum packet length

Quoted 64 lines · Lance Richardson
Quoted 49 lines · Ferruh Yigit
Quoted 39 lines · Lance Richardson
Quoted 18 lines · Ferruh Yigit
Quoted 17 lines

app/test-pmd/testpmd.c rxtx_port_config(struct rte_port *port) · line 3407

Quoted 13 lines
app/test-pmd/testpmd.c +12 -0
+       if (rx_offloads != port->dev_conf.rxmode.offloads) {
+               uint16_t qid;
+
+               port->dev_conf.rxmode.offloads = rx_offloads;
+
+               /* Apply JUMBO_FRAME offload configuration to Rx queue(s) */
+               for (qid = 0; qid < port->dev_info.nb_rx_queues; qid++) {
+                       if (on)
+                               port->rx_conf[qid].offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+                       else
+                               port->rx_conf[qid].offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
+               }

Is it correct to set per-queue offloads that aren't advertised by the PMD as supported in rx_queue_offload_capa?

Quoted 9 lines

'port->rx_conf[]' is testpmd struct, and 'port->dev_conf.rxmode.offloads' values are reflected to 'port->rx_conf[].offloads' for all queues.

We should set the offload in 'port->rx_conf[].offloads' if it is set in 'port->dev_conf.rxmode.offloads'.

If a port has capability for 'JUMBO_FRAME', 'port->rx_conf[].offloads' can have it. And the port level capability is already checked above.

I'm still not 100% clear about the per-queue offload question.

With this patch, and jumbo max packet size configured (on the command line in this case), I see:

testpmd> show port 0 rx_offload configuration
Rx Offloading Configuration of port 0 :
Port : JUMBO_FRAME
Queue[ 0] : JUMBO_FRAME

Quoted 7 lines

testpmd> show port 0 rx_offload capabilities
Rx Offloading Capabilities of port 0 :
Per Queue :
Per Port : VLAN_STRIP IPV4_CKSUM UDP_CKSUM TCP_CKSUM TCP_LRO
OUTER_IPV4_CKSUM VLAN_FILTER VLAN_EXTEND JUMBO_FRAME SCATTER TIMESTAMP KEEP_CRC OUTER_UDP_CKSUM RSS_HASH

Quoted 5 lines

The port level offload is applied to all queues on the port, testpmd config structure reflects this logic in implementation.
If Rx offload X is set for a port, it is set for all Rx queue offloads, this is not new behavior and not related to this patch.

OK, is this purely for display purposes within testpmd? I ask because it appears that all PMDs supporting per-queue offload configuration already take care of combining port-level and per-queue offloads within their tx_queue_setup()/rx_queue_setup() functions and then track the combined set of offloads within a per-queue field, e.g. this line is common to e1000/i40e/ionic/ixgbe/octeontx2/thunderx/txgbe rx_queue_setup() implementations:

     offloads = rx_conf->offloads | dev->data->dev_conf.rxmode.offloads;
Quoted 8 lines

And rte_ethdev.h says:
No need to repeat any bit in rx_conf->offloads which has already been enabled in rte_eth_dev_configure() at port level. An offloading enabled
at port level can't be disabled at queue level.

Which I suppose confirms that if testpmd is combining per-port and per- queue offloads, it's just for the purposes of testpmd.

Yes it is just for purposed of testpmd (application), but doesn't need to be just limited to display purpose, testpmd keeps the config locally for any need.

Quoted 3 lines

Apologies for worrying at this even more, I just wanted to be sure that I understand what the PMD is expected to do.

PMDs should not be getting these offloads in queue setup, since ethdev layer strips the port level offloads, I mean:

if port level offloads: X, Y

And applications provide following for queue_setup():
a) X
b) Y
c) X, Y

For all three PMD receives empty queue offload request.

d) X, Y, Z

PMD gets Z if it is in drivers queue specific capabilities.

Acked-by on v5 1/1
#31 lore raw

Re: [dpdk-dev] [PATCH v5] app/testpmd: fix setting maximum packet length

In reply to Ferruh Yigit

Hi,

Quoted 68 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, January 25, 2021 8:16 PM
To: Wenzhuo Lu <[email protected]>; Xiaoyun Li <[email protected]>; Bernard Iremonger <[email protected]>; Steve Yang <[email protected]>
Cc: Ferruh Yigit <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Wisam Monther <[email protected]>; [email protected]
Subject: [PATCH v5] app/testpmd: fix setting maximum packet length

From: Steve Yang <[email protected]>

"port config all max-pkt-len" command fails because it doesn't set the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag properly.

Commit in the fixes line moved the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag update from 'cmd_config_max_pkt_len_parsed()' to 'init_config()'.
'init_config()' function is only called during testpmd startup, but the flag status needs to be calculated whenever 'max_rx_pkt_len' changes.

The issue can be reproduce as [1], where the 'max-pkt-len' reduced and 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag should be cleared but it didn't.

Adding the 'update_jumbo_frame_offload()' helper function to update 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag and 'max_rx_pkt_len'. This function is called both by 'init_config()' and 'cmd_config_max_pkt_len_parsed()'.

Default 'max-pkt-len' value set to zero, 'update_jumbo_frame_offload()' updates it to "RTE_ETHER_MTU + PMD specific Ethernet overhead" when it is zero.
If '--max-pkt-len=N' argument provided, it will be used instead. And with each "port config all max-pkt-len" command, the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag, 'max-pkt-len' and MTU is updated.

[1]
--------------------------------------------------------------------------
dpdk-testpmd -c 0xf -n 4 -- -i --max-pkt-len=9000 --tx-offloads=0x8000

	--rxq=4 --txq=4 --disable-rss
testpmd>  set verbose 3
testpmd>  port stop all
testpmd>  port config all max-pkt-len 1518  port start all

// Got fail error info without this patch Configuring Port 0 (socket 1) Ethdev port_id=0 rx_queue_id=0, new added offloads 0x800 must be within per- queue offload capabilities 0x0 in rte_eth_rx_queue_setup() Fail to configure port 0 rx queues //<-- Fail error info;
--------------------------------------------------------------------------

Fixes 761c4d66900f ("app/testpmd: fix max Rx packet length for VLAN

packets")
Cc: [email protected]

---

v5:
* 'update_jumbo_frame_offload()' helper updated
* check zero 'max-pkt-len' value
* Update how queue offload flags updated
* Update MTU if JUMBO_FRAME flag is not set
* Default testpmd 'max-pkt-len' value set to zero

Quoted 5 lines

---

It fixed this bug indeed: https://bugs.dpdk.org/show_bug.cgi?id=625
Thanks

BRs,
Wisam Jaddo

Acked-by on v5 1/1
#32 lore raw

Re: [dpdk-dev] [PATCH v5] app/testpmd: fix setting maximum packet length

In reply to Ferruh Yigit

Except a minor typo inline.

Quoted 16 lines

-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Tuesday, January 26, 2021 02:16
To: Lu, Wenzhuo <[email protected]>; Li, Xiaoyun <[email protected]>; Iremonger, Bernard <[email protected]>; Yang, SteveX <[email protected]>
Cc: Yigit, Ferruh <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v5] app/testpmd: fix setting maximum packet length

From: Steve Yang <[email protected]>

"port config all max-pkt-len" command fails because it doesn't set the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag properly.

Quoted 6 lines

Commit in the fixes line moved the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag update from 'cmd_config_max_pkt_len_parsed()' to 'init_config()'. 'init_config()' function is only called during testpmd startup, but the flag status needs to be calculated whenever 'max_rx_pkt_len' changes.

The issue can be reproduce as [1], where the 'max-pkt-len' reduced and

reproduced

Quoted 247 lines

'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag should be cleared but it didn't.

Adding the 'update_jumbo_frame_offload()' helper function to update 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag and 'max_rx_pkt_len'. This function is called both by 'init_config()' and 'cmd_config_max_pkt_len_parsed()'.

Default 'max-pkt-len' value set to zero, 'update_jumbo_frame_offload()' updates it to "RTE_ETHER_MTU + PMD specific Ethernet overhead" when it is zero.
If '--max-pkt-len=N' argument provided, it will be used instead. And with each "port config all max-pkt-len" command, the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag, 'max-pkt-len' and MTU is updated.

[1]
--------------------------------------------------------------------------
dpdk-testpmd -c 0xf -n 4 -- -i --max-pkt-len=9000 --tx-offloads=0x8000

	--rxq=4 --txq=4 --disable-rss
testpmd>  set verbose 3
testpmd>  port stop all
testpmd>  port config all max-pkt-len 1518  port start all

// Got fail error info without this patch Configuring Port 0 (socket 1) Ethdev port_id=0 rx_queue_id=0, new added offloads 0x800 must be within per-queue offload capabilities 0x0 in rte_eth_rx_queue_setup() Fail to configure port 0 rx queues //<-- Fail error info;
--------------------------------------------------------------------------

Fixes 761c4d66900f ("app/testpmd: fix max Rx packet length for VLAN packets")

---

v5:
* 'update_jumbo_frame_offload()' helper updated
* check zero 'max-pkt-len' value
* Update how queue offload flags updated
* Update MTU if JUMBO_FRAME flag is not set
* Default testpmd 'max-pkt-len' value set to zero

---
 app/test-pmd/cmdline.c |  13 ++++++
 app/test-pmd/testpmd.c | 102 +++++++++++++++++++++++++++++++++--------
 app/test-pmd/testpmd.h |   1 +
 3 files changed, 97 insertions(+), 19 deletions(-)
app/test-pmd/cmdline.c index renamed from app/test-pmd/cmdline.c +0 -0

89034c8b7272..9ada4316c6c0 100644

app/test-pmd/cmdline.c +2 -0
@@ -1877,7 +1877,9 @@ cmd_config_max_pkt_len_parsed(void
 *parsed_result,
 				__rte_unused void *data)
 {
 	struct cmd_config_max_pkt_len_result *res = parsed_result;
+	uint32_t max_rx_pkt_len_backup = 0;
 	portid_t pid;
+	int ret;
 
 	if (!all_ports_stopped()) {

printf("Please stop all ports first\n"); @@ -1896,7 +1898,18 @@
cmd_config_max_pkt_len_parsed(void *parsed_result,
if (res->value == port-

Quoted 1 line

dev_conf.rxmode.max_rx_pkt_len)

app/test-pmd/cmdline.c +3 -0
 				return;
 
+			ret = eth_dev_info_get_print_err(pid, &port->dev_info);
+			if (ret != 0) {
+				printf("rte_eth_dev_info_get() failed for

port %u\n",

app/test-pmd/cmdline.c +5 -0
+					pid);
+				return;
+			}
+
+			max_rx_pkt_len_backup = port-
Quoted 1 line

dev_conf.rxmode.max_rx_pkt_len;

app/test-pmd/cmdline.c +3 -0
+
 			port->dev_conf.rxmode.max_rx_pkt_len = res->value;
+			if (update_jumbo_frame_offload(pid) != 0)
+				port->dev_conf.rxmode.max_rx_pkt_len =

max_rx_pkt_len_backup;

app/test-pmd/cmdline.c +0 -0
 		} else {
 			printf("Unknown parameter\n");
 			return;
app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0 -0

c256e719aea2..b69fcd3fde72 100644

app/test-pmd/testpmd.c +5 -4
@@ -443,8 +443,11 @@ lcoreid_t latencystats_lcore_id = -1;
  * Ethernet device configuration.
  */
 struct rte_eth_rxmode rx_mode = {
-	.max_rx_pkt_len = RTE_ETHER_MAX_LEN,
-		/**< Default maximum frame length. */
+	/* Default maximum frame length.
+	 * Zero is converted to "RTE_ETHER_MTU + PMD Ethernet overhead"
+	 * in init_config().
+	 */
+	.max_rx_pkt_len = 0,
 };
 
 struct rte_eth_txmode tx_mode = {
@@ -1410,7 +1413,6 @@ init_config(void)
 	struct rte_gro_param gro_param;
 	uint32_t gso_types;
 	uint16_t data_size;
-	uint16_t eth_overhead;
 	bool warning = 0;
 	int k;
 	int ret;
@@ -1447,22 +1449,10 @@ init_config(void)
 			rte_exit(EXIT_FAILURE,
 				 "rte_eth_dev_info_get() failed\n");
 
-		/* Update the max_rx_pkt_len to have MTU as

RTE_ETHER_MTU */

app/test-pmd/testpmd.c +3 -15
-		if (port->dev_info.max_mtu != UINT16_MAX &&
-		    port->dev_info.max_rx_pktlen > port->dev_info.max_mtu)
-			eth_overhead = port->dev_info.max_rx_pktlen -
-				port->dev_info.max_mtu;
-		else
-			eth_overhead =
-				RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
-
-		if (port->dev_conf.rxmode.max_rx_pkt_len <=
-			(uint32_t)(RTE_ETHER_MTU + eth_overhead))
-			port->dev_conf.rxmode.max_rx_pkt_len =
-					RTE_ETHER_MTU + eth_overhead;
-		else
-			port->dev_conf.rxmode.offloads |=
-					DEV_RX_OFFLOAD_JUMBO_FRAME;
+		ret = update_jumbo_frame_offload(pid);
+		if (ret != 0)
+			printf("Updating jumbo frame offload failed for

port %u\n",

app/test-pmd/testpmd.c +30 -0
+				pid);
 
 		if (!(port->dev_info.tx_offload_capa &
 		      DEV_TX_OFFLOAD_MBUF_FAST_FREE)) @@ -3358,6
+3348,80 @@ rxtx_port_config(struct rte_port *port)
 	}
 }
 
+/*
+ * Helper function to arrange max_rx_pktlen value and JUMBO_FRAME
+offload,
+ * MTU is also aligned if JUMBO_FRAME offload is not set.
+ *
+ * port->dev_info should be get before calling this function.
+ *
+ * return 0 on success, negative on error  */ int
+update_jumbo_frame_offload(portid_t portid) {
+	struct rte_port *port = &ports[portid];
+	uint32_t eth_overhead;
+	uint64_t rx_offloads;
+	int ret;
+	bool on;
+
+	/* Update the max_rx_pkt_len to have MTU as RTE_ETHER_MTU */
+	if (port->dev_info.max_mtu != UINT16_MAX &&
+	    port->dev_info.max_rx_pktlen > port->dev_info.max_mtu)
+		eth_overhead = port->dev_info.max_rx_pktlen -
+				port->dev_info.max_mtu;
+	else
+		eth_overhead = RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
+
+	rx_offloads = port->dev_conf.rxmode.offloads;
+
+	/* Default config value is 0 to use PMD specific overhead */
+	if (port->dev_conf.rxmode.max_rx_pkt_len == 0)
+		port->dev_conf.rxmode.max_rx_pkt_len = RTE_ETHER_MTU +

eth_overhead;

app/test-pmd/testpmd.c +2 -0
+
+	if (port->dev_conf.rxmode.max_rx_pkt_len <= RTE_ETHER_MTU +

eth_overhead) {

app/test-pmd/testpmd.c +4 -0
+		rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
+		on = false;
+	} else {
+		if ((port->dev_info.rx_offload_capa &

DEV_RX_OFFLOAD_JUMBO_FRAME) == 0) {

app/test-pmd/testpmd.c +15 -0
+			printf("Frame size (%u) is not supported by port %u\n",
+				port->dev_conf.rxmode.max_rx_pkt_len,
+				portid);
+			return -1;
+		}
+		rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+		on = true;
+	}
+
+	if (rx_offloads != port->dev_conf.rxmode.offloads) {
+		uint16_t qid;
+
+		port->dev_conf.rxmode.offloads = rx_offloads;
+
+		/* Apply JUMBO_FRAME offload configuration to Rx queue(s)

*/

app/test-pmd/testpmd.c +3 -0
+		for (qid = 0; qid < port->dev_info.nb_rx_queues; qid++) {
+			if (on)
+				port->rx_conf[qid].offloads |=

DEV_RX_OFFLOAD_JUMBO_FRAME;

app/test-pmd/testpmd.c +2 -0
+			else
+				port->rx_conf[qid].offloads &=

~DEV_RX_OFFLOAD_JUMBO_FRAME;

app/test-pmd/testpmd.c +9 -0
+		}
+	}
+
+	/* If JUMBO_FRAME is set MTU conversion done by ethdev layer,
+	 * if unset do it here
+	 */
+	if ((rx_offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) == 0) {
+		ret = rte_eth_dev_set_mtu(portid,
+				port->dev_conf.rxmode.max_rx_pkt_len -

eth_overhead);

app/test-pmd/testpmd.c +3 -0
+		if (ret)
+			printf("Failed to set MTU to %u for port %u\n",
+				port->dev_conf.rxmode.max_rx_pkt_len -

eth_overhead,

app/test-pmd/testpmd.c +6 -0
+				portid);
+	}
+
+	return 0;
+}
+
 void
 init_port_config(void)
 {
app/test-pmd/testpmd.h index renamed from app/test-pmd/testpmd.h +0 -0

5f2316210726..2f8f5a92e46a 100644

app/test-pmd/testpmd.h +1 -0
@@ -1005,6 +1005,7 @@ uint16_t tx_pkt_set_dynf(uint16_t port_id,
 __rte_unused uint16_t queue,
 			 __rte_unused void *user_param);
 void add_tx_dynf_callback(portid_t portid);  void
 remove_tx_dynf_callback(portid_t portid);
+int update_jumbo_frame_offload(portid_t portid);
 
 /*

* Work-around of a compilation error with ICC on invocations of the
--
2.29.2

Tested-by
#33 lore raw

Re: [dpdk-dev] [PATCH v5] app/testpmd: fix setting maximum packet length

Quoted 11 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Li, Xiaoyun
Sent: January 27, 2021 11:05
To: Yigit, Ferruh <[email protected]>; Lu, Wenzhuo <[email protected]>; Iremonger, Bernard <[email protected]>; Yang, SteveX <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v5] app/testpmd: fix setting maximum packet length

Quoted 3 lines

Except a minor typo inline.

#34 lore raw

Re: [dpdk-dev] [PATCH v5] app/testpmd: fix setting maximum packet length

In reply to Ferruh Yigit

Hi Ferruh,

Quoted 68 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, January 25, 2021 8:16 PM
To: Wenzhuo Lu <[email protected]>; Xiaoyun Li <[email protected]>; Bernard Iremonger <[email protected]>; Steve Yang <[email protected]>
Cc: Ferruh Yigit <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Wisam Monther <[email protected]>; [email protected]
Subject: [PATCH v5] app/testpmd: fix setting maximum packet length

From: Steve Yang <[email protected]>

"port config all max-pkt-len" command fails because it doesn't set the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag properly.

Commit in the fixes line moved the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag update from 'cmd_config_max_pkt_len_parsed()' to 'init_config()'.
'init_config()' function is only called during testpmd startup, but the flag status needs to be calculated whenever 'max_rx_pkt_len' changes.

The issue can be reproduce as [1], where the 'max-pkt-len' reduced and 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag should be cleared but it didn't.

Adding the 'update_jumbo_frame_offload()' helper function to update 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag and 'max_rx_pkt_len'. This function is called both by 'init_config()' and 'cmd_config_max_pkt_len_parsed()'.

Default 'max-pkt-len' value set to zero, 'update_jumbo_frame_offload()' updates it to "RTE_ETHER_MTU + PMD specific Ethernet overhead" when it is zero.
If '--max-pkt-len=N' argument provided, it will be used instead. And with each "port config all max-pkt-len" command, the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag, 'max-pkt-len' and MTU is updated.

[1]
--------------------------------------------------------------------------
dpdk-testpmd -c 0xf -n 4 -- -i --max-pkt-len=9000 --tx-offloads=0x8000

	--rxq=4 --txq=4 --disable-rss
testpmd>  set verbose 3
testpmd>  port stop all
testpmd>  port config all max-pkt-len 1518  port start all

// Got fail error info without this patch Configuring Port 0 (socket 1) Ethdev port_id=0 rx_queue_id=0, new added offloads 0x800 must be within per- queue offload capabilities 0x0 in rte_eth_rx_queue_setup() Fail to configure port 0 rx queues //<-- Fail error info;
--------------------------------------------------------------------------

Fixes 761c4d66900f ("app/testpmd: fix max Rx packet length for VLAN

packets")
Cc: [email protected]

---

v5:
* 'update_jumbo_frame_offload()' helper updated
* check zero 'max-pkt-len' value
* Update how queue offload flags updated
* Update MTU if JUMBO_FRAME flag is not set
* Default testpmd 'max-pkt-len' value set to zero

Quoted 5 lines

---

I think we need to have https://bugs.dpdk.org/show_bug.cgi?id=625 ID in the commit log as fix, In order to allow the scripts to close related bugs directly from Bugzilla.

BRs,
Wisam Jaddo

#35 lore raw

Re: [dpdk-dev] [PATCH v5] app/testpmd: fix setting maximum packet length

Quoted 71 lines · Wisam Monther

Hi Ferruh,

Quoted 68 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, January 25, 2021 8:16 PM
To: Wenzhuo Lu <[email protected]>; Xiaoyun Li <[email protected]>; Bernard Iremonger <[email protected]>; Steve Yang <[email protected]>
Cc: Ferruh Yigit <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Wisam Monther <[email protected]>; [email protected]
Subject: [PATCH v5] app/testpmd: fix setting maximum packet length

From: Steve Yang <[email protected]>

"port config all max-pkt-len" command fails because it doesn't set the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag properly.

Commit in the fixes line moved the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag update from 'cmd_config_max_pkt_len_parsed()' to 'init_config()'.
'init_config()' function is only called during testpmd startup, but the flag status needs to be calculated whenever 'max_rx_pkt_len' changes.

The issue can be reproduce as [1], where the 'max-pkt-len' reduced and 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag should be cleared but it didn't.

Adding the 'update_jumbo_frame_offload()' helper function to update 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag and 'max_rx_pkt_len'. This function is called both by 'init_config()' and 'cmd_config_max_pkt_len_parsed()'.

Default 'max-pkt-len' value set to zero, 'update_jumbo_frame_offload()' updates it to "RTE_ETHER_MTU + PMD specific Ethernet overhead" when it is zero.
If '--max-pkt-len=N' argument provided, it will be used instead. And with each "port config all max-pkt-len" command, the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag, 'max-pkt-len' and MTU is updated.

[1]
--------------------------------------------------------------------------
dpdk-testpmd -c 0xf -n 4 -- -i --max-pkt-len=9000 --tx-offloads=0x8000

	--rxq=4 --txq=4 --disable-rss
testpmd>  set verbose 3
testpmd>  port stop all
testpmd>  port config all max-pkt-len 1518  port start all

// Got fail error info without this patch Configuring Port 0 (socket 1) Ethdev port_id=0 rx_queue_id=0, new added offloads 0x800 must be within per- queue offload capabilities 0x0 in rte_eth_rx_queue_setup() Fail to configure port 0 rx queues //<-- Fail error info;
--------------------------------------------------------------------------

Fixes 761c4d66900f ("app/testpmd: fix max Rx packet length for VLAN

packets")
Cc: [email protected]

---

v5:
* 'update_jumbo_frame_offload()' helper updated
* check zero 'max-pkt-len' value
* Update how queue offload flags updated
* Update MTU if JUMBO_FRAME flag is not set
* Default testpmd 'max-pkt-len' value set to zero

Quoted 7 lines
Quoted 5 lines

---

I think we need to have https://bugs.dpdk.org/show_bug.cgi?id=625 ID in the commit log as fix,

Sure, I will send a new version with suggested updates, most probably today, I can add the Bugzilla information too.

Quoted 2 lines

In order to allow the scripts to close related bugs directly from Bugzilla.

Scripts? Do we have scripts that close defects automatically, I wasn't aware of it, where does it run?

#36 lore raw

Re: [dpdk-dev] [PATCH v5] app/testpmd: fix setting maximum packet length

Quoted 103 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Thursday, January 28, 2021 11:27 AM
To: Wisam Monther <[email protected]>; Wenzhuo Lu <[email protected]>; Xiaoyun Li <[email protected]>; Bernard Iremonger <[email protected]>; Steve Yang <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v5] app/testpmd: fix setting maximum packet length

Quoted 11 lines · Wisam Monther

Hi Ferruh,

Quoted 8 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, January 25, 2021 8:16 PM
To: Wenzhuo Lu <[email protected]>; Xiaoyun Li <[email protected]>; Bernard Iremonger <[email protected]>; Steve Yang <[email protected]>
Cc: Ferruh Yigit <[email protected]>; [email protected]; [email protected]; [email protected];

[email protected];

Quoted 5 lines
Quoted 5 lines

Wisam Monther <[email protected]>; [email protected]
Subject: [PATCH v5] app/testpmd: fix setting maximum packet length

From: Steve Yang <[email protected]>

Quoted 8 lines
Quoted 8 lines

"port config all max-pkt-len" command fails because it doesn't set the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag properly.

Commit in the fixes line moved the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag update from 'cmd_config_max_pkt_len_parsed()' to 'init_config()'.
'init_config()' function is only called during testpmd startup, but the flag status needs to be calculated whenever 'max_rx_pkt_len'

changes.

Quoted 3 lines
Quoted 3 lines

The issue can be reproduce as [1], where the 'max-pkt-len' reduced and 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag should be cleared

but

Quoted 4 lines
Quoted 4 lines

it didn't.

Adding the 'update_jumbo_frame_offload()' helper function to update 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag and 'max_rx_pkt_len'.

This

Quoted 9 lines
Quoted 9 lines

function is called both by 'init_config()' and
'cmd_config_max_pkt_len_parsed()'.

Default 'max-pkt-len' value set to zero, 'update_jumbo_frame_offload()' updates it to "RTE_ETHER_MTU + PMD specific Ethernet overhead" when it is zero.
If '--max-pkt-len=N' argument provided, it will be used instead. And with each "port config all max-pkt-len" command, the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag, 'max-pkt-len' and MTU

is

Quoted 34 lines
Quoted 34 lines

updated.

[1]
---------------------------------------------------------------------
----- dpdk-testpmd -c 0xf -n 4 -- -i --max-pkt-len=9000 --tx-offloads=0x8000

	--rxq=4 --txq=4 --disable-rss
testpmd>  set verbose 3
testpmd>  port stop all
testpmd>  port config all max-pkt-len 1518  port start all

// Got fail error info without this patch Configuring Port 0 (socket
1) Ethdev
port_id=0 rx_queue_id=0, new added offloads 0x800 must be within per- queue offload capabilities 0x0 in rte_eth_rx_queue_setup() Fail to configure port 0 rx queues //<-- Fail error info;
---------------------------------------------------------------------
-----

Fixes 761c4d66900f ("app/testpmd: fix max Rx packet length for VLAN

packets")
Cc: [email protected]

---

v5:
* 'update_jumbo_frame_offload()' helper updated
* check zero 'max-pkt-len' value
* Update how queue offload flags updated
* Update MTU if JUMBO_FRAME flag is not set
* Default testpmd 'max-pkt-len' value set to zero

Quoted 8 lines
Quoted 5 lines

---

I think we need to have https://bugs.dpdk.org/show_bug.cgi?id=625 ID in the commit log as fix,

Quoted 8 lines

Sure, I will send a new version with suggested updates, most probably today, I can add the Bugzilla information too.

Quoted 2 lines

In order to allow the scripts to close related bugs directly from Bugzilla.

Scripts? Do we have scripts that close defects automatically, I wasn't aware of it, where does it run?

It's something Thomas using and run it every time to time, it's not published yet. But it closes merged bugs, adding a link to the commit as comment.

#37 lore raw

PATCH v6 1/1 app/testpmd: fix setting maximum packet length

In reply to Ferruh Yigit

From: Steve Yang <[email protected]>

"port config all max-pkt-len" command fails because it doesn't set the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag properly.

Commit in the fixes line moved the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag update from 'cmd_config_max_pkt_len_parsed()' to 'init_config()'. 'init_config()' function is only called during testpmd startup, but the flag status needs to be calculated whenever 'max_rx_pkt_len' changes.

The issue can be reproduced as [1], where the 'max-pkt-len' reduced and 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag should be cleared but it didn't.

Adding the 'update_jumbo_frame_offload()' helper function to update 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag and 'max_rx_pkt_len'. This function is called both by 'init_config()' and 'cmd_config_max_pkt_len_parsed()'.

Default 'max-pkt-len' value set to zero, 'update_jumbo_frame_offload()' updates it to "RTE_ETHER_MTU + PMD specific Ethernet overhead" when it is zero.
If '--max-pkt-len=N' argument provided, it will be used instead. And with each "port config all max-pkt-len" command, the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag, 'max-pkt-len' and MTU is updated.

[1]
--------------------------------------------------------------------------
dpdk-testpmd -c 0xf -n 4 -- -i --max-pkt-len=9000 --tx-offloads=0x8000

	--rxq=4 --txq=4 --disable-rss
testpmd>  set verbose 3
testpmd>  port stop all
testpmd>  port config all max-pkt-len 1518
testpmd>  port start all

// Got fail error info without this patch
Configuring Port 0 (socket 1)
Ethdev port_id=0 rx_queue_id=0, new added offloads 0x800 must be within per-queue offload capabilities 0x0 in rte_eth_rx_queue_setup() Fail to configure port 0 rx queues //<-- Fail error info;
--------------------------------------------------------------------------

Bugzilla ID: 625

Fixes 761c4d66900f ("app/testpmd: fix max Rx packet length for VLAN packets")

---
v5:
* 'update_jumbo_frame_offload()' helper updated
* check zero 'max-pkt-len' value
* Update how queue offload flags updated
* Update MTU if JUMBO_FRAME flag is not set
* Default testpmd 'max-pkt-len' value set to zero

v6:
* Comment wording updated
* Bugzilla id added to the commit log

---
 app/test-pmd/cmdline.c |  13 ++++++
 app/test-pmd/testpmd.c | 102 +++++++++++++++++++++++++++++++++--------
 app/test-pmd/testpmd.h |   1 +
 3 files changed, 97 insertions(+), 19 deletions(-)
app/test-pmd/cmdline.c +13 -0
index c6ace2dd2546..b338f5fe6333 100644
@@ -1877,7 +1877,9 @@ cmd_config_max_pkt_len_parsed(void *parsed_result,
 				__rte_unused void *data)
 {
 	struct cmd_config_max_pkt_len_result *res = parsed_result;
+	uint32_t max_rx_pkt_len_backup = 0;
 	portid_t pid;
+	int ret;
 
 	if (!all_ports_stopped()) {
 		printf("Please stop all ports first\n");
@@ -1896,7 +1898,18 @@ cmd_config_max_pkt_len_parsed(void *parsed_result,
 			if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
 				return;
 
+			ret = eth_dev_info_get_print_err(pid, &port->dev_info);
+			if (ret != 0) {
+				printf("rte_eth_dev_info_get() failed for port %u\n",
+					pid);
+				return;
+			}
+
+			max_rx_pkt_len_backup = port->dev_conf.rxmode.max_rx_pkt_len;
+
 			port->dev_conf.rxmode.max_rx_pkt_len = res->value;
+			if (update_jumbo_frame_offload(pid) != 0)
+				port->dev_conf.rxmode.max_rx_pkt_len = max_rx_pkt_len_backup;
 		} else {
 			printf("Unknown parameter\n");
 			return;
app/test-pmd/testpmd.c +83 -19

126 lines not on this page · raw message

app/test-pmd/testpmd.h +1 -0
index 5f2316210726..2f8f5a92e46a 100644
@@ -1005,6 +1005,7 @@ uint16_t tx_pkt_set_dynf(uint16_t port_id, __rte_unused uint16_t queue,
 			 __rte_unused void *user_param);
 void add_tx_dynf_callback(portid_t portid);
 void remove_tx_dynf_callback(portid_t portid);
+int update_jumbo_frame_offload(portid_t portid);
 
 /*
  * Work-around of a compilation error with ICC on invocations of the
Signature · 1 line
2.29.2
Applied
#38 lore raw

Re: [dpdk-dev] [PATCH v6] app/testpmd: fix setting maximum packet length

Quoted 47 lines · Ferruh Yigit

From: Steve Yang <[email protected]>

"port config all max-pkt-len" command fails because it doesn't set the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag properly.

Commit in the fixes line moved the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag update from 'cmd_config_max_pkt_len_parsed()' to 'init_config()'. 'init_config()' function is only called during testpmd startup, but the flag status needs to be calculated whenever 'max_rx_pkt_len' changes.

The issue can be reproduced as [1], where the 'max-pkt-len' reduced and 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag should be cleared but it didn't.

Adding the 'update_jumbo_frame_offload()' helper function to update 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag and 'max_rx_pkt_len'. This function is called both by 'init_config()' and 'cmd_config_max_pkt_len_parsed()'.

Default 'max-pkt-len' value set to zero, 'update_jumbo_frame_offload()' updates it to "RTE_ETHER_MTU + PMD specific Ethernet overhead" when it is zero.
If '--max-pkt-len=N' argument provided, it will be used instead. And with each "port config all max-pkt-len" command, the 'DEV_RX_OFFLOAD_JUMBO_FRAME' offload flag, 'max-pkt-len' and MTU is updated.

[1]
--------------------------------------------------------------------------
dpdk-testpmd -c 0xf -n 4 -- -i --max-pkt-len=9000 --tx-offloads=0x8000

	--rxq=4 --txq=4 --disable-rss
testpmd>  set verbose 3
testpmd>  port stop all
testpmd>  port config all max-pkt-len 1518
testpmd>  port start all

// Got fail error info without this patch
Configuring Port 0 (socket 1)
Ethdev port_id=0 rx_queue_id=0, new added offloads 0x800 must be within per-queue offload capabilities 0x0 in rte_eth_rx_queue_setup() Fail to configure port 0 rx queues //<-- Fail error info;
--------------------------------------------------------------------------

Bugzilla ID: 625

Fixes 761c4d66900f ("app/testpmd: fix max Rx packet length for VLAN packets")
Quoted 6 lines

Applied to dpdk-next-net/main, thanks.