aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorVadim Pasternak <vadimp@nvidia.com>2022-02-22 19:16:52 +0200
committerDavid S. Miller <davem@davemloft.net>2022-02-23 12:38:16 +0000
commitc035ea76c4e79dca72f31e0676c81b2937d6f0a3 (patch)
tree66988553fd429c189263236210ec9abb196df24b /drivers
parentmctp: Fix warnings reported by clang-analyzer (diff)
downloadlinux-dev-c035ea76c4e79dca72f31e0676c81b2937d6f0a3.tar.xz
linux-dev-c035ea76c4e79dca72f31e0676c81b2937d6f0a3.zip
mlxsw: core: Prevent trap group setting if driver does not support EMAD
Avoid trap group setting if driver is not capable of EMAD support. For example, "mlxsw_minimal" driver works over I2C bus, overs which EMADs cannot be sent. Validation is performed by testing feature 'MLXSW_BUS_F_TXRX'. Fixes: 74e0494d35ac ("mlxsw: core: Move basic_trap_groups_set() call out of EMAD init code") Signed-off-by: Vadim Pasternak <vadimp@nvidia.com> Reviewed-by: Jiri Pirko <jiri@nvidia.com> Signed-off-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/core.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
index f45df5fbdcc0..1c6c1ea107a1 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
@@ -223,6 +223,9 @@ static int mlxsw_core_trap_groups_set(struct mlxsw_core *mlxsw_core)
int err;
int i;
+ if (!(mlxsw_core->bus->features & MLXSW_BUS_F_TXRX))
+ return 0;
+
for (i = 0; i < ARRAY_SIZE(mlxsw_core_trap_groups); i++) {
mlxsw_reg_htgt_pack(htgt_pl, mlxsw_core_trap_groups[i],
MLXSW_REG_HTGT_INVALID_POLICER,
@@ -2522,6 +2525,9 @@ int mlxsw_core_trap_register(struct mlxsw_core *mlxsw_core,
char hpkt_pl[MLXSW_REG_HPKT_LEN];
int err;
+ if (!(mlxsw_core->bus->features & MLXSW_BUS_F_TXRX))
+ return 0;
+
err = mlxsw_core_listener_register(mlxsw_core, listener, priv,
listener->enabled_on_register);
if (err)
@@ -2551,6 +2557,9 @@ void mlxsw_core_trap_unregister(struct mlxsw_core *mlxsw_core,
{
char hpkt_pl[MLXSW_REG_HPKT_LEN];
+ if (!(mlxsw_core->bus->features & MLXSW_BUS_F_TXRX))
+ return;
+
if (!listener->is_event) {
mlxsw_reg_hpkt_pack(hpkt_pl, listener->dis_action,
listener->trap_id, listener->dis_trap_group,