mlxsw: spectrum_trap: Do not hard code "thin" policer identifier
authorIdo Schimmel <idosch@mellanox.com>
Mon, 25 May 2020 23:05:51 +0000 (02:05 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 27 May 2020 03:33:58 +0000 (20:33 -0700)
commitb87bde80daf77649efba90ef0b1079b84be92d39
treec3c6b78039ee39dd72f696954bf1349dab87bb9e
parent03cb0ce0ddc8c00b7c4c5becff7fb7cf44b00a91
mlxsw: spectrum_trap: Do not hard code "thin" policer identifier

As explained in commit e612523041ab ("mlxsw: spectrum_trap: Introduce
dummy group with thin policer"), the purpose of the "thin" policer is to
pass as less packets as possible to the CPU.

The identifier of this policer is currently set according to the maximum
number of used trap groups, but this is fragile: On Spectrum-1 the
maximum number of policers is less than the maximum number of trap
groups, which might result in an invalid policer identifier in case the
number of used trap groups grows beyond the policer limit.

Solve this by dynamically allocating the policer identifier.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.h