[ofa-general] [PATCH 1 of 2] libmlx4: deal with ownership bit wraparound when cleaning cq
Jack Morgenstein
jackm at dev.mellanox.co.il
Tue Jun 12 22:35:13 PDT 2007
1. ntohl should apply only to cqe->my_qpn.
2. when compacting the cqe's, need to preserve the
proper ownership value of the cqe in case of wraparound.
Found by Ronni Zimmerman of Mellanox.
Signed-off-by: Jack Morgenstein <jackm at dev.mellanox.co.il>
diff --git a/src/cq.c b/src/cq.c
index a1831ff..ead1004 100644
--- a/src/cq.c
+++ b/src/cq.c
@@ -404,14 +404,24 @@ void mlx4_cq_clean(struct mlx4_cq *cq, uint32_t qpn, struct mlx4_srq *srq)
* that match our QP by copying older entries on top of them.
*/
while ((int) --prod_index - (int) cq->cons_index >= 0) {
+ struct mlx4_cqe *q;
+ uint8_t own;
cqe = get_cqe(cq, prod_index & cq->ibv_cq.cqe);
- if (ntohl((cqe->my_qpn) & 0xffffff) == qpn) {
+ if ((ntohl(cqe->my_qpn) & 0xffffff) == qpn) {
if (srq && !(cqe->owner_sr_opcode & MLX4_CQE_IS_SEND_MASK))
mlx4_free_srq_wqe(srq, ntohs(cqe->wqe_index));
++nfreed;
- } else if (nfreed)
- memcpy(get_cqe(cq, (prod_index + nfreed) & cq->ibv_cq.cqe),
- cqe, sizeof *cqe);
+ } else if (nfreed) {
+ /*
+ * preserve proper ownership bit value in case of
+ * wraparound.
+ */
+ q = get_cqe(cq, (prod_index + nfreed) & cq->ibv_cq.cqe);
+ own = q->owner_sr_opcode & MLX4_CQE_OWNER_MASK;
+ memcpy(q, cqe, sizeof *cqe);
+ q->owner_sr_opcode =
+ (q->owner_sr_opcode & ~MLX4_CQE_OWNER_MASK) | own;
+ }
}
if (nfreed) {
More information about the general
mailing list