[openib-general] [PATCH] libmthca: fix SRQ cleanup during destroy-qp
Jack Morgenstein
jackm at mellanox.co.il
Thu Dec 15 01:23:03 PST 2005
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 <jackm at mellanox.co.il>
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;
More information about the general
mailing list