app/testpmd: fix max Rx packet length for VLAN packets
authorSteve Yang <stevex.yang@intel.com>
Mon, 18 Jan 2021 07:04:08 +0000 (07:04 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 19 Jan 2021 02:30:14 +0000 (03:30 +0100)
When the max rx packet length is smaller than the sum of mtu size and
ether overhead size, it should be enlarged, otherwise the VLAN packets
will be dropped.

Removed the rx_offloads assignment for jumbo frame during command line
parsing, and set the correct jumbo frame flag if MTU size is larger than
the default value 'RTE_ETHER_MTU' within 'init_config()'.

Fixes: 384161e00627 ("app/testpmd: adjust on the fly VLAN configuration")
Fixes: 35b2d13fd6fd ("net: add rte prefix to ether defines")
Fixes: ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
Fixes: 150c9ac2df13 ("app/testpmd: update Rx offload after setting MTU")
Cc: stable@dpdk.org
Signed-off-by: Steve Yang <stevex.yang@intel.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
app/test-pmd/cmdline.c
app/test-pmd/config.c
app/test-pmd/parameters.c
app/test-pmd/testpmd.c

index 855dbc2dece1acc2e8e0761fe409c3296b641995..89034c8b72726e4b13de3d9b9eb3428b1f51635f 100644 (file)
@@ -1886,7 +1886,6 @@ cmd_config_max_pkt_len_parsed(void *parsed_result,
 
        RTE_ETH_FOREACH_DEV(pid) {
                struct rte_port *port = &ports[pid];
-               uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
 
                if (!strcmp(res->name, "max-pkt-len")) {
                        if (res->value < RTE_ETHER_MIN_LEN) {
@@ -1898,11 +1897,6 @@ cmd_config_max_pkt_len_parsed(void *parsed_result,
                                return;
 
                        port->dev_conf.rxmode.max_rx_pkt_len = res->value;
-                       if (res->value > RTE_ETHER_MAX_LEN)
-                               rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
-                       else
-                               rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
-                       port->dev_conf.rxmode.offloads = rx_offloads;
                } else {
                        printf("Unknown parameter\n");
                        return;
index a6a5baa4e122f503898c40d8790e6e472c4c73a0..0e2b9f7d3c3baaa60c8ff74fb762fc942231cdb7 100644 (file)
@@ -1434,7 +1434,7 @@ port_mtu_set(portid_t port_id, uint16_t mtu)
                 * device supports jumbo frame.
                 */
                eth_overhead = dev_info.max_rx_pktlen - dev_info.max_mtu;
-               if (mtu > RTE_ETHER_MAX_LEN - eth_overhead) {
+               if (mtu > RTE_ETHER_MTU) {
                        rte_port->dev_conf.rxmode.offloads |=
                                                DEV_RX_OFFLOAD_JUMBO_FRAME;
                        rte_port->dev_conf.rxmode.max_rx_pkt_len =
index 414a0068fbbf7a88c577fd964b2083d7e5ef810c..df5eb10d841fbd28b89fea7672b332f8d859f5eb 100644 (file)
@@ -834,12 +834,9 @@ launch_args_parse(int argc, char** argv)
                        }
                        if (!strcmp(lgopts[opt_idx].name, "max-pkt-len")) {
                                n = atoi(optarg);
-                               if (n >= RTE_ETHER_MIN_LEN) {
+                               if (n >= RTE_ETHER_MIN_LEN)
                                        rx_mode.max_rx_pkt_len = (uint32_t) n;
-                                       if (n > RTE_ETHER_MAX_LEN)
-                                               rx_offloads |=
-                                                       DEV_RX_OFFLOAD_JUMBO_FRAME;
-                               } else
+                               else
                                        rte_exit(EXIT_FAILURE,
                                                 "Invalid max-pkt-len=%d - should be > %d\n",
                                                 n, RTE_ETHER_MIN_LEN);
index 2b60f6c5d3b125fd0bb72d6c65a5c4bd9e30f887..c256e719aea28584e9df9c88916cab5e32b6389b 100644 (file)
@@ -1410,6 +1410,7 @@ 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;
@@ -1446,6 +1447,23 @@ 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;
+
                if (!(port->dev_info.tx_offload_capa &
                      DEV_TX_OFFLOAD_MBUF_FAST_FREE))
                        port->dev_conf.txmode.offloads &=