Commit c035ea76 authored by Vadim Pasternak's avatar Vadim Pasternak Committed by David S. Miller

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: 74e0494d ("mlxsw: core: Move basic_trap_groups_set() call out of EMAD init code")
Signed-off-by: default avatarVadim Pasternak <vadimp@nvidia.com>
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8d783197
......@@ -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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment