timer callback for basic tests */
| 397 | |
| 398 | /* timer callback for basic tests */ |
| 399 | static void |
| 400 | timer_basic_cb(struct rte_timer *tim, void *arg) |
| 401 | { |
| 402 | struct mytimerinfo *timinfo = arg; |
| 403 | uint64_t hz = rte_get_timer_hz(); |
| 404 | unsigned lcore_id = rte_lcore_id(); |
| 405 | uint64_t cur_time = rte_get_timer_cycles(); |
| 406 | |
| 407 | if (rte_timer_pending(tim)) |
| 408 | return; |
| 409 | |
| 410 | timinfo->count ++; |
| 411 | |
| 412 | RTE_LOG(INFO, TESTTIMER, |
| 413 | "%"PRIu64": callback id=%u count=%u on core %u\n", |
| 414 | cur_time, timinfo->id, timinfo->count, lcore_id); |
| 415 | |
| 416 | /* reload timer 0 on same core */ |
| 417 | if (timinfo->id == 0 && timinfo->count < 20) { |
| 418 | mytimer_reset(timinfo, hz, SINGLE, lcore_id, timer_basic_cb); |
| 419 | return; |
| 420 | } |
| 421 | |
| 422 | /* reload timer 1 on next core */ |
| 423 | if (timinfo->id == 1 && timinfo->count < 10) { |
| 424 | mytimer_reset(timinfo, hz*2, SINGLE, |
| 425 | rte_get_next_lcore(lcore_id, 0, 1), |
| 426 | timer_basic_cb); |
| 427 | return; |
| 428 | } |
| 429 | |
| 430 | /* Explicitly stop timer 0. Once stop() called, we can even |
| 431 | * erase the content of the structure: it is not referenced |
| 432 | * anymore by any code (in case of dynamic structure, it can |
| 433 | * be freed) */ |
| 434 | if (timinfo->id == 0 && timinfo->count == 20) { |
| 435 | |
| 436 | /* stop_sync() is not needed, because we know that the |
| 437 | * status of timer is only modified by this core */ |
| 438 | rte_timer_stop(tim); |
| 439 | memset(tim, 0xAA, sizeof(struct rte_timer)); |
| 440 | return; |
| 441 | } |
| 442 | |
| 443 | /* stop timer3, and restart a new timer0 (it was removed 5 |
| 444 | * seconds ago) for a single shot */ |
| 445 | if (timinfo->id == 2 && timinfo->count == 25) { |
| 446 | rte_timer_stop_sync(&mytiminfo[3].tim); |
| 447 | |
| 448 | /* need to reinit because structure was erased with 0xAA */ |
| 449 | rte_timer_init(&mytiminfo[0].tim); |
| 450 | mytimer_reset(&mytiminfo[0], hz, SINGLE, lcore_id, |
| 451 | timer_basic_cb); |
| 452 | } |
| 453 | } |
| 454 | |
| 455 | static int |
| 456 | timer_basic_main_loop(__rte_unused void *arg) |
nothing calls this directly
no test coverage detected