app/testpmd: add 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 <cchemparathy@tilera.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
This commit is contained in:
Cyril Chemparathy 2014-04-03 10:30:11 -07:00 committed by Thomas Monjalon
parent 5706de6533
commit 3e2006d618
3 changed files with 18 additions and 3 deletions

View File

@ -731,7 +731,8 @@ simple_fwd_config_setup(void)
portid_t j; portid_t j;
portid_t inc = 2; portid_t inc = 2;
if (port_topology == PORT_TOPOLOGY_CHAINED) { if (port_topology == PORT_TOPOLOGY_CHAINED ||
port_topology == PORT_TOPOLOGY_LOOP) {
inc = 1; inc = 1;
} else if (nb_fwd_ports % 2) { } else if (nb_fwd_ports % 2) {
printf("\nWarning! Cannot handle an odd number of ports " printf("\nWarning! Cannot handle an odd number of ports "
@ -759,7 +760,10 @@ simple_fwd_config_setup(void)
setup_fwd_config_of_each_lcore(&cur_fwd_config); setup_fwd_config_of_each_lcore(&cur_fwd_config);
for (i = 0; i < cur_fwd_config.nb_fwd_ports; i = (portid_t) (i + inc)) { 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_port = fwd_ports_ids[i];
fwd_streams[i]->rx_queue = 0; fwd_streams[i]->rx_queue = 0;
fwd_streams[i]->tx_port = fwd_ports_ids[j]; fwd_streams[i]->tx_port = fwd_ports_ids[j];
@ -823,10 +827,18 @@ rss_fwd_config_setup(void)
struct fwd_stream *fs; struct fwd_stream *fs;
fs = fwd_streams[lc_id]; fs = fwd_streams[lc_id];
if ((rxp & 0x1) == 0) if ((rxp & 0x1) == 0)
txp = (portid_t) (rxp + 1); txp = (portid_t) (rxp + 1);
else else
txp = (portid_t) (rxp - 1); 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_port = fwd_ports_ids[rxp];
fs->rx_queue = rxq; fs->rx_queue = rxq;
fs->tx_port = fwd_ports_ids[txp]; fs->tx_port = fwd_ports_ids[txp];

View File

@ -756,6 +756,8 @@ launch_args_parse(int argc, char** argv)
port_topology = PORT_TOPOLOGY_PAIRED; port_topology = PORT_TOPOLOGY_PAIRED;
else if (!strcmp(optarg, "chained")) else if (!strcmp(optarg, "chained"))
port_topology = PORT_TOPOLOGY_CHAINED; port_topology = PORT_TOPOLOGY_CHAINED;
else if (!strcmp(optarg, "loop"))
port_topology = PORT_TOPOLOGY_LOOP;
else else
rte_exit(EXIT_FAILURE, "port-topology %s invalid -" rte_exit(EXIT_FAILURE, "port-topology %s invalid -"
" must be: paired or chained \n", " must be: paired or chained \n",

View File

@ -80,7 +80,8 @@ typedef uint16_t streamid_t;
enum { enum {
PORT_TOPOLOGY_PAIRED, PORT_TOPOLOGY_PAIRED,
PORT_TOPOLOGY_CHAINED PORT_TOPOLOGY_CHAINED,
PORT_TOPOLOGY_LOOP,
}; };
#ifdef RTE_TEST_PMD_RECORD_BURST_STATS #ifdef RTE_TEST_PMD_RECORD_BURST_STATS