[dpdk-dev] Fwd: testpmd reports port link down
Hi I have a setup with Intel 82576NS. Port 0 is connected to internal network and is managed by igb driver Port 1 is connected directly to PC which will serve as traffic generator. When Port 1 is managed by igb driver eth interface is configured and I am able to connect to traffic generator PC. However when I bind Port 1 to igb_uio driver and start testpmd application, it reports that Link is Down for this port. Tried to seach Mailing list for answer but didn't find any. Any ideas why this happens. (My suspicion is that Traffic Generator PC doesn't have DPDK NIC) Thanks in advance Tomasz Kasowicz Host PC: Intel(R) Xeon(R) CPU E31220 @ 3.10GHz Intel 82576NS Ubuntu 12.04 Kernel Options: iommu=pt intel_iommu=on pci=assign-busses Traffic Generator Inter(R) Core(TM)2 Duo CPU E8400 Intel 82567LF-3 Ubuntu 12.04
[dpdk-dev] [PATCH] mk: add support for gdb debug info generation
It is often useful to build with debug enabled, we add a config (CONFIG_RTE_TOOLCHAIN_DEBUG) to do so. Note: This patch does not include corresponding changes for ICC. The author pleads abject ignorance in this regard, and welcomes recommendations. :-) Signed-off-by: Cyril Chemparathy --- config/defconfig_x86_64-default-linuxapp-gcc | 1 + mk/toolchain/gcc/rte.vars.mk | 5 + 2 files changed, 6 insertions(+) diff --git a/config/defconfig_x86_64-default-linuxapp-gcc b/config/defconfig_x86_64-default-linuxapp-gcc index f11ffbf..3b36efd 100644 --- a/config/defconfig_x86_64-default-linuxapp-gcc +++ b/config/defconfig_x86_64-default-linuxapp-gcc @@ -67,6 +67,7 @@ CONFIG_RTE_ARCH_X86_64=y # CONFIG_RTE_TOOLCHAIN="gcc" CONFIG_RTE_TOOLCHAIN_GCC=y +CONFIG_RTE_TOOLCHAIN_DEBUG=n # # Use intrinsics or assembly code for key routines diff --git a/mk/toolchain/gcc/rte.vars.mk b/mk/toolchain/gcc/rte.vars.mk index 0edb93f..81ed3fa 100644 --- a/mk/toolchain/gcc/rte.vars.mk +++ b/mk/toolchain/gcc/rte.vars.mk @@ -68,6 +68,11 @@ ifeq (,$(findstring -O0,$(EXTRA_CFLAGS))) endif endif +ifeq ($(CONFIG_RTE_TOOLCHAIN_DEBUG),y) +TOOLCHAIN_CFLAGS += -g -ggdb +TOOLCHAIN_LDFLAGS += -g -ggdb +endif + WERROR_FLAGS := -W -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes WERROR_FLAGS += -Wmissing-declarations -Wold-style-definition -Wpointer-arith WERROR_FLAGS += -Wcast-align -Wnested-externs -Wcast-qual -- 1.8.3.1
[dpdk-dev] [PATCH 6/6] test-pmd: add flowgen forwarding engine
This commit adds a multi-flow traffic generator forwarding engine. In effect, this forwarding mode functions very similar to the txonly mode, with the difference that it generates multiple L4 flows. Signed-off-by: Cyril Chemparathy --- app/test-pmd/Makefile | 1 + app/test-pmd/flowgen.c | 247 + app/test-pmd/testpmd.c | 1 + app/test-pmd/testpmd.h | 1 + 4 files changed, 250 insertions(+) create mode 100644 app/test-pmd/flowgen.c diff --git a/app/test-pmd/Makefile b/app/test-pmd/Makefile index f0d0262..6ed2634 100644 --- a/app/test-pmd/Makefile +++ b/app/test-pmd/Makefile @@ -52,6 +52,7 @@ SRCS-$(CONFIG_RTE_TEST_PMD) += iofwd.c SRCS-$(CONFIG_RTE_TEST_PMD) += macfwd.c SRCS-$(CONFIG_RTE_TEST_PMD) += macfwd-retry.c SRCS-$(CONFIG_RTE_TEST_PMD) += macswap.c +SRCS-$(CONFIG_RTE_TEST_PMD) += flowgen.c SRCS-$(CONFIG_RTE_TEST_PMD) += rxonly.c SRCS-$(CONFIG_RTE_TEST_PMD) += txonly.c SRCS-$(CONFIG_RTE_TEST_PMD) += csumonly.c diff --git a/app/test-pmd/flowgen.c b/app/test-pmd/flowgen.c new file mode 100644 index 000..04911ff --- /dev/null +++ b/app/test-pmd/flowgen.c @@ -0,0 +1,247 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2010-2013 Tilera 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 Tilera 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 + +#include "testpmd.h" + +/* hardcoded configuration (for now) */ +static unsigned cfg_n_flows= 1024; +static unsigned cfg_pkt_size = 300; +static uint32_t cfg_ip_src = IPv4(10, 254, 0, 0); +static uint32_t cfg_ip_dst = IPv4(10, 253, 0, 0); +static uint16_t cfg_udp_src= 1000; +static uint16_t cfg_udp_dst= 1001; +static struct ether_addr cfg_ether_src = + {{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x00 }}; +static struct ether_addr cfg_ether_dst = + {{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x01 }}; + +#define IP_DEFTTL 64 /* from RFC 1340. */ +#define IP_VERSION 0x40 +#define IP_HDRLEN 0x05 /* default IP header length == five 32-bits words. */ +#define IP_VHL_DEF (IP_VERSION | IP_HDRLEN) + +static inline struct rte_mbuf * +tx_mbuf_alloc(struct rte_mempool *mp) +{ + struct rte_mbuf *m; + + m = __rte_mbuf_raw_alloc(mp); + __rte_mbuf_sanity_check_raw(m, RTE_MBUF_PKT, 0); + return (m); +} + + +static inline uint16_t +ip_sum(const uint16_t *hdr, int hdr_len) +{ + uint32_t sum = 0; + + while (hdr_len > 1) + { + sum += *hdr++; + if (sum & 0x8000) + sum = (sum & 0x) + (sum >> 16); + hdr_len -= 2; + } + + while (sum >> 16) + sum = (sum & 0x) + (sum >> 16); + + return ~sum; +} + +/* + * Multi-flow generation mode. + * + * We originate a bunch of flows (varying destination IP addresses), and + * terminate receive traffic. Received traffic is simply discarded, but we + * still do so in order to maintain traffic statistics. + */ +static void +pkt_burst_flow_gen(struct fwd_stream *fs) +{ + unsigned pkt_size =
[dpdk-dev] [PATCH 5/6] test-pmd: add mac swap forwarding mode
This commit adds a new forwarding mode, in which the source and destination MAC addresses of packets are swapped before forwarding according to the port-topology in effect. This has been designed for operation primarily with --port-topology=loopback. Signed-off-by: Cyril Chemparathy --- app/test-pmd/Makefile | 1 + app/test-pmd/macswap.c | 148 + app/test-pmd/testpmd.c | 1 + app/test-pmd/testpmd.h | 1 + 4 files changed, 151 insertions(+) create mode 100644 app/test-pmd/macswap.c diff --git a/app/test-pmd/Makefile b/app/test-pmd/Makefile index f0d4b4d..f0d0262 100644 --- a/app/test-pmd/Makefile +++ b/app/test-pmd/Makefile @@ -51,6 +51,7 @@ SRCS-$(CONFIG_RTE_TEST_PMD) += config.c SRCS-$(CONFIG_RTE_TEST_PMD) += iofwd.c SRCS-$(CONFIG_RTE_TEST_PMD) += macfwd.c SRCS-$(CONFIG_RTE_TEST_PMD) += macfwd-retry.c +SRCS-$(CONFIG_RTE_TEST_PMD) += macswap.c SRCS-$(CONFIG_RTE_TEST_PMD) += rxonly.c SRCS-$(CONFIG_RTE_TEST_PMD) += txonly.c SRCS-$(CONFIG_RTE_TEST_PMD) += csumonly.c diff --git a/app/test-pmd/macswap.c b/app/test-pmd/macswap.c new file mode 100644 index 000..4ed6096 --- /dev/null +++ b/app/test-pmd/macswap.c @@ -0,0 +1,148 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2014 Tilera Corporation. 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 Tilera 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 "testpmd.h" + +/* + * MAC swap forwarding mode: Swap the source and the destination Ethernet + * addresses of packets before forwarding them. + */ +static void +pkt_burst_mac_swap(struct fwd_stream *fs) +{ + struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; + struct rte_port *txp; + struct rte_mbuf *mb; + struct ether_hdr *eth_hdr; + struct ether_addr addr; + uint16_t nb_rx; + uint16_t nb_tx; + uint16_t 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 + + /* +* Receive a burst of packets and forward them. +*/ + nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, +nb_pkt_per_burst); + if (unlikely(nb_rx == 0)) + return; + +#ifdef RTE_TEST_PMD_RECORD_BURST_STATS + fs->rx_burst_stats.pkt_burst_spread[nb_rx]++; +#endif + fs->rx_packets += nb_rx; + txp = [fs->tx_port]; + for (i = 0; i < nb_rx; i++) { + mb = pkts_burst[i]; + eth_hdr = (struct ether_hdr *) mb->pkt.data; + + /* Swap dest and src mac addresses. */ + ether_addr_copy(_hdr->d_addr, ); + ether_addr_copy(_hdr->s_addr, _hdr->d_addr); + ether_addr_copy(, _hdr->s_addr); + + mb->ol_flags = txp->tx_ol_flags; + mb->pkt.vlan_macip.f.l2_len = sizeof(struct ether_hdr); + mb->pkt.vlan_macip.f.l3_len = sizeof(struct ipv4_hdr); + mb->pkt.vlan_macip.f.vlan_tci =
[dpdk-dev] [PATCH 4/6] test-pmd: allow txpkts to be setup via command line
We allow a new --txpkts command-line parameter to configure segment sizes when in txonly or flowgen forwarding modes. Signed-off-by: Cyril Chemparathy --- app/test-pmd/parameters.c | 57 +++ 1 file changed, 57 insertions(+) diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 67081d7..ce90399 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -476,6 +476,52 @@ parse_ringnuma_config(const char *q_arg) return 0; } +static unsigned int +parse_item_list(char* str, unsigned int max_items, unsigned int *parsed_items) +{ + unsigned int nb_item; + unsigned int value; + unsigned int i; + int value_ok; + char c; + + /* +* First parse all items in the list and store their value. +*/ + value = 0; + nb_item = 0; + value_ok = 0; + for (i = 0; i < strlen(str); i++) { + c = str[i]; + if ((c >= '0') && (c <= '9')) { + value = (unsigned int) (value * 10 + (c - '0')); + value_ok = 1; + continue; + } + if (c != ',') { + printf("character %c is not a decimal digit\n", c); + return (0); + } + if (! value_ok) { + printf("No valid value before comma\n"); + return (0); + } + if (nb_item < max_items) { + parsed_items[nb_item] = value; + value_ok = 0; + value = 0; + } + nb_item++; + } + + if (nb_item >= max_items) + rte_exit(EXIT_FAILURE, "too many txpkt segments!\n"); + + parsed_items[nb_item++] = value; + + return (nb_item); +} + void launch_args_parse(int argc, char** argv) { @@ -538,6 +584,7 @@ launch_args_parse(int argc, char** argv) { "tx-queue-stats-mapping", 1, 0, 0 }, { "rx-queue-stats-mapping", 1, 0, 0 }, { "no-flush-rx",0, 0, 0 }, + { "txpkts", 1, 0, 0 }, { 0, 0, 0, 0 }, }; @@ -983,6 +1030,16 @@ launch_args_parse(int argc, char** argv) "invalid RX queue statistics mapping config entered\n"); } } + if (!strcmp(lgopts[opt_idx].name, "txpkts")) { + unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT]; + unsigned int nb_segs; + + nb_segs = parse_item_list(optarg, RTE_MAX_SEGS_PER_PKT, seg_lengths); + if (nb_segs > 0) + set_tx_pkt_segments(seg_lengths, nb_segs); + else + rte_exit(EXIT_FAILURE, "bad txpkts\n"); + } if (!strcmp(lgopts[opt_idx].name, "no-flush-rx")) no_flush_rx = 1; -- 1.8.3.1
[dpdk-dev] [PATCH 3/6] test-pmd: allow command line selection of forwarding mode
This commit allows testpmd forwarding mode selection through command line parameters instead of having to set this up in interactive mode. Signed-off-by: Cyril Chemparathy --- app/test-pmd/parameters.c | 4 1 file changed, 4 insertions(+) diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 18b52cc..67081d7 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -158,6 +158,7 @@ usage(char* progname) printf(" --disable-rss: disable rss.\n"); printf(" --port-topology=N: set port topology (N: paired (default) or " "chained).\n"); + printf(" --forward-mode=N: set forwarding mode.\n"); printf(" --rss-ip: set RSS functions to IPv4/IPv6 only .\n"); printf(" --rss-udp: set RSS functions to IPv4/IPv6 + UDP.\n"); printf(" --rxq=N: set the number of RX queues per port to N.\n"); @@ -515,6 +516,7 @@ launch_args_parse(int argc, char** argv) { "enable-drop-en",0, 0, 0 }, { "disable-rss",0, 0, 0 }, { "port-topology", 1, 0, 0 }, + { "forward-mode", 1, 0, 0 }, { "rss-ip", 0, 0, 0 }, { "rss-udp",0, 0, 0 }, { "rxq",1, 0, 0 }, @@ -775,6 +777,8 @@ launch_args_parse(int argc, char** argv) " must be: paired or chained \n", optarg); } + if (!strcmp(lgopts[opt_idx].name, "forward-mode")) + set_pkt_forwarding_mode(optarg); if (!strcmp(lgopts[opt_idx].name, "rss-ip")) rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6; if (!strcmp(lgopts[opt_idx].name, "rss-udp")) -- 1.8.3.1
[dpdk-dev] [PATCH 2/6] test-pmd: add support for auto-start when interactive
This patch adds support for a command-line argument --auto-start (-a). When running in interactive mode, this allows us to start traffic without user intervention before dropping to the prompt. Signed-off-by: Cyril Chemparathy --- app/test-pmd/parameters.c | 20 app/test-pmd/testpmd.c| 9 +++-- app/test-pmd/testpmd.h| 1 + 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index d47d020..18b52cc 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -85,7 +85,7 @@ usage(char* progname) #ifdef RTE_LIBRTE_CMDLINE "[--interactive|-i] " #endif - "[--help|-h] | [" + "[--help|-h] | [--auto-start|-a] | [" "--coremask=COREMASK --portmask=PORTMASK --numa " "--mbuf-size= | --total-num-mbufs= | " "--nb-cores= | --nb-ports= | " @@ -102,6 +102,8 @@ usage(char* progname) #ifdef RTE_LIBRTE_CMDLINE printf(" --interactive: run in interactive mode.\n"); #endif + printf(" --auto-start: start forwarding on init " + "[always when non-interactive].\n"); printf(" --help: display this message and quit.\n"); printf(" --nb-cores=N: set the number of forwarding cores " "(1 <= N <= %d).\n", nb_lcores); @@ -485,6 +487,7 @@ launch_args_parse(int argc, char** argv) { "help", 0, 0, 0 }, #ifdef RTE_LIBRTE_CMDLINE { "interactive",0, 0, 0 }, + { "auto-start", 0, 0, 0 }, { "eth-peers-configfile", 1, 0, 0 }, { "eth-peer", 1, 0, 0 }, #endif @@ -539,11 +542,11 @@ launch_args_parse(int argc, char** argv) argvopt = argv; #ifdef RTE_LIBRTE_CMDLINE -#define SHORTOPTS "ih" +#define SHORTOPTS "i" #else -#define SHORTOPTS "h" +#define SHORTOPTS "" #endif - while ((opt = getopt_long(argc, argvopt, SHORTOPTS, + while ((opt = getopt_long(argc, argvopt, SHORTOPTS "ah", lgopts, _idx)) != EOF) { switch (opt) { #ifdef RTE_LIBRTE_CMDLINE @@ -552,6 +555,11 @@ launch_args_parse(int argc, char** argv) interactive = 1; break; #endif + case 'a': + printf("Auto-start selected\n"); + auto_start = 1; + break; + case 0: /*long options */ if (!strcmp(lgopts[opt_idx].name, "help")) { usage(argv[0]); @@ -562,6 +570,10 @@ launch_args_parse(int argc, char** argv) printf("Interactive-mode selected\n"); interactive = 1; } + if (!strcmp(lgopts[opt_idx].name, "auto-start")) { + printf("Auto-start selected\n"); + auto_start = 1; + } if (!strcmp(lgopts[opt_idx].name, "eth-peers-configfile")) { if (init_peer_eth_addrs(optarg) != 0) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 04dca57..cde9c2b 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -83,6 +83,7 @@ uint16_t verbose_level = 0; /**< Silent by default. */ /* use master core for command line ? */ uint8_t interactive = 0; +uint8_t auto_start = 0; /* * NUMA support configuration. @@ -1794,9 +1795,13 @@ main(int argc, char** argv) rte_eth_promiscuous_enable(port_id); #ifdef RTE_LIBRTE_CMDLINE - if (interactive == 1) + if (interactive == 1) { + if (auto_start) { + printf("Start automatic packet forwarding\n"); + start_packet_forwarding(0); + } prompt(); - else + } else #endif { char c; diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index a4842ec..52d3543 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -270,6 +270,7 @@ extern uint16_t nb_rx_queue_stats_mappings; /* globals used for configuration */ extern uint16_t verbose_level; /**< Drives messages being displayed, if any. */ extern uint8_t interactive; +extern uint8_t auto_start; extern uint8_t numa_support; /**< set by "--numa" parameter */ extern uint16_t port_topology; /**< set by "--port-topology" parameter */ extern uint8_t no_flush_rx; /**
[dpdk-dev] [PATCH 1/6] test-pmd: add support for single port loopback topology
This commits adds a new "loop" option to the --port-topology argument. With the loop option specified, ingress traffic is simply transmitted back on the same interface. Signed-off-by: Cyril Chemparathy --- app/test-pmd/config.c | 16 ++-- app/test-pmd/parameters.c | 2 ++ app/test-pmd/testpmd.h| 3 ++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 0816227..1d3cdba 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -733,7 +733,8 @@ simple_fwd_config_setup(void) portid_t j; portid_t inc = 2; - if (port_topology == PORT_TOPOLOGY_CHAINED) { + if (port_topology == PORT_TOPOLOGY_CHAINED || + port_topology == PORT_TOPOLOGY_LOOP) { inc = 1; } else if (nb_fwd_ports % 2) { printf("\nWarning! Cannot handle an odd number of ports " @@ -761,7 +762,10 @@ simple_fwd_config_setup(void) setup_fwd_config_of_each_lcore(_fwd_config); for (i = 0; i < cur_fwd_config.nb_fwd_ports; i = (portid_t) (i + inc)) { - j = (portid_t) ((i + 1) % cur_fwd_config.nb_fwd_ports); + if (port_topology != PORT_TOPOLOGY_LOOP) + j = (portid_t) ((i + 1) % cur_fwd_config.nb_fwd_ports); + else + j = i; fwd_streams[i]->rx_port = fwd_ports_ids[i]; fwd_streams[i]->rx_queue = 0; fwd_streams[i]->tx_port = fwd_ports_ids[j]; @@ -825,10 +829,18 @@ rss_fwd_config_setup(void) struct fwd_stream *fs; fs = fwd_streams[lc_id]; + if ((rxp & 0x1) == 0) txp = (portid_t) (rxp + 1); else txp = (portid_t) (rxp - 1); + /* +* if we are in loopback, simply send stuff out through the +* ingress port +*/ + if (port_topology == PORT_TOPOLOGY_LOOP) + txp = rxp; + fs->rx_port = fwd_ports_ids[rxp]; fs->rx_queue = rxq; fs->tx_port = fwd_ports_ids[txp]; diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index f537e49..d47d020 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -756,6 +756,8 @@ launch_args_parse(int argc, char** argv) port_topology = PORT_TOPOLOGY_PAIRED; else if (!strcmp(optarg, "chained")) port_topology = PORT_TOPOLOGY_CHAINED; + else if (!strcmp(optarg, "loop")) + port_topology = PORT_TOPOLOGY_LOOP; else rte_exit(EXIT_FAILURE, "port-topology %s invalid -" " must be: paired or chained \n", diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 5b4ee6f..a4842ec 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -80,7 +80,8 @@ typedef uint16_t streamid_t; enum { PORT_TOPOLOGY_PAIRED, - PORT_TOPOLOGY_CHAINED + PORT_TOPOLOGY_CHAINED, + PORT_TOPOLOGY_LOOP, }; #ifdef RTE_TEST_PMD_RECORD_BURST_STATS -- 1.8.3.1
[dpdk-dev] [PATCH 0/6] Extensions to test-pmd
Hi, This patch series contains a few minor extensions to test-pmd. These changes have been added primarily for convenience while testing out various scenarios with DPDK. Thanks -- Cyril. Cyril Chemparathy (6): test-pmd: add support for single port loopback topology test-pmd: add support for auto-start when interactive test-pmd: allow command line selection of forwarding mode test-pmd: allow txpkts to be setup via command line test-pmd: add mac swap forwarding mode test-pmd: add flowgen forwarding engine app/test-pmd/Makefile | 2 + app/test-pmd/config.c | 16 ++- app/test-pmd/flowgen.c| 247 ++ app/test-pmd/macswap.c| 148 +++ app/test-pmd/parameters.c | 83 +++- app/test-pmd/testpmd.c| 11 ++- app/test-pmd/testpmd.h| 6 +- 7 files changed, 504 insertions(+), 9 deletions(-) create mode 100644 app/test-pmd/flowgen.c create mode 100644 app/test-pmd/macswap.c -- 1.8.3.1
[dpdk-dev] [memnic PATCH] pmd: use rte_atomic32_cmpset instead of cmpxchg
From: Hiroshi ShimamotoBecause DPDK has its own compare and set function to optimize to dedicated processor type, use that rte_atomic32_cmpset() instead of cmpxchg macro which is specially introduced for MEMNIC. Signed-off-by: Hiroshi Shimamoto --- common/memnic.h | 12 pmd/pmd_memnic.c | 10 ++ 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/common/memnic.h b/common/memnic.h index 2187ac1..84e941c 100644 --- a/common/memnic.h +++ b/common/memnic.h @@ -120,18 +120,6 @@ struct memnic_area { /* for userspace */ #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) -static inline uint32_t cmpxchg(uint32_t *dst, uint32_t old, uint32_t new) -{ - volatile uint32_t *ptr = (volatile uint32_t *)dst; - uint32_t ret; - - asm volatile("lock; cmpxchgl %2, %1" -: "=a" (ret), "+m" (*ptr) -: "r" (new), "0" (old) -: "memory"); - - return ret; -} #endif /* __KERNEL__ */ #endif /* MEMNIC_H */ diff --git a/pmd/pmd_memnic.c b/pmd/pmd_memnic.c index 4a1c1e4..4abdf26 100644 --- a/pmd/pmd_memnic.c +++ b/pmd/pmd_memnic.c @@ -314,7 +314,7 @@ static uint16_t memnic_xmit_pkts(void *tx_queue, struct memnic_data *data = >nic->down; struct memnic_packet *p; uint16_t nr; - int idx, old; + int idx; struct rte_eth_stats *st = >stats[rte_lcore_id()]; uint64_t pkts, bytes, errs; @@ -335,10 +335,12 @@ static uint16_t memnic_xmit_pkts(void *tx_queue, retry: idx = ACCESS_ONCE(adapter->down_idx); p = >packets[idx]; - old = cmpxchg(>status, MEMNIC_PKT_ST_FREE, MEMNIC_PKT_ST_USED); - if (old != MEMNIC_PKT_ST_FREE) { - if (old == MEMNIC_PKT_ST_FILLED && + if (unlikely(rte_atomic32_cmpset(>status, + MEMNIC_PKT_ST_FREE, MEMNIC_PKT_ST_USED) == 0)) { + /* cmpxchg failed */ + if (p->status == MEMNIC_PKT_ST_FILLED && idx == ACCESS_ONCE(adapter->down_idx)) { + /* what we're seeing is FILLED means queue full */ errs++; break; } -- 1.8.4
[dpdk-dev] [memnic PATCH] common: add Dual BSD/GPL license line
From: Hiroshi ShimamotoThe MEMNIC header file should be under Dual BSD/GPL license. Put the license text "Dual BSD/GPL" into the file header. Signed-off-by: Hiroshi Shimamoto --- common/memnic.h | 1 + 1 file changed, 1 insertion(+) diff --git a/common/memnic.h b/common/memnic.h index 8bd483c..2187ac1 100644 --- a/common/memnic.h +++ b/common/memnic.h @@ -27,6 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ +/* Dual BSD/GPL */ #ifndef MEMNIC_H #define MEMNIC_H -- 1.8.4
[dpdk-dev] [memnic PATCH v2] pmd: fix race condition
From: Hiroshi ShimamotoThere is a race condition, on transmit to host. Guest PMD Host Thread-A Thread-B vSwitch |idx=0 |idx=0 |p[0] st!=2 |cmpxchg || |p[0] st->1 || |idx=1 || |fill data || |p[0] st->2 ||p[0] st==2 |||receive data |||p[0] st->0 ||cmpxchg | ||success |p[1] st!=2 ||p[0] st->1 | This is BAD That causes traffic stop. We have to take care about that race condition with checking whether current index is correct. Signed-off-by: Hiroshi Shimamoto Reviewed-by: Hayato Momma --- pmd/pmd_memnic.c | 9 + 1 file changed, 9 insertions(+) diff --git a/pmd/pmd_memnic.c b/pmd/pmd_memnic.c index d833130..4a1c1e4 100644 --- a/pmd/pmd_memnic.c +++ b/pmd/pmd_memnic.c @@ -345,6 +345,15 @@ retry: goto retry; } + if (idx != ACCESS_ONCE(adapter->down_idx)) { + /* +* host freed this and got false positive, +* need to recover the status and retry. +*/ + p->status = MEMNIC_PKT_ST_FREE; + goto retry; + } + if (++idx >= MEMNIC_NR_PACKET) idx = 0; adapter->down_idx = idx; -- 1.8.4