diff mbox series

bmips: bcm6368-enetsw: Bump max MTU to 1536

Message ID 20231001203958.2995526-1-linus.walleij@linaro.org
State Superseded
Delegated to: Hauke Mehrtens
Headers show
Series bmips: bcm6368-enetsw: Bump max MTU to 1536 | expand

Commit Message

Linus Walleij Oct. 1, 2023, 8:39 p.m. UTC
The max MTU for this ethernet switch is 1536 bytes, not 1510 as it is
right now. The available overhead is needed when using the DSA switch with
a cascaded DSA switch, which is something that exist in real products,
in this case the Inteno XG6846.

Before this patch (on the lan1 DSA port in this case):
dsa_slave_change_mtu: master->max_mtu = 9724, dev->max_mtu = 10218, DSA overhead = 8
dsa_slave_change_mtu: master = extsw, dev = lan1
dsa_slave_change_mtu: master->max_mtu = 1510, dev->max_mtu = 9724, DSA overhead = 6
dsa_slave_change_mtu: master = eth0, dev = extsw
dsa_slave_change_mtu new_master_mtu 1514 > mtu_limit 1510
mdio_mux-0.1:00: nonfatal error -34 setting MTU to 1500 on port 0

After this patch the error is gone.

Cc: Álvaro Fernández Rojas <noltari@gmail.com>
Cc: Jonas Gorski <jonas.gorski@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 .../bmips/files/drivers/net/ethernet/broadcom/bcm6368-enetsw.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jonas Gorski Oct. 1, 2023, 8:55 p.m. UTC | #1
On Sun, 1 Oct 2023 at 22:40, Linus Walleij <linus.walleij@linaro.org> wrote:
>
> The max MTU for this ethernet switch is 1536 bytes, not 1510 as it is

The maximum *frame* size accepted is 1536 bytes, not MTU. A difference
of 14 bytes.

> right now. The available overhead is needed when using the DSA switch with
> a cascaded DSA switch, which is something that exist in real products,
> in this case the Inteno XG6846.
>
> Before this patch (on the lan1 DSA port in this case):
> dsa_slave_change_mtu: master->max_mtu = 9724, dev->max_mtu = 10218, DSA overhead = 8
> dsa_slave_change_mtu: master = extsw, dev = lan1
> dsa_slave_change_mtu: master->max_mtu = 1510, dev->max_mtu = 9724, DSA overhead = 6
> dsa_slave_change_mtu: master = eth0, dev = extsw
> dsa_slave_change_mtu new_master_mtu 1514 > mtu_limit 1510
> mdio_mux-0.1:00: nonfatal error -34 setting MTU to 1500 on port 0
>
> After this patch the error is gone.

Did you test this? As in verified that 1536 bytes long frames are
correctly received and sent?

> Cc: Álvaro Fernández Rojas <noltari@gmail.com>
> Cc: Jonas Gorski <jonas.gorski@gmail.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  .../bmips/files/drivers/net/ethernet/broadcom/bcm6368-enetsw.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6368-enetsw.c b/target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6368-enetsw.c
> index 321e95dbbb3d..96f4c303a433 100644
> --- a/target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6368-enetsw.c
> +++ b/target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6368-enetsw.c
> @@ -24,6 +24,7 @@
>
>  /* MTU */
>  #define ENETSW_TAG_SIZE                        (6 + VLAN_HLEN)
> +#define ENETSW_MAX_MTU                 1536

Again, not MTU. FRAME_LEN.

>  #define ENETSW_MTU_OVERHEAD            (VLAN_ETH_HLEN + VLAN_HLEN + \
>                                          ENETSW_TAG_SIZE)
>  #define ENETSW_FRAG_SIZE(x)            (SKB_DATA_ALIGN(NET_SKB_PAD + x + \
> @@ -1067,7 +1068,7 @@ static int bcm6368_enetsw_probe(struct platform_device *pdev)
>         ndev->netdev_ops = &bcm6368_enetsw_ops;
>         ndev->min_mtu = ETH_ZLEN;
>         ndev->mtu = ETH_DATA_LEN + ENETSW_TAG_SIZE;
> -       ndev->max_mtu = ETH_DATA_LEN + ENETSW_TAG_SIZE;
> +       ndev->max_mtu = ENETSW_MAX_MTU;

And here you would need to subtract the ETH_HLEN first, else you will
allow 14 bytes too much. Also not sure if the ENETSW_TAG_SIZE should
be still added here, as it is stripped on rx and added on tx on the
cpu port.

Best Regards,
Jonas
Linus Walleij Oct. 1, 2023, 10:36 p.m. UTC | #2
On Sun, Oct 1, 2023 at 10:55 PM Jonas Gorski <jonas.gorski@gmail.com> wrote:
> On Sun, 1 Oct 2023 at 22:40, Linus Walleij <linus.walleij@linaro.org> wrote:
> >
> > The max MTU for this ethernet switch is 1536 bytes, not 1510 as it is
>
> The maximum *frame* size accepted is 1536 bytes, not MTU. A difference
> of 14 bytes.

Darn. I sent a new version which is tested and hopefully better.
Let's take it from there (it may have more/other bugs...)

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6368-enetsw.c b/target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6368-enetsw.c
index 321e95dbbb3d..96f4c303a433 100644
--- a/target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6368-enetsw.c
+++ b/target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6368-enetsw.c
@@ -24,6 +24,7 @@ 
 
 /* MTU */
 #define ENETSW_TAG_SIZE			(6 + VLAN_HLEN)
+#define ENETSW_MAX_MTU			1536
 #define ENETSW_MTU_OVERHEAD		(VLAN_ETH_HLEN + VLAN_HLEN + \
 					 ENETSW_TAG_SIZE)
 #define ENETSW_FRAG_SIZE(x)		(SKB_DATA_ALIGN(NET_SKB_PAD + x + \
@@ -1067,7 +1068,7 @@  static int bcm6368_enetsw_probe(struct platform_device *pdev)
 	ndev->netdev_ops = &bcm6368_enetsw_ops;
 	ndev->min_mtu = ETH_ZLEN;
 	ndev->mtu = ETH_DATA_LEN + ENETSW_TAG_SIZE;
-	ndev->max_mtu = ETH_DATA_LEN + ENETSW_TAG_SIZE;
+	ndev->max_mtu = ENETSW_MAX_MTU;
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(6,1,0)
 	netif_napi_add(ndev, &priv->napi, bcm6368_enetsw_poll);
 #else