> -----Original Message-----
> From: dev <dev-boun...@dpdk.org> On Behalf Of Ferruh Yigit
> Sent: Friday, November 6, 2020 2:10 AM
> To: Lu, Wenzhuo <wenzhuo...@intel.com>; Xing, Beilei
> <beilei.x...@intel.com>; Iremonger, Bernard <bernard.iremon...@intel.com>
> Cc: Yigit, Ferruh <ferruh.yi...@intel.com>; dev@dpdk.org; Yang, SteveX
> <stevex.y...@intel.com>; Thomas Monjalon <tho...@monjalon.net>;
> Andrew Rybchenko <andrew.rybche...@oktetlabs.ru>; Ananyev, Konstantin
> <konstantin.anan...@intel.com>; Olivier Matz <olivier.m...@6wind.com>;
> Lance Richardson <lance.richard...@broadcom.com>
> Subject: [dpdk-dev] [RFC] app/testpmd: fix MTU after device configure
> 
> In 'rte_eth_dev_configure()', if 'DEV_RX_OFFLOAD_JUMBO_FRAME' is not set
> the max frame size is limited to 'RTE_ETHER_MAX_LEN' (1518).
> This is mistake because for the PMDs that has frame size bigger than
> "RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN" (18 bytes), the MTU becomes
> less than 1500, causing a valid frame with 1500 bytes payload to be dropped.
> 
> Since 'rte_eth_dev_set_mtu()' works as expected, it is called after
> 'rte_eth_dev_configure()' to fix the MTU.
> It may look redundant to set MTU after 'rte_eth_dev_configure()', both with
> default values, but it is not, the resulting MTU config can be different in 
> the
> device based on frame overhead of the PMD.
> 
> And instead of setting the MTU to default value, it is first get via
> 'rte_eth_dev_get_mtu()' and set again, this is to cover cases MTU changed
> from testpmd command line.
> 
> 'rte_eth_dev_set_mtu()', '-ENOTSUP' error is ignored to prevent irrelevant
> warning messages for the virtual PMDs.
> 
> Signed-off-by: Ferruh Yigit <ferruh.yi...@intel.com>

Reviewed-by: Qi Zhang <qi.z.zh...@intel.com>

> ---
> Cc: Steve Yang <stevex.y...@intel.com>
> Cc: Thomas Monjalon <tho...@monjalon.net>
> Cc: Andrew Rybchenko <andrew.rybche...@oktetlabs.ru>
> Cc: Konstantin Ananyev <konstantin.anan...@intel.com>
> Cc: Olivier Matz <olivier.m...@6wind.com>
> Cc: Lance Richardson <lance.richard...@broadcom.com>
> ---
>  app/test-pmd/testpmd.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
> 33fc0fddf5..48e9647fc7 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -2537,6 +2537,8 @@ start_port(portid_t pid)
>               }
> 
>               if (port->need_reconfig > 0) {
> +                     uint16_t mtu = RTE_ETHER_MTU;
> +
>                       port->need_reconfig = 0;
> 
>                       if (flow_isolate_all) {
> @@ -2570,6 +2572,23 @@ start_port(portid_t pid)
>                               port->need_reconfig = 1;
>                               return -1;
>                       }
> +
> +                     /*
> +                      * Workaround for rte_eth_dev_configure(), 
> max_rx_pkt_len
> +                      * set MTU wrong for the PMDs that have frame overhead
> +                      * bigger than RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN.
> +                      * For a PMD that has 26 bytes overhead,
> rte_eth_dev_configure()
> +                      * can set MTU to max 1492, not to expected 1500 bytes.
> +                      * Using rte_eth_dev_set_mtu() to be able to set MTU
> correctly,
> +                      * default MTU value is 1500.
> +                      */
> +                     diag = rte_eth_dev_get_mtu(pi, &mtu);
> +                     if (diag)
> +                             printf("Failed to get MTU for port %d\n", pi);
> +                     diag = rte_eth_dev_set_mtu(pi, mtu);
> +                     if (diag != 0 && diag != -ENOTSUP)
> +                             printf("Failed to set MTU to %u for port %d\n",
> +                                             mtu, pi);
>               }
>               if (port->need_reconfig_queues > 0) {
>                       port->need_reconfig_queues = 0;
> --
> 2.26.2

Reply via email to