Lines Matching refs:devlink
47 devlink_reload_action_is_supported(struct devlink *devlink, enum devlink_reload_action action) in devlink_reload_action_is_supported() argument
49 return test_bit(action, &devlink->ops->reload_actions); in devlink_reload_action_is_supported()
53 devlink_reload_limit_is_supported(struct devlink *devlink, enum devlink_reload_limit limit) in devlink_reload_limit_is_supported() argument
55 return test_bit(limit, &devlink->ops->reload_limits); in devlink_reload_limit_is_supported()
79 devlink_reload_stats_put(struct sk_buff *msg, struct devlink *devlink, bool is_remote) in devlink_reload_stats_put() argument
95 !devlink_reload_action_is_supported(devlink, i)) || in devlink_reload_stats_put()
115 !devlink_reload_limit_is_supported(devlink, j)) || in devlink_reload_stats_put()
121 value = devlink->stats.reload_stats[stat_idx]; in devlink_reload_stats_put()
123 value = devlink->stats.remote_reload_stats[stat_idx]; in devlink_reload_stats_put()
142 static int devlink_nl_nested_fill(struct sk_buff *msg, struct devlink *devlink) in devlink_nl_nested_fill() argument
148 xa_for_each(&devlink->nested_rels, rel_index, unused) { in devlink_nl_nested_fill()
149 err = devlink_rel_devlink_handle_put(msg, devlink, in devlink_nl_nested_fill()
159 static int devlink_nl_fill(struct sk_buff *msg, struct devlink *devlink, in devlink_nl_fill() argument
170 if (devlink_nl_put_handle(msg, devlink)) in devlink_nl_fill()
172 if (nla_put_u8(msg, DEVLINK_ATTR_RELOAD_FAILED, devlink->reload_failed)) in devlink_nl_fill()
179 if (devlink_reload_stats_put(msg, devlink, false)) in devlink_nl_fill()
181 if (devlink_reload_stats_put(msg, devlink, true)) in devlink_nl_fill()
186 if (devlink_nl_nested_fill(msg, devlink)) in devlink_nl_fill()
199 static void devlink_notify(struct devlink *devlink, enum devlink_command cmd) in devlink_notify() argument
205 WARN_ON(!devl_is_registered(devlink)); in devlink_notify()
207 if (!devlink_nl_notify_need(devlink)) in devlink_notify()
214 err = devlink_nl_fill(msg, devlink, cmd, 0, 0, 0); in devlink_notify()
220 devlink_nl_notify_send(devlink, msg); in devlink_notify()
225 struct devlink *devlink = info->user_ptr[0]; in devlink_nl_get_doit() local
233 err = devlink_nl_fill(msg, devlink, DEVLINK_CMD_NEW, in devlink_nl_get_doit()
244 devlink_nl_get_dump_one(struct sk_buff *msg, struct devlink *devlink, in devlink_nl_get_dump_one() argument
247 return devlink_nl_fill(msg, devlink, DEVLINK_CMD_NEW, in devlink_nl_get_dump_one()
257 static void devlink_rel_notify_cb(struct devlink *devlink, u32 obj_index) in devlink_rel_notify_cb() argument
259 devlink_notify(devlink, DEVLINK_CMD_NEW); in devlink_rel_notify_cb()
262 static void devlink_rel_cleanup_cb(struct devlink *devlink, u32 obj_index, in devlink_rel_cleanup_cb() argument
265 xa_erase(&devlink->nested_rels, rel_index); in devlink_rel_cleanup_cb()
268 int devl_nested_devlink_set(struct devlink *devlink, in devl_nested_devlink_set() argument
269 struct devlink *nested_devlink) in devl_nested_devlink_set()
274 err = devlink_rel_nested_in_add(&rel_index, devlink->index, 0, in devl_nested_devlink_set()
280 return xa_insert(&devlink->nested_rels, rel_index, in devl_nested_devlink_set()
285 void devlink_notify_register(struct devlink *devlink) in devlink_notify_register() argument
287 devlink_notify(devlink, DEVLINK_CMD_NEW); in devlink_notify_register()
288 devlink_linecards_notify_register(devlink); in devlink_notify_register()
289 devlink_ports_notify_register(devlink); in devlink_notify_register()
290 devlink_trap_policers_notify_register(devlink); in devlink_notify_register()
291 devlink_trap_groups_notify_register(devlink); in devlink_notify_register()
292 devlink_traps_notify_register(devlink); in devlink_notify_register()
293 devlink_rates_notify_register(devlink); in devlink_notify_register()
294 devlink_regions_notify_register(devlink); in devlink_notify_register()
295 devlink_params_notify_register(devlink); in devlink_notify_register()
298 void devlink_notify_unregister(struct devlink *devlink) in devlink_notify_unregister() argument
300 devlink_params_notify_unregister(devlink); in devlink_notify_unregister()
301 devlink_regions_notify_unregister(devlink); in devlink_notify_unregister()
302 devlink_rates_notify_unregister(devlink); in devlink_notify_unregister()
303 devlink_traps_notify_unregister(devlink); in devlink_notify_unregister()
304 devlink_trap_groups_notify_unregister(devlink); in devlink_notify_unregister()
305 devlink_trap_policers_notify_unregister(devlink); in devlink_notify_unregister()
306 devlink_ports_notify_unregister(devlink); in devlink_notify_unregister()
307 devlink_linecards_notify_unregister(devlink); in devlink_notify_unregister()
308 devlink_notify(devlink, DEVLINK_CMD_DEL); in devlink_notify_unregister()
311 static void devlink_reload_failed_set(struct devlink *devlink, in devlink_reload_failed_set() argument
314 if (devlink->reload_failed == reload_failed) in devlink_reload_failed_set()
316 devlink->reload_failed = reload_failed; in devlink_reload_failed_set()
317 devlink_notify(devlink, DEVLINK_CMD_NEW); in devlink_reload_failed_set()
320 bool devlink_is_reload_failed(const struct devlink *devlink) in devlink_is_reload_failed() argument
322 return devlink->reload_failed; in devlink_is_reload_failed()
327 __devlink_reload_stats_update(struct devlink *devlink, u32 *reload_stats, in __devlink_reload_stats_update() argument
338 devlink_notify(devlink, DEVLINK_CMD_NEW); in __devlink_reload_stats_update()
342 devlink_reload_stats_update(struct devlink *devlink, enum devlink_reload_limit limit, in devlink_reload_stats_update() argument
345 __devlink_reload_stats_update(devlink, devlink->stats.reload_stats, limit, in devlink_reload_stats_update()
363 void devlink_remote_reload_actions_performed(struct devlink *devlink, in devlink_remote_reload_actions_performed() argument
373 __devlink_reload_stats_update(devlink, devlink->stats.remote_reload_stats, limit, in devlink_remote_reload_actions_performed()
415 static void devlink_reload_netns_change(struct devlink *devlink, in devlink_reload_netns_change() argument
424 devlink_notify_unregister(devlink); in devlink_reload_netns_change()
425 write_pnet(&devlink->_net, dest_net); in devlink_reload_netns_change()
426 devlink_notify_register(devlink); in devlink_reload_netns_change()
427 devlink_rel_nested_in_notify(devlink); in devlink_reload_netns_change()
430 static void devlink_reload_reinit_sanity_check(struct devlink *devlink) in devlink_reload_reinit_sanity_check() argument
432 WARN_ON(!list_empty(&devlink->trap_policer_list)); in devlink_reload_reinit_sanity_check()
433 WARN_ON(!list_empty(&devlink->trap_group_list)); in devlink_reload_reinit_sanity_check()
434 WARN_ON(!list_empty(&devlink->trap_list)); in devlink_reload_reinit_sanity_check()
435 WARN_ON(!list_empty(&devlink->dpipe_table_list)); in devlink_reload_reinit_sanity_check()
436 WARN_ON(!list_empty(&devlink->sb_list)); in devlink_reload_reinit_sanity_check()
437 WARN_ON(!list_empty(&devlink->rate_list)); in devlink_reload_reinit_sanity_check()
438 WARN_ON(!list_empty(&devlink->linecard_list)); in devlink_reload_reinit_sanity_check()
439 WARN_ON(!xa_empty(&devlink->ports)); in devlink_reload_reinit_sanity_check()
442 int devlink_reload(struct devlink *devlink, struct net *dest_net, in devlink_reload() argument
456 device_lock_assert(devlink->dev); in devlink_reload()
458 memcpy(remote_reload_stats, devlink->stats.remote_reload_stats, in devlink_reload()
461 err = devlink->ops->reload_down(devlink, !!dest_net, action, limit, extack); in devlink_reload()
465 curr_net = devlink_net(devlink); in devlink_reload()
467 devlink_reload_netns_change(devlink, curr_net, dest_net); in devlink_reload()
470 devlink_params_driverinit_load_new(devlink); in devlink_reload()
471 devlink_reload_reinit_sanity_check(devlink); in devlink_reload()
474 err = devlink->ops->reload_up(devlink, action, limit, actions_performed, extack); in devlink_reload()
475 devlink_reload_failed_set(devlink, !!err); in devlink_reload()
481 WARN_ON(memcmp(remote_reload_stats, devlink->stats.remote_reload_stats, in devlink_reload()
483 devlink_reload_stats_update(devlink, limit, *actions_performed); in devlink_reload()
488 devlink_nl_reload_actions_performed_snd(struct devlink *devlink, u32 actions_performed, in devlink_nl_reload_actions_performed_snd() argument
502 if (devlink_nl_put_handle(msg, devlink)) in devlink_nl_reload_actions_performed_snd()
521 struct devlink *devlink = info->user_ptr[0]; in devlink_nl_reload_doit() local
528 err = devlink_resources_validate(devlink, NULL, info); in devlink_nl_reload_doit()
539 if (!devlink_reload_action_is_supported(devlink, action)) { in devlink_nl_reload_doit()
563 if (!devlink_reload_limit_is_supported(devlink, limit)) { in devlink_nl_reload_doit()
578 if (!net_eq(dest_net, devlink_net(devlink)) && in devlink_nl_reload_doit()
586 err = devlink_reload(devlink, dest_net, action, limit, &actions_performed, info->extack); in devlink_nl_reload_doit()
597 return devlink_nl_reload_actions_performed_snd(devlink, actions_performed, in devlink_nl_reload_doit()
630 static int devlink_nl_eswitch_fill(struct sk_buff *msg, struct devlink *devlink, in devlink_nl_eswitch_fill() argument
634 const struct devlink_ops *ops = devlink->ops; in devlink_nl_eswitch_fill()
645 err = devlink_nl_put_handle(msg, devlink); in devlink_nl_eswitch_fill()
650 err = ops->eswitch_mode_get(devlink, &mode); in devlink_nl_eswitch_fill()
659 err = ops->eswitch_inline_mode_get(devlink, &inline_mode); in devlink_nl_eswitch_fill()
669 err = ops->eswitch_encap_mode_get(devlink, &encap_mode); in devlink_nl_eswitch_fill()
687 struct devlink *devlink = info->user_ptr[0]; in devlink_nl_eswitch_get_doit() local
695 err = devlink_nl_eswitch_fill(msg, devlink, DEVLINK_CMD_ESWITCH_GET, in devlink_nl_eswitch_get_doit()
708 struct devlink *devlink = info->user_ptr[0]; in devlink_nl_eswitch_set_doit() local
709 const struct devlink_ops *ops = devlink->ops; in devlink_nl_eswitch_set_doit()
719 err = devlink_rate_nodes_check(devlink, mode, info->extack); in devlink_nl_eswitch_set_doit()
722 err = ops->eswitch_mode_set(devlink, mode, info->extack); in devlink_nl_eswitch_set_doit()
731 err = ops->eswitch_inline_mode_set(devlink, inline_mode, in devlink_nl_eswitch_set_doit()
741 err = ops->eswitch_encap_mode_set(devlink, encap_mode, in devlink_nl_eswitch_set_doit()
872 devlink_nl_info_fill(struct sk_buff *msg, struct devlink *devlink, in devlink_nl_info_fill() argument
876 struct device *dev = devlink_to_dev(devlink); in devlink_nl_info_fill()
886 if (devlink_nl_put_handle(msg, devlink)) in devlink_nl_info_fill()
890 if (devlink->ops->info_get) { in devlink_nl_info_fill()
891 err = devlink->ops->info_get(devlink, &req, extack); in devlink_nl_info_fill()
910 struct devlink *devlink = info->user_ptr[0]; in devlink_nl_info_get_doit() local
918 err = devlink_nl_info_fill(msg, devlink, DEVLINK_CMD_INFO_GET, in devlink_nl_info_get_doit()
930 devlink_nl_info_get_dump_one(struct sk_buff *msg, struct devlink *devlink, in devlink_nl_info_get_dump_one() argument
935 err = devlink_nl_info_fill(msg, devlink, DEVLINK_CMD_INFO_GET, in devlink_nl_info_get_dump_one()
950 struct devlink *devlink, in devlink_nl_flash_update_fill() argument
960 if (devlink_nl_put_handle(msg, devlink)) in devlink_nl_flash_update_fill()
993 static void __devlink_flash_update_notify(struct devlink *devlink, in __devlink_flash_update_notify() argument
1004 if (!devl_is_registered(devlink) || !devlink_nl_notify_need(devlink)) in __devlink_flash_update_notify()
1011 err = devlink_nl_flash_update_fill(msg, devlink, cmd, params); in __devlink_flash_update_notify()
1015 devlink_nl_notify_send(devlink, msg); in __devlink_flash_update_notify()
1022 static void devlink_flash_update_begin_notify(struct devlink *devlink) in devlink_flash_update_begin_notify() argument
1026 __devlink_flash_update_notify(devlink, in devlink_flash_update_begin_notify()
1031 static void devlink_flash_update_end_notify(struct devlink *devlink) in devlink_flash_update_end_notify() argument
1035 __devlink_flash_update_notify(devlink, in devlink_flash_update_end_notify()
1040 void devlink_flash_update_status_notify(struct devlink *devlink, in devlink_flash_update_status_notify() argument
1053 __devlink_flash_update_notify(devlink, in devlink_flash_update_status_notify()
1059 void devlink_flash_update_timeout_notify(struct devlink *devlink, in devlink_flash_update_timeout_notify() argument
1070 __devlink_flash_update_notify(devlink, in devlink_flash_update_timeout_notify()
1096 static int devlink_flash_component_get(struct devlink *devlink, in devlink_flash_component_get() argument
1111 if (!devlink->ops->info_get) { in devlink_flash_component_get()
1121 ret = devlink->ops->info_get(devlink, &req, NULL); in devlink_flash_component_get()
1138 struct devlink *devlink = info->user_ptr[0]; in devlink_nl_flash_update_doit() local
1143 if (!devlink->ops->flash_update) in devlink_nl_flash_update_doit()
1149 ret = devlink_flash_component_get(devlink, in devlink_nl_flash_update_doit()
1155 supported_params = devlink->ops->supported_flash_update_params; in devlink_nl_flash_update_doit()
1172 ret = request_firmware(¶ms.fw, file_name, devlink->dev); in devlink_nl_flash_update_doit()
1179 devlink_flash_update_begin_notify(devlink); in devlink_nl_flash_update_doit()
1180 ret = devlink->ops->flash_update(devlink, ¶ms, info->extack); in devlink_nl_flash_update_doit()
1181 devlink_flash_update_end_notify(devlink); in devlink_nl_flash_update_doit()
1188 static void __devlink_compat_running_version(struct devlink *devlink, in __devlink_compat_running_version() argument
1201 err = devlink->ops->info_get(devlink, &req, NULL); in __devlink_compat_running_version()
1220 void devlink_compat_running_version(struct devlink *devlink, in devlink_compat_running_version() argument
1223 if (!devlink->ops->info_get) in devlink_compat_running_version()
1226 devl_lock(devlink); in devlink_compat_running_version()
1227 if (devl_is_registered(devlink)) in devlink_compat_running_version()
1228 __devlink_compat_running_version(devlink, buf, len); in devlink_compat_running_version()
1229 devl_unlock(devlink); in devlink_compat_running_version()
1232 int devlink_compat_flash_update(struct devlink *devlink, const char *file_name) in devlink_compat_flash_update() argument
1237 devl_lock(devlink); in devlink_compat_flash_update()
1238 if (!devl_is_registered(devlink)) { in devlink_compat_flash_update()
1243 if (!devlink->ops->flash_update) { in devlink_compat_flash_update()
1248 ret = request_firmware(¶ms.fw, file_name, devlink->dev); in devlink_compat_flash_update()
1252 devlink_flash_update_begin_notify(devlink); in devlink_compat_flash_update()
1253 ret = devlink->ops->flash_update(devlink, ¶ms, NULL); in devlink_compat_flash_update()
1254 devlink_flash_update_end_notify(devlink); in devlink_compat_flash_update()
1258 devl_unlock(devlink); in devlink_compat_flash_update()
1264 devlink_nl_selftests_fill(struct sk_buff *msg, struct devlink *devlink, in devlink_nl_selftests_fill() argument
1279 if (devlink_nl_put_handle(msg, devlink)) in devlink_nl_selftests_fill()
1288 if (devlink->ops->selftest_check(devlink, i, extack)) { in devlink_nl_selftests_fill()
1306 struct devlink *devlink = info->user_ptr[0]; in devlink_nl_selftests_get_doit() local
1310 if (!devlink->ops->selftest_check) in devlink_nl_selftests_get_doit()
1317 err = devlink_nl_selftests_fill(msg, devlink, info->snd_portid, in devlink_nl_selftests_get_doit()
1328 struct devlink *devlink, in devlink_nl_selftests_get_dump_one() argument
1332 if (!devlink->ops->selftest_check) in devlink_nl_selftests_get_dump_one()
1335 return devlink_nl_selftests_fill(msg, devlink, in devlink_nl_selftests_get_dump_one()
1376 struct devlink *devlink = info->user_ptr[0]; in devlink_nl_selftests_run_doit() local
1383 if (!devlink->ops->selftest_run || !devlink->ops->selftest_check) in devlink_nl_selftests_run_doit()
1406 if (devlink_nl_put_handle(msg, devlink)) in devlink_nl_selftests_run_doit()
1418 if (!devlink->ops->selftest_check(devlink, i, in devlink_nl_selftests_run_doit()
1426 test_status = devlink->ops->selftest_run(devlink, i, in devlink_nl_selftests_run_doit()