summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Ribas <jonathan.ribas@fraudbuster.mobi>2019-01-18 17:22:18 +0100
committerJonathan Ribas <jonathan.ribas@fraudbuster.mobi>2019-01-18 17:22:18 +0100
commit8f9199e0f7afa4a081ee5f71e9e227e2da1c36a4 (patch)
treeb993fcfe2b683d8ea1901f33ffa318e87ed9e869
parent7532d33b2a1ea05f4ad9f0584d5db2b72c9c5062 (diff)
downloaddpdk-burst-replay-8f9199e0f7afa4a081ee5f71e9e227e2da1c36a4.zip
dpdk-burst-replay-8f9199e0f7afa4a081ee5f71e9e227e2da1c36a4.tar.gz
dpdk-burst-replay-8f9199e0f7afa4a081ee5f71e9e227e2da1c36a4.tar.xz
Update logs (makes the non-debug build less verbose)
-rw-r--r--src/cpus.c8
-rw-r--r--src/dpdk.c9
-rw-r--r--src/pcap.c5
3 files changed, 19 insertions, 3 deletions
diff --git a/src/cpus.c b/src/cpus.c
index 17ea101..fe895ad 100644
--- a/src/cpus.c
+++ b/src/cpus.c
@@ -28,17 +28,23 @@ static int find_cpus_to_use(const struct cmd_opts* opts, struct cpus_bindings* c
printf("%s: malloc failed.\n", __FUNCTION__);
return (ENOMEM);
}
+#ifdef DEBUG
printf("CPU cores to use:");
+#endif /* DEBUG */
for (i = 0, cpu_cpt = 0; i < cpus->nb_available_cpus; i++) {
/* be sure that we get cores on the wanted numa */
if (cpus->numacore == numa_node_of_cpu(i)) {
cpus->cpus_to_use[cpu_cpt++] = i;
+#ifdef DEBUG
printf(" %i", i);
+#endif /* DEBUG */
if (cpu_cpt == cpus->nb_needed_cpus + 1) /* +1 to keep the first as fake master */
break;
} else cpus->numacores = 2;
}
+#ifdef DEBUG
putchar('\n');
+#endif /* DEBUG */
if (cpu_cpt < cpus->nb_needed_cpus + 1) {
printf("Wanted %i threads on numa %i, but found only %i CPUs.\n",
cpus->nb_needed_cpus + 1, cpus->numacore, cpu_cpt);
@@ -62,7 +68,9 @@ static uint64_t generate_mask(const struct cpus_bindings* cpus, uint8_t number)
/* generate coremask */
for (coremask = 0, i = 0; i < number; i++)
coremask |= (uint64_t)(1 << cpus->cpus_to_use[i]);
+#ifdef DEBUG
printf("%s for %u cores -> 0x%lx\n", __FUNCTION__, number, coremask);
+#endif /* DEBUG */
return (coremask);
}
diff --git a/src/dpdk.c b/src/dpdk.c
index 22701f0..6a9dde1 100644
--- a/src/dpdk.c
+++ b/src/dpdk.c
@@ -11,6 +11,7 @@
/* DPDK includes */
#include <rte_version.h>
#include <rte_ethdev.h>
+#include <rte_log.h>
#include "main.h"
@@ -183,6 +184,8 @@ int init_dpdk_eal_mempool(const struct cmd_opts* opts,
if (!opts || !cpus || !dpdk)
return (EINVAL);
+ rte_log_set_global_level(RTE_LOG_ERR);
+
/* craft an eal arg list */
eal_args = fill_eal_args(opts, cpus, dpdk, &eal_args_ac);
if (!eal_args) {
@@ -292,7 +295,9 @@ int tx_thread(void* thread_ctx)
ctx = (struct thread_ctx*)thread_ctx;
thread_id = ctx->tx_port_id;
mbuf = ctx->pcap_cache->mbufs;
+#ifdef DEBUG
printf("Starting thread %i.\n", thread_id);
+#endif
/* init semaphore to wait to start the burst */
ret = sem_wait(ctx->sem);
@@ -357,7 +362,9 @@ int tx_thread(void* thread_ctx)
return (errno);
}
ctx->duration = timespec_diff_to_double(start, end);
+#ifdef DEBUG
printf("Exiting thread %i properly.\n", thread_id);
+#endif /* DEBUG */
return (0);
}
@@ -376,7 +383,7 @@ int process_result_stats(const struct cpus_bindings* cpus,
total_pps = total_bitrate = 0;
total_drop = 0;
- puts("\nRESULTS :");
+ puts("RESULTS :");
for (i = 0; i < cpus->nb_needed_cpus; i++) {
total_pkt_sent = (ctx[i].nb_pkt * opts->nbruns) - ctx[i].total_drop;
total_pkt_sent_sz = (dpdk->pcap_sz * opts->nbruns) - ctx[i].total_drop_sz;
diff --git a/src/pcap.c b/src/pcap.c
index 8a412bd..5b04301 100644
--- a/src/pcap.c
+++ b/src/pcap.c
@@ -235,7 +235,7 @@ int load_pcap(const struct cmd_opts* opts, struct pcap_ctx* pcap,
if (ret)
goto load_pcapError;
- printf("-> Will cache %i pkts.\n", pcap->nb_pkts);
+ printf("-> Will cache %i pkts on %i caches.\n", pcap->nb_pkts, cpus->nb_needed_cpus);
for (; cpt < pcap->nb_pkts; cpt++) {
/* get packet pcap header */
nb_read = read(pcap->fd, &pcap_rechdr, sizeof(pcap_rechdr));
@@ -286,7 +286,8 @@ int load_pcap(const struct cmd_opts* opts, struct pcap_ctx* pcap,
load_pcapError:
percent = 100 * cpt / pcap->nb_pkts;
printf("%sfile read at %02.2f%%\n", (ret ? "\n" : "\r"), percent);
- printf("read %u pkts (for a total of %li bytes).\n", cpt, total_read);
+ if (ret)
+ printf("read %u pkts (for a total of %li bytes).\n", cpt, total_read);
dpdk->pcap_sz = total_read;
close(pcap->fd);
pcap->fd = 0;