Skip to content

Commit 3968cb5

Browse files
chuckleveramschuma-ntap
authored andcommitted
xprtrdma: Add "open" memreg op
The open op determines the size of various transport data structures based on device capabilities and memory registration mode. Signed-off-by: Chuck Lever <[email protected]> Tested-by: Devesh Sharma <[email protected]> Tested-by: Meghana Cheripady <[email protected]> Tested-by: Veeresh U. Kokatnur <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 4561f34 commit 3968cb5

File tree

5 files changed

+70
-46
lines changed

5 files changed

+70
-46
lines changed

net/sunrpc/xprtrdma/fmr_ops.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
/* Maximum scatter/gather per FMR */
2121
#define RPCRDMA_MAX_FMR_SGES (64)
2222

23+
static int
24+
fmr_op_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep,
25+
struct rpcrdma_create_data_internal *cdata)
26+
{
27+
return 0;
28+
}
29+
2330
/* FMR mode conveys up to 64 pages of payload per chunk segment.
2431
*/
2532
static size_t
@@ -188,6 +195,7 @@ fmr_op_destroy(struct rpcrdma_buffer *buf)
188195
const struct rpcrdma_memreg_ops rpcrdma_fmr_memreg_ops = {
189196
.ro_map = fmr_op_map,
190197
.ro_unmap = fmr_op_unmap,
198+
.ro_open = fmr_op_open,
191199
.ro_maxpages = fmr_op_maxpages,
192200
.ro_init = fmr_op_init,
193201
.ro_reset = fmr_op_reset,

net/sunrpc/xprtrdma/frwr_ops.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,53 @@ __frwr_release(struct rpcrdma_mw *r)
5858
ib_free_fast_reg_page_list(r->r.frmr.fr_pgl);
5959
}
6060

61+
static int
62+
frwr_op_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep,
63+
struct rpcrdma_create_data_internal *cdata)
64+
{
65+
struct ib_device_attr *devattr = &ia->ri_devattr;
66+
int depth, delta;
67+
68+
ia->ri_max_frmr_depth =
69+
min_t(unsigned int, RPCRDMA_MAX_DATA_SEGS,
70+
devattr->max_fast_reg_page_list_len);
71+
dprintk("RPC: %s: device's max FR page list len = %u\n",
72+
__func__, ia->ri_max_frmr_depth);
73+
74+
/* Add room for frmr register and invalidate WRs.
75+
* 1. FRMR reg WR for head
76+
* 2. FRMR invalidate WR for head
77+
* 3. N FRMR reg WRs for pagelist
78+
* 4. N FRMR invalidate WRs for pagelist
79+
* 5. FRMR reg WR for tail
80+
* 6. FRMR invalidate WR for tail
81+
* 7. The RDMA_SEND WR
82+
*/
83+
depth = 7;
84+
85+
/* Calculate N if the device max FRMR depth is smaller than
86+
* RPCRDMA_MAX_DATA_SEGS.
87+
*/
88+
if (ia->ri_max_frmr_depth < RPCRDMA_MAX_DATA_SEGS) {
89+
delta = RPCRDMA_MAX_DATA_SEGS - ia->ri_max_frmr_depth;
90+
do {
91+
depth += 2; /* FRMR reg + invalidate */
92+
delta -= ia->ri_max_frmr_depth;
93+
} while (delta > 0);
94+
}
95+
96+
ep->rep_attr.cap.max_send_wr *= depth;
97+
if (ep->rep_attr.cap.max_send_wr > devattr->max_qp_wr) {
98+
cdata->max_requests = devattr->max_qp_wr / depth;
99+
if (!cdata->max_requests)
100+
return -EINVAL;
101+
ep->rep_attr.cap.max_send_wr = cdata->max_requests *
102+
depth;
103+
}
104+
105+
return 0;
106+
}
107+
61108
/* FRWR mode conveys a list of pages per chunk segment. The
62109
* maximum length of that list is the FRWR page list depth.
63110
*/
@@ -276,6 +323,7 @@ frwr_op_destroy(struct rpcrdma_buffer *buf)
276323
const struct rpcrdma_memreg_ops rpcrdma_frwr_memreg_ops = {
277324
.ro_map = frwr_op_map,
278325
.ro_unmap = frwr_op_unmap,
326+
.ro_open = frwr_op_open,
279327
.ro_maxpages = frwr_op_maxpages,
280328
.ro_init = frwr_op_init,
281329
.ro_reset = frwr_op_reset,

net/sunrpc/xprtrdma/physical_ops.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
# define RPCDBG_FACILITY RPCDBG_TRANS
2020
#endif
2121

22+
static int
23+
physical_op_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep,
24+
struct rpcrdma_create_data_internal *cdata)
25+
{
26+
return 0;
27+
}
28+
2229
/* PHYSICAL memory registration conveys one page per chunk segment.
2330
*/
2431
static size_t
@@ -72,6 +79,7 @@ physical_op_destroy(struct rpcrdma_buffer *buf)
7279
const struct rpcrdma_memreg_ops rpcrdma_physical_memreg_ops = {
7380
.ro_map = physical_op_map,
7481
.ro_unmap = physical_op_unmap,
82+
.ro_open = physical_op_open,
7583
.ro_maxpages = physical_op_maxpages,
7684
.ro_init = physical_op_init,
7785
.ro_reset = physical_op_reset,

net/sunrpc/xprtrdma/verbs.c

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -622,11 +622,6 @@ rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr *addr, int memreg)
622622
dprintk("RPC: %s: FRMR registration "
623623
"not supported by HCA\n", __func__);
624624
memreg = RPCRDMA_MTHCAFMR;
625-
} else {
626-
/* Mind the ia limit on FRMR page list depth */
627-
ia->ri_max_frmr_depth = min_t(unsigned int,
628-
RPCRDMA_MAX_DATA_SEGS,
629-
devattr->max_fast_reg_page_list_len);
630625
}
631626
}
632627
if (memreg == RPCRDMA_MTHCAFMR) {
@@ -741,49 +736,11 @@ rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia,
741736

742737
ep->rep_attr.event_handler = rpcrdma_qp_async_error_upcall;
743738
ep->rep_attr.qp_context = ep;
744-
/* send_cq and recv_cq initialized below */
745739
ep->rep_attr.srq = NULL;
746740
ep->rep_attr.cap.max_send_wr = cdata->max_requests;
747-
switch (ia->ri_memreg_strategy) {
748-
case RPCRDMA_FRMR: {
749-
int depth = 7;
750-
751-
/* Add room for frmr register and invalidate WRs.
752-
* 1. FRMR reg WR for head
753-
* 2. FRMR invalidate WR for head
754-
* 3. N FRMR reg WRs for pagelist
755-
* 4. N FRMR invalidate WRs for pagelist
756-
* 5. FRMR reg WR for tail
757-
* 6. FRMR invalidate WR for tail
758-
* 7. The RDMA_SEND WR
759-
*/
760-
761-
/* Calculate N if the device max FRMR depth is smaller than
762-
* RPCRDMA_MAX_DATA_SEGS.
763-
*/
764-
if (ia->ri_max_frmr_depth < RPCRDMA_MAX_DATA_SEGS) {
765-
int delta = RPCRDMA_MAX_DATA_SEGS -
766-
ia->ri_max_frmr_depth;
767-
768-
do {
769-
depth += 2; /* FRMR reg + invalidate */
770-
delta -= ia->ri_max_frmr_depth;
771-
} while (delta > 0);
772-
773-
}
774-
ep->rep_attr.cap.max_send_wr *= depth;
775-
if (ep->rep_attr.cap.max_send_wr > devattr->max_qp_wr) {
776-
cdata->max_requests = devattr->max_qp_wr / depth;
777-
if (!cdata->max_requests)
778-
return -EINVAL;
779-
ep->rep_attr.cap.max_send_wr = cdata->max_requests *
780-
depth;
781-
}
782-
break;
783-
}
784-
default:
785-
break;
786-
}
741+
rc = ia->ri_ops->ro_open(ia, ep, cdata);
742+
if (rc)
743+
return rc;
787744
ep->rep_attr.cap.max_recv_wr = cdata->max_requests;
788745
ep->rep_attr.cap.max_send_sge = (cdata->padding ? 4 : 2);
789746
ep->rep_attr.cap.max_recv_sge = 1;

net/sunrpc/xprtrdma/xprt_rdma.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,9 @@ struct rpcrdma_memreg_ops {
340340
struct rpcrdma_mr_seg *, int, bool);
341341
int (*ro_unmap)(struct rpcrdma_xprt *,
342342
struct rpcrdma_mr_seg *);
343+
int (*ro_open)(struct rpcrdma_ia *,
344+
struct rpcrdma_ep *,
345+
struct rpcrdma_create_data_internal *);
343346
size_t (*ro_maxpages)(struct rpcrdma_xprt *);
344347
int (*ro_init)(struct rpcrdma_xprt *);
345348
void (*ro_reset)(struct rpcrdma_xprt *);

0 commit comments

Comments
 (0)