[v2] ethdev: account for smaller MTU when setting default

Message ID 20231108060535.1249507-1-joshwash@google.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [v2] ethdev: account for smaller MTU when setting default |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS

Commit Message

Joshua Washington Nov. 8, 2023, 6:05 a.m. UTC
  Currently, if not specified in the user configuration,
rte_eth_dev_configure() sets the MTU of the device to RTE_EHTER_MTU.
This value could potentially be larger than the MTU that the device
supports. This change updates the configured MTU to be the minimum of
the maximum suported MTU and the default DPDK MTU.

Fixes: 1bb4a528c4 ("ethdev: fix max Rx packet length")
Signed-off-by: Joshua Washington <joshwash@google.com>
Signed-off-by: Rushil Gupta <rushilg@google.com>
---
 lib/ethdev/rte_ethdev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Comments

Andrew Rybchenko Nov. 8, 2023, 3:07 p.m. UTC | #1
On 11/8/23 09:05, Joshua Washington wrote:
> Currently, if not specified in the user configuration,
> rte_eth_dev_configure() sets the MTU of the device to RTE_EHTER_MTU.
> This value could potentially be larger than the MTU that the device
> supports. This change updates the configured MTU to be the minimum of
> the maximum suported MTU and the default DPDK MTU.
> 
> Fixes: 1bb4a528c4 ("ethdev: fix max Rx packet length")
> Signed-off-by: Joshua Washington <joshwash@google.com>
> Signed-off-by: Rushil Gupta <rushilg@google.com>

Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
  
Ajit Khaparde Nov. 8, 2023, 5:05 p.m. UTC | #2
On Wed, Nov 8, 2023 at 7:07 AM Andrew Rybchenko
<andrew.rybchenko@oktetlabs.ru> wrote:
>
> On 11/8/23 09:05, Joshua Washington wrote:
> > Currently, if not specified in the user configuration,
> > rte_eth_dev_configure() sets the MTU of the device to RTE_EHTER_MTU.
> > This value could potentially be larger than the MTU that the device
> > supports. This change updates the configured MTU to be the minimum of
> > the maximum suported MTU and the default DPDK MTU.
> >
> > Fixes: 1bb4a528c4 ("ethdev: fix max Rx packet length")
> > Signed-off-by: Joshua Washington <joshwash@google.com>
> > Signed-off-by: Rushil Gupta <rushilg@google.com>
>
> Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>

>
>
  
Ferruh Yigit Nov. 8, 2023, 5:23 p.m. UTC | #3
On 11/8/2023 5:05 PM, Ajit Khaparde wrote:
> On Wed, Nov 8, 2023 at 7:07 AM Andrew Rybchenko
> <andrew.rybchenko@oktetlabs.ru> wrote:
>>
>> On 11/8/23 09:05, Joshua Washington wrote:
>>> Currently, if not specified in the user configuration,
>>> rte_eth_dev_configure() sets the MTU of the device to RTE_EHTER_MTU.
>>> This value could potentially be larger than the MTU that the device
>>> supports. This change updates the configured MTU to be the minimum of
>>> the maximum suported MTU and the default DPDK MTU.
>>>
>>> Fixes: 1bb4a528c4 ("ethdev: fix max Rx packet length")
>>> Signed-off-by: Joshua Washington <joshwash@google.com>
>>> Signed-off-by: Rushil Gupta <rushilg@google.com>
>>
>> Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
>
> Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
> 

Applied to dpdk-next-net/main, thanks.
  

Patch

diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 9163ef47ea..3858983fcc 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -1419,7 +1419,9 @@  rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	}
 
 	if (dev_conf->rxmode.mtu == 0)
-		dev->data->dev_conf.rxmode.mtu = RTE_ETHER_MTU;
+		dev->data->dev_conf.rxmode.mtu =
+			(dev_info.max_mtu == 0) ? RTE_ETHER_MTU :
+			RTE_MIN(dev_info.max_mtu, RTE_ETHER_MTU);
 
 	ret = eth_dev_validate_mtu(port_id, &dev_info,
 			dev->data->dev_conf.rxmode.mtu);