From c7f6ba0e5341c97aaf65bfc87855249cec94054a Mon Sep 17 00:00:00 2001 From: Ophir Munk Date: Wed, 3 Jun 2020 15:05:59 +0000 Subject: [PATCH] net/mlx5: remove umem field dependency on Direct Verbs 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 Acked-by: Matan Azrad --- 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(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 85dcf49cd1..7d60683a76 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -86,6 +86,24 @@ mlx5_os_get_ctx_device_path(void *ctx) return ((struct ibv_context *)ctx)->device->ibdev_path; } +/** + * 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 diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 0fa87429ad..4f7b4d3ff6 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 478ebef0fc..ec4ba87b81 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 4dec57d696..81f5bd4282 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 f01855388a..78046fd860 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); -- 2.20.1