Subject: Re: Regression in mvneta with XDP patches

From: Lorenzo Bianconi <[email-masked]>
Date: Mon, 11 Nov 2019 17:14:36 +0200

On Nov 11, Andrew Lunn wrote:
> On Mon, Nov 11, 2019 at 04:33:52PM +0200, Ilias Apalodimas wrote:
> > Hi Andrew,
> > 
> > On Mon, Nov 11, 2019 at 02:46:15PM +0100, Andrew Lunn wrote:
> > > Hi Lorenzo, Jesper, Ilias
> > > 
> > > I just found that the XDP patches to mvneta have caused a regression.
> > > 
> > > This one breaks networking:
> > 
> > Thaks for the report.
> > Looking at the DTS i can see 'buffer-manager' in it. The changes we made were
> > for the driver path software buffer manager. 
> > Can you confirm which one your hardware uses?
> 
> Hi Ilias
> 
> Ah, interesting.
> 
> # CONFIG_MVNETA_BM_ENABLE is not set
> 
> So in fact it is not being compiled in, so should be falling back to
> software buffer manager.
> 
> If i do enable it, then it works. So we are in a corner cases you
> probably never tested. Requested by DT, but not actually available.
> 
> 	 Andrew

Maybe I got the issue. If mvneta_bm_port_init fails (e.g. if
CONFIG_MVNETA_BM_ENABLE is not set) rx_offset_correction will be set to a wrong
value. To bisect the issue, could you please test the following patch?

Regards,
Lorenzo

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 591d580c68b4..e476fb043379 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -4944,7 +4944,6 @@ static int mvneta_probe(struct platform_device *pdev)
 	SET_NETDEV_DEV(dev, &pdev->dev);
 
 	pp->id = global_port_id++;
-	pp->rx_offset_correction = MVNETA_SKB_HEADROOM;
 
 	/* Obtain access to BM resources if enabled and already initialized */
 	bm_node = of_parse_phandle(dn, "buffer-manager", 0);
@@ -4969,6 +4968,9 @@ static int mvneta_probe(struct platform_device *pdev)
 	}
 	of_node_put(bm_node);
 
+	if (!pp->bm_priv)
+		pp->rx_offset_correction = MVNETA_SKB_HEADROOM;
+
 	err = mvneta_init(&pdev->dev, pp);
 	if (err < 0)
 		goto err_netdev;