blob: da149e892858af34d51e40e46c4c3d8d9e0c7b57 [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 Lever3968cb52015-03-30 14:35:26 -040022static int
23physical_op_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep,
24 struct rpcrdma_create_data_internal *cdata)
25{
26 return 0;
27}
28
Chuck Lever1c9351e2015-03-30 14:34:30 -040029/* PHYSICAL memory registration conveys one page per chunk segment.
30 */
31static size_t
32physical_op_maxpages(struct rpcrdma_xprt *r_xprt)
33{
34 return min_t(unsigned int, RPCRDMA_MAX_DATA_SEGS,
35 rpcrdma_max_segments(r_xprt));
36}
37
Chuck Lever91e70e72015-03-30 14:34:58 -040038static int
39physical_op_init(struct rpcrdma_xprt *r_xprt)
40{
41 return 0;
42}
43
Chuck Lever9c1b4d72015-03-30 14:34:39 -040044/* The client's physical memory is already exposed for
45 * remote access via RDMA READ or RDMA WRITE.
46 */
47static int
48physical_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg,
49 int nsegs, bool writing)
50{
51 struct rpcrdma_ia *ia = &r_xprt->rx_ia;
52
Chuck Lever89e0d1122015-05-26 11:51:56 -040053 rpcrdma_map_one(ia->ri_device, seg, rpcrdma_data_dir(writing));
Chuck Lever9c1b4d72015-03-30 14:34:39 -040054 seg->mr_rkey = ia->ri_bind_mem->rkey;
55 seg->mr_base = seg->mr_dma;
56 seg->mr_nsegs = 1;
57 return 1;
58}
59
Chuck Lever6814bae2015-03-30 14:34:48 -040060/* Unmap a memory region, but leave it registered.
61 */
62static int
63physical_op_unmap(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg)
64{
Chuck Leverd6547882015-03-30 14:35:44 -040065 struct rpcrdma_ia *ia = &r_xprt->rx_ia;
66
Chuck Lever89e0d1122015-05-26 11:51:56 -040067 rpcrdma_unmap_one(ia->ri_device, seg);
Chuck Lever6814bae2015-03-30 14:34:48 -040068 return 1;
69}
70
Chuck Lever31a701a2015-03-30 14:35:07 -040071static void
72physical_op_reset(struct rpcrdma_xprt *r_xprt)
73{
74}
75
Chuck Lever4561f342015-03-30 14:35:17 -040076static void
77physical_op_destroy(struct rpcrdma_buffer *buf)
78{
79}
80
Chuck Levera0ce85f2015-03-30 14:34:21 -040081const struct rpcrdma_memreg_ops rpcrdma_physical_memreg_ops = {
Chuck Lever9c1b4d72015-03-30 14:34:39 -040082 .ro_map = physical_op_map,
Chuck Lever6814bae2015-03-30 14:34:48 -040083 .ro_unmap = physical_op_unmap,
Chuck Lever3968cb52015-03-30 14:35:26 -040084 .ro_open = physical_op_open,
Chuck Lever1c9351e2015-03-30 14:34:30 -040085 .ro_maxpages = physical_op_maxpages,
Chuck Lever91e70e72015-03-30 14:34:58 -040086 .ro_init = physical_op_init,
Chuck Lever31a701a2015-03-30 14:35:07 -040087 .ro_reset = physical_op_reset,
Chuck Lever4561f342015-03-30 14:35:17 -040088 .ro_destroy = physical_op_destroy,
Chuck Levera0ce85f2015-03-30 14:34:21 -040089 .ro_displayname = "physical",
90};