summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Ribas <jonathan.ribas@fraudbuster.mobi>2018-12-13 16:28:12 +0100
committerJonathan Ribas <jonathan.ribas@fraudbuster.mobi>2018-12-13 16:28:12 +0100
commit8bb0256742806ef4bb434036ccb2b738f92f2f2d (patch)
tree2371f9d96017886fef45fd03a36d17fedb4d1ff4
parentd9a97c2f6e0409700c3377d1a85f668af51710f4 (diff)
downloaddpdk-burst-replay-8bb0256742806ef4bb434036ccb2b738f92f2f2d.zip
dpdk-burst-replay-8bb0256742806ef4bb434036ccb2b738f92f2f2d.tar.gz
dpdk-burst-replay-8bb0256742806ef4bb434036ccb2b738f92f2f2d.tar.xz
Fix memory calculation for big pcap files.
-rw-r--r--src/dpdk.c2
-rw-r--r--src/main.c10
-rw-r--r--src/main.h6
3 files changed, 9 insertions, 9 deletions
diff --git a/src/dpdk.c b/src/dpdk.c
index 48333a6..22701f0 100644
--- a/src/dpdk.c
+++ b/src/dpdk.c
@@ -218,7 +218,7 @@ int init_dpdk_eal_mempool(const struct cmd_opts* opts,
return (1);
}
- printf("-> Create mempool of %u mbufs of %u octs.\n",
+ printf("-> Create mempool of %lu mbufs of %lu octs.\n",
dpdk->nb_mbuf, dpdk->mbuf_sz);
dpdk->pktmbuf_pool = rte_mempool_create("dpdk_replay_mempool",
dpdk->nb_mbuf,
diff --git a/src/main.c b/src/main.c
index 07d0530..afd5c71 100644
--- a/src/main.c
+++ b/src/main.c
@@ -144,12 +144,12 @@ int check_needed_memory(const struct cmd_opts* opts, const struct pcap_ctx* pcap
puts("Needed paket allocation size = "
"(size of MBUF) + (size of biggest pcap packet), "
"rounded up to the next multiple of an integer.");
- printf("(%lu + %u) + ((%lu + %u) %% %lu) = %u\n",
+ printf("(%lu + %u) + ((%lu + %u) %% %lu) = %lu\n",
sizeof(struct rte_mbuf), pcap->max_pkt_sz,
sizeof(struct rte_mbuf), pcap->max_pkt_sz,
sizeof(int), dpdk->mbuf_sz);
#endif /* DEBUG */
- printf("-> Needed MBUF size: %u\n", dpdk->mbuf_sz);
+ printf("-> Needed MBUF size: %lu\n", dpdk->mbuf_sz);
/* # CALCULATE THE NEEDED NUMBER OF MBUFS */
/* For number of pkts to be allocated on the mempool, DPDK says: */
@@ -160,13 +160,13 @@ int check_needed_memory(const struct cmd_opts* opts, const struct pcap_ctx* pcap
"(nb pkts * nb ports)");
#endif /* DEBUG */
dpdk->nb_mbuf = get_next_power_of_2(pcap->nb_pkts * opts->nb_pcicards) - 1;
- printf("-> Needed number of MBUFS: %u\n", dpdk->nb_mbuf);
+ printf("-> Needed number of MBUFS: %lu\n", dpdk->nb_mbuf);
/* # CALCULATE THE TOTAL NEEDED MEMORY SIZE */
needed_mem = dpdk->mbuf_sz * dpdk->nb_mbuf;
#ifdef DEBUG
puts("Needed memory = (needed mbuf size) * (number of needed mbuf).");
- printf("%u * %u = %.0f bytes\n", dpdk->mbuf_sz, dpdk->nb_mbuf, needed_mem);
+ printf("%lu * %lu = %.0f bytes\n", dpdk->mbuf_sz, dpdk->nb_mbuf, needed_mem);
#endif /* DEBUG */
hsize = nb_oct_to_human_str(needed_mem);
if (!hsize)
@@ -179,7 +179,7 @@ int check_needed_memory(const struct cmd_opts* opts, const struct pcap_ctx* pcap
dpdk->pool_sz = needed_mem / (float)(1024*1024*1024) + 1;
else
dpdk->pool_sz = needed_mem / (1024*1024*1024);
- printf("-> Needed Hugepages of 1 Go = %i\n", dpdk->pool_sz);
+ printf("-> Needed Hugepages of 1 Go = %lu\n", dpdk->pool_sz);
return (0);
}
diff --git a/src/main.h b/src/main.h
index e169920..634735c 100644
--- a/src/main.h
+++ b/src/main.h
@@ -55,9 +55,9 @@ struct pcap_cache {
/* struct to store dpdk context */
struct dpdk_ctx {
- unsigned int nb_mbuf; /* number of needed mbuf (see main.c) */
- unsigned int mbuf_sz; /* wanted/needed size for the mbuf (see main.c) */
- unsigned int pool_sz; /* mempool wanted/needed size (see main.c) */
+ unsigned long nb_mbuf; /* number of needed mbuf (see main.c) */
+ unsigned long mbuf_sz; /* wanted/needed size for the mbuf (see main.c) */
+ unsigned long pool_sz; /* mempool wanted/needed size (see main.c) */
struct rte_mempool* pktmbuf_pool;
/* pcap file caches */