RDMA/cxgb4: Fix accounting for unsignaled SQ WRs to deal with wrap

When determining how many WRs are completed with a signaled CQE,
correctly deal with queue wraps.

Signed-off-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Vipul Pandya <vipul@chelsio.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
This commit is contained in:
Steve Wise 2013-08-06 21:04:36 +05:30 committed by Roland Dreier
parent 1cf24dcef4
commit 27ca34f54a

View file

@ -611,9 +611,12 @@ proc_cqe:
* to the first unsignaled one, and idx points to the
* signaled one. So adjust in_use based on this delta.
* if this is not completing any unsigned wrs, then the
* delta will be 0.
* delta will be 0. Handle wrapping also!
*/
wq->sq.in_use -= idx - wq->sq.cidx;
if (idx < wq->sq.cidx)
wq->sq.in_use -= wq->sq.size + idx - wq->sq.cidx;
else
wq->sq.in_use -= idx - wq->sq.cidx;
BUG_ON(wq->sq.in_use < 0 && wq->sq.in_use < wq->sq.size);
wq->sq.cidx = (uint16_t)idx;