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