• Luiz Angelo Daros de Luca's avatar
    net: dsa: realtek: rtl8365mb: add change_mtu · c36a77c3
    Luiz Angelo Daros de Luca authored
    The rtl8365mb was using a fixed MTU size of 1536, which was probably
    inspired by the rtl8366rb's initial frame size. However, unlike that
    family, the rtl8365mb family can specify the max frame size in bytes,
    rather than in fixed steps.
    
    DSA calls change_mtu for the CPU port once the max MTU value among the
    ports changes. As the max frame size is defined globally, the switch
    is configured only when the call affects the CPU port.
    
    The available specifications do not directly define the max supported
    frame size, but it mentions a 16k limit. This driver will use the 0x3FFF
    limit as it is used in the vendor API code. However, the switch sets the
    max frame size to 16368 bytes (0x3FF0) after it resets.
    
    change_mtu uses MTU size, or ethernet payload size, while the switch
    works with frame size. The frame size is calculated considering the
    ethernet header (14 bytes), a possible 802.1Q tag (4 bytes), the payload
    size (MTU), and the Ethernet FCS (4 bytes). The CPU tag (8 bytes) is
    consumed before the switch enforces the limit.
    
    During setup, the driver will use the default 1500-byte MTU of DSA to
    set the maximum frame size. The current sum will be
    VLAN_ETH_HLEN+1500+ETH_FCS_LEN, which results in 1522 bytes.  Although
    it is lower than the previous initial value of 1536 bytes, the driver
    will increase the frame size for a larger MTU. However, if something
    requires more space without increasing the MTU, such as QinQ, we would
    need to add the extra length to the rtl8365mb_port_change_mtu() formula.
    
    MTU was tested up to 2018 (with 802.1Q) as that is as far as mt7620
    (where rtl8367s is stacked) can go. The register was manually
    manipulated byte-by-byte to ensure the MTU to frame size conversion was
    correct. For frames without 802.1Q tag, the frame size limit will be 4
    bytes over the required size.
    
    There is a jumbo register, enabled by default at 6k frame size.
    However, the jumbo settings do not seem to limit nor expand the maximum
    tested MTU (2018), even when jumbo is disabled. More tests are needed
    with a device that can handle larger frames.
    Signed-off-by: default avatarLuiz Angelo Daros de Luca <luizluca@gmail.com>
    Reviewed-by: default avatarAlexander Duyck <alexanderduyck@fb.com>
    Reviewed-by: default avatarAlvin Šipraga <alsi@bang-olufsen.dk>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    c36a77c3
rtl8365mb.c 64.9 KB