X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=app%2Ftest-pmd%2Ftestpmd.c;h=1398c6cb5ff4cbb28637e8262bbe3f51f52ba0a8;hb=09419f235e099ecb265a590778fe64a685a2a241;hp=093952f0c8a074fbb67ed71ff847bdcdd68b3f49;hpb=f72a0fa627ac8c6d907bd0035adcb9999560e4c9;p=dpdk.git diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 093952f0c8..1398c6cb5f 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -1,7 +1,7 @@ /*- * BSD LICENSE * - * Copyright(c) 2010-2015 Intel Corporation. All rights reserved. + * Copyright(c) 2010-2016 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -354,17 +354,17 @@ set_default_fwd_lcores_config(void) nb_lc = 0; for (i = 0; i < RTE_MAX_LCORE; i++) { - if (! rte_lcore_is_enabled(i)) - continue; - if (i == rte_get_master_lcore()) - continue; - fwd_lcores_cpuids[nb_lc++] = i; sock_num = rte_lcore_to_socket_id(i) + 1; if (sock_num > max_socket) { if (sock_num > RTE_MAX_NUMA_NODES) rte_exit(EXIT_FAILURE, "Total sockets greater than %u\n", RTE_MAX_NUMA_NODES); max_socket = sock_num; } + if (!rte_lcore_is_enabled(i)) + continue; + if (i == rte_get_master_lcore()) + continue; + fwd_lcores_cpuids[nb_lc++] = i; } nb_lcores = (lcoreid_t) nb_lc; nb_cfg_lcores = nb_lcores; @@ -608,6 +608,7 @@ init_fwd_streams(void) portid_t pid; struct rte_port *port; streamid_t sm_id, nb_fwd_streams_new; + queueid_t q; /* set socket id according to numa or not */ FOREACH_PORT(pid, ports) { @@ -643,7 +644,12 @@ init_fwd_streams(void) } } - nb_fwd_streams_new = (streamid_t)(nb_ports * nb_rxq); + q = RTE_MAX(nb_rxq, nb_txq); + if (q == 0) { + printf("Fail: Cannot allocate fwd streams as number of queues is 0\n"); + return -1; + } + nb_fwd_streams_new = (streamid_t)(nb_ports * q); if (nb_fwd_streams_new == nb_fwd_streams) return 0; /* clear the old */ @@ -753,7 +759,7 @@ fwd_port_stats_display(portid_t port_id, struct rte_eth_stats *stats) if (cur_fwd_eng == &csum_fwd_engine) printf(" Bad-ipcsum: %-14"PRIu64" Bad-l4csum: %-14"PRIu64" \n", port->rx_bad_ip_csum, port->rx_bad_l4_csum); - if (((stats->ierrors - stats->imissed) + stats->rx_nombuf) > 0) { + if ((stats->ierrors + stats->rx_nombuf) > 0) { printf(" RX-error: %-"PRIu64"\n", stats->ierrors); printf(" RX-nombufs: %-14"PRIu64"\n", stats->rx_nombuf); } @@ -772,7 +778,7 @@ fwd_port_stats_display(portid_t port_id, struct rte_eth_stats *stats) if (cur_fwd_eng == &csum_fwd_engine) printf(" Bad-ipcsum:%14"PRIu64" Bad-l4csum:%14"PRIu64"\n", port->rx_bad_ip_csum, port->rx_bad_l4_csum); - if (((stats->ierrors - stats->imissed) + stats->rx_nombuf) > 0) { + if ((stats->ierrors + stats->rx_nombuf) > 0) { printf(" RX-error:%"PRIu64"\n", stats->ierrors); printf(" RX-nombufs: %14"PRIu64"\n", stats->rx_nombuf); @@ -955,6 +961,19 @@ start_packet_forwarding(int with_tx_first) portid_t pt_id; streamid_t sm_id; + if (strcmp(cur_fwd_eng->fwd_mode_name, "rxonly") == 0 && !nb_rxq) + rte_exit(EXIT_FAILURE, "rxq are 0, cannot use rxonly fwd mode\n"); + + if (strcmp(cur_fwd_eng->fwd_mode_name, "txonly") == 0 && !nb_txq) + rte_exit(EXIT_FAILURE, "txq are 0, cannot use txonly fwd mode\n"); + + if ((strcmp(cur_fwd_eng->fwd_mode_name, "rxonly") != 0 && + strcmp(cur_fwd_eng->fwd_mode_name, "txonly") != 0) && + (!nb_rxq || !nb_txq)) + rte_exit(EXIT_FAILURE, + "Either rxq or txq are 0, cannot use %s fwd mode\n", + cur_fwd_eng->fwd_mode_name); + if (all_ports_started() == 0) { printf("Not all ports were started\n"); return; @@ -1512,7 +1531,7 @@ attach_port(char *identifier) nb_ports = rte_eth_dev_count(); /* set_default_fwd_ports_config(); */ - bzero(fwd_ports_ids, sizeof(fwd_ports_ids)); + memset(fwd_ports_ids, 0, sizeof(fwd_ports_ids)); i = 0; FOREACH_PORT(j, ports) { fwd_ports_ids[i] = j; @@ -1547,7 +1566,7 @@ detach_port(uint8_t port_id) nb_ports = rte_eth_dev_count(); /* set_default_fwd_ports_config(); */ - bzero(fwd_ports_ids, sizeof(fwd_ports_ids)); + memset(fwd_ports_ids, 0, sizeof(fwd_ports_ids)); i = 0; FOREACH_PORT(pi, ports) { fwd_ports_ids[i] = pi; @@ -1570,13 +1589,16 @@ pmd_test_exit(void) if (test_done == 0) stop_packet_forwarding(); - FOREACH_PORT(pt_id, ports) { - printf("Stopping port %d...", pt_id); - fflush(stdout); - rte_eth_dev_close(pt_id); - printf("done\n"); + if (ports != NULL) { + no_link_check = 1; + FOREACH_PORT(pt_id, ports) { + printf("\nShutting down port %d...\n", pt_id); + fflush(stdout); + stop_port(pt_id); + close_port(pt_id); + } } - printf("bye...\n"); + printf("\nBye...\n"); } typedef void (*cmd_func_t)(void); @@ -1619,7 +1641,7 @@ check_all_ports_link_status(uint32_t port_mask) continue; } /* clear all_ports_up flag if any link down */ - if (link.link_status == 0) { + if (link.link_status == ETH_LINK_DOWN) { all_ports_up = 0; break; } @@ -1984,12 +2006,35 @@ init_port(void) ports[pid].enabled = 1; } +static void +force_quit(void) +{ + pmd_test_exit(); + prompt_exit(); +} + +static void +signal_handler(int signum) +{ + if (signum == SIGINT || signum == SIGTERM) { + printf("\nSignal %d received, preparing to exit...\n", + signum); + force_quit(); + /* exit with the expected status */ + signal(signum, SIG_DFL); + kill(getpid(), signum); + } +} + int main(int argc, char** argv) { int diag; uint8_t port_id; + signal(SIGINT, signal_handler); + signal(SIGTERM, signal_handler); + diag = rte_eal_init(argc, argv); if (diag < 0) rte_panic("Cannot init EAL\n"); @@ -2011,7 +2056,10 @@ main(int argc, char** argv) if (argc > 1) launch_args_parse(argc, argv); - if (nb_rxq > nb_txq) + if (!nb_rxq && !nb_txq) + printf("Warning: Either rx or tx queues should be non-zero\n"); + + if (nb_rxq > 1 && nb_rxq > nb_txq) printf("Warning: nb_rxq=%d enables RSS configuration, " "but nb_txq=%d will prevent to fully test it.\n", nb_rxq, nb_txq); @@ -2041,6 +2089,7 @@ main(int argc, char** argv) start_packet_forwarding(0); printf("Press enter to exit\n"); rc = read(0, &c, 1); + pmd_test_exit(); if (rc < 0) return 1; }