Lines Matching refs:qp

58 #include "qp.h"
66 static void flush_tx_list(struct rvt_qp *qp);
75 static void qp_pio_drain(struct rvt_qp *qp);
164 static void flush_tx_list(struct rvt_qp *qp)
166 struct hfi1_qp_priv *priv = qp->priv;
172 static void flush_iowait(struct rvt_qp *qp)
174 struct hfi1_qp_priv *priv = qp->priv;
184 rvt_put_qp(qp);
202 int hfi1_check_modify_qp(struct rvt_qp *qp, struct ib_qp_attr *attr,
205 struct ib_qp *ibqp = &qp->ibqp;
215 if (!qp_to_sdma_engine(qp, sc) &&
219 if (!qp_to_send_context(qp, sc))
228 if (!qp_to_sdma_engine(qp, sc) &&
232 if (!qp_to_send_context(qp, sc))
244 static inline void qp_set_16b(struct rvt_qp *qp)
248 struct hfi1_qp_priv *priv = qp->priv;
251 hfi1_update_ah_attr(qp->ibqp.device, &qp->remote_ah_attr);
254 hfi1_make_opa_lid(&qp->remote_ah_attr);
256 if (!(rdma_ah_get_ah_flags(&qp->remote_ah_attr) & IB_AH_GRH))
259 ibp = to_iport(qp->ibqp.device, qp->port_num);
261 priv->hdr_type = hfi1_get_hdr_type(ppd->lid, &qp->remote_ah_attr);
264 void hfi1_modify_qp(struct rvt_qp *qp, struct ib_qp_attr *attr,
267 struct ib_qp *ibqp = &qp->ibqp;
268 struct hfi1_qp_priv *priv = qp->priv;
271 priv->s_sc = ah_to_sc(ibqp->device, &qp->remote_ah_attr);
272 priv->s_sde = qp_to_sdma_engine(qp, priv->s_sc);
273 priv->s_sendcontext = qp_to_send_context(qp, priv->s_sc);
274 qp_set_16b(qp);
279 qp->s_mig_state == IB_MIG_ARMED) {
280 qp->s_flags |= HFI1_S_AHG_CLEAR;
281 priv->s_sc = ah_to_sc(ibqp->device, &qp->remote_ah_attr);
282 priv->s_sde = qp_to_sdma_engine(qp, priv->s_sc);
283 priv->s_sendcontext = qp_to_send_context(qp, priv->s_sc);
284 qp_set_16b(qp);
287 opfn_qp_init(qp, attr, attr_mask);
292 * @qp - The qp
305 int hfi1_setup_wqe(struct rvt_qp *qp, struct rvt_swqe *wqe, bool *call_send)
307 struct hfi1_ibport *ibp = to_iport(qp->ibqp.device, qp->port_num);
312 switch (qp->ibqp.qp_type) {
314 hfi1_setup_tid_rdma_wqe(qp, wqe);
319 if (wqe->length > qp->pmtu)
357 * @qp: the QP
359 * This schedules qp progress w/o regard to the s_flags.
364 bool _hfi1_schedule_send(struct rvt_qp *qp)
366 struct hfi1_qp_priv *priv = qp->priv;
368 to_iport(qp->ibqp.device, qp->port_num);
381 static void qp_pio_drain(struct rvt_qp *qp)
383 struct hfi1_qp_priv *priv = qp->priv;
400 * @qp: the QP
402 * This schedules qp progress and caller should hold
407 bool hfi1_schedule_send(struct rvt_qp *qp)
409 lockdep_assert_held(&qp->s_lock);
410 if (hfi1_send_ok(qp)) {
411 _hfi1_schedule_send(qp);
414 if (qp->s_flags & HFI1_S_ANY_WAIT_IO)
415 iowait_set_flag(&((struct hfi1_qp_priv *)qp->priv)->s_iowait,
420 static void hfi1_qp_schedule(struct rvt_qp *qp)
422 struct hfi1_qp_priv *priv = qp->priv;
426 ret = hfi1_schedule_send(qp);
431 ret = hfi1_schedule_tid_send(qp);
437 void hfi1_qp_wakeup(struct rvt_qp *qp, u32 flag)
441 spin_lock_irqsave(&qp->s_lock, flags);
442 if (qp->s_flags & flag) {
443 qp->s_flags &= ~flag;
444 trace_hfi1_qpwakeup(qp, flag);
445 hfi1_qp_schedule(qp);
447 spin_unlock_irqrestore(&qp->s_lock, flags);
449 rvt_put_qp(qp);
452 void hfi1_qp_unbusy(struct rvt_qp *qp, struct iowait_work *wait)
454 struct hfi1_qp_priv *priv = qp->priv;
457 qp->s_flags &= ~RVT_S_BUSY;
461 * avoid a race condition when the qp wakes up before
485 struct rvt_qp *qp;
490 qp = tx->qp;
491 priv = qp->priv;
493 spin_lock_irqsave(&qp->s_lock, flags);
494 if (ib_rvt_state_ops[qp->state] & RVT_PROCESS_RECV_OK) {
507 to_iport(qp->ibqp.device, qp->port_num);
510 qp->s_flags |= RVT_S_WAIT_DMA_DESC;
515 trace_hfi1_qpsleep(qp, RVT_S_WAIT_DMA_DESC);
516 rvt_get_qp(qp);
519 hfi1_qp_unbusy(qp, wait);
520 spin_unlock_irqrestore(&qp->s_lock, flags);
523 spin_unlock_irqrestore(&qp->s_lock, flags);
529 spin_unlock_irqrestore(&qp->s_lock, flags);
536 struct rvt_qp *qp = iowait_to_qp(wait);
539 hfi1_qp_wakeup(qp, RVT_S_WAIT_DMA_DESC);
544 struct rvt_qp *qp = iowait_to_qp(wait);
553 spin_lock_irqsave(&qp->s_lock, flags);
554 if (qp->s_flags & RVT_S_WAIT_DMA) {
555 qp->s_flags &= ~RVT_S_WAIT_DMA;
556 hfi1_schedule_send(qp);
558 spin_unlock_irqrestore(&qp->s_lock, flags);
563 struct rvt_qp *qp = iowait_to_qp(w);
564 struct hfi1_qp_priv *priv = qp->priv;
566 if (qp->s_flags & RVT_S_ACK_PENDING)
573 * qp_to_sdma_engine - map a qp to a send engine
574 * @qp: the QP
578 * A send engine for the qp or NULL for SMI type qp.
580 struct sdma_engine *qp_to_sdma_engine(struct rvt_qp *qp, u8 sc5)
582 struct hfi1_devdata *dd = dd_from_ibdev(qp->ibqp.device);
587 switch (qp->ibqp.qp_type) {
593 sde = sdma_select_engine_sc(dd, qp->ibqp.qp_num >> dd->qos_shift, sc5);
598 * qp_to_send_context - map a qp to a send context
599 * @qp: the QP
603 * A send context for the qp
605 struct send_context *qp_to_send_context(struct rvt_qp *qp, u8 sc5)
607 struct hfi1_devdata *dd = dd_from_ibdev(qp->ibqp.device);
609 switch (qp->ibqp.qp_type) {
617 return pio_select_send_context_sc(dd, qp->ibqp.qp_num >> dd->qos_shift,
625 static int qp_idle(struct rvt_qp *qp)
628 qp->s_last == qp->s_acked &&
629 qp->s_acked == qp->s_cur &&
630 qp->s_cur == qp->s_tail &&
631 qp->s_tail == qp->s_head;
635 * qp_iter_print - print the qp information to seq_file
636 * @s: the seq_file to emit the qp information on
637 * @iter: the iterator for the qp hash list
642 struct rvt_qp *qp = iter->qp;
643 struct hfi1_qp_priv *priv = qp->priv;
647 struct rvt_srq *srq = qp->ibqp.srq ?
648 ibsrq_to_rvtsrq(qp->ibqp.srq) : NULL;
650 sde = qp_to_sdma_engine(qp, priv->s_sc);
651 wqe = rvt_get_swqe_ptr(qp, qp->s_last);
652 send_context = qp_to_send_context(qp, priv->s_sc);
653 if (qp->s_ack_queue)
654 e = &qp->s_ack_queue[qp->s_tail_ack_queue];
658 qp_idle(qp) ? "I" : "B",
659 qp->ibqp.qp_num,
660 atomic_read(&qp->refcount),
661 qp_type_str[qp->ibqp.qp_type],
662 qp->state,
664 qp->s_flags,
668 qp->timeout,
670 qp->s_lsn,
671 qp->s_last_psn,
672 qp->s_psn, qp->s_next_psn,
673 qp->s_sending_psn, qp->s_sending_hpsn,
674 qp->r_psn,
675 qp->s_last, qp->s_acked, qp->s_cur,
676 qp->s_tail, qp->s_head, qp->s_size,
677 qp->s_avail,
679 qp->s_tail_ack_queue, qp->r_head_ack_queue,
680 rvt_max_atomic(&to_idev(qp->ibqp.device)->rdi),
682 qp->remote_qpn,
683 rdma_ah_get_dlid(&qp->remote_ah_attr),
684 rdma_ah_get_sl(&qp->remote_ah_attr),
685 qp->pmtu,
686 qp->s_retry,
687 qp->s_retry_cnt,
688 qp->s_rnr_retry_cnt,
689 qp->s_rnr_retry,
694 ib_cq_head(qp->ibqp.send_cq),
695 ib_cq_tail(qp->ibqp.send_cq),
696 qp->pid,
697 qp->s_state,
698 qp->s_ack_state,
703 qp->r_min_rnr_timer,
705 srq ? srq->rq.size : qp->r_rq.size
709 void *qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp)
717 priv->owner = qp;
739 void qp_priv_free(struct rvt_dev_info *rdi, struct rvt_qp *qp)
741 struct hfi1_qp_priv *priv = qp->priv;
743 hfi1_qp_priv_tid_free(rdi, qp);
763 if (rcu_dereference(ibp->rvp.qp[0]))
765 if (rcu_dereference(ibp->rvp.qp[1]))
773 void flush_qp_waiters(struct rvt_qp *qp)
775 lockdep_assert_held(&qp->s_lock);
776 flush_iowait(qp);
777 hfi1_tid_rdma_flush_wait(qp);
780 void stop_send_queue(struct rvt_qp *qp)
782 struct hfi1_qp_priv *priv = qp->priv;
786 rvt_put_qp(qp);
789 void quiesce_qp(struct rvt_qp *qp)
791 struct hfi1_qp_priv *priv = qp->priv;
793 hfi1_del_tid_reap_timer(qp);
794 hfi1_del_tid_retry_timer(qp);
796 qp_pio_drain(qp);
797 flush_tx_list(qp);
800 void notify_qp_reset(struct rvt_qp *qp)
802 hfi1_qp_kern_exp_rcv_clear_all(qp);
803 qp->r_adefered = 0;
804 clear_ahg(qp);
807 if (qp->ibqp.qp_type == IB_QPT_RC)
808 opfn_conn_error(qp);
815 void hfi1_migrate_qp(struct rvt_qp *qp)
817 struct hfi1_qp_priv *priv = qp->priv;
820 qp->s_mig_state = IB_MIG_MIGRATED;
821 qp->remote_ah_attr = qp->alt_ah_attr;
822 qp->port_num = rdma_ah_get_port_num(&qp->alt_ah_attr);
823 qp->s_pkey_index = qp->s_alt_pkey_index;
824 qp->s_flags |= HFI1_S_AHG_CLEAR;
825 priv->s_sc = ah_to_sc(qp->ibqp.device, &qp->remote_ah_attr);
826 priv->s_sde = qp_to_sdma_engine(qp, priv->s_sc);
827 qp_set_16b(qp);
829 ev.device = qp->ibqp.device;
830 ev.element.qp = &qp->ibqp;
832 qp->ibqp.event_handler(&ev, qp->ibqp.qp_context);
840 u32 mtu_from_qp(struct rvt_dev_info *rdi, struct rvt_qp *qp, u32 pmtu)
852 ibp = &dd->pport[qp->port_num - 1].ibport_data;
853 sc = ibp->sl_to_sc[rdma_ah_get_sl(&qp->remote_ah_attr)];
856 mtu = verbs_mtu_enum_to_int(qp->ibqp.device, pmtu);
862 int get_pmtu_from_attr(struct rvt_dev_info *rdi, struct rvt_qp *qp,
865 int mtu, pidx = qp->port_num - 1;
872 mtu = verbs_mtu_enum_to_int(qp->ibqp.device, attr->path_mtu);
882 void notify_error_qp(struct rvt_qp *qp)
884 struct hfi1_qp_priv *priv = qp->priv;
890 !(qp->s_flags & RVT_S_BUSY) &&
892 qp->s_flags &= ~HFI1_S_ANY_WAIT_IO;
897 rvt_put_qp(qp);
902 if (!(qp->s_flags & RVT_S_BUSY) && !(priv->s_flags & RVT_S_BUSY)) {
903 qp->s_hdrwords = 0;
904 if (qp->s_rdma_mr) {
905 rvt_put_mr(qp->s_rdma_mr);
906 qp->s_rdma_mr = NULL;
908 flush_tx_list(qp);
914 * @qp - the qp
918 * on an individual qp.
920 static void hfi1_qp_iter_cb(struct rvt_qp *qp, u64 v)
925 to_iport(qp->ibqp.device, qp->port_num);
929 if (qp->port_num != ppd->port ||
930 (qp->ibqp.qp_type != IB_QPT_UC &&
931 qp->ibqp.qp_type != IB_QPT_RC) ||
932 rdma_ah_get_sl(&qp->remote_ah_attr) != sl ||
933 !(ib_rvt_state_ops[qp->state] & RVT_POST_SEND_OK))
936 spin_lock_irq(&qp->r_lock);
937 spin_lock(&qp->s_hlock);
938 spin_lock(&qp->s_lock);
939 lastwqe = rvt_error_qp(qp, IB_WC_WR_FLUSH_ERR);
940 spin_unlock(&qp->s_lock);
941 spin_unlock(&qp->s_hlock);
942 spin_unlock_irq(&qp->r_lock);
944 ev.device = qp->ibqp.device;
945 ev.element.qp = &qp->ibqp;
947 qp->ibqp.event_handler(&ev, qp->ibqp.qp_context);