Re: Is it ok for switch TCAMs to depend on the bridge state?

Ido Schimmel
2021-11-07T11:56:10Z

On Tue, Nov 02, 2021 at 11:03:53AM +0000, Vladimir Oltean wrote:
> I've been reviewing a patch set which offloads to hardware some
> tc-flower filters with some TSN-specific actions (ingress policing).
> The keys of those offloaded tc-flower filters are not arbitrary, they
> are the destination MAC address and VLAN ID of the frames, which is
> relevant because these TSN policers are actually coupled with the
> bridging service in hardware. So the premise of that patch set was that
> the user would first need to add static FDB entries to the bridge with
> the same key as the tc-flower key, before the tc-flower filters would be
> accepted for offloading.

[...]

> I don't have a clear picture in my mind about what is wrong. An airplane
> viewer might argue that the TCAM should be completely separate from the
> bridging service, but I'm not completely sure that this can be achieved
> in the aforementioned case with VLAN rewriting on ingress and on egress,
> it would seem more natural for these features to operate on the
> classified VLAN (which again, depends on VLAN awareness being turned on).
> Alternatively, one might argue that the deletion of a bridge interface
> should be vetoed, and so should the removal of a port from a bridge.
> But that is quite complicated, and doesn't answer questions such as
> "what should you do when you reboot".
> Alternatively, one might say that letting the user remove TCAM
> dependencies from the bridging service is fine, but the driver should
> have a way to also unoffload the tc-flower keys as long as the
> requirements are not satisfied. I think this is also difficult to
> implement.

Regarding the question in the subject ("Is it ok for switch TCAMs to
depend on the bridge state?"), I believe the answer is yes because there
is no way to avoid it and effectively it is already happening.

To add to your examples and Jakub's, this is also how "ERSPAN" works in
mlxsw. User space installs some flower filter with a mirror action
towards a gretap netdev, but the HW does not do the forwarding towards
the destination. Instead, it relies on the SW to tell it which headers
(i.e., Eth, IP, GRE) to put on the mirrored packet and tell it from
which port the packet should egress. When we have a bridge in the
forwarding path, it means that the offload state of the filter is
affected by FDB updates. As was discussed in the past, we are missing
the ability to notify user space when the offload state of the filter
changes.

Regarding the particular example of TSN policers. I'm not familiar with
the subject, but from your mail I get the impression that the dependency
between them and the bridge is a quirk of the hardware you are working
with and that in general the two are not related. If so, in order to
make the user experience somewhat better, you might consider vetoing the
addition of the flower filter or at least emit a warning via extack when
the port is not enslaved to a bridge. Regarding the FDB entries, instead
of requiring user space to understand that it needs to install those
entries in order to make the filter work, you can notify them from the
driver to the bridge via SWITCHDEV_FDB_ADD_TO_BRIDGE.