blob: f700b34a5bfd24d8260b0b3641a29195368ef48c [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Chuck Levera0ce85f2015-03-30 14:34:21 -04002/*
Chuck Leverce5b3712017-12-14 20:57:47 -05003 * Copyright (c) 2015, 2017 Oracle. All rights reserved.
Chuck Levera0ce85f2015-03-30 14:34:21 -04004 * Copyright (c) 2003-2007 Network Appliance, Inc. All rights reserved.
5 */
6
7/* Lightweight memory registration using Fast Registration Work
Chuck Leverce5b3712017-12-14 20:57:47 -05008 * Requests (FRWR).
Chuck Levera0ce85f2015-03-30 14:34:21 -04009 *
Chuck Lever2fb2a4d2019-08-19 18:37:52 -040010 * FRWR features ordered asynchronous registration and invalidation
11 * of arbitrarily-sized memory regions. This is the fastest and safest
Chuck Levera0ce85f2015-03-30 14:34:21 -040012 * but most complex memory registration mode.
13 */
14
Chuck Leverc14d86e2015-05-26 11:52:35 -040015/* Normal operation
16 *
Chuck Lever2fb2a4d2019-08-19 18:37:52 -040017 * A Memory Region is prepared for RDMA Read or Write using a FAST_REG
Chuck Lever5f624122018-12-19 10:59:01 -050018 * Work Request (frwr_map). When the RDMA operation is finished, this
Chuck Leverc14d86e2015-05-26 11:52:35 -040019 * Memory Region is invalidated using a LOCAL_INV Work Request
Chuck Lever2fb2a4d2019-08-19 18:37:52 -040020 * (frwr_unmap_async and frwr_unmap_sync).
Chuck Leverc14d86e2015-05-26 11:52:35 -040021 *
Chuck Lever2fb2a4d2019-08-19 18:37:52 -040022 * Typically FAST_REG Work Requests are not signaled, and neither are
23 * RDMA Send Work Requests (with the exception of signaling occasionally
24 * to prevent provider work queue overflows). This greatly reduces HCA
Chuck Leverc14d86e2015-05-26 11:52:35 -040025 * interrupt workload.
Chuck Leverc14d86e2015-05-26 11:52:35 -040026 */
27
28/* Transport recovery
29 *
Chuck Lever2fb2a4d2019-08-19 18:37:52 -040030 * frwr_map and frwr_unmap_* cannot run at the same time the transport
31 * connect worker is running. The connect worker holds the transport
32 * send lock, just as ->send_request does. This prevents frwr_map and
33 * the connect worker from running concurrently. When a connection is
34 * closed, the Receive completion queue is drained before the allowing
35 * the connect worker to get control. This prevents frwr_unmap and the
36 * connect worker from running concurrently.
Chuck Leverc14d86e2015-05-26 11:52:35 -040037 *
Chuck Lever2fb2a4d2019-08-19 18:37:52 -040038 * When the underlying transport disconnects, MRs that are in flight
Chuck Lever9d2da4f2019-10-09 13:07:48 -040039 * are flushed and are likely unusable. Thus all MRs are destroyed.
40 * New MRs are created on demand.
Chuck Leverc14d86e2015-05-26 11:52:35 -040041 */
42
Chuck Leverbd2abef2018-05-07 15:27:16 -040043#include <linux/sunrpc/svc_rdma.h>
Chuck Leverc8b920b2016-09-15 10:57:16 -040044
Chuck Levera0ce85f2015-03-30 14:34:21 -040045#include "xprt_rdma.h"
Chuck Leverb6e717cb2018-05-07 15:27:05 -040046#include <trace/events/rpcrdma.h>
Chuck Levera0ce85f2015-03-30 14:34:21 -040047
48#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
49# define RPCDBG_FACILITY RPCDBG_TRANS
50#endif
51
Chuck Lever0a26d102021-04-19 14:03:56 -040052static void frwr_cid_init(struct rpcrdma_ep *ep,
53 struct rpcrdma_mr *mr)
54{
55 struct rpc_rdma_cid *cid = &mr->mr_cid;
56
57 cid->ci_queue_id = ep->re_attr.send_cq->res.id;
Chuck Lever13bcf7e2021-04-19 14:04:21 -040058 cid->ci_completion_id = mr->mr_ibmr->res.id;
Chuck Lever0a26d102021-04-19 14:03:56 -040059}
60
Chuck Leveref2be592020-11-09 14:40:14 -050061static void frwr_mr_unmap(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr *mr)
Chuck Lever61da8862018-10-01 14:25:25 -040062{
Chuck Lever7a03aeb62020-11-09 14:40:19 -050063 if (mr->mr_device) {
Chuck Leverd379eaa2018-10-01 14:25:30 -040064 trace_xprtrdma_mr_unmap(mr);
Chuck Lever7a03aeb62020-11-09 14:40:19 -050065 ib_dma_unmap_sg(mr->mr_device, mr->mr_sg, mr->mr_nents,
66 mr->mr_dir);
67 mr->mr_device = NULL;
Chuck Lever61da8862018-10-01 14:25:25 -040068 }
Chuck Leveref2be592020-11-09 14:40:14 -050069}
70
Chuck Levere4b52ca2021-04-19 14:03:12 -040071/**
72 * frwr_mr_release - Destroy one MR
73 * @mr: MR allocated by frwr_mr_init
74 *
75 */
76void frwr_mr_release(struct rpcrdma_mr *mr)
Chuck Leveref2be592020-11-09 14:40:14 -050077{
Chuck Levere4b52ca2021-04-19 14:03:12 -040078 int rc;
Chuck Leveref2be592020-11-09 14:40:14 -050079
Chuck Levere4b52ca2021-04-19 14:03:12 -040080 frwr_mr_unmap(mr->mr_xprt, mr);
Chuck Leveref2be592020-11-09 14:40:14 -050081
Chuck Lever13bcf7e2021-04-19 14:04:21 -040082 rc = ib_dereg_mr(mr->mr_ibmr);
Chuck Levere4b52ca2021-04-19 14:03:12 -040083 if (rc)
84 trace_xprtrdma_frwr_dereg(mr, rc);
85 kfree(mr->mr_sg);
86 kfree(mr);
Chuck Lever61da8862018-10-01 14:25:25 -040087}
88
Chuck Leveref2be592020-11-09 14:40:14 -050089static void frwr_mr_put(struct rpcrdma_mr *mr)
90{
91 frwr_mr_unmap(mr->mr_xprt, mr);
92
93 /* The MR is returned to the req's MR free list instead
94 * of to the xprt's MR free list. No spinlock is needed.
95 */
96 rpcrdma_mr_push(mr, &mr->mr_req->rl_free_mrs);
97}
98
Chuck Lever40088f02019-06-19 10:33:04 -040099/* frwr_reset - Place MRs back on the free list
100 * @req: request to reset
101 *
102 * Used after a failed marshal. For FRWR, this means the MRs
103 * don't have to be fully released and recreated.
104 *
105 * NB: This is safe only as long as none of @req's MRs are
106 * involved with an ongoing asynchronous FAST_REG or LOCAL_INV
107 * Work Request.
108 */
109void frwr_reset(struct rpcrdma_req *req)
110{
Chuck Lever265a38d2019-08-19 18:44:04 -0400111 struct rpcrdma_mr *mr;
Chuck Lever40088f02019-06-19 10:33:04 -0400112
Chuck Lever265a38d2019-08-19 18:44:04 -0400113 while ((mr = rpcrdma_mr_pop(&req->rl_registered)))
Chuck Leveref2be592020-11-09 14:40:14 -0500114 frwr_mr_put(mr);
Chuck Lever40088f02019-06-19 10:33:04 -0400115}
116
Chuck Lever5f624122018-12-19 10:59:01 -0500117/**
Chuck Lever253a5162020-02-21 17:00:17 -0500118 * frwr_mr_init - Initialize one MR
119 * @r_xprt: controlling transport instance
Chuck Lever5f624122018-12-19 10:59:01 -0500120 * @mr: generic MR to prepare for FRWR
121 *
122 * Returns zero if successful. Otherwise a negative errno
123 * is returned.
124 */
Chuck Lever253a5162020-02-21 17:00:17 -0500125int frwr_mr_init(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr *mr)
Chuck Leverd48b1d22016-06-29 13:52:29 -0400126{
Chuck Levere28ce902020-02-21 17:01:05 -0500127 struct rpcrdma_ep *ep = r_xprt->rx_ep;
Chuck Lever93aa8e02020-02-21 17:00:54 -0500128 unsigned int depth = ep->re_max_fr_depth;
Chuck Leverf85adb12018-12-19 11:00:48 -0500129 struct scatterlist *sg;
130 struct ib_mr *frmr;
Chuck Leverd48b1d22016-06-29 13:52:29 -0400131 int rc;
132
Chuck Lever93aa8e02020-02-21 17:00:54 -0500133 frmr = ib_alloc_mr(ep->re_pd, ep->re_mrtype, depth);
Chuck Leverf85adb12018-12-19 11:00:48 -0500134 if (IS_ERR(frmr))
Chuck Leverd48b1d22016-06-29 13:52:29 -0400135 goto out_mr_err;
136
Julia Lawalled38c332020-09-20 13:26:20 +0200137 sg = kmalloc_array(depth, sizeof(*sg), GFP_NOFS);
Chuck Leverf85adb12018-12-19 11:00:48 -0500138 if (!sg)
Chuck Leverd48b1d22016-06-29 13:52:29 -0400139 goto out_list_err;
140
Chuck Lever253a5162020-02-21 17:00:17 -0500141 mr->mr_xprt = r_xprt;
Chuck Lever13bcf7e2021-04-19 14:04:21 -0400142 mr->mr_ibmr = frmr;
Chuck Lever7a03aeb62020-11-09 14:40:19 -0500143 mr->mr_device = NULL;
Chuck Lever054f1552018-05-01 11:37:14 -0400144 INIT_LIST_HEAD(&mr->mr_list);
Chuck Lever9a301ca2021-04-19 14:04:09 -0400145 init_completion(&mr->mr_linv_done);
Chuck Lever0a26d102021-04-19 14:03:56 -0400146 frwr_cid_init(ep, mr);
Chuck Leverf85adb12018-12-19 11:00:48 -0500147
148 sg_init_table(sg, depth);
149 mr->mr_sg = sg;
Chuck Leverd48b1d22016-06-29 13:52:29 -0400150 return 0;
151
152out_mr_err:
Chuck Leverf85adb12018-12-19 11:00:48 -0500153 rc = PTR_ERR(frmr);
Chuck Lever53b2c1c2018-12-19 11:00:06 -0500154 trace_xprtrdma_frwr_alloc(mr, rc);
Chuck Leverd48b1d22016-06-29 13:52:29 -0400155 return rc;
156
157out_list_err:
Chuck Leverf85adb12018-12-19 11:00:48 -0500158 ib_dereg_mr(frmr);
159 return -ENOMEM;
Chuck Leverd48b1d22016-06-29 13:52:29 -0400160}
161
Chuck Lever5f624122018-12-19 10:59:01 -0500162/**
Chuck Lever25868e62020-01-03 11:56:48 -0500163 * frwr_query_device - Prepare a transport for use with FRWR
Chuck Lever93aa8e02020-02-21 17:00:54 -0500164 * @ep: endpoint to fill in
Chuck Lever25868e62020-01-03 11:56:48 -0500165 * @device: RDMA device to query
Chuck Lever5f624122018-12-19 10:59:01 -0500166 *
167 * On success, sets:
Chuck Lever93aa8e02020-02-21 17:00:54 -0500168 * ep->re_attr
169 * ep->re_max_requests
170 * ep->re_max_rdma_segs
171 * ep->re_max_fr_depth
172 * ep->re_mrtype
Chuck Lever5f624122018-12-19 10:59:01 -0500173 *
Chuck Lever25868e62020-01-03 11:56:48 -0500174 * Return values:
175 * On success, returns zero.
176 * %-EINVAL - the device does not support FRWR memory registration
177 * %-ENOMEM - the device is not sufficiently capable for NFS/RDMA
Chuck Lever914fcad2018-05-04 15:34:48 -0400178 */
Chuck Lever93aa8e02020-02-21 17:00:54 -0500179int frwr_query_device(struct rpcrdma_ep *ep, const struct ib_device *device)
Chuck Lever3968cb52015-03-30 14:35:26 -0400180{
Chuck Lever25868e62020-01-03 11:56:48 -0500181 const struct ib_device_attr *attrs = &device->attrs;
Chuck Lever914fcad2018-05-04 15:34:48 -0400182 int max_qp_wr, depth, delta;
Chuck Lever2e870362020-01-03 11:56:27 -0500183 unsigned int max_sge;
184
Chuck Lever25868e62020-01-03 11:56:48 -0500185 if (!(attrs->device_cap_flags & IB_DEVICE_MEM_MGT_EXTENSIONS) ||
186 attrs->max_fast_reg_page_list_len == 0) {
187 pr_err("rpcrdma: 'frwr' mode is not supported by device %s\n",
188 device->name);
189 return -EINVAL;
190 }
191
Chuck Lever2e870362020-01-03 11:56:27 -0500192 max_sge = min_t(unsigned int, attrs->max_send_sge,
193 RPCRDMA_MAX_SEND_SGES);
194 if (max_sge < RPCRDMA_MIN_SEND_SGES) {
195 pr_err("rpcrdma: HCA provides only %u send SGEs\n", max_sge);
196 return -ENOMEM;
197 }
Chuck Lever93aa8e02020-02-21 17:00:54 -0500198 ep->re_attr.cap.max_send_sge = max_sge;
199 ep->re_attr.cap.max_recv_sge = 1;
Chuck Lever3968cb52015-03-30 14:35:26 -0400200
Chuck Lever93aa8e02020-02-21 17:00:54 -0500201 ep->re_mrtype = IB_MR_TYPE_MEM_REG;
Chuck Lever5e9fc6a2016-11-29 10:52:24 -0500202 if (attrs->device_cap_flags & IB_DEVICE_SG_GAPS_REG)
Chuck Lever93aa8e02020-02-21 17:00:54 -0500203 ep->re_mrtype = IB_MR_TYPE_SG_GAPS;
Chuck Lever5e9fc6a2016-11-29 10:52:24 -0500204
Chuck Levera7886842018-12-19 10:58:51 -0500205 /* Quirk: Some devices advertise a large max_fast_reg_page_list_len
206 * capability, but perform optimally when the MRs are not larger
207 * than a page.
208 */
Chuck Lever18d065a2020-01-03 11:56:43 -0500209 if (attrs->max_sge_rd > RPCRDMA_MAX_HDR_SEGS)
Chuck Lever93aa8e02020-02-21 17:00:54 -0500210 ep->re_max_fr_depth = attrs->max_sge_rd;
Chuck Levera7886842018-12-19 10:58:51 -0500211 else
Chuck Lever93aa8e02020-02-21 17:00:54 -0500212 ep->re_max_fr_depth = attrs->max_fast_reg_page_list_len;
213 if (ep->re_max_fr_depth > RPCRDMA_MAX_DATA_SEGS)
214 ep->re_max_fr_depth = RPCRDMA_MAX_DATA_SEGS;
Chuck Lever3968cb52015-03-30 14:35:26 -0400215
Chuck Leverce5b3712017-12-14 20:57:47 -0500216 /* Add room for frwr register and invalidate WRs.
217 * 1. FRWR reg WR for head
218 * 2. FRWR invalidate WR for head
219 * 3. N FRWR reg WRs for pagelist
220 * 4. N FRWR invalidate WRs for pagelist
221 * 5. FRWR reg WR for tail
222 * 6. FRWR invalidate WR for tail
Chuck Lever3968cb52015-03-30 14:35:26 -0400223 * 7. The RDMA_SEND WR
224 */
225 depth = 7;
226
Chuck Leverce5b3712017-12-14 20:57:47 -0500227 /* Calculate N if the device max FRWR depth is smaller than
Chuck Lever3968cb52015-03-30 14:35:26 -0400228 * RPCRDMA_MAX_DATA_SEGS.
229 */
Chuck Lever93aa8e02020-02-21 17:00:54 -0500230 if (ep->re_max_fr_depth < RPCRDMA_MAX_DATA_SEGS) {
231 delta = RPCRDMA_MAX_DATA_SEGS - ep->re_max_fr_depth;
Chuck Lever3968cb52015-03-30 14:35:26 -0400232 do {
Chuck Leverce5b3712017-12-14 20:57:47 -0500233 depth += 2; /* FRWR reg + invalidate */
Chuck Lever93aa8e02020-02-21 17:00:54 -0500234 delta -= ep->re_max_fr_depth;
Chuck Lever3968cb52015-03-30 14:35:26 -0400235 } while (delta > 0);
236 }
237
Chuck Lever25868e62020-01-03 11:56:48 -0500238 max_qp_wr = attrs->max_qp_wr;
Chuck Lever914fcad2018-05-04 15:34:48 -0400239 max_qp_wr -= RPCRDMA_BACKWARD_WRS;
240 max_qp_wr -= 1;
241 if (max_qp_wr < RPCRDMA_MIN_SLOT_TABLE)
242 return -ENOMEM;
Chuck Lever93aa8e02020-02-21 17:00:54 -0500243 if (ep->re_max_requests > max_qp_wr)
244 ep->re_max_requests = max_qp_wr;
245 ep->re_attr.cap.max_send_wr = ep->re_max_requests * depth;
246 if (ep->re_attr.cap.max_send_wr > max_qp_wr) {
247 ep->re_max_requests = max_qp_wr / depth;
248 if (!ep->re_max_requests)
Chuck Lever25868e62020-01-03 11:56:48 -0500249 return -ENOMEM;
Chuck Lever93aa8e02020-02-21 17:00:54 -0500250 ep->re_attr.cap.max_send_wr = ep->re_max_requests * depth;
Chuck Lever3968cb52015-03-30 14:35:26 -0400251 }
Chuck Lever93aa8e02020-02-21 17:00:54 -0500252 ep->re_attr.cap.max_send_wr += RPCRDMA_BACKWARD_WRS;
253 ep->re_attr.cap.max_send_wr += 1; /* for ib_drain_sq */
254 ep->re_attr.cap.max_recv_wr = ep->re_max_requests;
255 ep->re_attr.cap.max_recv_wr += RPCRDMA_BACKWARD_WRS;
Chuck Lever32e6b682021-04-19 14:02:03 -0400256 ep->re_attr.cap.max_recv_wr += RPCRDMA_MAX_RECV_BATCH;
Chuck Lever93aa8e02020-02-21 17:00:54 -0500257 ep->re_attr.cap.max_recv_wr += 1; /* for ib_drain_rq */
Chuck Lever3968cb52015-03-30 14:35:26 -0400258
Chuck Lever93aa8e02020-02-21 17:00:54 -0500259 ep->re_max_rdma_segs =
260 DIV_ROUND_UP(RPCRDMA_MAX_DATA_SEGS, ep->re_max_fr_depth);
Chuck Lever6946f822018-12-19 10:58:45 -0500261 /* Reply chunks require segments for head and tail buffers */
Chuck Lever93aa8e02020-02-21 17:00:54 -0500262 ep->re_max_rdma_segs += 2;
263 if (ep->re_max_rdma_segs > RPCRDMA_MAX_HDR_SEGS)
264 ep->re_max_rdma_segs = RPCRDMA_MAX_HDR_SEGS;
Chuck Lever18d065a2020-01-03 11:56:43 -0500265
266 /* Ensure the underlying device is capable of conveying the
267 * largest r/wsize NFS will ask for. This guarantees that
268 * failing over from one RDMA device to another will not
269 * break NFS I/O.
270 */
Chuck Lever93aa8e02020-02-21 17:00:54 -0500271 if ((ep->re_max_rdma_segs * ep->re_max_fr_depth) < RPCRDMA_MAX_SEGS)
Chuck Lever18d065a2020-01-03 11:56:43 -0500272 return -ENOMEM;
273
Chuck Lever3968cb52015-03-30 14:35:26 -0400274 return 0;
275}
276
Chuck Lever5f624122018-12-19 10:59:01 -0500277/**
Chuck Lever5f624122018-12-19 10:59:01 -0500278 * frwr_map - Register a memory region
279 * @r_xprt: controlling transport
280 * @seg: memory region co-ordinates
281 * @nsegs: number of segments remaining
282 * @writing: true when RDMA Write will be used
Chuck Lever0a93fbc2018-12-19 10:59:07 -0500283 * @xid: XID of RPC using the registered memory
Chuck Lever3b39f522019-08-19 18:45:37 -0400284 * @mr: MR to fill in
Chuck Lever5f624122018-12-19 10:59:01 -0500285 *
286 * Prepare a REG_MR Work Request to register a memory region
Chuck Lever9c1b4d72015-03-30 14:34:39 -0400287 * for remote access via RDMA READ or RDMA WRITE.
Chuck Lever5f624122018-12-19 10:59:01 -0500288 *
289 * Returns the next segment or a negative errno pointer.
Chuck Lever3b39f522019-08-19 18:45:37 -0400290 * On success, @mr is filled in.
Chuck Lever9c1b4d72015-03-30 14:34:39 -0400291 */
Chuck Lever5f624122018-12-19 10:59:01 -0500292struct rpcrdma_mr_seg *frwr_map(struct rpcrdma_xprt *r_xprt,
293 struct rpcrdma_mr_seg *seg,
Chuck Leverec482cc2019-02-11 11:23:44 -0500294 int nsegs, bool writing, __be32 xid,
Chuck Lever3b39f522019-08-19 18:45:37 -0400295 struct rpcrdma_mr *mr)
Chuck Lever9c1b4d72015-03-30 14:34:39 -0400296{
Chuck Levere28ce902020-02-21 17:01:05 -0500297 struct rpcrdma_ep *ep = r_xprt->rx_ep;
Chuck Lever3cf4e162015-12-16 17:22:31 -0500298 struct ib_reg_wr *reg_wr;
Chuck Leverca1c6712020-02-12 11:12:30 -0500299 int i, n, dma_nents;
Chuck Lever3b39f522019-08-19 18:45:37 -0400300 struct ib_mr *ibmr;
Chuck Lever9c1b4d72015-03-30 14:34:39 -0400301 u8 key;
Chuck Lever9c1b4d72015-03-30 14:34:39 -0400302
Chuck Lever93aa8e02020-02-21 17:00:54 -0500303 if (nsegs > ep->re_max_fr_depth)
304 nsegs = ep->re_max_fr_depth;
Sagi Grimberg4143f342015-10-13 19:11:35 +0300305 for (i = 0; i < nsegs;) {
Chuck Lever67b16622021-02-04 11:59:13 -0500306 sg_set_page(&mr->mr_sg[i], seg->mr_page,
307 seg->mr_len, seg->mr_offset);
Sagi Grimberg4143f342015-10-13 19:11:35 +0300308
Chuck Lever9c1b4d72015-03-30 14:34:39 -0400309 ++seg;
310 ++i;
Chuck Lever93aa8e02020-02-21 17:00:54 -0500311 if (ep->re_mrtype == IB_MR_TYPE_SG_GAPS)
Chuck Lever5e9fc6a2016-11-29 10:52:24 -0500312 continue;
Chuck Lever67b16622021-02-04 11:59:13 -0500313 if ((i < nsegs && seg->mr_offset) ||
Chuck Lever9c1b4d72015-03-30 14:34:39 -0400314 offset_in_page((seg-1)->mr_offset + (seg-1)->mr_len))
315 break;
316 }
Chuck Lever96cedde2017-12-14 20:57:55 -0500317 mr->mr_dir = rpcrdma_data_dir(writing);
Chuck Leverca1c6712020-02-12 11:12:30 -0500318 mr->mr_nents = i;
Chuck Lever9c1b4d72015-03-30 14:34:39 -0400319
Chuck Lever93aa8e02020-02-21 17:00:54 -0500320 dma_nents = ib_dma_map_sg(ep->re_id->device, mr->mr_sg, mr->mr_nents,
Chuck Leverca1c6712020-02-12 11:12:30 -0500321 mr->mr_dir);
322 if (!dma_nents)
Chuck Lever564471d2016-06-29 13:52:21 -0400323 goto out_dmamap_err;
Chuck Lever7a03aeb62020-11-09 14:40:19 -0500324 mr->mr_device = ep->re_id->device;
Sagi Grimberg4143f342015-10-13 19:11:35 +0300325
Chuck Lever13bcf7e2021-04-19 14:04:21 -0400326 ibmr = mr->mr_ibmr;
Chuck Leverca1c6712020-02-12 11:12:30 -0500327 n = ib_map_mr_sg(ibmr, mr->mr_sg, dma_nents, NULL, PAGE_SIZE);
328 if (n != dma_nents)
Chuck Lever564471d2016-06-29 13:52:21 -0400329 goto out_mapmr_err;
Sagi Grimberg4143f342015-10-13 19:11:35 +0300330
Chuck Lever0a93fbc2018-12-19 10:59:07 -0500331 ibmr->iova &= 0x00000000ffffffff;
Chuck Leverec482cc2019-02-11 11:23:44 -0500332 ibmr->iova |= ((u64)be32_to_cpu(xid)) << 32;
Chuck Lever96cedde2017-12-14 20:57:55 -0500333 key = (u8)(ibmr->rkey & 0x000000FF);
334 ib_update_fast_reg_key(ibmr, ++key);
Sagi Grimberg4143f342015-10-13 19:11:35 +0300335
Chuck Leverdcff9ed2021-04-19 14:04:15 -0400336 reg_wr = &mr->mr_regwr;
Chuck Lever96cedde2017-12-14 20:57:55 -0500337 reg_wr->mr = ibmr;
338 reg_wr->key = ibmr->rkey;
Chuck Lever3cf4e162015-12-16 17:22:31 -0500339 reg_wr->access = writing ?
340 IB_ACCESS_REMOTE_WRITE | IB_ACCESS_LOCAL_WRITE :
341 IB_ACCESS_REMOTE_READ;
Chuck Lever9c1b4d72015-03-30 14:34:39 -0400342
Chuck Lever96cedde2017-12-14 20:57:55 -0500343 mr->mr_handle = ibmr->rkey;
344 mr->mr_length = ibmr->length;
345 mr->mr_offset = ibmr->iova;
Chuck Leverba217ec2018-12-19 10:59:55 -0500346 trace_xprtrdma_mr_map(mr);
Sagi Grimberg4143f342015-10-13 19:11:35 +0300347
Chuck Lever6748b0ca2017-08-14 15:38:30 -0400348 return seg;
Chuck Lever564471d2016-06-29 13:52:21 -0400349
350out_dmamap_err:
Chuck Lever53b2c1c2018-12-19 11:00:06 -0500351 trace_xprtrdma_frwr_sgerr(mr, i);
Chuck Lever6748b0ca2017-08-14 15:38:30 -0400352 return ERR_PTR(-EIO);
Chuck Lever564471d2016-06-29 13:52:21 -0400353
354out_mapmr_err:
Chuck Lever53b2c1c2018-12-19 11:00:06 -0500355 trace_xprtrdma_frwr_maperr(mr, n);
Chuck Lever6748b0ca2017-08-14 15:38:30 -0400356 return ERR_PTR(-EIO);
Chuck Leverf2877622018-02-28 15:30:59 -0500357}
Chuck Lever9c1b4d72015-03-30 14:34:39 -0400358
Chuck Lever5f624122018-12-19 10:59:01 -0500359/**
Chuck Lever84756892019-06-19 10:32:59 -0400360 * frwr_wc_fastreg - Invoked by RDMA provider for a flushed FastReg WC
Chuck Leverd6ccebf2020-02-21 17:00:49 -0500361 * @cq: completion queue
362 * @wc: WCE for a completed FastReg WR
Chuck Lever84756892019-06-19 10:32:59 -0400363 *
Chuck Levere4b52ca2021-04-19 14:03:12 -0400364 * Each flushed MR gets destroyed after the QP has drained.
Chuck Lever84756892019-06-19 10:32:59 -0400365 */
366static void frwr_wc_fastreg(struct ib_cq *cq, struct ib_wc *wc)
367{
368 struct ib_cqe *cqe = wc->wr_cqe;
Chuck Levere10fa962021-04-19 14:04:03 -0400369 struct rpcrdma_mr *mr = container_of(cqe, struct rpcrdma_mr, mr_cqe);
Chuck Lever84756892019-06-19 10:32:59 -0400370
371 /* WARNING: Only wr_cqe and status are reliable at this point */
Chuck Lever0a26d102021-04-19 14:03:56 -0400372 trace_xprtrdma_wc_fastreg(wc, &mr->mr_cid);
Chuck Leverd6ccebf2020-02-21 17:00:49 -0500373
Chuck Leverf423f752020-06-15 09:21:02 -0400374 rpcrdma_flush_disconnect(cq->cq_context, wc);
Chuck Lever84756892019-06-19 10:32:59 -0400375}
376
377/**
Chuck Lever97d0de82020-02-21 17:00:23 -0500378 * frwr_send - post Send WRs containing the RPC Call message
379 * @r_xprt: controlling transport instance
380 * @req: prepared RPC Call
Chuck Leverf2877622018-02-28 15:30:59 -0500381 *
Chuck Levere0f86bc2018-12-19 11:00:27 -0500382 * For FRWR, chain any FastReg WRs to the Send WR. Only a
Chuck Leverf2877622018-02-28 15:30:59 -0500383 * single ib_post_send call is needed to register memory
384 * and then post the Send WR.
Chuck Lever5f624122018-12-19 10:59:01 -0500385 *
Chuck Lever97d0de82020-02-21 17:00:23 -0500386 * Returns the return code from ib_post_send.
387 *
388 * Caller must hold the transport send lock to ensure that the
389 * pointers to the transport's rdma_cm_id and QP are stable.
Chuck Leverf2877622018-02-28 15:30:59 -0500390 */
Chuck Lever97d0de82020-02-21 17:00:23 -0500391int frwr_send(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req)
Chuck Leverf2877622018-02-28 15:30:59 -0500392{
Chuck Leverb3ce7a22021-04-19 14:03:25 -0400393 struct ib_send_wr *post_wr, *send_wr = &req->rl_wr;
Chuck Lever5ecef9c2020-11-09 14:39:31 -0500394 struct rpcrdma_ep *ep = r_xprt->rx_ep;
Chuck Leverf2877622018-02-28 15:30:59 -0500395 struct rpcrdma_mr *mr;
Chuck Leverb3ce7a22021-04-19 14:03:25 -0400396 unsigned int num_wrs;
Chuck Leverd9ae8132021-08-02 14:44:36 -0400397 int ret;
Chuck Leverf2877622018-02-28 15:30:59 -0500398
Chuck Leverb3ce7a22021-04-19 14:03:25 -0400399 num_wrs = 1;
400 post_wr = send_wr;
Chuck Leverf2877622018-02-28 15:30:59 -0500401 list_for_each_entry(mr, &req->rl_registered, mr_list) {
Chuck Lever4ddd0fc2021-04-19 14:03:31 -0400402 trace_xprtrdma_mr_fastreg(mr);
Chuck Leverf2877622018-02-28 15:30:59 -0500403
Chuck Levere10fa962021-04-19 14:04:03 -0400404 mr->mr_cqe.done = frwr_wc_fastreg;
Chuck Leverdcff9ed2021-04-19 14:04:15 -0400405 mr->mr_regwr.wr.next = post_wr;
406 mr->mr_regwr.wr.wr_cqe = &mr->mr_cqe;
407 mr->mr_regwr.wr.num_sge = 0;
408 mr->mr_regwr.wr.opcode = IB_WR_REG_MR;
409 mr->mr_regwr.wr.send_flags = 0;
410 post_wr = &mr->mr_regwr.wr;
Chuck Leverb3ce7a22021-04-19 14:03:25 -0400411 ++num_wrs;
Chuck Leverf2877622018-02-28 15:30:59 -0500412 }
413
Chuck Leverb3ce7a22021-04-19 14:03:25 -0400414 if ((kref_read(&req->rl_kref) > 1) || num_wrs > ep->re_send_count) {
415 send_wr->send_flags |= IB_SEND_SIGNALED;
416 ep->re_send_count = min_t(unsigned int, ep->re_send_batch,
417 num_wrs - ep->re_send_count);
418 } else {
419 send_wr->send_flags &= ~IB_SEND_SIGNALED;
420 ep->re_send_count -= num_wrs;
421 }
422
423 trace_xprtrdma_post_send(req);
Chuck Leverd9ae8132021-08-02 14:44:36 -0400424 ret = ib_post_send(ep->re_id->qp, post_wr, NULL);
425 if (ret)
426 trace_xprtrdma_post_send_err(r_xprt, req, ret);
427 return ret;
Chuck Lever9c1b4d72015-03-30 14:34:39 -0400428}
429
Chuck Lever5f624122018-12-19 10:59:01 -0500430/**
431 * frwr_reminv - handle a remotely invalidated mr on the @mrs list
432 * @rep: Received reply
433 * @mrs: list of MRs to check
434 *
Chuck Leverc3441612017-12-14 20:56:26 -0500435 */
Chuck Lever5f624122018-12-19 10:59:01 -0500436void frwr_reminv(struct rpcrdma_rep *rep, struct list_head *mrs)
Chuck Leverc3441612017-12-14 20:56:26 -0500437{
Chuck Lever96cedde2017-12-14 20:57:55 -0500438 struct rpcrdma_mr *mr;
Chuck Leverc3441612017-12-14 20:56:26 -0500439
Chuck Lever96cedde2017-12-14 20:57:55 -0500440 list_for_each_entry(mr, mrs, mr_list)
441 if (mr->mr_handle == rep->rr_inv_rkey) {
Chuck Lever054f1552018-05-01 11:37:14 -0400442 list_del_init(&mr->mr_list);
Chuck Lever4ddd0fc2021-04-19 14:03:31 -0400443 trace_xprtrdma_mr_reminv(mr);
Chuck Leveref2be592020-11-09 14:40:14 -0500444 frwr_mr_put(mr);
Chuck Leverc3441612017-12-14 20:56:26 -0500445 break; /* only one invalidated MR per RPC */
446 }
447}
448
Chuck Leveref2be592020-11-09 14:40:14 -0500449static void frwr_mr_done(struct ib_wc *wc, struct rpcrdma_mr *mr)
Chuck Lever84756892019-06-19 10:32:59 -0400450{
Chuck Levere4b52ca2021-04-19 14:03:12 -0400451 if (likely(wc->status == IB_WC_SUCCESS))
Chuck Leveref2be592020-11-09 14:40:14 -0500452 frwr_mr_put(mr);
Chuck Lever84756892019-06-19 10:32:59 -0400453}
454
455/**
456 * frwr_wc_localinv - Invoked by RDMA provider for a LOCAL_INV WC
Chuck Leverd6ccebf2020-02-21 17:00:49 -0500457 * @cq: completion queue
458 * @wc: WCE for a completed LocalInv WR
Chuck Lever84756892019-06-19 10:32:59 -0400459 *
460 */
461static void frwr_wc_localinv(struct ib_cq *cq, struct ib_wc *wc)
462{
463 struct ib_cqe *cqe = wc->wr_cqe;
Chuck Levere10fa962021-04-19 14:04:03 -0400464 struct rpcrdma_mr *mr = container_of(cqe, struct rpcrdma_mr, mr_cqe);
Chuck Lever84756892019-06-19 10:32:59 -0400465
466 /* WARNING: Only wr_cqe and status are reliable at this point */
Chuck Lever0a26d102021-04-19 14:03:56 -0400467 trace_xprtrdma_wc_li(wc, &mr->mr_cid);
Chuck Leveref2be592020-11-09 14:40:14 -0500468 frwr_mr_done(wc, mr);
Chuck Leverd6ccebf2020-02-21 17:00:49 -0500469
Chuck Leverf423f752020-06-15 09:21:02 -0400470 rpcrdma_flush_disconnect(cq->cq_context, wc);
Chuck Lever84756892019-06-19 10:32:59 -0400471}
472
473/**
474 * frwr_wc_localinv_wake - Invoked by RDMA provider for a LOCAL_INV WC
Chuck Leverd6ccebf2020-02-21 17:00:49 -0500475 * @cq: completion queue
476 * @wc: WCE for a completed LocalInv WR
Chuck Lever84756892019-06-19 10:32:59 -0400477 *
478 * Awaken anyone waiting for an MR to finish being fenced.
479 */
480static void frwr_wc_localinv_wake(struct ib_cq *cq, struct ib_wc *wc)
481{
482 struct ib_cqe *cqe = wc->wr_cqe;
Chuck Levere10fa962021-04-19 14:04:03 -0400483 struct rpcrdma_mr *mr = container_of(cqe, struct rpcrdma_mr, mr_cqe);
Chuck Lever84756892019-06-19 10:32:59 -0400484
485 /* WARNING: Only wr_cqe and status are reliable at this point */
Chuck Lever0a26d102021-04-19 14:03:56 -0400486 trace_xprtrdma_wc_li_wake(wc, &mr->mr_cid);
Chuck Leveref2be592020-11-09 14:40:14 -0500487 frwr_mr_done(wc, mr);
Chuck Lever9a301ca2021-04-19 14:04:09 -0400488 complete(&mr->mr_linv_done);
Chuck Leverd6ccebf2020-02-21 17:00:49 -0500489
Chuck Leverf423f752020-06-15 09:21:02 -0400490 rpcrdma_flush_disconnect(cq->cq_context, wc);
Chuck Lever84756892019-06-19 10:32:59 -0400491}
492
Chuck Lever5f624122018-12-19 10:59:01 -0500493/**
494 * frwr_unmap_sync - invalidate memory regions that were registered for @req
Chuck Lever84756892019-06-19 10:32:59 -0400495 * @r_xprt: controlling transport instance
496 * @req: rpcrdma_req with a non-empty list of MRs to process
Chuck Leverc9918ff2015-12-16 17:22:47 -0500497 *
Chuck Lever84756892019-06-19 10:32:59 -0400498 * Sleeps until it is safe for the host CPU to access the previously mapped
Chuck Leverd8099fe2019-06-19 10:33:10 -0400499 * memory regions. This guarantees that registered MRs are properly fenced
500 * from the server before the RPC consumer accesses the data in them. It
501 * also ensures proper Send flow control: waking the next RPC waits until
502 * this RPC has relinquished all its Send Queue entries.
Chuck Leverc9918ff2015-12-16 17:22:47 -0500503 */
Chuck Lever84756892019-06-19 10:32:59 -0400504void frwr_unmap_sync(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req)
Chuck Leverc9918ff2015-12-16 17:22:47 -0500505{
Bart Van Assched34ac5c2018-07-18 09:25:32 -0700506 struct ib_send_wr *first, **prev, *last;
Chuck Lever5ecef9c2020-11-09 14:39:31 -0500507 struct rpcrdma_ep *ep = r_xprt->rx_ep;
Bart Van Assched34ac5c2018-07-18 09:25:32 -0700508 const struct ib_send_wr *bad_wr;
Chuck Lever96cedde2017-12-14 20:57:55 -0500509 struct rpcrdma_mr *mr;
Chuck Lever84756892019-06-19 10:32:59 -0400510 int rc;
Chuck Leverc9918ff2015-12-16 17:22:47 -0500511
Chuck Lever451d26e2017-06-08 11:52:04 -0400512 /* ORDER: Invalidate all of the MRs first
Chuck Leverc9918ff2015-12-16 17:22:47 -0500513 *
514 * Chain the LOCAL_INV Work Requests and post them with
515 * a single ib_post_send() call.
516 */
Chuck Levera100fda2016-11-29 10:52:57 -0500517 prev = &first;
Chuck Lever265a38d2019-08-19 18:44:04 -0400518 while ((mr = rpcrdma_mr_pop(&req->rl_registered))) {
Chuck Lever84756892019-06-19 10:32:59 -0400519
520 trace_xprtrdma_mr_localinv(mr);
521 r_xprt->rx_stats.local_inv_needed++;
Chuck Leverc8b920b2016-09-15 10:57:16 -0400522
Chuck Leverdcff9ed2021-04-19 14:04:15 -0400523 last = &mr->mr_invwr;
Chuck Lever84756892019-06-19 10:32:59 -0400524 last->next = NULL;
Chuck Levere10fa962021-04-19 14:04:03 -0400525 last->wr_cqe = &mr->mr_cqe;
Chuck Lever84756892019-06-19 10:32:59 -0400526 last->sg_list = NULL;
527 last->num_sge = 0;
Chuck Levera100fda2016-11-29 10:52:57 -0500528 last->opcode = IB_WR_LOCAL_INV;
Chuck Lever84756892019-06-19 10:32:59 -0400529 last->send_flags = IB_SEND_SIGNALED;
Chuck Lever96cedde2017-12-14 20:57:55 -0500530 last->ex.invalidate_rkey = mr->mr_handle;
Chuck Leverc9918ff2015-12-16 17:22:47 -0500531
Chuck Levere10fa962021-04-19 14:04:03 -0400532 last->wr_cqe->done = frwr_wc_localinv;
533
Chuck Levera100fda2016-11-29 10:52:57 -0500534 *prev = last;
535 prev = &last->next;
Chuck Leverc9918ff2015-12-16 17:22:47 -0500536 }
Chuck Lever9e895cd2021-05-01 15:38:02 -0400537 mr = container_of(last, struct rpcrdma_mr, mr_invwr);
Chuck Leverc9918ff2015-12-16 17:22:47 -0500538
539 /* Strong send queue ordering guarantees that when the
540 * last WR in the chain completes, all WRs in the chain
541 * are complete.
542 */
Chuck Levere10fa962021-04-19 14:04:03 -0400543 last->wr_cqe->done = frwr_wc_localinv_wake;
Chuck Lever9a301ca2021-04-19 14:04:09 -0400544 reinit_completion(&mr->mr_linv_done);
Chuck Lever8d38de62016-11-29 10:52:16 -0500545
Chuck Leverc9918ff2015-12-16 17:22:47 -0500546 /* Transport disconnect drains the receive CQ before it
547 * replaces the QP. The RPC reply handler won't call us
Chuck Lever93aa8e02020-02-21 17:00:54 -0500548 * unless re_id->qp is a valid pointer.
Chuck Leverc9918ff2015-12-16 17:22:47 -0500549 */
Chuck Lever8d754832017-06-08 11:52:28 -0400550 bad_wr = NULL;
Chuck Lever5ecef9c2020-11-09 14:39:31 -0500551 rc = ib_post_send(ep->re_id->qp, first, &bad_wr);
Chuck Lever84756892019-06-19 10:32:59 -0400552
553 /* The final LOCAL_INV WR in the chain is supposed to
554 * do the wake. If it was never posted, the wake will
555 * not happen, so don't wait in that case.
556 */
Chuck Lever8d754832017-06-08 11:52:28 -0400557 if (bad_wr != first)
Chuck Lever9a301ca2021-04-19 14:04:09 -0400558 wait_for_completion(&mr->mr_linv_done);
Chuck Lever84756892019-06-19 10:32:59 -0400559 if (!rc)
560 return;
Chuck Leverc9918ff2015-12-16 17:22:47 -0500561
Chuck Levere4b52ca2021-04-19 14:03:12 -0400562 /* On error, the MRs get destroyed once the QP has drained. */
Chuck Lever36a55ed2020-11-09 14:39:37 -0500563 trace_xprtrdma_post_linv_err(req, rc);
Chuck Lever11431292021-08-02 14:44:17 -0400564
565 /* Force a connection loss to ensure complete recovery.
566 */
567 rpcrdma_force_disconnect(ep);
Chuck Leverc9918ff2015-12-16 17:22:47 -0500568}
Chuck Leverd8099fe2019-06-19 10:33:10 -0400569
570/**
571 * frwr_wc_localinv_done - Invoked by RDMA provider for a signaled LOCAL_INV WC
Chuck Leverd6ccebf2020-02-21 17:00:49 -0500572 * @cq: completion queue
573 * @wc: WCE for a completed LocalInv WR
Chuck Leverd8099fe2019-06-19 10:33:10 -0400574 *
575 */
576static void frwr_wc_localinv_done(struct ib_cq *cq, struct ib_wc *wc)
577{
578 struct ib_cqe *cqe = wc->wr_cqe;
Chuck Levere10fa962021-04-19 14:04:03 -0400579 struct rpcrdma_mr *mr = container_of(cqe, struct rpcrdma_mr, mr_cqe);
Chuck Lever44438ad2021-04-19 14:03:06 -0400580 struct rpcrdma_rep *rep;
Chuck Leverd8099fe2019-06-19 10:33:10 -0400581
582 /* WARNING: Only wr_cqe and status are reliable at this point */
Chuck Lever0a26d102021-04-19 14:03:56 -0400583 trace_xprtrdma_wc_li_done(wc, &mr->mr_cid);
Chuck Lever6dc6ec92019-08-19 18:47:10 -0400584
Chuck Lever44438ad2021-04-19 14:03:06 -0400585 /* Ensure that @rep is generated before the MR is released */
586 rep = mr->mr_req->rl_reply;
Chuck Lever6dc6ec92019-08-19 18:47:10 -0400587 smp_rmb();
Chuck Lever44438ad2021-04-19 14:03:06 -0400588
Chuck Lever8a053432021-04-19 14:03:19 -0400589 if (wc->status != IB_WC_SUCCESS) {
590 if (rep)
591 rpcrdma_unpin_rqst(rep);
592 rpcrdma_flush_disconnect(cq->cq_context, wc);
593 return;
594 }
595 frwr_mr_put(mr);
Chuck Lever6dc6ec92019-08-19 18:47:10 -0400596 rpcrdma_complete_rqst(rep);
Chuck Leverd8099fe2019-06-19 10:33:10 -0400597}
598
599/**
600 * frwr_unmap_async - invalidate memory regions that were registered for @req
601 * @r_xprt: controlling transport instance
602 * @req: rpcrdma_req with a non-empty list of MRs to process
603 *
604 * This guarantees that registered MRs are properly fenced from the
605 * server before the RPC consumer accesses the data in them. It also
606 * ensures proper Send flow control: waking the next RPC waits until
607 * this RPC has relinquished all its Send Queue entries.
608 */
609void frwr_unmap_async(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req)
610{
611 struct ib_send_wr *first, *last, **prev;
Chuck Lever5ecef9c2020-11-09 14:39:31 -0500612 struct rpcrdma_ep *ep = r_xprt->rx_ep;
Chuck Leverd8099fe2019-06-19 10:33:10 -0400613 struct rpcrdma_mr *mr;
614 int rc;
615
616 /* Chain the LOCAL_INV Work Requests and post them with
617 * a single ib_post_send() call.
618 */
Chuck Leverd8099fe2019-06-19 10:33:10 -0400619 prev = &first;
Chuck Lever265a38d2019-08-19 18:44:04 -0400620 while ((mr = rpcrdma_mr_pop(&req->rl_registered))) {
Chuck Leverd8099fe2019-06-19 10:33:10 -0400621
622 trace_xprtrdma_mr_localinv(mr);
623 r_xprt->rx_stats.local_inv_needed++;
624
Chuck Leverdcff9ed2021-04-19 14:04:15 -0400625 last = &mr->mr_invwr;
Chuck Leverd8099fe2019-06-19 10:33:10 -0400626 last->next = NULL;
Chuck Levere10fa962021-04-19 14:04:03 -0400627 last->wr_cqe = &mr->mr_cqe;
Chuck Leverd8099fe2019-06-19 10:33:10 -0400628 last->sg_list = NULL;
629 last->num_sge = 0;
630 last->opcode = IB_WR_LOCAL_INV;
631 last->send_flags = IB_SEND_SIGNALED;
632 last->ex.invalidate_rkey = mr->mr_handle;
633
Chuck Levere10fa962021-04-19 14:04:03 -0400634 last->wr_cqe->done = frwr_wc_localinv;
635
Chuck Leverd8099fe2019-06-19 10:33:10 -0400636 *prev = last;
637 prev = &last->next;
638 }
639
640 /* Strong send queue ordering guarantees that when the
641 * last WR in the chain completes, all WRs in the chain
642 * are complete. The last completion will wake up the
643 * RPC waiter.
644 */
Chuck Levere10fa962021-04-19 14:04:03 -0400645 last->wr_cqe->done = frwr_wc_localinv_done;
Chuck Leverd8099fe2019-06-19 10:33:10 -0400646
647 /* Transport disconnect drains the receive CQ before it
648 * replaces the QP. The RPC reply handler won't call us
Chuck Lever93aa8e02020-02-21 17:00:54 -0500649 * unless re_id->qp is a valid pointer.
Chuck Leverd8099fe2019-06-19 10:33:10 -0400650 */
Chuck Levere4b52ca2021-04-19 14:03:12 -0400651 rc = ib_post_send(ep->re_id->qp, first, NULL);
Chuck Leverd8099fe2019-06-19 10:33:10 -0400652 if (!rc)
653 return;
654
Chuck Levere4b52ca2021-04-19 14:03:12 -0400655 /* On error, the MRs get destroyed once the QP has drained. */
Chuck Lever36a55ed2020-11-09 14:39:37 -0500656 trace_xprtrdma_post_linv_err(req, rc);
Chuck Leverd8099fe2019-06-19 10:33:10 -0400657
658 /* The final LOCAL_INV WR in the chain is supposed to
Chuck Lever8a053432021-04-19 14:03:19 -0400659 * do the wake. If it was never posted, the wake does
660 * not happen. Unpin the rqst in preparation for its
661 * retransmission.
Chuck Leverd8099fe2019-06-19 10:33:10 -0400662 */
Chuck Lever8a053432021-04-19 14:03:19 -0400663 rpcrdma_unpin_rqst(req->rl_reply);
Chuck Lever11431292021-08-02 14:44:17 -0400664
665 /* Force a connection loss to ensure complete recovery.
666 */
667 rpcrdma_force_disconnect(ep);
Chuck Leverd8099fe2019-06-19 10:33:10 -0400668}