net/mlx5: fix shared RSS destruction
authorDmitry Kozlyuk <dkozlyuk@nvidia.com>
Wed, 1 Sep 2021 08:07:52 +0000 (11:07 +0300)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 21 Sep 2021 08:06:11 +0000 (10:06 +0200)
Shared RSS resources were released before checking that the shared RSS
has no more references. If it had, the destruction was aborted, leaving
the shared RSS in an invalid state where it could no longer be used.
Move reference counter check before resource release.

Fixes: d2046c09aa64 ("net/mlx5: support shared action for RSS")
Cc: stable@dpdk.org
Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
drivers/net/mlx5/mlx5_flow_dv.c

index 626513c..15ca5cd 100644 (file)
@@ -14761,12 +14761,6 @@ __flow_dv_action_rss_release(struct rte_eth_dev *dev, uint32_t idx,
                return rte_flow_error_set(error, EINVAL,
                                          RTE_FLOW_ERROR_TYPE_ACTION, NULL,
                                          "invalid shared action");
-       remaining = __flow_dv_action_rss_hrxqs_release(dev, shared_rss);
-       if (remaining)
-               return rte_flow_error_set(error, EBUSY,
-                                         RTE_FLOW_ERROR_TYPE_ACTION,
-                                         NULL,
-                                         "shared rss hrxq has references");
        if (!__atomic_compare_exchange_n(&shared_rss->refcnt, &old_refcnt,
                                         0, 0, __ATOMIC_ACQUIRE,
                                         __ATOMIC_RELAXED))
@@ -14774,6 +14768,12 @@ __flow_dv_action_rss_release(struct rte_eth_dev *dev, uint32_t idx,
                                          RTE_FLOW_ERROR_TYPE_ACTION,
                                          NULL,
                                          "shared rss has references");
+       remaining = __flow_dv_action_rss_hrxqs_release(dev, shared_rss);
+       if (remaining)
+               return rte_flow_error_set(error, EBUSY,
+                                         RTE_FLOW_ERROR_TYPE_ACTION,
+                                         NULL,
+                                         "shared rss hrxq has references");
        queue = shared_rss->ind_tbl->queues;
        remaining = mlx5_ind_table_obj_release(dev, shared_rss->ind_tbl, true);
        if (remaining)