Re: [PATCH net-next 5/8] net: mscc: Add initial Ocelot switch support

From: Andrew Lunn
Date: Fri Mar 23 2018 - 17:25:30 EST


Hi Alexandre

> +static int ocelot_port_bridge_join(struct ocelot_port *ocelot_port,
> + struct net_device *bridge)
> +{
> + struct ocelot *ocelot = ocelot_port->ocelot;
> +
> + if (!ocelot->bridge_mask) {
> + ocelot->hw_bridge_dev = bridge;
> + } else {
> + if (ocelot->hw_bridge_dev != bridge)
> + return -ENODEV; //TODO: do something clever here
> + }
> +
> + ocelot->bridge_mask |= BIT(ocelot_port->chip_port);
> +
> + return 0;
> +}

I could be missing something here, but this looks way too simple.

By default, you have individual ports. They can just forward frames
between the host CPU and the port. There is no port-to-port traffic
allowed.

You then create a bridge, and add ports to the bridge. When you add a
port, you need to program the hardware that it can now forward frames
from this port to other parts in the same bridge. You also need to
tell other parts in the same bridge it can forward frames to it. You
might also need to tell the port which forwarding database it should
use, since each bridge might have its own.

Andrew