1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2020 Mellanox Technologies, Ltd
5 #ifndef RTE_PMD_MLX5_COMMON_OS_H_
6 #define RTE_PMD_MLX5_COMMON_OS_H_
11 #include <rte_debug.h>
12 #include <rte_atomic.h>
14 #include <rte_kvargs.h>
15 #include <rte_devargs.h>
17 #include "mlx5_autoconf.h"
18 #include "mlx5_glue.h"
21 * Get device name. Given an ibv_device pointer - return a
22 * pointer to the corresponding device name.
25 * Pointer to ibv device.
28 * Pointer to device name if dev is valid, NULL otherwise.
30 static inline const char *
31 mlx5_os_get_dev_device_name(void *dev)
35 return ((struct ibv_device *)dev)->name;
39 * Get ibv device name. Given an ibv_context pointer - return a
40 * pointer to the corresponding device name.
43 * Pointer to ibv context.
46 * Pointer to device name if ctx is valid, NULL otherwise.
48 static inline const char *
49 mlx5_os_get_ctx_device_name(void *ctx)
53 return ((struct ibv_context *)ctx)->device->name;
57 * Get ibv device path name. Given an ibv_context pointer - return a
58 * pointer to the corresponding device path name.
61 * Pointer to ibv context.
64 * Pointer to device path name if ctx is valid, NULL otherwise.
67 static inline const char *
68 mlx5_os_get_ctx_device_path(void *ctx)
73 return ((struct ibv_context *)ctx)->device->ibdev_path;
77 * Get umem id. Given a pointer to umem object of type
78 * 'struct mlx5dv_devx_umem *' - return its id.
81 * Pointer to umem object.
84 * The umem id if umem is valid, 0 otherwise.
86 static inline uint32_t
87 mlx5_os_get_umem_id(void *umem)
91 return ((struct mlx5dv_devx_umem *)umem)->umem_id;
93 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */