Lines Matching refs:qp

16 #include "qp.h"
24 static void flush_tx_list(struct rvt_qp *qp);
33 static void qp_pio_drain(struct rvt_qp *qp);
122 static void flush_tx_list(struct rvt_qp *qp)
124 struct hfi1_qp_priv *priv = qp->priv;
130 static void flush_iowait(struct rvt_qp *qp)
132 struct hfi1_qp_priv *priv = qp->priv;
142 rvt_put_qp(qp);
160 int hfi1_check_modify_qp(struct rvt_qp *qp, struct ib_qp_attr *attr,
163 struct ib_qp *ibqp = &qp->ibqp;
173 if (!qp_to_sdma_engine(qp, sc) &&
177 if (!qp_to_send_context(qp, sc))
186 if (!qp_to_sdma_engine(qp, sc) &&
190 if (!qp_to_send_context(qp, sc))
202 static inline void qp_set_16b(struct rvt_qp *qp)
206 struct hfi1_qp_priv *priv = qp->priv;
209 hfi1_update_ah_attr(qp->ibqp.device, &qp->remote_ah_attr);
212 hfi1_make_opa_lid(&qp->remote_ah_attr);
214 if (!(rdma_ah_get_ah_flags(&qp->remote_ah_attr) & IB_AH_GRH))
217 ibp = to_iport(qp->ibqp.device, qp->port_num);
219 priv->hdr_type = hfi1_get_hdr_type(ppd->lid, &qp->remote_ah_attr);
222 void hfi1_modify_qp(struct rvt_qp *qp, struct ib_qp_attr *attr,
225 struct ib_qp *ibqp = &qp->ibqp;
226 struct hfi1_qp_priv *priv = qp->priv;
229 priv->s_sc = ah_to_sc(ibqp->device, &qp->remote_ah_attr);
230 priv->s_sde = qp_to_sdma_engine(qp, priv->s_sc);
231 priv->s_sendcontext = qp_to_send_context(qp, priv->s_sc);
232 qp_set_16b(qp);
237 qp->s_mig_state == IB_MIG_ARMED) {
238 qp->s_flags |= HFI1_S_AHG_CLEAR;
239 priv->s_sc = ah_to_sc(ibqp->device, &qp->remote_ah_attr);
240 priv->s_sde = qp_to_sdma_engine(qp, priv->s_sc);
241 priv->s_sendcontext = qp_to_send_context(qp, priv->s_sc);
242 qp_set_16b(qp);
245 opfn_qp_init(qp, attr, attr_mask);
250 * @qp: The qp
263 int hfi1_setup_wqe(struct rvt_qp *qp, struct rvt_swqe *wqe, bool *call_send)
265 struct hfi1_ibport *ibp = to_iport(qp->ibqp.device, qp->port_num);
270 switch (qp->ibqp.qp_type) {
272 hfi1_setup_tid_rdma_wqe(qp, wqe);
277 if (wqe->length > qp->pmtu)
316 * @qp: the QP
318 * This schedules qp progress w/o regard to the s_flags.
323 bool _hfi1_schedule_send(struct rvt_qp *qp)
325 struct hfi1_qp_priv *priv = qp->priv;
327 to_iport(qp->ibqp.device, qp->port_num);
340 static void qp_pio_drain(struct rvt_qp *qp)
342 struct hfi1_qp_priv *priv = qp->priv;
359 * @qp: the QP
361 * This schedules qp progress and caller should hold
366 bool hfi1_schedule_send(struct rvt_qp *qp)
368 lockdep_assert_held(&qp->s_lock);
369 if (hfi1_send_ok(qp)) {
370 _hfi1_schedule_send(qp);
373 if (qp->s_flags & HFI1_S_ANY_WAIT_IO)
374 iowait_set_flag(&((struct hfi1_qp_priv *)qp->priv)->s_iowait,
379 static void hfi1_qp_schedule(struct rvt_qp *qp)
381 struct hfi1_qp_priv *priv = qp->priv;
385 ret = hfi1_schedule_send(qp);
390 ret = hfi1_schedule_tid_send(qp);
396 void hfi1_qp_wakeup(struct rvt_qp *qp, u32 flag)
400 spin_lock_irqsave(&qp->s_lock, flags);
401 if (qp->s_flags & flag) {
402 qp->s_flags &= ~flag;
403 trace_hfi1_qpwakeup(qp, flag);
404 hfi1_qp_schedule(qp);
406 spin_unlock_irqrestore(&qp->s_lock, flags);
408 rvt_put_qp(qp);
411 void hfi1_qp_unbusy(struct rvt_qp *qp, struct iowait_work *wait)
413 struct hfi1_qp_priv *priv = qp->priv;
416 qp->s_flags &= ~RVT_S_BUSY;
420 * avoid a race condition when the qp wakes up before
444 struct rvt_qp *qp;
449 qp = tx->qp;
450 priv = qp->priv;
452 spin_lock_irqsave(&qp->s_lock, flags);
453 if (ib_rvt_state_ops[qp->state] & RVT_PROCESS_RECV_OK) {
466 to_iport(qp->ibqp.device, qp->port_num);
469 qp->s_flags |= RVT_S_WAIT_DMA_DESC;
474 trace_hfi1_qpsleep(qp, RVT_S_WAIT_DMA_DESC);
475 rvt_get_qp(qp);
478 hfi1_qp_unbusy(qp, wait);
479 spin_unlock_irqrestore(&qp->s_lock, flags);
482 spin_unlock_irqrestore(&qp->s_lock, flags);
488 spin_unlock_irqrestore(&qp->s_lock, flags);
495 struct rvt_qp *qp = iowait_to_qp(wait);
498 hfi1_qp_wakeup(qp, RVT_S_WAIT_DMA_DESC);
503 struct rvt_qp *qp = iowait_to_qp(wait);
512 spin_lock_irqsave(&qp->s_lock, flags);
513 if (qp->s_flags & RVT_S_WAIT_DMA) {
514 qp->s_flags &= ~RVT_S_WAIT_DMA;
515 hfi1_schedule_send(qp);
517 spin_unlock_irqrestore(&qp->s_lock, flags);
522 struct rvt_qp *qp = iowait_to_qp(w);
523 struct hfi1_qp_priv *priv = qp->priv;
525 if (qp->s_flags & RVT_S_ACK_PENDING)
532 * qp_to_sdma_engine - map a qp to a send engine
533 * @qp: the QP
537 * A send engine for the qp or NULL for SMI type qp.
539 struct sdma_engine *qp_to_sdma_engine(struct rvt_qp *qp, u8 sc5)
541 struct hfi1_devdata *dd = dd_from_ibdev(qp->ibqp.device);
546 switch (qp->ibqp.qp_type) {
552 sde = sdma_select_engine_sc(dd, qp->ibqp.qp_num >> dd->qos_shift, sc5);
557 * qp_to_send_context - map a qp to a send context
558 * @qp: the QP
562 * A send context for the qp
564 struct send_context *qp_to_send_context(struct rvt_qp *qp, u8 sc5)
566 struct hfi1_devdata *dd = dd_from_ibdev(qp->ibqp.device);
568 switch (qp->ibqp.qp_type) {
576 return pio_select_send_context_sc(dd, qp->ibqp.qp_num >> dd->qos_shift,
584 static int qp_idle(struct rvt_qp *qp)
587 qp->s_last == qp->s_acked &&
588 qp->s_acked == qp->s_cur &&
589 qp->s_cur == qp->s_tail &&
590 qp->s_tail == qp->s_head;
594 * qp_iter_print - print the qp information to seq_file
595 * @s: the seq_file to emit the qp information on
596 * @iter: the iterator for the qp hash list
601 struct rvt_qp *qp = iter->qp;
602 struct hfi1_qp_priv *priv = qp->priv;
606 struct rvt_srq *srq = qp->ibqp.srq ?
607 ibsrq_to_rvtsrq(qp->ibqp.srq) : NULL;
609 sde = qp_to_sdma_engine(qp, priv->s_sc);
610 wqe = rvt_get_swqe_ptr(qp, qp->s_last);
611 send_context = qp_to_send_context(qp, priv->s_sc);
612 if (qp->s_ack_queue)
613 e = &qp->s_ack_queue[qp->s_tail_ack_queue];
617 qp_idle(qp) ? "I" : "B",
618 qp->ibqp.qp_num,
619 atomic_read(&qp->refcount),
620 qp_type_str[qp->ibqp.qp_type],
621 qp->state,
623 qp->s_flags,
627 qp->timeout,
629 qp->s_lsn,
630 qp->s_last_psn,
631 qp->s_psn, qp->s_next_psn,
632 qp->s_sending_psn, qp->s_sending_hpsn,
633 qp->r_psn,
634 qp->s_last, qp->s_acked, qp->s_cur,
635 qp->s_tail, qp->s_head, qp->s_size,
636 qp->s_avail,
638 qp->s_tail_ack_queue, qp->r_head_ack_queue,
639 rvt_max_atomic(&to_idev(qp->ibqp.device)->rdi),
641 qp->remote_qpn,
642 rdma_ah_get_dlid(&qp->remote_ah_attr),
643 rdma_ah_get_sl(&qp->remote_ah_attr),
644 qp->pmtu,
645 qp->s_retry,
646 qp->s_retry_cnt,
647 qp->s_rnr_retry_cnt,
648 qp->s_rnr_retry,
653 ib_cq_head(qp->ibqp.send_cq),
654 ib_cq_tail(qp->ibqp.send_cq),
655 qp->pid,
656 qp->s_state,
657 qp->s_ack_state,
662 qp->r_min_rnr_timer,
664 srq ? srq->rq.size : qp->r_rq.size
668 void *qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp)
676 priv->owner = qp;
698 void qp_priv_free(struct rvt_dev_info *rdi, struct rvt_qp *qp)
700 struct hfi1_qp_priv *priv = qp->priv;
702 hfi1_qp_priv_tid_free(rdi, qp);
722 if (rcu_dereference(ibp->rvp.qp[0]))
724 if (rcu_dereference(ibp->rvp.qp[1]))
732 void flush_qp_waiters(struct rvt_qp *qp)
734 lockdep_assert_held(&qp->s_lock);
735 flush_iowait(qp);
736 hfi1_tid_rdma_flush_wait(qp);
739 void stop_send_queue(struct rvt_qp *qp)
741 struct hfi1_qp_priv *priv = qp->priv;
745 rvt_put_qp(qp);
748 void quiesce_qp(struct rvt_qp *qp)
750 struct hfi1_qp_priv *priv = qp->priv;
752 hfi1_del_tid_reap_timer(qp);
753 hfi1_del_tid_retry_timer(qp);
755 qp_pio_drain(qp);
756 flush_tx_list(qp);
759 void notify_qp_reset(struct rvt_qp *qp)
761 hfi1_qp_kern_exp_rcv_clear_all(qp);
762 qp->r_adefered = 0;
763 clear_ahg(qp);
766 if (qp->ibqp.qp_type == IB_QPT_RC)
767 opfn_conn_error(qp);
774 void hfi1_migrate_qp(struct rvt_qp *qp)
776 struct hfi1_qp_priv *priv = qp->priv;
779 qp->s_mig_state = IB_MIG_MIGRATED;
780 qp->remote_ah_attr = qp->alt_ah_attr;
781 qp->port_num = rdma_ah_get_port_num(&qp->alt_ah_attr);
782 qp->s_pkey_index = qp->s_alt_pkey_index;
783 qp->s_flags |= HFI1_S_AHG_CLEAR;
784 priv->s_sc = ah_to_sc(qp->ibqp.device, &qp->remote_ah_attr);
785 priv->s_sde = qp_to_sdma_engine(qp, priv->s_sc);
786 qp_set_16b(qp);
788 ev.device = qp->ibqp.device;
789 ev.element.qp = &qp->ibqp;
791 qp->ibqp.event_handler(&ev, qp->ibqp.qp_context);
799 u32 mtu_from_qp(struct rvt_dev_info *rdi, struct rvt_qp *qp, u32 pmtu)
811 ibp = &dd->pport[qp->port_num - 1].ibport_data;
812 sc = ibp->sl_to_sc[rdma_ah_get_sl(&qp->remote_ah_attr)];
815 mtu = verbs_mtu_enum_to_int(qp->ibqp.device, pmtu);
821 int get_pmtu_from_attr(struct rvt_dev_info *rdi, struct rvt_qp *qp,
824 int mtu, pidx = qp->port_num - 1;
831 mtu = verbs_mtu_enum_to_int(qp->ibqp.device, attr->path_mtu);
841 void notify_error_qp(struct rvt_qp *qp)
843 struct hfi1_qp_priv *priv = qp->priv;
849 !(qp->s_flags & RVT_S_BUSY) &&
851 qp->s_flags &= ~HFI1_S_ANY_WAIT_IO;
856 rvt_put_qp(qp);
861 if (!(qp->s_flags & RVT_S_BUSY) && !(priv->s_flags & RVT_S_BUSY)) {
862 qp->s_hdrwords = 0;
863 if (qp->s_rdma_mr) {
864 rvt_put_mr(qp->s_rdma_mr);
865 qp->s_rdma_mr = NULL;
867 flush_tx_list(qp);
873 * @qp: the qp
877 * on an individual qp.
879 static void hfi1_qp_iter_cb(struct rvt_qp *qp, u64 v)
884 to_iport(qp->ibqp.device, qp->port_num);
888 if (qp->port_num != ppd->port ||
889 (qp->ibqp.qp_type != IB_QPT_UC &&
890 qp->ibqp.qp_type != IB_QPT_RC) ||
891 rdma_ah_get_sl(&qp->remote_ah_attr) != sl ||
892 !(ib_rvt_state_ops[qp->state] & RVT_POST_SEND_OK))
895 spin_lock_irq(&qp->r_lock);
896 spin_lock(&qp->s_hlock);
897 spin_lock(&qp->s_lock);
898 lastwqe = rvt_error_qp(qp, IB_WC_WR_FLUSH_ERR);
899 spin_unlock(&qp->s_lock);
900 spin_unlock(&qp->s_hlock);
901 spin_unlock_irq(&qp->r_lock);
903 ev.device = qp->ibqp.device;
904 ev.element.qp = &qp->ibqp;
906 qp->ibqp.event_handler(&ev, qp->ibqp.qp_context);