Commit 39defcbb authored by Ido Schimmel's avatar Ido Schimmel Committed by David S. Miller

mlxsw: spectrum_trap: Add support for setting of packet trap group parameters

Implement support for setting of packet trap group parameters by
invoking the trap_group_init() callback with the new parameters.
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Reviewed-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d12d8468
...@@ -1198,6 +1198,19 @@ mlxsw_devlink_trap_group_init(struct devlink *devlink, ...@@ -1198,6 +1198,19 @@ mlxsw_devlink_trap_group_init(struct devlink *devlink,
return mlxsw_driver->trap_group_init(mlxsw_core, group); return mlxsw_driver->trap_group_init(mlxsw_core, group);
} }
static int
mlxsw_devlink_trap_group_set(struct devlink *devlink,
const struct devlink_trap_group *group,
const struct devlink_trap_policer *policer)
{
struct mlxsw_core *mlxsw_core = devlink_priv(devlink);
struct mlxsw_driver *mlxsw_driver = mlxsw_core->driver;
if (!mlxsw_driver->trap_group_set)
return -EOPNOTSUPP;
return mlxsw_driver->trap_group_set(mlxsw_core, group, policer);
}
static int static int
mlxsw_devlink_trap_policer_init(struct devlink *devlink, mlxsw_devlink_trap_policer_init(struct devlink *devlink,
const struct devlink_trap_policer *policer) const struct devlink_trap_policer *policer)
...@@ -1273,6 +1286,7 @@ static const struct devlink_ops mlxsw_devlink_ops = { ...@@ -1273,6 +1286,7 @@ static const struct devlink_ops mlxsw_devlink_ops = {
.trap_fini = mlxsw_devlink_trap_fini, .trap_fini = mlxsw_devlink_trap_fini,
.trap_action_set = mlxsw_devlink_trap_action_set, .trap_action_set = mlxsw_devlink_trap_action_set,
.trap_group_init = mlxsw_devlink_trap_group_init, .trap_group_init = mlxsw_devlink_trap_group_init,
.trap_group_set = mlxsw_devlink_trap_group_set,
.trap_policer_init = mlxsw_devlink_trap_policer_init, .trap_policer_init = mlxsw_devlink_trap_policer_init,
.trap_policer_fini = mlxsw_devlink_trap_policer_fini, .trap_policer_fini = mlxsw_devlink_trap_policer_fini,
.trap_policer_set = mlxsw_devlink_trap_policer_set, .trap_policer_set = mlxsw_devlink_trap_policer_set,
......
...@@ -327,6 +327,9 @@ struct mlxsw_driver { ...@@ -327,6 +327,9 @@ struct mlxsw_driver {
enum devlink_trap_action action); enum devlink_trap_action action);
int (*trap_group_init)(struct mlxsw_core *mlxsw_core, int (*trap_group_init)(struct mlxsw_core *mlxsw_core,
const struct devlink_trap_group *group); const struct devlink_trap_group *group);
int (*trap_group_set)(struct mlxsw_core *mlxsw_core,
const struct devlink_trap_group *group,
const struct devlink_trap_policer *policer);
int (*trap_policer_init)(struct mlxsw_core *mlxsw_core, int (*trap_policer_init)(struct mlxsw_core *mlxsw_core,
const struct devlink_trap_policer *policer); const struct devlink_trap_policer *policer);
void (*trap_policer_fini)(struct mlxsw_core *mlxsw_core, void (*trap_policer_fini)(struct mlxsw_core *mlxsw_core,
......
...@@ -5674,6 +5674,7 @@ static struct mlxsw_driver mlxsw_sp1_driver = { ...@@ -5674,6 +5674,7 @@ static struct mlxsw_driver mlxsw_sp1_driver = {
.trap_fini = mlxsw_sp_trap_fini, .trap_fini = mlxsw_sp_trap_fini,
.trap_action_set = mlxsw_sp_trap_action_set, .trap_action_set = mlxsw_sp_trap_action_set,
.trap_group_init = mlxsw_sp_trap_group_init, .trap_group_init = mlxsw_sp_trap_group_init,
.trap_group_set = mlxsw_sp_trap_group_set,
.trap_policer_init = mlxsw_sp_trap_policer_init, .trap_policer_init = mlxsw_sp_trap_policer_init,
.trap_policer_fini = mlxsw_sp_trap_policer_fini, .trap_policer_fini = mlxsw_sp_trap_policer_fini,
.trap_policer_set = mlxsw_sp_trap_policer_set, .trap_policer_set = mlxsw_sp_trap_policer_set,
...@@ -5712,6 +5713,7 @@ static struct mlxsw_driver mlxsw_sp2_driver = { ...@@ -5712,6 +5713,7 @@ static struct mlxsw_driver mlxsw_sp2_driver = {
.trap_fini = mlxsw_sp_trap_fini, .trap_fini = mlxsw_sp_trap_fini,
.trap_action_set = mlxsw_sp_trap_action_set, .trap_action_set = mlxsw_sp_trap_action_set,
.trap_group_init = mlxsw_sp_trap_group_init, .trap_group_init = mlxsw_sp_trap_group_init,
.trap_group_set = mlxsw_sp_trap_group_set,
.trap_policer_init = mlxsw_sp_trap_policer_init, .trap_policer_init = mlxsw_sp_trap_policer_init,
.trap_policer_fini = mlxsw_sp_trap_policer_fini, .trap_policer_fini = mlxsw_sp_trap_policer_fini,
.trap_policer_set = mlxsw_sp_trap_policer_set, .trap_policer_set = mlxsw_sp_trap_policer_set,
...@@ -5749,6 +5751,7 @@ static struct mlxsw_driver mlxsw_sp3_driver = { ...@@ -5749,6 +5751,7 @@ static struct mlxsw_driver mlxsw_sp3_driver = {
.trap_fini = mlxsw_sp_trap_fini, .trap_fini = mlxsw_sp_trap_fini,
.trap_action_set = mlxsw_sp_trap_action_set, .trap_action_set = mlxsw_sp_trap_action_set,
.trap_group_init = mlxsw_sp_trap_group_init, .trap_group_init = mlxsw_sp_trap_group_init,
.trap_group_set = mlxsw_sp_trap_group_set,
.trap_policer_init = mlxsw_sp_trap_policer_init, .trap_policer_init = mlxsw_sp_trap_policer_init,
.trap_policer_fini = mlxsw_sp_trap_policer_fini, .trap_policer_fini = mlxsw_sp_trap_policer_fini,
.trap_policer_set = mlxsw_sp_trap_policer_set, .trap_policer_set = mlxsw_sp_trap_policer_set,
......
...@@ -1023,6 +1023,9 @@ int mlxsw_sp_trap_action_set(struct mlxsw_core *mlxsw_core, ...@@ -1023,6 +1023,9 @@ int mlxsw_sp_trap_action_set(struct mlxsw_core *mlxsw_core,
enum devlink_trap_action action); enum devlink_trap_action action);
int mlxsw_sp_trap_group_init(struct mlxsw_core *mlxsw_core, int mlxsw_sp_trap_group_init(struct mlxsw_core *mlxsw_core,
const struct devlink_trap_group *group); const struct devlink_trap_group *group);
int mlxsw_sp_trap_group_set(struct mlxsw_core *mlxsw_core,
const struct devlink_trap_group *group,
const struct devlink_trap_policer *policer);
int int
mlxsw_sp_trap_policer_init(struct mlxsw_core *mlxsw_core, mlxsw_sp_trap_policer_init(struct mlxsw_core *mlxsw_core,
const struct devlink_trap_policer *policer); const struct devlink_trap_policer *policer);
......
...@@ -537,8 +537,10 @@ int mlxsw_sp_trap_action_set(struct mlxsw_core *mlxsw_core, ...@@ -537,8 +537,10 @@ int mlxsw_sp_trap_action_set(struct mlxsw_core *mlxsw_core,
return 0; return 0;
} }
int mlxsw_sp_trap_group_init(struct mlxsw_core *mlxsw_core, static int
const struct devlink_trap_group *group) __mlxsw_sp_trap_group_init(struct mlxsw_core *mlxsw_core,
const struct devlink_trap_group *group,
u32 policer_id)
{ {
struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core);
u16 hw_policer_id = MLXSW_REG_HTGT_INVALID_POLICER; u16 hw_policer_id = MLXSW_REG_HTGT_INVALID_POLICER;
...@@ -570,11 +572,11 @@ int mlxsw_sp_trap_group_init(struct mlxsw_core *mlxsw_core, ...@@ -570,11 +572,11 @@ int mlxsw_sp_trap_group_init(struct mlxsw_core *mlxsw_core,
return -EINVAL; return -EINVAL;
} }
if (group->init_policer_id) { if (policer_id) {
struct mlxsw_sp_trap_policer_item *policer_item; struct mlxsw_sp_trap_policer_item *policer_item;
u32 id = group->init_policer_id;
policer_item = mlxsw_sp_trap_policer_item_lookup(mlxsw_sp, id); policer_item = mlxsw_sp_trap_policer_item_lookup(mlxsw_sp,
policer_id);
if (WARN_ON(!policer_item)) if (WARN_ON(!policer_item))
return -EINVAL; return -EINVAL;
hw_policer_id = policer_item->hw_id; hw_policer_id = policer_item->hw_id;
...@@ -584,6 +586,22 @@ int mlxsw_sp_trap_group_init(struct mlxsw_core *mlxsw_core, ...@@ -584,6 +586,22 @@ int mlxsw_sp_trap_group_init(struct mlxsw_core *mlxsw_core,
return mlxsw_reg_write(mlxsw_core, MLXSW_REG(htgt), htgt_pl); return mlxsw_reg_write(mlxsw_core, MLXSW_REG(htgt), htgt_pl);
} }
int mlxsw_sp_trap_group_init(struct mlxsw_core *mlxsw_core,
const struct devlink_trap_group *group)
{
return __mlxsw_sp_trap_group_init(mlxsw_core, group,
group->init_policer_id);
}
int mlxsw_sp_trap_group_set(struct mlxsw_core *mlxsw_core,
const struct devlink_trap_group *group,
const struct devlink_trap_policer *policer)
{
u32 policer_id = policer ? policer->id : 0;
return __mlxsw_sp_trap_group_init(mlxsw_core, group, policer_id);
}
static struct mlxsw_sp_trap_policer_item * static struct mlxsw_sp_trap_policer_item *
mlxsw_sp_trap_policer_item_init(struct mlxsw_sp *mlxsw_sp, u32 id) mlxsw_sp_trap_policer_item_init(struct mlxsw_sp *mlxsw_sp, u32 id)
{ {
......
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