[dpdk-dev] [RFC PATCH DRAFT 2/2] l2fwd: update l2fwd to use tx_buffer API
Bruce Richardson
bruce.richardson at intel.com
Wed Jun 25 00:32:16 CEST 2014
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], ð->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
More information about the dev
mailing list