Subject: Re: set mtu size broken for dwmac-sun8i

From: Corentin Labbe <[email-masked]>
Date: Wed, 17 Mar 2021 17:01:56 +0100

Le Wed, Mar 17, 2021 at 12:37:48PM +0100, Belisko Marek a écrit :
> On Wed, Mar 17, 2021 at 12:33 PM Corentin Labbe
> <[email-masked]> wrote:
> >
> > Le Wed, Mar 17, 2021 at 10:19:26AM +0100, Belisko Marek a écrit :
> > > Hi,
> > >
> > > I'm hunting an issue when setting mtu failed for dwmac-sun8i driver.
> > > Basically adding more debug shows that in stmmac_change_mtu
> > > tx_fifo_size is 0 and in this case EINVAL is reported. Isaw there was
> > > fix for similar driver dwmac-sunxi driver by:
> > > 806fd188ce2a4f8b587e83e73c478e6484fbfa55
> > >
> > > IIRC dwmac-sun8i should get tx and rx fifo size from dma but seems
> > > it's not the case. I'm using 5.4 kernel LTS release. Any ideas?
> > >
> > > Thanks and BR,
> > >
> > > marek
> > >
> >
> > Hello
> >
> > Could you provide exact command line you tried to change mtu ?
> > Along with all MTU values you tried.
> I tried with ifconfig eth0 down && ifconfig eth0 mtu 1400 return:
> ifconfig: SIOCSIFMTU: Invalid argument
> 
> btw board is orange-pi-pc-plus
> >
> > Thanks
> > Regards
> 

I have added as CC sunxi maintainers

I can confirm that dwmac-sun8i need the same fix as 806fd188ce2a4f8b587e83e73c478e6484fbfa55.
With the patch below, I successfully changed MTU ... and the network is still working.
My first test was on orange-pi-pc which is the same SoC than your board.
I test this patch on all other sunxi SoCs and I send it upstream after.

@netdev, does there is some specific MTU values interesting to test ? (I curently try 68 500 1000 1200 1400 1500 1600 9000)

Regards

Author: Corentin Labbe <[email-masked]>
Date:   Wed Mar 17 16:49:50 2021 +0100

    net: stmmac: dwmac-sun8i: Provide TX and RX fifo sizes
    
    MTU cannot be changed on dwmac-sun8i.
    This is due to tx_fifo_size being 0.
    Like dwmac-sunxi (with 806fd188ce2a ("net: stmmac: dwmac-sunxi: Provide TX and RX fifo sizes"))
    dwmac-sun8i need to have tx and rx fifo sizes set.
    
    Fixes: 9f93ac8d408 ("net-next: stmmac: Add dwmac-sun8i")
    Reported-by: Belisko Marek <[email-masked]>
    Signed-off-by: Corentin Labbe <[email-masked]>

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 6b75cf2603ff..e62efd166ec8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -1214,6 +1214,8 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
        plat_dat->init = sun8i_dwmac_init;
        plat_dat->exit = sun8i_dwmac_exit;
        plat_dat->setup = sun8i_dwmac_setup;
+       plat_dat->tx_fifo_size = 4096;
+       plat_dat->rx_fifo_size = 16384;
 
        ret = sun8i_dwmac_set_syscon(&pdev->dev, plat_dat);
        if (ret)