Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [RFC PATCH v1 net-next 1/1] net: ethernet: ti: cpsw: allow MTU > 1500 when overridden by module parameter
@ 2021-07-21 21:05 Colin Foster
  2021-07-22 14:05 ` Andrew Lunn
  0 siblings, 1 reply; 4+ messages in thread
From: Colin Foster @ 2021-07-21 21:05 UTC (permalink / raw)
  To: Grygorii Strashko, David S. Miller, Jakub Kicinski
  Cc: linux-omap, netdev, linux-kernel

The module parameter rx_packet_max can be overridden at module load or
boot args. But it doesn't adjust the max_mtu for the device accordingly.

If a CPSW device is to be used in a DSA architecture, increasing the
MTU by small amounts to account for switch overhead becomes necessary.
This way, a boot arg of cpsw.rx_packet_max=1600 should allow the MTU
to be increased to values of 1520, which is necessary for DSA tagging
protocols like "ocelot" and "seville".

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
---
 drivers/net/ethernet/ti/cpsw.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index c0cd7de88316..d400163c4ef2 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -1625,6 +1625,14 @@ static int cpsw_probe(struct platform_device *pdev)
 		goto clean_cpts;
 	}
 
+	/* adjust max_mtu to match module parameter rx_packet_max */
+	if (cpsw->rx_packet_max > CPSW_MAX_PACKET_SIZE) {
+		ndev->max_mtu = ETH_DATA_LEN + (cpsw->rx_packet_max -
+				CPSW_MAX_PACKET_SIZE);
+		dev_info(dev, "overriding default MTU to %d\n\n",
+			 ndev->max_mtu);
+	}
+
 	priv = netdev_priv(ndev);
 	priv->cpsw = cpsw;
 	priv->ndev = ndev;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH v1 net-next 1/1] net: ethernet: ti: cpsw: allow MTU > 1500 when overridden by module parameter
  2021-07-21 21:05 [RFC PATCH v1 net-next 1/1] net: ethernet: ti: cpsw: allow MTU > 1500 when overridden by module parameter Colin Foster
@ 2021-07-22 14:05 ` Andrew Lunn
  2021-07-22 15:33   ` Colin Foster
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2021-07-22 14:05 UTC (permalink / raw)
  To: Colin Foster
  Cc: Grygorii Strashko, David S. Miller, Jakub Kicinski, linux-omap,
	netdev, linux-kernel

On Wed, Jul 21, 2021 at 02:05:38PM -0700, Colin Foster wrote:
> The module parameter rx_packet_max can be overridden at module load or
> boot args. But it doesn't adjust the max_mtu for the device accordingly.
> 
> If a CPSW device is to be used in a DSA architecture, increasing the
> MTU by small amounts to account for switch overhead becomes necessary.
> This way, a boot arg of cpsw.rx_packet_max=1600 should allow the MTU
> to be increased to values of 1520, which is necessary for DSA tagging
> protocols like "ocelot" and "seville".

Hi Colin

As far as your patch goes, it makes sense.

However, module parameters are unlikely by netdev maintainers. Having
to set one in order to make DSA work is not nice. What is involved in
actually removing the module parameter and making the MTU change work
without it?

> Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
> ---
>  drivers/net/ethernet/ti/cpsw.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
> index c0cd7de88316..d400163c4ef2 100644
> --- a/drivers/net/ethernet/ti/cpsw.c
> +++ b/drivers/net/ethernet/ti/cpsw.c
> @@ -1625,6 +1625,14 @@ static int cpsw_probe(struct platform_device *pdev)
>  		goto clean_cpts;
>  	}
>  
> +	/* adjust max_mtu to match module parameter rx_packet_max */
> +	if (cpsw->rx_packet_max > CPSW_MAX_PACKET_SIZE) {
> +		ndev->max_mtu = ETH_DATA_LEN + (cpsw->rx_packet_max -
> +				CPSW_MAX_PACKET_SIZE);
> +		dev_info(dev, "overriding default MTU to %d\n\n",
> +			 ndev->max_mtu);

There is no need for dev_info(). You could consider dev_dbg(), or just
remove it.

       Andrew

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH v1 net-next 1/1] net: ethernet: ti: cpsw: allow MTU > 1500 when overridden by module parameter
  2021-07-22 14:05 ` Andrew Lunn
@ 2021-07-22 15:33   ` Colin Foster
  2021-07-22 16:50     ` Andrew Lunn
  0 siblings, 1 reply; 4+ messages in thread
From: Colin Foster @ 2021-07-22 15:33 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Grygorii Strashko, David S. Miller, Jakub Kicinski, linux-omap,
	netdev, linux-kernel

On Thu, Jul 22, 2021 at 04:05:33PM +0200, Andrew Lunn wrote:
> On Wed, Jul 21, 2021 at 02:05:38PM -0700, Colin Foster wrote:
> > The module parameter rx_packet_max can be overridden at module load or
> > boot args. But it doesn't adjust the max_mtu for the device accordingly.
> > 
> > If a CPSW device is to be used in a DSA architecture, increasing the
> > MTU by small amounts to account for switch overhead becomes necessary.
> > This way, a boot arg of cpsw.rx_packet_max=1600 should allow the MTU
> > to be increased to values of 1520, which is necessary for DSA tagging
> > protocols like "ocelot" and "seville".
> 
> Hi Colin
> 
> As far as your patch goes, it makes sense.
> 
> However, module parameters are unlikely by netdev maintainers. Having
> to set one in order to make DSA work is not nice. What is involved in
> actually removing the module parameter and making the MTU change work
> without it?

Thanks for the feedback Andrew.

That's a good idea. I used the module parameter because it was already 
there.

My intent was to not change any existing default behavior. The below 
forum post makes me think that simply changing the default value of 
rx_packet_max from 1500 to 1998 alongside this patch is all that is 
needed. It all seems too easy, so either my use-case is rare enough 
that nobody considered it, or there's some limitation I'm missing.

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/461724/how-to-send-receive-jumbo-packet-by-am335x-emac

> 
> > Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
> > ---
> >  drivers/net/ethernet/ti/cpsw.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> > 
> > diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
> > index c0cd7de88316..d400163c4ef2 100644
> > --- a/drivers/net/ethernet/ti/cpsw.c
> > +++ b/drivers/net/ethernet/ti/cpsw.c
> > @@ -1625,6 +1625,14 @@ static int cpsw_probe(struct platform_device *pdev)
> >  		goto clean_cpts;
> >  	}
> >  
> > +	/* adjust max_mtu to match module parameter rx_packet_max */
> > +	if (cpsw->rx_packet_max > CPSW_MAX_PACKET_SIZE) {
> > +		ndev->max_mtu = ETH_DATA_LEN + (cpsw->rx_packet_max -
> > +				CPSW_MAX_PACKET_SIZE);
> > +		dev_info(dev, "overriding default MTU to %d\n\n",
> > +			 ndev->max_mtu);
> 
> There is no need for dev_info(). You could consider dev_dbg(), or just
> remove it.

Understood.

> 
>        Andrew

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH v1 net-next 1/1] net: ethernet: ti: cpsw: allow MTU > 1500 when overridden by module parameter
  2021-07-22 15:33   ` Colin Foster
@ 2021-07-22 16:50     ` Andrew Lunn
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2021-07-22 16:50 UTC (permalink / raw)
  To: Colin Foster
  Cc: Grygorii Strashko, David S. Miller, Jakub Kicinski, linux-omap,
	netdev, linux-kernel

On Thu, Jul 22, 2021 at 08:33:51AM -0700, Colin Foster wrote:
> On Thu, Jul 22, 2021 at 04:05:33PM +0200, Andrew Lunn wrote:
> > On Wed, Jul 21, 2021 at 02:05:38PM -0700, Colin Foster wrote:
> > > The module parameter rx_packet_max can be overridden at module load or
> > > boot args. But it doesn't adjust the max_mtu for the device accordingly.
> > > 
> > > If a CPSW device is to be used in a DSA architecture, increasing the
> > > MTU by small amounts to account for switch overhead becomes necessary.
> > > This way, a boot arg of cpsw.rx_packet_max=1600 should allow the MTU
> > > to be increased to values of 1520, which is necessary for DSA tagging
> > > protocols like "ocelot" and "seville".
> > 
> > Hi Colin
> > 
> > As far as your patch goes, it makes sense.
> > 
> > However, module parameters are unlikely by netdev maintainers. Having
> > to set one in order to make DSA work is not nice. What is involved in
> > actually removing the module parameter and making the MTU change work
> > without it?
> 
> Thanks for the feedback Andrew.
> 
> That's a good idea. I used the module parameter because it was already 
> there.

Yes, i understand the rational for what you did. KISS. But this is
also a chance to improve the code.

> My intent was to not change any existing default behavior. The below 
> forum post makes me think that simply changing the default value of 
> rx_packet_max from 1500 to 1998 alongside this patch is all that is 
> needed. It all seems too easy, so either my use-case is rare enough 
> that nobody considered it, or there's some limitation I'm missing.

Probably nobody has done it before. The internal switch for the cpsw
is probably enough for most users, and it is happy with the default
MTU. And anybody using jumbo seems to be happy to hack the driver and
not post the fix upstream?

I've not looked at what is actually required to make this dynamic.
Maybe you need to destroy all the descriptors and buffers and
re-create them?

[Goes an looks at the code]

On the RX side, it is using a page pool, order 0. So it looks like it
already supports MTU of 4K - overheads. And changing the default max
MTU costs nothing. And on the TX side, i don't see any restrictions.

I guess when the page pool was added, nobody considered what affect
this has on the module parameter, and the MTU. It looks like 99% of
the work is done to allow bigger MTU at no cost. But the devil is in
the details.

   Andrew

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-22 16:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-21 21:05 [RFC PATCH v1 net-next 1/1] net: ethernet: ti: cpsw: allow MTU > 1500 when overridden by module parameter Colin Foster
2021-07-22 14:05 ` Andrew Lunn
2021-07-22 15:33   ` Colin Foster
2021-07-22 16:50     ` Andrew Lunn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).