Skip to content

Commit c50bf2b

Browse files
IoanaCiorneidavem330
authored andcommitted
devlink: add .trap_group_action_set() callback
Add a new devlink callback, .trap_group_action_set(), which can be used by device drivers which do not support controlling the action (drop, trap) on each trap but rather on the entire group trap. If this new callback is populated, it will take precedence over the .trap_action_set() callback when the user requests a change of all the traps in a group. Signed-off-by: Ioana Ciornei <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 10c24eb commit c50bf2b

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

include/net/devlink.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,16 @@ struct devlink_ops {
12421242
const struct devlink_trap_group *group,
12431243
const struct devlink_trap_policer *policer,
12441244
struct netlink_ext_ack *extack);
1245+
/**
1246+
* @trap_group_action_set: Trap group action set function.
1247+
*
1248+
* If this callback is populated, it will take precedence over looping
1249+
* over all traps in a group and calling .trap_action_set().
1250+
*/
1251+
int (*trap_group_action_set)(struct devlink *devlink,
1252+
const struct devlink_trap_group *group,
1253+
enum devlink_trap_action action,
1254+
struct netlink_ext_ack *extack);
12451255
/**
12461256
* @trap_policer_init: Trap policer initialization function.
12471257
*

net/core/devlink.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6720,6 +6720,24 @@ __devlink_trap_group_action_set(struct devlink *devlink,
67206720
struct devlink_trap_item *trap_item;
67216721
int err;
67226722

6723+
if (devlink->ops->trap_group_action_set) {
6724+
err = devlink->ops->trap_group_action_set(devlink, group_item->group,
6725+
trap_action, extack);
6726+
if (err)
6727+
return err;
6728+
6729+
list_for_each_entry(trap_item, &devlink->trap_list, list) {
6730+
if (strcmp(trap_item->group_item->group->name, group_name))
6731+
continue;
6732+
if (trap_item->action != trap_action &&
6733+
trap_item->trap->type != DEVLINK_TRAP_TYPE_DROP)
6734+
continue;
6735+
trap_item->action = trap_action;
6736+
}
6737+
6738+
return 0;
6739+
}
6740+
67236741
list_for_each_entry(trap_item, &devlink->trap_list, list) {
67246742
if (strcmp(trap_item->group_item->group->name, group_name))
67256743
continue;

0 commit comments

Comments
 (0)