[03/10] net/enetc: batch process enetc clean Tx ring calls

Message ID 20200302143209.11854-4-hemant.agrawal@nxp.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/enetc: optimization and cleanup |

Checks

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

Commit Message

Hemant Agrawal March 2, 2020, 2:32 p.m. UTC
  From: Alex Marginean <alexandru.marginean@nxp.com>

Each call to enetc_clean_tx_ring will cost at least 150-200 CPU cycles
even if no clean-up is done, due to the CI register read.
We're only calling it once at the end of the function, on the assumption
that software is slower than hardware and hardware completed sending older
frames out by now.
We're also cleaning up the ring before kicking off Tx for the new batch to
minimize chances of contention on the Tx ring.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
---
 drivers/net/enetc/enetc_rxtx.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
  

Patch

diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c
index 395f5ecf4..958e3a21d 100644
--- a/drivers/net/enetc/enetc_rxtx.c
+++ b/drivers/net/enetc/enetc_rxtx.c
@@ -76,7 +76,6 @@  enetc_xmit_pkts(void *tx_queue,
 
 	start = 0;
 	while (nb_pkts--) {
-		enetc_clean_tx_ring(tx_ring);
 		tx_ring->q_swbd[i].buffer_addr = tx_pkts[start];
 		txbd = ENETC_TXBD(*tx_ring, i);
 		tx_swbd = &tx_ring->q_swbd[i];
@@ -92,6 +91,14 @@  enetc_xmit_pkts(void *tx_queue,
 			i = 0;
 	}
 
+	/* we're only cleaning up the Tx ring here, on the assumption that
+	 * software is slower than hardware and hardware completed sending
+	 * older frames out by now.
+	 * We're also cleaning up the ring before kicking off Tx for the new
+	 * batch to minimize chances of contention on the Tx ring
+	 */
+	enetc_clean_tx_ring(tx_ring);
+
 	tx_ring->next_to_use = i;
 	enetc_wr_reg(tx_ring->tcir, i);
 	return start;