| @@ -554,13 +554,13 @@ out: · 553 unmodified lines |
| 554 | 554 | return ret; |
| 555 | 555 | } |
| 556 | 556 | |
| 557 | | −static inline void *get_sq_wqe(struct pvrdma_qp *qp, int n) |
| 557 | +static inline void *get_sq_wqe(struct pvrdma_qp *qp, unsigned int n) |
| 558 | 558 | { |
| 559 | 559 | return pvrdma_page_dir_get_ptr(&qp->pdir, |
| 560 | 560 | qp->sq.offset + n * qp->sq.wqe_size); |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | | −static inline void *get_rq_wqe(struct pvrdma_qp *qp, int n) |
| 563 | +static inline void *get_rq_wqe(struct pvrdma_qp *qp, unsigned int n) |
| 564 | 564 | { |
| 565 | 565 | return pvrdma_page_dir_get_ptr(&qp->pdir, |
| 566 | 566 | qp->rq.offset + n * qp->rq.wqe_size); |
| @@ -598,9 +598,7 @@ int pvrdma_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, · 31 unmodified lines |
| 598 | 598 | unsigned long flags; |
| 599 | 599 | struct pvrdma_sq_wqe_hdr *wqe_hdr; |
| 600 | 600 | struct pvrdma_sge *sge; |
| 601 | | − int i, index; |
| 602 | | − int nreq; |
| 603 | | − int ret; |
| 601 | + int i, ret; |
| 604 | 602 | |
| 605 | 603 | /* |
| 606 | 604 | * In states lower than RTS, we can fail immediately. In other states, |
| @@ -613,9 +611,8 @@ int pvrdma_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, · 6 unmodified lines |
| 613 | 611 | |
| 614 | 612 | spin_lock_irqsave(&qp->sq.lock, flags); |
| 615 | 613 | |
| 616 | | − index = pvrdma_idx(&qp->sq.ring->prod_tail, qp->sq.wqe_cnt); |
| 617 | | − for (nreq = 0; wr; nreq++, wr = wr->next) { |
| 618 | | − unsigned int tail; |
| 614 | + while (wr) { |
| 615 | + unsigned int tail = 0; |
| 619 | 616 | |
| 620 | 617 | if (unlikely(!pvrdma_idx_ring_has_space( |
| 621 | 618 | qp->sq.ring, qp->sq.wqe_cnt, &tail))) { |
| @@ -680,7 +677,7 @@ int pvrdma_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, · 58 unmodified lines |
| 680 | 677 | } |
| 681 | 678 | } |
| 682 | 679 | |
| 683 | | − wqe_hdr = (struct pvrdma_sq_wqe_hdr *)get_sq_wqe(qp, index); |
| 680 | + wqe_hdr = (struct pvrdma_sq_wqe_hdr *)get_sq_wqe(qp, tail); |
| 684 | 681 | memset(wqe_hdr, 0, sizeof(*wqe_hdr)); |
| 685 | 682 | wqe_hdr->wr_id = wr->wr_id; |
| 686 | 683 | wqe_hdr->num_sge = wr->num_sge; |
| @@ -771,12 +768,11 @@ int pvrdma_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, · 84 unmodified lines |
| 771 | 768 | /* Make sure wqe is written before index update */ |
| 772 | 769 | smp_wmb(); |
| 773 | 770 | |
| 774 | | − index++; |
| 775 | | − if (unlikely(index >= qp->sq.wqe_cnt)) |
| 776 | | − index = 0; |
| 777 | 771 | /* Update shared sq ring */ |
| 778 | 772 | pvrdma_idx_ring_inc(&qp->sq.ring->prod_tail, |
| 779 | 773 | qp->sq.wqe_cnt); |
| 774 | + |
| 775 | + wr = wr->next; |
| 780 | 776 | } |
| 781 | 777 | |
| 782 | 778 | ret = 0; |
| @@ -806,7 +802,6 @@ int pvrdma_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, · 23 unmodified lines |
| 806 | 802 | struct pvrdma_qp *qp = to_vqp(ibqp); |
| 807 | 803 | struct pvrdma_rq_wqe_hdr *wqe_hdr; |
| 808 | 804 | struct pvrdma_sge *sge; |
| 809 | | − int index, nreq; |
| 810 | 805 | int ret = 0; |
| 811 | 806 | int i; |
| 812 | 807 | |
| @@ -821,9 +816,8 @@ int pvrdma_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, · 8 unmodified lines |
| 821 | 816 | |
| 822 | 817 | spin_lock_irqsave(&qp->rq.lock, flags); |
| 823 | 818 | |
| 824 | | − index = pvrdma_idx(&qp->rq.ring->prod_tail, qp->rq.wqe_cnt); |
| 825 | | − for (nreq = 0; wr; nreq++, wr = wr->next) { |
| 826 | | − unsigned int tail; |
| 819 | + while (wr) { |
| 820 | + unsigned int tail = 0; |
| 827 | 821 | |
| 828 | 822 | if (unlikely(wr->num_sge > qp->rq.max_sg || |
| 829 | 823 | wr->num_sge < 0)) { |
| @@ -843,7 +837,7 @@ int pvrdma_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, · 13 unmodified lines |
| 843 | 837 | goto out; |
| 844 | 838 | } |
| 845 | 839 | |
| 846 | | − wqe_hdr = (struct pvrdma_rq_wqe_hdr *)get_rq_wqe(qp, index); |
| 840 | + wqe_hdr = (struct pvrdma_rq_wqe_hdr *)get_rq_wqe(qp, tail); |
| 847 | 841 | wqe_hdr->wr_id = wr->wr_id; |
| 848 | 842 | wqe_hdr->num_sge = wr->num_sge; |
| 849 | 843 | wqe_hdr->total_len = 0; |
| @@ -859,12 +853,11 @@ int pvrdma_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, · 9 unmodified lines |
| 859 | 853 | /* Make sure wqe is written before index update */ |
| 860 | 854 | smp_wmb(); |
| 861 | 855 | |
| 862 | | − index++; |
| 863 | | − if (unlikely(index >= qp->rq.wqe_cnt)) |
| 864 | | − index = 0; |
| 865 | 856 | /* Update shared rq ring */ |
| 866 | 857 | pvrdma_idx_ring_inc(&qp->rq.ring->prod_tail, |
| 867 | 858 | qp->rq.wqe_cnt); |
| 859 | + |
| 860 | + wr = wr->next; |
| 868 | 861 | } |
| 869 | 862 | |
| 870 | 863 | spin_unlock_irqrestore(&qp->rq.lock, flags); |