[dpdk-dev,4/5] net/mlx5: fix memory registration cache last index

Message ID fdd12318a13867d2bd06b26aaee34f28cea787b4.1516727100.git.shahafs@mellanox.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Shahaf Shuler Jan. 23, 2018, 5:08 p.m. UTC
  In case memory registration cache is full the new mempool will be
inserted in the last index of the array.

Update the last entry being hit to reflect it.

Fixes: 6cb559d67b83 ("net/mlx5: add vectorized Rx/Tx burst for x86")
Cc: stable@dpdk.org
Cc: yskoh@mellanox.com

Signed-off-by: Shahaf Shuler <shahafs@mellanox.com>
---
 drivers/net/mlx5/mlx5_rxtx.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h
index 2934f9fb3..4bedfb89b 100644
--- a/drivers/net/mlx5/mlx5_rxtx.h
+++ b/drivers/net/mlx5/mlx5_rxtx.h
@@ -572,7 +572,6 @@  mlx5_tx_mb2mr(struct mlx5_txq_data *txq, struct rte_mbuf *mb)
 			return txq->mp2mr[i]->lkey;
 		}
 	}
-	txq->mr_cache_idx = 0;
 	mp = mlx5_tx_mb2mp(mb);
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
 		WARN("Using unregistered mempool 0x%p(%s) in secondary process,"
@@ -588,6 +587,7 @@  mlx5_tx_mb2mr(struct mlx5_txq_data *txq, struct rte_mbuf *mb)
 	 */
 	if (mr) {
 		rte_atomic32_inc(&mr->refcnt);
+		txq->mr_cache_idx = i >= RTE_DIM(txq->mp2mr) ? i - 1 : i;
 		return mr->lkey;
 	} else {
 		WARN("Failed to register mempool 0x%p(%s)",