OSDN Git Service

mlxsw: spectrum: Prevent duplicate mirrors
authorPetr Machata <petrm@mellanox.com>
Fri, 9 Mar 2018 13:33:53 +0000 (15:33 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 9 Mar 2018 18:02:14 +0000 (13:02 -0500)
commit663f1b26f9c129aa2912c1a1d3359e3ecd88e814
tree9c12d2370eba76987264c3f57c27db2ee7224f1c
parent49bae2f3093b0a7bc5e1a158d89697a73cdb0243
mlxsw: spectrum: Prevent duplicate mirrors

The Spectrum ASIC doesn't support mirroring more than once from a single
binding point (which is a port-direction pair). Therefore detect that a
second binding of a given binding point is attempted.

To that end, extend struct mlxsw_sp_span_inspected_port to track whether
a given binding point is bound or not. Extend
mlxsw_sp_span_entry_port_find() to look for ports based on the full
unique key: port number, direction, and boundness.

Besides fixing the overt bug where configured mirrors are not offloaded,
this also fixes a more subtle bug: mlxsw_sp_span_inspected_port_del()
just defers to mlxsw_sp_span_entry_bound_port_find(), and that used to
find the first port with the right number (disregarding the type). Thus
by adding and removing egress and ingress mirrors in the right order,
one could trick the system into believing it has no egress mirrors when
in fact it did have some. That then caused that
mlxsw_sp_span_port_mtu_update() didn't update mirroring buffer when MTU
was changed.

Fixes: 763b4b70afcd ("mlxsw: spectrum: Add support in matchall mirror TC offloading")
Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
drivers/net/ethernet/mellanox/mlxsw/spectrum.h