All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: dev-VfR2kkLFssw@public.gmane.org
Subject: [RFC PATCH DRAFT 2/2] l2fwd: update l2fwd to use tx_buffer API
Date: Tue, 24 Jun 2014 23:32:16 +0100	[thread overview]
Message-ID: <1403649136-23551-3-git-send-email-bruce.richardson@intel.com> (raw)
In-Reply-To: <1403649136-23551-1-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

The internal buffering of packets for TX done in l2fwd is no longer
needed, so replace this code with calls to the new rte_eth_tx_buffer*
APIs.
---
 examples/l2fwd/main.c | 61 ++++++---------------------------------------------
 1 file changed, 7 insertions(+), 54 deletions(-)

diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c
index 4069d7c..5ca5709 100644
--- a/examples/l2fwd/main.c
+++ b/examples/l2fwd/main.c
@@ -231,52 +231,6 @@ print_stats(void)
 	printf("\n====================================================\n");
 }
 
-/* Send the burst of packets on an output interface */
-static int
-l2fwd_send_burst(struct lcore_queue_conf *qconf, unsigned n, uint8_t port)
-{
-	struct rte_mbuf **m_table;
-	unsigned ret;
-	unsigned queueid =0;
-
-	m_table = (struct rte_mbuf **)qconf->tx_mbufs[port].m_table;
-
-	ret = rte_eth_tx_burst(port, (uint16_t) queueid, m_table, (uint16_t) n);
-	port_statistics[port].tx += ret;
-	if (unlikely(ret < n)) {
-		port_statistics[port].dropped += (n - ret);
-		do {
-			rte_pktmbuf_free(m_table[ret]);
-		} while (++ret < n);
-	}
-
-	return 0;
-}
-
-/* Enqueue packets for TX and prepare them to be sent */
-static int
-l2fwd_send_packet(struct rte_mbuf *m, uint8_t port)
-{
-	unsigned lcore_id, len;
-	struct lcore_queue_conf *qconf;
-
-	lcore_id = rte_lcore_id();
-
-	qconf = &lcore_queue_conf[lcore_id];
-	len = qconf->tx_mbufs[port].len;
-	qconf->tx_mbufs[port].m_table[len] = m;
-	len++;
-
-	/* enough pkts to be sent */
-	if (unlikely(len == MAX_PKT_BURST)) {
-		l2fwd_send_burst(qconf, MAX_PKT_BURST, port);
-		len = 0;
-	}
-
-	qconf->tx_mbufs[port].len = len;
-	return 0;
-}
-
 static void
 l2fwd_simple_forward(struct rte_mbuf *m, unsigned portid)
 {
@@ -294,7 +248,7 @@ l2fwd_simple_forward(struct rte_mbuf *m, unsigned portid)
 	/* src addr */
 	ether_addr_copy(&l2fwd_ports_eth_addr[dst_port], &eth->s_addr);
 
-	l2fwd_send_packet(m, (uint8_t) dst_port);
+	port_statistics[dst_port].tx += rte_eth_tx_buffer(dst_port, 0, m);
 }
 
 /* main processing loop */
@@ -339,13 +293,12 @@ l2fwd_main_loop(void)
 		diff_tsc = cur_tsc - prev_tsc;
 		if (unlikely(diff_tsc > drain_tsc)) {
 
-			for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) {
-				if (qconf->tx_mbufs[portid].len == 0)
-					continue;
-				l2fwd_send_burst(&lcore_queue_conf[lcore_id],
-						 qconf->tx_mbufs[portid].len,
-						 (uint8_t) portid);
-				qconf->tx_mbufs[portid].len = 0;
+			for (i = 0; i < qconf->n_rx_port; i++) {
+
+				portid = qconf->rx_port_list[i];
+				portid = l2fwd_dst_ports[portid];
+				port_statistics[portid].tx +=
+					rte_eth_tx_buffer_flush(portid, 0);
 			}
 
 			/* if timer is enabled */
-- 
1.9.3

      parent reply	other threads:[~2014-06-24 22:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-24 22:32 [RFC PATCH DRAFT 0/2] ethdev: Proposal to expand API for single-pkt-tx Bruce Richardson
     [not found] ` <1403649136-23551-1-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-06-24 22:32   ` [RFC PATCH DRAFT 1/2] ethdev: add buffered single pkt TX function to API Bruce Richardson
     [not found]     ` <1403649136-23551-2-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-06-24 23:05       ` Stephen Hemminger
     [not found]         ` <20140624160545.136ad9e4-We1ePj4FEcvRI77zikRAJc56i+j3xesD0e7PPNI6Mm0@public.gmane.org>
2014-06-25  0:05           ` Richardson, Bruce
2014-06-24 23:07       ` Stephen Hemminger
     [not found]         ` <20140624160716.57f99bd2-We1ePj4FEcvRI77zikRAJc56i+j3xesD0e7PPNI6Mm0@public.gmane.org>
2014-06-25  0:02           ` Richardson, Bruce
2014-06-24 22:32   ` Bruce Richardson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1403649136-23551-3-git-send-email-bruce.richardson@intel.com \
    --to=bruce.richardson-ral2jqcrhueavxtiumwx3w@public.gmane.org \
    --cc=dev-VfR2kkLFssw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.