Skip to content

Commit 93aa8e0

Browse files
chuckleveramschuma-ntap
authored andcommitted
xprtrdma: Merge struct rpcrdma_ia into struct rpcrdma_ep
I eventually want to allocate rpcrdma_ep separately from struct rpcrdma_xprt so that on occasion there can be more than one ep per xprt. The new struct rpcrdma_ep will contain all the fields currently in rpcrdma_ia and in rpcrdma_ep. This is all the device and CM settings for the connection, in addition to per-connection settings negotiated with the remote. Take this opportunity to rename the existing ep fields from rep_* to re_* to disambiguate these from struct rpcrdma_rep. Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent d6ccebf commit 93aa8e0

File tree

7 files changed

+246
-261
lines changed

7 files changed

+246
-261
lines changed

include/trace/events/rpcrdma.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ DECLARE_EVENT_CLASS(xprtrdma_connect_class,
104104
TP_fast_assign(
105105
__entry->r_xprt = r_xprt;
106106
__entry->rc = rc;
107-
__entry->connect_status = r_xprt->rx_ep.rep_connected;
107+
__entry->connect_status = r_xprt->rx_ep.re_connect_status;
108108
__assign_str(addr, rpcrdma_addrstr(r_xprt));
109109
__assign_str(port, rpcrdma_portstr(r_xprt));
110110
),
@@ -394,10 +394,10 @@ TRACE_EVENT(xprtrdma_inline_thresh,
394394
const struct rpcrdma_ep *ep = &r_xprt->rx_ep;
395395

396396
__entry->r_xprt = r_xprt;
397-
__entry->inline_send = ep->rep_inline_send;
398-
__entry->inline_recv = ep->rep_inline_recv;
399-
__entry->max_send = ep->rep_max_inline_send;
400-
__entry->max_recv = ep->rep_max_inline_recv;
397+
__entry->inline_send = ep->re_inline_send;
398+
__entry->inline_recv = ep->re_inline_recv;
399+
__entry->max_send = ep->re_max_inline_send;
400+
__entry->max_recv = ep->re_max_inline_recv;
401401
__assign_str(addr, rpcrdma_addrstr(r_xprt));
402402
__assign_str(port, rpcrdma_portstr(r_xprt));
403403
),
@@ -803,7 +803,7 @@ TRACE_EVENT(xprtrdma_post_recvs,
803803
__entry->r_xprt = r_xprt;
804804
__entry->count = count;
805805
__entry->status = status;
806-
__entry->posted = r_xprt->rx_ep.rep_receive_count;
806+
__entry->posted = r_xprt->rx_ep.re_receive_count;
807807
__assign_str(addr, rpcrdma_addrstr(r_xprt));
808808
__assign_str(port, rpcrdma_portstr(r_xprt));
809809
),

net/sunrpc/xprtrdma/backchannel.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ size_t xprt_rdma_bc_maxpayload(struct rpc_xprt *xprt)
4747
struct rpcrdma_ep *ep = &r_xprt->rx_ep;
4848
size_t maxmsg;
4949

50-
maxmsg = min_t(unsigned int, ep->rep_inline_send, ep->rep_inline_recv);
50+
maxmsg = min_t(unsigned int, ep->re_inline_send, ep->re_inline_recv);
5151
maxmsg = min_t(unsigned int, maxmsg, PAGE_SIZE);
5252
return maxmsg - RPCRDMA_HDRLEN_MIN;
5353
}
@@ -190,7 +190,7 @@ static struct rpc_rqst *rpcrdma_bc_rqst_get(struct rpcrdma_xprt *r_xprt)
190190
if (xprt->bc_alloc_count >= RPCRDMA_BACKWARD_WRS)
191191
return NULL;
192192

193-
size = min_t(size_t, r_xprt->rx_ep.rep_inline_recv, PAGE_SIZE);
193+
size = min_t(size_t, r_xprt->rx_ep.re_inline_recv, PAGE_SIZE);
194194
req = rpcrdma_req_create(r_xprt, size, GFP_KERNEL);
195195
if (!req)
196196
return NULL;

net/sunrpc/xprtrdma/frwr_ops.c

Lines changed: 51 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static void frwr_mr_recycle(struct rpcrdma_mr *mr)
7474

7575
if (mr->mr_dir != DMA_NONE) {
7676
trace_xprtrdma_mr_unmap(mr);
77-
ib_dma_unmap_sg(r_xprt->rx_ia.ri_id->device,
77+
ib_dma_unmap_sg(r_xprt->rx_ep.re_id->device,
7878
mr->mr_sg, mr->mr_nents, mr->mr_dir);
7979
mr->mr_dir = DMA_NONE;
8080
}
@@ -115,13 +115,13 @@ void frwr_reset(struct rpcrdma_req *req)
115115
*/
116116
int frwr_mr_init(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr *mr)
117117
{
118-
struct rpcrdma_ia *ia = &r_xprt->rx_ia;
119-
unsigned int depth = ia->ri_max_frwr_depth;
118+
struct rpcrdma_ep *ep = &r_xprt->rx_ep;
119+
unsigned int depth = ep->re_max_fr_depth;
120120
struct scatterlist *sg;
121121
struct ib_mr *frmr;
122122
int rc;
123123

124-
frmr = ib_alloc_mr(ia->ri_pd, ia->ri_mrtype, depth);
124+
frmr = ib_alloc_mr(ep->re_pd, ep->re_mrtype, depth);
125125
if (IS_ERR(frmr))
126126
goto out_mr_err;
127127

@@ -151,29 +151,24 @@ int frwr_mr_init(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr *mr)
151151

152152
/**
153153
* frwr_query_device - Prepare a transport for use with FRWR
154-
* @r_xprt: controlling transport instance
154+
* @ep: endpoint to fill in
155155
* @device: RDMA device to query
156156
*
157157
* On success, sets:
158-
* ep->rep_attr
159-
* ep->rep_max_requests
160-
* ia->ri_max_rdma_segs
161-
*
162-
* And these FRWR-related fields:
163-
* ia->ri_max_frwr_depth
164-
* ia->ri_mrtype
158+
* ep->re_attr
159+
* ep->re_max_requests
160+
* ep->re_max_rdma_segs
161+
* ep->re_max_fr_depth
162+
* ep->re_mrtype
165163
*
166164
* Return values:
167165
* On success, returns zero.
168166
* %-EINVAL - the device does not support FRWR memory registration
169167
* %-ENOMEM - the device is not sufficiently capable for NFS/RDMA
170168
*/
171-
int frwr_query_device(struct rpcrdma_xprt *r_xprt,
172-
const struct ib_device *device)
169+
int frwr_query_device(struct rpcrdma_ep *ep, const struct ib_device *device)
173170
{
174171
const struct ib_device_attr *attrs = &device->attrs;
175-
struct rpcrdma_ia *ia = &r_xprt->rx_ia;
176-
struct rpcrdma_ep *ep = &r_xprt->rx_ep;
177172
int max_qp_wr, depth, delta;
178173
unsigned int max_sge;
179174

@@ -190,23 +185,23 @@ int frwr_query_device(struct rpcrdma_xprt *r_xprt,
190185
pr_err("rpcrdma: HCA provides only %u send SGEs\n", max_sge);
191186
return -ENOMEM;
192187
}
193-
ep->rep_attr.cap.max_send_sge = max_sge;
194-
ep->rep_attr.cap.max_recv_sge = 1;
188+
ep->re_attr.cap.max_send_sge = max_sge;
189+
ep->re_attr.cap.max_recv_sge = 1;
195190

196-
ia->ri_mrtype = IB_MR_TYPE_MEM_REG;
191+
ep->re_mrtype = IB_MR_TYPE_MEM_REG;
197192
if (attrs->device_cap_flags & IB_DEVICE_SG_GAPS_REG)
198-
ia->ri_mrtype = IB_MR_TYPE_SG_GAPS;
193+
ep->re_mrtype = IB_MR_TYPE_SG_GAPS;
199194

200195
/* Quirk: Some devices advertise a large max_fast_reg_page_list_len
201196
* capability, but perform optimally when the MRs are not larger
202197
* than a page.
203198
*/
204199
if (attrs->max_sge_rd > RPCRDMA_MAX_HDR_SEGS)
205-
ia->ri_max_frwr_depth = attrs->max_sge_rd;
200+
ep->re_max_fr_depth = attrs->max_sge_rd;
206201
else
207-
ia->ri_max_frwr_depth = attrs->max_fast_reg_page_list_len;
208-
if (ia->ri_max_frwr_depth > RPCRDMA_MAX_DATA_SEGS)
209-
ia->ri_max_frwr_depth = RPCRDMA_MAX_DATA_SEGS;
202+
ep->re_max_fr_depth = attrs->max_fast_reg_page_list_len;
203+
if (ep->re_max_fr_depth > RPCRDMA_MAX_DATA_SEGS)
204+
ep->re_max_fr_depth = RPCRDMA_MAX_DATA_SEGS;
210205

211206
/* Add room for frwr register and invalidate WRs.
212207
* 1. FRWR reg WR for head
@@ -222,11 +217,11 @@ int frwr_query_device(struct rpcrdma_xprt *r_xprt,
222217
/* Calculate N if the device max FRWR depth is smaller than
223218
* RPCRDMA_MAX_DATA_SEGS.
224219
*/
225-
if (ia->ri_max_frwr_depth < RPCRDMA_MAX_DATA_SEGS) {
226-
delta = RPCRDMA_MAX_DATA_SEGS - ia->ri_max_frwr_depth;
220+
if (ep->re_max_fr_depth < RPCRDMA_MAX_DATA_SEGS) {
221+
delta = RPCRDMA_MAX_DATA_SEGS - ep->re_max_fr_depth;
227222
do {
228223
depth += 2; /* FRWR reg + invalidate */
229-
delta -= ia->ri_max_frwr_depth;
224+
delta -= ep->re_max_fr_depth;
230225
} while (delta > 0);
231226
}
232227

@@ -235,34 +230,34 @@ int frwr_query_device(struct rpcrdma_xprt *r_xprt,
235230
max_qp_wr -= 1;
236231
if (max_qp_wr < RPCRDMA_MIN_SLOT_TABLE)
237232
return -ENOMEM;
238-
if (ep->rep_max_requests > max_qp_wr)
239-
ep->rep_max_requests = max_qp_wr;
240-
ep->rep_attr.cap.max_send_wr = ep->rep_max_requests * depth;
241-
if (ep->rep_attr.cap.max_send_wr > max_qp_wr) {
242-
ep->rep_max_requests = max_qp_wr / depth;
243-
if (!ep->rep_max_requests)
233+
if (ep->re_max_requests > max_qp_wr)
234+
ep->re_max_requests = max_qp_wr;
235+
ep->re_attr.cap.max_send_wr = ep->re_max_requests * depth;
236+
if (ep->re_attr.cap.max_send_wr > max_qp_wr) {
237+
ep->re_max_requests = max_qp_wr / depth;
238+
if (!ep->re_max_requests)
244239
return -ENOMEM;
245-
ep->rep_attr.cap.max_send_wr = ep->rep_max_requests * depth;
240+
ep->re_attr.cap.max_send_wr = ep->re_max_requests * depth;
246241
}
247-
ep->rep_attr.cap.max_send_wr += RPCRDMA_BACKWARD_WRS;
248-
ep->rep_attr.cap.max_send_wr += 1; /* for ib_drain_sq */
249-
ep->rep_attr.cap.max_recv_wr = ep->rep_max_requests;
250-
ep->rep_attr.cap.max_recv_wr += RPCRDMA_BACKWARD_WRS;
251-
ep->rep_attr.cap.max_recv_wr += 1; /* for ib_drain_rq */
252-
253-
ia->ri_max_rdma_segs =
254-
DIV_ROUND_UP(RPCRDMA_MAX_DATA_SEGS, ia->ri_max_frwr_depth);
242+
ep->re_attr.cap.max_send_wr += RPCRDMA_BACKWARD_WRS;
243+
ep->re_attr.cap.max_send_wr += 1; /* for ib_drain_sq */
244+
ep->re_attr.cap.max_recv_wr = ep->re_max_requests;
245+
ep->re_attr.cap.max_recv_wr += RPCRDMA_BACKWARD_WRS;
246+
ep->re_attr.cap.max_recv_wr += 1; /* for ib_drain_rq */
247+
248+
ep->re_max_rdma_segs =
249+
DIV_ROUND_UP(RPCRDMA_MAX_DATA_SEGS, ep->re_max_fr_depth);
255250
/* Reply chunks require segments for head and tail buffers */
256-
ia->ri_max_rdma_segs += 2;
257-
if (ia->ri_max_rdma_segs > RPCRDMA_MAX_HDR_SEGS)
258-
ia->ri_max_rdma_segs = RPCRDMA_MAX_HDR_SEGS;
251+
ep->re_max_rdma_segs += 2;
252+
if (ep->re_max_rdma_segs > RPCRDMA_MAX_HDR_SEGS)
253+
ep->re_max_rdma_segs = RPCRDMA_MAX_HDR_SEGS;
259254

260255
/* Ensure the underlying device is capable of conveying the
261256
* largest r/wsize NFS will ask for. This guarantees that
262257
* failing over from one RDMA device to another will not
263258
* break NFS I/O.
264259
*/
265-
if ((ia->ri_max_rdma_segs * ia->ri_max_frwr_depth) < RPCRDMA_MAX_SEGS)
260+
if ((ep->re_max_rdma_segs * ep->re_max_fr_depth) < RPCRDMA_MAX_SEGS)
266261
return -ENOMEM;
267262

268263
return 0;
@@ -288,14 +283,14 @@ struct rpcrdma_mr_seg *frwr_map(struct rpcrdma_xprt *r_xprt,
288283
int nsegs, bool writing, __be32 xid,
289284
struct rpcrdma_mr *mr)
290285
{
291-
struct rpcrdma_ia *ia = &r_xprt->rx_ia;
286+
struct rpcrdma_ep *ep = &r_xprt->rx_ep;
292287
struct ib_reg_wr *reg_wr;
293288
int i, n, dma_nents;
294289
struct ib_mr *ibmr;
295290
u8 key;
296291

297-
if (nsegs > ia->ri_max_frwr_depth)
298-
nsegs = ia->ri_max_frwr_depth;
292+
if (nsegs > ep->re_max_fr_depth)
293+
nsegs = ep->re_max_fr_depth;
299294
for (i = 0; i < nsegs;) {
300295
if (seg->mr_page)
301296
sg_set_page(&mr->mr_sg[i],
@@ -308,7 +303,7 @@ struct rpcrdma_mr_seg *frwr_map(struct rpcrdma_xprt *r_xprt,
308303

309304
++seg;
310305
++i;
311-
if (ia->ri_mrtype == IB_MR_TYPE_SG_GAPS)
306+
if (ep->re_mrtype == IB_MR_TYPE_SG_GAPS)
312307
continue;
313308
if ((i < nsegs && offset_in_page(seg->mr_offset)) ||
314309
offset_in_page((seg-1)->mr_offset + (seg-1)->mr_len))
@@ -317,7 +312,7 @@ struct rpcrdma_mr_seg *frwr_map(struct rpcrdma_xprt *r_xprt,
317312
mr->mr_dir = rpcrdma_data_dir(writing);
318313
mr->mr_nents = i;
319314

320-
dma_nents = ib_dma_map_sg(ia->ri_id->device, mr->mr_sg, mr->mr_nents,
315+
dma_nents = ib_dma_map_sg(ep->re_id->device, mr->mr_sg, mr->mr_nents,
321316
mr->mr_dir);
322317
if (!dma_nents)
323318
goto out_dmamap_err;
@@ -391,7 +386,6 @@ static void frwr_wc_fastreg(struct ib_cq *cq, struct ib_wc *wc)
391386
*/
392387
int frwr_send(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req)
393388
{
394-
struct rpcrdma_ia *ia = &r_xprt->rx_ia;
395389
struct ib_send_wr *post_wr;
396390
struct rpcrdma_mr *mr;
397391

@@ -411,7 +405,7 @@ int frwr_send(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req)
411405
post_wr = &frwr->fr_regwr.wr;
412406
}
413407

414-
return ib_post_send(ia->ri_id->qp, post_wr, NULL);
408+
return ib_post_send(r_xprt->rx_ep.re_id->qp, post_wr, NULL);
415409
}
416410

417411
/**
@@ -538,10 +532,10 @@ void frwr_unmap_sync(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req)
538532

539533
/* Transport disconnect drains the receive CQ before it
540534
* replaces the QP. The RPC reply handler won't call us
541-
* unless ri_id->qp is a valid pointer.
535+
* unless re_id->qp is a valid pointer.
542536
*/
543537
bad_wr = NULL;
544-
rc = ib_post_send(r_xprt->rx_ia.ri_id->qp, first, &bad_wr);
538+
rc = ib_post_send(r_xprt->rx_ep.re_id->qp, first, &bad_wr);
545539

546540
/* The final LOCAL_INV WR in the chain is supposed to
547541
* do the wake. If it was never posted, the wake will
@@ -643,10 +637,10 @@ void frwr_unmap_async(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req)
643637

644638
/* Transport disconnect drains the receive CQ before it
645639
* replaces the QP. The RPC reply handler won't call us
646-
* unless ri_id->qp is a valid pointer.
640+
* unless re_id->qp is a valid pointer.
647641
*/
648642
bad_wr = NULL;
649-
rc = ib_post_send(r_xprt->rx_ia.ri_id->qp, first, &bad_wr);
643+
rc = ib_post_send(r_xprt->rx_ep.re_id->qp, first, &bad_wr);
650644
if (!rc)
651645
return;
652646

net/sunrpc/xprtrdma/rpc_rdma.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,20 @@ static unsigned int rpcrdma_max_reply_header_size(unsigned int maxsegs)
103103

104104
/**
105105
* rpcrdma_set_max_header_sizes - Initialize inline payload sizes
106-
* @r_xprt: transport instance to initialize
106+
* @ep: endpoint to initialize
107107
*
108108
* The max_inline fields contain the maximum size of an RPC message
109109
* so the marshaling code doesn't have to repeat this calculation
110110
* for every RPC.
111111
*/
112-
void rpcrdma_set_max_header_sizes(struct rpcrdma_xprt *r_xprt)
112+
void rpcrdma_set_max_header_sizes(struct rpcrdma_ep *ep)
113113
{
114-
unsigned int maxsegs = r_xprt->rx_ia.ri_max_rdma_segs;
115-
struct rpcrdma_ep *ep = &r_xprt->rx_ep;
114+
unsigned int maxsegs = ep->re_max_rdma_segs;
116115

117-
ep->rep_max_inline_send =
118-
ep->rep_inline_send - rpcrdma_max_call_header_size(maxsegs);
119-
ep->rep_max_inline_recv =
120-
ep->rep_inline_recv - rpcrdma_max_reply_header_size(maxsegs);
116+
ep->re_max_inline_send =
117+
ep->re_inline_send - rpcrdma_max_call_header_size(maxsegs);
118+
ep->re_max_inline_recv =
119+
ep->re_inline_recv - rpcrdma_max_reply_header_size(maxsegs);
121120
}
122121

123122
/* The client can send a request inline as long as the RPCRDMA header
@@ -134,7 +133,7 @@ static bool rpcrdma_args_inline(struct rpcrdma_xprt *r_xprt,
134133
struct xdr_buf *xdr = &rqst->rq_snd_buf;
135134
unsigned int count, remaining, offset;
136135

137-
if (xdr->len > r_xprt->rx_ep.rep_max_inline_send)
136+
if (xdr->len > r_xprt->rx_ep.re_max_inline_send)
138137
return false;
139138

140139
if (xdr->page_len) {
@@ -145,7 +144,7 @@ static bool rpcrdma_args_inline(struct rpcrdma_xprt *r_xprt,
145144
remaining -= min_t(unsigned int,
146145
PAGE_SIZE - offset, remaining);
147146
offset = 0;
148-
if (++count > r_xprt->rx_ep.rep_attr.cap.max_send_sge)
147+
if (++count > r_xprt->rx_ep.re_attr.cap.max_send_sge)
149148
return false;
150149
}
151150
}
@@ -162,7 +161,7 @@ static bool rpcrdma_args_inline(struct rpcrdma_xprt *r_xprt,
162161
static bool rpcrdma_results_inline(struct rpcrdma_xprt *r_xprt,
163162
struct rpc_rqst *rqst)
164163
{
165-
return rqst->rq_rcv_buf.buflen <= r_xprt->rx_ep.rep_max_inline_recv;
164+
return rqst->rq_rcv_buf.buflen <= r_xprt->rx_ep.re_max_inline_recv;
166165
}
167166

168167
/* The client is required to provide a Reply chunk if the maximum
@@ -176,7 +175,7 @@ rpcrdma_nonpayload_inline(const struct rpcrdma_xprt *r_xprt,
176175
const struct xdr_buf *buf = &rqst->rq_rcv_buf;
177176

178177
return (buf->head[0].iov_len + buf->tail[0].iov_len) <
179-
r_xprt->rx_ep.rep_max_inline_recv;
178+
r_xprt->rx_ep.re_max_inline_recv;
180179
}
181180

182181
/* Split @vec on page boundaries into SGEs. FMR registers pages, not
@@ -255,15 +254,15 @@ rpcrdma_convert_iovs(struct rpcrdma_xprt *r_xprt, struct xdr_buf *xdrbuf,
255254
/* When encoding a Read chunk, the tail iovec contains an
256255
* XDR pad and may be omitted.
257256
*/
258-
if (type == rpcrdma_readch && r_xprt->rx_ia.ri_implicit_roundup)
257+
if (type == rpcrdma_readch && r_xprt->rx_ep.re_implicit_roundup)
259258
goto out;
260259

261260
/* When encoding a Write chunk, some servers need to see an
262261
* extra segment for non-XDR-aligned Write chunks. The upper
263262
* layer provides space in the tail iovec that may be used
264263
* for this purpose.
265264
*/
266-
if (type == rpcrdma_writech && r_xprt->rx_ia.ri_implicit_roundup)
265+
if (type == rpcrdma_writech && r_xprt->rx_ep.re_implicit_roundup)
267266
goto out;
268267

269268
if (xdrbuf->tail[0].iov_len)
@@ -1476,8 +1475,8 @@ void rpcrdma_reply_handler(struct rpcrdma_rep *rep)
14761475

14771476
if (credits == 0)
14781477
credits = 1; /* don't deadlock */
1479-
else if (credits > r_xprt->rx_ep.rep_max_requests)
1480-
credits = r_xprt->rx_ep.rep_max_requests;
1478+
else if (credits > r_xprt->rx_ep.re_max_requests)
1479+
credits = r_xprt->rx_ep.re_max_requests;
14811480
if (buf->rb_credits != credits)
14821481
rpcrdma_update_cwnd(r_xprt, credits);
14831482
rpcrdma_post_recvs(r_xprt, false);

0 commit comments

Comments
 (0)