Chuck Lever | a0ce85f | 2015-03-30 14:34:21 -0400 | [diff] [blame] | 1 | /* |
| 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 Lever | 1c9351e | 2015-03-30 14:34:30 -0400 | [diff] [blame] | 22 | /* PHYSICAL memory registration conveys one page per chunk segment. |
| 23 | */ |
| 24 | static size_t |
| 25 | physical_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 Lever | 9c1b4d7 | 2015-03-30 14:34:39 -0400 | [diff] [blame^] | 31 | /* The client's physical memory is already exposed for |
| 32 | * remote access via RDMA READ or RDMA WRITE. |
| 33 | */ |
| 34 | static int |
| 35 | physical_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 Lever | a0ce85f | 2015-03-30 14:34:21 -0400 | [diff] [blame] | 47 | const struct rpcrdma_memreg_ops rpcrdma_physical_memreg_ops = { |
Chuck Lever | 9c1b4d7 | 2015-03-30 14:34:39 -0400 | [diff] [blame^] | 48 | .ro_map = physical_op_map, |
Chuck Lever | 1c9351e | 2015-03-30 14:34:30 -0400 | [diff] [blame] | 49 | .ro_maxpages = physical_op_maxpages, |
Chuck Lever | a0ce85f | 2015-03-30 14:34:21 -0400 | [diff] [blame] | 50 | .ro_displayname = "physical", |
| 51 | }; |