diff mbox series

[net-next,2/2] devlink: warn about existing entities during reload-reinit

Message ID 20231128115255.773377-3-jiri@resnulli.us (mailing list archive)
State Accepted
Commit 9b2348e2d6c94146f50b68d7d2067146e7339ac5
Delegated to: Netdev Maintainers
Headers show
Series devlink: warn about existing entities during reload-reinit | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/codegen success Generated files up to date
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1117 this patch: 1117
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 1143 this patch: 1143
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1144 this patch: 1144
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 29 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Jiri Pirko Nov. 28, 2023, 11:52 a.m. UTC
From: Jiri Pirko <jiri@nvidia.com>

During reload-reinit, all entities except for params, resources, regions
and health reporter should be removed and re-added. Add a warning to
be triggered in case the driver behaves differently.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
 net/devlink/dev.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

Comments

Przemek Kitszel Nov. 28, 2023, 2:15 p.m. UTC | #1
On 11/28/23 12:52, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@nvidia.com>
> 
> During reload-reinit, all entities except for params, resources, regions
> and health reporter should be removed and re-added. Add a warning to
> be triggered in case the driver behaves differently.
> 
> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
> ---
>   net/devlink/dev.c | 16 +++++++++++++++-
>   1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/net/devlink/dev.c b/net/devlink/dev.c
> index ea6a92f2e6a2..918a0395b03e 100644
> --- a/net/devlink/dev.c
> +++ b/net/devlink/dev.c
> @@ -425,6 +425,18 @@ static void devlink_reload_netns_change(struct devlink *devlink,
>   	devlink_rel_nested_in_notify(devlink);
>   }
>   
> +static void devlink_reload_reinit_sanity_check(struct devlink *devlink)
> +{
> +	WARN_ON(!list_empty(&devlink->trap_policer_list));
> +	WARN_ON(!list_empty(&devlink->trap_group_list));
> +	WARN_ON(!list_empty(&devlink->trap_list));
> +	WARN_ON(!list_empty(&devlink->dpipe_table_list));
> +	WARN_ON(!list_empty(&devlink->sb_list));
> +	WARN_ON(!list_empty(&devlink->rate_list));
> +	WARN_ON(!list_empty(&devlink->linecard_list));
> +	WARN_ON(!xa_empty(&devlink->ports));
> +}
> +
>   int devlink_reload(struct devlink *devlink, struct net *dest_net,
>   		   enum devlink_reload_action action,
>   		   enum devlink_reload_limit limit,
> @@ -452,8 +464,10 @@ int devlink_reload(struct devlink *devlink, struct net *dest_net,
>   	if (dest_net && !net_eq(dest_net, curr_net))
>   		devlink_reload_netns_change(devlink, curr_net, dest_net);
>   
> -	if (action == DEVLINK_RELOAD_ACTION_DRIVER_REINIT)
> +	if (action == DEVLINK_RELOAD_ACTION_DRIVER_REINIT) {
>   		devlink_params_driverinit_load_new(devlink);
> +		devlink_reload_reinit_sanity_check(devlink);
> +	}
>   
>   	err = devlink->ops->reload_up(devlink, action, limit, actions_performed, extack);
>   	devlink_reload_failed_set(devlink, !!err);

Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
diff mbox series

Patch

diff --git a/net/devlink/dev.c b/net/devlink/dev.c
index ea6a92f2e6a2..918a0395b03e 100644
--- a/net/devlink/dev.c
+++ b/net/devlink/dev.c
@@ -425,6 +425,18 @@  static void devlink_reload_netns_change(struct devlink *devlink,
 	devlink_rel_nested_in_notify(devlink);
 }
 
+static void devlink_reload_reinit_sanity_check(struct devlink *devlink)
+{
+	WARN_ON(!list_empty(&devlink->trap_policer_list));
+	WARN_ON(!list_empty(&devlink->trap_group_list));
+	WARN_ON(!list_empty(&devlink->trap_list));
+	WARN_ON(!list_empty(&devlink->dpipe_table_list));
+	WARN_ON(!list_empty(&devlink->sb_list));
+	WARN_ON(!list_empty(&devlink->rate_list));
+	WARN_ON(!list_empty(&devlink->linecard_list));
+	WARN_ON(!xa_empty(&devlink->ports));
+}
+
 int devlink_reload(struct devlink *devlink, struct net *dest_net,
 		   enum devlink_reload_action action,
 		   enum devlink_reload_limit limit,
@@ -452,8 +464,10 @@  int devlink_reload(struct devlink *devlink, struct net *dest_net,
 	if (dest_net && !net_eq(dest_net, curr_net))
 		devlink_reload_netns_change(devlink, curr_net, dest_net);
 
-	if (action == DEVLINK_RELOAD_ACTION_DRIVER_REINIT)
+	if (action == DEVLINK_RELOAD_ACTION_DRIVER_REINIT) {
 		devlink_params_driverinit_load_new(devlink);
+		devlink_reload_reinit_sanity_check(devlink);
+	}
 
 	err = devlink->ops->reload_up(devlink, action, limit, actions_performed, extack);
 	devlink_reload_failed_set(devlink, !!err);