]> bbs.cooldavid.org Git - net-next-2.6.git/blame - include/linux/rds.h
jbd: Use offset_in_page() instead of manual calculation
[net-next-2.6.git] / include / linux / rds.h
CommitLineData
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
39/* These sparse annotated types shouldn't be in any user
40 * visible header file. We should clean this up rather
41 * than kludging around them. */
42#ifndef __KERNEL__
43#define __be16 u_int16_t
44#define __be32 u_int32_t
45#define __be64 u_int64_t
46#endif
47
48#define RDS_IB_ABI_VERSION 0x301
49
50/*
51 * setsockopt/getsockopt for SOL_RDS
52 */
53#define RDS_CANCEL_SENT_TO 1
54#define RDS_GET_MR 2
55#define RDS_FREE_MR 3
56/* deprecated: RDS_BARRIER 4 */
57#define RDS_RECVERR 5
58#define RDS_CONG_MONITOR 6
244546f0 59#define RDS_GET_MR_FOR_DEST 7
db49b9d2
AG
60
61/*
62 * Control message types for SOL_RDS.
63 *
64 * CMSG_RDMA_ARGS (sendmsg)
65 * Request a RDMA transfer to/from the specified
66 * memory ranges.
67 * The cmsg_data is a struct rds_rdma_args.
68 * RDS_CMSG_RDMA_DEST (recvmsg, sendmsg)
69 * Kernel informs application about intended
70 * source/destination of a RDMA transfer
71 * RDS_CMSG_RDMA_MAP (sendmsg)
72 * Application asks kernel to map the given
73 * memory range into a IB MR, and send the
74 * R_Key along in an RDS extension header.
75 * The cmsg_data is a struct rds_get_mr_args,
76 * the same as for the GET_MR setsockopt.
77 * RDS_CMSG_RDMA_STATUS (recvmsg)
78 * Returns the status of a completed RDMA operation.
79 */
80#define RDS_CMSG_RDMA_ARGS 1
81#define RDS_CMSG_RDMA_DEST 2
82#define RDS_CMSG_RDMA_MAP 3
83#define RDS_CMSG_RDMA_STATUS 4
84#define RDS_CMSG_CONG_UPDATE 5
85
86#define RDS_INFO_FIRST 10000
87#define RDS_INFO_COUNTERS 10000
88#define RDS_INFO_CONNECTIONS 10001
89/* 10002 aka RDS_INFO_FLOWS is deprecated */
90#define RDS_INFO_SEND_MESSAGES 10003
91#define RDS_INFO_RETRANS_MESSAGES 10004
92#define RDS_INFO_RECV_MESSAGES 10005
93#define RDS_INFO_SOCKETS 10006
94#define RDS_INFO_TCP_SOCKETS 10007
95#define RDS_INFO_IB_CONNECTIONS 10008
96#define RDS_INFO_CONNECTION_STATS 10009
97#define RDS_INFO_IWARP_CONNECTIONS 10010
98#define RDS_INFO_LAST 10010
99
100struct rds_info_counter {
101 u_int8_t name[32];
102 u_int64_t value;
bc10502d 103} __packed;
db49b9d2
AG
104
105#define RDS_INFO_CONNECTION_FLAG_SENDING 0x01
106#define RDS_INFO_CONNECTION_FLAG_CONNECTING 0x02
107#define RDS_INFO_CONNECTION_FLAG_CONNECTED 0x04
108
109#define TRANSNAMSIZ 16
110
111struct rds_info_connection {
112 u_int64_t next_tx_seq;
113 u_int64_t next_rx_seq;
114 __be32 laddr;
115 __be32 faddr;
116 u_int8_t transport[TRANSNAMSIZ]; /* null term ascii */
117 u_int8_t flags;
bc10502d 118} __packed;
db49b9d2
AG
119
120struct rds_info_flow {
121 __be32 laddr;
122 __be32 faddr;
123 u_int32_t bytes;
124 __be16 lport;
125 __be16 fport;
bc10502d 126} __packed;
db49b9d2
AG
127
128#define RDS_INFO_MESSAGE_FLAG_ACK 0x01
129#define RDS_INFO_MESSAGE_FLAG_FAST_ACK 0x02
130
131struct rds_info_message {
132 u_int64_t seq;
133 u_int32_t len;
134 __be32 laddr;
135 __be32 faddr;
136 __be16 lport;
137 __be16 fport;
138 u_int8_t flags;
bc10502d 139} __packed;
db49b9d2
AG
140
141struct rds_info_socket {
142 u_int32_t sndbuf;
143 __be32 bound_addr;
144 __be32 connected_addr;
145 __be16 bound_port;
146 __be16 connected_port;
147 u_int32_t rcvbuf;
148 u_int64_t inum;
bc10502d 149} __packed;
db49b9d2 150
70041088
AG
151struct rds_info_tcp_socket {
152 __be32 local_addr;
153 __be16 local_port;
154 __be32 peer_addr;
155 __be16 peer_port;
156 u_int64_t hdr_rem;
157 u_int64_t data_rem;
158 u_int32_t last_sent_nxt;
159 u_int32_t last_expected_una;
160 u_int32_t last_seen_una;
bc10502d 161} __packed;
70041088 162
db49b9d2
AG
163#define RDS_IB_GID_LEN 16
164struct rds_info_rdma_connection {
165 __be32 src_addr;
166 __be32 dst_addr;
167 uint8_t src_gid[RDS_IB_GID_LEN];
168 uint8_t dst_gid[RDS_IB_GID_LEN];
169
170 uint32_t max_send_wr;
171 uint32_t max_recv_wr;
172 uint32_t max_send_sge;
173 uint32_t rdma_mr_max;
174 uint32_t rdma_mr_size;
175};
176
177/*
178 * Congestion monitoring.
179 * Congestion control in RDS happens at the host connection
180 * level by exchanging a bitmap marking congested ports.
181 * By default, a process sleeping in poll() is always woken
182 * up when the congestion map is updated.
183 * With explicit monitoring, an application can have more
184 * fine-grained control.
185 * The application installs a 64bit mask value in the socket,
186 * where each bit corresponds to a group of ports.
187 * When a congestion update arrives, RDS checks the set of
188 * ports that are now uncongested against the list bit mask
189 * installed in the socket, and if they overlap, we queue a
190 * cong_notification on the socket.
191 *
192 * To install the congestion monitor bitmask, use RDS_CONG_MONITOR
193 * with the 64bit mask.
194 * Congestion updates are received via RDS_CMSG_CONG_UPDATE
195 * control messages.
196 *
197 * The correspondence between bits and ports is
198 * 1 << (portnum % 64)
199 */
200#define RDS_CONG_MONITOR_SIZE 64
201#define RDS_CONG_MONITOR_BIT(port) (((unsigned int) port) % RDS_CONG_MONITOR_SIZE)
202#define RDS_CONG_MONITOR_MASK(port) (1ULL << RDS_CONG_MONITOR_BIT(port))
203
204/*
205 * RDMA related types
206 */
207
208/*
209 * This encapsulates a remote memory location.
210 * In the current implementation, it contains the R_Key
211 * of the remote memory region, and the offset into it
212 * (so that the application does not have to worry about
213 * alignment).
214 */
215typedef u_int64_t rds_rdma_cookie_t;
216
217struct rds_iovec {
218 u_int64_t addr;
219 u_int64_t bytes;
220};
221
222struct rds_get_mr_args {
223 struct rds_iovec vec;
224 u_int64_t cookie_addr;
225 uint64_t flags;
226};
227
244546f0
AG
228struct rds_get_mr_for_dest_args {
229 struct sockaddr_storage dest_addr;
230 struct rds_iovec vec;
231 u_int64_t cookie_addr;
232 uint64_t flags;
233};
234
db49b9d2
AG
235struct rds_free_mr_args {
236 rds_rdma_cookie_t cookie;
237 u_int64_t flags;
238};
239
240struct rds_rdma_args {
241 rds_rdma_cookie_t cookie;
242 struct rds_iovec remote_vec;
243 u_int64_t local_vec_addr;
244 u_int64_t nr_local;
245 u_int64_t flags;
246 u_int64_t user_token;
247};
248
249struct rds_rdma_notify {
250 u_int64_t user_token;
251 int32_t status;
252};
253
254#define RDS_RDMA_SUCCESS 0
255#define RDS_RDMA_REMOTE_ERROR 1
256#define RDS_RDMA_CANCELED 2
257#define RDS_RDMA_DROPPED 3
258#define RDS_RDMA_OTHER_ERROR 4
259
260/*
261 * Common set of flags for all RDMA related structs
262 */
263#define RDS_RDMA_READWRITE 0x0001
264#define RDS_RDMA_FENCE 0x0002 /* use FENCE for immediate send */
265#define RDS_RDMA_INVALIDATE 0x0004 /* invalidate R_Key after freeing MR */
266#define RDS_RDMA_USE_ONCE 0x0008 /* free MR after use */
267#define RDS_RDMA_DONTWAIT 0x0010 /* Don't wait in SET_BARRIER */
268#define RDS_RDMA_NOTIFY_ME 0x0020 /* Notify when operation completes */
269
270#endif /* IB_RDS_H */