[05/10] port: prevent unnecessary flush for the Ethernet device output port

Message ID 20220805220029.1096212-6-cristian.dumitrescu@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series port: implement output port non-blocking behavior |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Cristian Dumitrescu Aug. 5, 2022, 10 p.m. UTC
  Do not flush the buffered packets unnecessarily when a burst was sent
since the last flush call.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 lib/port/rte_swx_port_ethdev.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Patch

diff --git a/lib/port/rte_swx_port_ethdev.c b/lib/port/rte_swx_port_ethdev.c
index 8a1da71003..7cb3c4dfb1 100644
--- a/lib/port/rte_swx_port_ethdev.c
+++ b/lib/port/rte_swx_port_ethdev.c
@@ -174,6 +174,7 @@  struct writer {
 	struct rte_mbuf **pkts;
 	int n_pkts;
 	uint32_t n_bytes;
+	int flush_flag;
 };
 
 static void *
@@ -249,6 +250,7 @@  __writer_flush(struct writer *p)
 	p->stats.n_bytes_drop = n_bytes_drop_total + n_bytes_drop;
 	p->n_pkts = 0;
 	p->n_bytes = 0;
+	p->flush_flag = 0;
 
 	TRACE("[Ethdev TX port %u queue %u] Buffered packets flushed: %d out, %d dropped\n",
 	      (uint32_t)p->params.port_id,
@@ -363,8 +365,10 @@  writer_flush(void *port)
 {
 	struct writer *p = port;
 
-	if (p->n_pkts)
+	if (p->n_pkts && p->flush_flag)
 		__writer_flush(p);
+
+	p->flush_flag = 1;
 }
 
 static void