diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2014-07-29 17:24:09 -0400 |
---|---|---|
committer | Anna Schumaker <Anna.Schumaker@Netapp.com> | 2014-07-31 16:22:54 -0400 |
commit | 0dbb4108a6a615589751de2aaf468d3ddbcef24c (patch) | |
tree | 462d3f68adb8bbafd03e05f7548f7a2d34b6617c /net/sunrpc/xprtrdma | |
parent | 539431a437d2e5d6d94016184dfc0aab263c01e1 (diff) |
xprtrdma: Unclutter struct rpcrdma_mr_seg
Clean ups:
- make it obvious that the rl_mw field is a pointer -- allocated
separately, not as part of struct rpcrdma_mr_seg
- promote "struct {} frmr;" to a named type
- promote the state enum to a named type
- name the MW state field the same way other fields in
rpcrdma_mw are named
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Tested-by: Steve Wise <swise@opengridcomputing.com>
Tested-by: Shirley Ma <shirley.ma@oracle.com>
Tested-by: Devesh Sharma <devesh.sharma@emulex.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Diffstat (limited to 'net/sunrpc/xprtrdma')
-rw-r--r-- | net/sunrpc/xprtrdma/verbs.c | 34 | ||||
-rw-r--r-- | net/sunrpc/xprtrdma/xprt_rdma.h | 44 |
2 files changed, 50 insertions, 28 deletions
diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c index e49cdc930dfd..dd1dabcd3a07 100644 --- a/net/sunrpc/xprtrdma/verbs.c +++ b/net/sunrpc/xprtrdma/verbs.c | |||
@@ -156,9 +156,9 @@ rpcrdma_sendcq_process_wc(struct ib_wc *wc) | |||
156 | return; | 156 | return; |
157 | 157 | ||
158 | if (wc->opcode == IB_WC_FAST_REG_MR) | 158 | if (wc->opcode == IB_WC_FAST_REG_MR) |
159 | frmr->r.frmr.state = FRMR_IS_VALID; | 159 | frmr->r.frmr.fr_state = FRMR_IS_VALID; |
160 | else if (wc->opcode == IB_WC_LOCAL_INV) | 160 | else if (wc->opcode == IB_WC_LOCAL_INV) |
161 | frmr->r.frmr.state = FRMR_IS_INVALID; | 161 | frmr->r.frmr.fr_state = FRMR_IS_INVALID; |
162 | } | 162 | } |
163 | 163 | ||
164 | static int | 164 | static int |
@@ -1496,6 +1496,9 @@ rpcrdma_register_frmr_external(struct rpcrdma_mr_seg *seg, | |||
1496 | struct rpcrdma_xprt *r_xprt) | 1496 | struct rpcrdma_xprt *r_xprt) |
1497 | { | 1497 | { |
1498 | struct rpcrdma_mr_seg *seg1 = seg; | 1498 | struct rpcrdma_mr_seg *seg1 = seg; |
1499 | struct rpcrdma_mw *mw = seg1->mr_chunk.rl_mw; | ||
1500 | struct rpcrdma_frmr *frmr = &mw->r.frmr; | ||
1501 | struct ib_mr *mr = frmr->fr_mr; | ||
1499 | struct ib_send_wr invalidate_wr, frmr_wr, *bad_wr, *post_wr; | 1502 | struct ib_send_wr invalidate_wr, frmr_wr, *bad_wr, *post_wr; |
1500 | 1503 | ||
1501 | u8 key; | 1504 | u8 key; |
@@ -1515,8 +1518,7 @@ rpcrdma_register_frmr_external(struct rpcrdma_mr_seg *seg, | |||
1515 | rpcrdma_map_one(ia, seg, writing); | 1518 | rpcrdma_map_one(ia, seg, writing); |
1516 | pa = seg->mr_dma; | 1519 | pa = seg->mr_dma; |
1517 | for (seg_len = seg->mr_len; seg_len > 0; seg_len -= PAGE_SIZE) { | 1520 | for (seg_len = seg->mr_len; seg_len > 0; seg_len -= PAGE_SIZE) { |
1518 | seg1->mr_chunk.rl_mw->r.frmr.fr_pgl-> | 1521 | frmr->fr_pgl->page_list[page_no++] = pa; |
1519 | page_list[page_no++] = pa; | ||
1520 | pa += PAGE_SIZE; | 1522 | pa += PAGE_SIZE; |
1521 | } | 1523 | } |
1522 | len += seg->mr_len; | 1524 | len += seg->mr_len; |
@@ -1528,20 +1530,18 @@ rpcrdma_register_frmr_external(struct rpcrdma_mr_seg *seg, | |||
1528 | break; | 1530 | break; |
1529 | } | 1531 | } |
1530 | dprintk("RPC: %s: Using frmr %p to map %d segments\n", | 1532 | dprintk("RPC: %s: Using frmr %p to map %d segments\n", |
1531 | __func__, seg1->mr_chunk.rl_mw, i); | 1533 | __func__, mw, i); |
1532 | 1534 | ||
1533 | if (unlikely(seg1->mr_chunk.rl_mw->r.frmr.state == FRMR_IS_VALID)) { | 1535 | if (unlikely(frmr->fr_state == FRMR_IS_VALID)) { |
1534 | dprintk("RPC: %s: frmr %x left valid, posting invalidate.\n", | 1536 | dprintk("RPC: %s: frmr %x left valid, posting invalidate.\n", |
1535 | __func__, | 1537 | __func__, mr->rkey); |
1536 | seg1->mr_chunk.rl_mw->r.frmr.fr_mr->rkey); | ||
1537 | /* Invalidate before using. */ | 1538 | /* Invalidate before using. */ |
1538 | memset(&invalidate_wr, 0, sizeof invalidate_wr); | 1539 | memset(&invalidate_wr, 0, sizeof invalidate_wr); |
1539 | invalidate_wr.wr_id = (unsigned long)(void *)seg1->mr_chunk.rl_mw; | 1540 | invalidate_wr.wr_id = (unsigned long)(void *)mw; |
1540 | invalidate_wr.next = &frmr_wr; | 1541 | invalidate_wr.next = &frmr_wr; |
1541 | invalidate_wr.opcode = IB_WR_LOCAL_INV; | 1542 | invalidate_wr.opcode = IB_WR_LOCAL_INV; |
1542 | invalidate_wr.send_flags = IB_SEND_SIGNALED; | 1543 | invalidate_wr.send_flags = IB_SEND_SIGNALED; |
1543 | invalidate_wr.ex.invalidate_rkey = | 1544 | invalidate_wr.ex.invalidate_rkey = mr->rkey; |
1544 | seg1->mr_chunk.rl_mw->r.frmr.fr_mr->rkey; | ||
1545 | DECR_CQCOUNT(&r_xprt->rx_ep); | 1545 | DECR_CQCOUNT(&r_xprt->rx_ep); |
1546 | post_wr = &invalidate_wr; | 1546 | post_wr = &invalidate_wr; |
1547 | } else | 1547 | } else |
@@ -1549,11 +1549,11 @@ rpcrdma_register_frmr_external(struct rpcrdma_mr_seg *seg, | |||
1549 | 1549 | ||
1550 | /* Prepare FRMR WR */ | 1550 | /* Prepare FRMR WR */ |
1551 | memset(&frmr_wr, 0, sizeof frmr_wr); | 1551 | memset(&frmr_wr, 0, sizeof frmr_wr); |
1552 | frmr_wr.wr_id = (unsigned long)(void *)seg1->mr_chunk.rl_mw; | 1552 | frmr_wr.wr_id = (unsigned long)(void *)mw; |
1553 | frmr_wr.opcode = IB_WR_FAST_REG_MR; | 1553 | frmr_wr.opcode = IB_WR_FAST_REG_MR; |
1554 | frmr_wr.send_flags = IB_SEND_SIGNALED; | 1554 | frmr_wr.send_flags = IB_SEND_SIGNALED; |
1555 | frmr_wr.wr.fast_reg.iova_start = seg1->mr_dma; | 1555 | frmr_wr.wr.fast_reg.iova_start = seg1->mr_dma; |
1556 | frmr_wr.wr.fast_reg.page_list = seg1->mr_chunk.rl_mw->r.frmr.fr_pgl; | 1556 | frmr_wr.wr.fast_reg.page_list = frmr->fr_pgl; |
1557 | frmr_wr.wr.fast_reg.page_list_len = page_no; | 1557 | frmr_wr.wr.fast_reg.page_list_len = page_no; |
1558 | frmr_wr.wr.fast_reg.page_shift = PAGE_SHIFT; | 1558 | frmr_wr.wr.fast_reg.page_shift = PAGE_SHIFT; |
1559 | frmr_wr.wr.fast_reg.length = page_no << PAGE_SHIFT; | 1559 | frmr_wr.wr.fast_reg.length = page_no << PAGE_SHIFT; |
@@ -1563,13 +1563,13 @@ rpcrdma_register_frmr_external(struct rpcrdma_mr_seg *seg, | |||
1563 | } | 1563 | } |
1564 | 1564 | ||
1565 | /* Bump the key */ | 1565 | /* Bump the key */ |
1566 | key = (u8)(seg1->mr_chunk.rl_mw->r.frmr.fr_mr->rkey & 0x000000FF); | 1566 | key = (u8)(mr->rkey & 0x000000FF); |
1567 | ib_update_fast_reg_key(seg1->mr_chunk.rl_mw->r.frmr.fr_mr, ++key); | 1567 | ib_update_fast_reg_key(mr, ++key); |
1568 | 1568 | ||
1569 | frmr_wr.wr.fast_reg.access_flags = (writing ? | 1569 | frmr_wr.wr.fast_reg.access_flags = (writing ? |
1570 | IB_ACCESS_REMOTE_WRITE | IB_ACCESS_LOCAL_WRITE : | 1570 | IB_ACCESS_REMOTE_WRITE | IB_ACCESS_LOCAL_WRITE : |
1571 | IB_ACCESS_REMOTE_READ); | 1571 | IB_ACCESS_REMOTE_READ); |
1572 | frmr_wr.wr.fast_reg.rkey = seg1->mr_chunk.rl_mw->r.frmr.fr_mr->rkey; | 1572 | frmr_wr.wr.fast_reg.rkey = mr->rkey; |
1573 | DECR_CQCOUNT(&r_xprt->rx_ep); | 1573 | DECR_CQCOUNT(&r_xprt->rx_ep); |
1574 | 1574 | ||
1575 | rc = ib_post_send(ia->ri_id->qp, post_wr, &bad_wr); | 1575 | rc = ib_post_send(ia->ri_id->qp, post_wr, &bad_wr); |
@@ -1579,7 +1579,7 @@ rpcrdma_register_frmr_external(struct rpcrdma_mr_seg *seg, | |||
1579 | " status %i\n", __func__, rc); | 1579 | " status %i\n", __func__, rc); |
1580 | goto out_err; | 1580 | goto out_err; |
1581 | } else { | 1581 | } else { |
1582 | seg1->mr_rkey = seg1->mr_chunk.rl_mw->r.frmr.fr_mr->rkey; | 1582 | seg1->mr_rkey = mr->rkey; |
1583 | seg1->mr_base = seg1->mr_dma + pageoff; | 1583 | seg1->mr_base = seg1->mr_dma + pageoff; |
1584 | seg1->mr_nsegs = i; | 1584 | seg1->mr_nsegs = i; |
1585 | seg1->mr_len = len; | 1585 | seg1->mr_len = len; |
diff --git a/net/sunrpc/xprtrdma/xprt_rdma.h b/net/sunrpc/xprtrdma/xprt_rdma.h index c270e59cf917..84c3455a9521 100644 --- a/net/sunrpc/xprtrdma/xprt_rdma.h +++ b/net/sunrpc/xprtrdma/xprt_rdma.h | |||
@@ -146,6 +146,38 @@ struct rpcrdma_rep { | |||
146 | }; | 146 | }; |
147 | 147 | ||
148 | /* | 148 | /* |
149 | * struct rpcrdma_mw - external memory region metadata | ||
150 | * | ||
151 | * An external memory region is any buffer or page that is registered | ||
152 | * on the fly (ie, not pre-registered). | ||
153 | * | ||
154 | * Each rpcrdma_buffer has a list of these anchored in rb_mws. During | ||
155 | * call_allocate, rpcrdma_buffer_get() assigns one to each segment in | ||
156 | * an rpcrdma_req. Then rpcrdma_register_external() grabs these to keep | ||
157 | * track of registration metadata while each RPC is pending. | ||
158 | * rpcrdma_deregister_external() uses this metadata to unmap and | ||
159 | * release these resources when an RPC is complete. | ||
160 | */ | ||
161 | enum rpcrdma_frmr_state { | ||
162 | FRMR_IS_INVALID, /* ready to be used */ | ||
163 | FRMR_IS_VALID, /* in use */ | ||
164 | }; | ||
165 | |||
166 | struct rpcrdma_frmr { | ||
167 | struct ib_fast_reg_page_list *fr_pgl; | ||
168 | struct ib_mr *fr_mr; | ||
169 | enum rpcrdma_frmr_state fr_state; | ||
170 | }; | ||
171 | |||
172 | struct rpcrdma_mw { | ||
173 | union { | ||
174 | struct ib_fmr *fmr; | ||
175 | struct rpcrdma_frmr frmr; | ||
176 | } r; | ||
177 | struct list_head mw_list; | ||
178 | }; | ||
179 | |||
180 | /* | ||
149 | * struct rpcrdma_req -- structure central to the request/reply sequence. | 181 | * struct rpcrdma_req -- structure central to the request/reply sequence. |
150 | * | 182 | * |
151 | * N of these are associated with a transport instance, and stored in | 183 | * N of these are associated with a transport instance, and stored in |
@@ -172,17 +204,7 @@ struct rpcrdma_rep { | |||
172 | struct rpcrdma_mr_seg { /* chunk descriptors */ | 204 | struct rpcrdma_mr_seg { /* chunk descriptors */ |
173 | union { /* chunk memory handles */ | 205 | union { /* chunk memory handles */ |
174 | struct ib_mr *rl_mr; /* if registered directly */ | 206 | struct ib_mr *rl_mr; /* if registered directly */ |
175 | struct rpcrdma_mw { /* if registered from region */ | 207 | struct rpcrdma_mw *rl_mw; /* if registered from region */ |
176 | union { | ||
177 | struct ib_fmr *fmr; | ||
178 | struct { | ||
179 | struct ib_fast_reg_page_list *fr_pgl; | ||
180 | struct ib_mr *fr_mr; | ||
181 | enum { FRMR_IS_INVALID, FRMR_IS_VALID } state; | ||
182 | } frmr; | ||
183 | } r; | ||
184 | struct list_head mw_list; | ||
185 | } *rl_mw; | ||
186 | } mr_chunk; | 208 | } mr_chunk; |
187 | u64 mr_base; /* registration result */ | 209 | u64 mr_base; /* registration result */ |
188 | u32 mr_rkey; /* registration result */ | 210 | u32 mr_rkey; /* registration result */ |