Commit | Line | Data |
---|---|---|
f58851e6 TT |
1 | /* |
2 | * Copyright (c) 2003-2007 Network Appliance, Inc. 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 BSD-type | |
8 | * license below: | |
9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | |
13 | * | |
14 | * Redistributions of source code must retain the above copyright | |
15 | * notice, this list of conditions and the following disclaimer. | |
16 | * | |
17 | * Redistributions in binary form must reproduce the above | |
18 | * copyright notice, this list of conditions and the following | |
19 | * disclaimer in the documentation and/or other materials provided | |
20 | * with the distribution. | |
21 | * | |
22 | * Neither the name of the Network Appliance, Inc. nor the names of | |
23 | * its contributors may be used to endorse or promote products | |
24 | * derived from this software without specific prior written | |
25 | * permission. | |
26 | * | |
27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
30 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
31 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
32 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
33 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
34 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
35 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
36 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
37 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
38 | */ | |
39 | ||
40 | #ifndef _LINUX_SUNRPC_XPRT_RDMA_H | |
41 | #define _LINUX_SUNRPC_XPRT_RDMA_H | |
42 | ||
43 | #include <linux/wait.h> /* wait_queue_head_t, etc */ | |
44 | #include <linux/spinlock.h> /* spinlock_t, etc */ | |
60063497 | 45 | #include <linux/atomic.h> /* atomic_t, etc */ |
254f91e2 | 46 | #include <linux/workqueue.h> /* struct work_struct */ |
f58851e6 TT |
47 | |
48 | #include <rdma/rdma_cm.h> /* RDMA connection api */ | |
49 | #include <rdma/ib_verbs.h> /* RDMA verbs api */ | |
50 | ||
51 | #include <linux/sunrpc/clnt.h> /* rpc_xprt */ | |
52 | #include <linux/sunrpc/rpc_rdma.h> /* RPC/RDMA protocol */ | |
53 | #include <linux/sunrpc/xprtrdma.h> /* xprt parameters */ | |
54 | ||
5675add3 TT |
55 | #define RDMA_RESOLVE_TIMEOUT (5000) /* 5 seconds */ |
56 | #define RDMA_CONNECT_RETRY_MAX (2) /* retries if no listener backlog */ | |
57 | ||
f58851e6 TT |
58 | /* |
59 | * Interface Adapter -- one per transport instance | |
60 | */ | |
61 | struct rpcrdma_ia { | |
a0ce85f5 | 62 | const struct rpcrdma_memreg_ops *ri_ops; |
73806c88 | 63 | rwlock_t ri_qplock; |
89e0d112 | 64 | struct ib_device *ri_device; |
f58851e6 TT |
65 | struct rdma_cm_id *ri_id; |
66 | struct ib_pd *ri_pd; | |
67 | struct ib_mr *ri_bind_mem; | |
fe9053b3 TT |
68 | u32 ri_dma_lkey; |
69 | int ri_have_dma_lkey; | |
f58851e6 TT |
70 | struct completion ri_done; |
71 | int ri_async_rc; | |
0fc6c4e7 | 72 | unsigned int ri_max_frmr_depth; |
7bc7972c | 73 | struct ib_device_attr ri_devattr; |
ce1ab9ab CL |
74 | struct ib_qp_attr ri_qp_attr; |
75 | struct ib_qp_init_attr ri_qp_init_attr; | |
f58851e6 TT |
76 | }; |
77 | ||
78 | /* | |
79 | * RDMA Endpoint -- one per transport instance | |
80 | */ | |
81 | ||
8301a2c0 | 82 | #define RPCRDMA_WC_BUDGET (128) |
1c00dd07 CL |
83 | #define RPCRDMA_POLLSIZE (16) |
84 | ||
f58851e6 TT |
85 | struct rpcrdma_ep { |
86 | atomic_t rep_cqcount; | |
87 | int rep_cqinit; | |
88 | int rep_connected; | |
f58851e6 TT |
89 | struct ib_qp_init_attr rep_attr; |
90 | wait_queue_head_t rep_connect_wait; | |
c05fbb5a | 91 | struct rpcrdma_regbuf *rep_padbuf; |
f58851e6 TT |
92 | struct rdma_conn_param rep_remote_cma; |
93 | struct sockaddr_storage rep_remote_addr; | |
254f91e2 | 94 | struct delayed_work rep_connect_worker; |
1c00dd07 CL |
95 | struct ib_wc rep_send_wcs[RPCRDMA_POLLSIZE]; |
96 | struct ib_wc rep_recv_wcs[RPCRDMA_POLLSIZE]; | |
f58851e6 TT |
97 | }; |
98 | ||
e7104a2a CL |
99 | /* |
100 | * Force a signaled SEND Work Request every so often, | |
101 | * in case the provider needs to do some housekeeping. | |
102 | */ | |
103 | #define RPCRDMA_MAX_UNSIGNALED_SENDS (32) | |
104 | ||
f58851e6 TT |
105 | #define INIT_CQCOUNT(ep) atomic_set(&(ep)->rep_cqcount, (ep)->rep_cqinit) |
106 | #define DECR_CQCOUNT(ep) atomic_sub_return(1, &(ep)->rep_cqcount) | |
107 | ||
e46ac34c CL |
108 | /* Force completion handler to ignore the signal |
109 | */ | |
110 | #define RPCRDMA_IGNORE_COMPLETION (0ULL) | |
111 | ||
9128c3e7 CL |
112 | /* Registered buffer -- registered kmalloc'd memory for RDMA SEND/RECV |
113 | * | |
114 | * The below structure appears at the front of a large region of kmalloc'd | |
115 | * memory, which always starts on a good alignment boundary. | |
116 | */ | |
117 | ||
118 | struct rpcrdma_regbuf { | |
119 | size_t rg_size; | |
120 | struct rpcrdma_req *rg_owner; | |
121 | struct ib_mr *rg_mr; | |
122 | struct ib_sge rg_iov; | |
123 | __be32 rg_base[0] __attribute__ ((aligned(256))); | |
124 | }; | |
125 | ||
126 | static inline u64 | |
127 | rdmab_addr(struct rpcrdma_regbuf *rb) | |
128 | { | |
129 | return rb->rg_iov.addr; | |
130 | } | |
131 | ||
132 | static inline u32 | |
133 | rdmab_length(struct rpcrdma_regbuf *rb) | |
134 | { | |
135 | return rb->rg_iov.length; | |
136 | } | |
137 | ||
138 | static inline u32 | |
139 | rdmab_lkey(struct rpcrdma_regbuf *rb) | |
140 | { | |
141 | return rb->rg_iov.lkey; | |
142 | } | |
143 | ||
144 | static inline struct rpcrdma_msg * | |
145 | rdmab_to_msg(struct rpcrdma_regbuf *rb) | |
146 | { | |
147 | return (struct rpcrdma_msg *)rb->rg_base; | |
148 | } | |
149 | ||
f58851e6 TT |
150 | /* |
151 | * struct rpcrdma_rep -- this structure encapsulates state required to recv | |
152 | * and complete a reply, asychronously. It needs several pieces of | |
153 | * state: | |
154 | * o recv buffer (posted to provider) | |
155 | * o ib_sge (also donated to provider) | |
156 | * o status of reply (length, success or not) | |
157 | * o bookkeeping state to get run by tasklet (list, etc) | |
158 | * | |
159 | * These are allocated during initialization, per-transport instance; | |
160 | * however, the tasklet execution list itself is global, as it should | |
161 | * always be pretty short. | |
162 | * | |
163 | * N of these are associated with a transport instance, and stored in | |
164 | * struct rpcrdma_buffer. N is the max number of outstanding requests. | |
165 | */ | |
166 | ||
167 | /* temporary static scatter/gather max */ | |
2773395b | 168 | #define RPCRDMA_MAX_DATA_SEGS (64) /* max scatter/gather */ |
f58851e6 | 169 | #define RPCRDMA_MAX_SEGS (RPCRDMA_MAX_DATA_SEGS + 2) /* head+tail = 2 */ |
f58851e6 TT |
170 | |
171 | struct rpcrdma_buffer; | |
172 | ||
173 | struct rpcrdma_rep { | |
6b1184cd | 174 | unsigned int rr_len; |
89e0d112 | 175 | struct ib_device *rr_device; |
fed171b3 | 176 | struct rpcrdma_xprt *rr_rxprt; |
6b1184cd CL |
177 | struct list_head rr_list; |
178 | struct rpcrdma_regbuf *rr_rdmabuf; | |
f58851e6 TT |
179 | }; |
180 | ||
0dbb4108 CL |
181 | /* |
182 | * struct rpcrdma_mw - external memory region metadata | |
183 | * | |
184 | * An external memory region is any buffer or page that is registered | |
185 | * on the fly (ie, not pre-registered). | |
186 | * | |
3111d72c | 187 | * Each rpcrdma_buffer has a list of free MWs anchored in rb_mws. During |
0dbb4108 CL |
188 | * call_allocate, rpcrdma_buffer_get() assigns one to each segment in |
189 | * an rpcrdma_req. Then rpcrdma_register_external() grabs these to keep | |
190 | * track of registration metadata while each RPC is pending. | |
191 | * rpcrdma_deregister_external() uses this metadata to unmap and | |
192 | * release these resources when an RPC is complete. | |
193 | */ | |
194 | enum rpcrdma_frmr_state { | |
195 | FRMR_IS_INVALID, /* ready to be used */ | |
196 | FRMR_IS_VALID, /* in use */ | |
9f9d802a | 197 | FRMR_IS_STALE, /* failed completion */ |
0dbb4108 CL |
198 | }; |
199 | ||
200 | struct rpcrdma_frmr { | |
201 | struct ib_fast_reg_page_list *fr_pgl; | |
202 | struct ib_mr *fr_mr; | |
203 | enum rpcrdma_frmr_state fr_state; | |
951e721c CL |
204 | struct work_struct fr_work; |
205 | struct rpcrdma_xprt *fr_xprt; | |
0dbb4108 CL |
206 | }; |
207 | ||
acb9da7a CL |
208 | struct rpcrdma_fmr { |
209 | struct ib_fmr *fmr; | |
210 | u64 *physaddrs; | |
0dbb4108 CL |
211 | }; |
212 | ||
213 | struct rpcrdma_mw { | |
214 | union { | |
acb9da7a | 215 | struct rpcrdma_fmr fmr; |
0dbb4108 CL |
216 | struct rpcrdma_frmr frmr; |
217 | } r; | |
e46ac34c | 218 | void (*mw_sendcompletion)(struct ib_wc *); |
0dbb4108 | 219 | struct list_head mw_list; |
3111d72c | 220 | struct list_head mw_all; |
0dbb4108 CL |
221 | }; |
222 | ||
f58851e6 TT |
223 | /* |
224 | * struct rpcrdma_req -- structure central to the request/reply sequence. | |
225 | * | |
226 | * N of these are associated with a transport instance, and stored in | |
227 | * struct rpcrdma_buffer. N is the max number of outstanding requests. | |
228 | * | |
229 | * It includes pre-registered buffer memory for send AND recv. | |
230 | * The recv buffer, however, is not owned by this structure, and | |
231 | * is "donated" to the hardware when a recv is posted. When a | |
232 | * reply is handled, the recv buffer used is given back to the | |
233 | * struct rpcrdma_req associated with the request. | |
234 | * | |
235 | * In addition to the basic memory, this structure includes an array | |
236 | * of iovs for send operations. The reason is that the iovs passed to | |
237 | * ib_post_{send,recv} must not be modified until the work request | |
238 | * completes. | |
239 | * | |
240 | * NOTES: | |
241 | * o RPCRDMA_MAX_SEGS is the max number of addressible chunk elements we | |
242 | * marshal. The number needed varies depending on the iov lists that | |
243 | * are passed to us, the memory registration mode we are in, and if | |
244 | * physical addressing is used, the layout. | |
245 | */ | |
246 | ||
247 | struct rpcrdma_mr_seg { /* chunk descriptors */ | |
3eb35810 | 248 | struct rpcrdma_mw *rl_mw; /* registered MR */ |
f58851e6 TT |
249 | u64 mr_base; /* registration result */ |
250 | u32 mr_rkey; /* registration result */ | |
251 | u32 mr_len; /* length of chunk or segment */ | |
252 | int mr_nsegs; /* number of segments in chunk or 0 */ | |
253 | enum dma_data_direction mr_dir; /* segment mapping direction */ | |
254 | dma_addr_t mr_dma; /* segment mapping address */ | |
255 | size_t mr_dmalen; /* segment mapping length */ | |
256 | struct page *mr_page; /* owning page, if any */ | |
257 | char *mr_offset; /* kva if no page, else offset */ | |
258 | }; | |
259 | ||
260 | struct rpcrdma_req { | |
f58851e6 TT |
261 | unsigned int rl_niovs; /* 0, 2 or 4 */ |
262 | unsigned int rl_nchunks; /* non-zero if chunks */ | |
575448bd | 263 | unsigned int rl_connect_cookie; /* retry detection */ |
f58851e6 TT |
264 | struct rpcrdma_buffer *rl_buffer; /* home base for this structure */ |
265 | struct rpcrdma_rep *rl_reply;/* holder for reply buffer */ | |
f58851e6 | 266 | struct ib_sge rl_send_iov[4]; /* for active requests */ |
85275c87 | 267 | struct rpcrdma_regbuf *rl_rdmabuf; |
0ca77dc3 | 268 | struct rpcrdma_regbuf *rl_sendbuf; |
85275c87 | 269 | struct rpcrdma_mr_seg rl_segments[RPCRDMA_MAX_SEGS]; |
f58851e6 | 270 | }; |
0ca77dc3 CL |
271 | |
272 | static inline struct rpcrdma_req * | |
273 | rpcr_to_rdmar(struct rpc_rqst *rqst) | |
274 | { | |
b625a616 CL |
275 | void *buffer = rqst->rq_buffer; |
276 | struct rpcrdma_regbuf *rb; | |
277 | ||
278 | rb = container_of(buffer, struct rpcrdma_regbuf, rg_base); | |
0ca77dc3 CL |
279 | return rb->rg_owner; |
280 | } | |
f58851e6 TT |
281 | |
282 | /* | |
283 | * struct rpcrdma_buffer -- holds list/queue of pre-registered memory for | |
284 | * inline requests/replies, and client/server credits. | |
285 | * | |
286 | * One of these is associated with a transport instance | |
287 | */ | |
288 | struct rpcrdma_buffer { | |
58d1dcf5 CL |
289 | spinlock_t rb_mwlock; /* protect rb_mws list */ |
290 | struct list_head rb_mws; | |
291 | struct list_head rb_all; | |
292 | char *rb_pool; | |
293 | ||
294 | spinlock_t rb_lock; /* protect buf arrays */ | |
295 | u32 rb_max_requests; | |
296 | int rb_send_index; | |
297 | int rb_recv_index; | |
f58851e6 | 298 | struct rpcrdma_req **rb_send_bufs; |
f58851e6 | 299 | struct rpcrdma_rep **rb_recv_bufs; |
f58851e6 TT |
300 | }; |
301 | #define rdmab_to_ia(b) (&container_of((b), struct rpcrdma_xprt, rx_buf)->rx_ia) | |
302 | ||
303 | /* | |
304 | * Internal structure for transport instance creation. This | |
305 | * exists primarily for modularity. | |
306 | * | |
307 | * This data should be set with mount options | |
308 | */ | |
309 | struct rpcrdma_create_data_internal { | |
310 | struct sockaddr_storage addr; /* RDMA server address */ | |
311 | unsigned int max_requests; /* max requests (slots) in flight */ | |
312 | unsigned int rsize; /* mount rsize - max read hdr+data */ | |
313 | unsigned int wsize; /* mount wsize - max write hdr+data */ | |
314 | unsigned int inline_rsize; /* max non-rdma read data payload */ | |
315 | unsigned int inline_wsize; /* max non-rdma write data payload */ | |
316 | unsigned int padding; /* non-rdma write header padding */ | |
317 | }; | |
318 | ||
319 | #define RPCRDMA_INLINE_READ_THRESHOLD(rq) \ | |
a4f0835c | 320 | (rpcx_to_rdmad(rq->rq_xprt).inline_rsize) |
f58851e6 TT |
321 | |
322 | #define RPCRDMA_INLINE_WRITE_THRESHOLD(rq)\ | |
a4f0835c | 323 | (rpcx_to_rdmad(rq->rq_xprt).inline_wsize) |
f58851e6 TT |
324 | |
325 | #define RPCRDMA_INLINE_PAD_VALUE(rq)\ | |
a4f0835c | 326 | rpcx_to_rdmad(rq->rq_xprt).padding |
f58851e6 TT |
327 | |
328 | /* | |
329 | * Statistics for RPCRDMA | |
330 | */ | |
331 | struct rpcrdma_stats { | |
332 | unsigned long read_chunk_count; | |
333 | unsigned long write_chunk_count; | |
334 | unsigned long reply_chunk_count; | |
335 | ||
336 | unsigned long long total_rdma_request; | |
337 | unsigned long long total_rdma_reply; | |
338 | ||
339 | unsigned long long pullup_copy_count; | |
340 | unsigned long long fixup_copy_count; | |
341 | unsigned long hardway_register_count; | |
342 | unsigned long failed_marshal_count; | |
343 | unsigned long bad_reply_count; | |
344 | }; | |
345 | ||
a0ce85f5 CL |
346 | /* |
347 | * Per-registration mode operations | |
348 | */ | |
1c9351ee | 349 | struct rpcrdma_xprt; |
a0ce85f5 | 350 | struct rpcrdma_memreg_ops { |
9c1b4d77 CL |
351 | int (*ro_map)(struct rpcrdma_xprt *, |
352 | struct rpcrdma_mr_seg *, int, bool); | |
6814baea CL |
353 | int (*ro_unmap)(struct rpcrdma_xprt *, |
354 | struct rpcrdma_mr_seg *); | |
3968cb58 CL |
355 | int (*ro_open)(struct rpcrdma_ia *, |
356 | struct rpcrdma_ep *, | |
357 | struct rpcrdma_create_data_internal *); | |
1c9351ee | 358 | size_t (*ro_maxpages)(struct rpcrdma_xprt *); |
91e70e70 | 359 | int (*ro_init)(struct rpcrdma_xprt *); |
4561f347 | 360 | void (*ro_destroy)(struct rpcrdma_buffer *); |
a0ce85f5 CL |
361 | const char *ro_displayname; |
362 | }; | |
363 | ||
364 | extern const struct rpcrdma_memreg_ops rpcrdma_fmr_memreg_ops; | |
365 | extern const struct rpcrdma_memreg_ops rpcrdma_frwr_memreg_ops; | |
366 | extern const struct rpcrdma_memreg_ops rpcrdma_physical_memreg_ops; | |
367 | ||
f58851e6 TT |
368 | /* |
369 | * RPCRDMA transport -- encapsulates the structures above for | |
370 | * integration with RPC. | |
371 | * | |
372 | * The contained structures are embedded, not pointers, | |
373 | * for convenience. This structure need not be visible externally. | |
374 | * | |
375 | * It is allocated and initialized during mount, and released | |
376 | * during unmount. | |
377 | */ | |
378 | struct rpcrdma_xprt { | |
5abefb86 | 379 | struct rpc_xprt rx_xprt; |
f58851e6 TT |
380 | struct rpcrdma_ia rx_ia; |
381 | struct rpcrdma_ep rx_ep; | |
382 | struct rpcrdma_buffer rx_buf; | |
383 | struct rpcrdma_create_data_internal rx_data; | |
5abefb86 | 384 | struct delayed_work rx_connect_worker; |
f58851e6 TT |
385 | struct rpcrdma_stats rx_stats; |
386 | }; | |
387 | ||
5abefb86 | 388 | #define rpcx_to_rdmax(x) container_of(x, struct rpcrdma_xprt, rx_xprt) |
f58851e6 TT |
389 | #define rpcx_to_rdmad(x) (rpcx_to_rdmax(x)->rx_data) |
390 | ||
9191ca3b TT |
391 | /* Setting this to 0 ensures interoperability with early servers. |
392 | * Setting this to 1 enhances certain unaligned read/write performance. | |
393 | * Default is 0, see sysctl entry and rpc_rdma.c rpcrdma_convert_iovs() */ | |
394 | extern int xprt_rdma_pad_optimize; | |
395 | ||
f58851e6 TT |
396 | /* |
397 | * Interface Adapter calls - xprtrdma/verbs.c | |
398 | */ | |
399 | int rpcrdma_ia_open(struct rpcrdma_xprt *, struct sockaddr *, int); | |
400 | void rpcrdma_ia_close(struct rpcrdma_ia *); | |
401 | ||
402 | /* | |
403 | * Endpoint calls - xprtrdma/verbs.c | |
404 | */ | |
405 | int rpcrdma_ep_create(struct rpcrdma_ep *, struct rpcrdma_ia *, | |
406 | struct rpcrdma_create_data_internal *); | |
7f1d5419 | 407 | void rpcrdma_ep_destroy(struct rpcrdma_ep *, struct rpcrdma_ia *); |
f58851e6 | 408 | int rpcrdma_ep_connect(struct rpcrdma_ep *, struct rpcrdma_ia *); |
282191cb | 409 | void rpcrdma_ep_disconnect(struct rpcrdma_ep *, struct rpcrdma_ia *); |
f58851e6 TT |
410 | |
411 | int rpcrdma_ep_post(struct rpcrdma_ia *, struct rpcrdma_ep *, | |
412 | struct rpcrdma_req *); | |
413 | int rpcrdma_ep_post_recv(struct rpcrdma_ia *, struct rpcrdma_ep *, | |
414 | struct rpcrdma_rep *); | |
415 | ||
416 | /* | |
417 | * Buffer calls - xprtrdma/verbs.c | |
418 | */ | |
ac920d04 | 419 | int rpcrdma_buffer_create(struct rpcrdma_xprt *); |
f58851e6 TT |
420 | void rpcrdma_buffer_destroy(struct rpcrdma_buffer *); |
421 | ||
346aa66b CL |
422 | struct rpcrdma_mw *rpcrdma_get_mw(struct rpcrdma_xprt *); |
423 | void rpcrdma_put_mw(struct rpcrdma_xprt *, struct rpcrdma_mw *); | |
f58851e6 TT |
424 | struct rpcrdma_req *rpcrdma_buffer_get(struct rpcrdma_buffer *); |
425 | void rpcrdma_buffer_put(struct rpcrdma_req *); | |
426 | void rpcrdma_recv_buffer_get(struct rpcrdma_req *); | |
427 | void rpcrdma_recv_buffer_put(struct rpcrdma_rep *); | |
428 | ||
9128c3e7 CL |
429 | struct rpcrdma_regbuf *rpcrdma_alloc_regbuf(struct rpcrdma_ia *, |
430 | size_t, gfp_t); | |
431 | void rpcrdma_free_regbuf(struct rpcrdma_ia *, | |
432 | struct rpcrdma_regbuf *); | |
433 | ||
1c9351ee | 434 | unsigned int rpcrdma_max_segments(struct rpcrdma_xprt *); |
d654788e | 435 | |
951e721c CL |
436 | int frwr_alloc_recovery_wq(void); |
437 | void frwr_destroy_recovery_wq(void); | |
438 | ||
d654788e CL |
439 | /* |
440 | * Wrappers for chunk registration, shared by read/write chunk code. | |
441 | */ | |
442 | ||
443 | void rpcrdma_mapping_error(struct rpcrdma_mr_seg *); | |
444 | ||
445 | static inline enum dma_data_direction | |
446 | rpcrdma_data_dir(bool writing) | |
447 | { | |
448 | return writing ? DMA_FROM_DEVICE : DMA_TO_DEVICE; | |
449 | } | |
450 | ||
451 | static inline void | |
452 | rpcrdma_map_one(struct ib_device *device, struct rpcrdma_mr_seg *seg, | |
453 | enum dma_data_direction direction) | |
454 | { | |
455 | seg->mr_dir = direction; | |
456 | seg->mr_dmalen = seg->mr_len; | |
457 | ||
458 | if (seg->mr_page) | |
459 | seg->mr_dma = ib_dma_map_page(device, | |
460 | seg->mr_page, offset_in_page(seg->mr_offset), | |
461 | seg->mr_dmalen, seg->mr_dir); | |
462 | else | |
463 | seg->mr_dma = ib_dma_map_single(device, | |
464 | seg->mr_offset, | |
465 | seg->mr_dmalen, seg->mr_dir); | |
466 | ||
467 | if (ib_dma_mapping_error(device, seg->mr_dma)) | |
468 | rpcrdma_mapping_error(seg); | |
469 | } | |
470 | ||
471 | static inline void | |
472 | rpcrdma_unmap_one(struct ib_device *device, struct rpcrdma_mr_seg *seg) | |
473 | { | |
474 | if (seg->mr_page) | |
475 | ib_dma_unmap_page(device, | |
476 | seg->mr_dma, seg->mr_dmalen, seg->mr_dir); | |
477 | else | |
478 | ib_dma_unmap_single(device, | |
479 | seg->mr_dma, seg->mr_dmalen, seg->mr_dir); | |
480 | } | |
1c9351ee | 481 | |
f58851e6 TT |
482 | /* |
483 | * RPC/RDMA connection management calls - xprtrdma/rpc_rdma.c | |
484 | */ | |
254f91e2 | 485 | void rpcrdma_connect_worker(struct work_struct *); |
f58851e6 TT |
486 | void rpcrdma_conn_func(struct rpcrdma_ep *); |
487 | void rpcrdma_reply_handler(struct rpcrdma_rep *); | |
488 | ||
489 | /* | |
490 | * RPC/RDMA protocol calls - xprtrdma/rpc_rdma.c | |
491 | */ | |
492 | int rpcrdma_marshal_req(struct rpc_rqst *); | |
493 | ||
ffe1f0df CL |
494 | /* RPC/RDMA module init - xprtrdma/transport.c |
495 | */ | |
496 | int xprt_rdma_init(void); | |
497 | void xprt_rdma_cleanup(void); | |
498 | ||
cec56c8f TT |
499 | /* Temporary NFS request map cache. Created in svc_rdma.c */ |
500 | extern struct kmem_cache *svc_rdma_map_cachep; | |
501 | /* WR context cache. Created in svc_rdma.c */ | |
502 | extern struct kmem_cache *svc_rdma_ctxt_cachep; | |
503 | /* Workqueue created in svc_rdma.c */ | |
504 | extern struct workqueue_struct *svc_rdma_wq; | |
505 | ||
f58851e6 | 506 | #endif /* _LINUX_SUNRPC_XPRT_RDMA_H */ |