diff options
author | Matias Elo <matias.elo@nokia.com> | 2016-02-24 15:47:19 +0200 |
---|---|---|
committer | Maxim Uvarov <maxim.uvarov@linaro.org> | 2016-02-25 09:26:44 +0300 |
commit | 8a7c720c15c3de7f39a0bae9453cc742cc030302 (patch) | |
tree | 82f986ad6d6037e9c62b5ece3ac1b00f3e91aed8 /example | |
parent | df4789d50f85af895dbeb6fbbd97f8d78f965318 (diff) |
example: generator: retry tx if no failure code is returned
If odp_pktout_send() doesn't return an error code (ret == 0)
try to resend after a small delay. This enables running
odp_l2fwd_run validation test with netmap enabled.
Signed-off-by: Matias Elo <matias.elo@nokia.com>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'example')
-rw-r--r-- | example/generator/odp_generator.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index c06a31968..40e34f305 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -71,6 +71,7 @@ static struct { odp_atomic_u64_t udp; /**< udp packets */ odp_atomic_u64_t icmp; /**< icmp packets */ odp_atomic_u64_t cnt; /**< sent packets*/ + odp_atomic_u64_t tx_drops; /**< packets dropped in transmit */ } counters; /** * Thread specific arguments @@ -351,6 +352,7 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool) static void *gen_send_thread(void *arg) { int thr; + int ret; odp_pktio_t pktio; thread_args_t *thr_args; odp_pktout_queue_t pktout; @@ -390,7 +392,15 @@ static void *gen_send_thread(void *arg) return NULL; } - if (odp_pktout_send(pktout, &pkt, 1) < 1) { + for (;;) { + ret = odp_pktout_send(pktout, &pkt, 1); + if (ret == 1) { + break; + } else if (ret == 0) { + odp_atomic_add_u64(&counters.tx_drops, 1); + odp_time_wait_ns(ODP_TIME_MSEC_IN_NS); + continue; + } EXAMPLE_ERR(" [%02i] packet send failed\n", thr); odp_packet_free(pkt); return NULL; @@ -586,7 +596,8 @@ static void print_global_stats(int num_workers) } pkts = odp_atomic_load_u64(&counters.seq); - printf(" total sent: %" PRIu64 "\n", pkts); + printf(" total sent: %" PRIu64 ", drops: %" PRIu64 "\n", pkts, + odp_atomic_load_u64(&counters.tx_drops)); if (args->appl.mode == APPL_MODE_UDP) { pps = (pkts - pkts_prev) / verbose_interval; @@ -633,6 +644,7 @@ int main(int argc, char *argv[]) odp_atomic_init_u64(&counters.udp, 0); odp_atomic_init_u64(&counters.icmp, 0); odp_atomic_init_u64(&counters.cnt, 0); + odp_atomic_init_u64(&counters.tx_drops, 0); /* Reserve memory for args from shared mem */ shm = odp_shm_reserve("shm_args", sizeof(args_t), |