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>
This commit is contained in:
Jiri Pirko 2020-02-24 08:35:46 +01:00 committed by David S. Miller
parent 99ff9cc249
commit 4a23d45a3e
3 changed files with 13 additions and 14 deletions

View File

@ -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)
{

View File

@ -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);

View File

@ -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;
}