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 #ifdef HAVE_INFINIBAND_VERBS_H
19 #include <infiniband/verbs.h>
21 #ifdef HAVE_INFINIBAND_MLX5DV_H
22 #include <infiniband/mlx5dv.h>
26 * Get device name. Given an ibv_device pointer - return a
27 * pointer to the corresponding device name.
30 * Pointer to ibv device.
33 * Pointer to device name if dev is valid, NULL otherwise.
35 static inline const char *
36 mlx5_os_get_dev_device_name(void *dev)
40 return ((struct ibv_device *)dev)->name;
44 * Get ibv device name. Given an ibv_context pointer - return a
45 * pointer to the corresponding device name.
48 * Pointer to ibv context.
51 * Pointer to device name if ctx is valid, NULL otherwise.
53 static inline const char *
54 mlx5_os_get_ctx_device_name(void *ctx)
58 return ((struct ibv_context *)ctx)->device->name;
62 * Get ibv device path name. Given an ibv_context pointer - return a
63 * pointer to the corresponding device path name.
66 * Pointer to ibv context.
69 * Pointer to device path name if ctx is valid, NULL otherwise.
72 static inline const char *
73 mlx5_os_get_ctx_device_path(void *ctx)
78 return ((struct ibv_context *)ctx)->device->ibdev_path;
82 * Get umem id. Given a pointer to umem object of type
83 * 'struct mlx5dv_devx_umem *' - return its id.
86 * Pointer to umem object.
89 * The umem id if umem is valid, 0 otherwise.
91 static inline uint32_t
92 mlx5_os_get_umem_id(void *umem)
96 return ((struct mlx5dv_devx_umem *)umem)->umem_id;
98 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */