diff options
author | Mohammad Abdul Awal <mohammad.abdul.awal@intel.com> | 2016-09-15 09:03:08 +0100 |
---|---|---|
committer | Mohammad Abdul Awal <mohammad.abdul.awal@intel.com> | 2016-09-16 14:29:15 +0100 |
commit | c216b95d0278eff271f12766cc630baaa21d8af0 (patch) | |
tree | f703949f7c41f397e26cc762777bdec873219515 /examples/udpfwd/main.c | |
parent | 258f299a2a152acab4ce497673eb293c5da15f73 (diff) |
allocated all port and all cpu momory together instead of realloc
Change-Id: I3240e6afefb5d784e08e3a5a1b70ada7d5b4b223
Signed-off-by: Mohammad Abdul Awal <mohammad.abdul.awal@intel.com>
Diffstat (limited to 'examples/udpfwd/main.c')
-rw-r--r-- | examples/udpfwd/main.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/examples/udpfwd/main.c b/examples/udpfwd/main.c index 1eb4e2a..c260d1c 100644 --- a/examples/udpfwd/main.c +++ b/examples/udpfwd/main.c @@ -500,7 +500,6 @@ calculate_nb_prtq(struct netbe_cfg *cfg) lc = find_initilized_lcore(cfg, prt->lcore[j]); if (lc == NULL) { - NETBE_REALLOC(cfg->cpu, cfg->cpu_num + 1); lc = &cfg->cpu[cfg->cpu_num]; lc->id = prt->lcore[j]; cfg->cpu_num++; @@ -526,22 +525,30 @@ netbe_port_init(struct netbe_cfg *cfg, int argc, char *argv[]) int32_t rc; uint32_t i, n, sid, j; struct netbe_port *prt; + rte_cpuset_t cpuset; + uint32_t nc; n = (uint32_t)argc; + cfg->prt = rte_zmalloc(NULL, sizeof(struct netbe_port) * n, + RTE_CACHE_LINE_SIZE); + cfg->prt_num = n; rc = 0; for (i = 0; i != n; i++) { - NETBE_REALLOC(cfg->prt, cfg->prt_num + 1); - rc = parse_netbe_arg(cfg->prt + i, argv[i]); + rc = parse_netbe_arg(cfg->prt + i, argv[i], &cpuset); if (rc != 0) { RTE_LOG(ERR, USER1, "%s: processing of \"%s\" failed with error code: %d\n", __func__, argv[i], rc); return rc; } - cfg->prt_num++; } + for (i = 0, nc = 0; i < RTE_MAX_LCORE; i++) + nc += CPU_ISSET(i, &cpuset); + cfg->cpu = rte_zmalloc(NULL, sizeof(struct netbe_lcore) * nc, + RTE_CACHE_LINE_SIZE); + /* calculate number of queues per lcore. */ rc = calculate_nb_prtq(cfg); if (rc != 0) { |