From: Wei Hu (Xavier) Date: Thu, 13 Feb 2020 01:57:43 +0000 (+0800) Subject: app/testpmd: update Rx offload after setting MTU X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=150c9ac2df13;p=dpdk.git app/testpmd: update Rx offload after setting MTU Currently, Rx offload capabilities and max_rx_pkt_len in the struct variable named rte_port are not updated after setting mtu successfully in port_mtu_set function by 'port config mtu ' command. This may lead to reconfig mtu to the initial value in the driver when recalling rte_eth_dev_configure API interface. This patch updates Rx offload capabilities and max_rx_pkt_len after setting mtu successfully when configuring mtu. Fixes: ae03d0d18adf ("app/testpmd: command to configure MTU") Cc: stable@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Wei Hu (Xavier) Reviewed-by: Ferruh Yigit --- diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index f9c55a2260..9d95202233 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1215,7 +1215,9 @@ void port_mtu_set(portid_t port_id, uint16_t mtu) { int diag; + struct rte_port *rte_port = &ports[port_id]; struct rte_eth_dev_info dev_info; + uint16_t eth_overhead; int ret; if (port_id_is_invalid(port_id, ENABLED_WARN)) @@ -1231,8 +1233,25 @@ port_mtu_set(portid_t port_id, uint16_t mtu) return; } diag = rte_eth_dev_set_mtu(port_id, mtu); - if (diag == 0) + if (diag == 0 && + dev_info.rx_offload_capa & DEV_RX_OFFLOAD_JUMBO_FRAME) { + /* + * Ether overhead in driver is equal to the difference of + * max_rx_pktlen and max_mtu in rte_eth_dev_info when the + * device supports jumbo frame. + */ + eth_overhead = dev_info.max_rx_pktlen - dev_info.max_mtu; + if (mtu > RTE_ETHER_MAX_LEN - eth_overhead) { + rte_port->dev_conf.rxmode.offloads |= + DEV_RX_OFFLOAD_JUMBO_FRAME; + rte_port->dev_conf.rxmode.max_rx_pkt_len = + mtu + eth_overhead; + } else + rte_port->dev_conf.rxmode.offloads &= + ~DEV_RX_OFFLOAD_JUMBO_FRAME; + return; + } printf("Set MTU failed. diag=%d\n", diag); }