[v1,13/15] examples/l2fwd: move pkt send code to a new function

Message ID 1528976946-14396-14-git-send-email-anoob.joseph@caviumnetworks.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [v1,01/15] examples/l2fwd: add new header to move common code |

Checks

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

Commit Message

Anoob Joseph June 14, 2018, 11:49 a.m. UTC
  Signed-off-by: Anoob Joseph <anoob.joseph@caviumnetworks.com>
---
v1:
* Replaced 'unsigned' with 'unsigned int'

 examples/l2fwd/l2fwd_worker.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
  

Patch

diff --git a/examples/l2fwd/l2fwd_worker.c b/examples/l2fwd/l2fwd_worker.c
index d6a5e90..bac1946 100644
--- a/examples/l2fwd/l2fwd_worker.c
+++ b/examples/l2fwd/l2fwd_worker.c
@@ -154,22 +154,30 @@  l2fwd_mac_updating(struct rte_mbuf *m, unsigned int dest_portid)
 	ether_addr_copy(&l2fwd_ports_eth_addr[dest_portid], &eth->s_addr);
 }
 
+static inline void
+l2fwd_send_pkt(struct rte_mbuf *tx_pkt, unsigned int port_id)
+{
+	int sent;
+	struct rte_eth_dev_tx_buffer *buffer;
+
+	buffer = tx_buffer[port_id];
+	sent = rte_eth_tx_buffer(port_id, 0, buffer, tx_pkt);
+	if (sent)
+		port_statistics[port_id].tx += sent;
+}
+
 static void
 l2fwd_simple_forward(struct rte_mbuf *m, unsigned int portid)
 {
 	unsigned int dst_port;
-	int sent;
-	struct rte_eth_dev_tx_buffer *buffer;
 
 	dst_port = l2fwd_dst_ports[portid];
 
 	if (mac_updating)
 		l2fwd_mac_updating(m, dst_port);
 
-	buffer = tx_buffer[dst_port];
-	sent = rte_eth_tx_buffer(dst_port, 0, buffer, m);
-	if (sent)
-		port_statistics[dst_port].tx += sent;
+	/* Send packet */
+	l2fwd_send_pkt(m, dst_port);
 }
 
 /* main processing loop */