linux/net/dsa
Vladimir Oltean bfcb813203 net: dsa: configure the MTU for switch ports
It is useful be able to configure port policers on a switch to accept
frames of various sizes:

- Increase the MTU for better throughput from the default of 1500 if it
  is known that there is no 10/100 Mbps device in the network.
- Decrease the MTU to limit the latency of high-priority frames under
  congestion, or work around various network segments that add extra
  headers to packets which can't be fragmented.

For DSA slave ports, this is mostly a pass-through callback, called
through the regular ndo ops and at probe time (to ensure consistency
across all supported switches).

The CPU port is called with an MTU equal to the largest configured MTU
of the slave ports. The assumption is that the user might want to
sustain a bidirectional conversation with a partner over any switch
port.

The DSA master is configured the same as the CPU port, plus the tagger
overhead. Since the MTU is by definition L2 payload (sans Ethernet
header), it is up to each individual driver to figure out if it needs to
do anything special for its frame tags on the CPU port (it shouldn't
except in special cases). So the MTU does not contain the tagger
overhead on the CPU port.
However the MTU of the DSA master, minus the tagger overhead, is used as
a proxy for the MTU of the CPU port, which does not have a net device.
This is to avoid uselessly calling the .change_mtu function on the CPU
port when nothing should change.

So it is safe to assume that the DSA master and the CPU port MTUs are
apart by exactly the tagger's overhead in bytes.

Some changes were made around dsa_master_set_mtu(), function which was
now removed, for 2 reasons:
  - dev_set_mtu() already calls dev_validate_mtu(), so it's redundant to
    do the same thing in DSA
  - __dev_set_mtu() returns 0 if ops->ndo_change_mtu is an absent method
That is to say, there's no need for this function in DSA, we can safely
call dev_set_mtu() directly, take the rtnl lock when necessary, and just
propagate whatever errors get reported (since the user probably wants to
be informed).

Some inspiration (mainly in the MTU DSA notifier) was taken from a
vaguely similar patch from Murali and Florian, who are credited as
co-developers down below.

Co-developed-by: Murali Krishna Policharla <murali.policharla@broadcom.com>
Signed-off-by: Murali Krishna Policharla <murali.policharla@broadcom.com>
Co-developed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-27 16:07:24 -07:00
..
dsa2.c net: dsa: Fix use-after-free in probing of DSA switch tree 2020-01-27 11:12:46 +01:00
dsa_priv.h net: dsa: configure the MTU for switch ports 2020-03-27 16:07:24 -07:00
dsa.c net: dsa: Add support for devlink resources 2019-11-05 18:09:45 -08:00
Kconfig net: dsa: add support for Atheros AR9331 TAG format 2019-12-20 17:05:47 -08:00
Makefile net: dsa: add support for Atheros AR9331 TAG format 2019-12-20 17:05:47 -08:00
master.c net: dsa: configure the MTU for switch ports 2020-03-27 16:07:24 -07:00
port.c net: dsa: configure the MTU for switch ports 2020-03-27 16:07:24 -07:00
slave.c net: dsa: configure the MTU for switch ports 2020-03-27 16:07:24 -07:00
switch.c net: dsa: configure the MTU for switch ports 2020-03-27 16:07:24 -07:00
tag_8021q.c net: dsa: tag_8021q: replace dsa_8021q_remove_header with __skb_vlan_pop 2020-03-24 16:19:01 -07:00
tag_ar9331.c net: dsa: tag_ar9331: Make sure there is headroom for tag 2020-02-14 07:34:51 -08:00
tag_brcm.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2020-03-25 18:58:11 -07:00
tag_dsa.c dsa: Cleanup unneeded table and make tag structures static 2019-04-28 19:41:01 -04:00
tag_edsa.c dsa: Cleanup unneeded table and make tag structures static 2019-04-28 19:41:01 -04:00
tag_gswip.c net: dsa: tag_gswip: fix typo in tagger name 2020-01-16 13:58:26 +01:00
tag_ksz.c net: dsa: ksz: use common define for tag len 2019-12-20 21:06:49 -08:00
tag_lan9303.c dsa: Cleanup unneeded table and make tag structures static 2019-04-28 19:41:01 -04:00
tag_mtk.c dsa: Cleanup unneeded table and make tag structures static 2019-04-28 19:41:01 -04:00
tag_ocelot.c net: mscc: ocelot: eliminate confusion between CPU and NPI port 2020-03-04 14:19:00 -08:00
tag_qca.c net: dsa: tag_qca: Make sure there is headroom for tag 2020-02-14 07:34:51 -08:00
tag_sja1105.c net: dsa: tag_8021q: replace dsa_8021q_remove_header with __skb_vlan_pop 2020-03-24 16:19:01 -07:00
tag_trailer.c dsa: Cleanup unneeded table and make tag structures static 2019-04-28 19:41:01 -04:00