[openib-general] [PATCH] mthca: fix SRQ cleanup during destroy-qp
Jack Morgenstein
jackm at mellanox.co.il
Thu Dec 15 01:51:58 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: openib/drivers/infiniband/hw/mthca/mthca_cq.c
===================================================================
--- openib.orig/drivers/infiniband/hw/mthca/mthca_cq.c
+++ openib/drivers/infiniband/hw/mthca/mthca_cq.c
@@ -150,6 +150,13 @@ struct mthca_err_cqe {
#define MTHCA_ARBEL_CQ_DB_REQ_NOT (2 << 24)
#define MTHCA_ARBEL_CQ_DB_REQ_NOT_MULT (3 << 24)
+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)
{
if (cq->is_direct)
@@ -296,7 +303,7 @@ void mthca_cq_clean(struct mthca_dev *de
while ((int) --prod_index - (int) cq->cons_index >= 0) {
cqe = get_cqe(cq, prod_index & cq->ibcq.cqe);
if (cqe->my_qpn == cpu_to_be32(qpn)) {
- if (srq)
+ if (srq && is_recv_cqe(cqe))
mthca_free_srq_wqe(srq, be32_to_cpu(cqe->wqe));
++nfreed;
} else if (nfreed)
More information about the general
mailing list