2 * This file contains definitions used in OFED defined user/kernel
3 * interfaces. These are imported from the OFED header <linux/rds.h>. Oracle
4 * elects to have and use the contents of <linux/rds.h> under and governed
5 * by the OpenIB.org BSD license (see below for full license text). However,
6 * the following notice accompanied the original version of this file:
9 * Copyright (c) 2008 Oracle. All rights reserved.
11 * This software is available to you under a choice of one of two
12 * licenses. You may choose to be licensed under the terms of the GNU
13 * General Public License (GPL) Version 2, available from the file
14 * COPYING in the main directory of this source tree, or the
15 * OpenIB.org BSD license below:
17 * Redistribution and use in source and binary forms, with or
18 * without modification, are permitted provided that the following
21 * - Redistributions of source code must retain the above
22 * copyright notice, this list of conditions and the following
25 * - Redistributions in binary form must reproduce the above
26 * copyright notice, this list of conditions and the following
27 * disclaimer in the documentation and/or other materials
28 * provided with the distribution.
30 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
34 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
35 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
36 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
47 #if !(defined(__SVR4) && defined(__sun))
48 #include <linux/types.h>
50 #include <sys/types.h>
51 #include <sys/socket.h>
55 * These sparse annotated types shouldn't be in any user
56 * visible header file. We should clean this up rather
57 * than kludging around them.
59 #if !(defined(__SVR4) && defined(__sun))
61 #define __be16 u_int16_t
62 #define __be32 u_int32_t
63 #define __be64 u_int64_t
66 #define u_int8_t uint8_t
67 #define u_int16_t uint16_t
68 #define u_int32_t uint32_t
69 #define u_int64_t uint64_t
72 #define RDS_IB_ABI_VERSION 0x301
74 #define AF_RDS AF_INET_OFFLOAD
75 #define PF_RDS AF_INET_OFFLOAD
79 * setsockopt/getsockopt for SOL_RDS
81 #define RDS_CANCEL_SENT_TO 1
84 /* deprecated: RDS_BARRIER 4 */
86 #define RDS_CONG_MONITOR 6
87 #define RDS_GET_MR_FOR_DEST 7
91 * Control message types for SOL_RDS.
93 * CMSG_RDMA_ARGS (sendmsg)
94 * Request a RDMA transfer to/from the specified
96 * The cmsg_data is a struct rds_rdma_args.
97 * RDS_CMSG_RDMA_DEST (recvmsg, sendmsg)
98 * Kernel informs application about intended
99 * source/destination of a RDMA transfer
100 * RDS_CMSG_RDMA_MAP (sendmsg)
101 * Application asks kernel to map the given
102 * memory range into a IB MR, and send the
103 * R_Key along in an RDS extension header.
104 * The cmsg_data is a struct rds_get_mr_args,
105 * the same as for the GET_MR setsockopt.
106 * RDS_CMSG_RDMA_STATUS (recvmsg)
107 * Returns the status of a completed RDMA operation.
109 #define RDS_CMSG_RDMA_ARGS 1
110 #define RDS_CMSG_RDMA_DEST 2
111 #define RDS_CMSG_RDMA_MAP 3
112 #define RDS_CMSG_RDMA_STATUS 4
113 #define RDS_CMSG_CONG_UPDATE 5
115 #define RDS_INFO_FIRST 10000
116 #define RDS_INFO_COUNTERS 10000
117 #define RDS_INFO_CONNECTIONS 10001
118 /* 10002 aka RDS_INFO_FLOWS is deprecated */
119 #define RDS_INFO_SEND_MESSAGES 10003
120 #define RDS_INFO_RETRANS_MESSAGES 10004
121 #define RDS_INFO_RECV_MESSAGES 10005
122 #define RDS_INFO_SOCKETS 10006
123 #define RDS_INFO_TCP_SOCKETS 10007
124 #define RDS_INFO_IB_CONNECTIONS 10008
125 #define RDS_INFO_CONNECTION_STATS 10009
126 #define RDS_INFO_IWARP_CONNECTIONS 10010
127 #define RDS_INFO_LAST 10010
129 #if defined(__SVR4) && defined(__sun)
130 struct rds_info_arg
{
138 struct rds_info_counter
{
141 } __attribute__((packed
));
144 struct rds_info_counter
{
150 #define RDS_INFO_CONNECTION_FLAG_SENDING 0x01
151 #define RDS_INFO_CONNECTION_FLAG_CONNECTING 0x02
152 #define RDS_INFO_CONNECTION_FLAG_CONNECTED 0x04
154 #define TRANSNAMSIZ 16
158 struct rds_info_connection
{
159 u_int64_t next_tx_seq
;
160 u_int64_t next_rx_seq
;
163 u_int8_t transport
[TRANSNAMSIZ
]; /* null term ascii */
165 } __attribute__((packed
));
168 struct rds_info_connection
{
169 u_int64_t next_tx_seq
;
170 u_int64_t next_rx_seq
;
173 u_int8_t transport
[TRANSNAMSIZ
]; /* null term ascii */
180 struct rds_info_flow
{
186 } __attribute__((packed
));
189 struct rds_info_flow
{
198 #define RDS_INFO_MESSAGE_FLAG_ACK 0x01
199 #define RDS_INFO_MESSAGE_FLAG_FAST_ACK 0x02
203 struct rds_info_message
{
211 } __attribute__((packed
));
214 struct rds_info_message
{
227 struct rds_info_socket
{
229 u_int32_t bound_addr
;
230 u_int32_t connected_addr
;
231 u_int16_t bound_port
;
232 u_int16_t connected_port
;
235 } __attribute__((packed
));
238 struct rds_info_socket
{
240 u_int32_t bound_addr
;
241 u_int32_t connected_addr
;
242 u_int16_t bound_port
;
243 u_int16_t connected_port
;
251 struct rds_info_tcp_socket
{
252 u_int32_t local_addr
;
253 u_int16_t local_port
;
258 u_int32_t last_sent_nxt
;
259 u_int32_t last_expected_una
;
260 u_int32_t last_seen_una
;
261 } __attribute__((packed
));
264 struct rds_info_tcp_socket
{
265 u_int32_t local_addr
;
266 u_int16_t local_port
;
271 u_int32_t last_sent_nxt
;
272 u_int32_t last_expected_una
;
273 u_int32_t last_seen_una
;
274 } __attribute__((packed
));
278 #define RDS_IB_GID_LEN 16
279 struct rds_info_rdma_connection
{
282 uint8_t src_gid
[RDS_IB_GID_LEN
];
283 uint8_t dst_gid
[RDS_IB_GID_LEN
];
285 uint32_t max_send_wr
;
286 uint32_t max_recv_wr
;
287 uint32_t max_send_sge
;
288 uint32_t rdma_mr_max
;
289 uint32_t rdma_mr_size
;
293 * Congestion monitoring.
294 * Congestion control in RDS happens at the host connection
295 * level by exchanging a bitmap marking congested ports.
296 * By default, a process sleeping in poll() is always woken
297 * up when the congestion map is updated.
298 * With explicit monitoring, an application can have more
299 * fine-grained control.
300 * The application installs a 64bit mask value in the socket,
301 * where each bit corresponds to a group of ports.
302 * When a congestion update arrives, RDS checks the set of
303 * ports that are now uncongested against the list bit mask
304 * installed in the socket, and if they overlap, we queue a
305 * cong_notification on the socket.
307 * To install the congestion monitor bitmask, use RDS_CONG_MONITOR
308 * with the 64bit mask.
309 * Congestion updates are received via RDS_CMSG_CONG_UPDATE
312 * The correspondence between bits and ports is
313 * 1 << (portnum % 64)
315 #define RDS_CONG_MONITOR_SIZE 64
316 #define RDS_CONG_MONITOR_BIT(port) \
317 (((unsigned int) port) % RDS_CONG_MONITOR_SIZE)
318 #define RDS_CONG_MONITOR_MASK(port) (1ULL << RDS_CONG_MONITOR_BIT(port))
325 * This encapsulates a remote memory location.
326 * In the current implementation, it contains the R_Key
327 * of the remote memory region, and the offset into it
328 * (so that the application does not have to worry about
331 typedef u_int64_t rds_rdma_cookie_t
;
338 struct rds_get_mr_args
{
339 struct rds_iovec vec
;
340 u_int64_t cookie_addr
;
344 struct rds_get_mr_for_dest_args
{
345 struct sockaddr_storage dest_addr
;
346 struct rds_iovec vec
;
347 u_int64_t cookie_addr
;
352 struct rds_free_mr_args
{
353 rds_rdma_cookie_t cookie
;
357 struct rds_rdma_args
{
358 rds_rdma_cookie_t cookie
;
359 struct rds_iovec remote_vec
;
360 u_int64_t local_vec_addr
;
363 u_int64_t user_token
;
366 struct rds_rdma_notify
{
367 u_int64_t user_token
;
371 #define RDS_RDMA_SUCCESS 0
372 #define RDS_RDMA_REMOTE_ERROR 1
373 #define RDS_RDMA_CANCELED 2
374 #define RDS_RDMA_DROPPED 3
375 #define RDS_RDMA_OTHER_ERROR 4
378 * Common set of flags for all RDMA related structs
380 #define RDS_RDMA_READWRITE 0x0001
381 #define RDS_RDMA_FENCE 0x0002 /* use FENCE for immediate send */
382 #define RDS_RDMA_INVALIDATE 0x0004 /* invalidate R_Key after freeing MR */
383 #define RDS_RDMA_USE_ONCE 0x0008 /* free MR after use */
384 #define RDS_RDMA_DONTWAIT 0x0010 /* Don't wait in SET_BARRIER */
385 #define RDS_RDMA_NOTIFY_ME 0x0020 /* Notify when operation completes */
391 #endif /* _SYS_RDS_H */