net/mlx5: fix RSS flow item expansion for NVGRE
[dpdk.git] / drivers / net / mlx5 / mlx5.c
index 10d44c7..35f91e9 100644 (file)
@@ -672,6 +672,96 @@ mlx5_age_event_prepare(struct mlx5_dev_ctx_shared *sh)
        }
 }
 
+/*
+ * Initialize the ASO connection tracking structure.
+ *
+ * @param[in] sh
+ *   Pointer to mlx5_dev_ctx_shared object.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_flow_aso_ct_mng_init(struct mlx5_dev_ctx_shared *sh)
+{
+       int err;
+
+       if (sh->ct_mng)
+               return 0;
+       sh->ct_mng = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*sh->ct_mng),
+                                RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY);
+       if (!sh->ct_mng) {
+               DRV_LOG(ERR, "ASO CT management allocation failed.");
+               rte_errno = ENOMEM;
+               return -rte_errno;
+       }
+       err = mlx5_aso_queue_init(sh, ASO_OPC_MOD_CONNECTION_TRACKING);
+       if (err) {
+               mlx5_free(sh->ct_mng);
+               /* rte_errno should be extracted from the failure. */
+               rte_errno = EINVAL;
+               return -rte_errno;
+       }
+       rte_spinlock_init(&sh->ct_mng->ct_sl);
+       rte_rwlock_init(&sh->ct_mng->resize_rwl);
+       LIST_INIT(&sh->ct_mng->free_cts);
+       return 0;
+}
+
+/*
+ * Close and release all the resources of the
+ * ASO connection tracking management structure.
+ *
+ * @param[in] sh
+ *   Pointer to mlx5_dev_ctx_shared object to free.
+ */
+static void
+mlx5_flow_aso_ct_mng_close(struct mlx5_dev_ctx_shared *sh)
+{
+       struct mlx5_aso_ct_pools_mng *mng = sh->ct_mng;
+       struct mlx5_aso_ct_pool *ct_pool;
+       struct mlx5_aso_ct_action *ct;
+       uint32_t idx;
+       uint32_t val;
+       uint32_t cnt;
+       int i;
+
+       mlx5_aso_queue_uninit(sh, ASO_OPC_MOD_CONNECTION_TRACKING);
+       idx = mng->next;
+       while (idx--) {
+               cnt = 0;
+               ct_pool = mng->pools[idx];
+               for (i = 0; i < MLX5_ASO_CT_ACTIONS_PER_POOL; i++) {
+                       ct = &ct_pool->actions[i];
+                       val = __atomic_fetch_sub(&ct->refcnt, 1,
+                                                __ATOMIC_RELAXED);
+                       MLX5_ASSERT(val == 1);
+                       if (val > 1)
+                               cnt++;
+#ifdef HAVE_MLX5_DR_ACTION_ASO_CT
+                       if (ct->dr_action_orig)
+                               claim_zero(mlx5_glue->destroy_flow_action
+                                                       (ct->dr_action_orig));
+                       if (ct->dr_action_rply)
+                               claim_zero(mlx5_glue->destroy_flow_action
+                                                       (ct->dr_action_rply));
+#endif
+               }
+               claim_zero(mlx5_devx_cmd_destroy(ct_pool->devx_obj));
+               if (cnt) {
+                       DRV_LOG(DEBUG, "%u ASO CT objects are being used in the pool %u",
+                               cnt, i);
+               }
+               mlx5_free(ct_pool);
+               /* in case of failure. */
+               mng->next--;
+       }
+       mlx5_free(mng->pools);
+       mlx5_free(mng);
+       /* Management structure must be cleared to 0s during allocation. */
+       sh->ct_mng = NULL;
+}
+
 /**
  * Initialize the flow resources' indexed mempool.
  *
@@ -1474,6 +1564,8 @@ mlx5_dev_close(struct rte_eth_dev *dev)
        if (priv->mreg_cp_tbl)
                mlx5_hlist_destroy(priv->mreg_cp_tbl);
        mlx5_mprq_free_mp(dev);
+       if (priv->sh->ct_mng)
+               mlx5_flow_aso_ct_mng_close(priv->sh);
        mlx5_os_free_shared_dr(priv);
        if (priv->rss_conf.rss_key != NULL)
                mlx5_free(priv->rss_conf.rss_key);
@@ -1617,6 +1709,7 @@ const struct eth_dev_ops mlx5_dev_ops = {
        .hairpin_queue_peer_update = mlx5_hairpin_queue_peer_update,
        .hairpin_queue_peer_bind = mlx5_hairpin_queue_peer_bind,
        .hairpin_queue_peer_unbind = mlx5_hairpin_queue_peer_unbind,
+       .get_monitor_addr = mlx5_get_monitor_addr,
 };
 
 /* Available operations from secondary process. */
@@ -1701,6 +1794,7 @@ const struct eth_dev_ops mlx5_dev_ops_isolate = {
        .hairpin_queue_peer_update = mlx5_hairpin_queue_peer_update,
        .hairpin_queue_peer_bind = mlx5_hairpin_queue_peer_bind,
        .hairpin_queue_peer_unbind = mlx5_hairpin_queue_peer_unbind,
+       .get_monitor_addr = mlx5_get_monitor_addr,
 };
 
 /**
@@ -2348,7 +2442,7 @@ static struct mlx5_pci_driver mlx5_driver = {
 };
 
 /* Initialize driver log type. */
-RTE_LOG_REGISTER(mlx5_logtype, pmd.net.mlx5, NOTICE)
+RTE_LOG_REGISTER_DEFAULT(mlx5_logtype, NOTICE)
 
 /**
  * Driver initialization routine.