X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fl2fwd%2Fmain.c;h=3827aa44530574390f04a11ac035a6e81fdf3cf9;hb=fa0eea389ba867614a44c7613d6390f9944e5526;hp=e175681944629a86fc2bc1cb39cdd3738bf99e34;hpb=e2366e74e0295a8b21019dd871a10c77e9adb4b2;p=dpdk.git diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c index e175681944..3827aa4453 100644 --- a/examples/l2fwd/main.c +++ b/examples/l2fwd/main.c @@ -68,7 +68,6 @@ #include #include #include -#include #include #include @@ -80,6 +79,7 @@ static volatile bool force_quit; #define MAX_PKT_BURST 32 #define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */ +#define MEMPOOL_CACHE_SIZE 256 /* * Configurable number of RX/TX ring descriptors @@ -134,10 +134,9 @@ struct l2fwd_port_statistics { } __rte_cache_aligned; struct l2fwd_port_statistics port_statistics[RTE_MAX_ETHPORTS]; -/* A tsc-based timer responsible for triggering statistics printout */ -#define TIMER_MILLISECOND 2000000ULL /* around 1ms at 2 Ghz */ #define MAX_TIMER_PERIOD 86400 /* 1 day max */ -static int64_t timer_period = 10 * TIMER_MILLISECOND * 1000; /* default period is 10 seconds */ +/* A tsc-based timer responsible for triggering statistics printout */ +static uint64_t timer_period = 10; /* default period is 10 seconds */ /* Print out statistics on packets dropped */ static void @@ -274,7 +273,7 @@ l2fwd_main_loop(void) timer_tsc += diff_tsc; /* if timer has reached its timeout */ - if (unlikely(timer_tsc >= (uint64_t) timer_period)) { + if (unlikely(timer_tsc >= timer_period)) { /* do this only on master core */ if (lcore_id == rte_get_master_lcore()) { @@ -381,7 +380,7 @@ l2fwd_parse_timer_period(const char *q_arg) static int l2fwd_parse_args(int argc, char **argv) { - int opt, ret; + int opt, ret, timer_secs; char **argvopt; int option_index; char *prgname = argv[0]; @@ -417,12 +416,13 @@ l2fwd_parse_args(int argc, char **argv) /* timer period */ case 'T': - timer_period = l2fwd_parse_timer_period(optarg) * 1000 * TIMER_MILLISECOND; - if (timer_period < 0) { + timer_secs = l2fwd_parse_timer_period(optarg); + if (timer_secs < 0) { printf("invalid timer period\n"); l2fwd_usage(prgname); return -1; } + timer_period = timer_secs; break; /* long options */ @@ -480,7 +480,7 @@ check_all_ports_link_status(uint8_t port_num, 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; } @@ -541,9 +541,13 @@ main(int argc, char **argv) if (ret < 0) rte_exit(EXIT_FAILURE, "Invalid L2FWD arguments\n"); + /* convert to number of cycles */ + timer_period *= rte_get_timer_hz(); + /* create the mbuf pool */ - l2fwd_pktmbuf_pool = rte_pktmbuf_pool_create("mbuf_pool", NB_MBUF, 32, - 0, RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id()); + l2fwd_pktmbuf_pool = rte_pktmbuf_pool_create("mbuf_pool", NB_MBUF, + MEMPOOL_CACHE_SIZE, 0, RTE_MBUF_DEFAULT_BUF_SIZE, + rte_socket_id()); if (l2fwd_pktmbuf_pool == NULL) rte_exit(EXIT_FAILURE, "Cannot init mbuf pool\n"); @@ -551,9 +555,6 @@ main(int argc, char **argv) if (nb_ports == 0) rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n"); - if (nb_ports > RTE_MAX_ETHPORTS) - nb_ports = RTE_MAX_ETHPORTS; - /* reset l2fwd_dst_ports */ for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) l2fwd_dst_ports[portid] = 0;