• Home
  • Raw
  • Download

Lines Matching refs:qp

209 static int ipath_alloc_qpn(struct ipath_qp_table *qpt, struct ipath_qp *qp,  in ipath_alloc_qpn()  argument
218 qp->ibqp.qp_num = ret; in ipath_alloc_qpn()
224 qp->next = qpt->table[ret]; in ipath_alloc_qpn()
225 qpt->table[ret] = qp; in ipath_alloc_qpn()
226 atomic_inc(&qp->refcount); in ipath_alloc_qpn()
243 static void ipath_free_qp(struct ipath_qp_table *qpt, struct ipath_qp *qp) in ipath_free_qp() argument
251 qpp = &qpt->table[qp->ibqp.qp_num % qpt->max]; in ipath_free_qp()
253 if (q == qp) { in ipath_free_qp()
254 *qpp = qp->next; in ipath_free_qp()
255 qp->next = NULL; in ipath_free_qp()
256 atomic_dec(&qp->refcount); in ipath_free_qp()
274 struct ipath_qp *qp; in ipath_free_all_qps() local
279 qp = qpt->table[n]; in ipath_free_all_qps()
282 for (; qp; qp = qp->next) in ipath_free_all_qps()
304 struct ipath_qp *qp; in ipath_lookup_qpn() local
308 for (qp = qpt->table[qpn % qpt->max]; qp; qp = qp->next) { in ipath_lookup_qpn()
309 if (qp->ibqp.qp_num == qpn) { in ipath_lookup_qpn()
310 atomic_inc(&qp->refcount); in ipath_lookup_qpn()
316 return qp; in ipath_lookup_qpn()
324 static void ipath_reset_qp(struct ipath_qp *qp, enum ib_qp_type type) in ipath_reset_qp() argument
326 qp->remote_qpn = 0; in ipath_reset_qp()
327 qp->qkey = 0; in ipath_reset_qp()
328 qp->qp_access_flags = 0; in ipath_reset_qp()
329 atomic_set(&qp->s_dma_busy, 0); in ipath_reset_qp()
330 qp->s_flags &= IPATH_S_SIGNAL_REQ_WR; in ipath_reset_qp()
331 qp->s_hdrwords = 0; in ipath_reset_qp()
332 qp->s_wqe = NULL; in ipath_reset_qp()
333 qp->s_pkt_delay = 0; in ipath_reset_qp()
334 qp->s_draining = 0; in ipath_reset_qp()
335 qp->s_psn = 0; in ipath_reset_qp()
336 qp->r_psn = 0; in ipath_reset_qp()
337 qp->r_msn = 0; in ipath_reset_qp()
339 qp->s_state = IB_OPCODE_RC_SEND_LAST; in ipath_reset_qp()
340 qp->r_state = IB_OPCODE_RC_SEND_LAST; in ipath_reset_qp()
342 qp->s_state = IB_OPCODE_UC_SEND_LAST; in ipath_reset_qp()
343 qp->r_state = IB_OPCODE_UC_SEND_LAST; in ipath_reset_qp()
345 qp->s_ack_state = IB_OPCODE_RC_ACKNOWLEDGE; in ipath_reset_qp()
346 qp->r_nak_state = 0; in ipath_reset_qp()
347 qp->r_aflags = 0; in ipath_reset_qp()
348 qp->r_flags = 0; in ipath_reset_qp()
349 qp->s_rnr_timeout = 0; in ipath_reset_qp()
350 qp->s_head = 0; in ipath_reset_qp()
351 qp->s_tail = 0; in ipath_reset_qp()
352 qp->s_cur = 0; in ipath_reset_qp()
353 qp->s_last = 0; in ipath_reset_qp()
354 qp->s_ssn = 1; in ipath_reset_qp()
355 qp->s_lsn = 0; in ipath_reset_qp()
356 memset(qp->s_ack_queue, 0, sizeof(qp->s_ack_queue)); in ipath_reset_qp()
357 qp->r_head_ack_queue = 0; in ipath_reset_qp()
358 qp->s_tail_ack_queue = 0; in ipath_reset_qp()
359 qp->s_num_rd_atomic = 0; in ipath_reset_qp()
360 if (qp->r_rq.wq) { in ipath_reset_qp()
361 qp->r_rq.wq->head = 0; in ipath_reset_qp()
362 qp->r_rq.wq->tail = 0; in ipath_reset_qp()
377 int ipath_error_qp(struct ipath_qp *qp, enum ib_wc_status err) in ipath_error_qp() argument
379 struct ipath_ibdev *dev = to_idev(qp->ibqp.device); in ipath_error_qp()
383 if (qp->state == IB_QPS_ERR) in ipath_error_qp()
386 qp->state = IB_QPS_ERR; in ipath_error_qp()
389 if (!list_empty(&qp->timerwait)) in ipath_error_qp()
390 list_del_init(&qp->timerwait); in ipath_error_qp()
391 if (!list_empty(&qp->piowait)) in ipath_error_qp()
392 list_del_init(&qp->piowait); in ipath_error_qp()
396 if (qp->s_last != qp->s_head) in ipath_error_qp()
397 ipath_schedule_send(qp); in ipath_error_qp()
400 wc.qp = &qp->ibqp; in ipath_error_qp()
403 if (test_and_clear_bit(IPATH_R_WRID_VALID, &qp->r_aflags)) { in ipath_error_qp()
404 wc.wr_id = qp->r_wr_id; in ipath_error_qp()
406 ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, 1); in ipath_error_qp()
410 if (qp->r_rq.wq) { in ipath_error_qp()
415 spin_lock(&qp->r_rq.lock); in ipath_error_qp()
418 wq = qp->r_rq.wq; in ipath_error_qp()
420 if (head >= qp->r_rq.size) in ipath_error_qp()
423 if (tail >= qp->r_rq.size) in ipath_error_qp()
426 wc.wr_id = get_rwqe_ptr(&qp->r_rq, tail)->wr_id; in ipath_error_qp()
427 if (++tail >= qp->r_rq.size) in ipath_error_qp()
429 ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, 1); in ipath_error_qp()
433 spin_unlock(&qp->r_rq.lock); in ipath_error_qp()
434 } else if (qp->ibqp.event_handler) in ipath_error_qp()
454 struct ipath_qp *qp = to_iqp(ibqp); in ipath_modify_qp() local
459 spin_lock_irq(&qp->s_lock); in ipath_modify_qp()
462 attr->cur_qp_state : qp->state; in ipath_modify_qp()
512 if (qp->state != IB_QPS_RESET) { in ipath_modify_qp()
513 qp->state = IB_QPS_RESET; in ipath_modify_qp()
515 if (!list_empty(&qp->timerwait)) in ipath_modify_qp()
516 list_del_init(&qp->timerwait); in ipath_modify_qp()
517 if (!list_empty(&qp->piowait)) in ipath_modify_qp()
518 list_del_init(&qp->piowait); in ipath_modify_qp()
520 qp->s_flags &= ~IPATH_S_ANY_WAIT; in ipath_modify_qp()
521 spin_unlock_irq(&qp->s_lock); in ipath_modify_qp()
523 tasklet_kill(&qp->s_task); in ipath_modify_qp()
524 wait_event(qp->wait_dma, !atomic_read(&qp->s_dma_busy)); in ipath_modify_qp()
525 spin_lock_irq(&qp->s_lock); in ipath_modify_qp()
527 ipath_reset_qp(qp, ibqp->qp_type); in ipath_modify_qp()
531 qp->s_draining = qp->s_last != qp->s_cur; in ipath_modify_qp()
532 qp->state = new_state; in ipath_modify_qp()
536 if (qp->ibqp.qp_type == IB_QPT_RC) in ipath_modify_qp()
538 qp->state = new_state; in ipath_modify_qp()
542 lastwqe = ipath_error_qp(qp, IB_WC_WR_FLUSH_ERR); in ipath_modify_qp()
546 qp->state = new_state; in ipath_modify_qp()
551 qp->s_pkey_index = attr->pkey_index; in ipath_modify_qp()
554 qp->remote_qpn = attr->dest_qp_num; in ipath_modify_qp()
557 qp->s_psn = qp->s_next_psn = attr->sq_psn; in ipath_modify_qp()
558 qp->s_last_psn = qp->s_next_psn - 1; in ipath_modify_qp()
562 qp->r_psn = attr->rq_psn; in ipath_modify_qp()
565 qp->qp_access_flags = attr->qp_access_flags; in ipath_modify_qp()
568 qp->remote_ah_attr = attr->ah_attr; in ipath_modify_qp()
569 qp->s_dmult = ipath_ib_rate_to_mult(attr->ah_attr.static_rate); in ipath_modify_qp()
573 qp->path_mtu = attr->path_mtu; in ipath_modify_qp()
576 qp->s_retry = qp->s_retry_cnt = attr->retry_cnt; in ipath_modify_qp()
579 qp->s_rnr_retry = attr->rnr_retry; in ipath_modify_qp()
580 if (qp->s_rnr_retry > 7) in ipath_modify_qp()
581 qp->s_rnr_retry = 7; in ipath_modify_qp()
582 qp->s_rnr_retry_cnt = qp->s_rnr_retry; in ipath_modify_qp()
586 qp->r_min_rnr_timer = attr->min_rnr_timer; in ipath_modify_qp()
589 qp->timeout = attr->timeout; in ipath_modify_qp()
592 qp->qkey = attr->qkey; in ipath_modify_qp()
595 qp->r_max_rd_atomic = attr->max_dest_rd_atomic; in ipath_modify_qp()
598 qp->s_max_rd_atomic = attr->max_rd_atomic; in ipath_modify_qp()
600 spin_unlock_irq(&qp->s_lock); in ipath_modify_qp()
605 ev.device = qp->ibqp.device; in ipath_modify_qp()
606 ev.element.qp = &qp->ibqp; in ipath_modify_qp()
608 qp->ibqp.event_handler(&ev, qp->ibqp.qp_context); in ipath_modify_qp()
614 spin_unlock_irq(&qp->s_lock); in ipath_modify_qp()
624 struct ipath_qp *qp = to_iqp(ibqp); in ipath_query_qp() local
626 attr->qp_state = qp->state; in ipath_query_qp()
628 attr->path_mtu = qp->path_mtu; in ipath_query_qp()
630 attr->qkey = qp->qkey; in ipath_query_qp()
631 attr->rq_psn = qp->r_psn; in ipath_query_qp()
632 attr->sq_psn = qp->s_next_psn; in ipath_query_qp()
633 attr->dest_qp_num = qp->remote_qpn; in ipath_query_qp()
634 attr->qp_access_flags = qp->qp_access_flags; in ipath_query_qp()
635 attr->cap.max_send_wr = qp->s_size - 1; in ipath_query_qp()
636 attr->cap.max_recv_wr = qp->ibqp.srq ? 0 : qp->r_rq.size - 1; in ipath_query_qp()
637 attr->cap.max_send_sge = qp->s_max_sge; in ipath_query_qp()
638 attr->cap.max_recv_sge = qp->r_rq.max_sge; in ipath_query_qp()
640 attr->ah_attr = qp->remote_ah_attr; in ipath_query_qp()
642 attr->pkey_index = qp->s_pkey_index; in ipath_query_qp()
645 attr->sq_draining = qp->s_draining; in ipath_query_qp()
646 attr->max_rd_atomic = qp->s_max_rd_atomic; in ipath_query_qp()
647 attr->max_dest_rd_atomic = qp->r_max_rd_atomic; in ipath_query_qp()
648 attr->min_rnr_timer = qp->r_min_rnr_timer; in ipath_query_qp()
650 attr->timeout = qp->timeout; in ipath_query_qp()
651 attr->retry_cnt = qp->s_retry_cnt; in ipath_query_qp()
652 attr->rnr_retry = qp->s_rnr_retry_cnt; in ipath_query_qp()
656 init_attr->event_handler = qp->ibqp.event_handler; in ipath_query_qp()
657 init_attr->qp_context = qp->ibqp.qp_context; in ipath_query_qp()
658 init_attr->send_cq = qp->ibqp.send_cq; in ipath_query_qp()
659 init_attr->recv_cq = qp->ibqp.recv_cq; in ipath_query_qp()
660 init_attr->srq = qp->ibqp.srq; in ipath_query_qp()
662 if (qp->s_flags & IPATH_S_SIGNAL_REQ_WR) in ipath_query_qp()
666 init_attr->qp_type = qp->ibqp.qp_type; in ipath_query_qp()
677 __be32 ipath_compute_aeth(struct ipath_qp *qp) in ipath_compute_aeth() argument
679 u32 aeth = qp->r_msn & IPATH_MSN_MASK; in ipath_compute_aeth()
681 if (qp->ibqp.srq) { in ipath_compute_aeth()
690 struct ipath_rwq *wq = qp->r_rq.wq; in ipath_compute_aeth()
696 if (head >= qp->r_rq.size) in ipath_compute_aeth()
699 if (tail >= qp->r_rq.size) in ipath_compute_aeth()
708 credits += qp->r_rq.size; in ipath_compute_aeth()
745 struct ipath_qp *qp; in ipath_create_qp() local
794 sz = sizeof(*qp); in ipath_create_qp()
800 sg_list_sz = sizeof(*qp->r_sg_list) * in ipath_create_qp()
803 sg_list_sz = sizeof(*qp->r_sg_list) * in ipath_create_qp()
805 qp = kmalloc(sz + sg_list_sz, GFP_KERNEL); in ipath_create_qp()
806 if (!qp) { in ipath_create_qp()
813 qp->r_ud_sg_list = kmalloc(sg_list_sz, GFP_KERNEL); in ipath_create_qp()
814 if (!qp->r_ud_sg_list) { in ipath_create_qp()
819 qp->r_ud_sg_list = NULL; in ipath_create_qp()
822 qp->r_rq.size = 0; in ipath_create_qp()
823 qp->r_rq.max_sge = 0; in ipath_create_qp()
824 qp->r_rq.wq = NULL; in ipath_create_qp()
828 qp->r_rq.size = init_attr->cap.max_recv_wr + 1; in ipath_create_qp()
829 qp->r_rq.max_sge = init_attr->cap.max_recv_sge; in ipath_create_qp()
830 sz = (sizeof(struct ib_sge) * qp->r_rq.max_sge) + in ipath_create_qp()
832 qp->r_rq.wq = vmalloc_user(sizeof(struct ipath_rwq) + in ipath_create_qp()
833 qp->r_rq.size * sz); in ipath_create_qp()
834 if (!qp->r_rq.wq) { in ipath_create_qp()
844 spin_lock_init(&qp->s_lock); in ipath_create_qp()
845 spin_lock_init(&qp->r_rq.lock); in ipath_create_qp()
846 atomic_set(&qp->refcount, 0); in ipath_create_qp()
847 init_waitqueue_head(&qp->wait); in ipath_create_qp()
848 init_waitqueue_head(&qp->wait_dma); in ipath_create_qp()
849 tasklet_init(&qp->s_task, ipath_do_send, (unsigned long)qp); in ipath_create_qp()
850 INIT_LIST_HEAD(&qp->piowait); in ipath_create_qp()
851 INIT_LIST_HEAD(&qp->timerwait); in ipath_create_qp()
852 qp->state = IB_QPS_RESET; in ipath_create_qp()
853 qp->s_wq = swq; in ipath_create_qp()
854 qp->s_size = init_attr->cap.max_send_wr + 1; in ipath_create_qp()
855 qp->s_max_sge = init_attr->cap.max_send_sge; in ipath_create_qp()
857 qp->s_flags = IPATH_S_SIGNAL_REQ_WR; in ipath_create_qp()
859 qp->s_flags = 0; in ipath_create_qp()
861 err = ipath_alloc_qpn(&dev->qp_table, qp, in ipath_create_qp()
865 vfree(qp->r_rq.wq); in ipath_create_qp()
868 qp->ip = NULL; in ipath_create_qp()
869 qp->s_tx = NULL; in ipath_create_qp()
870 ipath_reset_qp(qp, init_attr->qp_type); in ipath_create_qp()
886 if (!qp->r_rq.wq) { in ipath_create_qp()
897 qp->r_rq.size * sz; in ipath_create_qp()
899 qp->ip = in ipath_create_qp()
902 qp->r_rq.wq); in ipath_create_qp()
903 if (!qp->ip) { in ipath_create_qp()
908 err = ib_copy_to_udata(udata, &(qp->ip->offset), in ipath_create_qp()
909 sizeof(qp->ip->offset)); in ipath_create_qp()
927 if (qp->ip) { in ipath_create_qp()
929 list_add(&qp->ip->pending_mmaps, &dev->pending_mmaps); in ipath_create_qp()
933 ret = &qp->ibqp; in ipath_create_qp()
937 if (qp->ip) in ipath_create_qp()
938 kref_put(&qp->ip->ref, ipath_release_mmap_info); in ipath_create_qp()
940 vfree(qp->r_rq.wq); in ipath_create_qp()
941 ipath_free_qp(&dev->qp_table, qp); in ipath_create_qp()
942 free_qpn(&dev->qp_table, qp->ibqp.qp_num); in ipath_create_qp()
944 kfree(qp->r_ud_sg_list); in ipath_create_qp()
946 kfree(qp); in ipath_create_qp()
964 struct ipath_qp *qp = to_iqp(ibqp); in ipath_destroy_qp() local
968 spin_lock_irq(&qp->s_lock); in ipath_destroy_qp()
969 if (qp->state != IB_QPS_RESET) { in ipath_destroy_qp()
970 qp->state = IB_QPS_RESET; in ipath_destroy_qp()
972 if (!list_empty(&qp->timerwait)) in ipath_destroy_qp()
973 list_del_init(&qp->timerwait); in ipath_destroy_qp()
974 if (!list_empty(&qp->piowait)) in ipath_destroy_qp()
975 list_del_init(&qp->piowait); in ipath_destroy_qp()
977 qp->s_flags &= ~IPATH_S_ANY_WAIT; in ipath_destroy_qp()
978 spin_unlock_irq(&qp->s_lock); in ipath_destroy_qp()
980 tasklet_kill(&qp->s_task); in ipath_destroy_qp()
981 wait_event(qp->wait_dma, !atomic_read(&qp->s_dma_busy)); in ipath_destroy_qp()
983 spin_unlock_irq(&qp->s_lock); in ipath_destroy_qp()
985 ipath_free_qp(&dev->qp_table, qp); in ipath_destroy_qp()
987 if (qp->s_tx) { in ipath_destroy_qp()
988 atomic_dec(&qp->refcount); in ipath_destroy_qp()
989 if (qp->s_tx->txreq.flags & IPATH_SDMA_TXREQ_F_FREEBUF) in ipath_destroy_qp()
990 kfree(qp->s_tx->txreq.map_addr); in ipath_destroy_qp()
992 list_add(&qp->s_tx->txreq.list, &dev->txreq_free); in ipath_destroy_qp()
994 qp->s_tx = NULL; in ipath_destroy_qp()
997 wait_event(qp->wait, !atomic_read(&qp->refcount)); in ipath_destroy_qp()
1000 free_qpn(&dev->qp_table, qp->ibqp.qp_num); in ipath_destroy_qp()
1005 if (qp->ip) in ipath_destroy_qp()
1006 kref_put(&qp->ip->ref, ipath_release_mmap_info); in ipath_destroy_qp()
1008 vfree(qp->r_rq.wq); in ipath_destroy_qp()
1009 kfree(qp->r_ud_sg_list); in ipath_destroy_qp()
1010 vfree(qp->s_wq); in ipath_destroy_qp()
1011 kfree(qp); in ipath_destroy_qp()
1055 void ipath_get_credit(struct ipath_qp *qp, u32 aeth) in ipath_get_credit() argument
1065 qp->s_lsn = (u32) -1; in ipath_get_credit()
1066 else if (qp->s_lsn != (u32) -1) { in ipath_get_credit()
1069 if (ipath_cmp24(credit, qp->s_lsn) > 0) in ipath_get_credit()
1070 qp->s_lsn = credit; in ipath_get_credit()
1074 if ((qp->s_flags & IPATH_S_WAIT_SSN_CREDIT) && in ipath_get_credit()
1075 qp->s_cur != qp->s_head && in ipath_get_credit()
1076 (qp->s_lsn == (u32) -1 || in ipath_get_credit()
1077 ipath_cmp24(get_swqe_ptr(qp, qp->s_cur)->ssn, in ipath_get_credit()
1078 qp->s_lsn + 1) <= 0)) in ipath_get_credit()
1079 ipath_schedule_send(qp); in ipath_get_credit()