• Vladimir Oltean's avatar
    net: dsa: configure the MTU for switch ports · bfcb8132
    Vladimir Oltean authored
    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: default avatarMurali Krishna Policharla <murali.policharla@broadcom.com>
    Signed-off-by: default avatarMurali Krishna Policharla <murali.policharla@broadcom.com>
    Co-developed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
    Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
    Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    bfcb8132
port.c 17.4 KB