From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 219F14C57 for ; Wed, 21 Jun 2017 04:59:34 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP; 20 Jun 2017 19:59:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,367,1493708400"; d="scan'208";a="101830311" Received: from dpdk25.sh.intel.com ([10.67.111.75]) by orsmga002.jf.intel.com with ESMTP; 20 Jun 2017 19:59:34 -0700 From: Tiwei Bie To: dev@dpdk.org Cc: Yuanhan Liu Date: Wed, 21 Jun 2017 10:57:48 +0800 Message-Id: <1498013885-102779-13-git-send-email-tiwei.bie@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498013885-102779-1-git-send-email-tiwei.bie@intel.com> References: <1498013885-102779-1-git-send-email-tiwei.bie@intel.com> Subject: [dpdk-dev] [RFC 12/29] testpmd: add s-txonly X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jun 2017 02:59:36 -0000 From: Yuanhan Liu Signed-off-by: Yuanhan Liu --- app/test-pmd/Makefile | 1 + app/test-pmd/s-txonly.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++++ app/test-pmd/testpmd.c | 1 + app/test-pmd/testpmd.h | 1 + 4 files changed, 137 insertions(+) create mode 100644 app/test-pmd/s-txonly.c diff --git a/app/test-pmd/Makefile b/app/test-pmd/Makefile index 35ecee9..d87cae6 100644 --- a/app/test-pmd/Makefile +++ b/app/test-pmd/Makefile @@ -55,6 +55,7 @@ SRCS-y += macswap.c SRCS-y += flowgen.c SRCS-y += rxonly.c SRCS-y += txonly.c +SRCS-y += s-txonly.c SRCS-y += csumonly.c SRCS-y += icmpecho.c SRCS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ieee1588fwd.c diff --git a/app/test-pmd/s-txonly.c b/app/test-pmd/s-txonly.c new file mode 100644 index 0000000..6275136 --- /dev/null +++ b/app/test-pmd/s-txonly.c @@ -0,0 +1,134 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "testpmd.h" + +#undef MAX_PKT_BURST +#define MAX_PKT_BURST 32 + +/* + * Transmit a burst of multi-segments packets. + */ +static void +pkt_burst_transmit(struct fwd_stream *fs) +{ + static struct rte_mbuf *pkts[MAX_PKT_BURST]; + uint16_t nb_tx; + int i; +#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES + uint64_t start_tsc; + uint64_t end_tsc; + uint64_t core_cycles; +#endif + +#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES + start_tsc = rte_rdtsc(); +#endif + + for (i = 0; i < MAX_PKT_BURST; i++) { + if (unlikely(!pkts[i])) { + pkts[i] = rte_pktmbuf_alloc(current_fwd_lcore()->mbp); + assert(pkts[i]); + + pkts[i]->data_len = tx_pkt_seg_lengths[0]; + pkts[i]->pkt_len = tx_pkt_seg_lengths[0]; + pkts[i]->nb_segs = 1; + } + + rte_pktmbuf_refcnt_update(pkts[i], 1); + } + + nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts, MAX_PKT_BURST); + + //uint32_t retry; + //if (unlikely(nb_tx < MAX_PKT_BURST) && fs->retry_enabled) { + // retry = 0; + // while (nb_tx < MAX_PKT_BURST && retry++ < burst_tx_retry_num) { + // rte_delay_us(burst_tx_delay_time); + // nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, + // &pkts[nb_tx], MAX_PKT_BURST - nb_tx); + // } + //} + + fs->tx_packets += nb_tx; + +#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES + end_tsc = rte_rdtsc(); + core_cycles = (end_tsc - start_tsc); + fs->core_cycles = (uint64_t) (fs->core_cycles + core_cycles); +#endif +} + +struct fwd_engine s_tx_only_engine = { + .fwd_mode_name = "s-txonly", + .port_fwd_begin = NULL, + .port_fwd_end = NULL, + .packet_fwd = pkt_burst_transmit, +}; diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index d1041af..f224357 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -160,6 +160,7 @@ struct fwd_engine * fwd_engines[] = { &flow_gen_engine, &rx_only_engine, &tx_only_engine, + &s_tx_only_engine, &csum_fwd_engine, &icmp_echo_engine, #ifdef RTE_LIBRTE_IEEE1588 diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index e6c43ba..b53ce0a 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -248,6 +248,7 @@ extern struct fwd_engine mac_swap_engine; extern struct fwd_engine flow_gen_engine; extern struct fwd_engine rx_only_engine; extern struct fwd_engine tx_only_engine; +extern struct fwd_engine s_tx_only_engine; extern struct fwd_engine csum_fwd_engine; extern struct fwd_engine icmp_echo_engine; #ifdef RTE_LIBRTE_IEEE1588 -- 2.7.4