hv: timer: add periodic timer setup support

and add MIN_TIMER_PERIOD_US for limit periodic timer frequency.
Now it's set to 500 us.

Signed-off-by: Li, Fei1 <fei1.li@intel.com>
This commit is contained in:
Li, Fei1
2018-04-25 15:14:44 +08:00
committed by Jack Ren
parent 9bfa574a27
commit ac253f8c60
4 changed files with 27 additions and 10 deletions

View File

@@ -33,9 +33,17 @@
typedef int (*timer_handle_t)(void *);
enum tick_mode {
TICK_MODE_ONESHOT = 0,
TICK_MODE_PERIODIC,
};
struct timer {
struct list_head node; /* link all timers */
int mode; /* timer mode: one-shot or periodic */
uint64_t fire_tsc; /* tsc deadline to interrupt */
uint64_t period_in_cycle; /* period of the periodic timer in unit of TSC cycles */
timer_handle_t func; /* callback if time reached */
void *priv_data; /* func private data */
};
@@ -43,12 +51,16 @@ struct timer {
static inline void initialize_timer(struct timer *timer,
timer_handle_t func,
void *priv_data,
uint64_t fire_tsc)
uint64_t fire_tsc,
int mode,
uint64_t period_in_cycle)
{
if (timer) {
timer->func = func;
timer->priv_data = priv_data;
timer->fire_tsc = fire_tsc;
timer->mode = mode;
timer->period_in_cycle = period_in_cycle;
}
}