Roland> I think the solution is to keep track of the last
    Roland> completed index too, and then we can figure out how many
    Roland> WQEs a completion is for.

Something like this should do the trick I think...

--- hw/mthca/mthca_provider.h   (revision 1915)
+++ hw/mthca/mthca_provider.h   (working copy)
@@ -169,6 +169,7 @@ struct mthca_wq {
        spinlock_t lock;
        int        max;
        unsigned   next_ind;
+       unsigned   last_comp;
        unsigned   head;
        unsigned   tail;
        void      *last;
--- hw/mthca/mthca_cq.c (revision 1915)
+++ hw/mthca/mthca_cq.c (working copy)
@@ -453,7 +453,12 @@ static inline int mthca_poll_one(struct 
                entry->wr_id = (*cur_qp)->wrid[wqe_index];
        }
 
-       ++wq->tail;
+       if (wq->last_comp < wqe_index)
+               wq->tail += wqe_index - wq->last_comp;
+       else
+               wq->tail += wqe_index + wq->max - wq->last_comp;
+
+       wq->last_comp = wqe_index;
 
        if (0)
                mthca_dbg(dev, "%s completion for QP %06x, index %d (nr %d)\n",
--- hw/mthca/mthca_qp.c (revision 1915)
+++ hw/mthca/mthca_qp.c (working copy)
@@ -1082,6 +1082,7 @@ static void mthca_wq_init(struct mthca_w
 {
        spin_lock_init(&wq->lock);
        wq->next_ind  = 0;
+       wq->last_comp = wq->max - 1;
        wq->head      = 0;
        wq->tail      = 0;
        wq->last      = NULL;
_______________________________________________
openib-general mailing list
[email protected]
http://openib.org/mailman/listinfo/openib-general

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

Reply via email to