[v4,2/2] app/testpmd: fix max-pkt-len option invalid
Checks
Commit Message
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")
Signed-off-by: Steve Yang <stevex.yang@intel.com>
---
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(-)
Comments
On 1/25/2021 8:32 AM, Steve Yang wrote:
> 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")
>
> Signed-off-by: Steve Yang <stevex.yang@intel.com>
> ---
> 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(-)
>
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
> index 89034c8b72..8b6b7b6206 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c
> @@ -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();
> diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
> index df5eb10d84..1c63156ddd 100644
> --- a/app/test-pmd/parameters.c
> +++ b/app/test-pmd/parameters.c
> @@ -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;
> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
> index c256e719ae..f22d2be46d 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -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 */
> + 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.
> + /*
> + * 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?
> + rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
> + } else
> + rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
> +
> + /* Apply Rx offloads configuration to Rx queue(s) */
> + 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.
> + }
> +}
> +
> void
> init_port_config(void)
> {
> diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
> index 5f23162107..16f6fbefef 100644
> --- a/app/test-pmd/testpmd.h
> +++ b/app/test-pmd/testpmd.h
> @@ -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
>
On Mon, Jan 25, 2021 at 3:35 AM Steve Yang <stevex.yang@intel.com> wrote:
>
> 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")
>
> Signed-off-by: Steve Yang <stevex.yang@intel.com>
> ---
> 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(-)
>
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
> index 89034c8b72..8b6b7b6206 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c
> @@ -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?
> }
>
> init_port_config();
On 1/25/2021 3:46 PM, Lance Richardson wrote:
> On Mon, Jan 25, 2021 at 3:35 AM Steve Yang <stevex.yang@intel.com> wrote:
>>
>> 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")
>>
>> Signed-off-by: Steve Yang <stevex.yang@intel.com>
>> ---
>> 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(-)
>>
>> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
>> index 89034c8b72..8b6b7b6206 100644
>> --- a/app/test-pmd/cmdline.c
>> +++ b/app/test-pmd/cmdline.c
>> @@ -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.
@@ -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();
@@ -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;
@@ -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 */
+ 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) {
+ /*
+ * 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;
+ rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
+ } else
+ rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+
+ /* Apply Rx offloads configuration to Rx queue(s) */
+ 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;
+ }
+}
+
void
init_port_config(void)
{
@@ -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