xref: /dpdk/drivers/common/mlx5/mlx5_common_devx.h (revision 1094dd940ec0cc4e3ce2c5cd94807350855a17f9)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2020 Mellanox Technologies, Ltd
3  */
4 
5 #ifndef RTE_PMD_MLX5_COMMON_DEVX_H_
6 #define RTE_PMD_MLX5_COMMON_DEVX_H_
7 
8 #include "mlx5_devx_cmds.h"
9 
10 #include <rte_compat.h>
11 
12 /* The standard page size */
13 #define MLX5_LOG_PAGE_SIZE 12
14 
15 /* DevX Completion Queue structure. */
16 struct mlx5_devx_cq {
17 	struct mlx5_devx_obj *cq; /* The CQ DevX object. */
18 	void *umem_obj; /* The CQ umem object. */
19 	union {
20 		volatile void *umem_buf;
21 		volatile struct mlx5_cqe *cqes; /* The CQ ring buffer. */
22 	};
23 	volatile uint32_t *db_rec; /* The CQ doorbell record. */
24 };
25 
26 /* DevX Send Queue structure. */
27 struct mlx5_devx_sq {
28 	struct mlx5_devx_obj *sq; /* The SQ DevX object. */
29 	void *umem_obj; /* The SQ umem object. */
30 	union {
31 		volatile void *umem_buf;
32 		volatile struct mlx5_wqe *wqes; /* The SQ ring buffer. */
33 		volatile struct mlx5_aso_wqe *aso_wqes;
34 	};
35 	volatile uint32_t *db_rec; /* The SQ doorbell record. */
36 };
37 
38 /* DevX Queue Pair structure. */
39 struct mlx5_devx_qp {
40 	struct mlx5_devx_obj *qp; /* The QP DevX object. */
41 	void *umem_obj; /* The QP umem object. */
42 	union {
43 		void *umem_buf;
44 		struct mlx5_wqe *wqes; /* The QP ring buffer. */
45 		struct mlx5_aso_wqe *aso_wqes;
46 	};
47 	volatile uint32_t *db_rec; /* The QP doorbell record. */
48 };
49 
50 /* DevX Receive Queue resource structure. */
51 struct mlx5_devx_wq_res {
52 	void *umem_obj; /* The RQ umem object. */
53 	volatile void *umem_buf;
54 	volatile uint32_t *db_rec; /* The RQ doorbell record. */
55 };
56 
57 /* DevX Receive Memory Pool structure. */
58 struct mlx5_devx_rmp {
59 	struct mlx5_devx_obj *rmp; /* The RMP DevX object. */
60 	uint32_t ref_cnt; /* Reference count. */
61 	struct mlx5_devx_wq_res wq;
62 };
63 
64 /* DevX Receive Queue structure. */
65 struct mlx5_devx_rq {
66 	struct mlx5_devx_obj *rq; /* The RQ DevX object. */
67 	struct mlx5_devx_rmp *rmp; /* Shared RQ RMP object. */
68 	struct mlx5_devx_wq_res wq; /* WQ resource of standalone RQ. */
69 };
70 
71 /* mlx5_common_devx.c */
72 
73 __rte_internal
74 void mlx5_devx_cq_destroy(struct mlx5_devx_cq *cq);
75 
76 __rte_internal
77 int mlx5_devx_cq_create(void *ctx, struct mlx5_devx_cq *cq_obj,
78 			uint16_t log_desc_n,
79 			struct mlx5_devx_cq_attr *attr, int socket);
80 
81 __rte_internal
82 void mlx5_devx_sq_destroy(struct mlx5_devx_sq *sq);
83 
84 __rte_internal
85 int mlx5_devx_sq_create(void *ctx, struct mlx5_devx_sq *sq_obj,
86 			uint16_t log_wqbb_n,
87 			struct mlx5_devx_create_sq_attr *attr, int socket);
88 
89 __rte_internal
90 void mlx5_devx_qp_destroy(struct mlx5_devx_qp *qp);
91 
92 __rte_internal
93 int mlx5_devx_qp_create(void *ctx, struct mlx5_devx_qp *qp_obj,
94 			uint32_t queue_size,
95 			struct mlx5_devx_qp_attr *attr, int socket);
96 
97 __rte_internal
98 void mlx5_devx_rq_destroy(struct mlx5_devx_rq *rq);
99 
100 __rte_internal
101 int mlx5_devx_rq_create(void *ctx, struct mlx5_devx_rq *rq_obj,
102 			uint32_t wqe_size, uint16_t log_wqbb_n,
103 			struct mlx5_devx_create_rq_attr *attr, int socket);
104 
105 __rte_internal
106 int mlx5_devx_qp2rts(struct mlx5_devx_qp *qp, uint32_t remote_qp_id);
107 
108 #endif /* RTE_PMD_MLX5_COMMON_DEVX_H_ */
109