X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fqos_sched%2Fmain.c;h=7732273d11450d11624bf7322c9d36a8d2fcc090;hb=fdf20fa7bee9df9037116318a87080e1eb7e757e;hp=b6cbe3572ae93e04d88767d07cd82489e9685a32;hpb=de3cfa2c9823a7e0391d4f4a355e2d78b83eec62;p=dpdk.git diff --git a/examples/qos_sched/main.c b/examples/qos_sched/main.c old mode 100755 new mode 100644 index b6cbe3572a..7732273d11 --- a/examples/qos_sched/main.c +++ b/examples/qos_sched/main.c @@ -1,35 +1,34 @@ /*- * BSD LICENSE - * - * Copyright(c) 2010-2013 Intel Corporation. All rights reserved. + * + * 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 + * + * 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 + * + * * 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 + * * 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 + * * 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 + * + * 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 @@ -53,6 +52,9 @@ #define APP_WT_MODE 2 #define APP_TX_MODE 4 +uint8_t interactive = APP_INTERACTIVE_DEFAULT; +uint32_t qavg_period = APP_QAVG_PERIOD; +uint32_t qavg_ntimes = APP_QAVG_NTIMES; /* main processing loop */ static int @@ -123,8 +125,9 @@ app_main_loop(__attribute__((unused))void *dummy) /* initialize mbuf memory */ if (mode == APP_RX_MODE) { for (i = 0; i < rx_idx; i++) { - RTE_LOG(INFO, APP, "flow %u lcoreid %u reading port %hu\n", - i, lcore_id, rx_confs[i]->rx_port); + RTE_LOG(INFO, APP, "flow %u lcoreid %u " + "reading port %"PRIu8"\n", + i, lcore_id, rx_confs[i]->rx_port); } app_rx_thread(rx_confs); @@ -132,13 +135,14 @@ app_main_loop(__attribute__((unused))void *dummy) else if (mode == (APP_TX_MODE | APP_WT_MODE)) { for (i = 0; i < wt_idx; i++) { wt_confs[i]->m_table = rte_malloc("table_wt", sizeof(struct rte_mbuf *) - * burst_conf.tx_burst, CACHE_LINE_SIZE); + * burst_conf.tx_burst, RTE_CACHE_LINE_SIZE); if (wt_confs[i]->m_table == NULL) rte_panic("flow %u unable to allocate memory buffer\n", i); - RTE_LOG(INFO, APP, "flow %u lcoreid %u sched+write port %hu\n", - i, lcore_id, wt_confs[i]->tx_port); + RTE_LOG(INFO, APP, "flow %u lcoreid %u sched+write " + "port %"PRIu8"\n", + i, lcore_id, wt_confs[i]->tx_port); } app_mixed_thread(wt_confs); @@ -146,13 +150,14 @@ app_main_loop(__attribute__((unused))void *dummy) else if (mode == APP_TX_MODE) { for (i = 0; i < tx_idx; i++) { tx_confs[i]->m_table = rte_malloc("table_tx", sizeof(struct rte_mbuf *) - * burst_conf.tx_burst, CACHE_LINE_SIZE); + * burst_conf.tx_burst, RTE_CACHE_LINE_SIZE); if (tx_confs[i]->m_table == NULL) rte_panic("flow %u unable to allocate memory buffer\n", i); - RTE_LOG(INFO, APP, "flow %u lcoreid %u writing port %hu\n", - i, lcore_id, tx_confs[i]->tx_port); + RTE_LOG(INFO, APP, "flow %u lcoreid %u " + "writing port %"PRIu8"\n", + i, lcore_id, tx_confs[i]->tx_port); } app_tx_thread(tx_confs); @@ -168,7 +173,7 @@ app_main_loop(__attribute__((unused))void *dummy) return 0; } -static void +void app_stat(void) { uint32_t i; @@ -181,18 +186,19 @@ app_stat(void) struct flow_conf *flow = &qos_conf[i]; rte_eth_stats_get(flow->rx_port, &stats); - printf("\nRX port %hu: rx: %"PRIu64 " err: %"PRIu64 " no_mbuf: %"PRIu64 "\n", - flow->rx_port, - stats.ipackets - rx_stats[i].ipackets, - stats.ierrors - rx_stats[i].ierrors, - stats.rx_nombuf - rx_stats[i].rx_nombuf); + printf("\nRX port %"PRIu8": rx: %"PRIu64 " err: %"PRIu64 + " no_mbuf: %"PRIu64 "\n", + flow->rx_port, + stats.ipackets - rx_stats[i].ipackets, + stats.ierrors - rx_stats[i].ierrors, + stats.rx_nombuf - rx_stats[i].rx_nombuf); memcpy(&rx_stats[i], &stats, sizeof(stats)); rte_eth_stats_get(flow->tx_port, &stats); - printf("TX port %hu: tx: %" PRIu64 " err: %" PRIu64 "\n", - flow->tx_port, - stats.opackets - tx_stats[i].opackets, - stats.oerrors - tx_stats[i].oerrors); + printf("TX port %"PRIu8": tx: %" PRIu64 " err: %" PRIu64 "\n", + flow->tx_port, + stats.opackets - tx_stats[i].opackets, + stats.oerrors - tx_stats[i].oerrors); memcpy(&tx_stats[i], &stats, sizeof(stats)); //printf("MP = %d\n", rte_mempool_count(conf->app_pktmbuf_pool)); @@ -216,10 +222,8 @@ app_stat(void) } } - - int -MAIN(int argc, char **argv) +main(int argc, char **argv) { int ret; @@ -231,16 +235,21 @@ MAIN(int argc, char **argv) if (ret < 0) return -1; - /* launch per-lcore init on every lcore */ rte_eal_mp_remote_launch(app_main_loop, NULL, SKIP_MASTER); - - /* print statistics every second */ - while(1) { + + if (interactive) { sleep(1); - app_stat(); + prompt(); + } + else { + /* print statistics every second */ + while(1) { + sleep(1); + app_stat(); + } } -} - + return 0; +}