When cleaning up a CQ for a QP attached to SRQ, need to free an SRQ wqe only if the CQE is a receive completion.
Signed-off-by: Jack Morgenstein <[EMAIL PROTECTED]> Index: latest/src/userspace/libmthca/src/cq.c =================================================================== --- latest.orig/src/userspace/libmthca/src/cq.c +++ latest/src/userspace/libmthca/src/cq.c @@ -121,6 +121,13 @@ struct mthca_err_cqe { uint8_t owner; }; +static inline int is_recv_cqe(struct mthca_cqe * cqe) +{ + return (((cqe->opcode & MTHCA_ERROR_CQE_OPCODE_MASK) == + MTHCA_ERROR_CQE_OPCODE_MASK) ? + !(cqe->opcode & 0x01) : !(cqe->is_send & 0x80)); +} + static inline struct mthca_cqe *get_cqe(struct mthca_cq *cq, int entry) { return cq->buf + entry * MTHCA_CQ_ENTRY_SIZE; @@ -549,7 +556,7 @@ void mthca_cq_clean(struct mthca_cq *cq, while ((int) --prod_index - (int) cq->cons_index >= 0) { cqe = get_cqe(cq, prod_index & cq->ibv_cq.cqe); if (cqe->my_qpn == htonl(qpn)) { - if (srq) + if (srq && is_recv_cqe(cqe)) mthca_free_srq_wqe(srq, ntohl(cqe->wqe) >> srq->wqe_shift); ++nfreed; _______________________________________________ openib-general mailing list openib-general@openib.org http://openib.org/mailman/listinfo/openib-general To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general