blob: 5a284ee0e0584354e08dcdc190f40a2976809be7 [file] [log] [blame]
Chuck Levera0ce85f2015-03-30 14:34:21 -04001/*
2 * Copyright (c) 2015 Oracle. All rights reserved.
3 * Copyright (c) 2003-2007 Network Appliance, Inc. All rights reserved.
4 */
5
6/* No-op chunk preparation. All client memory is pre-registered.
7 * Sometimes referred to as ALLPHYSICAL mode.
8 *
9 * Physical registration is simple because all client memory is
10 * pre-registered and never deregistered. This mode is good for
11 * adapter bring up, but is considered not safe: the server is
12 * trusted not to abuse its access to client memory not involved
13 * in RDMA I/O.
14 */
15
16#include "xprt_rdma.h"
17
18#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
19# define RPCDBG_FACILITY RPCDBG_TRANS
20#endif
21
Chuck Lever1c9351e2015-03-30 14:34:30 -040022/* PHYSICAL memory registration conveys one page per chunk segment.
23 */
24static size_t
25physical_op_maxpages(struct rpcrdma_xprt *r_xprt)
26{
27 return min_t(unsigned int, RPCRDMA_MAX_DATA_SEGS,
28 rpcrdma_max_segments(r_xprt));
29}
30
Chuck Lever9c1b4d72015-03-30 14:34:39 -040031/* The client's physical memory is already exposed for
32 * remote access via RDMA READ or RDMA WRITE.
33 */
34static int
35physical_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg,
36 int nsegs, bool writing)
37{
38 struct rpcrdma_ia *ia = &r_xprt->rx_ia;
39
40 rpcrdma_map_one(ia, seg, writing);
41 seg->mr_rkey = ia->ri_bind_mem->rkey;
42 seg->mr_base = seg->mr_dma;
43 seg->mr_nsegs = 1;
44 return 1;
45}
46
Chuck Levera0ce85f2015-03-30 14:34:21 -040047const struct rpcrdma_memreg_ops rpcrdma_physical_memreg_ops = {
Chuck Lever9c1b4d72015-03-30 14:34:39 -040048 .ro_map = physical_op_map,
Chuck Lever1c9351e2015-03-30 14:34:30 -040049 .ro_maxpages = physical_op_maxpages,
Chuck Levera0ce85f2015-03-30 14:34:21 -040050 .ro_displayname = "physical",
51};