Commit 4a23d45a authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

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: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 99ff9cc2
......@@ -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)
{
......
......@@ -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);
......
......@@ -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;
}
......
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