xref: /linux/include/uapi/rdma/efa-abi.h (revision c34e9ab9a612ee8b18273398ef75c207b01f516d)
1 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) */
2 /*
3  * Copyright 2018-2024 Amazon.com, Inc. or its affiliates. All rights reserved.
4  */
5 
6 #ifndef EFA_ABI_USER_H
7 #define EFA_ABI_USER_H
8 
9 #include <linux/types.h>
10 #include <rdma/ib_user_ioctl_cmds.h>
11 
12 /*
13  * Increment this value if any changes that break userspace ABI
14  * compatibility are made.
15  */
16 #define EFA_UVERBS_ABI_VERSION 1
17 
18 /*
19  * Keep structs aligned to 8 bytes.
20  * Keep reserved fields as arrays of __u8 named reserved_XXX where XXX is the
21  * hex bit offset of the field.
22  */
23 
24 enum {
25 	EFA_ALLOC_UCONTEXT_CMD_COMP_TX_BATCH  = 1 << 0,
26 	EFA_ALLOC_UCONTEXT_CMD_COMP_MIN_SQ_WR = 1 << 1,
27 };
28 
29 struct efa_ibv_alloc_ucontext_cmd {
30 	__u32 comp_mask;
31 	__u8 reserved_20[4];
32 };
33 
34 enum efa_ibv_user_cmds_supp_udata {
35 	EFA_USER_CMDS_SUPP_UDATA_QUERY_DEVICE = 1 << 0,
36 	EFA_USER_CMDS_SUPP_UDATA_CREATE_AH    = 1 << 1,
37 };
38 
39 struct efa_ibv_alloc_ucontext_resp {
40 	__u32 comp_mask;
41 	__u32 cmds_supp_udata_mask;
42 	__u16 sub_cqs_per_cq;
43 	__u16 inline_buf_size;
44 	__u32 max_llq_size; /* bytes */
45 	__u16 max_tx_batch; /* units of 64 bytes */
46 	__u16 min_sq_wr;
47 	__u8 reserved_a0[4];
48 };
49 
50 struct efa_ibv_alloc_pd_resp {
51 	__u32 comp_mask;
52 	__u16 pdn;
53 	__u8 reserved_30[2];
54 };
55 
56 enum {
57 	EFA_CREATE_CQ_WITH_COMPLETION_CHANNEL = 1 << 0,
58 	EFA_CREATE_CQ_WITH_SGID               = 1 << 1,
59 };
60 
61 struct efa_ibv_create_cq {
62 	__u32 comp_mask;
63 	__u32 cq_entry_size;
64 	__u16 num_sub_cqs;
65 	__u8 flags;
66 	__u8 reserved_58[5];
67 };
68 
69 enum {
70 	EFA_CREATE_CQ_RESP_DB_OFF = 1 << 0,
71 };
72 
73 struct efa_ibv_create_cq_resp {
74 	__u32 comp_mask;
75 	__u8 reserved_20[4];
76 	__aligned_u64 q_mmap_key;
77 	__aligned_u64 q_mmap_size;
78 	__u16 cq_idx;
79 	__u8 reserved_d0[2];
80 	__u32 db_off;
81 	__aligned_u64 db_mmap_key;
82 };
83 
84 enum {
85 	EFA_QP_DRIVER_TYPE_SRD = 0,
86 };
87 
88 enum {
89 	EFA_CREATE_QP_WITH_UNSOLICITED_WRITE_RECV = 1 << 0,
90 };
91 
92 struct efa_ibv_create_qp {
93 	__u32 comp_mask;
94 	__u32 rq_ring_size; /* bytes */
95 	__u32 sq_ring_size; /* bytes */
96 	__u32 driver_qp_type;
97 	__u16 flags;
98 	__u8 sl;
99 	__u8 reserved_98[5];
100 };
101 
102 struct efa_ibv_create_qp_resp {
103 	__u32 comp_mask;
104 	/* the offset inside the page of the rq db */
105 	__u32 rq_db_offset;
106 	/* the offset inside the page of the sq db */
107 	__u32 sq_db_offset;
108 	/* the offset inside the page of descriptors buffer */
109 	__u32 llq_desc_offset;
110 	__aligned_u64 rq_mmap_key;
111 	__aligned_u64 rq_mmap_size;
112 	__aligned_u64 rq_db_mmap_key;
113 	__aligned_u64 sq_db_mmap_key;
114 	__aligned_u64 llq_desc_mmap_key;
115 	__u16 send_sub_cq_idx;
116 	__u16 recv_sub_cq_idx;
117 	__u8 reserved_1e0[4];
118 };
119 
120 struct efa_ibv_create_ah_resp {
121 	__u32 comp_mask;
122 	__u16 efa_address_handle;
123 	__u8 reserved_30[2];
124 };
125 
126 enum {
127 	EFA_QUERY_DEVICE_CAPS_RDMA_READ = 1 << 0,
128 	EFA_QUERY_DEVICE_CAPS_RNR_RETRY = 1 << 1,
129 	EFA_QUERY_DEVICE_CAPS_CQ_NOTIFICATIONS = 1 << 2,
130 	EFA_QUERY_DEVICE_CAPS_CQ_WITH_SGID     = 1 << 3,
131 	EFA_QUERY_DEVICE_CAPS_DATA_POLLING_128 = 1 << 4,
132 	EFA_QUERY_DEVICE_CAPS_RDMA_WRITE = 1 << 5,
133 	EFA_QUERY_DEVICE_CAPS_UNSOLICITED_WRITE_RECV = 1 << 6,
134 };
135 
136 struct efa_ibv_ex_query_device_resp {
137 	__u32 comp_mask;
138 	__u32 max_sq_wr;
139 	__u32 max_rq_wr;
140 	__u16 max_sq_sge;
141 	__u16 max_rq_sge;
142 	__u32 max_rdma_size;
143 	__u32 device_caps;
144 };
145 
146 enum {
147 	EFA_QUERY_MR_VALIDITY_RECV_IC_ID = 1 << 0,
148 	EFA_QUERY_MR_VALIDITY_RDMA_READ_IC_ID = 1 << 1,
149 	EFA_QUERY_MR_VALIDITY_RDMA_RECV_IC_ID = 1 << 2,
150 };
151 
152 enum efa_query_mr_attrs {
153 	EFA_IB_ATTR_QUERY_MR_HANDLE = (1U << UVERBS_ID_NS_SHIFT),
154 	EFA_IB_ATTR_QUERY_MR_RESP_IC_ID_VALIDITY,
155 	EFA_IB_ATTR_QUERY_MR_RESP_RECV_IC_ID,
156 	EFA_IB_ATTR_QUERY_MR_RESP_RDMA_READ_IC_ID,
157 	EFA_IB_ATTR_QUERY_MR_RESP_RDMA_RECV_IC_ID,
158 };
159 
160 enum efa_mr_methods {
161 	EFA_IB_METHOD_MR_QUERY = (1U << UVERBS_ID_NS_SHIFT),
162 };
163 
164 #endif /* EFA_ABI_USER_H */
165