net/mlx5: translate shared action for RSS action
[dpdk.git] / drivers / net / mlx5 / mlx5.c
index 74a537b..2484251 100644 (file)
@@ -484,14 +484,13 @@ mlx5_flow_counters_mng_init(struct mlx5_dev_ctx_shared *sh)
 
        memset(&sh->cmng, 0, sizeof(sh->cmng));
        TAILQ_INIT(&sh->cmng.flow_counters);
-       for (i = 0; i < MLX5_CCONT_TYPE_MAX; ++i) {
-               sh->cmng.ccont[i].min_id = MLX5_CNT_BATCH_OFFSET;
-               sh->cmng.ccont[i].max_id = -1;
-               sh->cmng.ccont[i].last_pool_idx = POOL_IDX_INVALID;
-               TAILQ_INIT(&sh->cmng.ccont[i].pool_list);
-               rte_spinlock_init(&sh->cmng.ccont[i].resize_sl);
-               TAILQ_INIT(&sh->cmng.ccont[i].counters);
-               rte_spinlock_init(&sh->cmng.ccont[i].csl);
+       sh->cmng.min_id = MLX5_CNT_BATCH_OFFSET;
+       sh->cmng.max_id = -1;
+       sh->cmng.last_pool_idx = POOL_IDX_INVALID;
+       rte_spinlock_init(&sh->cmng.pool_update_sl);
+       for (i = 0; i < MLX5_COUNTER_TYPE_MAX; i++) {
+               TAILQ_INIT(&sh->cmng.counters[i]);
+               rte_spinlock_init(&sh->cmng.csl[i]);
        }
 }
 
@@ -522,8 +521,7 @@ static void
 mlx5_flow_counters_mng_close(struct mlx5_dev_ctx_shared *sh)
 {
        struct mlx5_counter_stats_mem_mng *mng;
-       int i;
-       int j;
+       int i, j;
        int retries = 1024;
 
        rte_errno = 0;
@@ -533,34 +531,33 @@ mlx5_flow_counters_mng_close(struct mlx5_dev_ctx_shared *sh)
                        break;
                rte_pause();
        }
-       for (i = 0; i < MLX5_CCONT_TYPE_MAX; ++i) {
+
+       if (sh->cmng.pools) {
                struct mlx5_flow_counter_pool *pool;
-               uint32_t batch = !!(i > 1);
+               uint16_t n_valid = sh->cmng.n_valid;
+               bool fallback = sh->cmng.counter_fallback;
 
-               if (!sh->cmng.ccont[i].pools)
-                       continue;
-               pool = TAILQ_FIRST(&sh->cmng.ccont[i].pool_list);
-               while (pool) {
-                       if (batch && pool->min_dcs)
+               for (i = 0; i < n_valid; ++i) {
+                       pool = sh->cmng.pools[i];
+                       if (!fallback && pool->min_dcs)
                                claim_zero(mlx5_devx_cmd_destroy
                                                               (pool->min_dcs));
                        for (j = 0; j < MLX5_COUNTERS_PER_POOL; ++j) {
-                               if (MLX5_POOL_GET_CNT(pool, j)->action)
+                               struct mlx5_flow_counter *cnt =
+                                               MLX5_POOL_GET_CNT(pool, j);
+
+                               if (cnt->action)
                                        claim_zero
                                         (mlx5_glue->destroy_flow_action
-                                         (MLX5_POOL_GET_CNT
-                                         (pool, j)->action));
-                               if (!batch && MLX5_GET_POOL_CNT_EXT
-                                   (pool, j)->dcs)
+                                         (cnt->action));
+                               if (fallback && MLX5_POOL_GET_CNT
+                                   (pool, j)->dcs_when_free)
                                        claim_zero(mlx5_devx_cmd_destroy
-                                                  (MLX5_GET_POOL_CNT_EXT
-                                                   (pool, j)->dcs));
+                                                  (cnt->dcs_when_free));
                        }
-                       TAILQ_REMOVE(&sh->cmng.ccont[i].pool_list, pool, next);
                        mlx5_free(pool);
-                       pool = TAILQ_FIRST(&sh->cmng.ccont[i].pool_list);
                }
-               mlx5_free(sh->cmng.ccont[i].pools);
+               mlx5_free(sh->cmng.pools);
        }
        mng = LIST_FIRST(&sh->cmng.mem_mngs);
        while (mng) {
@@ -1404,6 +1401,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)
         * then this will return directly without any action.
         */
        mlx5_flow_list_flush(dev, &priv->flows, true);
+       mlx5_shared_action_flush(dev);
        mlx5_flow_meter_flush(dev, NULL);
        /* Free the intermediate buffers for flow creation. */
        mlx5_flow_free_intermediate(dev);