[PATCH] Pre link receive WQEs

Pre linking of receive WQEs is required in Tavor mode. This is
required for both SRQ and regular QPs.
Remove an always true condition.
For memfree linking to the nxt wqe is moved to mthca_free_srq_wqe()
as in Tavor mode.

Signed-off-by: Eli Cohen <[EMAIL PROTECTED]>
Reviewed-by: Jack Morgenstein <[EMAIL PROTECTED]>
---
 src/qp.c  |   14 ++++++++------
 src/srq.c |   28 +++++++++++++++-------------
 2 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/src/qp.c b/src/qp.c
index 841e316..f3aa6c7 100644
--- a/src/qp.c
+++ b/src/qp.c
@@ -360,7 +360,6 @@ int mthca_tavor_post_recv(struct ibv_qp *ibqp, struct 
ibv_recv_wr *wr,
                prev_wqe = qp->rq.last;
                qp->rq.last = wqe;
 
-               ((struct mthca_next_seg *) wqe)->nda_op = 0;
                ((struct mthca_next_seg *) wqe)->ee_nds =
                        htonl(MTHCA_NEXT_DBD);
                ((struct mthca_next_seg *) wqe)->flags =
@@ -388,9 +387,6 @@ int mthca_tavor_post_recv(struct ibv_qp *ibqp, struct 
ibv_recv_wr *wr,
 
                qp->wrid[ind + qp->sq.max] = wr->wr_id;
 
-               ((struct mthca_next_seg *) prev_wqe)->nda_op =
-                       htonl((ind << qp->rq.wqe_shift) | 1);
-               wmb();
                ((struct mthca_next_seg *) prev_wqe)->ee_nds =
                        htonl(MTHCA_NEXT_DBD | size);
 
@@ -786,6 +782,8 @@ int mthca_alloc_qp_buf(struct ibv_pd *pd, struct ibv_qp_cap 
*cap,
 {
        int size;
        int max_sq_sge;
+       struct mthca_next_seg *next;
+       int i;
 
        qp->rq.max_gs    = cap->max_recv_sge;
        qp->sq.max_gs    = cap->max_send_sge;
@@ -860,9 +858,7 @@ int mthca_alloc_qp_buf(struct ibv_pd *pd, struct ibv_qp_cap 
*cap,
        memset(qp->buf.buf, 0, qp->buf_size);
 
        if (mthca_is_memfree(pd->context)) {
-               struct mthca_next_seg *next;
                struct mthca_data_seg *scatter;
-               int i;
                uint32_t sz;
 
                sz = htonl((sizeof (struct mthca_next_seg) +
@@ -886,6 +882,12 @@ int mthca_alloc_qp_buf(struct ibv_pd *pd, struct 
ibv_qp_cap *cap,
                                              qp->sq.wqe_shift) +
                                             qp->send_wqe_offset);
                }
+       } else {
+               for (i = 0; i < qp->rq.max; ++i) {
+                       next = get_recv_wqe(qp, i);
+                       next->nda_op = htonl((((i + 1) & (qp->rq.max - 1)) <<
+                                            qp->rq.wqe_shift) | 1);
+               }
        }
 
        qp->sq.last = get_send_wqe(qp, qp->sq.max - 1);
diff --git a/src/srq.c b/src/srq.c
index f9fc006..1d326b8 100644
--- a/src/srq.c
+++ b/src/srq.c
@@ -64,13 +64,13 @@ static inline int *wqe_to_link(void *wqe)
 
 void mthca_free_srq_wqe(struct mthca_srq *srq, int ind)
 {
-       pthread_spin_lock(&srq->lock);
+       struct mthca_next_seg *last_free;
 
-       if (srq->first_free >= 0)
-               *wqe_to_link(get_wqe(srq, srq->last_free)) = ind;
-       else
-               srq->first_free = ind;
+       pthread_spin_lock(&srq->lock);
 
+       last_free = get_wqe(srq, srq->last_free);
+       *wqe_to_link(last_free) = ind;
+       last_free->nda_op = htonl((ind << srq->wqe_shift) | 1);
        *wqe_to_link(get_wqe(srq, ind)) = -1;
        srq->last_free = ind;
 
@@ -117,7 +117,6 @@ int mthca_tavor_post_srq_recv(struct ibv_srq *ibsrq,
                prev_wqe  = srq->last;
                srq->last = wqe;
 
-               ((struct mthca_next_seg *) wqe)->nda_op = 0;
                ((struct mthca_next_seg *) wqe)->ee_nds = 0;
                /* flags field will always remain 0 */
 
@@ -146,9 +145,6 @@ int mthca_tavor_post_srq_recv(struct ibv_srq *ibsrq,
                        ((struct mthca_data_seg *) wqe)->addr = 0;
                }
 
-               ((struct mthca_next_seg *) prev_wqe)->nda_op =
-                       htonl((ind << srq->wqe_shift) | 1);
-               wmb();
                ((struct mthca_next_seg *) prev_wqe)->ee_nds =
                        htonl(MTHCA_NEXT_DBD);
 
@@ -222,8 +218,6 @@ int mthca_arbel_post_srq_recv(struct ibv_srq *ibsrq,
                        break;
                }
 
-               ((struct mthca_next_seg *) wqe)->nda_op =
-                       htonl((next_ind << srq->wqe_shift) | 1);
                ((struct mthca_next_seg *) wqe)->ee_nds = 0;
                /* flags field will always remain 0 */
 
@@ -306,9 +300,17 @@ int mthca_alloc_srq_buf(struct ibv_pd *pd, struct 
ibv_srq_attr *attr,
         */
 
        for (i = 0; i < srq->max; ++i) {
-               wqe = get_wqe(srq, i);
+               struct mthca_next_seg *next;
 
-               *wqe_to_link(wqe) = i < srq->max - 1 ? i + 1 : -1;
+               next = wqe = get_wqe(srq, i);
+
+               if (i < srq->max - 1) {
+                       *wqe_to_link(wqe) = i + 1;
+                       next->nda_op = htonl(((i + 1) << srq->wqe_shift) | 1);
+               } else {
+                       *wqe_to_link(wqe) = -1;
+                       next->nda_op = 0;
+               }
 
                for (scatter = wqe + sizeof (struct mthca_next_seg);
                     (void *) scatter < wqe + (1 << srq->wqe_shift);
-- 
1.5.3.8


_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to