RDMA/rxe: Compute PSN windows correctly
authorBob Pearson <rpearsonhpe@gmail.com>
Tue, 13 Oct 2020 17:07:42 +0000 (12:07 -0500)
committerJason Gunthorpe <jgg@nvidia.com>
Wed, 28 Oct 2020 13:34:20 +0000 (10:34 -0300)
The code which limited the number of unacknowledged PSNs was incorrect.
The PSNs are limited to 24 bits and wrap back to zero from 0x00ffffff.
The test was computing a 32 bit value which wraps at 32 bits so that
qp->req.psn can appear smaller than the limit when it is actually larger.

Replace '>' test with psn_compare which is used for other PSN comparisons
and correctly handles the 24 bit size.

Fixes: 8700e3e7c485 ("Soft RoCE driver")
Link: https://lore.kernel.org/r/20201013170741.3590-1-rpearson@hpe.com
Signed-off-by: Bob Pearson <rpearson@hpe.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/sw/rxe/rxe_req.c

index af3923bf0a36bf32bbcb3d4efedcc2b6d0ffc1f1..d4917646641aad4e036defd8ed20ff9afe94e590 100644 (file)
@@ -634,7 +634,8 @@ next_wqe:
        }
 
        if (unlikely(qp_type(qp) == IB_QPT_RC &&
-                    qp->req.psn > (qp->comp.psn + RXE_MAX_UNACKED_PSNS))) {
+               psn_compare(qp->req.psn, (qp->comp.psn +
+                               RXE_MAX_UNACKED_PSNS)) > 0)) {
                qp->req.wait_psn = 1;
                goto exit;
        }