2 * Copyright (c) 2008 Oracle. All rights reserved.
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:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
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.
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
37 #include <linux/types.h>
39 #define RDS_IB_ABI_VERSION 0x301
42 * setsockopt/getsockopt for SOL_RDS
44 #define RDS_CANCEL_SENT_TO 1
47 /* deprecated: RDS_BARRIER 4 */
49 #define RDS_CONG_MONITOR 6
50 #define RDS_GET_MR_FOR_DEST 7
53 * Control message types for SOL_RDS.
55 * CMSG_RDMA_ARGS (sendmsg)
56 * Request a RDMA transfer to/from the specified
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.
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
76 #define RDS_CMSG_ATOMIC_FADD 6
77 #define RDS_CMSG_ATOMIC_CSWP 7
79 #define RDS_INFO_FIRST 10000
80 #define RDS_INFO_COUNTERS 10000
81 #define RDS_INFO_CONNECTIONS 10001
82 /* 10002 aka RDS_INFO_FLOWS is deprecated */
83 #define RDS_INFO_SEND_MESSAGES 10003
84 #define RDS_INFO_RETRANS_MESSAGES 10004
85 #define RDS_INFO_RECV_MESSAGES 10005
86 #define RDS_INFO_SOCKETS 10006
87 #define RDS_INFO_TCP_SOCKETS 10007
88 #define RDS_INFO_IB_CONNECTIONS 10008
89 #define RDS_INFO_CONNECTION_STATS 10009
90 #define RDS_INFO_IWARP_CONNECTIONS 10010
91 #define RDS_INFO_LAST 10010
93 struct rds_info_counter {
98 #define RDS_INFO_CONNECTION_FLAG_SENDING 0x01
99 #define RDS_INFO_CONNECTION_FLAG_CONNECTING 0x02
100 #define RDS_INFO_CONNECTION_FLAG_CONNECTED 0x04
102 #define TRANSNAMSIZ 16
104 struct rds_info_connection {
105 u_int64_t next_tx_seq;
106 u_int64_t next_rx_seq;
109 u_int8_t transport[TRANSNAMSIZ]; /* null term ascii */
113 struct rds_info_flow {
121 #define RDS_INFO_MESSAGE_FLAG_ACK 0x01
122 #define RDS_INFO_MESSAGE_FLAG_FAST_ACK 0x02
124 struct rds_info_message {
134 struct rds_info_socket {
137 __be32 connected_addr;
139 __be16 connected_port;
144 struct rds_info_tcp_socket {
151 u_int32_t last_sent_nxt;
152 u_int32_t last_expected_una;
153 u_int32_t last_seen_una;
156 #define RDS_IB_GID_LEN 16
157 struct rds_info_rdma_connection {
160 uint8_t src_gid[RDS_IB_GID_LEN];
161 uint8_t dst_gid[RDS_IB_GID_LEN];
163 uint32_t max_send_wr;
164 uint32_t max_recv_wr;
165 uint32_t max_send_sge;
166 uint32_t rdma_mr_max;
167 uint32_t rdma_mr_size;
171 * Congestion monitoring.
172 * Congestion control in RDS happens at the host connection
173 * level by exchanging a bitmap marking congested ports.
174 * By default, a process sleeping in poll() is always woken
175 * up when the congestion map is updated.
176 * With explicit monitoring, an application can have more
177 * fine-grained control.
178 * The application installs a 64bit mask value in the socket,
179 * where each bit corresponds to a group of ports.
180 * When a congestion update arrives, RDS checks the set of
181 * ports that are now uncongested against the list bit mask
182 * installed in the socket, and if they overlap, we queue a
183 * cong_notification on the socket.
185 * To install the congestion monitor bitmask, use RDS_CONG_MONITOR
186 * with the 64bit mask.
187 * Congestion updates are received via RDS_CMSG_CONG_UPDATE
190 * The correspondence between bits and ports is
191 * 1 << (portnum % 64)
193 #define RDS_CONG_MONITOR_SIZE 64
194 #define RDS_CONG_MONITOR_BIT(port) (((unsigned int) port) % RDS_CONG_MONITOR_SIZE)
195 #define RDS_CONG_MONITOR_MASK(port) (1ULL << RDS_CONG_MONITOR_BIT(port))
202 * This encapsulates a remote memory location.
203 * In the current implementation, it contains the R_Key
204 * of the remote memory region, and the offset into it
205 * (so that the application does not have to worry about
208 typedef u_int64_t rds_rdma_cookie_t;
215 struct rds_get_mr_args {
216 struct rds_iovec vec;
217 u_int64_t cookie_addr;
221 struct rds_get_mr_for_dest_args {
222 struct sockaddr_storage dest_addr;
223 struct rds_iovec vec;
224 u_int64_t cookie_addr;
228 struct rds_free_mr_args {
229 rds_rdma_cookie_t cookie;
233 struct rds_rdma_args {
234 rds_rdma_cookie_t cookie;
235 struct rds_iovec remote_vec;
236 u_int64_t local_vec_addr;
239 u_int64_t user_token;
242 struct rds_atomic_args {
243 rds_rdma_cookie_t cookie;
245 uint64_t remote_addr;
259 struct rds_rdma_notify {
260 u_int64_t user_token;
264 #define RDS_RDMA_SUCCESS 0
265 #define RDS_RDMA_REMOTE_ERROR 1
266 #define RDS_RDMA_CANCELED 2
267 #define RDS_RDMA_DROPPED 3
268 #define RDS_RDMA_OTHER_ERROR 4
271 * Common set of flags for all RDMA related structs
273 #define RDS_RDMA_READWRITE 0x0001
274 #define RDS_RDMA_FENCE 0x0002 /* use FENCE for immediate send */
275 #define RDS_RDMA_INVALIDATE 0x0004 /* invalidate R_Key after freeing MR */
276 #define RDS_RDMA_USE_ONCE 0x0008 /* free MR after use */
277 #define RDS_RDMA_DONTWAIT 0x0010 /* Don't wait in SET_BARRIER */
278 #define RDS_RDMA_NOTIFY_ME 0x0020 /* Notify when operation completes */
280 #endif /* IB_RDS_H */