[08/10] port: prevent unnecessary flush for the ring output port

Message ID 20220805220029.1096212-9-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_ring.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Patch

diff --git a/lib/port/rte_swx_port_ring.c b/lib/port/rte_swx_port_ring.c
index 7cdcd4b638..d0058087bd 100644
--- a/lib/port/rte_swx_port_ring.c
+++ b/lib/port/rte_swx_port_ring.c
@@ -173,6 +173,7 @@  struct writer {
 	struct rte_mbuf **pkts;
 	int n_pkts;
 	uint32_t n_bytes;
+	int flush_flag;
 };
 
 static void *
@@ -253,6 +254,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("[Ring %s] Buffered packets flushed: %d out, %d dropped\n",
 	      p->params.name,
@@ -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