[dpdk-dev] [PATCH v6 2/2] librte_ethdev: fix MTU size exceeds max rx packet length

Ananyev, Konstantin konstantin.ananyev at intel.com
Thu Oct 22 18:52:09 CEST 2020


> 
> Update the MTU size according to the max rx packet and Ether overhead.
> 
> Fixes: 59d0ecdbf0e1 ("ethdev: MTU accessors")
> 
> Signed-off-by: SteveX Yang <stevex.yang at intel.com>
> ---
>  lib/librte_ethdev/rte_ethdev.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
> index b12bb3854..17f1c33ac 100644
> --- a/lib/librte_ethdev/rte_ethdev.c
> +++ b/lib/librte_ethdev/rte_ethdev.c
> @@ -1290,6 +1290,8 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
>  	struct rte_eth_dev *dev;
>  	struct rte_eth_dev_info dev_info;
>  	struct rte_eth_conf orig_conf;
> +	uint16_t overhead_len;
> +	uint16_t max_rx_pktlen;
>  	int diag;
>  	int ret;
> 
> @@ -1415,6 +1417,18 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
>  							RTE_ETHER_MAX_LEN;
>  	}
> 
> +	/*
> +	 * Update MTU value if MTU + OVERHEAD exceeds the max_rx_pkt_len
> +	 */
> +	max_rx_pktlen = dev->data->dev_conf.rxmode.max_rx_pkt_len;
> +	if (dev_info.max_rx_pktlen && dev_info.max_mtu)
> +		overhead_len = dev_info.max_rx_pktlen - dev_info.max_mtu;
> +	else
> +		overhead_len = RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
> +
> +	if (max_rx_pktlen < dev->data->mtu + overhead_len)

Do we need that if() here?
Might be do assignment unconditionally?

> +		dev->data->mtu = max_rx_pktlen - overhead_len;
> +
>  	/*
>  	 * If LRO is enabled, check that the maximum aggregated packet
>  	 * size is supported by the configured device.
> --
> 2.17.1



More information about the dev mailing list