X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=app%2Ftest%2Ftest_timer_racecond.c;h=133d3324ee6611528da63f95aab2f7b687424dd4;hb=c17af95a19e30c8d89eb96ceca99f60474ca2ac4;hp=aef320372a659550c7132a5bf8f2c1ec36b5f6f3;hpb=6d2d5e19e0fc323b2cc464c4f374adc6787780fa;p=dpdk.git diff --git a/app/test/test_timer_racecond.c b/app/test/test_timer_racecond.c index aef320372a..133d3324ee 100644 --- a/app/test/test_timer_racecond.c +++ b/app/test/test_timer_racecond.c @@ -1,8 +1,6 @@ -/*- - * BSD LICENSE - * - * Copyright(c) 2015 Akamai Technologies. - * All rights reserved. +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2015 Akamai Technologies. + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -42,10 +40,9 @@ #include #include #include +#include -#undef TEST_TIMER_RACECOND_VERBOSE - -#ifdef RTE_EXEC_ENV_LINUXAPP +#ifdef RTE_EXEC_ENV_LINUX #define usec_delay(us) usleep(us) #else #define usec_delay(us) rte_delay_us(us) @@ -53,29 +50,29 @@ #define BILLION (1UL << 30) -#define TEST_DURATION_S 20 /* in seconds */ +#define TEST_DURATION_S 4 /* in seconds */ #define N_TIMERS 50 static struct rte_timer timer[N_TIMERS]; -static unsigned timer_lcore_id[N_TIMERS]; +static unsigned int timer_lcore_id[N_TIMERS]; -static unsigned master; -static volatile unsigned stop_slaves; +static unsigned int main_lcore; +static volatile unsigned int stop_workers; static int reload_timer(struct rte_timer *tim); +RTE_LOG_REGISTER(timer_logtype_test, test.timer, INFO); + static void timer_cb(struct rte_timer *tim, void *arg __rte_unused) { /* Simulate slow callback function, 100 us. */ rte_delay_us(100); - -#ifdef TEST_TIMER_RACECOND_VERBOSE if (tim == &timer[0]) - printf("------------------------------------------------\n"); - printf("timer_cb: core %u timer %lu\n", - rte_lcore_id(), tim - timer); -#endif + rte_log(RTE_LOG_DEBUG, timer_logtype_test, + "------------------------------------------------\n"); + rte_log(RTE_LOG_DEBUG, timer_logtype_test, "%s: core %u timer %" + PRIuPTR "\n", __func__, rte_lcore_id(), tim - timer); (void)reload_timer(tim); } @@ -93,19 +90,18 @@ reload_timer(struct rte_timer *tim) (tim - timer); int ret; - ret = rte_timer_reset(tim, ticks, PERIODICAL, master, timer_cb, NULL); + ret = rte_timer_reset(tim, ticks, PERIODICAL, main_lcore, timer_cb, NULL); if (ret != 0) { -#ifdef TEST_TIMER_RACECOND_VERBOSE - printf("- core %u failed to reset timer %lu (OK)\n", + rte_log(RTE_LOG_DEBUG, timer_logtype_test, + "- core %u failed to reset timer %" PRIuPTR " (OK)\n", rte_lcore_id(), tim - timer); -#endif RTE_PER_LCORE(n_reset_collisions) += 1; } return ret; } static int -slave_main_loop(__attribute__((unused)) void *arg) +worker_main_loop(__rte_unused void *arg) { unsigned lcore_id = rte_lcore_id(); unsigned i; @@ -114,7 +110,7 @@ slave_main_loop(__attribute__((unused)) void *arg) printf("Starting main loop on core %u\n", lcore_id); - while (!stop_slaves) { + while (!stop_workers) { /* Wait until the timer manager is running. * We know it's running when we see timer[0] NOT pending. */ @@ -151,7 +147,7 @@ test_timer_racecond(void) unsigned lcore_id; unsigned i; - master = lcore_id = rte_lcore_id(); + main_lcore = lcore_id = rte_lcore_id(); hz = rte_get_timer_hz(); /* init and start timers */ @@ -160,8 +156,8 @@ test_timer_racecond(void) ret = reload_timer(&timer[i]); TEST_ASSERT(ret == 0, "reload_timer failed"); - /* Distribute timers to slaves. - * Note that we assign timer[0] to the master. + /* Distribute timers to workers. + * Note that we assign timer[0] to the main. */ timer_lcore_id[i] = lcore_id; lcore_id = rte_get_next_lcore(lcore_id, 1, 1); @@ -171,11 +167,11 @@ test_timer_racecond(void) cur_time = rte_get_timer_cycles(); end_time = cur_time + (hz * TEST_DURATION_S); - /* start slave cores */ - stop_slaves = 0; + /* start worker cores */ + stop_workers = 0; printf("Start timer manage race condition test (%u seconds)\n", TEST_DURATION_S); - rte_eal_mp_remote_launch(slave_main_loop, NULL, SKIP_MASTER); + rte_eal_mp_remote_launch(worker_main_loop, NULL, SKIP_MAIN); while (diff >= 0) { /* run the timers */ @@ -188,9 +184,9 @@ test_timer_racecond(void) diff = end_time - cur_time; } - /* stop slave cores */ + /* stop worker cores */ printf("Stopping timer manage race condition test\n"); - stop_slaves = 1; + stop_workers = 1; rte_eal_mp_wait_lcore(); /* stop timers */ @@ -202,8 +198,4 @@ test_timer_racecond(void) return TEST_SUCCESS; } -static struct test_command timer_racecond_cmd = { - .command = "timer_racecond_autotest", - .callback = test_timer_racecond, -}; -REGISTER_TEST_COMMAND(timer_racecond_cmd); +REGISTER_TEST_COMMAND(timer_racecond_autotest, test_timer_racecond);