diff options
author | Jiri Pirko <jiri@mellanox.com> | 2020-02-24 10:35:46 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-02-24 22:55:06 +0300 |
commit | 4a23d45a3e0cfaf9676ba2e67f2c2bca5a1478f0 (patch) | |
tree | 56ea155130d5823c08f9a1ab2afaf01b39e0baa4 | |
parent | 99ff9cc249ff3c75aa12f52f12a35b3b9cfa32f7 (diff) | |
download | linux-4a23d45a3e0cfaf9676ba2e67f2c2bca5a1478f0.tar.xz |
mlxsw: spectrum_trap: Prepare mlxsw_core_trap_action_set() to handle not only action
Rename function mlxsw_core_trap_action_set() to
mlxsw_core_trap_state_set() and pass bool enabled instead of action.
Figure out the action according to the enabled state there.
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/core.c | 10 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/core.h | 6 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c | 11 |
3 files changed, 13 insertions, 14 deletions
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c index a01868282008..167df7e4d678 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core.c @@ -1669,17 +1669,19 @@ void mlxsw_core_trap_unregister(struct mlxsw_core *mlxsw_core, } EXPORT_SYMBOL(mlxsw_core_trap_unregister); -int mlxsw_core_trap_action_set(struct mlxsw_core *mlxsw_core, - const struct mlxsw_listener *listener, - enum mlxsw_reg_hpkt_action action) +int mlxsw_core_trap_state_set(struct mlxsw_core *mlxsw_core, + const struct mlxsw_listener *listener, + bool enabled) { + enum mlxsw_reg_hpkt_action action; char hpkt_pl[MLXSW_REG_HPKT_LEN]; + action = enabled ? listener->en_action : listener->dis_action; mlxsw_reg_hpkt_pack(hpkt_pl, action, listener->trap_id, listener->trap_group, listener->is_ctrl); return mlxsw_reg_write(mlxsw_core, MLXSW_REG(hpkt), hpkt_pl); } -EXPORT_SYMBOL(mlxsw_core_trap_action_set); +EXPORT_SYMBOL(mlxsw_core_trap_state_set); static u64 mlxsw_core_tid_get(struct mlxsw_core *mlxsw_core) { diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h index 9c4ce3f65944..b6e57cbc084e 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core.h +++ b/drivers/net/ethernet/mellanox/mlxsw/core.h @@ -145,9 +145,9 @@ int mlxsw_core_trap_register(struct mlxsw_core *mlxsw_core, void mlxsw_core_trap_unregister(struct mlxsw_core *mlxsw_core, const struct mlxsw_listener *listener, void *priv); -int mlxsw_core_trap_action_set(struct mlxsw_core *mlxsw_core, - const struct mlxsw_listener *listener, - enum mlxsw_reg_hpkt_action action); +int mlxsw_core_trap_state_set(struct mlxsw_core *mlxsw_core, + const struct mlxsw_listener *listener, + bool enabled); typedef void mlxsw_reg_trans_cb_t(struct mlxsw_core *mlxsw_core, char *payload, size_t payload_len, unsigned long cb_priv); diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c index 7c6a9634cdbc..afd3f28ec9f6 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c @@ -320,26 +320,23 @@ int mlxsw_sp_trap_action_set(struct mlxsw_core *mlxsw_core, for (i = 0; i < ARRAY_SIZE(mlxsw_sp_listener_devlink_map); i++) { const struct mlxsw_listener *listener; - enum mlxsw_reg_hpkt_action hw_action; + bool enabled; int err; if (mlxsw_sp_listener_devlink_map[i] != trap->id) continue; listener = &mlxsw_sp_listeners_arr[i]; - switch (action) { case DEVLINK_TRAP_ACTION_DROP: - hw_action = listener->dis_action; + enabled = false; break; case DEVLINK_TRAP_ACTION_TRAP: - hw_action = listener->en_action; + enabled = true; break; default: return -EINVAL; } - - err = mlxsw_core_trap_action_set(mlxsw_core, listener, - hw_action); + err = mlxsw_core_trap_state_set(mlxsw_core, listener, enabled); if (err) return err; } |