net/mlx5: fix memory region boundary checks
authorShahaf Shuler <shahafs@mellanox.com>
Thu, 25 Jan 2018 16:18:03 +0000 (18:18 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 29 Jan 2018 09:04:28 +0000 (10:04 +0100)
Since commit f81ec748434b ("net/mlx5: fix memory region lookup") the
Memory Region (MR) are no longer overlaps.

Comparing the end address of the MR should be exclusive, otherwise two
contiguous MRs may cause wrong matching.

Fixes: f81ec748434b ("net/mlx5: fix memory region lookup")
Cc: stable@dpdk.org
Signed-off-by: Xueming Li <xuemingl@mellanox.com>
Signed-off-by: Shahaf Shuler <shahafs@mellanox.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
drivers/net/mlx5/mlx5_rxtx.h

index 7297f01..6d1bc85 100644 (file)
@@ -552,7 +552,7 @@ mlx5_tx_mb2mr(struct mlx5_txq_data *txq, struct rte_mbuf *mb)
        struct mlx5_mr *mr;
 
        assert(i < RTE_DIM(txq->mp2mr));
-       if (likely(txq->mp2mr[i]->start <= addr && txq->mp2mr[i]->end >= addr))
+       if (likely(txq->mp2mr[i]->start <= addr && txq->mp2mr[i]->end > addr))
                return txq->mp2mr[i]->lkey;
        for (i = 0; (i != RTE_DIM(txq->mp2mr)); ++i) {
                if (unlikely(txq->mp2mr[i] == NULL ||
@@ -561,7 +561,7 @@ mlx5_tx_mb2mr(struct mlx5_txq_data *txq, struct rte_mbuf *mb)
                        break;
                }
                if (txq->mp2mr[i]->start <= addr &&
-                   txq->mp2mr[i]->end >= addr) {
+                   txq->mp2mr[i]->end > addr) {
                        assert(txq->mp2mr[i]->lkey != (uint32_t)-1);
                        txq->mr_cache_idx = i;
                        return txq->mp2mr[i]->lkey;