From: Yuanhan Liu <yuanhan....@linux.intel.com> Signed-off-by: Yuanhan Liu <yuanhan....@linux.intel.com> --- 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 <stdarg.h> +#include <string.h> +#include <stdio.h> +#include <errno.h> +#include <stdint.h> +#include <unistd.h> +#include <inttypes.h> +#include <assert.h> + +#include <rte_common.h> +#include <rte_byteorder.h> +#include <rte_log.h> +#include <rte_debug.h> +#include <rte_cycles.h> +#include <rte_memory.h> +#include <rte_memcpy.h> +#include <rte_memzone.h> +#include <rte_launch.h> +#include <rte_eal.h> +#include <rte_per_lcore.h> +#include <rte_lcore.h> +#include <rte_atomic.h> +#include <rte_branch_prediction.h> +#include <rte_memory.h> +#include <rte_mempool.h> +#include <rte_mbuf.h> +#include <rte_memcpy.h> +#include <rte_interrupts.h> +#include <rte_pci.h> +#include <rte_ether.h> +#include <rte_ethdev.h> +#include <rte_ip.h> +#include <rte_tcp.h> +#include <rte_udp.h> +#include <rte_string_fns.h> +#include <rte_flow.h> + +#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