Lines Matching refs:qp
86 void ipath_insert_rnr_queue(struct ipath_qp *qp) in ipath_insert_rnr_queue() argument
88 struct ipath_ibdev *dev = to_idev(qp->ibqp.device); in ipath_insert_rnr_queue()
93 list_add(&qp->timerwait, &dev->rnrwait); in ipath_insert_rnr_queue()
99 while (qp->s_rnr_timeout >= nqp->s_rnr_timeout) { in ipath_insert_rnr_queue()
100 qp->s_rnr_timeout -= nqp->s_rnr_timeout; in ipath_insert_rnr_queue()
110 nqp->s_rnr_timeout -= qp->s_rnr_timeout; in ipath_insert_rnr_queue()
111 list_add(&qp->timerwait, l); in ipath_insert_rnr_queue()
122 int ipath_init_sge(struct ipath_qp *qp, struct ipath_rwqe *wqe, in ipath_init_sge() argument
133 if (!ipath_lkey_ok(qp, j ? &ss->sg_list[j - 1] : &ss->sge, in ipath_init_sge()
148 wc.qp = &qp->ibqp; in ipath_init_sge()
150 ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, 1); in ipath_init_sge()
165 int ipath_get_rwqe(struct ipath_qp *qp, int wr_id_only) in ipath_get_rwqe() argument
176 if (qp->ibqp.srq) { in ipath_get_rwqe()
177 srq = to_isrq(qp->ibqp.srq); in ipath_get_rwqe()
183 rq = &qp->r_rq; in ipath_get_rwqe()
187 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_RECV_OK)) { in ipath_get_rwqe()
209 qp->r_sge.sg_list = qp->r_sg_list; in ipath_get_rwqe()
210 } while (!ipath_init_sge(qp, wqe, &qp->r_len, &qp->r_sge)); in ipath_get_rwqe()
211 qp->r_wr_id = wqe->wr_id; in ipath_get_rwqe()
215 set_bit(IPATH_R_WRID_VALID, &qp->r_aflags); in ipath_get_rwqe()
235 ev.device = qp->ibqp.device; in ipath_get_rwqe()
236 ev.element.srq = qp->ibqp.srq; in ipath_get_rwqe()
262 struct ipath_qp *qp; in ipath_ruc_loopback() local
275 qp = ipath_lookup_qpn(&dev->qp_table, sqp->remote_qpn); in ipath_ruc_loopback()
311 if (!qp || !(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_RECV_OK)) { in ipath_ruc_loopback()
337 if (!ipath_get_rwqe(qp, 0)) in ipath_ruc_loopback()
342 if (unlikely(!(qp->qp_access_flags & IB_ACCESS_REMOTE_WRITE))) in ipath_ruc_loopback()
346 if (!ipath_get_rwqe(qp, 1)) in ipath_ruc_loopback()
350 if (unlikely(!(qp->qp_access_flags & IB_ACCESS_REMOTE_WRITE))) in ipath_ruc_loopback()
354 if (unlikely(!ipath_rkey_ok(qp, &qp->r_sge, wqe->length, in ipath_ruc_loopback()
362 if (unlikely(!(qp->qp_access_flags & IB_ACCESS_REMOTE_READ))) in ipath_ruc_loopback()
364 if (unlikely(!ipath_rkey_ok(qp, &sqp->s_sge, wqe->length, in ipath_ruc_loopback()
369 qp->r_sge.sge = wqe->sg_list[0]; in ipath_ruc_loopback()
370 qp->r_sge.sg_list = wqe->sg_list + 1; in ipath_ruc_loopback()
371 qp->r_sge.num_sge = wqe->wr.num_sge; in ipath_ruc_loopback()
376 if (unlikely(!(qp->qp_access_flags & IB_ACCESS_REMOTE_ATOMIC))) in ipath_ruc_loopback()
378 if (unlikely(!ipath_rkey_ok(qp, &qp->r_sge, sizeof(u64), in ipath_ruc_loopback()
384 maddr = (atomic64_t *) qp->r_sge.sge.vaddr; in ipath_ruc_loopback()
389 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr, in ipath_ruc_loopback()
407 ipath_copy_sge(&qp->r_sge, sge->vaddr, len); in ipath_ruc_loopback()
428 if (!test_and_clear_bit(IPATH_R_WRID_VALID, &qp->r_aflags)) in ipath_ruc_loopback()
435 wc.wr_id = qp->r_wr_id; in ipath_ruc_loopback()
438 wc.qp = &qp->ibqp; in ipath_ruc_loopback()
439 wc.src_qp = qp->remote_qpn; in ipath_ruc_loopback()
440 wc.slid = qp->remote_ah_attr.dlid; in ipath_ruc_loopback()
441 wc.sl = qp->remote_ah_attr.sl; in ipath_ruc_loopback()
444 ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, in ipath_ruc_loopback()
456 if (qp->ibqp.qp_type == IB_QPT_UC) in ipath_ruc_loopback()
473 sqp->s_rnr_timeout = ib_ipath_rnr_table[qp->r_min_rnr_timer]; in ipath_ruc_loopback()
487 ipath_rc_error(qp, wc.status); in ipath_ruc_loopback()
501 ev.element.qp = &sqp->ibqp; in ipath_ruc_loopback()
512 if (qp && atomic_dec_and_test(&qp->refcount)) in ipath_ruc_loopback()
513 wake_up(&qp->wait); in ipath_ruc_loopback()
516 static void want_buffer(struct ipath_devdata *dd, struct ipath_qp *qp) in want_buffer() argument
519 qp->ibqp.qp_type == IB_QPT_SMI) { in want_buffer()
540 static int ipath_no_bufs_available(struct ipath_qp *qp, in ipath_no_bufs_available() argument
552 spin_lock_irqsave(&qp->s_lock, flags); in ipath_no_bufs_available()
553 if (ib_ipath_state_ops[qp->state] & IPATH_PROCESS_SEND_OK) { in ipath_no_bufs_available()
555 qp->s_flags |= IPATH_S_WAITING; in ipath_no_bufs_available()
556 qp->s_flags &= ~IPATH_S_BUSY; in ipath_no_bufs_available()
558 if (list_empty(&qp->piowait)) in ipath_no_bufs_available()
559 list_add_tail(&qp->piowait, &dev->piowait); in ipath_no_bufs_available()
563 spin_unlock_irqrestore(&qp->s_lock, flags); in ipath_no_bufs_available()
565 want_buffer(dev->dd, qp); in ipath_no_bufs_available()
599 void ipath_make_ruc_header(struct ipath_ibdev *dev, struct ipath_qp *qp, in ipath_make_ruc_header() argument
608 extra_bytes = -qp->s_cur_size & 3; in ipath_make_ruc_header()
609 nwords = (qp->s_cur_size + extra_bytes) >> 2; in ipath_make_ruc_header()
611 if (unlikely(qp->remote_ah_attr.ah_flags & IB_AH_GRH)) { in ipath_make_ruc_header()
612 qp->s_hdrwords += ipath_make_grh(dev, &qp->s_hdr.u.l.grh, in ipath_make_ruc_header()
613 &qp->remote_ah_attr.grh, in ipath_make_ruc_header()
614 qp->s_hdrwords, nwords); in ipath_make_ruc_header()
617 lrh0 |= qp->remote_ah_attr.sl << 4; in ipath_make_ruc_header()
618 qp->s_hdr.lrh[0] = cpu_to_be16(lrh0); in ipath_make_ruc_header()
619 qp->s_hdr.lrh[1] = cpu_to_be16(qp->remote_ah_attr.dlid); in ipath_make_ruc_header()
620 qp->s_hdr.lrh[2] = cpu_to_be16(qp->s_hdrwords + nwords + SIZE_OF_CRC); in ipath_make_ruc_header()
621 qp->s_hdr.lrh[3] = cpu_to_be16(dev->dd->ipath_lid | in ipath_make_ruc_header()
622 qp->remote_ah_attr.src_path_bits); in ipath_make_ruc_header()
623 bth0 |= ipath_get_pkey(dev->dd, qp->s_pkey_index); in ipath_make_ruc_header()
626 ohdr->bth[1] = cpu_to_be32(qp->remote_qpn); in ipath_make_ruc_header()
640 struct ipath_qp *qp = (struct ipath_qp *)data; in ipath_do_send() local
641 struct ipath_ibdev *dev = to_idev(qp->ibqp.device); in ipath_do_send()
642 int (*make_req)(struct ipath_qp *qp); in ipath_do_send()
645 if ((qp->ibqp.qp_type == IB_QPT_RC || in ipath_do_send()
646 qp->ibqp.qp_type == IB_QPT_UC) && in ipath_do_send()
647 qp->remote_ah_attr.dlid == dev->dd->ipath_lid) { in ipath_do_send()
648 ipath_ruc_loopback(qp); in ipath_do_send()
652 if (qp->ibqp.qp_type == IB_QPT_RC) in ipath_do_send()
654 else if (qp->ibqp.qp_type == IB_QPT_UC) in ipath_do_send()
659 spin_lock_irqsave(&qp->s_lock, flags); in ipath_do_send()
662 if ((qp->s_flags & (IPATH_S_BUSY | IPATH_S_ANY_WAIT)) || in ipath_do_send()
663 !(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_OR_FLUSH_SEND)) { in ipath_do_send()
664 spin_unlock_irqrestore(&qp->s_lock, flags); in ipath_do_send()
668 qp->s_flags |= IPATH_S_BUSY; in ipath_do_send()
670 spin_unlock_irqrestore(&qp->s_lock, flags); in ipath_do_send()
674 if (qp->s_hdrwords != 0) { in ipath_do_send()
679 if (ipath_verbs_send(qp, &qp->s_hdr, qp->s_hdrwords, in ipath_do_send()
680 qp->s_cur_sge, qp->s_cur_size)) { in ipath_do_send()
681 if (ipath_no_bufs_available(qp, dev)) in ipath_do_send()
686 qp->s_hdrwords = 0; in ipath_do_send()
689 if (make_req(qp)) in ipath_do_send()
698 void ipath_send_complete(struct ipath_qp *qp, struct ipath_swqe *wqe, in ipath_send_complete() argument
703 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_OR_FLUSH_SEND)) in ipath_send_complete()
707 if (!(qp->s_flags & IPATH_S_SIGNAL_REQ_WR) || in ipath_send_complete()
716 wc.qp = &qp->ibqp; in ipath_send_complete()
719 ipath_cq_enter(to_icq(qp->ibqp.send_cq), &wc, in ipath_send_complete()
723 old_last = last = qp->s_last; in ipath_send_complete()
724 if (++last >= qp->s_size) in ipath_send_complete()
726 qp->s_last = last; in ipath_send_complete()
727 if (qp->s_cur == old_last) in ipath_send_complete()
728 qp->s_cur = last; in ipath_send_complete()
729 if (qp->s_tail == old_last) in ipath_send_complete()
730 qp->s_tail = last; in ipath_send_complete()
731 if (qp->state == IB_QPS_SQD && last == qp->s_cur) in ipath_send_complete()
732 qp->s_draining = 0; in ipath_send_complete()