blob: 91950950aa598060a8e0e370f82654cd9a75e7d6 [file] [log] [blame]
Andy Groverdb49b9d2009-02-24 15:30:42 +00001/*
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
Andy Groverdb49b9d2009-02-24 15:30:42 +000039#define RDS_IB_ABI_VERSION 0x301
40
41/*
42 * setsockopt/getsockopt for SOL_RDS
43 */
44#define RDS_CANCEL_SENT_TO 1
45#define RDS_GET_MR 2
46#define RDS_FREE_MR 3
47/* deprecated: RDS_BARRIER 4 */
48#define RDS_RECVERR 5
49#define RDS_CONG_MONITOR 6
Andy Grover244546f2009-10-30 08:54:53 +000050#define RDS_GET_MR_FOR_DEST 7
Andy Groverdb49b9d2009-02-24 15:30:42 +000051
52/*
53 * Control message types for SOL_RDS.
54 *
55 * CMSG_RDMA_ARGS (sendmsg)
56 * Request a RDMA transfer to/from the specified
57 * memory ranges.
58 * The cmsg_data is a struct rds_rdma_args.
59 * RDS_CMSG_RDMA_DEST (recvmsg, sendmsg)
60 * Kernel informs application about intended
61 * source/destination of a RDMA transfer
62 * RDS_CMSG_RDMA_MAP (sendmsg)
63 * Application asks kernel to map the given
64 * memory range into a IB MR, and send the
65 * R_Key along in an RDS extension header.
66 * The cmsg_data is a struct rds_get_mr_args,
67 * the same as for the GET_MR setsockopt.
68 * RDS_CMSG_RDMA_STATUS (recvmsg)
69 * Returns the status of a completed RDMA operation.
70 */
71#define RDS_CMSG_RDMA_ARGS 1
72#define RDS_CMSG_RDMA_DEST 2
73#define RDS_CMSG_RDMA_MAP 3
74#define RDS_CMSG_RDMA_STATUS 4
75#define RDS_CMSG_CONG_UPDATE 5
Andy Grover15133f62010-01-12 14:33:38 -080076#define RDS_CMSG_ATOMIC_FADD 6
77#define RDS_CMSG_ATOMIC_CSWP 7
Andy Grover20c72bd2010-08-25 05:51:28 -070078#define RDS_CMSG_MASKED_ATOMIC_FADD 8
79#define RDS_CMSG_MASKED_ATOMIC_CSWP 9
Andy Groverdb49b9d2009-02-24 15:30:42 +000080
81#define RDS_INFO_FIRST 10000
82#define RDS_INFO_COUNTERS 10000
83#define RDS_INFO_CONNECTIONS 10001
84/* 10002 aka RDS_INFO_FLOWS is deprecated */
85#define RDS_INFO_SEND_MESSAGES 10003
86#define RDS_INFO_RETRANS_MESSAGES 10004
87#define RDS_INFO_RECV_MESSAGES 10005
88#define RDS_INFO_SOCKETS 10006
89#define RDS_INFO_TCP_SOCKETS 10007
90#define RDS_INFO_IB_CONNECTIONS 10008
91#define RDS_INFO_CONNECTION_STATS 10009
92#define RDS_INFO_IWARP_CONNECTIONS 10010
93#define RDS_INFO_LAST 10010
94
95struct rds_info_counter {
Andy Grovera46f5612010-08-25 09:34:10 -070096 uint8_t name[32];
97 uint64_t value;
Andy Groverfd128df2010-08-25 09:32:17 -070098} __attribute__((packed));
Andy Groverdb49b9d2009-02-24 15:30:42 +000099
100#define RDS_INFO_CONNECTION_FLAG_SENDING 0x01
101#define RDS_INFO_CONNECTION_FLAG_CONNECTING 0x02
102#define RDS_INFO_CONNECTION_FLAG_CONNECTED 0x04
103
104#define TRANSNAMSIZ 16
105
106struct rds_info_connection {
Andy Grovera46f5612010-08-25 09:34:10 -0700107 uint64_t next_tx_seq;
108 uint64_t next_rx_seq;
Andy Groverdb49b9d2009-02-24 15:30:42 +0000109 __be32 laddr;
110 __be32 faddr;
Andy Grovera46f5612010-08-25 09:34:10 -0700111 uint8_t transport[TRANSNAMSIZ]; /* null term ascii */
112 uint8_t flags;
Andy Groverfd128df2010-08-25 09:32:17 -0700113} __attribute__((packed));
Andy Groverdb49b9d2009-02-24 15:30:42 +0000114
Andy Groverdb49b9d2009-02-24 15:30:42 +0000115#define RDS_INFO_MESSAGE_FLAG_ACK 0x01
116#define RDS_INFO_MESSAGE_FLAG_FAST_ACK 0x02
117
118struct rds_info_message {
Andy Grovera46f5612010-08-25 09:34:10 -0700119 uint64_t seq;
120 uint32_t len;
Andy Groverdb49b9d2009-02-24 15:30:42 +0000121 __be32 laddr;
122 __be32 faddr;
123 __be16 lport;
124 __be16 fport;
Andy Grovera46f5612010-08-25 09:34:10 -0700125 uint8_t flags;
Andy Groverfd128df2010-08-25 09:32:17 -0700126} __attribute__((packed));
Andy Groverdb49b9d2009-02-24 15:30:42 +0000127
128struct rds_info_socket {
Andy Grovera46f5612010-08-25 09:34:10 -0700129 uint32_t sndbuf;
Andy Groverdb49b9d2009-02-24 15:30:42 +0000130 __be32 bound_addr;
131 __be32 connected_addr;
132 __be16 bound_port;
133 __be16 connected_port;
Andy Grovera46f5612010-08-25 09:34:10 -0700134 uint32_t rcvbuf;
135 uint64_t inum;
Andy Groverfd128df2010-08-25 09:32:17 -0700136} __attribute__((packed));
Andy Groverdb49b9d2009-02-24 15:30:42 +0000137
Andy Grover70041082009-08-21 12:28:31 +0000138struct rds_info_tcp_socket {
139 __be32 local_addr;
140 __be16 local_port;
141 __be32 peer_addr;
142 __be16 peer_port;
Andy Grovera46f5612010-08-25 09:34:10 -0700143 uint64_t hdr_rem;
144 uint64_t data_rem;
145 uint32_t last_sent_nxt;
146 uint32_t last_expected_una;
147 uint32_t last_seen_una;
Andy Groverfd128df2010-08-25 09:32:17 -0700148} __attribute__((packed));
Andy Grover70041082009-08-21 12:28:31 +0000149
Andy Groverdb49b9d2009-02-24 15:30:42 +0000150#define RDS_IB_GID_LEN 16
151struct rds_info_rdma_connection {
152 __be32 src_addr;
153 __be32 dst_addr;
154 uint8_t src_gid[RDS_IB_GID_LEN];
155 uint8_t dst_gid[RDS_IB_GID_LEN];
156
157 uint32_t max_send_wr;
158 uint32_t max_recv_wr;
159 uint32_t max_send_sge;
160 uint32_t rdma_mr_max;
161 uint32_t rdma_mr_size;
162};
163
164/*
165 * Congestion monitoring.
166 * Congestion control in RDS happens at the host connection
167 * level by exchanging a bitmap marking congested ports.
168 * By default, a process sleeping in poll() is always woken
169 * up when the congestion map is updated.
170 * With explicit monitoring, an application can have more
171 * fine-grained control.
172 * The application installs a 64bit mask value in the socket,
173 * where each bit corresponds to a group of ports.
174 * When a congestion update arrives, RDS checks the set of
175 * ports that are now uncongested against the list bit mask
176 * installed in the socket, and if they overlap, we queue a
177 * cong_notification on the socket.
178 *
179 * To install the congestion monitor bitmask, use RDS_CONG_MONITOR
180 * with the 64bit mask.
181 * Congestion updates are received via RDS_CMSG_CONG_UPDATE
182 * control messages.
183 *
184 * The correspondence between bits and ports is
185 * 1 << (portnum % 64)
186 */
187#define RDS_CONG_MONITOR_SIZE 64
188#define RDS_CONG_MONITOR_BIT(port) (((unsigned int) port) % RDS_CONG_MONITOR_SIZE)
189#define RDS_CONG_MONITOR_MASK(port) (1ULL << RDS_CONG_MONITOR_BIT(port))
190
191/*
192 * RDMA related types
193 */
194
195/*
196 * This encapsulates a remote memory location.
197 * In the current implementation, it contains the R_Key
198 * of the remote memory region, and the offset into it
199 * (so that the application does not have to worry about
200 * alignment).
201 */
Andy Grovera46f5612010-08-25 09:34:10 -0700202typedef uint64_t rds_rdma_cookie_t;
Andy Groverdb49b9d2009-02-24 15:30:42 +0000203
204struct rds_iovec {
Andy Grovera46f5612010-08-25 09:34:10 -0700205 uint64_t addr;
206 uint64_t bytes;
Andy Groverdb49b9d2009-02-24 15:30:42 +0000207};
208
209struct rds_get_mr_args {
210 struct rds_iovec vec;
Andy Grovera46f5612010-08-25 09:34:10 -0700211 uint64_t cookie_addr;
Andy Groverdb49b9d2009-02-24 15:30:42 +0000212 uint64_t flags;
213};
214
Andy Grover244546f2009-10-30 08:54:53 +0000215struct rds_get_mr_for_dest_args {
216 struct sockaddr_storage dest_addr;
217 struct rds_iovec vec;
Andy Grovera46f5612010-08-25 09:34:10 -0700218 uint64_t cookie_addr;
Andy Grover244546f2009-10-30 08:54:53 +0000219 uint64_t flags;
220};
221
Andy Groverdb49b9d2009-02-24 15:30:42 +0000222struct rds_free_mr_args {
223 rds_rdma_cookie_t cookie;
Andy Grovera46f5612010-08-25 09:34:10 -0700224 uint64_t flags;
Andy Groverdb49b9d2009-02-24 15:30:42 +0000225};
226
227struct rds_rdma_args {
228 rds_rdma_cookie_t cookie;
229 struct rds_iovec remote_vec;
Andy Grovera46f5612010-08-25 09:34:10 -0700230 uint64_t local_vec_addr;
231 uint64_t nr_local;
232 uint64_t flags;
233 uint64_t user_token;
Andy Groverdb49b9d2009-02-24 15:30:42 +0000234};
235
Andy Grover15133f62010-01-12 14:33:38 -0800236struct rds_atomic_args {
237 rds_rdma_cookie_t cookie;
238 uint64_t local_addr;
239 uint64_t remote_addr;
240 union {
241 struct {
242 uint64_t compare;
243 uint64_t swap;
244 } cswp;
245 struct {
246 uint64_t add;
247 } fadd;
Andy Grover20c72bd2010-08-25 05:51:28 -0700248 struct {
249 uint64_t compare;
250 uint64_t swap;
251 uint64_t compare_mask;
252 uint64_t swap_mask;
253 } m_cswp;
254 struct {
255 uint64_t add;
256 uint64_t nocarry_mask;
257 } m_fadd;
Andy Grover15133f62010-01-12 14:33:38 -0800258 };
259 uint64_t flags;
260 uint64_t user_token;
261};
262
Andy Groverdb49b9d2009-02-24 15:30:42 +0000263struct rds_rdma_notify {
Andy Grovera46f5612010-08-25 09:34:10 -0700264 uint64_t user_token;
Andy Groverdb49b9d2009-02-24 15:30:42 +0000265 int32_t status;
266};
267
268#define RDS_RDMA_SUCCESS 0
269#define RDS_RDMA_REMOTE_ERROR 1
270#define RDS_RDMA_CANCELED 2
271#define RDS_RDMA_DROPPED 3
272#define RDS_RDMA_OTHER_ERROR 4
273
274/*
275 * Common set of flags for all RDMA related structs
276 */
277#define RDS_RDMA_READWRITE 0x0001
278#define RDS_RDMA_FENCE 0x0002 /* use FENCE for immediate send */
279#define RDS_RDMA_INVALIDATE 0x0004 /* invalidate R_Key after freeing MR */
280#define RDS_RDMA_USE_ONCE 0x0008 /* free MR after use */
281#define RDS_RDMA_DONTWAIT 0x0010 /* Don't wait in SET_BARRIER */
282#define RDS_RDMA_NOTIFY_ME 0x0020 /* Notify when operation completes */
Andy Grover2c3a5f92010-03-01 16:10:40 -0800283#define RDS_RDMA_SILENT 0x0040 /* Do not interrupt remote */
Andy Groverdb49b9d2009-02-24 15:30:42 +0000284
285#endif /* IB_RDS_H */