Lines Matching refs:devlink
46 devlink_reload_action_is_supported(struct devlink *devlink, enum devlink_reload_action action) in devlink_reload_action_is_supported() argument
48 return test_bit(action, &devlink->ops->reload_actions); in devlink_reload_action_is_supported()
52 devlink_reload_limit_is_supported(struct devlink *devlink, enum devlink_reload_limit limit) in devlink_reload_limit_is_supported() argument
54 return test_bit(limit, &devlink->ops->reload_limits); in devlink_reload_limit_is_supported()
78 devlink_reload_stats_put(struct sk_buff *msg, struct devlink *devlink, bool is_remote) in devlink_reload_stats_put() argument
94 !devlink_reload_action_is_supported(devlink, i)) || in devlink_reload_stats_put()
114 !devlink_reload_limit_is_supported(devlink, j)) || in devlink_reload_stats_put()
120 value = devlink->stats.reload_stats[stat_idx]; in devlink_reload_stats_put()
122 value = devlink->stats.remote_reload_stats[stat_idx]; in devlink_reload_stats_put()
141 static int devlink_nl_fill(struct sk_buff *msg, struct devlink *devlink, in devlink_nl_fill() argument
152 if (devlink_nl_put_handle(msg, devlink)) in devlink_nl_fill()
154 if (nla_put_u8(msg, DEVLINK_ATTR_RELOAD_FAILED, devlink->reload_failed)) in devlink_nl_fill()
161 if (devlink_reload_stats_put(msg, devlink, false)) in devlink_nl_fill()
163 if (devlink_reload_stats_put(msg, devlink, true)) in devlink_nl_fill()
177 static void devlink_notify(struct devlink *devlink, enum devlink_command cmd) in devlink_notify() argument
183 WARN_ON(!xa_get_mark(&devlinks, devlink->index, DEVLINK_REGISTERED)); in devlink_notify()
189 err = devlink_nl_fill(msg, devlink, cmd, 0, 0, 0); in devlink_notify()
195 genlmsg_multicast_netns(&devlink_nl_family, devlink_net(devlink), in devlink_notify()
201 struct devlink *devlink = info->user_ptr[0]; in devlink_nl_get_doit() local
209 err = devlink_nl_fill(msg, devlink, DEVLINK_CMD_NEW, in devlink_nl_get_doit()
220 devlink_nl_get_dump_one(struct sk_buff *msg, struct devlink *devlink, in devlink_nl_get_dump_one() argument
223 return devlink_nl_fill(msg, devlink, DEVLINK_CMD_NEW, in devlink_nl_get_dump_one()
233 void devlink_notify_register(struct devlink *devlink) in devlink_notify_register() argument
235 devlink_notify(devlink, DEVLINK_CMD_NEW); in devlink_notify_register()
236 devlink_linecards_notify_register(devlink); in devlink_notify_register()
237 devlink_ports_notify_register(devlink); in devlink_notify_register()
238 devlink_trap_policers_notify_register(devlink); in devlink_notify_register()
239 devlink_trap_groups_notify_register(devlink); in devlink_notify_register()
240 devlink_traps_notify_register(devlink); in devlink_notify_register()
241 devlink_rates_notify_register(devlink); in devlink_notify_register()
242 devlink_regions_notify_register(devlink); in devlink_notify_register()
243 devlink_params_notify_register(devlink); in devlink_notify_register()
246 void devlink_notify_unregister(struct devlink *devlink) in devlink_notify_unregister() argument
248 devlink_params_notify_unregister(devlink); in devlink_notify_unregister()
249 devlink_regions_notify_unregister(devlink); in devlink_notify_unregister()
250 devlink_rates_notify_unregister(devlink); in devlink_notify_unregister()
251 devlink_traps_notify_unregister(devlink); in devlink_notify_unregister()
252 devlink_trap_groups_notify_unregister(devlink); in devlink_notify_unregister()
253 devlink_trap_policers_notify_unregister(devlink); in devlink_notify_unregister()
254 devlink_ports_notify_unregister(devlink); in devlink_notify_unregister()
255 devlink_linecards_notify_unregister(devlink); in devlink_notify_unregister()
256 devlink_notify(devlink, DEVLINK_CMD_DEL); in devlink_notify_unregister()
259 static void devlink_reload_failed_set(struct devlink *devlink, in devlink_reload_failed_set() argument
262 if (devlink->reload_failed == reload_failed) in devlink_reload_failed_set()
264 devlink->reload_failed = reload_failed; in devlink_reload_failed_set()
265 devlink_notify(devlink, DEVLINK_CMD_NEW); in devlink_reload_failed_set()
268 bool devlink_is_reload_failed(const struct devlink *devlink) in devlink_is_reload_failed() argument
270 return devlink->reload_failed; in devlink_is_reload_failed()
275 __devlink_reload_stats_update(struct devlink *devlink, u32 *reload_stats, in __devlink_reload_stats_update() argument
286 devlink_notify(devlink, DEVLINK_CMD_NEW); in __devlink_reload_stats_update()
290 devlink_reload_stats_update(struct devlink *devlink, enum devlink_reload_limit limit, in devlink_reload_stats_update() argument
293 __devlink_reload_stats_update(devlink, devlink->stats.reload_stats, limit, in devlink_reload_stats_update()
311 void devlink_remote_reload_actions_performed(struct devlink *devlink, in devlink_remote_reload_actions_performed() argument
321 __devlink_reload_stats_update(devlink, devlink->stats.remote_reload_stats, limit, in devlink_remote_reload_actions_performed()
363 static void devlink_reload_netns_change(struct devlink *devlink, in devlink_reload_netns_change() argument
372 devlink_notify_unregister(devlink); in devlink_reload_netns_change()
373 write_pnet(&devlink->_net, dest_net); in devlink_reload_netns_change()
374 devlink_notify_register(devlink); in devlink_reload_netns_change()
377 int devlink_reload(struct devlink *devlink, struct net *dest_net, in devlink_reload() argument
386 memcpy(remote_reload_stats, devlink->stats.remote_reload_stats, in devlink_reload()
389 err = devlink->ops->reload_down(devlink, !!dest_net, action, limit, extack); in devlink_reload()
393 curr_net = devlink_net(devlink); in devlink_reload()
395 devlink_reload_netns_change(devlink, curr_net, dest_net); in devlink_reload()
398 devlink_params_driverinit_load_new(devlink); in devlink_reload()
400 err = devlink->ops->reload_up(devlink, action, limit, actions_performed, extack); in devlink_reload()
401 devlink_reload_failed_set(devlink, !!err); in devlink_reload()
407 WARN_ON(memcmp(remote_reload_stats, devlink->stats.remote_reload_stats, in devlink_reload()
409 devlink_reload_stats_update(devlink, limit, *actions_performed); in devlink_reload()
414 devlink_nl_reload_actions_performed_snd(struct devlink *devlink, u32 actions_performed, in devlink_nl_reload_actions_performed_snd() argument
428 if (devlink_nl_put_handle(msg, devlink)) in devlink_nl_reload_actions_performed_snd()
447 struct devlink *devlink = info->user_ptr[0]; in devlink_nl_cmd_reload() local
454 err = devlink_resources_validate(devlink, NULL, info); in devlink_nl_cmd_reload()
465 if (!devlink_reload_action_is_supported(devlink, action)) { in devlink_nl_cmd_reload()
489 if (!devlink_reload_limit_is_supported(devlink, limit)) { in devlink_nl_cmd_reload()
504 if (!net_eq(dest_net, devlink_net(devlink)) && in devlink_nl_cmd_reload()
512 err = devlink_reload(devlink, dest_net, action, limit, &actions_performed, info->extack); in devlink_nl_cmd_reload()
523 return devlink_nl_reload_actions_performed_snd(devlink, actions_performed, in devlink_nl_cmd_reload()
556 static int devlink_nl_eswitch_fill(struct sk_buff *msg, struct devlink *devlink, in devlink_nl_eswitch_fill() argument
560 const struct devlink_ops *ops = devlink->ops; in devlink_nl_eswitch_fill()
571 err = devlink_nl_put_handle(msg, devlink); in devlink_nl_eswitch_fill()
576 err = ops->eswitch_mode_get(devlink, &mode); in devlink_nl_eswitch_fill()
585 err = ops->eswitch_inline_mode_get(devlink, &inline_mode); in devlink_nl_eswitch_fill()
595 err = ops->eswitch_encap_mode_get(devlink, &encap_mode); in devlink_nl_eswitch_fill()
613 struct devlink *devlink = info->user_ptr[0]; in devlink_nl_cmd_eswitch_get_doit() local
621 err = devlink_nl_eswitch_fill(msg, devlink, DEVLINK_CMD_ESWITCH_GET, in devlink_nl_cmd_eswitch_get_doit()
634 struct devlink *devlink = info->user_ptr[0]; in devlink_nl_cmd_eswitch_set_doit() local
635 const struct devlink_ops *ops = devlink->ops; in devlink_nl_cmd_eswitch_set_doit()
645 err = devlink_rate_nodes_check(devlink, mode, info->extack); in devlink_nl_cmd_eswitch_set_doit()
648 err = ops->eswitch_mode_set(devlink, mode, info->extack); in devlink_nl_cmd_eswitch_set_doit()
657 err = ops->eswitch_inline_mode_set(devlink, inline_mode, in devlink_nl_cmd_eswitch_set_doit()
667 err = ops->eswitch_encap_mode_set(devlink, encap_mode, in devlink_nl_cmd_eswitch_set_doit()
798 devlink_nl_info_fill(struct sk_buff *msg, struct devlink *devlink, in devlink_nl_info_fill() argument
802 struct device *dev = devlink_to_dev(devlink); in devlink_nl_info_fill()
812 if (devlink_nl_put_handle(msg, devlink)) in devlink_nl_info_fill()
816 if (devlink->ops->info_get) { in devlink_nl_info_fill()
817 err = devlink->ops->info_get(devlink, &req, extack); in devlink_nl_info_fill()
836 struct devlink *devlink = info->user_ptr[0]; in devlink_nl_info_get_doit() local
844 err = devlink_nl_info_fill(msg, devlink, DEVLINK_CMD_INFO_GET, in devlink_nl_info_get_doit()
856 devlink_nl_info_get_dump_one(struct sk_buff *msg, struct devlink *devlink, in devlink_nl_info_get_dump_one() argument
861 err = devlink_nl_info_fill(msg, devlink, DEVLINK_CMD_INFO_GET, in devlink_nl_info_get_dump_one()
876 struct devlink *devlink, in devlink_nl_flash_update_fill() argument
886 if (devlink_nl_put_handle(msg, devlink)) in devlink_nl_flash_update_fill()
919 static void __devlink_flash_update_notify(struct devlink *devlink, in __devlink_flash_update_notify() argument
930 if (!xa_get_mark(&devlinks, devlink->index, DEVLINK_REGISTERED)) in __devlink_flash_update_notify()
937 err = devlink_nl_flash_update_fill(msg, devlink, cmd, params); in __devlink_flash_update_notify()
941 genlmsg_multicast_netns(&devlink_nl_family, devlink_net(devlink), in __devlink_flash_update_notify()
949 static void devlink_flash_update_begin_notify(struct devlink *devlink) in devlink_flash_update_begin_notify() argument
953 __devlink_flash_update_notify(devlink, in devlink_flash_update_begin_notify()
958 static void devlink_flash_update_end_notify(struct devlink *devlink) in devlink_flash_update_end_notify() argument
962 __devlink_flash_update_notify(devlink, in devlink_flash_update_end_notify()
967 void devlink_flash_update_status_notify(struct devlink *devlink, in devlink_flash_update_status_notify() argument
980 __devlink_flash_update_notify(devlink, in devlink_flash_update_status_notify()
986 void devlink_flash_update_timeout_notify(struct devlink *devlink, in devlink_flash_update_timeout_notify() argument
997 __devlink_flash_update_notify(devlink, in devlink_flash_update_timeout_notify()
1023 static int devlink_flash_component_get(struct devlink *devlink, in devlink_flash_component_get() argument
1038 if (!devlink->ops->info_get) { in devlink_flash_component_get()
1048 ret = devlink->ops->info_get(devlink, &req, NULL); in devlink_flash_component_get()
1065 struct devlink *devlink = info->user_ptr[0]; in devlink_nl_cmd_flash_update() local
1070 if (!devlink->ops->flash_update) in devlink_nl_cmd_flash_update()
1076 ret = devlink_flash_component_get(devlink, in devlink_nl_cmd_flash_update()
1082 supported_params = devlink->ops->supported_flash_update_params; in devlink_nl_cmd_flash_update()
1099 ret = request_firmware(¶ms.fw, file_name, devlink->dev); in devlink_nl_cmd_flash_update()
1106 devlink_flash_update_begin_notify(devlink); in devlink_nl_cmd_flash_update()
1107 ret = devlink->ops->flash_update(devlink, ¶ms, info->extack); in devlink_nl_cmd_flash_update()
1108 devlink_flash_update_end_notify(devlink); in devlink_nl_cmd_flash_update()
1115 static void __devlink_compat_running_version(struct devlink *devlink, in __devlink_compat_running_version() argument
1128 err = devlink->ops->info_get(devlink, &req, NULL); in __devlink_compat_running_version()
1151 void devlink_compat_running_version(struct devlink *devlink, in devlink_compat_running_version() argument
1154 if (!devlink->ops->info_get) in devlink_compat_running_version()
1157 devl_lock(devlink); in devlink_compat_running_version()
1158 if (devl_is_registered(devlink)) in devlink_compat_running_version()
1159 __devlink_compat_running_version(devlink, buf, len); in devlink_compat_running_version()
1160 devl_unlock(devlink); in devlink_compat_running_version()
1163 int devlink_compat_flash_update(struct devlink *devlink, const char *file_name) in devlink_compat_flash_update() argument
1168 devl_lock(devlink); in devlink_compat_flash_update()
1169 if (!devl_is_registered(devlink)) { in devlink_compat_flash_update()
1174 if (!devlink->ops->flash_update) { in devlink_compat_flash_update()
1179 ret = request_firmware(¶ms.fw, file_name, devlink->dev); in devlink_compat_flash_update()
1183 devlink_flash_update_begin_notify(devlink); in devlink_compat_flash_update()
1184 ret = devlink->ops->flash_update(devlink, ¶ms, NULL); in devlink_compat_flash_update()
1185 devlink_flash_update_end_notify(devlink); in devlink_compat_flash_update()
1189 devl_unlock(devlink); in devlink_compat_flash_update()
1195 devlink_nl_selftests_fill(struct sk_buff *msg, struct devlink *devlink, in devlink_nl_selftests_fill() argument
1210 if (devlink_nl_put_handle(msg, devlink)) in devlink_nl_selftests_fill()
1219 if (devlink->ops->selftest_check(devlink, i, extack)) { in devlink_nl_selftests_fill()
1237 struct devlink *devlink = info->user_ptr[0]; in devlink_nl_selftests_get_doit() local
1241 if (!devlink->ops->selftest_check) in devlink_nl_selftests_get_doit()
1248 err = devlink_nl_selftests_fill(msg, devlink, info->snd_portid, in devlink_nl_selftests_get_doit()
1259 struct devlink *devlink, in devlink_nl_selftests_get_dump_one() argument
1263 if (!devlink->ops->selftest_check) in devlink_nl_selftests_get_dump_one()
1266 return devlink_nl_selftests_fill(msg, devlink, in devlink_nl_selftests_get_dump_one()
1307 struct devlink *devlink = info->user_ptr[0]; in devlink_nl_cmd_selftests_run() local
1314 if (!devlink->ops->selftest_run || !devlink->ops->selftest_check) in devlink_nl_cmd_selftests_run()
1337 if (devlink_nl_put_handle(msg, devlink)) in devlink_nl_cmd_selftests_run()
1349 if (!devlink->ops->selftest_check(devlink, i, in devlink_nl_cmd_selftests_run()
1357 test_status = devlink->ops->selftest_run(devlink, i, in devlink_nl_cmd_selftests_run()