hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/infiniband/hw/hfi1/ud.c
....@@ -1,5 +1,5 @@
11 /*
2
- * Copyright(c) 2015 - 2018 Intel Corporation.
2
+ * Copyright(c) 2015 - 2019 Intel Corporation.
33 *
44 * This file is provided under a dual BSD/GPLv2 license. When using or
55 * redistributing this file, you may do so under either license.
....@@ -87,7 +87,7 @@
8787 rcu_read_lock();
8888
8989 qp = rvt_lookup_qpn(ib_to_rvt(sqp->ibqp.device), &ibp->rvp,
90
- swqe->ud_wr.remote_qpn);
90
+ rvt_get_swqe_remote_qpn(swqe));
9191 if (!qp) {
9292 ibp->rvp.n_pkt_drops++;
9393 rcu_read_unlock();
....@@ -105,7 +105,7 @@
105105 goto drop;
106106 }
107107
108
- ah_attr = &ibah_to_rvtah(swqe->ud_wr.ah)->attr;
108
+ ah_attr = rvt_get_swqe_ah_attr(swqe);
109109 ppd = ppd_from_ibp(ibp);
110110
111111 if (qp->ibqp.qp_num > 1) {
....@@ -135,8 +135,8 @@
135135 if (qp->ibqp.qp_num) {
136136 u32 qkey;
137137
138
- qkey = (int)swqe->ud_wr.remote_qkey < 0 ?
139
- sqp->qkey : swqe->ud_wr.remote_qkey;
138
+ qkey = (int)rvt_get_swqe_remote_qkey(swqe) < 0 ?
139
+ sqp->qkey : rvt_get_swqe_remote_qkey(swqe);
140140 if (unlikely(qkey != qp->qkey))
141141 goto drop; /* silently drop per IBTA spec */
142142 }
....@@ -211,8 +211,8 @@
211211 }
212212
213213 hfi1_make_grh(ibp, &grh, &grd, 0, 0);
214
- hfi1_copy_sge(&qp->r_sge, &grh,
215
- sizeof(grh), true, false);
214
+ rvt_copy_sge(qp, &qp->r_sge, &grh,
215
+ sizeof(grh), true, false);
216216 wc.wc_flags |= IB_WC_GRH;
217217 } else {
218218 rvt_skip_sge(&qp->r_sge, sizeof(struct ib_grh), true);
....@@ -222,31 +222,11 @@
222222 ssge.num_sge = swqe->wr.num_sge;
223223 sge = &ssge.sge;
224224 while (length) {
225
- u32 len = sge->length;
225
+ u32 len = rvt_get_sge_length(sge, length);
226226
227
- if (len > length)
228
- len = length;
229
- if (len > sge->sge_length)
230
- len = sge->sge_length;
231227 WARN_ON_ONCE(len == 0);
232
- hfi1_copy_sge(&qp->r_sge, sge->vaddr, len, true, false);
233
- sge->vaddr += len;
234
- sge->length -= len;
235
- sge->sge_length -= len;
236
- if (sge->sge_length == 0) {
237
- if (--ssge.num_sge)
238
- *sge = *ssge.sg_list++;
239
- } else if (sge->length == 0 && sge->mr->lkey) {
240
- if (++sge->n >= RVT_SEGSZ) {
241
- if (++sge->m >= sge->mr->mapsz)
242
- break;
243
- sge->n = 0;
244
- }
245
- sge->vaddr =
246
- sge->mr->map[sge->m]->segs[sge->n].vaddr;
247
- sge->length =
248
- sge->mr->map[sge->m]->segs[sge->n].length;
249
- }
228
+ rvt_copy_sge(qp, &qp->r_sge, sge->vaddr, len, true, false);
229
+ rvt_update_sge(&ssge, len, false);
250230 length -= len;
251231 }
252232 rvt_put_ss(&qp->r_sge);
....@@ -260,7 +240,7 @@
260240 if (qp->ibqp.qp_type == IB_QPT_GSI || qp->ibqp.qp_type == IB_QPT_SMI) {
261241 if (sqp->ibqp.qp_type == IB_QPT_GSI ||
262242 sqp->ibqp.qp_type == IB_QPT_SMI)
263
- wc.pkey_index = swqe->ud_wr.pkey_index;
243
+ wc.pkey_index = rvt_get_swqe_pkey_index(swqe);
264244 else
265245 wc.pkey_index = sqp->s_pkey_index;
266246 } else {
....@@ -275,8 +255,7 @@
275255 wc.dlid_path_bits = rdma_ah_get_dlid(ah_attr) & ((1 << ppd->lmc) - 1);
276256 wc.port_num = qp->port_num;
277257 /* Signal completion event if the solicited bit is set. */
278
- rvt_cq_enter(ibcq_to_rvtcq(qp->ibqp.recv_cq), &wc,
279
- swqe->wr.send_flags & IB_SEND_SOLICITED);
258
+ rvt_recv_cq(qp, &wc, swqe->wr.send_flags & IB_SEND_SOLICITED);
280259 ibp->rvp.n_loop_pkts++;
281260 bail_unlock:
282261 spin_unlock_irqrestore(&qp->r_lock, flags);
....@@ -303,20 +282,21 @@
303282 bth0 |= IB_BTH_SOLICITED;
304283 bth0 |= extra_bytes << 20;
305284 if (qp->ibqp.qp_type == IB_QPT_GSI || qp->ibqp.qp_type == IB_QPT_SMI)
306
- *pkey = hfi1_get_pkey(ibp, wqe->ud_wr.pkey_index);
285
+ *pkey = hfi1_get_pkey(ibp, rvt_get_swqe_pkey_index(wqe));
307286 else
308287 *pkey = hfi1_get_pkey(ibp, qp->s_pkey_index);
309288 if (!bypass)
310289 bth0 |= *pkey;
311290 ohdr->bth[0] = cpu_to_be32(bth0);
312
- ohdr->bth[1] = cpu_to_be32(wqe->ud_wr.remote_qpn);
291
+ ohdr->bth[1] = cpu_to_be32(rvt_get_swqe_remote_qpn(wqe));
313292 ohdr->bth[2] = cpu_to_be32(mask_psn(wqe->psn));
314293 /*
315294 * Qkeys with the high order bit set mean use the
316295 * qkey from the QP context instead of the WR (see 10.2.5).
317296 */
318
- ohdr->u.ud.deth[0] = cpu_to_be32((int)wqe->ud_wr.remote_qkey < 0 ?
319
- qp->qkey : wqe->ud_wr.remote_qkey);
297
+ ohdr->u.ud.deth[0] =
298
+ cpu_to_be32((int)rvt_get_swqe_remote_qkey(wqe) < 0 ? qp->qkey :
299
+ rvt_get_swqe_remote_qkey(wqe));
320300 ohdr->u.ud.deth[1] = cpu_to_be32(qp->ibqp.qp_num);
321301 }
322302
....@@ -336,7 +316,7 @@
336316
337317 ibp = to_iport(qp->ibqp.device, qp->port_num);
338318 ppd = ppd_from_ibp(ibp);
339
- ah_attr = &ibah_to_rvtah(wqe->ud_wr.ah)->attr;
319
+ ah_attr = rvt_get_swqe_ah_attr(wqe);
340320
341321 extra_bytes = -wqe->length & 3;
342322 nwords = ((wqe->length + extra_bytes) >> 2) + SIZE_OF_CRC;
....@@ -400,7 +380,7 @@
400380 struct hfi1_pportdata *ppd;
401381 struct hfi1_ibport *ibp;
402382 u32 dlid, slid, nwords, extra_bytes;
403
- u32 dest_qp = wqe->ud_wr.remote_qpn;
383
+ u32 dest_qp = rvt_get_swqe_remote_qpn(wqe);
404384 u32 src_qp = qp->ibqp.qp_num;
405385 u16 len, pkey;
406386 u8 l4, sc5;
....@@ -408,7 +388,7 @@
408388
409389 ibp = to_iport(qp->ibqp.device, qp->port_num);
410390 ppd = ppd_from_ibp(ibp);
411
- ah_attr = &ibah_to_rvtah(wqe->ud_wr.ah)->attr;
391
+ ah_attr = rvt_get_swqe_ah_attr(wqe);
412392
413393 /*
414394 * Build 16B Management Packet if either the destination
....@@ -470,7 +450,7 @@
470450
471451 if (is_mgmt) {
472452 l4 = OPA_16B_L4_FM;
473
- pkey = hfi1_get_pkey(ibp, wqe->ud_wr.pkey_index);
453
+ pkey = hfi1_get_pkey(ibp, rvt_get_swqe_pkey_index(wqe));
474454 hfi1_16B_set_qpn(&ps->s_txreq->phdr.hdr.opah.u.mgmt,
475455 dest_qp, src_qp);
476456 } else {
....@@ -519,7 +499,7 @@
519499 goto bail;
520500 }
521501 wqe = rvt_get_swqe_ptr(qp, qp->s_last);
522
- hfi1_send_complete(qp, wqe, IB_WC_WR_FLUSH_ERR);
502
+ rvt_send_complete(qp, wqe, IB_WC_WR_FLUSH_ERR);
523503 goto done_free_tx;
524504 }
525505
....@@ -535,7 +515,7 @@
535515 /* Construct the header. */
536516 ibp = to_iport(qp->ibqp.device, qp->port_num);
537517 ppd = ppd_from_ibp(ibp);
538
- ah_attr = &ibah_to_rvtah(wqe->ud_wr.ah)->attr;
518
+ ah_attr = rvt_get_swqe_ah_attr(wqe);
539519 priv->hdr_type = hfi1_get_hdr_type(ppd->lid, ah_attr);
540520 if ((!hfi1_check_mcast(rdma_ah_get_dlid(ah_attr))) ||
541521 (rdma_ah_get_dlid(ah_attr) == be32_to_cpu(OPA_LID_PERMISSIVE))) {
....@@ -561,7 +541,7 @@
561541 ud_loopback(qp, wqe);
562542 spin_lock_irqsave(&qp->s_lock, tflags);
563543 ps->flags = tflags;
564
- hfi1_send_complete(qp, wqe, IB_WC_SUCCESS);
544
+ rvt_send_complete(qp, wqe, IB_WC_SUCCESS);
565545 goto done_free_tx;
566546 }
567547 }
....@@ -1025,8 +1005,8 @@
10251005 goto drop;
10261006 }
10271007 if (packet->grh) {
1028
- hfi1_copy_sge(&qp->r_sge, packet->grh,
1029
- sizeof(struct ib_grh), true, false);
1008
+ rvt_copy_sge(qp, &qp->r_sge, packet->grh,
1009
+ sizeof(struct ib_grh), true, false);
10301010 wc.wc_flags |= IB_WC_GRH;
10311011 } else if (packet->etype == RHF_RCV_TYPE_BYPASS) {
10321012 struct ib_grh grh;
....@@ -1036,14 +1016,14 @@
10361016 * out when creating 16B, add back the GRH here.
10371017 */
10381018 hfi1_make_ext_grh(packet, &grh, slid, dlid);
1039
- hfi1_copy_sge(&qp->r_sge, &grh,
1040
- sizeof(struct ib_grh), true, false);
1019
+ rvt_copy_sge(qp, &qp->r_sge, &grh,
1020
+ sizeof(struct ib_grh), true, false);
10411021 wc.wc_flags |= IB_WC_GRH;
10421022 } else {
10431023 rvt_skip_sge(&qp->r_sge, sizeof(struct ib_grh), true);
10441024 }
1045
- hfi1_copy_sge(&qp->r_sge, data, wc.byte_len - sizeof(struct ib_grh),
1046
- true, false);
1025
+ rvt_copy_sge(qp, &qp->r_sge, data, wc.byte_len - sizeof(struct ib_grh),
1026
+ true, false);
10471027 rvt_put_ss(&qp->r_sge);
10481028 if (!test_and_clear_bit(RVT_R_WRID_VALID, &qp->r_aflags))
10491029 return;
....@@ -1081,7 +1061,7 @@
10811061 dlid & ((1 << ppd_from_ibp(ibp)->lmc) - 1);
10821062 wc.port_num = qp->port_num;
10831063 /* Signal completion event if the solicited bit is set. */
1084
- rvt_cq_enter(ibcq_to_rvtcq(qp->ibqp.recv_cq), &wc, solicited);
1064
+ rvt_recv_cq(qp, &wc, solicited);
10851065 return;
10861066
10871067 drop: