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

devlink: Pass extack when setting trap's action and group's parameters

A later patch will refuse to set the action of certain traps in mlxsw
and also to change the policer binding of certain groups. Pass extack so
that failure could be communicated clearly to user space.
Reviewed-by: default avatarPetr Machata <petrm@mellanox.com>
Reviewed-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 08e335f6
...@@ -1177,14 +1177,15 @@ static void mlxsw_devlink_trap_fini(struct devlink *devlink, ...@@ -1177,14 +1177,15 @@ static void mlxsw_devlink_trap_fini(struct devlink *devlink,
static int mlxsw_devlink_trap_action_set(struct devlink *devlink, static int mlxsw_devlink_trap_action_set(struct devlink *devlink,
const struct devlink_trap *trap, const struct devlink_trap *trap,
enum devlink_trap_action action) enum devlink_trap_action action,
struct netlink_ext_ack *extack)
{ {
struct mlxsw_core *mlxsw_core = devlink_priv(devlink); struct mlxsw_core *mlxsw_core = devlink_priv(devlink);
struct mlxsw_driver *mlxsw_driver = mlxsw_core->driver; struct mlxsw_driver *mlxsw_driver = mlxsw_core->driver;
if (!mlxsw_driver->trap_action_set) if (!mlxsw_driver->trap_action_set)
return -EOPNOTSUPP; return -EOPNOTSUPP;
return mlxsw_driver->trap_action_set(mlxsw_core, trap, action); return mlxsw_driver->trap_action_set(mlxsw_core, trap, action, extack);
} }
static int static int
...@@ -1202,14 +1203,15 @@ mlxsw_devlink_trap_group_init(struct devlink *devlink, ...@@ -1202,14 +1203,15 @@ mlxsw_devlink_trap_group_init(struct devlink *devlink,
static int static int
mlxsw_devlink_trap_group_set(struct devlink *devlink, mlxsw_devlink_trap_group_set(struct devlink *devlink,
const struct devlink_trap_group *group, const struct devlink_trap_group *group,
const struct devlink_trap_policer *policer) const struct devlink_trap_policer *policer,
struct netlink_ext_ack *extack)
{ {
struct mlxsw_core *mlxsw_core = devlink_priv(devlink); struct mlxsw_core *mlxsw_core = devlink_priv(devlink);
struct mlxsw_driver *mlxsw_driver = mlxsw_core->driver; struct mlxsw_driver *mlxsw_driver = mlxsw_core->driver;
if (!mlxsw_driver->trap_group_set) if (!mlxsw_driver->trap_group_set)
return -EOPNOTSUPP; return -EOPNOTSUPP;
return mlxsw_driver->trap_group_set(mlxsw_core, group, policer); return mlxsw_driver->trap_group_set(mlxsw_core, group, policer, extack);
} }
static int static int
......
...@@ -326,12 +326,14 @@ struct mlxsw_driver { ...@@ -326,12 +326,14 @@ struct mlxsw_driver {
const struct devlink_trap *trap, void *trap_ctx); const struct devlink_trap *trap, void *trap_ctx);
int (*trap_action_set)(struct mlxsw_core *mlxsw_core, int (*trap_action_set)(struct mlxsw_core *mlxsw_core,
const struct devlink_trap *trap, const struct devlink_trap *trap,
enum devlink_trap_action action); enum devlink_trap_action action,
struct netlink_ext_ack *extack);
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, int (*trap_group_set)(struct mlxsw_core *mlxsw_core,
const struct devlink_trap_group *group, const struct devlink_trap_group *group,
const struct devlink_trap_policer *policer); const struct devlink_trap_policer *policer,
struct netlink_ext_ack *extack);
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,
......
...@@ -1177,12 +1177,14 @@ void mlxsw_sp_trap_fini(struct mlxsw_core *mlxsw_core, ...@@ -1177,12 +1177,14 @@ void mlxsw_sp_trap_fini(struct mlxsw_core *mlxsw_core,
const struct devlink_trap *trap, void *trap_ctx); const struct devlink_trap *trap, void *trap_ctx);
int mlxsw_sp_trap_action_set(struct mlxsw_core *mlxsw_core, int mlxsw_sp_trap_action_set(struct mlxsw_core *mlxsw_core,
const struct devlink_trap *trap, const struct devlink_trap *trap,
enum devlink_trap_action action); enum devlink_trap_action action,
struct netlink_ext_ack *extack);
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, int mlxsw_sp_trap_group_set(struct mlxsw_core *mlxsw_core,
const struct devlink_trap_group *group, const struct devlink_trap_group *group,
const struct devlink_trap_policer *policer); const struct devlink_trap_policer *policer,
struct netlink_ext_ack *extack);
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);
......
...@@ -1352,7 +1352,8 @@ void mlxsw_sp_trap_fini(struct mlxsw_core *mlxsw_core, ...@@ -1352,7 +1352,8 @@ void mlxsw_sp_trap_fini(struct mlxsw_core *mlxsw_core,
int mlxsw_sp_trap_action_set(struct mlxsw_core *mlxsw_core, int mlxsw_sp_trap_action_set(struct mlxsw_core *mlxsw_core,
const struct devlink_trap *trap, const struct devlink_trap *trap,
enum devlink_trap_action action) enum devlink_trap_action action,
struct netlink_ext_ack *extack)
{ {
struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core);
const struct mlxsw_sp_trap_item *trap_item; const struct mlxsw_sp_trap_item *trap_item;
...@@ -1392,7 +1393,7 @@ int mlxsw_sp_trap_action_set(struct mlxsw_core *mlxsw_core, ...@@ -1392,7 +1393,7 @@ int mlxsw_sp_trap_action_set(struct mlxsw_core *mlxsw_core,
static int static int
__mlxsw_sp_trap_group_init(struct mlxsw_core *mlxsw_core, __mlxsw_sp_trap_group_init(struct mlxsw_core *mlxsw_core,
const struct devlink_trap_group *group, const struct devlink_trap_group *group,
u32 policer_id) u32 policer_id, struct netlink_ext_ack *extack)
{ {
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;
...@@ -1422,16 +1423,18 @@ int mlxsw_sp_trap_group_init(struct mlxsw_core *mlxsw_core, ...@@ -1422,16 +1423,18 @@ int mlxsw_sp_trap_group_init(struct mlxsw_core *mlxsw_core,
const struct devlink_trap_group *group) const struct devlink_trap_group *group)
{ {
return __mlxsw_sp_trap_group_init(mlxsw_core, group, return __mlxsw_sp_trap_group_init(mlxsw_core, group,
group->init_policer_id); group->init_policer_id, NULL);
} }
int mlxsw_sp_trap_group_set(struct mlxsw_core *mlxsw_core, int mlxsw_sp_trap_group_set(struct mlxsw_core *mlxsw_core,
const struct devlink_trap_group *group, const struct devlink_trap_group *group,
const struct devlink_trap_policer *policer) const struct devlink_trap_policer *policer,
struct netlink_ext_ack *extack)
{ {
u32 policer_id = policer ? policer->id : 0; u32 policer_id = policer ? policer->id : 0;
return __mlxsw_sp_trap_group_init(mlxsw_core, group, policer_id); return __mlxsw_sp_trap_group_init(mlxsw_core, group, policer_id,
extack);
} }
static int static int
......
...@@ -810,7 +810,8 @@ static int nsim_dev_devlink_trap_init(struct devlink *devlink, ...@@ -810,7 +810,8 @@ static int nsim_dev_devlink_trap_init(struct devlink *devlink,
static int static int
nsim_dev_devlink_trap_action_set(struct devlink *devlink, nsim_dev_devlink_trap_action_set(struct devlink *devlink,
const struct devlink_trap *trap, const struct devlink_trap *trap,
enum devlink_trap_action action) enum devlink_trap_action action,
struct netlink_ext_ack *extack)
{ {
struct nsim_dev *nsim_dev = devlink_priv(devlink); struct nsim_dev *nsim_dev = devlink_priv(devlink);
struct nsim_trap_item *nsim_trap_item; struct nsim_trap_item *nsim_trap_item;
...@@ -829,7 +830,8 @@ nsim_dev_devlink_trap_action_set(struct devlink *devlink, ...@@ -829,7 +830,8 @@ nsim_dev_devlink_trap_action_set(struct devlink *devlink,
static int static int
nsim_dev_devlink_trap_group_set(struct devlink *devlink, nsim_dev_devlink_trap_group_set(struct devlink *devlink,
const struct devlink_trap_group *group, const struct devlink_trap_group *group,
const struct devlink_trap_policer *policer) const struct devlink_trap_policer *policer,
struct netlink_ext_ack *extack)
{ {
struct nsim_dev *nsim_dev = devlink_priv(devlink); struct nsim_dev *nsim_dev = devlink_priv(devlink);
......
...@@ -1077,7 +1077,8 @@ struct devlink_ops { ...@@ -1077,7 +1077,8 @@ struct devlink_ops {
*/ */
int (*trap_action_set)(struct devlink *devlink, int (*trap_action_set)(struct devlink *devlink,
const struct devlink_trap *trap, const struct devlink_trap *trap,
enum devlink_trap_action action); enum devlink_trap_action action,
struct netlink_ext_ack *extack);
/** /**
* @trap_group_init: Trap group initialization function. * @trap_group_init: Trap group initialization function.
* *
...@@ -1094,7 +1095,8 @@ struct devlink_ops { ...@@ -1094,7 +1095,8 @@ struct devlink_ops {
*/ */
int (*trap_group_set)(struct devlink *devlink, int (*trap_group_set)(struct devlink *devlink,
const struct devlink_trap_group *group, const struct devlink_trap_group *group,
const struct devlink_trap_policer *policer); const struct devlink_trap_policer *policer,
struct netlink_ext_ack *extack);
/** /**
* @trap_policer_init: Trap policer initialization function. * @trap_policer_init: Trap policer initialization function.
* *
......
...@@ -6423,7 +6423,7 @@ static int __devlink_trap_action_set(struct devlink *devlink, ...@@ -6423,7 +6423,7 @@ static int __devlink_trap_action_set(struct devlink *devlink,
} }
err = devlink->ops->trap_action_set(devlink, trap_item->trap, err = devlink->ops->trap_action_set(devlink, trap_item->trap,
trap_action); trap_action, extack);
if (err) if (err)
return err; return err;
...@@ -6713,7 +6713,8 @@ static int devlink_trap_group_set(struct devlink *devlink, ...@@ -6713,7 +6713,8 @@ static int devlink_trap_group_set(struct devlink *devlink,
} }
policer = policer_item ? policer_item->policer : NULL; policer = policer_item ? policer_item->policer : NULL;
err = devlink->ops->trap_group_set(devlink, group_item->group, policer); err = devlink->ops->trap_group_set(devlink, group_item->group, policer,
extack);
if (err) if (err)
return err; return err;
...@@ -9051,7 +9052,8 @@ static void devlink_trap_disable(struct devlink *devlink, ...@@ -9051,7 +9052,8 @@ static void devlink_trap_disable(struct devlink *devlink,
if (WARN_ON_ONCE(!trap_item)) if (WARN_ON_ONCE(!trap_item))
return; return;
devlink->ops->trap_action_set(devlink, trap, DEVLINK_TRAP_ACTION_DROP); devlink->ops->trap_action_set(devlink, trap, DEVLINK_TRAP_ACTION_DROP,
NULL);
trap_item->action = DEVLINK_TRAP_ACTION_DROP; trap_item->action = DEVLINK_TRAP_ACTION_DROP;
} }
......
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