From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 862BA5961 for ; Wed, 25 Jun 2014 00:32:14 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 24 Jun 2014 15:32:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,540,1400050800"; d="scan'208";a="560447143" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 24 Jun 2014 15:32:30 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s5OMWUsa007070; Tue, 24 Jun 2014 23:32:30 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id s5OMWUlb024054; Tue, 24 Jun 2014 23:32:30 +0100 Received: (from bricha3@localhost) by sivswdev02.ir.intel.com with id s5OMWUmi024050; Tue, 24 Jun 2014 23:32:30 +0100 From: Bruce Richardson To: dev@dpdk.org Date: Tue, 24 Jun 2014 23:32:16 +0100 Message-Id: <1403649136-23551-3-git-send-email-bruce.richardson@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1403649136-23551-1-git-send-email-bruce.richardson@intel.com> References: <1403649136-23551-1-git-send-email-bruce.richardson@intel.com> Subject: [dpdk-dev] [RFC PATCH DRAFT 2/2] l2fwd: update l2fwd to use tx_buffer API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Jun 2014 22:32:15 -0000 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