diff options
Diffstat (limited to 'drivers/infiniband/hw/ipath/ipath_ruc.c')
-rw-r--r-- | drivers/infiniband/hw/ipath/ipath_ruc.c | 308 |
1 files changed, 108 insertions, 200 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c index c69c25239443..4b6b7ee8e5c1 100644 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c | |||
@@ -31,6 +31,8 @@ | |||
31 | * SOFTWARE. | 31 | * SOFTWARE. |
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <linux/spinlock.h> | ||
35 | |||
34 | #include "ipath_verbs.h" | 36 | #include "ipath_verbs.h" |
35 | #include "ipath_kernel.h" | 37 | #include "ipath_kernel.h" |
36 | 38 | ||
@@ -106,27 +108,30 @@ void ipath_insert_rnr_queue(struct ipath_qp *qp) | |||
106 | spin_unlock_irqrestore(&dev->pending_lock, flags); | 108 | spin_unlock_irqrestore(&dev->pending_lock, flags); |
107 | } | 109 | } |
108 | 110 | ||
109 | static int init_sge(struct ipath_qp *qp, struct ipath_rwqe *wqe) | 111 | /** |
112 | * ipath_init_sge - Validate a RWQE and fill in the SGE state | ||
113 | * @qp: the QP | ||
114 | * | ||
115 | * Return 1 if OK. | ||
116 | */ | ||
117 | int ipath_init_sge(struct ipath_qp *qp, struct ipath_rwqe *wqe, | ||
118 | u32 *lengthp, struct ipath_sge_state *ss) | ||
110 | { | 119 | { |
111 | int user = to_ipd(qp->ibqp.pd)->user; | ||
112 | int i, j, ret; | 120 | int i, j, ret; |
113 | struct ib_wc wc; | 121 | struct ib_wc wc; |
114 | 122 | ||
115 | qp->r_len = 0; | 123 | *lengthp = 0; |
116 | for (i = j = 0; i < wqe->num_sge; i++) { | 124 | for (i = j = 0; i < wqe->num_sge; i++) { |
117 | if (wqe->sg_list[i].length == 0) | 125 | if (wqe->sg_list[i].length == 0) |
118 | continue; | 126 | continue; |
119 | /* Check LKEY */ | 127 | /* Check LKEY */ |
120 | if ((user && wqe->sg_list[i].lkey == 0) || | 128 | if (!ipath_lkey_ok(qp, j ? &ss->sg_list[j - 1] : &ss->sge, |
121 | !ipath_lkey_ok(qp, &qp->r_sg_list[j], &wqe->sg_list[i], | 129 | &wqe->sg_list[i], IB_ACCESS_LOCAL_WRITE)) |
122 | IB_ACCESS_LOCAL_WRITE)) | ||
123 | goto bad_lkey; | 130 | goto bad_lkey; |
124 | qp->r_len += wqe->sg_list[i].length; | 131 | *lengthp += wqe->sg_list[i].length; |
125 | j++; | 132 | j++; |
126 | } | 133 | } |
127 | qp->r_sge.sge = qp->r_sg_list[0]; | 134 | ss->num_sge = j; |
128 | qp->r_sge.sg_list = qp->r_sg_list + 1; | ||
129 | qp->r_sge.num_sge = j; | ||
130 | ret = 1; | 135 | ret = 1; |
131 | goto bail; | 136 | goto bail; |
132 | 137 | ||
@@ -172,6 +177,8 @@ int ipath_get_rwqe(struct ipath_qp *qp, int wr_id_only) | |||
172 | u32 tail; | 177 | u32 tail; |
173 | int ret; | 178 | int ret; |
174 | 179 | ||
180 | qp->r_sge.sg_list = qp->r_sg_list; | ||
181 | |||
175 | if (qp->ibqp.srq) { | 182 | if (qp->ibqp.srq) { |
176 | srq = to_isrq(qp->ibqp.srq); | 183 | srq = to_isrq(qp->ibqp.srq); |
177 | handler = srq->ibsrq.event_handler; | 184 | handler = srq->ibsrq.event_handler; |
@@ -199,7 +206,8 @@ int ipath_get_rwqe(struct ipath_qp *qp, int wr_id_only) | |||
199 | wqe = get_rwqe_ptr(rq, tail); | 206 | wqe = get_rwqe_ptr(rq, tail); |
200 | if (++tail >= rq->size) | 207 | if (++tail >= rq->size) |
201 | tail = 0; | 208 | tail = 0; |
202 | } while (!wr_id_only && !init_sge(qp, wqe)); | 209 | } while (!wr_id_only && !ipath_init_sge(qp, wqe, &qp->r_len, |
210 | &qp->r_sge)); | ||
203 | qp->r_wr_id = wqe->wr_id; | 211 | qp->r_wr_id = wqe->wr_id; |
204 | wq->tail = tail; | 212 | wq->tail = tail; |
205 | 213 | ||
@@ -239,9 +247,9 @@ bail: | |||
239 | 247 | ||
240 | /** | 248 | /** |
241 | * ipath_ruc_loopback - handle UC and RC lookback requests | 249 | * ipath_ruc_loopback - handle UC and RC lookback requests |
242 | * @sqp: the loopback QP | 250 | * @sqp: the sending QP |
243 | * | 251 | * |
244 | * This is called from ipath_do_uc_send() or ipath_do_rc_send() to | 252 | * This is called from ipath_do_send() to |
245 | * forward a WQE addressed to the same HCA. | 253 | * forward a WQE addressed to the same HCA. |
246 | * Note that although we are single threaded due to the tasklet, we still | 254 | * Note that although we are single threaded due to the tasklet, we still |
247 | * have to protect against post_send(). We don't have to worry about | 255 | * have to protect against post_send(). We don't have to worry about |
@@ -450,40 +458,18 @@ again: | |||
450 | wc.byte_len = wqe->length; | 458 | wc.byte_len = wqe->length; |
451 | wc.qp = &qp->ibqp; | 459 | wc.qp = &qp->ibqp; |
452 | wc.src_qp = qp->remote_qpn; | 460 | wc.src_qp = qp->remote_qpn; |
453 | /* XXX do we know which pkey matched? Only needed for GSI. */ | ||
454 | wc.pkey_index = 0; | 461 | wc.pkey_index = 0; |
455 | wc.slid = qp->remote_ah_attr.dlid; | 462 | wc.slid = qp->remote_ah_attr.dlid; |
456 | wc.sl = qp->remote_ah_attr.sl; | 463 | wc.sl = qp->remote_ah_attr.sl; |
457 | wc.dlid_path_bits = 0; | 464 | wc.dlid_path_bits = 0; |
465 | wc.port_num = 1; | ||
458 | /* Signal completion event if the solicited bit is set. */ | 466 | /* Signal completion event if the solicited bit is set. */ |
459 | ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, | 467 | ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, |
460 | wqe->wr.send_flags & IB_SEND_SOLICITED); | 468 | wqe->wr.send_flags & IB_SEND_SOLICITED); |
461 | 469 | ||
462 | send_comp: | 470 | send_comp: |
463 | sqp->s_rnr_retry = sqp->s_rnr_retry_cnt; | 471 | sqp->s_rnr_retry = sqp->s_rnr_retry_cnt; |
464 | 472 | ipath_send_complete(sqp, wqe, IB_WC_SUCCESS); | |
465 | if (!(sqp->s_flags & IPATH_S_SIGNAL_REQ_WR) || | ||
466 | (wqe->wr.send_flags & IB_SEND_SIGNALED)) { | ||
467 | wc.wr_id = wqe->wr.wr_id; | ||
468 | wc.status = IB_WC_SUCCESS; | ||
469 | wc.opcode = ib_ipath_wc_opcode[wqe->wr.opcode]; | ||
470 | wc.vendor_err = 0; | ||
471 | wc.byte_len = wqe->length; | ||
472 | wc.qp = &sqp->ibqp; | ||
473 | wc.src_qp = 0; | ||
474 | wc.pkey_index = 0; | ||
475 | wc.slid = 0; | ||
476 | wc.sl = 0; | ||
477 | wc.dlid_path_bits = 0; | ||
478 | wc.port_num = 0; | ||
479 | ipath_cq_enter(to_icq(sqp->ibqp.send_cq), &wc, 0); | ||
480 | } | ||
481 | |||
482 | /* Update s_last now that we are finished with the SWQE */ | ||
483 | spin_lock_irqsave(&sqp->s_lock, flags); | ||
484 | if (++sqp->s_last >= sqp->s_size) | ||
485 | sqp->s_last = 0; | ||
486 | spin_unlock_irqrestore(&sqp->s_lock, flags); | ||
487 | goto again; | 473 | goto again; |
488 | 474 | ||
489 | done: | 475 | done: |
@@ -491,13 +477,11 @@ done: | |||
491 | wake_up(&qp->wait); | 477 | wake_up(&qp->wait); |
492 | } | 478 | } |
493 | 479 | ||
494 | static int want_buffer(struct ipath_devdata *dd) | 480 | static void want_buffer(struct ipath_devdata *dd) |
495 | { | 481 | { |
496 | set_bit(IPATH_S_PIOINTBUFAVAIL, &dd->ipath_sendctrl); | 482 | set_bit(IPATH_S_PIOINTBUFAVAIL, &dd->ipath_sendctrl); |
497 | ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, | 483 | ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, |
498 | dd->ipath_sendctrl); | 484 | dd->ipath_sendctrl); |
499 | |||
500 | return 0; | ||
501 | } | 485 | } |
502 | 486 | ||
503 | /** | 487 | /** |
@@ -507,14 +491,11 @@ static int want_buffer(struct ipath_devdata *dd) | |||
507 | * | 491 | * |
508 | * Called when we run out of PIO buffers. | 492 | * Called when we run out of PIO buffers. |
509 | */ | 493 | */ |
510 | static void ipath_no_bufs_available(struct ipath_qp *qp, struct ipath_ibdev *dev) | 494 | static void ipath_no_bufs_available(struct ipath_qp *qp, |
495 | struct ipath_ibdev *dev) | ||
511 | { | 496 | { |
512 | unsigned long flags; | 497 | unsigned long flags; |
513 | 498 | ||
514 | spin_lock_irqsave(&dev->pending_lock, flags); | ||
515 | if (list_empty(&qp->piowait)) | ||
516 | list_add_tail(&qp->piowait, &dev->piowait); | ||
517 | spin_unlock_irqrestore(&dev->pending_lock, flags); | ||
518 | /* | 499 | /* |
519 | * Note that as soon as want_buffer() is called and | 500 | * Note that as soon as want_buffer() is called and |
520 | * possibly before it returns, ipath_ib_piobufavail() | 501 | * possibly before it returns, ipath_ib_piobufavail() |
@@ -524,101 +505,14 @@ static void ipath_no_bufs_available(struct ipath_qp *qp, struct ipath_ibdev *dev | |||
524 | * We leave the busy flag set so that another post send doesn't | 505 | * We leave the busy flag set so that another post send doesn't |
525 | * try to put the same QP on the piowait list again. | 506 | * try to put the same QP on the piowait list again. |
526 | */ | 507 | */ |
508 | spin_lock_irqsave(&dev->pending_lock, flags); | ||
509 | list_add_tail(&qp->piowait, &dev->piowait); | ||
510 | spin_unlock_irqrestore(&dev->pending_lock, flags); | ||
527 | want_buffer(dev->dd); | 511 | want_buffer(dev->dd); |
528 | dev->n_piowait++; | 512 | dev->n_piowait++; |
529 | } | 513 | } |
530 | 514 | ||
531 | /** | 515 | /** |
532 | * ipath_post_ruc_send - post RC and UC sends | ||
533 | * @qp: the QP to post on | ||
534 | * @wr: the work request to send | ||
535 | */ | ||
536 | int ipath_post_ruc_send(struct ipath_qp *qp, struct ib_send_wr *wr) | ||
537 | { | ||
538 | struct ipath_swqe *wqe; | ||
539 | unsigned long flags; | ||
540 | u32 next; | ||
541 | int i, j; | ||
542 | int acc; | ||
543 | int ret; | ||
544 | |||
545 | /* | ||
546 | * Don't allow RDMA reads or atomic operations on UC or | ||
547 | * undefined operations. | ||
548 | * Make sure buffer is large enough to hold the result for atomics. | ||
549 | */ | ||
550 | if (qp->ibqp.qp_type == IB_QPT_UC) { | ||
551 | if ((unsigned) wr->opcode >= IB_WR_RDMA_READ) { | ||
552 | ret = -EINVAL; | ||
553 | goto bail; | ||
554 | } | ||
555 | } else if ((unsigned) wr->opcode > IB_WR_ATOMIC_FETCH_AND_ADD) { | ||
556 | ret = -EINVAL; | ||
557 | goto bail; | ||
558 | } else if (wr->opcode >= IB_WR_ATOMIC_CMP_AND_SWP && | ||
559 | (wr->num_sge == 0 || | ||
560 | wr->sg_list[0].length < sizeof(u64) || | ||
561 | wr->sg_list[0].addr & (sizeof(u64) - 1))) { | ||
562 | ret = -EINVAL; | ||
563 | goto bail; | ||
564 | } else if (wr->opcode >= IB_WR_RDMA_READ && !qp->s_max_rd_atomic) { | ||
565 | ret = -EINVAL; | ||
566 | goto bail; | ||
567 | } | ||
568 | /* IB spec says that num_sge == 0 is OK. */ | ||
569 | if (wr->num_sge > qp->s_max_sge) { | ||
570 | ret = -ENOMEM; | ||
571 | goto bail; | ||
572 | } | ||
573 | spin_lock_irqsave(&qp->s_lock, flags); | ||
574 | next = qp->s_head + 1; | ||
575 | if (next >= qp->s_size) | ||
576 | next = 0; | ||
577 | if (next == qp->s_last) { | ||
578 | spin_unlock_irqrestore(&qp->s_lock, flags); | ||
579 | ret = -EINVAL; | ||
580 | goto bail; | ||
581 | } | ||
582 | |||
583 | wqe = get_swqe_ptr(qp, qp->s_head); | ||
584 | wqe->wr = *wr; | ||
585 | wqe->ssn = qp->s_ssn++; | ||
586 | wqe->sg_list[0].mr = NULL; | ||
587 | wqe->sg_list[0].vaddr = NULL; | ||
588 | wqe->sg_list[0].length = 0; | ||
589 | wqe->sg_list[0].sge_length = 0; | ||
590 | wqe->length = 0; | ||
591 | acc = wr->opcode >= IB_WR_RDMA_READ ? IB_ACCESS_LOCAL_WRITE : 0; | ||
592 | for (i = 0, j = 0; i < wr->num_sge; i++) { | ||
593 | if (to_ipd(qp->ibqp.pd)->user && wr->sg_list[i].lkey == 0) { | ||
594 | spin_unlock_irqrestore(&qp->s_lock, flags); | ||
595 | ret = -EINVAL; | ||
596 | goto bail; | ||
597 | } | ||
598 | if (wr->sg_list[i].length == 0) | ||
599 | continue; | ||
600 | if (!ipath_lkey_ok(qp, &wqe->sg_list[j], &wr->sg_list[i], | ||
601 | acc)) { | ||
602 | spin_unlock_irqrestore(&qp->s_lock, flags); | ||
603 | ret = -EINVAL; | ||
604 | goto bail; | ||
605 | } | ||
606 | wqe->length += wr->sg_list[i].length; | ||
607 | j++; | ||
608 | } | ||
609 | wqe->wr.num_sge = j; | ||
610 | qp->s_head = next; | ||
611 | spin_unlock_irqrestore(&qp->s_lock, flags); | ||
612 | |||
613 | ipath_do_ruc_send((unsigned long) qp); | ||
614 | |||
615 | ret = 0; | ||
616 | |||
617 | bail: | ||
618 | return ret; | ||
619 | } | ||
620 | |||
621 | /** | ||
622 | * ipath_make_grh - construct a GRH header | 516 | * ipath_make_grh - construct a GRH header |
623 | * @dev: a pointer to the ipath device | 517 | * @dev: a pointer to the ipath device |
624 | * @hdr: a pointer to the GRH header being constructed | 518 | * @hdr: a pointer to the GRH header being constructed |
@@ -648,39 +542,66 @@ u32 ipath_make_grh(struct ipath_ibdev *dev, struct ib_grh *hdr, | |||
648 | return sizeof(struct ib_grh) / sizeof(u32); | 542 | return sizeof(struct ib_grh) / sizeof(u32); |
649 | } | 543 | } |
650 | 544 | ||
545 | void ipath_make_ruc_header(struct ipath_ibdev *dev, struct ipath_qp *qp, | ||
546 | struct ipath_other_headers *ohdr, | ||
547 | u32 bth0, u32 bth2) | ||
548 | { | ||
549 | u16 lrh0; | ||
550 | u32 nwords; | ||
551 | u32 extra_bytes; | ||
552 | |||
553 | /* Construct the header. */ | ||
554 | extra_bytes = -qp->s_cur_size & 3; | ||
555 | nwords = (qp->s_cur_size + extra_bytes) >> 2; | ||
556 | lrh0 = IPATH_LRH_BTH; | ||
557 | if (unlikely(qp->remote_ah_attr.ah_flags & IB_AH_GRH)) { | ||
558 | qp->s_hdrwords += ipath_make_grh(dev, &qp->s_hdr.u.l.grh, | ||
559 | &qp->remote_ah_attr.grh, | ||
560 | qp->s_hdrwords, nwords); | ||
561 | lrh0 = IPATH_LRH_GRH; | ||
562 | } | ||
563 | lrh0 |= qp->remote_ah_attr.sl << 4; | ||
564 | qp->s_hdr.lrh[0] = cpu_to_be16(lrh0); | ||
565 | qp->s_hdr.lrh[1] = cpu_to_be16(qp->remote_ah_attr.dlid); | ||
566 | qp->s_hdr.lrh[2] = cpu_to_be16(qp->s_hdrwords + nwords + SIZE_OF_CRC); | ||
567 | qp->s_hdr.lrh[3] = cpu_to_be16(dev->dd->ipath_lid); | ||
568 | bth0 |= ipath_get_pkey(dev->dd, qp->s_pkey_index); | ||
569 | bth0 |= extra_bytes << 20; | ||
570 | ohdr->bth[0] = cpu_to_be32(bth0 | (1 << 22)); | ||
571 | ohdr->bth[1] = cpu_to_be32(qp->remote_qpn); | ||
572 | ohdr->bth[2] = cpu_to_be32(bth2); | ||
573 | } | ||
574 | |||
651 | /** | 575 | /** |
652 | * ipath_do_ruc_send - perform a send on an RC or UC QP | 576 | * ipath_do_send - perform a send on a QP |
653 | * @data: contains a pointer to the QP | 577 | * @data: contains a pointer to the QP |
654 | * | 578 | * |
655 | * Process entries in the send work queue until credit or queue is | 579 | * Process entries in the send work queue until credit or queue is |
656 | * exhausted. Only allow one CPU to send a packet per QP (tasklet). | 580 | * exhausted. Only allow one CPU to send a packet per QP (tasklet). |
657 | * Otherwise, after we drop the QP s_lock, two threads could send | 581 | * Otherwise, two threads could send packets out of order. |
658 | * packets out of order. | ||
659 | */ | 582 | */ |
660 | void ipath_do_ruc_send(unsigned long data) | 583 | void ipath_do_send(unsigned long data) |
661 | { | 584 | { |
662 | struct ipath_qp *qp = (struct ipath_qp *)data; | 585 | struct ipath_qp *qp = (struct ipath_qp *)data; |
663 | struct ipath_ibdev *dev = to_idev(qp->ibqp.device); | 586 | struct ipath_ibdev *dev = to_idev(qp->ibqp.device); |
664 | unsigned long flags; | 587 | int (*make_req)(struct ipath_qp *qp); |
665 | u16 lrh0; | ||
666 | u32 nwords; | ||
667 | u32 extra_bytes; | ||
668 | u32 bth0; | ||
669 | u32 bth2; | ||
670 | u32 pmtu = ib_mtu_enum_to_int(qp->path_mtu); | ||
671 | struct ipath_other_headers *ohdr; | ||
672 | 588 | ||
673 | if (test_and_set_bit(IPATH_S_BUSY, &qp->s_busy)) | 589 | if (test_and_set_bit(IPATH_S_BUSY, &qp->s_busy)) |
674 | goto bail; | 590 | goto bail; |
675 | 591 | ||
676 | if (unlikely(qp->remote_ah_attr.dlid == dev->dd->ipath_lid)) { | 592 | if ((qp->ibqp.qp_type == IB_QPT_RC || |
593 | qp->ibqp.qp_type == IB_QPT_UC) && | ||
594 | qp->remote_ah_attr.dlid == dev->dd->ipath_lid) { | ||
677 | ipath_ruc_loopback(qp); | 595 | ipath_ruc_loopback(qp); |
678 | goto clear; | 596 | goto clear; |
679 | } | 597 | } |
680 | 598 | ||
681 | ohdr = &qp->s_hdr.u.oth; | 599 | if (qp->ibqp.qp_type == IB_QPT_RC) |
682 | if (qp->remote_ah_attr.ah_flags & IB_AH_GRH) | 600 | make_req = ipath_make_rc_req; |
683 | ohdr = &qp->s_hdr.u.l.oth; | 601 | else if (qp->ibqp.qp_type == IB_QPT_UC) |
602 | make_req = ipath_make_uc_req; | ||
603 | else | ||
604 | make_req = ipath_make_ud_req; | ||
684 | 605 | ||
685 | again: | 606 | again: |
686 | /* Check for a constructed packet to be sent. */ | 607 | /* Check for a constructed packet to be sent. */ |
@@ -689,9 +610,8 @@ again: | |||
689 | * If no PIO bufs are available, return. An interrupt will | 610 | * If no PIO bufs are available, return. An interrupt will |
690 | * call ipath_ib_piobufavail() when one is available. | 611 | * call ipath_ib_piobufavail() when one is available. |
691 | */ | 612 | */ |
692 | if (ipath_verbs_send(dev->dd, qp->s_hdrwords, | 613 | if (ipath_verbs_send(qp, &qp->s_hdr, qp->s_hdrwords, |
693 | (u32 *) &qp->s_hdr, qp->s_cur_size, | 614 | qp->s_cur_sge, qp->s_cur_size)) { |
694 | qp->s_cur_sge)) { | ||
695 | ipath_no_bufs_available(qp, dev); | 615 | ipath_no_bufs_available(qp, dev); |
696 | goto bail; | 616 | goto bail; |
697 | } | 617 | } |
@@ -700,54 +620,42 @@ again: | |||
700 | qp->s_hdrwords = 0; | 620 | qp->s_hdrwords = 0; |
701 | } | 621 | } |
702 | 622 | ||
703 | /* | 623 | if (make_req(qp)) |
704 | * The lock is needed to synchronize between setting | 624 | goto again; |
705 | * qp->s_ack_state, resend timer, and post_send(). | 625 | clear: |
706 | */ | 626 | clear_bit(IPATH_S_BUSY, &qp->s_busy); |
707 | spin_lock_irqsave(&qp->s_lock, flags); | 627 | bail:; |
708 | 628 | } | |
709 | if (!((qp->ibqp.qp_type == IB_QPT_RC) ? | ||
710 | ipath_make_rc_req(qp, ohdr, pmtu, &bth0, &bth2) : | ||
711 | ipath_make_uc_req(qp, ohdr, pmtu, &bth0, &bth2))) { | ||
712 | /* | ||
713 | * Clear the busy bit before unlocking to avoid races with | ||
714 | * adding new work queue items and then failing to process | ||
715 | * them. | ||
716 | */ | ||
717 | clear_bit(IPATH_S_BUSY, &qp->s_busy); | ||
718 | spin_unlock_irqrestore(&qp->s_lock, flags); | ||
719 | goto bail; | ||
720 | } | ||
721 | 629 | ||
722 | spin_unlock_irqrestore(&qp->s_lock, flags); | 630 | void ipath_send_complete(struct ipath_qp *qp, struct ipath_swqe *wqe, |
631 | enum ib_wc_status status) | ||
632 | { | ||
633 | u32 last = qp->s_last; | ||
723 | 634 | ||
724 | /* Construct the header. */ | 635 | if (++last == qp->s_size) |
725 | extra_bytes = (4 - qp->s_cur_size) & 3; | 636 | last = 0; |
726 | nwords = (qp->s_cur_size + extra_bytes) >> 2; | 637 | qp->s_last = last; |
727 | lrh0 = IPATH_LRH_BTH; | ||
728 | if (unlikely(qp->remote_ah_attr.ah_flags & IB_AH_GRH)) { | ||
729 | qp->s_hdrwords += ipath_make_grh(dev, &qp->s_hdr.u.l.grh, | ||
730 | &qp->remote_ah_attr.grh, | ||
731 | qp->s_hdrwords, nwords); | ||
732 | lrh0 = IPATH_LRH_GRH; | ||
733 | } | ||
734 | lrh0 |= qp->remote_ah_attr.sl << 4; | ||
735 | qp->s_hdr.lrh[0] = cpu_to_be16(lrh0); | ||
736 | qp->s_hdr.lrh[1] = cpu_to_be16(qp->remote_ah_attr.dlid); | ||
737 | qp->s_hdr.lrh[2] = cpu_to_be16(qp->s_hdrwords + nwords + | ||
738 | SIZE_OF_CRC); | ||
739 | qp->s_hdr.lrh[3] = cpu_to_be16(dev->dd->ipath_lid); | ||
740 | bth0 |= ipath_get_pkey(dev->dd, qp->s_pkey_index); | ||
741 | bth0 |= extra_bytes << 20; | ||
742 | ohdr->bth[0] = cpu_to_be32(bth0); | ||
743 | ohdr->bth[1] = cpu_to_be32(qp->remote_qpn); | ||
744 | ohdr->bth[2] = cpu_to_be32(bth2); | ||
745 | 638 | ||
746 | /* Check for more work to do. */ | 639 | /* See ch. 11.2.4.1 and 10.7.3.1 */ |
747 | goto again; | 640 | if (!(qp->s_flags & IPATH_S_SIGNAL_REQ_WR) || |
641 | (wqe->wr.send_flags & IB_SEND_SIGNALED) || | ||
642 | status != IB_WC_SUCCESS) { | ||
643 | struct ib_wc wc; | ||
748 | 644 | ||
749 | clear: | 645 | wc.wr_id = wqe->wr.wr_id; |
750 | clear_bit(IPATH_S_BUSY, &qp->s_busy); | 646 | wc.status = status; |
751 | bail: | 647 | wc.opcode = ib_ipath_wc_opcode[wqe->wr.opcode]; |
752 | return; | 648 | wc.vendor_err = 0; |
649 | wc.byte_len = wqe->length; | ||
650 | wc.imm_data = 0; | ||
651 | wc.qp = &qp->ibqp; | ||
652 | wc.src_qp = 0; | ||
653 | wc.wc_flags = 0; | ||
654 | wc.pkey_index = 0; | ||
655 | wc.slid = 0; | ||
656 | wc.sl = 0; | ||
657 | wc.dlid_path_bits = 0; | ||
658 | wc.port_num = 0; | ||
659 | ipath_cq_enter(to_icq(qp->ibqp.send_cq), &wc, 0); | ||
660 | } | ||
753 | } | 661 | } |