netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Vladimir Oltean <olteanv@gmail.com>
Cc: f.fainelli@gmail.com, vivien.didelot@gmail.com,
	davem@davemloft.net, jakub.kicinski@netronome.com,
	murali.policharla@broadcom.com, stephen@networkplumber.org,
	jiri@resnulli.us, idosch@idosch.org, kuba@kernel.org,
	nikolay@cumulusnetworks.com, netdev@vger.kernel.org
Subject: Re: [PATCH v3 net-next 3/8] net: dsa: configure the MTU for switch ports
Date: Fri, 27 Mar 2020 01:06:25 +0100	[thread overview]
Message-ID: <20200327000625.GJ3819@lunn.ch> (raw)
In-Reply-To: <20200326224040.32014-4-olteanv@gmail.com>

> -static void dsa_master_set_mtu(struct net_device *dev, struct dsa_port *cpu_dp)
> -{
> -	unsigned int mtu = ETH_DATA_LEN + cpu_dp->tag_ops->overhead;
> -	int err;
> -
> -	rtnl_lock();
> -	if (mtu <= dev->max_mtu) {
> -		err = dev_set_mtu(dev, mtu);
> -		if (err)
> -			netdev_dbg(dev, "Unable to set MTU to include for DSA overheads\n");
> -	}
> -	rtnl_unlock();
> -}
> -
>  static void dsa_master_reset_mtu(struct net_device *dev)
>  {
>  	int err;
> @@ -344,7 +330,14 @@ int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp)
>  {
>  	int ret;
>  
> -	dsa_master_set_mtu(dev,  cpu_dp);
> +	rtnl_lock();
> +	ret = dev_set_mtu(dev, ETH_DATA_LEN + cpu_dp->tag_ops->overhead);
> +	rtnl_unlock();
> +	if (ret) {
> +		netdev_err(dev, "error %d setting MTU to include DSA overhead\n",
> +			   ret);
> +		return ret;
> +	}

I suspect this will break devices. dsa_master_set_mtu() was not fatal
if it failed. I did this deliberately because i suspect there are some
MAC drivers which are unhappy to have the MTU changed, but will still
send and receive frames which are bigger than the MTU. 

So please keep setting the MTU of ETH_DATA_LEN +
cpu_dp->tag_ops->overhead or less as non-fatal. Jumbo frame sizes you
should however check the return code.

> @@ -1465,7 +1556,10 @@ int dsa_slave_create(struct dsa_port *port)
>  	slave_dev->priv_flags |= IFF_NO_QUEUE;
>  	slave_dev->netdev_ops = &dsa_slave_netdev_ops;
>  	slave_dev->min_mtu = 0;
> -	slave_dev->max_mtu = ETH_MAX_MTU;
> +	if (ds->ops->port_max_mtu)
> +		slave_dev->max_mtu = ds->ops->port_max_mtu(ds, port->index);
> +	else
> +		slave_dev->max_mtu = ETH_MAX_MTU;

Does this bring you anything. You have a lot more checks you perform
when performing the actual change. Seems better to keep them all
together.

	Andrew

  reply	other threads:[~2020-03-27  0:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-26 22:40 [PATCH v3 net-next 0/8] Configure the MTU on DSA switches Vladimir Oltean
2020-03-26 22:40 ` [PATCH v3 net-next 1/8] net: phy: bcm7xx: add jumbo frame configuration to PHY Vladimir Oltean
2020-03-26 23:17   ` Florian Fainelli
2020-03-26 22:40 ` [PATCH v3 net-next 2/8] bgmac: configure MTU and add support for frames beyond 8192 byte size Vladimir Oltean
2020-03-26 22:40 ` [PATCH v3 net-next 3/8] net: dsa: configure the MTU for switch ports Vladimir Oltean
2020-03-27  0:06   ` Andrew Lunn [this message]
2020-03-27 10:00     ` Vladimir Oltean
2020-03-26 22:40 ` [PATCH v3 net-next 4/8] net: dsa: implement auto-normalization of MTU for bridge hardware datapath Vladimir Oltean
2020-04-02  1:25   ` kbuild test robot
2020-03-26 22:40 ` [PATCH v3 net-next 5/8] net: dsa: b53: add MTU configuration support Vladimir Oltean
2020-03-26 23:16   ` Florian Fainelli
2020-03-27 13:01     ` Vladimir Oltean
2020-03-26 22:40 ` [PATCH v3 net-next 6/8] net: dsa: sja1105: implement the port MTU callbacks Vladimir Oltean
2020-03-26 22:40 ` [PATCH v3 net-next 7/8] net: dsa: vsc73xx: make the MTU configurable Vladimir Oltean
2020-03-26 22:40 ` [PATCH v3 net-next 8/8] net: dsa: felix: support changing the MTU Vladimir Oltean

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=20200327000625.GJ3819@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=idosch@idosch.org \
    --cc=jakub.kicinski@netronome.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=murali.policharla@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=nikolay@cumulusnetworks.com \
    --cc=olteanv@gmail.com \
    --cc=stephen@networkplumber.org \
    --cc=vivien.didelot@gmail.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).