]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net/mlx5: E-Switch, move work queue generation counter
authorMark Bloch <mbloch@nvidia.com>
Tue, 28 Apr 2026 05:10:15 +0000 (08:10 +0300)
committerJakub Kicinski <kuba@kernel.org>
Thu, 30 Apr 2026 00:46:27 +0000 (17:46 -0700)
The generation counter in mlx5_esw_functions is used to detect stale
work items on the E-Switch work queue. Move it from mlx5_esw_functions
to the top-level mlx5_eswitch struct so it can guard all work types,
not just function-change events.

This is a mechanical refactor: no behavioral change.

Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20260428051018.219093-2-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c

index 123c96716a544de0ea7ac1716043409abb228da7..1986d4d0e886b84d8607e5b92dc3a0d66cebbd1c 100644 (file)
@@ -1075,7 +1075,7 @@ static void mlx5_eswitch_event_handler_unregister(struct mlx5_eswitch *esw)
        if (esw->mode == MLX5_ESWITCH_OFFLOADS &&
            mlx5_eswitch_is_funcs_handler(esw->dev)) {
                mlx5_eq_notifier_unregister(esw->dev, &esw->esw_funcs.nb);
-               atomic_inc(&esw->esw_funcs.generation);
+               atomic_inc(&esw->generation);
        }
 }
 
@@ -2072,6 +2072,7 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev)
        mutex_init(&esw->state_lock);
        init_rwsem(&esw->mode_lock);
        refcount_set(&esw->qos.refcnt, 0);
+       atomic_set(&esw->generation, 0);
 
        esw->enabled_vports = 0;
        esw->offloads.inline_mode = MLX5_INLINE_MODE_NONE;
index 5128f5020daec9f1e89d863b6716c3d4f41d6caa..0c3d2bdebf8c91fd9ed71d6b5705ce0cf6ddb70e 100644 (file)
@@ -340,7 +340,6 @@ struct mlx5_host_work {
 
 struct mlx5_esw_functions {
        struct mlx5_nb          nb;
-       atomic_t                generation;
        bool                    host_funcs_disabled;
        u16                     num_vfs;
        u16                     num_ec_vfs;
@@ -410,6 +409,7 @@ struct mlx5_eswitch {
        struct mlx5_devcom_comp_dev *devcom;
        u16 enabled_ipsec_vf_count;
        bool eswitch_operation_in_progress;
+       atomic_t generation;
 };
 
 void esw_offloads_disable(struct mlx5_eswitch *esw);
index a078d06f456739d66a88523f547df38e0fbd5019..b2e7294d3a5c29ed3deef30a0d5a0844afc328be 100644 (file)
@@ -3667,7 +3667,7 @@ esw_vfs_changed_event_handler(struct mlx5_eswitch *esw, int work_gen,
        devl_lock(devlink);
 
        /* Stale work from one or more mode changes ago. Bail out. */
-       if (work_gen != atomic_read(&esw->esw_funcs.generation))
+       if (work_gen != atomic_read(&esw->generation))
                goto unlock;
 
        new_num_vfs = MLX5_GET(query_esw_functions_out, out,
@@ -3729,7 +3729,7 @@ int mlx5_esw_funcs_changed_handler(struct notifier_block *nb, unsigned long type
        esw = container_of(esw_funcs, struct mlx5_eswitch, esw_funcs);
 
        host_work->esw = esw;
-       host_work->work_gen = atomic_read(&esw_funcs->generation);
+       host_work->work_gen = atomic_read(&esw->generation);
 
        INIT_WORK(&host_work->work, esw_functions_changed_event_handler);
        queue_work(esw->work_queue, &host_work->work);