xref: /openbmc/linux/include/uapi/rdma/rvt-abi.h (revision 7d545e77)
1 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
2 
3 /*
4  * This file contains defines, structures, etc. that are used
5  * to communicate between kernel and user code.
6  */
7 
8 #ifndef RVT_ABI_USER_H
9 #define RVT_ABI_USER_H
10 
11 #include <linux/types.h>
12 #include <rdma/ib_user_verbs.h>
13 #ifndef RDMA_ATOMIC_UAPI
14 #define RDMA_ATOMIC_UAPI(_type, _name) struct{ _type val; } _name
15 #endif
16 
17 struct rvt_wqe_sge {
18 	__aligned_u64 addr;
19 	__u32 length;
20 	__u32 lkey;
21 };
22 
23 /*
24  * This structure is used to contain the head pointer, tail pointer,
25  * and completion queue entries as a single memory allocation so
26  * it can be mmap'ed into user space.
27  */
28 struct rvt_cq_wc {
29 	/* index of next entry to fill */
30 	RDMA_ATOMIC_UAPI(__u32, head);
31 	/* index of next ib_poll_cq() entry */
32 	RDMA_ATOMIC_UAPI(__u32, tail);
33 
34 	/* these are actually size ibcq.cqe + 1 */
35 	struct ib_uverbs_wc uqueue[];
36 };
37 
38 /*
39  * Receive work request queue entry.
40  * The size of the sg_list is determined when the QP (or SRQ) is created
41  * and stored in qp->r_rq.max_sge (or srq->rq.max_sge).
42  */
43 struct rvt_rwqe {
44 	__u64 wr_id;
45 	__u8 num_sge;
46 	__u8 padding[7];
47 	struct rvt_wqe_sge sg_list[];
48 };
49 
50 /*
51  * This structure is used to contain the head pointer, tail pointer,
52  * and receive work queue entries as a single memory allocation so
53  * it can be mmap'ed into user space.
54  * Note that the wq array elements are variable size so you can't
55  * just index into the array to get the N'th element;
56  * use get_rwqe_ptr() for user space and rvt_get_rwqe_ptr()
57  * for kernel space.
58  */
59 struct rvt_rwq {
60 	/* new work requests posted to the head */
61 	RDMA_ATOMIC_UAPI(__u32, head);
62 	/* receives pull requests from here. */
63 	RDMA_ATOMIC_UAPI(__u32, tail);
64 	struct rvt_rwqe wq[];
65 };
66 #endif /* RVT_ABI_USER_H */
67