From fa3dfeff95a5bafcf13accaed5164bfc4e028d9a Mon Sep 17 00:00:00 2001 From: "Bjoern A. Zeeb" Date: Fri, 11 Oct 2024 18:51:32 +0000 Subject: [PATCH] dpaa2: fix MRU for dpni (and software vlans along) 0480dccd3f34 tried to fix the MTU for software VLANs given dpni announces IFCAP_VLAN_MTU. Unfortunately the initial MRU during setup is reduced from the maximum supported by the HW to our maximum ethernet RX frame length so only after further mtu toggles the solution there would work. Set the maximum RX frame size (without CRC) to jumbo length + vlan encap len by default given we also announce IFCAP_JUMBO_MTU. While here improve the manual (ioctl) MTU setting by checking if IFCAP_VLAN_MTU is currently enabled and only then add the extra bytes. Fixes: 0480dccd3f347da0dbccf5917633435d5ce6cb86 MFC after: 3 days Reviewed by: dsl Differential Revision: https://reviews.freebsd.org/D47066 --- sys/dev/dpaa2/dpaa2_ni.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sys/dev/dpaa2/dpaa2_ni.c b/sys/dev/dpaa2/dpaa2_ni.c index 6ed656849709..622e63626bfe 100644 --- a/sys/dev/dpaa2/dpaa2_ni.c +++ b/sys/dev/dpaa2/dpaa2_ni.c @@ -138,8 +138,9 @@ MALLOC_DEFINE(M_DPAA2_TXB, "dpaa2_txb", "DPAA2 DMA-mapped buffer (Tx)"); #define DPNI_IRQ_LINK_CHANGED 1 /* Link state changed */ #define DPNI_IRQ_EP_CHANGED 2 /* DPAA2 endpoint dis/connected */ -/* Default maximum frame length. */ -#define DPAA2_ETH_MFL (ETHER_MAX_LEN - ETHER_CRC_LEN) +/* Default maximum RX frame length w/o CRC. */ +#define DPAA2_ETH_MFL (ETHER_MAX_LEN_JUMBO + ETHER_VLAN_ENCAP_LEN - \ + ETHER_CRC_LEN) /* Minimally supported version of the DPNI API. */ #define DPNI_VER_MAJOR 7 @@ -2561,8 +2562,10 @@ dpaa2_ni_ioctl(if_t ifp, u_long c, caddr_t data) DPNI_UNLOCK(sc); /* Update maximum frame length. */ - error = DPAA2_CMD_NI_SET_MFL(dev, child, &cmd, - mtu + ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); + mtu += ETHER_HDR_LEN; + if (if_getcapenable(ifp) & IFCAP_VLAN_MTU) + mtu += ETHER_VLAN_ENCAP_LEN; + error = DPAA2_CMD_NI_SET_MFL(dev, child, &cmd, mtu); if (error) { device_printf(dev, "%s: failed to update maximum frame " "length: error=%d\n", __func__, error);