• Vladimir Oltean's avatar
    net: mscc: ocelot: enforce FDB isolation when VLAN-unaware · 54c31984
    Vladimir Oltean authored
    Currently ocelot uses a pvid of 0 for standalone ports and ports under a
    VLAN-unaware bridge, and the pvid of the bridge for ports under a
    VLAN-aware bridge. Standalone ports do not perform learning, but packets
    received on them are still subject to FDB lookups. So if the MAC DA that
    a standalone port receives has been also learned on a VLAN-unaware
    bridge port, ocelot will attempt to forward to that port, even though it
    can't, so it will drop packets.
    
    So there is a desire to avoid that, and isolate the FDBs of different
    bridges from one another, and from standalone ports.
    
    The ocelot switch library has two distinct entry points: the felix DSA
    driver and the ocelot switchdev driver.
    
    We need to code up a minimal bridge_num allocation in the ocelot
    switchdev driver too, this is copied from DSA with the exception that
    ocelot does not care about DSA trees, cross-chip bridging etc. So it
    only looks at its own ports that are already in the same bridge.
    
    The ocelot switchdev driver uses the bridge_num it has allocated itself,
    while the felix driver uses the bridge_num allocated by DSA. They are
    both stored inside ocelot_port->bridge_num by the common function
    ocelot_port_bridge_join() which receives the bridge_num passed by value.
    
    Once we have a bridge_num, we can only use it to enforce isolation
    between VLAN-unaware bridges. As far as I can see, ocelot does not have
    anything like a FID that further makes VLAN 100 from a port be different
    to VLAN 100 from another port with regard to FDB lookup. So we simply
    deny multiple VLAN-aware bridges.
    
    For VLAN-unaware bridges, we crop the 4000-4095 VLAN region and we
    allocate a VLAN for each bridge_num. This will be used as the pvid of
    each port that is under that VLAN-unaware bridge, for as long as that
    bridge is VLAN-unaware.
    
    VID 0 remains only for standalone ports. It is okay if all standalone
    ports use the same VID 0, since they perform no address learning, the
    FDB will contain no entry in VLAN 0, so the packets will always be
    flooded to the only possible destination, the CPU port.
    
    The CPU port module doesn't need to be member of the VLANs to receive
    packets, but if we use the DSA tag_8021q protocol, those packets are
    part of the data plane as far as ocelot is concerned, so there it needs
    to. Just ensure that the DSA tag_8021q CPU port is a member of all
    reserved VLANs when it is created, and is removed when it is deleted.
    Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    54c31984
ocelot.h 3.48 KB