Lines Matching refs:devlink
73 devlink_trap_policer_item_lookup(struct devlink *devlink, u32 id) in devlink_trap_policer_item_lookup() argument
77 list_for_each_entry(policer_item, &devlink->trap_policer_list, list) { in devlink_trap_policer_item_lookup()
86 devlink_trap_item_lookup(struct devlink *devlink, const char *name) in devlink_trap_item_lookup() argument
90 list_for_each_entry(trap_item, &devlink->trap_list, list) { in devlink_trap_item_lookup()
99 devlink_trap_item_get_from_info(struct devlink *devlink, in devlink_trap_item_get_from_info() argument
108 return devlink_trap_item_lookup(devlink, nla_data(attr)); in devlink_trap_item_get_from_info()
211 static int devlink_trap_stats_put(struct sk_buff *msg, struct devlink *devlink, in devlink_trap_stats_put() argument
219 if (devlink->ops->trap_drop_counter_get) { in devlink_trap_stats_put()
220 err = devlink->ops->trap_drop_counter_get(devlink, in devlink_trap_stats_put()
233 if (devlink->ops->trap_drop_counter_get && in devlink_trap_stats_put()
257 static int devlink_nl_trap_fill(struct sk_buff *msg, struct devlink *devlink, in devlink_nl_trap_fill() argument
270 if (devlink_nl_put_handle(msg, devlink)) in devlink_nl_trap_fill()
294 err = devlink_trap_stats_put(msg, devlink, trap_item); in devlink_nl_trap_fill()
310 struct devlink *devlink = info->user_ptr[0]; in devlink_nl_trap_get_doit() local
315 if (list_empty(&devlink->trap_list)) in devlink_nl_trap_get_doit()
318 trap_item = devlink_trap_item_get_from_info(devlink, info); in devlink_nl_trap_get_doit()
328 err = devlink_nl_trap_fill(msg, devlink, trap_item, in devlink_nl_trap_get_doit()
342 struct devlink *devlink, in devlink_nl_trap_get_dump_one() argument
350 list_for_each_entry(trap_item, &devlink->trap_list, list) { in devlink_nl_trap_get_dump_one()
355 err = devlink_nl_trap_fill(msg, devlink, trap_item, in devlink_nl_trap_get_dump_one()
374 static int __devlink_trap_action_set(struct devlink *devlink, in __devlink_trap_action_set() argument
387 err = devlink->ops->trap_action_set(devlink, trap_item->trap, in __devlink_trap_action_set()
397 static int devlink_trap_action_set(struct devlink *devlink, in devlink_trap_action_set() argument
413 return __devlink_trap_action_set(devlink, trap_item, trap_action, in devlink_trap_action_set()
420 struct devlink *devlink = info->user_ptr[0]; in devlink_nl_trap_set_doit() local
423 if (list_empty(&devlink->trap_list)) in devlink_nl_trap_set_doit()
426 trap_item = devlink_trap_item_get_from_info(devlink, info); in devlink_nl_trap_set_doit()
432 return devlink_trap_action_set(devlink, trap_item, info); in devlink_nl_trap_set_doit()
436 devlink_trap_group_item_lookup(struct devlink *devlink, const char *name) in devlink_trap_group_item_lookup() argument
440 list_for_each_entry(group_item, &devlink->trap_group_list, list) { in devlink_trap_group_item_lookup()
449 devlink_trap_group_item_lookup_by_id(struct devlink *devlink, u16 id) in devlink_trap_group_item_lookup_by_id() argument
453 list_for_each_entry(group_item, &devlink->trap_group_list, list) { in devlink_trap_group_item_lookup_by_id()
462 devlink_trap_group_item_get_from_info(struct devlink *devlink, in devlink_trap_group_item_get_from_info() argument
471 return devlink_trap_group_item_lookup(devlink, name); in devlink_trap_group_item_get_from_info()
475 devlink_nl_trap_group_fill(struct sk_buff *msg, struct devlink *devlink, in devlink_nl_trap_group_fill() argument
487 if (devlink_nl_put_handle(msg, devlink)) in devlink_nl_trap_group_fill()
519 struct devlink *devlink = info->user_ptr[0]; in devlink_nl_trap_group_get_doit() local
524 if (list_empty(&devlink->trap_group_list)) in devlink_nl_trap_group_get_doit()
527 group_item = devlink_trap_group_item_get_from_info(devlink, info); in devlink_nl_trap_group_get_doit()
537 err = devlink_nl_trap_group_fill(msg, devlink, group_item, in devlink_nl_trap_group_get_doit()
551 struct devlink *devlink, in devlink_nl_trap_group_get_dump_one() argument
560 list_for_each_entry(group_item, &devlink->trap_group_list, list) { in devlink_nl_trap_group_get_dump_one()
565 err = devlink_nl_trap_group_fill(msg, devlink, group_item, in devlink_nl_trap_group_get_dump_one()
586 __devlink_trap_group_action_set(struct devlink *devlink, in __devlink_trap_group_action_set() argument
595 if (devlink->ops->trap_group_action_set) { in __devlink_trap_group_action_set()
596 err = devlink->ops->trap_group_action_set(devlink, group_item->group, in __devlink_trap_group_action_set()
601 list_for_each_entry(trap_item, &devlink->trap_list, list) { in __devlink_trap_group_action_set()
613 list_for_each_entry(trap_item, &devlink->trap_list, list) { in __devlink_trap_group_action_set()
616 err = __devlink_trap_action_set(devlink, trap_item, in __devlink_trap_group_action_set()
626 devlink_trap_group_action_set(struct devlink *devlink, in devlink_trap_group_action_set() argument
642 err = __devlink_trap_group_action_set(devlink, group_item, trap_action, in devlink_trap_group_action_set()
652 static int devlink_trap_group_set(struct devlink *devlink, in devlink_trap_group_set() argument
666 if (!devlink->ops->trap_group_set) in devlink_trap_group_set()
670 policer_item = devlink_trap_policer_item_lookup(devlink, policer_id); in devlink_trap_group_set()
677 err = devlink->ops->trap_group_set(devlink, group_item->group, policer, in devlink_trap_group_set()
690 struct devlink *devlink = info->user_ptr[0]; in devlink_nl_trap_group_set_doit() local
695 if (list_empty(&devlink->trap_group_list)) in devlink_nl_trap_group_set_doit()
698 group_item = devlink_trap_group_item_get_from_info(devlink, info); in devlink_nl_trap_group_set_doit()
704 err = devlink_trap_group_action_set(devlink, group_item, info, in devlink_nl_trap_group_set_doit()
709 err = devlink_trap_group_set(devlink, group_item, info); in devlink_nl_trap_group_set_doit()
722 devlink_trap_policer_item_get_from_info(struct devlink *devlink, in devlink_trap_policer_item_get_from_info() argument
731 return devlink_trap_policer_item_lookup(devlink, id); in devlink_trap_policer_item_get_from_info()
735 devlink_trap_policer_stats_put(struct sk_buff *msg, struct devlink *devlink, in devlink_trap_policer_stats_put() argument
742 if (!devlink->ops->trap_policer_counter_get) in devlink_trap_policer_stats_put()
745 err = devlink->ops->trap_policer_counter_get(devlink, policer, &drops); in devlink_trap_policer_stats_put()
767 devlink_nl_trap_policer_fill(struct sk_buff *msg, struct devlink *devlink, in devlink_nl_trap_policer_fill() argument
779 if (devlink_nl_put_handle(msg, devlink)) in devlink_nl_trap_policer_fill()
794 err = devlink_trap_policer_stats_put(msg, devlink, in devlink_nl_trap_policer_fill()
813 struct devlink *devlink = info->user_ptr[0]; in devlink_nl_trap_policer_get_doit() local
817 if (list_empty(&devlink->trap_policer_list)) in devlink_nl_trap_policer_get_doit()
820 policer_item = devlink_trap_policer_item_get_from_info(devlink, info); in devlink_nl_trap_policer_get_doit()
830 err = devlink_nl_trap_policer_fill(msg, devlink, policer_item, in devlink_nl_trap_policer_get_doit()
844 struct devlink *devlink, in devlink_nl_trap_policer_get_dump_one() argument
853 list_for_each_entry(policer_item, &devlink->trap_policer_list, list) { in devlink_nl_trap_policer_get_dump_one()
858 err = devlink_nl_trap_policer_fill(msg, devlink, policer_item, in devlink_nl_trap_policer_get_dump_one()
879 devlink_trap_policer_set(struct devlink *devlink, in devlink_trap_policer_set() argument
917 err = devlink->ops->trap_policer_set(devlink, policer_item->policer, in devlink_trap_policer_set()
933 struct devlink *devlink = info->user_ptr[0]; in devlink_nl_trap_policer_set_doit() local
935 if (list_empty(&devlink->trap_policer_list)) in devlink_nl_trap_policer_set_doit()
938 if (!devlink->ops->trap_policer_set) in devlink_nl_trap_policer_set_doit()
941 policer_item = devlink_trap_policer_item_get_from_info(devlink, info); in devlink_nl_trap_policer_set_doit()
947 return devlink_trap_policer_set(devlink, policer_item, info); in devlink_nl_trap_policer_set_doit()
1167 devlink_trap_group_notify(struct devlink *devlink, in devlink_trap_group_notify() argument
1177 if (!devl_is_registered(devlink) || !devlink_nl_notify_need(devlink)) in devlink_trap_group_notify()
1184 err = devlink_nl_trap_group_fill(msg, devlink, group_item, cmd, 0, 0, in devlink_trap_group_notify()
1191 devlink_nl_notify_send(devlink, msg); in devlink_trap_group_notify()
1194 void devlink_trap_groups_notify_register(struct devlink *devlink) in devlink_trap_groups_notify_register() argument
1198 list_for_each_entry(group_item, &devlink->trap_group_list, list) in devlink_trap_groups_notify_register()
1199 devlink_trap_group_notify(devlink, group_item, in devlink_trap_groups_notify_register()
1203 void devlink_trap_groups_notify_unregister(struct devlink *devlink) in devlink_trap_groups_notify_unregister() argument
1207 list_for_each_entry_reverse(group_item, &devlink->trap_group_list, list) in devlink_trap_groups_notify_unregister()
1208 devlink_trap_group_notify(devlink, group_item, in devlink_trap_groups_notify_unregister()
1213 devlink_trap_item_group_link(struct devlink *devlink, in devlink_trap_item_group_link() argument
1219 group_item = devlink_trap_group_item_lookup_by_id(devlink, group_id); in devlink_trap_item_group_link()
1228 static void devlink_trap_notify(struct devlink *devlink, in devlink_trap_notify() argument
1238 if (!devl_is_registered(devlink) || !devlink_nl_notify_need(devlink)) in devlink_trap_notify()
1245 err = devlink_nl_trap_fill(msg, devlink, trap_item, cmd, 0, 0, 0); in devlink_trap_notify()
1251 devlink_nl_notify_send(devlink, msg); in devlink_trap_notify()
1254 void devlink_traps_notify_register(struct devlink *devlink) in devlink_traps_notify_register() argument
1258 list_for_each_entry(trap_item, &devlink->trap_list, list) in devlink_traps_notify_register()
1259 devlink_trap_notify(devlink, trap_item, DEVLINK_CMD_TRAP_NEW); in devlink_traps_notify_register()
1262 void devlink_traps_notify_unregister(struct devlink *devlink) in devlink_traps_notify_unregister() argument
1266 list_for_each_entry_reverse(trap_item, &devlink->trap_list, list) in devlink_traps_notify_unregister()
1267 devlink_trap_notify(devlink, trap_item, DEVLINK_CMD_TRAP_DEL); in devlink_traps_notify_unregister()
1271 devlink_trap_register(struct devlink *devlink, in devlink_trap_register() argument
1277 if (devlink_trap_item_lookup(devlink, trap->name)) in devlink_trap_register()
1294 err = devlink_trap_item_group_link(devlink, trap_item); in devlink_trap_register()
1298 err = devlink->ops->trap_init(devlink, trap, trap_item); in devlink_trap_register()
1302 list_add_tail(&trap_item->list, &devlink->trap_list); in devlink_trap_register()
1303 devlink_trap_notify(devlink, trap_item, DEVLINK_CMD_TRAP_NEW); in devlink_trap_register()
1315 static void devlink_trap_unregister(struct devlink *devlink, in devlink_trap_unregister() argument
1320 trap_item = devlink_trap_item_lookup(devlink, trap->name); in devlink_trap_unregister()
1324 devlink_trap_notify(devlink, trap_item, DEVLINK_CMD_TRAP_DEL); in devlink_trap_unregister()
1326 if (devlink->ops->trap_fini) in devlink_trap_unregister()
1327 devlink->ops->trap_fini(devlink, trap, trap_item); in devlink_trap_unregister()
1332 static void devlink_trap_disable(struct devlink *devlink, in devlink_trap_disable() argument
1337 trap_item = devlink_trap_item_lookup(devlink, trap->name); in devlink_trap_disable()
1341 devlink->ops->trap_action_set(devlink, trap, DEVLINK_TRAP_ACTION_DROP, in devlink_trap_disable()
1355 int devl_traps_register(struct devlink *devlink, in devl_traps_register() argument
1361 if (!devlink->ops->trap_init || !devlink->ops->trap_action_set) in devl_traps_register()
1364 devl_assert_locked(devlink); in devl_traps_register()
1372 err = devlink_trap_register(devlink, trap, priv); in devl_traps_register()
1382 devlink_trap_unregister(devlink, &traps[i]); in devl_traps_register()
1398 int devlink_traps_register(struct devlink *devlink, in devlink_traps_register() argument
1404 devl_lock(devlink); in devlink_traps_register()
1405 err = devl_traps_register(devlink, traps, traps_count, priv); in devlink_traps_register()
1406 devl_unlock(devlink); in devlink_traps_register()
1417 void devl_traps_unregister(struct devlink *devlink, in devl_traps_unregister() argument
1423 devl_assert_locked(devlink); in devl_traps_unregister()
1428 devlink_trap_disable(devlink, &traps[i]); in devl_traps_unregister()
1431 devlink_trap_unregister(devlink, &traps[i]); in devl_traps_unregister()
1443 void devlink_traps_unregister(struct devlink *devlink, in devlink_traps_unregister() argument
1447 devl_lock(devlink); in devlink_traps_unregister()
1448 devl_traps_unregister(devlink, traps, traps_count); in devlink_traps_unregister()
1449 devl_unlock(devlink); in devlink_traps_unregister()
1491 void devlink_trap_report(struct devlink *devlink, struct sk_buff *skb, in devlink_trap_report() argument
1506 trace_devlink_trap_report(devlink, skb, &metadata); in devlink_trap_report()
1526 devlink_trap_group_item_policer_link(struct devlink *devlink, in devlink_trap_group_item_policer_link() argument
1535 policer_item = devlink_trap_policer_item_lookup(devlink, policer_id); in devlink_trap_group_item_policer_link()
1545 devlink_trap_group_register(struct devlink *devlink, in devlink_trap_group_register() argument
1551 if (devlink_trap_group_item_lookup(devlink, group->name)) in devlink_trap_group_register()
1566 err = devlink_trap_group_item_policer_link(devlink, group_item); in devlink_trap_group_register()
1570 if (devlink->ops->trap_group_init) { in devlink_trap_group_register()
1571 err = devlink->ops->trap_group_init(devlink, group); in devlink_trap_group_register()
1576 list_add_tail(&group_item->list, &devlink->trap_group_list); in devlink_trap_group_register()
1577 devlink_trap_group_notify(devlink, group_item, in devlink_trap_group_register()
1591 devlink_trap_group_unregister(struct devlink *devlink, in devlink_trap_group_unregister() argument
1596 group_item = devlink_trap_group_item_lookup(devlink, group->name); in devlink_trap_group_unregister()
1600 devlink_trap_group_notify(devlink, group_item, in devlink_trap_group_unregister()
1615 int devl_trap_groups_register(struct devlink *devlink, in devl_trap_groups_register() argument
1621 devl_assert_locked(devlink); in devl_trap_groups_register()
1629 err = devlink_trap_group_register(devlink, group); in devl_trap_groups_register()
1639 devlink_trap_group_unregister(devlink, &groups[i]); in devl_trap_groups_register()
1654 int devlink_trap_groups_register(struct devlink *devlink, in devlink_trap_groups_register() argument
1660 devl_lock(devlink); in devlink_trap_groups_register()
1661 err = devl_trap_groups_register(devlink, groups, groups_count); in devlink_trap_groups_register()
1662 devl_unlock(devlink); in devlink_trap_groups_register()
1673 void devl_trap_groups_unregister(struct devlink *devlink, in devl_trap_groups_unregister() argument
1679 devl_assert_locked(devlink); in devl_trap_groups_unregister()
1681 devlink_trap_group_unregister(devlink, &groups[i]); in devl_trap_groups_unregister()
1693 void devlink_trap_groups_unregister(struct devlink *devlink, in devlink_trap_groups_unregister() argument
1697 devl_lock(devlink); in devlink_trap_groups_unregister()
1698 devl_trap_groups_unregister(devlink, groups, groups_count); in devlink_trap_groups_unregister()
1699 devl_unlock(devlink); in devlink_trap_groups_unregister()
1704 devlink_trap_policer_notify(struct devlink *devlink, in devlink_trap_policer_notify() argument
1714 if (!devl_is_registered(devlink) || !devlink_nl_notify_need(devlink)) in devlink_trap_policer_notify()
1721 err = devlink_nl_trap_policer_fill(msg, devlink, policer_item, cmd, 0, in devlink_trap_policer_notify()
1728 devlink_nl_notify_send(devlink, msg); in devlink_trap_policer_notify()
1731 void devlink_trap_policers_notify_register(struct devlink *devlink) in devlink_trap_policers_notify_register() argument
1735 list_for_each_entry(policer_item, &devlink->trap_policer_list, list) in devlink_trap_policers_notify_register()
1736 devlink_trap_policer_notify(devlink, policer_item, in devlink_trap_policers_notify_register()
1740 void devlink_trap_policers_notify_unregister(struct devlink *devlink) in devlink_trap_policers_notify_unregister() argument
1744 list_for_each_entry_reverse(policer_item, &devlink->trap_policer_list, in devlink_trap_policers_notify_unregister()
1746 devlink_trap_policer_notify(devlink, policer_item, in devlink_trap_policers_notify_unregister()
1751 devlink_trap_policer_register(struct devlink *devlink, in devlink_trap_policer_register() argument
1757 if (devlink_trap_policer_item_lookup(devlink, policer->id)) in devlink_trap_policer_register()
1768 if (devlink->ops->trap_policer_init) { in devlink_trap_policer_register()
1769 err = devlink->ops->trap_policer_init(devlink, policer); in devlink_trap_policer_register()
1774 list_add_tail(&policer_item->list, &devlink->trap_policer_list); in devlink_trap_policer_register()
1775 devlink_trap_policer_notify(devlink, policer_item, in devlink_trap_policer_register()
1786 devlink_trap_policer_unregister(struct devlink *devlink, in devlink_trap_policer_unregister() argument
1791 policer_item = devlink_trap_policer_item_lookup(devlink, policer->id); in devlink_trap_policer_unregister()
1795 devlink_trap_policer_notify(devlink, policer_item, in devlink_trap_policer_unregister()
1798 if (devlink->ops->trap_policer_fini) in devlink_trap_policer_unregister()
1799 devlink->ops->trap_policer_fini(devlink, policer); in devlink_trap_policer_unregister()
1812 devl_trap_policers_register(struct devlink *devlink, in devl_trap_policers_register() argument
1818 devl_assert_locked(devlink); in devl_trap_policers_register()
1829 err = devlink_trap_policer_register(devlink, policer); in devl_trap_policers_register()
1838 devlink_trap_policer_unregister(devlink, &policers[i]); in devl_trap_policers_register()
1850 devl_trap_policers_unregister(struct devlink *devlink, in devl_trap_policers_unregister() argument
1856 devl_assert_locked(devlink); in devl_trap_policers_unregister()
1858 devlink_trap_policer_unregister(devlink, &policers[i]); in devl_trap_policers_unregister()