xprtrdma: Add a "max_payload" op for each memreg mode
[linux-2.6-block.git] / net / sunrpc / xprtrdma / fmr_ops.c
CommitLineData
a0ce85f5
CL
1/*
2 * Copyright (c) 2015 Oracle. All rights reserved.
3 * Copyright (c) 2003-2007 Network Appliance, Inc. All rights reserved.
4 */
5
6/* Lightweight memory registration using Fast Memory Regions (FMR).
7 * Referred to sometimes as MTHCAFMR mode.
8 *
9 * FMR uses synchronous memory registration and deregistration.
10 * FMR registration is known to be fast, but FMR deregistration
11 * can take tens of usecs to complete.
12 */
13
14#include "xprt_rdma.h"
15
16#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
17# define RPCDBG_FACILITY RPCDBG_TRANS
18#endif
19
1c9351ee
CL
20/* Maximum scatter/gather per FMR */
21#define RPCRDMA_MAX_FMR_SGES (64)
22
23/* FMR mode conveys up to 64 pages of payload per chunk segment.
24 */
25static size_t
26fmr_op_maxpages(struct rpcrdma_xprt *r_xprt)
27{
28 return min_t(unsigned int, RPCRDMA_MAX_DATA_SEGS,
29 rpcrdma_max_segments(r_xprt) * RPCRDMA_MAX_FMR_SGES);
30}
31
a0ce85f5 32const struct rpcrdma_memreg_ops rpcrdma_fmr_memreg_ops = {
1c9351ee 33 .ro_maxpages = fmr_op_maxpages,
a0ce85f5
CL
34 .ro_displayname = "fmr",
35};