xref: /linux/include/uapi/rdma/efa-abi.h (revision ae22a94997b8a03dcb3c922857c203246711f9d4)
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 struct efa_ibv_create_qp {
89 	__u32 comp_mask;
90 	__u32 rq_ring_size; /* bytes */
91 	__u32 sq_ring_size; /* bytes */
92 	__u32 driver_qp_type;
93 };
94 
95 struct efa_ibv_create_qp_resp {
96 	__u32 comp_mask;
97 	/* the offset inside the page of the rq db */
98 	__u32 rq_db_offset;
99 	/* the offset inside the page of the sq db */
100 	__u32 sq_db_offset;
101 	/* the offset inside the page of descriptors buffer */
102 	__u32 llq_desc_offset;
103 	__aligned_u64 rq_mmap_key;
104 	__aligned_u64 rq_mmap_size;
105 	__aligned_u64 rq_db_mmap_key;
106 	__aligned_u64 sq_db_mmap_key;
107 	__aligned_u64 llq_desc_mmap_key;
108 	__u16 send_sub_cq_idx;
109 	__u16 recv_sub_cq_idx;
110 	__u8 reserved_1e0[4];
111 };
112 
113 struct efa_ibv_create_ah_resp {
114 	__u32 comp_mask;
115 	__u16 efa_address_handle;
116 	__u8 reserved_30[2];
117 };
118 
119 enum {
120 	EFA_QUERY_DEVICE_CAPS_RDMA_READ = 1 << 0,
121 	EFA_QUERY_DEVICE_CAPS_RNR_RETRY = 1 << 1,
122 	EFA_QUERY_DEVICE_CAPS_CQ_NOTIFICATIONS = 1 << 2,
123 	EFA_QUERY_DEVICE_CAPS_CQ_WITH_SGID     = 1 << 3,
124 	EFA_QUERY_DEVICE_CAPS_DATA_POLLING_128 = 1 << 4,
125 	EFA_QUERY_DEVICE_CAPS_RDMA_WRITE = 1 << 5,
126 };
127 
128 struct efa_ibv_ex_query_device_resp {
129 	__u32 comp_mask;
130 	__u32 max_sq_wr;
131 	__u32 max_rq_wr;
132 	__u16 max_sq_sge;
133 	__u16 max_rq_sge;
134 	__u32 max_rdma_size;
135 	__u32 device_caps;
136 };
137 
138 enum {
139 	EFA_QUERY_MR_VALIDITY_RECV_IC_ID = 1 << 0,
140 	EFA_QUERY_MR_VALIDITY_RDMA_READ_IC_ID = 1 << 1,
141 	EFA_QUERY_MR_VALIDITY_RDMA_RECV_IC_ID = 1 << 2,
142 };
143 
144 enum efa_query_mr_attrs {
145 	EFA_IB_ATTR_QUERY_MR_HANDLE = (1U << UVERBS_ID_NS_SHIFT),
146 	EFA_IB_ATTR_QUERY_MR_RESP_IC_ID_VALIDITY,
147 	EFA_IB_ATTR_QUERY_MR_RESP_RECV_IC_ID,
148 	EFA_IB_ATTR_QUERY_MR_RESP_RDMA_READ_IC_ID,
149 	EFA_IB_ATTR_QUERY_MR_RESP_RDMA_RECV_IC_ID,
150 };
151 
152 enum efa_mr_methods {
153 	EFA_IB_METHOD_MR_QUERY = (1U << UVERBS_ID_NS_SHIFT),
154 };
155 
156 #endif /* EFA_ABI_USER_H */
157