[dpdk-dev] [PATCH v6 2/2] librte_ethdev: fix MTU size exceeds max rx packet length
Ferruh Yigit
ferruh.yigit at intel.com
Thu Oct 22 18:31:03 CEST 2020
On 10/22/2020 9:48 AM, SteveX Yang wrote:
> If max rx packet length is smaller then MTU + Ether overhead, that will
> drop all MTU size packets.
>
> 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
> + */
I am not sure this conditional update is required, the target is keep
'max_rx_pktlen' & 'mtu' in sync.
So why not just:
dev->data->mtu = max_rx_pktlen - overhead_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)
> + 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.
>
More information about the dev
mailing list