]> git.droids-corp.org - dpdk.git/commitdiff
net/mlx5: store protection domain number on create
authorDekel Peled <dekelp@mellanox.com>
Mon, 22 Jul 2019 14:52:15 +0000 (14:52 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 23 Jul 2019 12:31:36 +0000 (14:31 +0200)
Function mlx5_alloc_shared_ibctx() allocates Protection Domain using
verbs API, as part of shared IB device context.
This patch adds reading and storing of pdn value from the created PD
object, using DV API.
The pdn value is required when creating WQ using DevX API.

This patch also updates function flow_dv_create_counter_stat_mem_mng()
which uses the pdn value as well.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
drivers/net/mlx5/mlx5.c
drivers/net/mlx5/mlx5.h
drivers/net/mlx5/mlx5_flow_dv.c

index e7bfbdf42cfab4c41923ff3daf0c8c2f21391ebc..617f5eeb7c8680ec31d16b950538862ab6230d92 100644 (file)
@@ -269,6 +269,37 @@ mlx5_flow_counters_mng_close(struct mlx5_ibv_shared *sh)
        memset(&sh->cmng, 0, sizeof(sh->cmng));
 }
 
+/**
+ * Extract pdn of PD object using DV API.
+ *
+ * @param[in] pd
+ *   Pointer to the verbs PD object.
+ * @param[out] pdn
+ *   Pointer to the PD object number variable.
+ *
+ * @return
+ *   0 on success, error value otherwise.
+ */
+#ifdef HAVE_IBV_FLOW_DV_SUPPORT
+static int
+mlx5_get_pdn(struct ibv_pd *pd __rte_unused, uint32_t *pdn __rte_unused)
+{
+       struct mlx5dv_obj obj;
+       struct mlx5dv_pd pd_info;
+       int ret = 0;
+
+       obj.pd.in = pd;
+       obj.pd.out = &pd_info;
+       ret = mlx5_glue->dv_init_obj(&obj, MLX5DV_OBJ_PD);
+       if (ret) {
+               DRV_LOG(DEBUG, "Fail to get PD object info");
+               return ret;
+       }
+       *pdn = pd_info.pdn;
+       return 0;
+}
+#endif /* HAVE_IBV_FLOW_DV_SUPPORT */
+
 /**
  * Allocate shared IB device context. If there is multiport device the
  * master and representors will share this context, if there is single
@@ -357,6 +388,13 @@ mlx5_alloc_shared_ibctx(const struct mlx5_dev_spawn_data *spawn)
                err = ENOMEM;
                goto error;
        }
+#ifdef HAVE_IBV_FLOW_DV_SUPPORT
+       err = mlx5_get_pdn(sh->pd, &sh->pdn);
+       if (err) {
+               DRV_LOG(ERR, "Fail to extract pdn from PD");
+               goto error;
+       }
+#endif /* HAVE_IBV_FLOW_DV_SUPPORT */
        /*
         * Once the device is added to the list of memory event
         * callback, its global MR cache table cannot be expanded
index b08006476319d62c3883b7f1e7baf63dbd34c5ee..b98c406830c51f77ed0b52e3fac72909a9830f7f 100644 (file)
@@ -525,6 +525,7 @@ struct mlx5_ibv_shared {
        uint32_t max_port; /* Maximal IB device port index. */
        struct ibv_context *ctx; /* Verbs/DV context. */
        struct ibv_pd *pd; /* Protection Domain. */
+       uint32_t pdn; /* Protection Domain number. */
        uint32_t tdn; /* Transport Domain number. */
        char ibdev_name[IBV_SYSFS_NAME_MAX]; /* IB device name. */
        char ibdev_path[IBV_SYSFS_PATH_MAX]; /* IB device path for secondary */
index afaa19c52ea500fd056821a2c628a0ba2802691f..36696c8a70ea450b821b03b93a96729a074fbb20 100644 (file)
@@ -2319,8 +2319,6 @@ flow_dv_create_counter_stat_mem_mng(struct rte_eth_dev *dev, int raws_n)
 {
        struct mlx5_ibv_shared *sh = ((struct mlx5_priv *)
                                        (dev->data->dev_private))->sh;
-       struct mlx5dv_pd dv_pd;
-       struct mlx5dv_obj dv_obj;
        struct mlx5_devx_mkey_attr mkey_attr;
        struct mlx5_counter_stats_mem_mng *mem_mng;
        volatile struct flow_counter_stats *raw_data;
@@ -2344,13 +2342,10 @@ flow_dv_create_counter_stat_mem_mng(struct rte_eth_dev *dev, int raws_n)
                rte_free(mem);
                return NULL;
        }
-       dv_obj.pd.in = sh->pd;
-       dv_obj.pd.out = &dv_pd;
-       mlx5_glue->dv_init_obj(&dv_obj, MLX5DV_OBJ_PD);
        mkey_attr.addr = (uintptr_t)mem;
        mkey_attr.size = size;
        mkey_attr.umem_id = mem_mng->umem->umem_id;
-       mkey_attr.pd = dv_pd.pdn;
+       mkey_attr.pd = sh->pdn;
        mem_mng->dm = mlx5_devx_cmd_mkey_create(sh->ctx, &mkey_attr);
        if (!mem_mng->dm) {
                mlx5_glue->devx_umem_dereg(mem_mng->umem);