]> git.proxmox.com Git - mirror_ubuntu-kernels.git/blob - drivers/infiniband/hw/qib/qib_ud.c
Merge branches 'for-5.1/upstream-fixes', 'for-5.2/core', 'for-5.2/ish', 'for-5.2...
[mirror_ubuntu-kernels.git] / drivers / infiniband / hw / qib / qib_ud.c
1 /*
2 * Copyright (c) 2006, 2007, 2008, 2009 QLogic Corporation. All rights reserved.
3 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved.
4 *
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the
9 * OpenIB.org BSD license below:
10 *
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
13 * conditions are met:
14 *
15 * - Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer.
18 *
19 * - Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials
22 * provided with the distribution.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE.
32 */
33
34 #include <rdma/ib_smi.h>
35 #include <rdma/ib_verbs.h>
36
37 #include "qib.h"
38 #include "qib_mad.h"
39
40 /**
41 * qib_ud_loopback - handle send on loopback QPs
42 * @sqp: the sending QP
43 * @swqe: the send work request
44 *
45 * This is called from qib_make_ud_req() to forward a WQE addressed
46 * to the same HCA.
47 * Note that the receive interrupt handler may be calling qib_ud_rcv()
48 * while this is being called.
49 */
50 static void qib_ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe)
51 {
52 struct qib_ibport *ibp = to_iport(sqp->ibqp.device, sqp->port_num);
53 struct qib_pportdata *ppd = ppd_from_ibp(ibp);
54 struct qib_devdata *dd = ppd->dd;
55 struct rvt_dev_info *rdi = &dd->verbs_dev.rdi;
56 struct rvt_qp *qp;
57 struct rdma_ah_attr *ah_attr;
58 unsigned long flags;
59 struct rvt_sge_state ssge;
60 struct rvt_sge *sge;
61 struct ib_wc wc;
62 u32 length;
63 enum ib_qp_type sqptype, dqptype;
64
65 rcu_read_lock();
66 qp = rvt_lookup_qpn(rdi, &ibp->rvp, swqe->ud_wr.remote_qpn);
67 if (!qp) {
68 ibp->rvp.n_pkt_drops++;
69 goto drop;
70 }
71
72 sqptype = sqp->ibqp.qp_type == IB_QPT_GSI ?
73 IB_QPT_UD : sqp->ibqp.qp_type;
74 dqptype = qp->ibqp.qp_type == IB_QPT_GSI ?
75 IB_QPT_UD : qp->ibqp.qp_type;
76
77 if (dqptype != sqptype ||
78 !(ib_rvt_state_ops[qp->state] & RVT_PROCESS_RECV_OK)) {
79 ibp->rvp.n_pkt_drops++;
80 goto drop;
81 }
82
83 ah_attr = &ibah_to_rvtah(swqe->ud_wr.ah)->attr;
84 ppd = ppd_from_ibp(ibp);
85
86 if (qp->ibqp.qp_num > 1) {
87 u16 pkey1;
88 u16 pkey2;
89 u16 lid;
90
91 pkey1 = qib_get_pkey(ibp, sqp->s_pkey_index);
92 pkey2 = qib_get_pkey(ibp, qp->s_pkey_index);
93 if (unlikely(!qib_pkey_ok(pkey1, pkey2))) {
94 lid = ppd->lid | (rdma_ah_get_path_bits(ah_attr) &
95 ((1 << ppd->lmc) - 1));
96 qib_bad_pkey(ibp, pkey1,
97 rdma_ah_get_sl(ah_attr),
98 sqp->ibqp.qp_num, qp->ibqp.qp_num,
99 cpu_to_be16(lid),
100 cpu_to_be16(rdma_ah_get_dlid(ah_attr)));
101 goto drop;
102 }
103 }
104
105 /*
106 * Check that the qkey matches (except for QP0, see 9.6.1.4.1).
107 * Qkeys with the high order bit set mean use the
108 * qkey from the QP context instead of the WR (see 10.2.5).
109 */
110 if (qp->ibqp.qp_num) {
111 u32 qkey;
112
113 qkey = (int)swqe->ud_wr.remote_qkey < 0 ?
114 sqp->qkey : swqe->ud_wr.remote_qkey;
115 if (unlikely(qkey != qp->qkey))
116 goto drop;
117 }
118
119 /*
120 * A GRH is expected to precede the data even if not
121 * present on the wire.
122 */
123 length = swqe->length;
124 memset(&wc, 0, sizeof(wc));
125 wc.byte_len = length + sizeof(struct ib_grh);
126
127 if (swqe->wr.opcode == IB_WR_SEND_WITH_IMM) {
128 wc.wc_flags = IB_WC_WITH_IMM;
129 wc.ex.imm_data = swqe->wr.ex.imm_data;
130 }
131
132 spin_lock_irqsave(&qp->r_lock, flags);
133
134 /*
135 * Get the next work request entry to find where to put the data.
136 */
137 if (qp->r_flags & RVT_R_REUSE_SGE)
138 qp->r_flags &= ~RVT_R_REUSE_SGE;
139 else {
140 int ret;
141
142 ret = rvt_get_rwqe(qp, false);
143 if (ret < 0) {
144 rvt_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
145 goto bail_unlock;
146 }
147 if (!ret) {
148 if (qp->ibqp.qp_num == 0)
149 ibp->rvp.n_vl15_dropped++;
150 goto bail_unlock;
151 }
152 }
153 /* Silently drop packets which are too big. */
154 if (unlikely(wc.byte_len > qp->r_len)) {
155 qp->r_flags |= RVT_R_REUSE_SGE;
156 ibp->rvp.n_pkt_drops++;
157 goto bail_unlock;
158 }
159
160 if (rdma_ah_get_ah_flags(ah_attr) & IB_AH_GRH) {
161 struct ib_grh grh;
162 const struct ib_global_route *grd = rdma_ah_read_grh(ah_attr);
163
164 qib_make_grh(ibp, &grh, grd, 0, 0);
165 rvt_copy_sge(qp, &qp->r_sge, &grh,
166 sizeof(grh), true, false);
167 wc.wc_flags |= IB_WC_GRH;
168 } else
169 rvt_skip_sge(&qp->r_sge, sizeof(struct ib_grh), true);
170 ssge.sg_list = swqe->sg_list + 1;
171 ssge.sge = *swqe->sg_list;
172 ssge.num_sge = swqe->wr.num_sge;
173 sge = &ssge.sge;
174 while (length) {
175 u32 len = rvt_get_sge_length(sge, length);
176
177 rvt_copy_sge(qp, &qp->r_sge, sge->vaddr, len, true, false);
178 sge->vaddr += len;
179 sge->length -= len;
180 sge->sge_length -= len;
181 if (sge->sge_length == 0) {
182 if (--ssge.num_sge)
183 *sge = *ssge.sg_list++;
184 } else if (sge->length == 0 && sge->mr->lkey) {
185 if (++sge->n >= RVT_SEGSZ) {
186 if (++sge->m >= sge->mr->mapsz)
187 break;
188 sge->n = 0;
189 }
190 sge->vaddr =
191 sge->mr->map[sge->m]->segs[sge->n].vaddr;
192 sge->length =
193 sge->mr->map[sge->m]->segs[sge->n].length;
194 }
195 length -= len;
196 }
197 rvt_put_ss(&qp->r_sge);
198 if (!test_and_clear_bit(RVT_R_WRID_VALID, &qp->r_aflags))
199 goto bail_unlock;
200 wc.wr_id = qp->r_wr_id;
201 wc.status = IB_WC_SUCCESS;
202 wc.opcode = IB_WC_RECV;
203 wc.qp = &qp->ibqp;
204 wc.src_qp = sqp->ibqp.qp_num;
205 wc.pkey_index = qp->ibqp.qp_type == IB_QPT_GSI ?
206 swqe->ud_wr.pkey_index : 0;
207 wc.slid = ppd->lid | (rdma_ah_get_path_bits(ah_attr) &
208 ((1 << ppd->lmc) - 1));
209 wc.sl = rdma_ah_get_sl(ah_attr);
210 wc.dlid_path_bits = rdma_ah_get_dlid(ah_attr) & ((1 << ppd->lmc) - 1);
211 wc.port_num = qp->port_num;
212 /* Signal completion event if the solicited bit is set. */
213 rvt_cq_enter(ibcq_to_rvtcq(qp->ibqp.recv_cq), &wc,
214 swqe->wr.send_flags & IB_SEND_SOLICITED);
215 ibp->rvp.n_loop_pkts++;
216 bail_unlock:
217 spin_unlock_irqrestore(&qp->r_lock, flags);
218 drop:
219 rcu_read_unlock();
220 }
221
222 /**
223 * qib_make_ud_req - construct a UD request packet
224 * @qp: the QP
225 *
226 * Assumes the s_lock is held.
227 *
228 * Return 1 if constructed; otherwise, return 0.
229 */
230 int qib_make_ud_req(struct rvt_qp *qp, unsigned long *flags)
231 {
232 struct qib_qp_priv *priv = qp->priv;
233 struct ib_other_headers *ohdr;
234 struct rdma_ah_attr *ah_attr;
235 struct qib_pportdata *ppd;
236 struct qib_ibport *ibp;
237 struct rvt_swqe *wqe;
238 u32 nwords;
239 u32 extra_bytes;
240 u32 bth0;
241 u16 lrh0;
242 u16 lid;
243 int ret = 0;
244 int next_cur;
245
246 if (!(ib_rvt_state_ops[qp->state] & RVT_PROCESS_NEXT_SEND_OK)) {
247 if (!(ib_rvt_state_ops[qp->state] & RVT_FLUSH_SEND))
248 goto bail;
249 /* We are in the error state, flush the work request. */
250 if (qp->s_last == READ_ONCE(qp->s_head))
251 goto bail;
252 /* If DMAs are in progress, we can't flush immediately. */
253 if (atomic_read(&priv->s_dma_busy)) {
254 qp->s_flags |= RVT_S_WAIT_DMA;
255 goto bail;
256 }
257 wqe = rvt_get_swqe_ptr(qp, qp->s_last);
258 rvt_send_complete(qp, wqe, IB_WC_WR_FLUSH_ERR);
259 goto done;
260 }
261
262 /* see post_one_send() */
263 if (qp->s_cur == READ_ONCE(qp->s_head))
264 goto bail;
265
266 wqe = rvt_get_swqe_ptr(qp, qp->s_cur);
267 next_cur = qp->s_cur + 1;
268 if (next_cur >= qp->s_size)
269 next_cur = 0;
270
271 /* Construct the header. */
272 ibp = to_iport(qp->ibqp.device, qp->port_num);
273 ppd = ppd_from_ibp(ibp);
274 ah_attr = &ibah_to_rvtah(wqe->ud_wr.ah)->attr;
275 if (rdma_ah_get_dlid(ah_attr) >= be16_to_cpu(IB_MULTICAST_LID_BASE)) {
276 if (rdma_ah_get_dlid(ah_attr) !=
277 be16_to_cpu(IB_LID_PERMISSIVE))
278 this_cpu_inc(ibp->pmastats->n_multicast_xmit);
279 else
280 this_cpu_inc(ibp->pmastats->n_unicast_xmit);
281 } else {
282 this_cpu_inc(ibp->pmastats->n_unicast_xmit);
283 lid = rdma_ah_get_dlid(ah_attr) & ~((1 << ppd->lmc) - 1);
284 if (unlikely(lid == ppd->lid)) {
285 unsigned long tflags = *flags;
286 /*
287 * If DMAs are in progress, we can't generate
288 * a completion for the loopback packet since
289 * it would be out of order.
290 * XXX Instead of waiting, we could queue a
291 * zero length descriptor so we get a callback.
292 */
293 if (atomic_read(&priv->s_dma_busy)) {
294 qp->s_flags |= RVT_S_WAIT_DMA;
295 goto bail;
296 }
297 qp->s_cur = next_cur;
298 spin_unlock_irqrestore(&qp->s_lock, tflags);
299 qib_ud_loopback(qp, wqe);
300 spin_lock_irqsave(&qp->s_lock, tflags);
301 *flags = tflags;
302 rvt_send_complete(qp, wqe, IB_WC_SUCCESS);
303 goto done;
304 }
305 }
306
307 qp->s_cur = next_cur;
308 extra_bytes = -wqe->length & 3;
309 nwords = (wqe->length + extra_bytes) >> 2;
310
311 /* header size in 32-bit words LRH+BTH+DETH = (8+12+8)/4. */
312 qp->s_hdrwords = 7;
313 qp->s_cur_size = wqe->length;
314 qp->s_cur_sge = &qp->s_sge;
315 qp->s_srate = rdma_ah_get_static_rate(ah_attr);
316 qp->s_wqe = wqe;
317 qp->s_sge.sge = wqe->sg_list[0];
318 qp->s_sge.sg_list = wqe->sg_list + 1;
319 qp->s_sge.num_sge = wqe->wr.num_sge;
320 qp->s_sge.total_len = wqe->length;
321
322 if (rdma_ah_get_ah_flags(ah_attr) & IB_AH_GRH) {
323 /* Header size in 32-bit words. */
324 qp->s_hdrwords += qib_make_grh(ibp, &priv->s_hdr->u.l.grh,
325 rdma_ah_read_grh(ah_attr),
326 qp->s_hdrwords, nwords);
327 lrh0 = QIB_LRH_GRH;
328 ohdr = &priv->s_hdr->u.l.oth;
329 /*
330 * Don't worry about sending to locally attached multicast
331 * QPs. It is unspecified by the spec. what happens.
332 */
333 } else {
334 /* Header size in 32-bit words. */
335 lrh0 = QIB_LRH_BTH;
336 ohdr = &priv->s_hdr->u.oth;
337 }
338 if (wqe->wr.opcode == IB_WR_SEND_WITH_IMM) {
339 qp->s_hdrwords++;
340 ohdr->u.ud.imm_data = wqe->wr.ex.imm_data;
341 bth0 = IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE << 24;
342 } else
343 bth0 = IB_OPCODE_UD_SEND_ONLY << 24;
344 lrh0 |= rdma_ah_get_sl(ah_attr) << 4;
345 if (qp->ibqp.qp_type == IB_QPT_SMI)
346 lrh0 |= 0xF000; /* Set VL (see ch. 13.5.3.1) */
347 else
348 lrh0 |= ibp->sl_to_vl[rdma_ah_get_sl(ah_attr)] << 12;
349 priv->s_hdr->lrh[0] = cpu_to_be16(lrh0);
350 priv->s_hdr->lrh[1] =
351 cpu_to_be16(rdma_ah_get_dlid(ah_attr)); /* DEST LID */
352 priv->s_hdr->lrh[2] =
353 cpu_to_be16(qp->s_hdrwords + nwords + SIZE_OF_CRC);
354 lid = ppd->lid;
355 if (lid) {
356 lid |= rdma_ah_get_path_bits(ah_attr) &
357 ((1 << ppd->lmc) - 1);
358 priv->s_hdr->lrh[3] = cpu_to_be16(lid);
359 } else
360 priv->s_hdr->lrh[3] = IB_LID_PERMISSIVE;
361 if (wqe->wr.send_flags & IB_SEND_SOLICITED)
362 bth0 |= IB_BTH_SOLICITED;
363 bth0 |= extra_bytes << 20;
364 bth0 |= qp->ibqp.qp_type == IB_QPT_SMI ? QIB_DEFAULT_P_KEY :
365 qib_get_pkey(ibp, qp->ibqp.qp_type == IB_QPT_GSI ?
366 wqe->ud_wr.pkey_index : qp->s_pkey_index);
367 ohdr->bth[0] = cpu_to_be32(bth0);
368 /*
369 * Use the multicast QP if the destination LID is a multicast LID.
370 */
371 ohdr->bth[1] = rdma_ah_get_dlid(ah_attr) >=
372 be16_to_cpu(IB_MULTICAST_LID_BASE) &&
373 rdma_ah_get_dlid(ah_attr) != be16_to_cpu(IB_LID_PERMISSIVE) ?
374 cpu_to_be32(QIB_MULTICAST_QPN) :
375 cpu_to_be32(wqe->ud_wr.remote_qpn);
376 ohdr->bth[2] = cpu_to_be32(wqe->psn & QIB_PSN_MASK);
377 /*
378 * Qkeys with the high order bit set mean use the
379 * qkey from the QP context instead of the WR (see 10.2.5).
380 */
381 ohdr->u.ud.deth[0] = cpu_to_be32((int)wqe->ud_wr.remote_qkey < 0 ?
382 qp->qkey : wqe->ud_wr.remote_qkey);
383 ohdr->u.ud.deth[1] = cpu_to_be32(qp->ibqp.qp_num);
384
385 done:
386 return 1;
387 bail:
388 qp->s_flags &= ~RVT_S_BUSY;
389 return ret;
390 }
391
392 static unsigned qib_lookup_pkey(struct qib_ibport *ibp, u16 pkey)
393 {
394 struct qib_pportdata *ppd = ppd_from_ibp(ibp);
395 struct qib_devdata *dd = ppd->dd;
396 unsigned ctxt = ppd->hw_pidx;
397 unsigned i;
398
399 pkey &= 0x7fff; /* remove limited/full membership bit */
400
401 for (i = 0; i < ARRAY_SIZE(dd->rcd[ctxt]->pkeys); ++i)
402 if ((dd->rcd[ctxt]->pkeys[i] & 0x7fff) == pkey)
403 return i;
404
405 /*
406 * Should not get here, this means hardware failed to validate pkeys.
407 * Punt and return index 0.
408 */
409 return 0;
410 }
411
412 /**
413 * qib_ud_rcv - receive an incoming UD packet
414 * @ibp: the port the packet came in on
415 * @hdr: the packet header
416 * @has_grh: true if the packet has a GRH
417 * @data: the packet data
418 * @tlen: the packet length
419 * @qp: the QP the packet came on
420 *
421 * This is called from qib_qp_rcv() to process an incoming UD packet
422 * for the given QP.
423 * Called at interrupt level.
424 */
425 void qib_ud_rcv(struct qib_ibport *ibp, struct ib_header *hdr,
426 int has_grh, void *data, u32 tlen, struct rvt_qp *qp)
427 {
428 struct ib_other_headers *ohdr;
429 int opcode;
430 u32 hdrsize;
431 u32 pad;
432 struct ib_wc wc;
433 u32 qkey;
434 u32 src_qp;
435 u16 dlid;
436
437 /* Check for GRH */
438 if (!has_grh) {
439 ohdr = &hdr->u.oth;
440 hdrsize = 8 + 12 + 8; /* LRH + BTH + DETH */
441 } else {
442 ohdr = &hdr->u.l.oth;
443 hdrsize = 8 + 40 + 12 + 8; /* LRH + GRH + BTH + DETH */
444 }
445 qkey = be32_to_cpu(ohdr->u.ud.deth[0]);
446 src_qp = be32_to_cpu(ohdr->u.ud.deth[1]) & RVT_QPN_MASK;
447
448 /*
449 * Get the number of bytes the message was padded by
450 * and drop incomplete packets.
451 */
452 pad = (be32_to_cpu(ohdr->bth[0]) >> 20) & 3;
453 if (unlikely(tlen < (hdrsize + pad + 4)))
454 goto drop;
455
456 tlen -= hdrsize + pad + 4;
457
458 /*
459 * Check that the permissive LID is only used on QP0
460 * and the QKEY matches (see 9.6.1.4.1 and 9.6.1.5.1).
461 */
462 if (qp->ibqp.qp_num) {
463 if (unlikely(hdr->lrh[1] == IB_LID_PERMISSIVE ||
464 hdr->lrh[3] == IB_LID_PERMISSIVE))
465 goto drop;
466 if (qp->ibqp.qp_num > 1) {
467 u16 pkey1, pkey2;
468
469 pkey1 = be32_to_cpu(ohdr->bth[0]);
470 pkey2 = qib_get_pkey(ibp, qp->s_pkey_index);
471 if (unlikely(!qib_pkey_ok(pkey1, pkey2))) {
472 qib_bad_pkey(ibp,
473 pkey1,
474 (be16_to_cpu(hdr->lrh[0]) >> 4) &
475 0xF,
476 src_qp, qp->ibqp.qp_num,
477 hdr->lrh[3], hdr->lrh[1]);
478 return;
479 }
480 }
481 if (unlikely(qkey != qp->qkey))
482 return;
483
484 /* Drop invalid MAD packets (see 13.5.3.1). */
485 if (unlikely(qp->ibqp.qp_num == 1 &&
486 (tlen != 256 ||
487 (be16_to_cpu(hdr->lrh[0]) >> 12) == 15)))
488 goto drop;
489 } else {
490 struct ib_smp *smp;
491
492 /* Drop invalid MAD packets (see 13.5.3.1). */
493 if (tlen != 256 || (be16_to_cpu(hdr->lrh[0]) >> 12) != 15)
494 goto drop;
495 smp = (struct ib_smp *) data;
496 if ((hdr->lrh[1] == IB_LID_PERMISSIVE ||
497 hdr->lrh[3] == IB_LID_PERMISSIVE) &&
498 smp->mgmt_class != IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
499 goto drop;
500 }
501
502 /*
503 * The opcode is in the low byte when its in network order
504 * (top byte when in host order).
505 */
506 opcode = be32_to_cpu(ohdr->bth[0]) >> 24;
507 if (qp->ibqp.qp_num > 1 &&
508 opcode == IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE) {
509 wc.ex.imm_data = ohdr->u.ud.imm_data;
510 wc.wc_flags = IB_WC_WITH_IMM;
511 } else if (opcode == IB_OPCODE_UD_SEND_ONLY) {
512 wc.ex.imm_data = 0;
513 wc.wc_flags = 0;
514 } else
515 goto drop;
516
517 /*
518 * A GRH is expected to precede the data even if not
519 * present on the wire.
520 */
521 wc.byte_len = tlen + sizeof(struct ib_grh);
522
523 /*
524 * Get the next work request entry to find where to put the data.
525 */
526 if (qp->r_flags & RVT_R_REUSE_SGE)
527 qp->r_flags &= ~RVT_R_REUSE_SGE;
528 else {
529 int ret;
530
531 ret = rvt_get_rwqe(qp, false);
532 if (ret < 0) {
533 rvt_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
534 return;
535 }
536 if (!ret) {
537 if (qp->ibqp.qp_num == 0)
538 ibp->rvp.n_vl15_dropped++;
539 return;
540 }
541 }
542 /* Silently drop packets which are too big. */
543 if (unlikely(wc.byte_len > qp->r_len)) {
544 qp->r_flags |= RVT_R_REUSE_SGE;
545 goto drop;
546 }
547 if (has_grh) {
548 rvt_copy_sge(qp, &qp->r_sge, &hdr->u.l.grh,
549 sizeof(struct ib_grh), true, false);
550 wc.wc_flags |= IB_WC_GRH;
551 } else
552 rvt_skip_sge(&qp->r_sge, sizeof(struct ib_grh), true);
553 rvt_copy_sge(qp, &qp->r_sge, data, wc.byte_len - sizeof(struct ib_grh),
554 true, false);
555 rvt_put_ss(&qp->r_sge);
556 if (!test_and_clear_bit(RVT_R_WRID_VALID, &qp->r_aflags))
557 return;
558 wc.wr_id = qp->r_wr_id;
559 wc.status = IB_WC_SUCCESS;
560 wc.opcode = IB_WC_RECV;
561 wc.vendor_err = 0;
562 wc.qp = &qp->ibqp;
563 wc.src_qp = src_qp;
564 wc.pkey_index = qp->ibqp.qp_type == IB_QPT_GSI ?
565 qib_lookup_pkey(ibp, be32_to_cpu(ohdr->bth[0])) : 0;
566 wc.slid = be16_to_cpu(hdr->lrh[3]);
567 wc.sl = (be16_to_cpu(hdr->lrh[0]) >> 4) & 0xF;
568 dlid = be16_to_cpu(hdr->lrh[1]);
569 /*
570 * Save the LMC lower bits if the destination LID is a unicast LID.
571 */
572 wc.dlid_path_bits = dlid >= be16_to_cpu(IB_MULTICAST_LID_BASE) ? 0 :
573 dlid & ((1 << ppd_from_ibp(ibp)->lmc) - 1);
574 wc.port_num = qp->port_num;
575 /* Signal completion event if the solicited bit is set. */
576 rvt_cq_enter(ibcq_to_rvtcq(qp->ibqp.recv_cq), &wc,
577 ib_bth_is_solicited(ohdr));
578 return;
579
580 drop:
581 ibp->rvp.n_pkt_drops++;
582 }