• Home
  • Raw
  • Download

Lines Matching full:qp

57 #include "qp.h"
64 static void rvt_reset_qp(struct rvt_dev_info *rdi, struct rvt_qp *qp,
325 * init_qpn_table - initialize the QP number table for a device
381 * free_qpn_table - free the QP number table for a device
393 * rvt_driver_qp_init - Init driver qp resources
407 * If driver is not doing any QP allocation then make sure it is in rvt_driver_qp_init()
408 * providing the necessary QP functions. in rvt_driver_qp_init()
457 * rvt_free_qp_cb - callback function to reset a qp
458 * @qp: the qp to reset
461 * This function resets the qp and removes it from the
462 * qp hash table.
464 static void rvt_free_qp_cb(struct rvt_qp *qp, u64 v) in rvt_free_qp_cb() argument
467 struct rvt_dev_info *rdi = ib_to_rvt(qp->ibqp.device); in rvt_free_qp_cb()
469 /* Reset the qp and remove it from the qp hash list */ in rvt_free_qp_cb()
470 rvt_reset_qp(rdi, qp, qp->ibqp.qp_type); in rvt_free_qp_cb()
499 * Check for qp leaks and free resources.
506 rvt_pr_err(rdi, "QP memory leak! %u still in use\n", in rvt_qp_exit()
521 * alloc_qpn - Allocate the next available qpn or zero/one for QP type
616 * @qp: rvt qp data structure
619 static void rvt_clear_mr_refs(struct rvt_qp *qp, int clr_sends) in rvt_clear_mr_refs() argument
622 struct rvt_dev_info *rdi = ib_to_rvt(qp->ibqp.device); in rvt_clear_mr_refs()
624 if (test_and_clear_bit(RVT_R_REWIND_SGE, &qp->r_aflags)) in rvt_clear_mr_refs()
625 rvt_put_ss(&qp->s_rdma_read_sge); in rvt_clear_mr_refs()
627 rvt_put_ss(&qp->r_sge); in rvt_clear_mr_refs()
630 while (qp->s_last != qp->s_head) { in rvt_clear_mr_refs()
631 struct rvt_swqe *wqe = rvt_get_swqe_ptr(qp, qp->s_last); in rvt_clear_mr_refs()
633 rvt_put_qp_swqe(qp, wqe); in rvt_clear_mr_refs()
634 if (++qp->s_last >= qp->s_size) in rvt_clear_mr_refs()
635 qp->s_last = 0; in rvt_clear_mr_refs()
638 if (qp->s_rdma_mr) { in rvt_clear_mr_refs()
639 rvt_put_mr(qp->s_rdma_mr); in rvt_clear_mr_refs()
640 qp->s_rdma_mr = NULL; in rvt_clear_mr_refs()
644 for (n = 0; qp->s_ack_queue && n < rvt_max_atomic(rdi); n++) { in rvt_clear_mr_refs()
645 struct rvt_ack_entry *e = &qp->s_ack_queue[n]; in rvt_clear_mr_refs()
675 * rvt_qp_sends_has_lkey - return true is qp sends use lkey
676 * @qp - the rvt_qp
679 static bool rvt_qp_sends_has_lkey(struct rvt_qp *qp, u32 lkey) in rvt_qp_sends_has_lkey() argument
681 u32 s_last = qp->s_last; in rvt_qp_sends_has_lkey()
683 while (s_last != qp->s_head) { in rvt_qp_sends_has_lkey()
684 struct rvt_swqe *wqe = rvt_get_swqe_ptr(qp, s_last); in rvt_qp_sends_has_lkey()
689 if (++s_last >= qp->s_size) in rvt_qp_sends_has_lkey()
692 if (qp->s_rdma_mr) in rvt_qp_sends_has_lkey()
693 if (rvt_mr_has_lkey(qp->s_rdma_mr, lkey)) in rvt_qp_sends_has_lkey()
700 * @qp - the qp
703 static bool rvt_qp_acks_has_lkey(struct rvt_qp *qp, u32 lkey) in rvt_qp_acks_has_lkey() argument
706 struct rvt_dev_info *rdi = ib_to_rvt(qp->ibqp.device); in rvt_qp_acks_has_lkey()
708 for (i = 0; qp->s_ack_queue && i < rvt_max_atomic(rdi); i++) { in rvt_qp_acks_has_lkey()
709 struct rvt_ack_entry *e = &qp->s_ack_queue[i]; in rvt_qp_acks_has_lkey()
719 * @qp - the qp
723 * the qp.
725 * If so, the qp is put into an error state to elminate
726 * any references from the qp.
728 void rvt_qp_mr_clean(struct rvt_qp *qp, u32 lkey) in rvt_qp_mr_clean() argument
732 if (qp->ibqp.qp_type == IB_QPT_SMI || in rvt_qp_mr_clean()
733 qp->ibqp.qp_type == IB_QPT_GSI) in rvt_qp_mr_clean()
736 spin_lock_irq(&qp->r_lock); in rvt_qp_mr_clean()
737 spin_lock(&qp->s_hlock); in rvt_qp_mr_clean()
738 spin_lock(&qp->s_lock); in rvt_qp_mr_clean()
740 if (qp->state == IB_QPS_ERR || qp->state == IB_QPS_RESET) in rvt_qp_mr_clean()
743 if (rvt_ss_has_lkey(&qp->r_sge, lkey) || in rvt_qp_mr_clean()
744 rvt_qp_sends_has_lkey(qp, lkey) || in rvt_qp_mr_clean()
745 rvt_qp_acks_has_lkey(qp, lkey)) in rvt_qp_mr_clean()
746 lastwqe = rvt_error_qp(qp, IB_WC_LOC_PROT_ERR); in rvt_qp_mr_clean()
748 spin_unlock(&qp->s_lock); in rvt_qp_mr_clean()
749 spin_unlock(&qp->s_hlock); in rvt_qp_mr_clean()
750 spin_unlock_irq(&qp->r_lock); in rvt_qp_mr_clean()
754 ev.device = qp->ibqp.device; in rvt_qp_mr_clean()
755 ev.element.qp = &qp->ibqp; in rvt_qp_mr_clean()
757 qp->ibqp.event_handler(&ev, qp->ibqp.qp_context); in rvt_qp_mr_clean()
762 * rvt_remove_qp - remove qp form table
764 * @qp: qp to remove
766 * Remove the QP from the table so it can't be found asynchronously by
769 static void rvt_remove_qp(struct rvt_dev_info *rdi, struct rvt_qp *qp) in rvt_remove_qp() argument
771 struct rvt_ibport *rvp = rdi->ports[qp->port_num - 1]; in rvt_remove_qp()
772 u32 n = hash_32(qp->ibqp.qp_num, rdi->qp_dev->qp_table_bits); in rvt_remove_qp()
778 if (rcu_dereference_protected(rvp->qp[0], in rvt_remove_qp()
779 lockdep_is_held(&rdi->qp_dev->qpt_lock)) == qp) { in rvt_remove_qp()
780 RCU_INIT_POINTER(rvp->qp[0], NULL); in rvt_remove_qp()
781 } else if (rcu_dereference_protected(rvp->qp[1], in rvt_remove_qp()
782 lockdep_is_held(&rdi->qp_dev->qpt_lock)) == qp) { in rvt_remove_qp()
783 RCU_INIT_POINTER(rvp->qp[1], NULL); in rvt_remove_qp()
793 if (q == qp) { in rvt_remove_qp()
795 rcu_dereference_protected(qp->next, in rvt_remove_qp()
798 trace_rvt_qpremove(qp, n); in rvt_remove_qp()
807 rvt_put_qp(qp); in rvt_remove_qp()
853 * rvt_init_qp - initialize the QP state to the reset state
854 * @qp: the QP to init or reinit
855 * @type: the QP type
862 static void rvt_init_qp(struct rvt_dev_info *rdi, struct rvt_qp *qp, in rvt_init_qp() argument
865 qp->remote_qpn = 0; in rvt_init_qp()
866 qp->qkey = 0; in rvt_init_qp()
867 qp->qp_access_flags = 0; in rvt_init_qp()
868 qp->s_flags &= RVT_S_SIGNAL_REQ_WR; in rvt_init_qp()
869 qp->s_hdrwords = 0; in rvt_init_qp()
870 qp->s_wqe = NULL; in rvt_init_qp()
871 qp->s_draining = 0; in rvt_init_qp()
872 qp->s_next_psn = 0; in rvt_init_qp()
873 qp->s_last_psn = 0; in rvt_init_qp()
874 qp->s_sending_psn = 0; in rvt_init_qp()
875 qp->s_sending_hpsn = 0; in rvt_init_qp()
876 qp->s_psn = 0; in rvt_init_qp()
877 qp->r_psn = 0; in rvt_init_qp()
878 qp->r_msn = 0; in rvt_init_qp()
880 qp->s_state = IB_OPCODE_RC_SEND_LAST; in rvt_init_qp()
881 qp->r_state = IB_OPCODE_RC_SEND_LAST; in rvt_init_qp()
883 qp->s_state = IB_OPCODE_UC_SEND_LAST; in rvt_init_qp()
884 qp->r_state = IB_OPCODE_UC_SEND_LAST; in rvt_init_qp()
886 qp->s_ack_state = IB_OPCODE_RC_ACKNOWLEDGE; in rvt_init_qp()
887 qp->r_nak_state = 0; in rvt_init_qp()
888 qp->r_aflags = 0; in rvt_init_qp()
889 qp->r_flags = 0; in rvt_init_qp()
890 qp->s_head = 0; in rvt_init_qp()
891 qp->s_tail = 0; in rvt_init_qp()
892 qp->s_cur = 0; in rvt_init_qp()
893 qp->s_acked = 0; in rvt_init_qp()
894 qp->s_last = 0; in rvt_init_qp()
895 qp->s_ssn = 1; in rvt_init_qp()
896 qp->s_lsn = 0; in rvt_init_qp()
897 qp->s_mig_state = IB_MIG_MIGRATED; in rvt_init_qp()
898 qp->r_head_ack_queue = 0; in rvt_init_qp()
899 qp->s_tail_ack_queue = 0; in rvt_init_qp()
900 qp->s_acked_ack_queue = 0; in rvt_init_qp()
901 qp->s_num_rd_atomic = 0; in rvt_init_qp()
902 qp->r_sge.num_sge = 0; in rvt_init_qp()
903 atomic_set(&qp->s_reserved_used, 0); in rvt_init_qp()
907 * _rvt_reset_qp - initialize the QP state to the reset state
908 * @qp: the QP to reset
909 * @type: the QP type
913 static void _rvt_reset_qp(struct rvt_dev_info *rdi, struct rvt_qp *qp, in _rvt_reset_qp() argument
915 __must_hold(&qp->s_lock) in _rvt_reset_qp()
916 __must_hold(&qp->s_hlock) in _rvt_reset_qp()
917 __must_hold(&qp->r_lock) in _rvt_reset_qp()
919 lockdep_assert_held(&qp->r_lock); in _rvt_reset_qp()
920 lockdep_assert_held(&qp->s_hlock); in _rvt_reset_qp()
921 lockdep_assert_held(&qp->s_lock); in _rvt_reset_qp()
922 if (qp->state != IB_QPS_RESET) { in _rvt_reset_qp()
923 qp->state = IB_QPS_RESET; in _rvt_reset_qp()
926 rdi->driver_f.flush_qp_waiters(qp); in _rvt_reset_qp()
927 rvt_stop_rc_timers(qp); in _rvt_reset_qp()
928 qp->s_flags &= ~(RVT_S_TIMER | RVT_S_ANY_WAIT); in _rvt_reset_qp()
929 spin_unlock(&qp->s_lock); in _rvt_reset_qp()
930 spin_unlock(&qp->s_hlock); in _rvt_reset_qp()
931 spin_unlock_irq(&qp->r_lock); in _rvt_reset_qp()
934 rdi->driver_f.stop_send_queue(qp); in _rvt_reset_qp()
935 rvt_del_timers_sync(qp); in _rvt_reset_qp()
937 rdi->driver_f.quiesce_qp(qp); in _rvt_reset_qp()
939 /* take qp out the hash and wait for it to be unused */ in _rvt_reset_qp()
940 rvt_remove_qp(rdi, qp); in _rvt_reset_qp()
943 spin_lock_irq(&qp->r_lock); in _rvt_reset_qp()
944 spin_lock(&qp->s_hlock); in _rvt_reset_qp()
945 spin_lock(&qp->s_lock); in _rvt_reset_qp()
947 rvt_clear_mr_refs(qp, 1); in _rvt_reset_qp()
950 * a qp that has been reset in _rvt_reset_qp()
952 rdi->driver_f.notify_qp_reset(qp); in _rvt_reset_qp()
954 rvt_init_qp(rdi, qp, type); in _rvt_reset_qp()
955 lockdep_assert_held(&qp->r_lock); in _rvt_reset_qp()
956 lockdep_assert_held(&qp->s_hlock); in _rvt_reset_qp()
957 lockdep_assert_held(&qp->s_lock); in _rvt_reset_qp()
961 * rvt_reset_qp - initialize the QP state to the reset state
963 * @qp: the QP to reset
964 * @type: the QP type
969 static void rvt_reset_qp(struct rvt_dev_info *rdi, struct rvt_qp *qp, in rvt_reset_qp() argument
972 spin_lock_irq(&qp->r_lock); in rvt_reset_qp()
973 spin_lock(&qp->s_hlock); in rvt_reset_qp()
974 spin_lock(&qp->s_lock); in rvt_reset_qp()
975 _rvt_reset_qp(rdi, qp, type); in rvt_reset_qp()
976 spin_unlock(&qp->s_lock); in rvt_reset_qp()
977 spin_unlock(&qp->s_hlock); in rvt_reset_qp()
978 spin_unlock_irq(&qp->r_lock); in rvt_reset_qp()
982 * @qpt: QP table
998 * get_allowed_ops - Given a QP type return the appropriate allowed OP
999 * @type: valid, supported, QP type
1009 * @qp: Valid QP with allowed_ops set
1014 static void free_ud_wq_attr(struct rvt_qp *qp) in free_ud_wq_attr() argument
1019 for (i = 0; qp->allowed_ops == IB_OPCODE_UD && i < qp->s_size; i++) { in free_ud_wq_attr()
1020 wqe = rvt_get_swqe_ptr(qp, i); in free_ud_wq_attr()
1028 * @qp: Valid QP with allowed_ops set
1034 static int alloc_ud_wq_attr(struct rvt_qp *qp, int node) in alloc_ud_wq_attr() argument
1039 for (i = 0; qp->allowed_ops == IB_OPCODE_UD && i < qp->s_size; i++) { in alloc_ud_wq_attr()
1040 wqe = rvt_get_swqe_ptr(qp, i); in alloc_ud_wq_attr()
1044 free_ud_wq_attr(qp); in alloc_ud_wq_attr()
1070 struct rvt_qp *qp; in rvt_create_qp() local
1121 sz = sizeof(*qp); in rvt_create_qp()
1127 sg_list_sz = sizeof(*qp->r_sg_list) * in rvt_create_qp()
1130 sg_list_sz = sizeof(*qp->r_sg_list) * in rvt_create_qp()
1132 qp = kzalloc_node(sz + sg_list_sz, GFP_KERNEL, in rvt_create_qp()
1134 if (!qp) in rvt_create_qp()
1136 qp->allowed_ops = get_allowed_ops(init_attr->qp_type); in rvt_create_qp()
1138 RCU_INIT_POINTER(qp->next, NULL); in rvt_create_qp()
1140 qp->s_ack_queue = in rvt_create_qp()
1142 sizeof(*qp->s_ack_queue), in rvt_create_qp()
1145 if (!qp->s_ack_queue) in rvt_create_qp()
1148 /* initialize timers needed for rc qp */ in rvt_create_qp()
1149 timer_setup(&qp->s_timer, rvt_rc_timeout, 0); in rvt_create_qp()
1150 hrtimer_init(&qp->s_rnr_timer, CLOCK_MONOTONIC, in rvt_create_qp()
1152 qp->s_rnr_timer.function = rvt_rc_rnr_retry; in rvt_create_qp()
1155 * Driver needs to set up it's private QP structure and do any in rvt_create_qp()
1158 priv = rdi->driver_f.qp_priv_alloc(rdi, qp); in rvt_create_qp()
1163 qp->priv = priv; in rvt_create_qp()
1164 qp->timeout_jiffies = in rvt_create_qp()
1165 usecs_to_jiffies((4096UL * (1UL << qp->timeout)) / in rvt_create_qp()
1170 qp->r_rq.size = init_attr->cap.max_recv_wr + 1; in rvt_create_qp()
1171 qp->r_rq.max_sge = init_attr->cap.max_recv_sge; in rvt_create_qp()
1172 sz = (sizeof(struct ib_sge) * qp->r_rq.max_sge) + in rvt_create_qp()
1174 err = rvt_alloc_rq(&qp->r_rq, qp->r_rq.size * sz, in rvt_create_qp()
1183 * ib_create_qp() will initialize qp->ibqp in rvt_create_qp()
1184 * except for qp->ibqp.qp_num. in rvt_create_qp()
1186 spin_lock_init(&qp->r_lock); in rvt_create_qp()
1187 spin_lock_init(&qp->s_hlock); in rvt_create_qp()
1188 spin_lock_init(&qp->s_lock); in rvt_create_qp()
1189 atomic_set(&qp->refcount, 0); in rvt_create_qp()
1190 atomic_set(&qp->local_ops_pending, 0); in rvt_create_qp()
1191 init_waitqueue_head(&qp->wait); in rvt_create_qp()
1192 INIT_LIST_HEAD(&qp->rspwait); in rvt_create_qp()
1193 qp->state = IB_QPS_RESET; in rvt_create_qp()
1194 qp->s_wq = swq; in rvt_create_qp()
1195 qp->s_size = sqsize; in rvt_create_qp()
1196 qp->s_avail = init_attr->cap.max_send_wr; in rvt_create_qp()
1197 qp->s_max_sge = init_attr->cap.max_send_sge; in rvt_create_qp()
1199 qp->s_flags = RVT_S_SIGNAL_REQ_WR; in rvt_create_qp()
1200 err = alloc_ud_wq_attr(qp, rdi->dparms.node); in rvt_create_qp()
1217 qp->ibqp.qp_num = err; in rvt_create_qp()
1219 qp->ibqp.qp_num |= RVT_AIP_QP_BASE; in rvt_create_qp()
1220 qp->port_num = init_attr->port_num; in rvt_create_qp()
1221 rvt_init_qp(rdi, qp, init_attr->qp_type); in rvt_create_qp()
1223 err = rdi->driver_f.qp_priv_init(rdi, qp, init_attr); in rvt_create_qp()
1243 if (!qp->r_rq.wq) { in rvt_create_qp()
1253 u32 s = sizeof(struct rvt_rwq) + qp->r_rq.size * sz; in rvt_create_qp()
1255 qp->ip = rvt_create_mmap_info(rdi, s, udata, in rvt_create_qp()
1256 qp->r_rq.wq); in rvt_create_qp()
1257 if (IS_ERR(qp->ip)) { in rvt_create_qp()
1258 ret = ERR_CAST(qp->ip); in rvt_create_qp()
1262 err = ib_copy_to_udata(udata, &qp->ip->offset, in rvt_create_qp()
1263 sizeof(qp->ip->offset)); in rvt_create_qp()
1269 qp->pid = current->pid; in rvt_create_qp()
1285 * qps. busy_jiffies is incremented every rc qp scaling interval. in rvt_create_qp()
1295 if (qp->ip) { in rvt_create_qp()
1297 list_add(&qp->ip->pending_mmaps, &rdi->pending_mmaps); in rvt_create_qp()
1301 ret = &qp->ibqp; in rvt_create_qp()
1306 if (qp->ip) in rvt_create_qp()
1307 kref_put(&qp->ip->ref, rvt_release_mmap_info); in rvt_create_qp()
1310 rvt_free_qpn(&rdi->qp_dev->qpn_table, qp->ibqp.qp_num); in rvt_create_qp()
1313 free_ud_wq_attr(qp); in rvt_create_qp()
1316 rvt_free_rq(&qp->r_rq); in rvt_create_qp()
1319 rdi->driver_f.qp_priv_free(rdi, qp); in rvt_create_qp()
1322 kfree(qp->s_ack_queue); in rvt_create_qp()
1323 kfree(qp); in rvt_create_qp()
1332 * rvt_error_qp - put a QP into the error state
1333 * @qp: the QP to put into the error state
1339 * The QP r_lock and s_lock should be held and interrupts disabled.
1342 int rvt_error_qp(struct rvt_qp *qp, enum ib_wc_status err) in rvt_error_qp() argument
1346 struct rvt_dev_info *rdi = ib_to_rvt(qp->ibqp.device); in rvt_error_qp()
1348 lockdep_assert_held(&qp->r_lock); in rvt_error_qp()
1349 lockdep_assert_held(&qp->s_lock); in rvt_error_qp()
1350 if (qp->state == IB_QPS_ERR || qp->state == IB_QPS_RESET) in rvt_error_qp()
1353 qp->state = IB_QPS_ERR; in rvt_error_qp()
1355 if (qp->s_flags & (RVT_S_TIMER | RVT_S_WAIT_RNR)) { in rvt_error_qp()
1356 qp->s_flags &= ~(RVT_S_TIMER | RVT_S_WAIT_RNR); in rvt_error_qp()
1357 del_timer(&qp->s_timer); in rvt_error_qp()
1360 if (qp->s_flags & RVT_S_ANY_WAIT_SEND) in rvt_error_qp()
1361 qp->s_flags &= ~RVT_S_ANY_WAIT_SEND; in rvt_error_qp()
1363 rdi->driver_f.notify_error_qp(qp); in rvt_error_qp()
1366 if (READ_ONCE(qp->s_last) != qp->s_head) in rvt_error_qp()
1367 rdi->driver_f.schedule_send(qp); in rvt_error_qp()
1369 rvt_clear_mr_refs(qp, 0); in rvt_error_qp()
1372 wc.qp = &qp->ibqp; in rvt_error_qp()
1375 if (test_and_clear_bit(RVT_R_WRID_VALID, &qp->r_aflags)) { in rvt_error_qp()
1376 wc.wr_id = qp->r_wr_id; in rvt_error_qp()
1378 rvt_cq_enter(ibcq_to_rvtcq(qp->ibqp.recv_cq), &wc, 1); in rvt_error_qp()
1382 if (qp->r_rq.kwq) { in rvt_error_qp()
1388 spin_lock(&qp->r_rq.kwq->c_lock); in rvt_error_qp()
1389 /* qp->ip used to validate if there is a user buffer mmaped */ in rvt_error_qp()
1390 if (qp->ip) { in rvt_error_qp()
1391 wq = qp->r_rq.wq; in rvt_error_qp()
1395 kwq = qp->r_rq.kwq; in rvt_error_qp()
1400 if (head >= qp->r_rq.size) in rvt_error_qp()
1402 if (tail >= qp->r_rq.size) in rvt_error_qp()
1405 wc.wr_id = rvt_get_rwqe_ptr(&qp->r_rq, tail)->wr_id; in rvt_error_qp()
1406 if (++tail >= qp->r_rq.size) in rvt_error_qp()
1408 rvt_cq_enter(ibcq_to_rvtcq(qp->ibqp.recv_cq), &wc, 1); in rvt_error_qp()
1410 if (qp->ip) in rvt_error_qp()
1414 spin_unlock(&qp->r_rq.kwq->c_lock); in rvt_error_qp()
1415 } else if (qp->ibqp.event_handler) { in rvt_error_qp()
1425 * Put the QP into the hash table.
1426 * The hash table holds a reference to the QP.
1428 static void rvt_insert_qp(struct rvt_dev_info *rdi, struct rvt_qp *qp) in rvt_insert_qp() argument
1430 struct rvt_ibport *rvp = rdi->ports[qp->port_num - 1]; in rvt_insert_qp()
1433 rvt_get_qp(qp); in rvt_insert_qp()
1436 if (qp->ibqp.qp_num <= 1) { in rvt_insert_qp()
1437 rcu_assign_pointer(rvp->qp[qp->ibqp.qp_num], qp); in rvt_insert_qp()
1439 u32 n = hash_32(qp->ibqp.qp_num, rdi->qp_dev->qp_table_bits); in rvt_insert_qp()
1441 qp->next = rdi->qp_dev->qp_table[n]; in rvt_insert_qp()
1442 rcu_assign_pointer(rdi->qp_dev->qp_table[n], qp); in rvt_insert_qp()
1443 trace_rvt_qpinsert(qp, n); in rvt_insert_qp()
1462 struct rvt_qp *qp = ibqp_to_rvtqp(ibqp); in rvt_modify_qp() local
1470 spin_lock_irq(&qp->r_lock); in rvt_modify_qp()
1471 spin_lock(&qp->s_hlock); in rvt_modify_qp()
1472 spin_lock(&qp->s_lock); in rvt_modify_qp()
1475 attr->cur_qp_state : qp->state; in rvt_modify_qp()
1477 opa_ah = rdma_cap_opa_ah(ibqp->device, qp->port_num); in rvt_modify_qp()
1484 rdi->driver_f.check_modify_qp(qp, attr, attr_mask, udata)) in rvt_modify_qp()
1498 if (rvt_check_ah(qp->ibqp.device, &attr->ah_attr)) in rvt_modify_qp()
1513 if (rvt_check_ah(qp->ibqp.device, &attr->alt_ah_attr)) in rvt_modify_qp()
1528 if (qp->ibqp.qp_type == IB_QPT_SMI || in rvt_modify_qp()
1529 qp->ibqp.qp_type == IB_QPT_GSI || in rvt_modify_qp()
1549 * that to a small mtu. We'll set qp->path_mtu in rvt_modify_qp()
1552 * Note that the QP port has to be set in INIT and MTU in RTR. in rvt_modify_qp()
1555 pmtu = rdi->driver_f.get_pmtu_from_attr(rdi, qp, attr); in rvt_modify_qp()
1562 if (qp->s_mig_state == IB_MIG_ARMED) in rvt_modify_qp()
1567 if (qp->s_mig_state == IB_MIG_REARM) in rvt_modify_qp()
1571 if (qp->s_mig_state == IB_MIG_ARMED) in rvt_modify_qp()
1584 if (qp->state != IB_QPS_RESET) in rvt_modify_qp()
1585 _rvt_reset_qp(rdi, qp, ibqp->qp_type); in rvt_modify_qp()
1589 /* Allow event to re-trigger if QP set to RTR more than once */ in rvt_modify_qp()
1590 qp->r_flags &= ~RVT_R_COMM_EST; in rvt_modify_qp()
1591 qp->state = new_state; in rvt_modify_qp()
1595 qp->s_draining = qp->s_last != qp->s_cur; in rvt_modify_qp()
1596 qp->state = new_state; in rvt_modify_qp()
1600 if (qp->ibqp.qp_type == IB_QPT_RC) in rvt_modify_qp()
1602 qp->state = new_state; in rvt_modify_qp()
1606 lastwqe = rvt_error_qp(qp, IB_WC_WR_FLUSH_ERR); in rvt_modify_qp()
1610 qp->state = new_state; in rvt_modify_qp()
1615 qp->s_pkey_index = attr->pkey_index; in rvt_modify_qp()
1618 qp->port_num = attr->port_num; in rvt_modify_qp()
1621 qp->remote_qpn = attr->dest_qp_num; in rvt_modify_qp()
1624 qp->s_next_psn = attr->sq_psn & rdi->dparms.psn_modify_mask; in rvt_modify_qp()
1625 qp->s_psn = qp->s_next_psn; in rvt_modify_qp()
1626 qp->s_sending_psn = qp->s_next_psn; in rvt_modify_qp()
1627 qp->s_last_psn = qp->s_next_psn - 1; in rvt_modify_qp()
1628 qp->s_sending_hpsn = qp->s_last_psn; in rvt_modify_qp()
1632 qp->r_psn = attr->rq_psn & rdi->dparms.psn_modify_mask; in rvt_modify_qp()
1635 qp->qp_access_flags = attr->qp_access_flags; in rvt_modify_qp()
1638 rdma_replace_ah_attr(&qp->remote_ah_attr, &attr->ah_attr); in rvt_modify_qp()
1639 qp->s_srate = rdma_ah_get_static_rate(&attr->ah_attr); in rvt_modify_qp()
1640 qp->srate_mbps = ib_rate_to_mbps(qp->s_srate); in rvt_modify_qp()
1644 rdma_replace_ah_attr(&qp->alt_ah_attr, &attr->alt_ah_attr); in rvt_modify_qp()
1645 qp->s_alt_pkey_index = attr->alt_pkey_index; in rvt_modify_qp()
1649 qp->s_mig_state = attr->path_mig_state; in rvt_modify_qp()
1651 qp->remote_ah_attr = qp->alt_ah_attr; in rvt_modify_qp()
1652 qp->port_num = rdma_ah_get_port_num(&qp->alt_ah_attr); in rvt_modify_qp()
1653 qp->s_pkey_index = qp->s_alt_pkey_index; in rvt_modify_qp()
1658 qp->pmtu = rdi->driver_f.mtu_from_qp(rdi, qp, pmtu); in rvt_modify_qp()
1659 qp->log_pmtu = ilog2(qp->pmtu); in rvt_modify_qp()
1663 qp->s_retry_cnt = attr->retry_cnt; in rvt_modify_qp()
1664 qp->s_retry = attr->retry_cnt; in rvt_modify_qp()
1668 qp->s_rnr_retry_cnt = attr->rnr_retry; in rvt_modify_qp()
1669 qp->s_rnr_retry = attr->rnr_retry; in rvt_modify_qp()
1673 qp->r_min_rnr_timer = attr->min_rnr_timer; in rvt_modify_qp()
1676 qp->timeout = attr->timeout; in rvt_modify_qp()
1677 qp->timeout_jiffies = rvt_timeout_to_jiffies(qp->timeout); in rvt_modify_qp()
1681 qp->qkey = attr->qkey; in rvt_modify_qp()
1684 qp->r_max_rd_atomic = attr->max_dest_rd_atomic; in rvt_modify_qp()
1687 qp->s_max_rd_atomic = attr->max_rd_atomic; in rvt_modify_qp()
1690 rdi->driver_f.modify_qp(qp, attr, attr_mask, udata); in rvt_modify_qp()
1692 spin_unlock(&qp->s_lock); in rvt_modify_qp()
1693 spin_unlock(&qp->s_hlock); in rvt_modify_qp()
1694 spin_unlock_irq(&qp->r_lock); in rvt_modify_qp()
1697 rvt_insert_qp(rdi, qp); in rvt_modify_qp()
1700 ev.device = qp->ibqp.device; in rvt_modify_qp()
1701 ev.element.qp = &qp->ibqp; in rvt_modify_qp()
1703 qp->ibqp.event_handler(&ev, qp->ibqp.qp_context); in rvt_modify_qp()
1706 ev.device = qp->ibqp.device; in rvt_modify_qp()
1707 ev.element.qp = &qp->ibqp; in rvt_modify_qp()
1709 qp->ibqp.event_handler(&ev, qp->ibqp.qp_context); in rvt_modify_qp()
1714 spin_unlock(&qp->s_lock); in rvt_modify_qp()
1715 spin_unlock(&qp->s_hlock); in rvt_modify_qp()
1716 spin_unlock_irq(&qp->r_lock); in rvt_modify_qp()
1724 * Note that this can be called while the QP is actively sending or
1731 struct rvt_qp *qp = ibqp_to_rvtqp(ibqp); in rvt_destroy_qp() local
1734 rvt_reset_qp(rdi, qp, ibqp->qp_type); in rvt_destroy_qp()
1736 wait_event(qp->wait, !atomic_read(&qp->refcount)); in rvt_destroy_qp()
1738 rvt_free_qpn(&rdi->qp_dev->qpn_table, qp->ibqp.qp_num); in rvt_destroy_qp()
1742 if (qp->ibqp.qp_type == IB_QPT_RC) { in rvt_destroy_qp()
1748 if (qp->ip) in rvt_destroy_qp()
1749 kref_put(&qp->ip->ref, rvt_release_mmap_info); in rvt_destroy_qp()
1750 kvfree(qp->r_rq.kwq); in rvt_destroy_qp()
1751 rdi->driver_f.qp_priv_free(rdi, qp); in rvt_destroy_qp()
1752 kfree(qp->s_ack_queue); in rvt_destroy_qp()
1753 rdma_destroy_ah_attr(&qp->remote_ah_attr); in rvt_destroy_qp()
1754 rdma_destroy_ah_attr(&qp->alt_ah_attr); in rvt_destroy_qp()
1755 free_ud_wq_attr(qp); in rvt_destroy_qp()
1756 vfree(qp->s_wq); in rvt_destroy_qp()
1757 kfree(qp); in rvt_destroy_qp()
1763 * @ibqp: IB qp to query
1773 struct rvt_qp *qp = ibqp_to_rvtqp(ibqp); in rvt_query_qp() local
1776 attr->qp_state = qp->state; in rvt_query_qp()
1778 attr->path_mtu = rdi->driver_f.mtu_to_path_mtu(qp->pmtu); in rvt_query_qp()
1779 attr->path_mig_state = qp->s_mig_state; in rvt_query_qp()
1780 attr->qkey = qp->qkey; in rvt_query_qp()
1781 attr->rq_psn = qp->r_psn & rdi->dparms.psn_mask; in rvt_query_qp()
1782 attr->sq_psn = qp->s_next_psn & rdi->dparms.psn_mask; in rvt_query_qp()
1783 attr->dest_qp_num = qp->remote_qpn; in rvt_query_qp()
1784 attr->qp_access_flags = qp->qp_access_flags; in rvt_query_qp()
1785 attr->cap.max_send_wr = qp->s_size - 1 - in rvt_query_qp()
1787 attr->cap.max_recv_wr = qp->ibqp.srq ? 0 : qp->r_rq.size - 1; in rvt_query_qp()
1788 attr->cap.max_send_sge = qp->s_max_sge; in rvt_query_qp()
1789 attr->cap.max_recv_sge = qp->r_rq.max_sge; in rvt_query_qp()
1791 attr->ah_attr = qp->remote_ah_attr; in rvt_query_qp()
1792 attr->alt_ah_attr = qp->alt_ah_attr; in rvt_query_qp()
1793 attr->pkey_index = qp->s_pkey_index; in rvt_query_qp()
1794 attr->alt_pkey_index = qp->s_alt_pkey_index; in rvt_query_qp()
1796 attr->sq_draining = qp->s_draining; in rvt_query_qp()
1797 attr->max_rd_atomic = qp->s_max_rd_atomic; in rvt_query_qp()
1798 attr->max_dest_rd_atomic = qp->r_max_rd_atomic; in rvt_query_qp()
1799 attr->min_rnr_timer = qp->r_min_rnr_timer; in rvt_query_qp()
1800 attr->port_num = qp->port_num; in rvt_query_qp()
1801 attr->timeout = qp->timeout; in rvt_query_qp()
1802 attr->retry_cnt = qp->s_retry_cnt; in rvt_query_qp()
1803 attr->rnr_retry = qp->s_rnr_retry_cnt; in rvt_query_qp()
1805 rdma_ah_get_port_num(&qp->alt_ah_attr); in rvt_query_qp()
1806 attr->alt_timeout = qp->alt_timeout; in rvt_query_qp()
1808 init_attr->event_handler = qp->ibqp.event_handler; in rvt_query_qp()
1809 init_attr->qp_context = qp->ibqp.qp_context; in rvt_query_qp()
1810 init_attr->send_cq = qp->ibqp.send_cq; in rvt_query_qp()
1811 init_attr->recv_cq = qp->ibqp.recv_cq; in rvt_query_qp()
1812 init_attr->srq = qp->ibqp.srq; in rvt_query_qp()
1814 if (qp->s_flags & RVT_S_SIGNAL_REQ_WR) in rvt_query_qp()
1818 init_attr->qp_type = qp->ibqp.qp_type; in rvt_query_qp()
1819 init_attr->port_num = qp->port_num; in rvt_query_qp()
1824 * rvt_post_receive - post a receive on a QP
1825 * @ibqp: the QP to post the receive on
1836 struct rvt_qp *qp = ibqp_to_rvtqp(ibqp); in rvt_post_recv() local
1837 struct rvt_krwq *wq = qp->r_rq.kwq; in rvt_post_recv()
1839 int qp_err_flush = (ib_rvt_state_ops[qp->state] & RVT_FLUSH_RECV) && in rvt_post_recv()
1840 !qp->ibqp.srq; in rvt_post_recv()
1843 if (!(ib_rvt_state_ops[qp->state] & RVT_POST_RECV_OK) || !wq) { in rvt_post_recv()
1853 if ((unsigned)wr->num_sge > qp->r_rq.max_sge) { in rvt_post_recv()
1858 spin_lock_irqsave(&qp->r_rq.kwq->p_lock, flags); in rvt_post_recv()
1860 if (next >= qp->r_rq.size) in rvt_post_recv()
1863 spin_unlock_irqrestore(&qp->r_rq.kwq->p_lock, flags); in rvt_post_recv()
1871 wc.qp = &qp->ibqp; in rvt_post_recv()
1875 rvt_cq_enter(ibcq_to_rvtcq(qp->ibqp.recv_cq), &wc, 1); in rvt_post_recv()
1877 wqe = rvt_get_rwqe_ptr(&qp->r_rq, wq->head); in rvt_post_recv()
1891 spin_unlock_irqrestore(&qp->r_rq.kwq->p_lock, flags); in rvt_post_recv()
1898 * @qp - the qp
1915 struct rvt_qp *qp, in rvt_qp_valid_operation() argument
1923 if (!(post_parms[wr->opcode].qpt_support & BIT(qp->ibqp.qp_type))) in rvt_qp_valid_operation()
1926 ibpd_to_rvtpd(qp->ibqp.pd)->user) in rvt_qp_valid_operation()
1934 !qp->s_max_rd_atomic) in rvt_qp_valid_operation()
1938 if (qp->ibqp.qp_type != IB_QPT_UC && in rvt_qp_valid_operation()
1939 qp->ibqp.qp_type != IB_QPT_RC) { in rvt_qp_valid_operation()
1940 if (qp->ibqp.pd != ud_wr(wr)->ah->pd) in rvt_qp_valid_operation()
1949 * @qp: the qp
1954 * qp variable is uncontrolled.
1956 * For non reserved operations, the qp->s_avail
1962 struct rvt_qp *qp, in rvt_qp_is_avail() argument
1974 reserved_used = atomic_read(&qp->s_reserved_used); in rvt_qp_is_avail()
1980 if (likely(qp->s_avail)) in rvt_qp_is_avail()
1983 slast = smp_load_acquire(&qp->s_last); in rvt_qp_is_avail()
1984 if (qp->s_head >= slast) in rvt_qp_is_avail()
1985 avail = qp->s_size - (qp->s_head - slast); in rvt_qp_is_avail()
1987 avail = slast - qp->s_head; in rvt_qp_is_avail()
1989 reserved_used = atomic_read(&qp->s_reserved_used); in rvt_qp_is_avail()
1995 qp->s_avail = avail; in rvt_qp_is_avail()
1996 if (WARN_ON(qp->s_avail > in rvt_qp_is_avail()
1997 (qp->s_size - 1 - rdi->dparms.reserved_operations))) in rvt_qp_is_avail()
1999 …"More avail entries than QP RB size.\nQP: %u, size: %u, avail: %u\nhead: %u, tail: %u, cur: %u, ac… in rvt_qp_is_avail()
2000 qp->ibqp.qp_num, qp->s_size, qp->s_avail, in rvt_qp_is_avail()
2001 qp->s_head, qp->s_tail, qp->s_cur, in rvt_qp_is_avail()
2002 qp->s_acked, qp->s_last); in rvt_qp_is_avail()
2008 * @qp: the QP to post on
2011 static int rvt_post_one_wr(struct rvt_qp *qp, in rvt_post_one_wr() argument
2022 struct rvt_dev_info *rdi = ib_to_rvt(qp->ibqp.device); in rvt_post_one_wr()
2032 if (unlikely(wr->num_sge > qp->s_max_sge)) in rvt_post_one_wr()
2035 ret = rvt_qp_valid_operation(qp, rdi->post_parms, wr); in rvt_post_one_wr()
2054 ret = rvt_fast_reg_mr(qp, in rvt_post_one_wr()
2063 atomic_read(&qp->local_ops_pending)) { in rvt_post_one_wr()
2067 qp, wr->ex.invalidate_rkey); in rvt_post_one_wr()
2080 ret = rvt_qp_is_avail(qp, rdi, reserved_op); in rvt_post_one_wr()
2083 next = qp->s_head + 1; in rvt_post_one_wr()
2084 if (next >= qp->s_size) in rvt_post_one_wr()
2088 pd = ibpd_to_rvtpd(qp->ibqp.pd); in rvt_post_one_wr()
2089 wqe = rvt_get_swqe_ptr(qp, qp->s_head); in rvt_post_one_wr()
2123 log_pmtu = qp->log_pmtu; in rvt_post_one_wr()
2124 if (qp->allowed_ops == IB_OPCODE_UD) { in rvt_post_one_wr()
2133 atomic_inc(&qp->local_ops_pending); in rvt_post_one_wr()
2140 wqe->ssn = qp->s_ssn++; in rvt_post_one_wr()
2141 wqe->psn = qp->s_next_psn; in rvt_post_one_wr()
2150 ret = rdi->driver_f.setup_wqe(qp, wqe, call_send); in rvt_post_one_wr()
2156 qp->s_next_psn = wqe->lpsn + 1; in rvt_post_one_wr()
2160 rvt_qp_wqe_reserve(qp, wqe); in rvt_post_one_wr()
2163 qp->s_avail--; in rvt_post_one_wr()
2165 trace_rvt_post_one_wr(qp, wqe, wr->num_sge); in rvt_post_one_wr()
2167 qp->s_head = next; in rvt_post_one_wr()
2172 if (qp->allowed_ops == IB_OPCODE_UD) in rvt_post_one_wr()
2185 * rvt_post_send - post a send on a QP
2186 * @ibqp: the QP to post the send on
2197 struct rvt_qp *qp = ibqp_to_rvtqp(ibqp); in rvt_post_send() local
2204 spin_lock_irqsave(&qp->s_hlock, flags); in rvt_post_send()
2207 * Ensure QP state is such that we can send. If not bail out early, in rvt_post_send()
2210 if (unlikely(!(ib_rvt_state_ops[qp->state] & RVT_POST_SEND_OK))) { in rvt_post_send()
2211 spin_unlock_irqrestore(&qp->s_hlock, flags); in rvt_post_send()
2220 call_send = qp->s_head == READ_ONCE(qp->s_last) && !wr->next; in rvt_post_send()
2223 err = rvt_post_one_wr(qp, wr, &call_send); in rvt_post_send()
2231 spin_unlock_irqrestore(&qp->s_hlock, flags); in rvt_post_send()
2238 rdi->driver_f.do_send(qp); in rvt_post_send()
2240 rdi->driver_f.schedule_send_no_lock(qp); in rvt_post_send()
2318 static int init_sge(struct rvt_qp *qp, struct rvt_rwqe *wqe) in init_sge() argument
2325 struct rvt_dev_info *rdi = ib_to_rvt(qp->ibqp.device); in init_sge()
2328 pd = ibpd_to_rvtpd(qp->ibqp.srq ? qp->ibqp.srq->pd : qp->ibqp.pd); in init_sge()
2329 ss = &qp->r_sge; in init_sge()
2330 ss->sg_list = qp->r_sg_list; in init_sge()
2331 qp->r_len = 0; in init_sge()
2341 qp->r_len += wqe->sg_list[i].length; in init_sge()
2345 ss->total_len = qp->r_len; in init_sge()
2359 wc.qp = &qp->ibqp; in init_sge()
2361 rvt_cq_enter(ibcq_to_rvtcq(qp->ibqp.recv_cq), &wc, 1); in init_sge()
2368 * @ip: the QP
2385 * rvt_get_rwqe - copy the next RWQE into the QP's RWQE
2386 * @qp: the QP
2387 * @wr_id_only: update qp->r_wr_id only, not qp->r_sge
2394 int rvt_get_rwqe(struct rvt_qp *qp, bool wr_id_only) in rvt_get_rwqe() argument
2408 if (qp->ibqp.srq) { in rvt_get_rwqe()
2409 srq = ibsrq_to_rvtsrq(qp->ibqp.srq); in rvt_get_rwqe()
2416 rq = &qp->r_rq; in rvt_get_rwqe()
2417 ip = qp->ip; in rvt_get_rwqe()
2421 if (!(ib_rvt_state_ops[qp->state] & RVT_PROCESS_RECV_OK)) { in rvt_get_rwqe()
2459 if (!wr_id_only && !init_sge(qp, wqe)) { in rvt_get_rwqe()
2463 qp->r_wr_id = wqe->wr_id; in rvt_get_rwqe()
2467 set_bit(RVT_R_WRID_VALID, &qp->r_aflags); in rvt_get_rwqe()
2482 ev.device = qp->ibqp.device; in rvt_get_rwqe()
2483 ev.element.srq = qp->ibqp.srq; in rvt_get_rwqe()
2498 * qp_comm_est - handle trap with QP established
2499 * @qp: the QP
2501 void rvt_comm_est(struct rvt_qp *qp) in rvt_comm_est() argument
2503 qp->r_flags |= RVT_R_COMM_EST; in rvt_comm_est()
2504 if (qp->ibqp.event_handler) { in rvt_comm_est()
2507 ev.device = qp->ibqp.device; in rvt_comm_est()
2508 ev.element.qp = &qp->ibqp; in rvt_comm_est()
2510 qp->ibqp.event_handler(&ev, qp->ibqp.qp_context); in rvt_comm_est()
2515 void rvt_rc_error(struct rvt_qp *qp, enum ib_wc_status err) in rvt_rc_error() argument
2520 spin_lock_irqsave(&qp->s_lock, flags); in rvt_rc_error()
2521 lastwqe = rvt_error_qp(qp, err); in rvt_rc_error()
2522 spin_unlock_irqrestore(&qp->s_lock, flags); in rvt_rc_error()
2527 ev.device = qp->ibqp.device; in rvt_rc_error()
2528 ev.element.qp = &qp->ibqp; in rvt_rc_error()
2530 qp->ibqp.event_handler(&ev, qp->ibqp.qp_context); in rvt_rc_error()
2554 * @qp - the QP
2556 * add a retry timer on the QP
2558 void rvt_add_retry_timer_ext(struct rvt_qp *qp, u8 shift) in rvt_add_retry_timer_ext() argument
2560 struct ib_qp *ibqp = &qp->ibqp; in rvt_add_retry_timer_ext()
2563 lockdep_assert_held(&qp->s_lock); in rvt_add_retry_timer_ext()
2564 qp->s_flags |= RVT_S_TIMER; in rvt_add_retry_timer_ext()
2565 /* 4.096 usec. * (1 << qp->timeout) */ in rvt_add_retry_timer_ext()
2566 qp->s_timer.expires = jiffies + rdi->busy_jiffies + in rvt_add_retry_timer_ext()
2567 (qp->timeout_jiffies << shift); in rvt_add_retry_timer_ext()
2568 add_timer(&qp->s_timer); in rvt_add_retry_timer_ext()
2573 * rvt_add_rnr_timer - add/start an rnr timer on the QP
2574 * @qp: the QP
2577 void rvt_add_rnr_timer(struct rvt_qp *qp, u32 aeth) in rvt_add_rnr_timer() argument
2581 lockdep_assert_held(&qp->s_lock); in rvt_add_rnr_timer()
2582 qp->s_flags |= RVT_S_WAIT_RNR; in rvt_add_rnr_timer()
2584 trace_rvt_rnrnak_add(qp, to); in rvt_add_rnr_timer()
2585 hrtimer_start(&qp->s_rnr_timer, in rvt_add_rnr_timer()
2592 * @qp: the QP
2595 void rvt_stop_rc_timers(struct rvt_qp *qp) in rvt_stop_rc_timers() argument
2597 lockdep_assert_held(&qp->s_lock); in rvt_stop_rc_timers()
2598 /* Remove QP from all timers */ in rvt_stop_rc_timers()
2599 if (qp->s_flags & (RVT_S_TIMER | RVT_S_WAIT_RNR)) { in rvt_stop_rc_timers()
2600 qp->s_flags &= ~(RVT_S_TIMER | RVT_S_WAIT_RNR); in rvt_stop_rc_timers()
2601 del_timer(&qp->s_timer); in rvt_stop_rc_timers()
2602 hrtimer_try_to_cancel(&qp->s_rnr_timer); in rvt_stop_rc_timers()
2609 * @qp - the QP
2614 static void rvt_stop_rnr_timer(struct rvt_qp *qp) in rvt_stop_rnr_timer() argument
2616 lockdep_assert_held(&qp->s_lock); in rvt_stop_rnr_timer()
2617 /* Remove QP from rnr timer */ in rvt_stop_rnr_timer()
2618 if (qp->s_flags & RVT_S_WAIT_RNR) { in rvt_stop_rnr_timer()
2619 qp->s_flags &= ~RVT_S_WAIT_RNR; in rvt_stop_rnr_timer()
2620 trace_rvt_rnrnak_stop(qp, 0); in rvt_stop_rnr_timer()
2626 * @qp: the QP
2628 void rvt_del_timers_sync(struct rvt_qp *qp) in rvt_del_timers_sync() argument
2630 del_timer_sync(&qp->s_timer); in rvt_del_timers_sync()
2631 hrtimer_cancel(&qp->s_rnr_timer); in rvt_del_timers_sync()
2640 struct rvt_qp *qp = from_timer(qp, t, s_timer); in rvt_rc_timeout() local
2641 struct rvt_dev_info *rdi = ib_to_rvt(qp->ibqp.device); in rvt_rc_timeout()
2644 spin_lock_irqsave(&qp->r_lock, flags); in rvt_rc_timeout()
2645 spin_lock(&qp->s_lock); in rvt_rc_timeout()
2646 if (qp->s_flags & RVT_S_TIMER) { in rvt_rc_timeout()
2647 struct rvt_ibport *rvp = rdi->ports[qp->port_num - 1]; in rvt_rc_timeout()
2649 qp->s_flags &= ~RVT_S_TIMER; in rvt_rc_timeout()
2651 del_timer(&qp->s_timer); in rvt_rc_timeout()
2652 trace_rvt_rc_timeout(qp, qp->s_last_psn + 1); in rvt_rc_timeout()
2654 rdi->driver_f.notify_restart_rc(qp, in rvt_rc_timeout()
2655 qp->s_last_psn + 1, in rvt_rc_timeout()
2657 rdi->driver_f.schedule_send(qp); in rvt_rc_timeout()
2659 spin_unlock(&qp->s_lock); in rvt_rc_timeout()
2660 spin_unlock_irqrestore(&qp->r_lock, flags); in rvt_rc_timeout()
2668 struct rvt_qp *qp = container_of(t, struct rvt_qp, s_rnr_timer); in rvt_rc_rnr_retry() local
2669 struct rvt_dev_info *rdi = ib_to_rvt(qp->ibqp.device); in rvt_rc_rnr_retry()
2672 spin_lock_irqsave(&qp->s_lock, flags); in rvt_rc_rnr_retry()
2673 rvt_stop_rnr_timer(qp); in rvt_rc_rnr_retry()
2674 trace_rvt_rnrnak_timeout(qp, 0); in rvt_rc_rnr_retry()
2675 rdi->driver_f.schedule_send(qp); in rvt_rc_rnr_retry()
2676 spin_unlock_irqrestore(&qp->s_lock, flags); in rvt_rc_rnr_retry()
2682 * rvt_qp_iter_init - initial for QP iteration
2692 * @cb. An example use case would be to alter QP processing
2702 void (*cb)(struct rvt_qp *qp, u64 v)) in rvt_qp_iter_init() argument
2721 * rvt_qp_iter_next - return the next QP in iter
2724 * Fine grained QP iterator suitable for use
2727 * Updates iter->qp with the current QP when the return
2730 * Return: 0 - iter->qp is valid 1 - no more QPs
2737 struct rvt_qp *pqp = iter->qp; in rvt_qp_iter_next()
2738 struct rvt_qp *qp; in rvt_qp_iter_next() local
2744 * real hash table. Since the qp code sets in rvt_qp_iter_next()
2745 * the qp->next hash link to NULL, this works just fine. in rvt_qp_iter_next()
2749 * n = 0..iter->specials is the special qp indices in rvt_qp_iter_next()
2757 qp = rcu_dereference(pqp->next); in rvt_qp_iter_next()
2765 qp = rcu_dereference(rvp->qp[n & 1]); in rvt_qp_iter_next()
2767 qp = rcu_dereference( in rvt_qp_iter_next()
2772 pqp = qp; in rvt_qp_iter_next()
2773 if (qp) { in rvt_qp_iter_next()
2774 iter->qp = qp; in rvt_qp_iter_next()
2793 * cb. An example use case would be to alter QP processing
2801 void (*cb)(struct rvt_qp *qp, u64 v)) in rvt_qp_iter() argument
2815 rvt_get_qp(i.qp); in rvt_qp_iter()
2817 i.cb(i.qp, i.v); in rvt_qp_iter()
2819 rvt_put_qp(i.qp); in rvt_qp_iter()
2829 void rvt_send_complete(struct rvt_qp *qp, struct rvt_swqe *wqe, in rvt_send_complete() argument
2835 if (!(ib_rvt_state_ops[qp->state] & RVT_PROCESS_OR_FLUSH_SEND)) in rvt_send_complete()
2837 rdi = ib_to_rvt(qp->ibqp.device); in rvt_send_complete()
2839 old_last = qp->s_last; in rvt_send_complete()
2840 trace_rvt_qp_send_completion(qp, wqe, old_last); in rvt_send_complete()
2841 last = rvt_qp_complete_swqe(qp, wqe, rdi->wc_opcode[wqe->wr.opcode], in rvt_send_complete()
2843 if (qp->s_acked == old_last) in rvt_send_complete()
2844 qp->s_acked = last; in rvt_send_complete()
2845 if (qp->s_cur == old_last) in rvt_send_complete()
2846 qp->s_cur = last; in rvt_send_complete()
2847 if (qp->s_tail == old_last) in rvt_send_complete()
2848 qp->s_tail = last; in rvt_send_complete()
2849 if (qp->state == IB_QPS_SQD && last == qp->s_cur) in rvt_send_complete()
2850 qp->s_draining = 0; in rvt_send_complete()
2856 * @qp: associated QP
2863 void rvt_copy_sge(struct rvt_qp *qp, struct rvt_sge_state *ss, in rvt_copy_sge() argument
2871 struct rvt_dev_info *rdi = ib_to_rvt(qp->ibqp.device); in rvt_copy_sge()
2945 * @sqp: the sending QP
2957 struct rvt_qp *qp; in rvt_ruc_loopback() local
2974 * Note that we check the responder QP state after in rvt_ruc_loopback()
2978 qp = rvt_lookup_qpn(ib_to_rvt(sqp->ibqp.device), rvp, in rvt_ruc_loopback()
3015 if (!qp) { in rvt_ruc_loopback()
3019 spin_lock_irqsave(&qp->r_lock, flags); in rvt_ruc_loopback()
3020 if (!(ib_rvt_state_ops[qp->state] & RVT_PROCESS_RECV_OK) || in rvt_ruc_loopback()
3021 qp->ibqp.qp_type != sqp->ibqp.qp_type) { in rvt_ruc_loopback()
3050 ret = rvt_get_rwqe(qp, false); in rvt_ruc_loopback()
3055 if (wqe->length > qp->r_len) in rvt_ruc_loopback()
3059 if (!rvt_invalidate_rkey(qp, in rvt_ruc_loopback()
3076 if (unlikely(!(qp->qp_access_flags & IB_ACCESS_REMOTE_WRITE))) in rvt_ruc_loopback()
3080 ret = rvt_get_rwqe(qp, true); in rvt_ruc_loopback()
3088 copy_last = rvt_is_user_qp(qp); in rvt_ruc_loopback()
3089 if (unlikely(!(qp->qp_access_flags & IB_ACCESS_REMOTE_WRITE))) in rvt_ruc_loopback()
3094 if (unlikely(!rvt_rkey_ok(qp, &qp->r_sge.sge, wqe->length, in rvt_ruc_loopback()
3099 qp->r_sge.sg_list = NULL; in rvt_ruc_loopback()
3100 qp->r_sge.num_sge = 1; in rvt_ruc_loopback()
3101 qp->r_sge.total_len = wqe->length; in rvt_ruc_loopback()
3105 if (unlikely(!(qp->qp_access_flags & IB_ACCESS_REMOTE_READ))) in rvt_ruc_loopback()
3107 if (unlikely(!rvt_rkey_ok(qp, &sqp->s_sge.sge, wqe->length, in rvt_ruc_loopback()
3115 qp->r_sge.sge = wqe->sg_list[0]; in rvt_ruc_loopback()
3116 qp->r_sge.sg_list = wqe->sg_list + 1; in rvt_ruc_loopback()
3117 qp->r_sge.num_sge = wqe->wr.num_sge; in rvt_ruc_loopback()
3118 qp->r_sge.total_len = wqe->length; in rvt_ruc_loopback()
3123 if (unlikely(!(qp->qp_access_flags & IB_ACCESS_REMOTE_ATOMIC))) in rvt_ruc_loopback()
3127 if (unlikely(!rvt_rkey_ok(qp, &qp->r_sge.sge, sizeof(u64), in rvt_ruc_loopback()
3133 maddr = (atomic64_t *)qp->r_sge.sge.vaddr; in rvt_ruc_loopback()
3138 (u64)cmpxchg((u64 *)qp->r_sge.sge.vaddr, in rvt_ruc_loopback()
3140 rvt_put_mr(qp->r_sge.sge.mr); in rvt_ruc_loopback()
3141 qp->r_sge.num_sge = 0; in rvt_ruc_loopback()
3154 rvt_copy_sge(qp, &qp->r_sge, sge->vaddr, in rvt_ruc_loopback()
3160 rvt_put_ss(&qp->r_sge); in rvt_ruc_loopback()
3162 if (!test_and_clear_bit(RVT_R_WRID_VALID, &qp->r_aflags)) in rvt_ruc_loopback()
3169 wc.wr_id = qp->r_wr_id; in rvt_ruc_loopback()
3172 wc.qp = &qp->ibqp; in rvt_ruc_loopback()
3173 wc.src_qp = qp->remote_qpn; in rvt_ruc_loopback()
3174 wc.slid = rdma_ah_get_dlid(&qp->remote_ah_attr) & U16_MAX; in rvt_ruc_loopback()
3175 wc.sl = rdma_ah_get_sl(&qp->remote_ah_attr); in rvt_ruc_loopback()
3178 rvt_recv_cq(qp, &wc, wqe->wr.send_flags & IB_SEND_SOLICITED); in rvt_ruc_loopback()
3181 spin_unlock_irqrestore(&qp->r_lock, flags); in rvt_ruc_loopback()
3197 if (qp->ibqp.qp_type == IB_QPT_UC) in rvt_ruc_loopback()
3210 spin_unlock_irqrestore(&qp->r_lock, flags); in rvt_ruc_loopback()
3214 rvt_add_rnr_timer(sqp, qp->r_min_rnr_timer << in rvt_ruc_loopback()
3236 rvt_rc_error(qp, wc.status); in rvt_ruc_loopback()
3239 spin_unlock_irqrestore(&qp->r_lock, flags); in rvt_ruc_loopback()
3258 ev.element.qp = &sqp->ibqp; in rvt_ruc_loopback()