Lines Matching refs:qp

14 static int next_opcode(struct rxe_qp *qp, struct rxe_send_wqe *wqe,
17 static inline void retry_first_write_send(struct rxe_qp *qp,
23 int to_send = (wqe->dma.resid > qp->mtu) ?
24 qp->mtu : wqe->dma.resid;
26 qp->req.opcode = next_opcode(qp, wqe,
38 static void req_retry(struct rxe_qp *qp)
45 struct rxe_queue *q = qp->sq.queue;
52 qp->req.wqe_index = cons;
53 qp->req.psn = qp->comp.psn;
54 qp->req.opcode = -1;
58 wqe = queue_addr_from_index(qp->sq.queue, wqe_index);
59 mask = wr_opcode_mask(wqe->wr.opcode, qp);
83 npsn = (qp->comp.psn - wqe->first_psn) &
85 retry_first_write_send(qp, wqe, npsn);
90 qp->mtu;
91 wqe->iova += npsn * qp->mtu;
101 struct rxe_qp *qp = from_timer(qp, t, rnr_nak_timer);
104 rxe_dbg_qp(qp, "nak timer fired\n");
106 spin_lock_irqsave(&qp->state_lock, flags);
107 if (qp->valid) {
109 qp->req.need_retry = 1;
110 qp->req.wait_for_rnr_timer = 0;
111 rxe_sched_task(&qp->req.task);
113 spin_unlock_irqrestore(&qp->state_lock, flags);
116 static void req_check_sq_drain_done(struct rxe_qp *qp)
124 spin_lock_irqsave(&qp->state_lock, flags);
125 if (qp_state(qp) == IB_QPS_SQD) {
126 q = qp->sq.queue;
127 index = qp->req.wqe_index;
135 if (!qp->attr.sq_draining)
144 qp->attr.sq_draining = 0;
145 spin_unlock_irqrestore(&qp->state_lock, flags);
147 if (qp->ibqp.event_handler) {
150 ev.device = qp->ibqp.device;
151 ev.element.qp = &qp->ibqp;
153 qp->ibqp.event_handler(&ev,
154 qp->ibqp.qp_context);
159 spin_unlock_irqrestore(&qp->state_lock, flags);
162 static struct rxe_send_wqe *__req_next_wqe(struct rxe_qp *qp)
164 struct rxe_queue *q = qp->sq.queue;
165 unsigned int index = qp->req.wqe_index;
175 static struct rxe_send_wqe *req_next_wqe(struct rxe_qp *qp)
180 req_check_sq_drain_done(qp);
182 wqe = __req_next_wqe(qp);
186 spin_lock_irqsave(&qp->state_lock, flags);
187 if (unlikely((qp_state(qp) == IB_QPS_SQD) &&
189 spin_unlock_irqrestore(&qp->state_lock, flags);
192 spin_unlock_irqrestore(&qp->state_lock, flags);
194 wqe->mask = wr_opcode_mask(wqe->wr.opcode, qp);
200 * @qp: the queue pair
206 static int rxe_wqe_is_fenced(struct rxe_qp *qp, struct rxe_send_wqe *wqe)
213 return qp->req.wqe_index != queue_get_consumer(qp->sq.queue,
221 atomic_read(&qp->req.rd_atomic) != qp->attr.max_rd_atomic;
224 static int next_opcode_rc(struct rxe_qp *qp, u32 opcode, int fits)
228 if (qp->req.opcode == IB_OPCODE_RC_RDMA_WRITE_FIRST ||
229 qp->req.opcode == IB_OPCODE_RC_RDMA_WRITE_MIDDLE)
239 if (qp->req.opcode == IB_OPCODE_RC_RDMA_WRITE_FIRST ||
240 qp->req.opcode == IB_OPCODE_RC_RDMA_WRITE_MIDDLE)
250 if (qp->req.opcode == IB_OPCODE_RC_SEND_FIRST ||
251 qp->req.opcode == IB_OPCODE_RC_SEND_MIDDLE)
261 if (qp->req.opcode == IB_OPCODE_RC_SEND_FIRST ||
262 qp->req.opcode == IB_OPCODE_RC_SEND_MIDDLE)
284 if (qp->req.opcode == IB_OPCODE_RC_SEND_FIRST ||
285 qp->req.opcode == IB_OPCODE_RC_SEND_MIDDLE)
303 static int next_opcode_uc(struct rxe_qp *qp, u32 opcode, int fits)
307 if (qp->req.opcode == IB_OPCODE_UC_RDMA_WRITE_FIRST ||
308 qp->req.opcode == IB_OPCODE_UC_RDMA_WRITE_MIDDLE)
318 if (qp->req.opcode == IB_OPCODE_UC_RDMA_WRITE_FIRST ||
319 qp->req.opcode == IB_OPCODE_UC_RDMA_WRITE_MIDDLE)
329 if (qp->req.opcode == IB_OPCODE_UC_SEND_FIRST ||
330 qp->req.opcode == IB_OPCODE_UC_SEND_MIDDLE)
340 if (qp->req.opcode == IB_OPCODE_UC_SEND_FIRST ||
341 qp->req.opcode == IB_OPCODE_UC_SEND_MIDDLE)
354 static int next_opcode(struct rxe_qp *qp, struct rxe_send_wqe *wqe,
357 int fits = (wqe->dma.resid <= qp->mtu);
359 switch (qp_type(qp)) {
361 return next_opcode_rc(qp, opcode, fits);
364 return next_opcode_uc(qp, opcode, fits);
384 static inline int check_init_depth(struct rxe_qp *qp, struct rxe_send_wqe *wqe)
391 qp->req.need_rd_atomic = 1;
392 depth = atomic_dec_return(&qp->req.rd_atomic);
395 qp->req.need_rd_atomic = 0;
400 atomic_inc(&qp->req.rd_atomic);
404 static inline int get_mtu(struct rxe_qp *qp)
406 struct rxe_dev *rxe = to_rdev(qp->ibqp.device);
408 if ((qp_type(qp) == IB_QPT_RC) || (qp_type(qp) == IB_QPT_UC))
409 return qp->mtu;
414 static struct sk_buff *init_req_packet(struct rxe_qp *qp,
420 struct rxe_dev *rxe = to_rdev(qp->ibqp.device);
446 qp->attr.dest_qp_num;
449 (qp->req.noack_pkts++ > RXE_MAX_PKT_PER_ACK));
451 qp->req.noack_pkts = 0;
488 if (qp->ibqp.qp_num == 1)
492 deth_set_sqp(pkt, qp->ibqp.qp_num);
498 static int finish_packet(struct rxe_qp *qp, struct rxe_av *av,
517 err = copy_data(qp->pd, 0, &wqe->dma,
541 static void update_wqe_state(struct rxe_qp *qp,
546 if (qp_type(qp) == IB_QPT_RC)
553 static void update_wqe_psn(struct rxe_qp *qp,
559 int num_pkt = (wqe->dma.resid + payload + qp->mtu - 1) / qp->mtu;
566 wqe->first_psn = qp->req.psn;
567 wqe->last_psn = (qp->req.psn + num_pkt - 1) & BTH_PSN_MASK;
571 qp->req.psn = (wqe->first_psn + num_pkt) & BTH_PSN_MASK;
573 qp->req.psn = (qp->req.psn + 1) & BTH_PSN_MASK;
577 struct rxe_qp *qp,
585 *rollback_psn = qp->req.psn;
589 struct rxe_qp *qp,
597 qp->req.psn = rollback_psn;
600 static void update_state(struct rxe_qp *qp, struct rxe_pkt_info *pkt)
602 qp->req.opcode = pkt->opcode;
605 qp->req.wqe_index = queue_next_index(qp->sq.queue,
606 qp->req.wqe_index);
608 qp->need_req_skb = 0;
610 if (qp->qp_timeout_jiffies && !timer_pending(&qp->retrans_timer))
611 mod_timer(&qp->retrans_timer,
612 jiffies + qp->qp_timeout_jiffies);
615 static int rxe_do_local_ops(struct rxe_qp *qp, struct rxe_send_wqe *wqe)
625 ret = rxe_invalidate_mw(qp, rkey);
627 ret = rxe_invalidate_mr(qp, rkey);
635 ret = rxe_reg_fast_mr(qp, wqe);
642 ret = rxe_bind_mw(qp, wqe);
649 rxe_dbg_qp(qp, "Unexpected send wqe opcode %d\n", opcode);
656 qp->req.wqe_index = queue_next_index(qp->sq.queue, qp->req.wqe_index);
662 rxe_sched_task(&qp->comp.task);
667 int rxe_requester(struct rxe_qp *qp)
669 struct rxe_dev *rxe = to_rdev(qp->ibqp.device);
681 struct rxe_queue *q = qp->sq.queue;
686 spin_lock_irqsave(&qp->state_lock, flags);
687 if (unlikely(!qp->valid)) {
688 spin_unlock_irqrestore(&qp->state_lock, flags);
692 if (unlikely(qp_state(qp) == IB_QPS_ERR)) {
693 wqe = __req_next_wqe(qp);
694 spin_unlock_irqrestore(&qp->state_lock, flags);
701 if (unlikely(qp_state(qp) == IB_QPS_RESET)) {
702 qp->req.wqe_index = queue_get_consumer(q,
704 qp->req.opcode = -1;
705 qp->req.need_rd_atomic = 0;
706 qp->req.wait_psn = 0;
707 qp->req.need_retry = 0;
708 qp->req.wait_for_rnr_timer = 0;
709 spin_unlock_irqrestore(&qp->state_lock, flags);
712 spin_unlock_irqrestore(&qp->state_lock, flags);
720 if (unlikely(qp->req.need_retry && !qp->req.wait_for_rnr_timer)) {
721 req_retry(qp);
722 qp->req.need_retry = 0;
725 wqe = req_next_wqe(qp);
729 if (rxe_wqe_is_fenced(qp, wqe)) {
730 qp->req.wait_fence = 1;
735 err = rxe_do_local_ops(qp, wqe);
742 if (unlikely(qp_type(qp) == IB_QPT_RC &&
743 psn_compare(qp->req.psn, (qp->comp.psn +
745 qp->req.wait_psn = 1;
750 if (unlikely(atomic_read(&qp->skb_out) >
752 qp->need_req_skb = 1;
756 opcode = next_opcode(qp, wqe, wqe->wr.opcode);
765 if (check_init_depth(qp, wqe))
769 mtu = get_mtu(qp);
773 if (qp_type(qp) == IB_QPT_UD) {
781 wqe->first_psn = qp->req.psn;
782 wqe->last_psn = qp->req.psn;
783 qp->req.psn = (qp->req.psn + 1) & BTH_PSN_MASK;
784 qp->req.opcode = IB_OPCODE_UD_SEND_ONLY;
785 qp->req.wqe_index = queue_next_index(qp->sq.queue,
786 qp->req.wqe_index);
789 rxe_sched_task(&qp->comp.task);
797 pkt.qp = qp;
798 pkt.psn = qp->req.psn;
803 save_state(wqe, qp, &rollback_wqe, &rollback_psn);
807 rxe_dbg_qp(qp, "Failed no address vector\n");
812 skb = init_req_packet(qp, av, wqe, opcode, payload, &pkt);
814 rxe_dbg_qp(qp, "Failed allocating skb\n");
821 err = finish_packet(qp, av, wqe, &pkt, skb, payload);
823 rxe_dbg_qp(qp, "Error during finish packet\n");
838 update_wqe_state(qp, wqe, &pkt);
839 update_wqe_psn(qp, wqe, &pkt, payload);
841 err = rxe_xmit_packet(qp, &pkt, skb);
851 rollback_state(wqe, qp, &rollback_wqe, rollback_psn);
856 qp->need_req_skb = 1;
858 rxe_sched_task(&qp->req.task);
862 update_state(qp, &pkt);
873 qp->req.wqe_index = queue_next_index(qp->sq.queue, qp->req.wqe_index);
875 rxe_qp_error(qp);