Skip to content

Commit 87cfb9a

Browse files
chuckleveramschuma-ntap
authored andcommitted
xprtrdma: Client-side support for rpcrdma_connect_private
Send an RDMA-CM private message on connect, and look for one during a connection-established event. Both sides can communicate their various implementation limits. Implementations that don't support this sideband protocol ignore it. Once the client knows the server's inline threshold maxima, it can adjust the use of Reply chunks, and eliminate most use of Position Zero Read chunks. Moderately-sized I/O can be done using a pure inline RDMA Send instead of RDMA operations that require memory registration. Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent ff06bd1 commit 87cfb9a

File tree

6 files changed

+53
-15
lines changed

6 files changed

+53
-15
lines changed

include/linux/sunrpc/rpc_rdma.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
#define RPCRDMA_VERSION 1
4747
#define rpcrdma_version cpu_to_be32(RPCRDMA_VERSION)
4848

49+
enum {
50+
RPCRDMA_V1_DEF_INLINE_SIZE = 1024,
51+
};
52+
4953
struct rpcrdma_segment {
5054
__be32 rs_handle; /* Registered memory handle */
5155
__be32 rs_length; /* Length of the chunk in bytes */

net/sunrpc/xprtrdma/fmr_ops.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,8 @@ static int
160160
fmr_op_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep,
161161
struct rpcrdma_create_data_internal *cdata)
162162
{
163-
rpcrdma_set_max_header_sizes(ia, cdata, max_t(unsigned int, 1,
164-
RPCRDMA_MAX_DATA_SEGS /
165-
RPCRDMA_MAX_FMR_SGES));
163+
ia->ri_max_segs = max_t(unsigned int, 1, RPCRDMA_MAX_DATA_SEGS /
164+
RPCRDMA_MAX_FMR_SGES);
166165
return 0;
167166
}
168167

net/sunrpc/xprtrdma/frwr_ops.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,8 @@ frwr_op_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep,
242242
depth;
243243
}
244244

245-
rpcrdma_set_max_header_sizes(ia, cdata, max_t(unsigned int, 1,
246-
RPCRDMA_MAX_DATA_SEGS /
247-
ia->ri_max_frmr_depth));
245+
ia->ri_max_segs = max_t(unsigned int, 1, RPCRDMA_MAX_DATA_SEGS /
246+
ia->ri_max_frmr_depth);
248247
return 0;
249248
}
250249

net/sunrpc/xprtrdma/rpc_rdma.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,12 @@ static unsigned int rpcrdma_max_reply_header_size(unsigned int maxsegs)
118118
return size;
119119
}
120120

121-
void rpcrdma_set_max_header_sizes(struct rpcrdma_ia *ia,
122-
struct rpcrdma_create_data_internal *cdata,
123-
unsigned int maxsegs)
121+
void rpcrdma_set_max_header_sizes(struct rpcrdma_xprt *r_xprt)
124122
{
123+
struct rpcrdma_create_data_internal *cdata = &r_xprt->rx_data;
124+
struct rpcrdma_ia *ia = &r_xprt->rx_ia;
125+
unsigned int maxsegs = ia->ri_max_segs;
126+
125127
ia->ri_max_inline_write = cdata->inline_wsize -
126128
rpcrdma_max_call_header_size(maxsegs);
127129
ia->ri_max_inline_read = cdata->inline_rsize -

net/sunrpc/xprtrdma/verbs.c

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,33 @@ rpcrdma_receive_wc(struct ib_cq *cq, struct ib_wc *wc)
204204
goto out_schedule;
205205
}
206206

207+
static void
208+
rpcrdma_update_connect_private(struct rpcrdma_xprt *r_xprt,
209+
struct rdma_conn_param *param)
210+
{
211+
struct rpcrdma_create_data_internal *cdata = &r_xprt->rx_data;
212+
const struct rpcrdma_connect_private *pmsg = param->private_data;
213+
unsigned int rsize, wsize;
214+
215+
rsize = RPCRDMA_V1_DEF_INLINE_SIZE;
216+
wsize = RPCRDMA_V1_DEF_INLINE_SIZE;
217+
218+
if (pmsg &&
219+
pmsg->cp_magic == rpcrdma_cmp_magic &&
220+
pmsg->cp_version == RPCRDMA_CMP_VERSION) {
221+
rsize = rpcrdma_decode_buffer_size(pmsg->cp_send_size);
222+
wsize = rpcrdma_decode_buffer_size(pmsg->cp_recv_size);
223+
}
224+
225+
if (rsize < cdata->inline_rsize)
226+
cdata->inline_rsize = rsize;
227+
if (wsize < cdata->inline_wsize)
228+
cdata->inline_wsize = wsize;
229+
pr_info("rpcrdma: max send %u, max recv %u\n",
230+
cdata->inline_wsize, cdata->inline_rsize);
231+
rpcrdma_set_max_header_sizes(r_xprt);
232+
}
233+
207234
static int
208235
rpcrdma_conn_upcall(struct rdma_cm_id *id, struct rdma_cm_event *event)
209236
{
@@ -244,6 +271,7 @@ rpcrdma_conn_upcall(struct rdma_cm_id *id, struct rdma_cm_event *event)
244271
" (%d initiator)\n",
245272
__func__, attr->max_dest_rd_atomic,
246273
attr->max_rd_atomic);
274+
rpcrdma_update_connect_private(xprt, &event->param.conn);
247275
goto connected;
248276
case RDMA_CM_EVENT_CONNECT_ERROR:
249277
connstate = -ENOTCONN;
@@ -454,6 +482,7 @@ int
454482
rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia,
455483
struct rpcrdma_create_data_internal *cdata)
456484
{
485+
struct rpcrdma_connect_private *pmsg = &ep->rep_cm_private;
457486
struct ib_cq *sendcq, *recvcq;
458487
unsigned int max_qp_wr;
459488
int rc;
@@ -536,9 +565,14 @@ rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia,
536565
/* Initialize cma parameters */
537566
memset(&ep->rep_remote_cma, 0, sizeof(ep->rep_remote_cma));
538567

539-
/* RPC/RDMA does not use private data */
540-
ep->rep_remote_cma.private_data = NULL;
541-
ep->rep_remote_cma.private_data_len = 0;
568+
/* Prepare RDMA-CM private message */
569+
pmsg->cp_magic = rpcrdma_cmp_magic;
570+
pmsg->cp_version = RPCRDMA_CMP_VERSION;
571+
pmsg->cp_flags = 0;
572+
pmsg->cp_send_size = rpcrdma_encode_buffer_size(cdata->inline_wsize);
573+
pmsg->cp_recv_size = rpcrdma_encode_buffer_size(cdata->inline_rsize);
574+
ep->rep_remote_cma.private_data = pmsg;
575+
ep->rep_remote_cma.private_data_len = sizeof(*pmsg);
542576

543577
/* Client offers RDMA Read but does not initiate */
544578
ep->rep_remote_cma.initiator_depth = 0;

net/sunrpc/xprtrdma/xprt_rdma.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ struct rpcrdma_ia {
7070
struct ib_pd *ri_pd;
7171
struct completion ri_done;
7272
int ri_async_rc;
73+
unsigned int ri_max_segs;
7374
unsigned int ri_max_frmr_depth;
7475
unsigned int ri_max_inline_write;
7576
unsigned int ri_max_inline_read;
@@ -87,6 +88,7 @@ struct rpcrdma_ep {
8788
int rep_connected;
8889
struct ib_qp_init_attr rep_attr;
8990
wait_queue_head_t rep_connect_wait;
91+
struct rpcrdma_connect_private rep_cm_private;
9092
struct rdma_conn_param rep_remote_cma;
9193
struct sockaddr_storage rep_remote_addr;
9294
struct delayed_work rep_connect_worker;
@@ -523,9 +525,7 @@ void rpcrdma_reply_handler(struct rpcrdma_rep *);
523525
* RPC/RDMA protocol calls - xprtrdma/rpc_rdma.c
524526
*/
525527
int rpcrdma_marshal_req(struct rpc_rqst *);
526-
void rpcrdma_set_max_header_sizes(struct rpcrdma_ia *,
527-
struct rpcrdma_create_data_internal *,
528-
unsigned int);
528+
void rpcrdma_set_max_header_sizes(struct rpcrdma_xprt *);
529529

530530
/* RPC/RDMA module init - xprtrdma/transport.c
531531
*/

0 commit comments

Comments
 (0)