MCPcopy Create free account
hub / github.com/F-Stack/f-stack / timer_basic_cb

Function timer_basic_cb

dpdk/app/test/test_timer.c:399–453  ·  view source on GitHub ↗

timer callback for basic tests */

Source from the content-addressed store, hash-verified

397
398/* timer callback for basic tests */
399static void
400timer_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
455static int
456timer_basic_main_loop(__rte_unused void *arg)

Callers

nothing calls this directly

Calls 8

rte_lcore_idFunction · 0.85
rte_timer_pendingFunction · 0.85
mytimer_resetFunction · 0.85
rte_get_next_lcoreFunction · 0.85
rte_timer_stopFunction · 0.85
memsetFunction · 0.85
rte_timer_stop_syncFunction · 0.85
rte_timer_initFunction · 0.85

Tested by

no test coverage detected