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