[RFC,03/10] common/mlx5: move pdn getter to common driver
Checks
Commit Message
Move to common and export the function mlx5_os_get_pdn.
Signed-off-by: Tal Shnaiderman <talshn@nvidia.com>
---
drivers/common/mlx5/linux/mlx5_common_os.c | 35 ++++++++++++++++++++++++++++
drivers/common/mlx5/mlx5_common.h | 4 ++++
drivers/common/mlx5/version.map | 1 +
drivers/common/mlx5/windows/mlx5_common_os.c | 21 +++++++++++++++++
drivers/net/mlx5/linux/mlx5_os.c | 35 ----------------------------
drivers/net/mlx5/mlx5.h | 1 -
drivers/net/mlx5/windows/mlx5_os.c | 21 -----------------
7 files changed, 61 insertions(+), 57 deletions(-)
@@ -456,3 +456,38 @@ mlx5_os_open_device_context(struct rte_device *dev)
}
return ctx;
}
+
+/**
+ * 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.
+ */
+int
+mlx5_os_get_pdn(void *pd, uint32_t *pdn)
+{
+#ifdef HAVE_IBV_FLOW_DV_SUPPORT
+ 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;
+#else
+ (void)pd;
+ (void)pdn;
+ return -ENOTSUP;
+#endif /* HAVE_IBV_FLOW_DV_SUPPORT */
+}
@@ -423,4 +423,8 @@ __rte_internal
void *
mlx5_os_open_device_context(struct rte_device *dev);
+__rte_internal
+int
+mlx5_os_get_pdn(void *pd, uint32_t *pdn);
+
#endif /* RTE_PMD_MLX5_COMMON_H_ */
@@ -144,6 +144,7 @@ INTERNAL {
mlx5_os_match_devx_devices_to_addr;
mlx5_os_open_device_context;
mlx5_os_get_ibv_dev; # WINDOWS_NO_EXPORT
+ mlx5_os_get_pdn;
mlx5_os_reg_mr;
mlx5_os_umem_dereg;
mlx5_os_umem_reg;
@@ -323,3 +323,24 @@ mlx5_os_open_device_context(struct rte_device *dev)
mlx5_glue->free_device_list(orig_devx_bdf_devs);
return devx_ctx_match;
}
+
+/**
+ * Extract pdn of PD object using DevX
+ *
+ * @param[in] pd
+ * Pointer to the DevX PD object.
+ * @param[out] pdn
+ * Pointer to the PD object number variable.
+ *
+ * @return
+ * 0 on success, error value otherwise.
+ */
+int
+mlx5_os_get_pdn(void *pd, uint32_t *pdn)
+{
+ if (!pd)
+ return -EINVAL;
+
+ *pdn = ((struct mlx5_pd *)pd)->pdn;
+ return 0;
+}
@@ -2811,41 +2811,6 @@ mlx5_restore_doorbell_mapping_env(int value)
setenv(MLX5_SHUT_UP_BF, value ? "1" : "0", 1);
}
-/**
- * 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.
- */
-int
-mlx5_os_get_pdn(void *pd, uint32_t *pdn)
-{
-#ifdef HAVE_IBV_FLOW_DV_SUPPORT
- 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;
-#else
- (void)pd;
- (void)pdn;
- return -ENOTSUP;
-#endif /* HAVE_IBV_FLOW_DV_SUPPORT */
-}
-
/**
* Function API to open IB device.
*
@@ -1770,7 +1770,6 @@ void mlx5_os_free_shared_dr(struct mlx5_priv *priv);
int mlx5_os_open_device(const struct mlx5_dev_spawn_data *spawn,
const struct mlx5_dev_config *config,
struct mlx5_dev_ctx_shared *sh);
-int mlx5_os_get_pdn(void *pd, uint32_t *pdn);
int mlx5_os_net_probe(struct rte_device *dev);
void mlx5_os_dev_shared_handler_install(struct mlx5_dev_ctx_shared *sh);
void mlx5_os_dev_shared_handler_uninstall(struct mlx5_dev_ctx_shared *sh);
@@ -1102,25 +1102,4 @@ mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb,
*dereg_mr_cb = mlx5_os_dereg_mr;
}
-/**
- * Extract pdn of PD object using DevX
- *
- * @param[in] pd
- * Pointer to the DevX PD object.
- * @param[out] pdn
- * Pointer to the PD object number variable.
- *
- * @return
- * 0 on success, error value otherwise.
- */
-int
-mlx5_os_get_pdn(void *pd, uint32_t *pdn)
-{
- if (!pd)
- return -EINVAL;
-
- *pdn = ((struct mlx5_pd *)pd)->pdn;
- return 0;
-}
-
const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops = {0};