@@ -101,6 +101,7 @@ static void usage(char *progname);
static int scan_ip(char *buf, unsigned int *paddr);
static int scan_mac(char *in, odph_ethaddr_t *des);
static void tv_sub(struct timeval *recvtime, struct timeval *sendtime);
+static void print_global_stats(void);
/**
* Sleep for the specified amount of milliseconds
@@ -371,7 +372,6 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool)
static void *gen_send_thread(void *arg)
{
int thr;
- uint64_t start, now, diff;
odp_pktio_t pktio;
thread_args_t *thr_args;
odp_queue_t outq_def;
@@ -393,7 +393,6 @@ static void *gen_send_thread(void *arg)
return NULL;
}
- start = odp_time_cycles();
printf(" [%02i] created mode: SEND\n", thr);
for (;;) {
int err;
@@ -434,15 +433,6 @@ static void *gen_send_thread(void *arg)
>= (unsigned int)args->appl.number) {
break;
}
-
- now = odp_time_cycles();
- diff = odp_time_diff_cycles(start, now);
- if (odp_time_cycles_to_ns(diff) > 20 * ODP_TIME_SEC) {
- start = odp_time_cycles();
- printf(" [%02i] total send: %ju\n",
- thr, odp_atomic_load_u64(&counters.seq));
- fflush(stdout);
- }
}
/* receive number of reply pks until timeout */
@@ -589,6 +579,45 @@ static void *gen_recv_thread(void *arg)
return arg;
}
+
+/**
+ * printing verbose statistics
+ *
+ */
+static void print_global_stats(void)
+{
+ uint64_t start, now, diff;
+ int loop_forever = 1;
+
+ if (args->appl.timeout != -1 || args->appl.number > 0)
+ loop_forever = 0;
+
+ start = odp_time_cycles();
+ do {
+ now = odp_time_cycles();
+ diff = odp_time_diff_cycles(start, now);
+ if (odp_time_cycles_to_ns(diff) > 20 * ODP_TIME_SEC) {
+ start = odp_time_cycles();
+ if (args->appl.mode == APPL_MODE_RCV ||
+ odp_atomic_load_u64(&counters.icmp) != 0 ||
+ odp_atomic_load_u64(&counters.udp) != 0) {
+ printf(" total receive(icmp:%ju, udp:%ju)\n",
+ odp_atomic_load_u64(&counters.icmp),
+ odp_atomic_load_u64(&counters.udp));
+ }
+
+ if (odp_atomic_load_u64(&counters.seq) > 0)
+ printf(" total send: %ju\n",
+ odp_atomic_load_u64(&counters.seq));
+
+ if (args->appl.number > 0 &&
+ odp_atomic_load_u64(&counters.icmp) >=
+ (unsigned int)args->appl.number)
+ break;
+ }
+ } while (loop_forever || args->appl.timeout >= 0);
+}
+
/**
* ODP packet example main function
*/
@@ -796,6 +825,8 @@ int main(int argc, char *argv[])
}
}
+ print_global_stats();
+
/* Master thread waits for other threads to exit */
odph_linux_pthread_join(thread_tbl, num_workers);
Signed-off-by: Balakrishna.Garapati <balakrishna.garapati@linaro.org> --- Moved verbose output logic from worker to control thread example/generator/odp_generator.c | 53 +++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 11 deletions(-)