[v1,09/15] examples/l2fwd: move drain buffers to new function

Message ID 1528971477-14156-10-git-send-email-anoob.joseph@caviumnetworks.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series preparing l2fwd for eventmode additions |

Checks

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

Commit Message

Anoob Joseph June 14, 2018, 10:17 a.m. UTC
  v1:
* Replaced 'unsigned' with 'unsigned int'

Signed-off-by: Anoob Joseph <anoob.joseph@caviumnetworks.com>
---
 examples/l2fwd/l2fwd_worker.c | 34 ++++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 deletions(-)
  

Comments

De Lara Guarch, Pablo July 9, 2018, 10:49 p.m. UTC | #1
> -----Original Message-----
> From: Anoob Joseph [mailto:anoob.joseph@caviumnetworks.com]
> Sent: Thursday, June 14, 2018 11:18 AM
> To: Richardson, Bruce <bruce.richardson@intel.com>; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>
> Cc: Anoob Joseph <anoob.joseph@caviumnetworks.com>; Jerin Jacob
> <jerin.jacob@caviumnetworks.com>; Narayana Prasad
> <narayanaprasad.athreya@caviumnetworks.com>; dev@dpdk.org
> Subject: [PATCH v1 09/15] examples/l2fwd: move drain buffers to new function
> 
> v1:
> * Replaced 'unsigned' with 'unsigned int'
> 

This changelog should not go in the commit message, but after the three dashes, following the Signed-off-by tag.
  
Anoob Joseph July 10, 2018, 3:17 a.m. UTC | #2
Hi Pablo,


On 10-07-2018 04:19, De Lara Guarch, Pablo wrote:
> External Email
>
>> -----Original Message-----
>> From: Anoob Joseph [mailto:anoob.joseph@caviumnetworks.com]
>> Sent: Thursday, June 14, 2018 11:18 AM
>> To: Richardson, Bruce <bruce.richardson@intel.com>; De Lara Guarch, Pablo
>> <pablo.de.lara.guarch@intel.com>
>> Cc: Anoob Joseph <anoob.joseph@caviumnetworks.com>; Jerin Jacob
>> <jerin.jacob@caviumnetworks.com>; Narayana Prasad
>> <narayanaprasad.athreya@caviumnetworks.com>; dev@dpdk.org
>> Subject: [PATCH v1 09/15] examples/l2fwd: move drain buffers to new function
>>
>> v1:
>> * Replaced 'unsigned' with 'unsigned int'
>>
> This changelog should not go in the commit message, but after the three dashes, following the Signed-off-by tag.
>
Will correct this when I send the revised patch. Thanks for pointing 
this out.

Anoob
  

Patch

diff --git a/examples/l2fwd/l2fwd_worker.c b/examples/l2fwd/l2fwd_worker.c
index ad5468a..dfa78ed 100644
--- a/examples/l2fwd/l2fwd_worker.c
+++ b/examples/l2fwd/l2fwd_worker.c
@@ -76,6 +76,24 @@  print_stats(void)
 	printf("\n====================================================\n");
 }
 
+static inline void
+l2fwd_drain_buffers(struct lcore_queue_conf *qconf)
+{
+	unsigned int i, sent;
+	unsigned int portid;
+	struct rte_eth_dev_tx_buffer *buffer;
+
+	for (i = 0; i < qconf->n_rx_port; i++) {
+
+		portid = l2fwd_dst_ports[qconf->rx_port_list[i]];
+		buffer = tx_buffer[portid];
+
+		sent = rte_eth_tx_buffer_flush(portid, 0, buffer);
+		if (sent)
+			port_statistics[portid].tx += sent;
+	}
+}
+
 static void
 l2fwd_mac_updating(struct rte_mbuf *m, unsigned int dest_portid)
 {
@@ -116,7 +134,6 @@  l2fwd_main_loop(void)
 {
 	struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
 	struct rte_mbuf *m;
-	int sent;
 	unsigned int lcore_id;
 	unsigned int master_core_id;
 	uint64_t prev_tsc, diff_tsc, cur_tsc, timer_tsc;
@@ -124,7 +141,6 @@  l2fwd_main_loop(void)
 	struct lcore_queue_conf *qconf;
 	const uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1)
 			/ US_PER_S * BURST_TX_DRAIN_US;
-	struct rte_eth_dev_tx_buffer *buffer;
 
 	prev_tsc = 0;
 	timer_tsc = 0;
@@ -159,18 +175,8 @@  l2fwd_main_loop(void)
 		diff_tsc = cur_tsc - prev_tsc;
 		if (unlikely(diff_tsc > drain_tsc)) {
 
-			for (i = 0; i < qconf->n_rx_port; i++) {
-
-				portid =
-					l2fwd_dst_ports[qconf->rx_port_list[i]];
-				buffer = tx_buffer[portid];
-
-				sent = rte_eth_tx_buffer_flush(portid, 0,
-						buffer);
-				if (sent)
-					port_statistics[portid].tx += sent;
-
-			}
+			/* Drain buffers */
+			l2fwd_drain_buffers(qconf);
 
 			/* if timer is enabled */
 			if (timer_period > 0) {