Commit | Line | Data |
---|---|---|
db49b9d2 AG |
1 | /* |
2 | * Copyright (c) 2008 Oracle. All rights reserved. | |
3 | * | |
4 | * This software is available to you under a choice of one of two | |
5 | * licenses. You may choose to be licensed under the terms of the GNU | |
6 | * General Public License (GPL) Version 2, available from the file | |
7 | * COPYING in the main directory of this source tree, or the | |
8 | * OpenIB.org BSD license below: | |
9 | * | |
10 | * Redistribution and use in source and binary forms, with or | |
11 | * without modification, are permitted provided that the following | |
12 | * conditions are met: | |
13 | * | |
14 | * - Redistributions of source code must retain the above | |
15 | * copyright notice, this list of conditions and the following | |
16 | * disclaimer. | |
17 | * | |
18 | * - Redistributions in binary form must reproduce the above | |
19 | * copyright notice, this list of conditions and the following | |
20 | * disclaimer in the documentation and/or other materials | |
21 | * provided with the distribution. | |
22 | * | |
23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
24 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
25 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
26 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | |
27 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | |
28 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | |
29 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
30 | * SOFTWARE. | |
31 | * | |
32 | */ | |
33 | ||
34 | #ifndef _LINUX_RDS_H | |
35 | #define _LINUX_RDS_H | |
36 | ||
37 | #include <linux/types.h> | |
38 | ||
db49b9d2 AG |
39 | #define RDS_IB_ABI_VERSION 0x301 |
40 | ||
a28c257c SV |
41 | #define SOL_RDS 276 |
42 | ||
db49b9d2 AG |
43 | /* |
44 | * setsockopt/getsockopt for SOL_RDS | |
45 | */ | |
46 | #define RDS_CANCEL_SENT_TO 1 | |
47 | #define RDS_GET_MR 2 | |
48 | #define RDS_FREE_MR 3 | |
49 | /* deprecated: RDS_BARRIER 4 */ | |
50 | #define RDS_RECVERR 5 | |
51 | #define RDS_CONG_MONITOR 6 | |
244546f0 | 52 | #define RDS_GET_MR_FOR_DEST 7 |
a28c257c SV |
53 | #define SO_RDS_TRANSPORT 8 |
54 | ||
55 | /* supported values for SO_RDS_TRANSPORT */ | |
56 | #define RDS_TRANS_IB 0 | |
57 | #define RDS_TRANS_IWARP 1 | |
58 | #define RDS_TRANS_TCP 2 | |
59 | #define RDS_TRANS_COUNT 3 | |
60 | #define RDS_TRANS_NONE (~0) | |
db49b9d2 AG |
61 | |
62 | /* | |
63 | * Control message types for SOL_RDS. | |
64 | * | |
65 | * CMSG_RDMA_ARGS (sendmsg) | |
66 | * Request a RDMA transfer to/from the specified | |
67 | * memory ranges. | |
68 | * The cmsg_data is a struct rds_rdma_args. | |
69 | * RDS_CMSG_RDMA_DEST (recvmsg, sendmsg) | |
70 | * Kernel informs application about intended | |
71 | * source/destination of a RDMA transfer | |
72 | * RDS_CMSG_RDMA_MAP (sendmsg) | |
73 | * Application asks kernel to map the given | |
74 | * memory range into a IB MR, and send the | |
75 | * R_Key along in an RDS extension header. | |
76 | * The cmsg_data is a struct rds_get_mr_args, | |
77 | * the same as for the GET_MR setsockopt. | |
78 | * RDS_CMSG_RDMA_STATUS (recvmsg) | |
79 | * Returns the status of a completed RDMA operation. | |
80 | */ | |
81 | #define RDS_CMSG_RDMA_ARGS 1 | |
82 | #define RDS_CMSG_RDMA_DEST 2 | |
83 | #define RDS_CMSG_RDMA_MAP 3 | |
84 | #define RDS_CMSG_RDMA_STATUS 4 | |
85 | #define RDS_CMSG_CONG_UPDATE 5 | |
15133f6e AG |
86 | #define RDS_CMSG_ATOMIC_FADD 6 |
87 | #define RDS_CMSG_ATOMIC_CSWP 7 | |
20c72bd5 AG |
88 | #define RDS_CMSG_MASKED_ATOMIC_FADD 8 |
89 | #define RDS_CMSG_MASKED_ATOMIC_CSWP 9 | |
db49b9d2 AG |
90 | |
91 | #define RDS_INFO_FIRST 10000 | |
92 | #define RDS_INFO_COUNTERS 10000 | |
93 | #define RDS_INFO_CONNECTIONS 10001 | |
94 | /* 10002 aka RDS_INFO_FLOWS is deprecated */ | |
95 | #define RDS_INFO_SEND_MESSAGES 10003 | |
96 | #define RDS_INFO_RETRANS_MESSAGES 10004 | |
97 | #define RDS_INFO_RECV_MESSAGES 10005 | |
98 | #define RDS_INFO_SOCKETS 10006 | |
99 | #define RDS_INFO_TCP_SOCKETS 10007 | |
100 | #define RDS_INFO_IB_CONNECTIONS 10008 | |
101 | #define RDS_INFO_CONNECTION_STATS 10009 | |
102 | #define RDS_INFO_IWARP_CONNECTIONS 10010 | |
103 | #define RDS_INFO_LAST 10010 | |
104 | ||
105 | struct rds_info_counter { | |
a46f561b AG |
106 | uint8_t name[32]; |
107 | uint64_t value; | |
fd128dfa | 108 | } __attribute__((packed)); |
db49b9d2 AG |
109 | |
110 | #define RDS_INFO_CONNECTION_FLAG_SENDING 0x01 | |
111 | #define RDS_INFO_CONNECTION_FLAG_CONNECTING 0x02 | |
112 | #define RDS_INFO_CONNECTION_FLAG_CONNECTED 0x04 | |
113 | ||
114 | #define TRANSNAMSIZ 16 | |
115 | ||
116 | struct rds_info_connection { | |
a46f561b AG |
117 | uint64_t next_tx_seq; |
118 | uint64_t next_rx_seq; | |
db49b9d2 AG |
119 | __be32 laddr; |
120 | __be32 faddr; | |
a46f561b AG |
121 | uint8_t transport[TRANSNAMSIZ]; /* null term ascii */ |
122 | uint8_t flags; | |
fd128dfa | 123 | } __attribute__((packed)); |
db49b9d2 | 124 | |
db49b9d2 AG |
125 | #define RDS_INFO_MESSAGE_FLAG_ACK 0x01 |
126 | #define RDS_INFO_MESSAGE_FLAG_FAST_ACK 0x02 | |
127 | ||
128 | struct rds_info_message { | |
a46f561b AG |
129 | uint64_t seq; |
130 | uint32_t len; | |
db49b9d2 AG |
131 | __be32 laddr; |
132 | __be32 faddr; | |
133 | __be16 lport; | |
134 | __be16 fport; | |
a46f561b | 135 | uint8_t flags; |
fd128dfa | 136 | } __attribute__((packed)); |
db49b9d2 AG |
137 | |
138 | struct rds_info_socket { | |
a46f561b | 139 | uint32_t sndbuf; |
db49b9d2 AG |
140 | __be32 bound_addr; |
141 | __be32 connected_addr; | |
142 | __be16 bound_port; | |
143 | __be16 connected_port; | |
a46f561b AG |
144 | uint32_t rcvbuf; |
145 | uint64_t inum; | |
fd128dfa | 146 | } __attribute__((packed)); |
db49b9d2 | 147 | |
70041088 AG |
148 | struct rds_info_tcp_socket { |
149 | __be32 local_addr; | |
150 | __be16 local_port; | |
151 | __be32 peer_addr; | |
152 | __be16 peer_port; | |
a46f561b AG |
153 | uint64_t hdr_rem; |
154 | uint64_t data_rem; | |
155 | uint32_t last_sent_nxt; | |
156 | uint32_t last_expected_una; | |
157 | uint32_t last_seen_una; | |
fd128dfa | 158 | } __attribute__((packed)); |
70041088 | 159 | |
db49b9d2 AG |
160 | #define RDS_IB_GID_LEN 16 |
161 | struct rds_info_rdma_connection { | |
162 | __be32 src_addr; | |
163 | __be32 dst_addr; | |
164 | uint8_t src_gid[RDS_IB_GID_LEN]; | |
165 | uint8_t dst_gid[RDS_IB_GID_LEN]; | |
166 | ||
167 | uint32_t max_send_wr; | |
168 | uint32_t max_recv_wr; | |
169 | uint32_t max_send_sge; | |
170 | uint32_t rdma_mr_max; | |
171 | uint32_t rdma_mr_size; | |
172 | }; | |
173 | ||
174 | /* | |
175 | * Congestion monitoring. | |
176 | * Congestion control in RDS happens at the host connection | |
177 | * level by exchanging a bitmap marking congested ports. | |
178 | * By default, a process sleeping in poll() is always woken | |
179 | * up when the congestion map is updated. | |
180 | * With explicit monitoring, an application can have more | |
181 | * fine-grained control. | |
182 | * The application installs a 64bit mask value in the socket, | |
183 | * where each bit corresponds to a group of ports. | |
184 | * When a congestion update arrives, RDS checks the set of | |
185 | * ports that are now uncongested against the list bit mask | |
186 | * installed in the socket, and if they overlap, we queue a | |
187 | * cong_notification on the socket. | |
188 | * | |
189 | * To install the congestion monitor bitmask, use RDS_CONG_MONITOR | |
190 | * with the 64bit mask. | |
191 | * Congestion updates are received via RDS_CMSG_CONG_UPDATE | |
192 | * control messages. | |
193 | * | |
194 | * The correspondence between bits and ports is | |
195 | * 1 << (portnum % 64) | |
196 | */ | |
197 | #define RDS_CONG_MONITOR_SIZE 64 | |
198 | #define RDS_CONG_MONITOR_BIT(port) (((unsigned int) port) % RDS_CONG_MONITOR_SIZE) | |
199 | #define RDS_CONG_MONITOR_MASK(port) (1ULL << RDS_CONG_MONITOR_BIT(port)) | |
200 | ||
201 | /* | |
202 | * RDMA related types | |
203 | */ | |
204 | ||
205 | /* | |
206 | * This encapsulates a remote memory location. | |
207 | * In the current implementation, it contains the R_Key | |
208 | * of the remote memory region, and the offset into it | |
209 | * (so that the application does not have to worry about | |
210 | * alignment). | |
211 | */ | |
a46f561b | 212 | typedef uint64_t rds_rdma_cookie_t; |
db49b9d2 AG |
213 | |
214 | struct rds_iovec { | |
a46f561b AG |
215 | uint64_t addr; |
216 | uint64_t bytes; | |
db49b9d2 AG |
217 | }; |
218 | ||
219 | struct rds_get_mr_args { | |
220 | struct rds_iovec vec; | |
a46f561b | 221 | uint64_t cookie_addr; |
db49b9d2 AG |
222 | uint64_t flags; |
223 | }; | |
224 | ||
244546f0 AG |
225 | struct rds_get_mr_for_dest_args { |
226 | struct sockaddr_storage dest_addr; | |
227 | struct rds_iovec vec; | |
a46f561b | 228 | uint64_t cookie_addr; |
244546f0 AG |
229 | uint64_t flags; |
230 | }; | |
231 | ||
db49b9d2 AG |
232 | struct rds_free_mr_args { |
233 | rds_rdma_cookie_t cookie; | |
a46f561b | 234 | uint64_t flags; |
db49b9d2 AG |
235 | }; |
236 | ||
237 | struct rds_rdma_args { | |
238 | rds_rdma_cookie_t cookie; | |
239 | struct rds_iovec remote_vec; | |
a46f561b AG |
240 | uint64_t local_vec_addr; |
241 | uint64_t nr_local; | |
242 | uint64_t flags; | |
243 | uint64_t user_token; | |
db49b9d2 AG |
244 | }; |
245 | ||
15133f6e AG |
246 | struct rds_atomic_args { |
247 | rds_rdma_cookie_t cookie; | |
248 | uint64_t local_addr; | |
249 | uint64_t remote_addr; | |
250 | union { | |
251 | struct { | |
252 | uint64_t compare; | |
253 | uint64_t swap; | |
254 | } cswp; | |
255 | struct { | |
256 | uint64_t add; | |
257 | } fadd; | |
20c72bd5 AG |
258 | struct { |
259 | uint64_t compare; | |
260 | uint64_t swap; | |
261 | uint64_t compare_mask; | |
262 | uint64_t swap_mask; | |
263 | } m_cswp; | |
264 | struct { | |
265 | uint64_t add; | |
266 | uint64_t nocarry_mask; | |
267 | } m_fadd; | |
15133f6e AG |
268 | }; |
269 | uint64_t flags; | |
270 | uint64_t user_token; | |
271 | }; | |
272 | ||
db49b9d2 | 273 | struct rds_rdma_notify { |
a46f561b | 274 | uint64_t user_token; |
db49b9d2 AG |
275 | int32_t status; |
276 | }; | |
277 | ||
278 | #define RDS_RDMA_SUCCESS 0 | |
279 | #define RDS_RDMA_REMOTE_ERROR 1 | |
280 | #define RDS_RDMA_CANCELED 2 | |
281 | #define RDS_RDMA_DROPPED 3 | |
282 | #define RDS_RDMA_OTHER_ERROR 4 | |
283 | ||
284 | /* | |
285 | * Common set of flags for all RDMA related structs | |
286 | */ | |
287 | #define RDS_RDMA_READWRITE 0x0001 | |
288 | #define RDS_RDMA_FENCE 0x0002 /* use FENCE for immediate send */ | |
289 | #define RDS_RDMA_INVALIDATE 0x0004 /* invalidate R_Key after freeing MR */ | |
290 | #define RDS_RDMA_USE_ONCE 0x0008 /* free MR after use */ | |
291 | #define RDS_RDMA_DONTWAIT 0x0010 /* Don't wait in SET_BARRIER */ | |
292 | #define RDS_RDMA_NOTIFY_ME 0x0020 /* Notify when operation completes */ | |
2c3a5f9a | 293 | #define RDS_RDMA_SILENT 0x0040 /* Do not interrupt remote */ |
db49b9d2 AG |
294 | |
295 | #endif /* IB_RDS_H */ |