Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH v2] validation: timer: periodic timer capa test per clock src #1936

Merged
merged 2 commits into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 42 additions & 21 deletions test/validation/api/timer/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ typedef struct {
/* Clock source support flags */
uint8_t clk_supported[ODP_CLOCK_NUM_SRC];

/* Periodic timer support per clock source*/
uint8_t periodic_support[ODP_CLOCK_NUM_SRC];

/* Periodic timers not supported with any clock source */
int no_periodic;

/* Default resolution / timeout parameters */
struct {
uint64_t res_ns;
Expand Down Expand Up @@ -97,9 +103,6 @@ typedef struct {
/* Number of timers allocated per thread */
uint32_t timers_per_thread;

/* Periodic timers supported */
int periodic;

/* Queue type to be tested */
odp_queue_type_t test_queue_type;

Expand All @@ -117,6 +120,7 @@ static int timer_global_init(odp_instance_t *inst)
uint64_t res_ns, min_tmo, max_tmo;
unsigned int range;
int i;
int num_periodic = 0;

if (odph_options(&helper_options)) {
ODPH_ERR("odph_options() failed\n");
Expand Down Expand Up @@ -184,23 +188,26 @@ static int timer_global_init(odp_instance_t *inst)
return -1;
}

/* Default parameters for test cases */
global_mem->clk_supported[0] = 1;
/* Default parameters for test cases using the default clock source */
global_mem->param.res_ns = res_ns;
global_mem->param.min_tmo = min_tmo;
global_mem->param.max_tmo = max_tmo;
global_mem->param.queue_type_plain = capa.queue_type_plain;
global_mem->param.queue_type_sched = capa.queue_type_sched;

/* Check which other source clocks are supported */
for (i = 1; i < ODP_CLOCK_NUM_SRC; i++) {
if (odp_timer_capability(ODP_CLOCK_SRC_0 + i, &capa) == 0)
/* Check which clock sources are supported */
for (i = 0; i < ODP_CLOCK_NUM_SRC; i++) {
if (odp_timer_capability(ODP_CLOCK_SRC_0 + i, &capa) == 0) {
global_mem->clk_supported[i] = 1;

if (capa.periodic.max_pools) {
global_mem->periodic_support[i] = 1;
num_periodic++;
}
}
}

/* Check if periodic timers are supported */
if (capa.periodic.max_pools > 0)
global_mem->periodic = 1;
global_mem->no_periodic = !num_periodic;

return 0;
}
Expand Down Expand Up @@ -248,23 +255,23 @@ check_plain_queue_support(void)

static int check_periodic_support(void)
{
if (global_mem->periodic)
return ODP_TEST_ACTIVE;
if (global_mem->no_periodic)
return ODP_TEST_INACTIVE;

return ODP_TEST_INACTIVE;
return ODP_TEST_ACTIVE;
}

static int check_periodic_sched_support(void)
{
if (global_mem->periodic && global_mem->param.queue_type_sched)
if (global_mem->periodic_support[0] && global_mem->param.queue_type_sched)
return ODP_TEST_ACTIVE;

return ODP_TEST_INACTIVE;
}

static int check_periodic_plain_support(void)
{
if (global_mem->periodic && global_mem->param.queue_type_plain)
if (global_mem->periodic_support[0] && global_mem->param.queue_type_plain)
return ODP_TEST_ACTIVE;

return ODP_TEST_INACTIVE;
Expand Down Expand Up @@ -2638,7 +2645,7 @@ static void timer_test_sched_all(void)
timer_test_all(ODP_QUEUE_TYPE_SCHED);
}

static void timer_test_periodic_capa(void)
static void timer_test_periodic_capa_run(odp_timer_clk_src_t clk_src)
{
odp_timer_capability_t timer_capa;
odp_timer_periodic_capability_t capa;
Expand All @@ -2650,7 +2657,7 @@ static void timer_test_periodic_capa(void)
uint32_t num = 100;

memset(&timer_capa, 0, sizeof(odp_timer_capability_t));
CU_ASSERT_FATAL(odp_timer_capability(ODP_CLOCK_DEFAULT, &timer_capa) == 0);
CU_ASSERT_FATAL(odp_timer_capability(clk_src, &timer_capa) == 0);
CU_ASSERT(timer_capa.periodic.max_pools);
CU_ASSERT(timer_capa.periodic.max_timers);

Expand Down Expand Up @@ -2681,7 +2688,7 @@ static void timer_test_periodic_capa(void)
capa.max_multiplier = 1;
capa.res_ns = 0;

CU_ASSERT(odp_timer_periodic_capability(ODP_CLOCK_DEFAULT, &capa) == 1);
CU_ASSERT(odp_timer_periodic_capability(clk_src, &capa) == 1);
CU_ASSERT(capa.base_freq_hz.integer == min_fract.integer);
CU_ASSERT(capa.base_freq_hz.numer == min_fract.numer);
CU_ASSERT(capa.base_freq_hz.denom == min_fract.denom);
Expand All @@ -2693,7 +2700,7 @@ static void timer_test_periodic_capa(void)
capa.max_multiplier = 1;
capa.res_ns = 0;

CU_ASSERT(odp_timer_periodic_capability(ODP_CLOCK_DEFAULT, &capa) == 1);
CU_ASSERT(odp_timer_periodic_capability(clk_src, &capa) == 1);
CU_ASSERT(capa.base_freq_hz.integer == max_fract.integer);
CU_ASSERT(capa.base_freq_hz.numer == max_fract.numer);
CU_ASSERT(capa.base_freq_hz.denom == max_fract.denom);
Expand Down Expand Up @@ -2743,7 +2750,7 @@ static void timer_test_periodic_capa(void)
ODPH_DBG("freq %" PRIu64 ", multip %" PRIu64 ", res %" PRIu64 ",\n",
base_freq.integer, max_multiplier, res_ns);

ret = odp_timer_periodic_capability(ODP_CLOCK_DEFAULT, &capa);
ret = odp_timer_periodic_capability(clk_src, &capa);

if (ret == 1) {
CU_ASSERT(capa.base_freq_hz.integer == base_freq.integer);
Expand Down Expand Up @@ -2778,6 +2785,20 @@ static void timer_test_periodic_capa(void)
}
}

static void timer_test_periodic_capa(void)
{
odp_timer_clk_src_t clk_src;
int i;

for (i = 0; i < ODP_CLOCK_NUM_SRC; i++) {
clk_src = ODP_CLOCK_SRC_0 + i;
if (global_mem->periodic_support[i]) {
ODPH_DBG("\nTesting clock source: %i\n", clk_src);
timer_test_periodic_capa_run(clk_src);
}
}
}

static void timer_test_periodic(odp_queue_type_t queue_type, int use_first, int rounds,
int reuse_event)
{
Expand Down