Netdev List
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: Woojung Huh <woojung.huh@microchip.com>,
	Andrew Lunn <andrew@lunn.ch>,
	Florian Fainelli <f.fainelli@gmail.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Vivien Didelot <vivien.didelot@gmail.com>,
	kernel@pengutronix.de, Jakub Kicinski <kuba@kernel.org>,
	UNGLinuxDriver@microchip.com,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH net-next v2 1/1] net: dsa: microchip: ksz9477: implement MTU configuration
Date: Thu, 24 Feb 2022 11:46:57 +0200	[thread overview]
Message-ID: <20220224094657.jzhvi67ryhuipor4@skbuf> (raw)
In-Reply-To: <20220224093827.GC4594@pengutronix.de>

On Thu, Feb 24, 2022 at 10:38:27AM +0100, Oleksij Rempel wrote:
> > > > > +	/* Now we can configure default MTU value */
> > > > > +	ret = regmap_update_bits(dev->regmap[1], REG_SW_MTU__2, REG_SW_MTU_MASK,
> > > > > +				 VLAN_ETH_FRAME_LEN + ETH_FCS_LEN);
> > > > 
> > > > Why do you need this? Doesn't DSA call dsa_slave_create() ->
> > > > dsa_slave_change_mtu(ETH_DATA_LEN) on probe?
> > > 
> > > This was my initial assumption as well, but cadence macb driver provides
> > > buggy max MTU == -18. I hardcoded bigger MTU for now[1], but was not able to
> > > find proper way to fix it. To avoid this kinds of regressions I decided
> > > to keep some sane default configuration.
> > > 
> > > [1] - my workaround.
> > > commit 5f8385e9641a383478a65f96ccee8fd992201f68
> > > Author: Oleksij Rempel <linux@rempel-privat.de>
> > > Date:   Mon Feb 14 14:41:06 2022 +0100
> > > 
> > >     WIP: net: macb: fix max mtu size
> > >     
> > >     The gem_readl(bp, JML) will return 0, so we get max_mtu size of -18,
> > >     this is breaking MTU configuration for DSA
> > >     
> > >     Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> > > 
> > > diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> > > index a363da928e8b..454d811991bb 100644
> > > --- a/drivers/net/ethernet/cadence/macb_main.c
> > > +++ b/drivers/net/ethernet/cadence/macb_main.c
> > > @@ -4727,7 +4727,7 @@ static int macb_probe(struct platform_device *pdev)
> > >  	/* MTU range: 68 - 1500 or 10240 */
> > >  	dev->min_mtu = GEM_MTU_MIN_SIZE;
> > >  	if (bp->caps & MACB_CAPS_JUMBO)
> > > -		dev->max_mtu = gem_readl(bp, JML) - ETH_HLEN - ETH_FCS_LEN;
> > > +		dev->max_mtu = 10240 - ETH_HLEN - ETH_FCS_LEN;
> > >  	else
> > >  		dev->max_mtu = ETH_DATA_LEN;
> > 
> > Yes, but the macb driver can be a DSA master for any switch, not just
> > for ksz9477. Better to fix this differently.
> 
> Yes, it should be fixed. I just need some time to understand the proper
> way to do so. For now, let's proceed with the ksz patch. Should I send
> new version with some changes?

So where is it failing exactly? Here I guess, because mtu_limit will be
negative?

	mtu_limit = min_t(int, master->max_mtu, dev->max_mtu);
	old_master_mtu = master->mtu;
	new_master_mtu = largest_mtu + dsa_tag_protocol_overhead(cpu_dp->tag_ops);
	if (new_master_mtu > mtu_limit)
		return -ERANGE;

I don't think we can work around it in DSA, it's garbage in, garbage out.

In principle, I don't have such a big issue with writing the MTU
register as part of the switch initialization, especially if it's global
and not per port. But tell me something else. You pre-program the MTU
with VLAN_ETH_FRAME_LEN + ETH_FCS_LEN, but in the MTU change procedure,
you also add KSZ9477_INGRESS_TAG_LEN (2) to that. Is that needed at all?
I expect that if it's needed, it's needed in both places. Can you
sustain an iperf3 tcp session over a VLAN upper of a ksz9477 port?
I suspect that the missing VLAN_HLEN is masking a lack of KSZ9477_INGRESS_TAG_LEN.

  reply	other threads:[~2022-02-24  9:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-23  8:40 [PATCH net-next v2 1/1] net: dsa: microchip: ksz9477: implement MTU configuration Oleksij Rempel
2022-02-23 23:38 ` Vladimir Oltean
2022-02-24  4:59   ` Oleksij Rempel
2022-02-24  9:33     ` Vladimir Oltean
2022-02-24  9:38       ` Oleksij Rempel
2022-02-24  9:46         ` Vladimir Oltean [this message]
2022-02-25 11:47           ` Oleksij Rempel
2022-02-25 11:58             ` Vladimir Oltean
2022-02-25 12:54               ` Oleksij Rempel
2022-02-25 16:35                 ` Vladimir Oltean
2022-03-08 10:06                   ` Oleksij Rempel
2022-03-08 11:21                     ` Vladimir Oltean
2022-03-08 11:59                       ` Oleksij Rempel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220224094657.jzhvi67ryhuipor4@skbuf \
    --to=olteanv@gmail.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=vivien.didelot@gmail.com \
    --cc=woojung.huh@microchip.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox