[dpdk-dev,8/8] net/mlx4: remove Tx completion elements counter

Message ID 1511871570-16826-9-git-send-email-matan@mellanox.com (mailing list archive)
State Superseded, archived
Delegated to: Shahaf Shuler
Headers

Checks

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

Commit Message

Matan Azrad Nov. 28, 2017, 12:19 p.m. UTC
  This counter saved the descriptor elements which are waiting to be
completted and was used to know if completion function should be
called.

This completion check can be done by other elements management
variables and we can prevent this counter management.

Remove this counter and replace the completion check easily by other
elements management variables.

Signed-off-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx4/mlx4_rxtx.c | 8 +++-----
 drivers/net/mlx4/mlx4_rxtx.h | 1 -
 drivers/net/mlx4/mlx4_txq.c  | 1 -
 3 files changed, 3 insertions(+), 7 deletions(-)
  

Comments

Adrien Mazarguil Dec. 6, 2017, 10:59 a.m. UTC | #1
On Tue, Nov 28, 2017 at 12:19:30PM +0000, Matan Azrad wrote:
> This counter saved the descriptor elements which are waiting to be
> completted and was used to know if completion function should be

completted => completed

> called.
> 
> This completion check can be done by other elements management
> variables and we can prevent this counter management.
> 
> Remove this counter and replace the completion check easily by other
> elements management variables.
> 
> Signed-off-by: Matan Azrad <matan@mellanox.com>

It's nice to finally get rid of this useless counter,

Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
  

Patch

diff --git a/drivers/net/mlx4/mlx4_rxtx.c b/drivers/net/mlx4/mlx4_rxtx.c
index b5aaf4c..b7b8489 100644
--- a/drivers/net/mlx4/mlx4_rxtx.c
+++ b/drivers/net/mlx4/mlx4_rxtx.c
@@ -363,7 +363,6 @@  struct pv {
 	/* Update CQ consumer index. */
 	cq->cons_index = cons_index;
 	*cq->set_ci_db = rte_cpu_to_be_32(cons_index & MLX4_CQ_DB_CI_MASK);
-	txq->elts_comp -= completed;
 	txq->elts_tail = elts_tail;
 }
 
@@ -535,15 +534,15 @@  struct pv {
 	const unsigned int elts_m = elts_n - 1;
 	unsigned int bytes_sent = 0;
 	unsigned int i;
-	unsigned int max;
+	unsigned int max = elts_head - txq->elts_tail;
 	struct mlx4_sq *sq = &txq->msq;
 	volatile struct mlx4_wqe_ctrl_seg *ctrl;
 	struct txq_elt *elt;
 
 	assert(txq->elts_comp_cd != 0);
-	if (likely(txq->elts_comp != 0))
+	if (likely(max >= txq->elts_comp_cd_init))
 		mlx4_txq_complete(txq, elts_m, sq);
-	max = (elts_n - (elts_head - txq->elts_tail));
+	max = elts_n - max;
 	assert(max >= 1);
 	assert(max <= elts_n);
 	/* Always leave one free entry in the ring. */
@@ -689,7 +688,6 @@  struct pv {
 	/* Ring QP doorbell. */
 	rte_write32(txq->msq.doorbell_qpn, txq->msq.db);
 	txq->elts_head += i;
-	txq->elts_comp += i;
 	return i;
 }
 
diff --git a/drivers/net/mlx4/mlx4_rxtx.h b/drivers/net/mlx4/mlx4_rxtx.h
index 9d83aeb..096a569 100644
--- a/drivers/net/mlx4/mlx4_rxtx.h
+++ b/drivers/net/mlx4/mlx4_rxtx.h
@@ -125,7 +125,6 @@  struct txq {
 	struct mlx4_cq mcq; /**< Info for directly manipulating the CQ. */
 	unsigned int elts_head; /**< Current index in (*elts)[]. */
 	unsigned int elts_tail; /**< First element awaiting completion. */
-	unsigned int elts_comp; /**< Number of packets awaiting completion. */
 	int elts_comp_cd; /**< Countdown for next completion. */
 	unsigned int elts_comp_cd_init; /**< Initial value for countdown. */
 	unsigned int elts_n; /**< (*elts)[] length. */
diff --git a/drivers/net/mlx4/mlx4_txq.c b/drivers/net/mlx4/mlx4_txq.c
index 253075a..b310aee 100644
--- a/drivers/net/mlx4/mlx4_txq.c
+++ b/drivers/net/mlx4/mlx4_txq.c
@@ -273,7 +273,6 @@  struct txq_mp2mr_mbuf_check_data {
 		.elts = elts,
 		.elts_head = 0,
 		.elts_tail = 0,
-		.elts_comp = 0,
 		/*
 		 * Request send completion every MLX4_PMD_TX_PER_COMP_REQ
 		 * packets or at least 4 times per ring.