[v1,5/8] net/mlx5: remove umem field dependency on dv
diff mbox series

Message ID 20200603150602.4686-6-ophirmu@mellanox.com
State Accepted
Delegated to: Raslan Darawsheh
Headers show
Series
  • mlx5 PMD multi OS support
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Ophir Munk June 3, 2020, 3:05 p.m. UTC
umem field is used in several structs. Its type 'struct mlx5dv_devx_umem
*' is changed to 'void *'. This change will allow non-Linux OS
compilations.

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/linux/mlx5_os.c | 18 ++++++++++++++++++
 drivers/net/mlx5/mlx5.c          |  2 +-
 drivers/net/mlx5/mlx5.h          |  5 +++--
 drivers/net/mlx5/mlx5_flow_dv.c  |  2 +-
 drivers/net/mlx5/mlx5_rxq.c      |  2 +-
 5 files changed, 24 insertions(+), 5 deletions(-)

Patch
diff mbox series

diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 85dcf49..7d60683 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -87,6 +87,24 @@  mlx5_os_get_ctx_device_path(void *ctx)
 }
 
 /**
+ * Get umem id. Given a pointer to umem object of type
+ * 'struct mlx5dv_devx_umem *' - return its id.
+ *
+ * @param[in] umem
+ *   Pointer to umem object.
+ *
+ * @return
+ *   The umem id if umem is valid, 0 otherwise.
+ */
+uint32_t
+mlx5_os_get_umem_id(void *umem)
+{
+	if (!umem)
+		return 0;
+	return ((struct mlx5dv_devx_umem *)umem)->umem_id;
+}
+
+/**
  * Get mlx5 device attributes. The glue function query_device_ex() is called
  * with out parameter of type 'struct ibv_device_attr_ex *'. Then fill in mlx5
  * device attributes from the glue out parameter.
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 0fa8742..4f7b4d3 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -2298,7 +2298,7 @@  mlx5_release_dbr(struct rte_eth_dev *dev, uint32_t umem_id, uint64_t offset)
 
 	LIST_FOREACH(page, &priv->dbrpgs, next)
 		/* Find the page this address belongs to. */
-		if (page->umem->umem_id == umem_id)
+		if (mlx5_os_get_umem_id(page->umem) == umem_id)
 			break;
 	if (!page)
 		return -EINVAL;
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 478ebef..ec4ba87 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -384,7 +384,7 @@  struct mlx5_counter_stats_mem_mng {
 	LIST_ENTRY(mlx5_counter_stats_mem_mng) next;
 	struct mlx5_counter_stats_raw *raws;
 	struct mlx5_devx_obj *dm;
-	struct mlx5dv_devx_umem *umem;
+	void *umem;
 };
 
 /* Raw memory structure for the counter statistics values of a pool. */
@@ -490,7 +490,7 @@  struct mlx5_devx_dbr_page {
 	/* Door-bell records, must be first member in structure. */
 	uint8_t dbrs[MLX5_DBR_PAGE_SIZE];
 	LIST_ENTRY(mlx5_devx_dbr_page) next; /* Pointer to the next element. */
-	struct mlx5dv_devx_umem *umem;
+	void *umem;
 	uint32_t dbr_count; /* Number of door-bell records in use. */
 	/* 1 bit marks matching door-bell is in use. */
 	uint64_t dbr_bitmap[MLX5_DBR_BITMAP_SIZE];
@@ -878,6 +878,7 @@  void mlx5_flow_meter_detach(struct mlx5_flow_meter *fm);
 /* mlx5_os.c */
 const char *mlx5_os_get_ctx_device_name(void *ctx);
 const char *mlx5_os_get_ctx_device_path(void *ctx);
+uint32_t mlx5_os_get_umem_id(void *umem);
 int mlx5_os_get_dev_attr(void *ctx, struct mlx5_dev_attr *dev_attr);
 
 #endif /* RTE_PMD_MLX5_H_ */
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 4dec57d..81f5bd4 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -4130,7 +4130,7 @@  flow_dv_create_counter_stat_mem_mng(struct rte_eth_dev *dev, int raws_n)
 	}
 	mkey_attr.addr = (uintptr_t)mem;
 	mkey_attr.size = size;
-	mkey_attr.umem_id = mem_mng->umem->umem_id;
+	mkey_attr.umem_id = mlx5_os_get_umem_id(mem_mng->umem);
 	mkey_attr.pd = sh->pdn;
 	mkey_attr.log_entity_size = 0;
 	mkey_attr.pg_access = 0;
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index f018553..78046fd 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -1417,7 +1417,7 @@  mlx5_rxq_obj_new(struct rte_eth_dev *dev, uint16_t idx,
 		if (dbr_offset < 0)
 			goto error;
 		rxq_ctrl->dbr_offset = dbr_offset;
-		rxq_ctrl->dbr_umem_id = dbr_page->umem->umem_id;
+		rxq_ctrl->dbr_umem_id = mlx5_os_get_umem_id(dbr_page->umem);
 		rxq_ctrl->dbr_umem_id_valid = 1;
 		rxq_data->rq_db = (uint32_t *)((uintptr_t)dbr_page->dbrs +
 					       (uintptr_t)rxq_ctrl->dbr_offset);