netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Corinna Vinschen <vinschen@redhat.com>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Jose Abreu <joabreu@synopsys.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH net-next] net: stmmac: publish actual MTU restriction
Date: Mon, 3 Apr 2023 09:30:11 -0700	[thread overview]
Message-ID: <20230403093011.27545760@kernel.org> (raw)
In-Reply-To: <ZCqYbMOEg9LvgcWZ@calimero.vinschen.de>

On Mon, 3 Apr 2023 11:12:12 +0200 Corinna Vinschen wrote:
> > Are any users depending on the advertised values being exactly right?  
> 
> The max MTU is advertised per interface:
> 
> p -d link show dev enp0s29f1
> 2: enp0s29f1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
>     link/ether [...] promiscuity 0 minmtu 46 maxmtu 9000 [...]
> 
> So the idea is surely that the user can check it and then set the MTU
> accordingly.  If the interface claims a max MTU of 9000, the expectation
> is that setting the MTU to this value just works, right?
> 
> So isn't it better if the interface only claims what it actually supports,
> i. .e, 
> 
>   # ip -d link show dev enp0s29f1
>   2: enp0s29f1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
>       link/ether [...] promiscuity 0 minmtu 46 maxmtu 4096 [...]
> 
> ?

No doubt that it's better to be more precise.

The question is what about drivers which can't support full MTU with
certain features enabled. So far nobody has been updating the max MTU
dynamically, to my knowledge, so the max MTU value is the static max
under best conditions.

> > > +	/* stmmac_change_mtu restricts MTU to queue size.
> > > +	 * Set maxmtu accordingly, if it hasn't been set from DT.
> > > +	 */
> > > +	if (priv->plat->maxmtu == 0) {
> > > +		priv->plat->maxmtu = priv->plat->tx_fifo_size ?:
> > > +				     priv->dma_cap.tx_fifo_size;
> > > +		priv->plat->maxmtu /= priv->plat->tx_queues_to_use;  
> > 
> > tx_queues_to_use may change due to reconfiguration, no?
> > What will happen then?  
> 
> Nothing.  tx_fifo_size is tx_queues_to_use multiplied by the size of the
> queue.  All the above code does is to compute the size of the queues,
> which is a fixed value limiting the size of the MTU.  It's the same
> check the stmmac_change_mtu() function performs to allow or deny the MTU
> change, basically:
> 
>   txfifosz = priv->plat->tx_fifo_size;
>   if (txfifosz == 0)
>     txfifosz = priv->dma_cap.tx_fifo_size;
>   txfifosz /= priv->plat->tx_queues_to_use;
>   if (txfifosz < new_mtu)
>     return -EINVAL;

I haven't looked at the code in detail but if we start with
tx_queues_to_use = 4 and lower it via ethtool -L, won't that
make the core prevent setting higher MTU even tho the driver
would have supported it previously?

  reply	other threads:[~2023-04-03 16:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-31  9:23 [PATCH net-next] net: stmmac: publish actual MTU restriction Corinna Vinschen
2023-04-01  4:52 ` Jakub Kicinski
2023-04-03  9:12   ` Corinna Vinschen
2023-04-03 16:30     ` Jakub Kicinski [this message]
2023-04-03 18:17       ` Corinna Vinschen
2023-04-03 18:26         ` Corinna Vinschen

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=20230403093011.27545760@kernel.org \
    --to=kuba@kernel.org \
    --cc=alexandre.torgue@foss.st.com \
    --cc=joabreu@synopsys.com \
    --cc=netdev@vger.kernel.org \
    --cc=peppe.cavallaro@st.com \
    --cc=vinschen@redhat.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;
as well as URLs for NNTP newsgroup(s).