net/bnxt: use macro for PCI log format
[dpdk.git] / drivers / net / mlx5 / mlx5.c
index 663ef2e..cc13e44 100644 (file)
@@ -199,6 +199,7 @@ static LIST_HEAD(, mlx5_ibv_shared) mlx5_ibv_list = LIST_HEAD_INITIALIZER();
 static pthread_mutex_t mlx5_ibv_list_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 static struct mlx5_indexed_pool_config mlx5_ipool_cfg[] = {
+#ifdef HAVE_IBV_FLOW_DV_SUPPORT
        {
                .size = sizeof(struct mlx5_flow_dv_encap_decap_resource),
                .trunk_size = 64,
@@ -254,6 +255,60 @@ static struct mlx5_indexed_pool_config mlx5_ipool_cfg[] = {
                .free = rte_free,
                .type = "mlx5_jump_ipool",
        },
+#endif
+       {
+               .size = sizeof(struct mlx5_flow_meter),
+               .trunk_size = 64,
+               .grow_trunk = 3,
+               .grow_shift = 2,
+               .need_lock = 0,
+               .release_mem_en = 1,
+               .malloc = rte_malloc_socket,
+               .free = rte_free,
+               .type = "mlx5_meter_ipool",
+       },
+       {
+               .size = sizeof(struct mlx5_flow_mreg_copy_resource),
+               .trunk_size = 64,
+               .grow_trunk = 3,
+               .grow_shift = 2,
+               .need_lock = 0,
+               .release_mem_en = 1,
+               .malloc = rte_malloc_socket,
+               .free = rte_free,
+               .type = "mlx5_mcp_ipool",
+       },
+       {
+               .size = (sizeof(struct mlx5_hrxq) + MLX5_RSS_HASH_KEY_LEN),
+               .trunk_size = 64,
+               .grow_trunk = 3,
+               .grow_shift = 2,
+               .need_lock = 0,
+               .release_mem_en = 1,
+               .malloc = rte_malloc_socket,
+               .free = rte_free,
+               .type = "mlx5_hrxq_ipool",
+       },
+       {
+               .size = sizeof(struct mlx5_flow_handle),
+               .trunk_size = 64,
+               .grow_trunk = 3,
+               .grow_shift = 2,
+               .need_lock = 0,
+               .release_mem_en = 1,
+               .malloc = rte_malloc_socket,
+               .free = rte_free,
+               .type = "mlx5_flow_handle_ipool",
+       },
+       {
+               .size = sizeof(struct rte_flow),
+               .trunk_size = 4096,
+               .need_lock = 1,
+               .release_mem_en = 1,
+               .malloc = rte_malloc_socket,
+               .free = rte_free,
+               .type = "rte_flow_ipool",
+       },
 };
 
 
@@ -480,12 +535,25 @@ mlx5_flow_counters_mng_close(struct mlx5_ibv_shared *sh)
  *
  * @param[in] sh
  *   Pointer to mlx5_ibv_shared object.
+ * @param[in] sh
+ *   Pointer to user dev config.
  */
 static void
-mlx5_flow_ipool_create(struct mlx5_ibv_shared *sh)
+mlx5_flow_ipool_create(struct mlx5_ibv_shared *sh,
+                      const struct mlx5_dev_config *config __rte_unused)
 {
        uint8_t i;
 
+#ifdef HAVE_IBV_FLOW_DV_SUPPORT
+       /*
+        * While DV is supported, user chooses the verbs mode,
+        * the mlx5 flow handle size is different with the
+        * MLX5_FLOW_HANDLE_VERBS_SIZE.
+        */
+       if (!config->dv_flow_en)
+               mlx5_ipool_cfg[MLX5_IPOOL_MLX5_FLOW].size =
+                                       MLX5_FLOW_HANDLE_VERBS_SIZE;
+#endif
        for (i = 0; i < MLX5_IPOOL_MAX; ++i)
                sh->ipool[i] = mlx5_ipool_create(&mlx5_ipool_cfg[i]);
 }
@@ -696,7 +764,8 @@ mlx5_alloc_shared_ibctx(const struct mlx5_dev_spawn_data *spawn,
                        goto error;
                }
        }
-       sh->flow_id_pool = mlx5_flow_id_pool_alloc(UINT32_MAX);
+       sh->flow_id_pool = mlx5_flow_id_pool_alloc
+                                       ((1 << HAIRPIN_FLOW_ID_BITS) - 1);
        if (!sh->flow_id_pool) {
                DRV_LOG(ERR, "can't create flow id pool");
                err = ENOMEM;
@@ -720,7 +789,7 @@ mlx5_alloc_shared_ibctx(const struct mlx5_dev_spawn_data *spawn,
                goto error;
        }
        mlx5_flow_counters_mng_init(sh);
-       mlx5_flow_ipool_create(sh);
+       mlx5_flow_ipool_create(sh, config);
        /* Add device to memory callback list. */
        rte_rwlock_write_lock(&mlx5_shared_data->mem_event_rwlock);
        LIST_INSERT_HEAD(&mlx5_shared_data->mem_event_cb_list,
@@ -1392,16 +1461,6 @@ mlx5_dev_close(struct rte_eth_dev *dev)
                close(priv->nl_socket_rdma);
        if (priv->vmwa_context)
                mlx5_vlan_vmwa_exit(priv->vmwa_context);
-       if (priv->sh) {
-               /*
-                * Free the shared context in last turn, because the cleanup
-                * routines above may use some shared fields, like
-                * mlx5_nl_mac_addr_flush() uses ibdev_path for retrieveing
-                * ifindex if Netlink fails.
-                */
-               mlx5_free_shared_ibctx(priv->sh);
-               priv->sh = NULL;
-       }
        ret = mlx5_hrxq_verify(dev);
        if (ret)
                DRV_LOG(WARNING, "port %u some hash Rx queue still remain",
@@ -1430,6 +1489,16 @@ mlx5_dev_close(struct rte_eth_dev *dev)
        if (ret)
                DRV_LOG(WARNING, "port %u some flows still remain",
                        dev->data->port_id);
+       if (priv->sh) {
+               /*
+                * Free the shared context in last turn, because the cleanup
+                * routines above may use some shared fields, like
+                * mlx5_nl_mac_addr_flush() uses ibdev_path for retrieveing
+                * ifindex if Netlink fails.
+                */
+               mlx5_free_shared_ibctx(priv->sh);
+               priv->sh = NULL;
+       }
        if (priv->domain_id != RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID) {
                unsigned int c = 0;
                uint16_t port_id;
@@ -2826,8 +2895,8 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
                                      mlx5_ifindex(eth_dev),
                                      eth_dev->data->mac_addrs,
                                      MLX5_MAX_MAC_ADDRESSES);
-       TAILQ_INIT(&priv->flows);
-       TAILQ_INIT(&priv->ctrl_flows);
+       priv->flows = 0;
+       priv->ctrl_flows = 0;
        TAILQ_INIT(&priv->flow_meters);
        TAILQ_INIT(&priv->flow_meter_profiles);
        /* Hint libmlx5 to use PMD allocator for data plane resources */