keepalive: export states

Changes the keepalive state from an anonymous enum to a declared one
which is externally visible, so that keepalive enum values can be
used by applications.

Signed-off-by: Remy Horton <remy.horton@intel.com>
This commit is contained in:
Remy Horton 2016-06-15 16:25:49 +01:00 committed by Thomas Monjalon
parent e2aae1c1ce
commit e70a61ad50
2 changed files with 30 additions and 16 deletions

View File

@ -1,7 +1,7 @@
/*- /*-
* BSD LICENSE * BSD LICENSE
* *
* Copyright 2015 Intel Shannon Ltd. All rights reserved. * Copyright 2015-2016 Intel Shannon Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -48,6 +48,16 @@
#define RTE_KEEPALIVE_MAXCORES RTE_MAX_LCORE #define RTE_KEEPALIVE_MAXCORES RTE_MAX_LCORE
#endif #endif
enum rte_keepalive_state {
RTE_KA_STATE_UNUSED = 0,
RTE_KA_STATE_ALIVE = 1,
RTE_KA_STATE_MISSING = 4,
RTE_KA_STATE_DEAD = 2,
RTE_KA_STATE_GONE = 3,
RTE_KA_STATE_DOZING = 5,
RTE_KA_STATE_SLEEP = 6
};
/** /**
* Keepalive failure callback. * Keepalive failure callback.
* *

View File

@ -42,12 +42,8 @@
struct rte_keepalive { struct rte_keepalive {
/** Core Liveness. */ /** Core Liveness. */
enum rte_keepalive_state { enum rte_keepalive_state __rte_cache_aligned state_flags[
ALIVE = 1, RTE_KEEPALIVE_MAXCORES];
MISSING = 0,
DEAD = 2,
GONE = 3
} __rte_cache_aligned state_flags[RTE_KEEPALIVE_MAXCORES];
/** Last-seen-alive timestamps */ /** Last-seen-alive timestamps */
uint64_t last_alive[RTE_KEEPALIVE_MAXCORES]; uint64_t last_alive[RTE_KEEPALIVE_MAXCORES];
@ -92,16 +88,18 @@ rte_keepalive_dispatch_pings(__rte_unused void *ptr_timer,
continue; continue;
switch (keepcfg->state_flags[idx_core]) { switch (keepcfg->state_flags[idx_core]) {
case ALIVE: /* Alive */ case RTE_KA_STATE_UNUSED:
keepcfg->state_flags[idx_core] = MISSING; break;
case RTE_KA_STATE_ALIVE: /* Alive */
keepcfg->state_flags[idx_core] = RTE_KA_STATE_MISSING;
keepcfg->last_alive[idx_core] = rte_rdtsc(); keepcfg->last_alive[idx_core] = rte_rdtsc();
break; break;
case MISSING: /* MIA */ case RTE_KA_STATE_MISSING: /* MIA */
print_trace("Core MIA. ", keepcfg, idx_core); print_trace("Core MIA. ", keepcfg, idx_core);
keepcfg->state_flags[idx_core] = DEAD; keepcfg->state_flags[idx_core] = RTE_KA_STATE_DEAD;
break; break;
case DEAD: /* Dead */ case RTE_KA_STATE_DEAD: /* Dead */
keepcfg->state_flags[idx_core] = GONE; keepcfg->state_flags[idx_core] = RTE_KA_STATE_GONE;
print_trace("Core died. ", keepcfg, idx_core); print_trace("Core died. ", keepcfg, idx_core);
if (keepcfg->callback) if (keepcfg->callback)
keepcfg->callback( keepcfg->callback(
@ -109,7 +107,13 @@ rte_keepalive_dispatch_pings(__rte_unused void *ptr_timer,
idx_core idx_core
); );
break; break;
case GONE: /* Buried */ case RTE_KA_STATE_GONE: /* Buried */
break;
case RTE_KA_STATE_DOZING: /* Core going idle */
keepcfg->state_flags[idx_core] = RTE_KA_STATE_SLEEP;
keepcfg->last_alive[idx_core] = rte_rdtsc();
break;
case RTE_KA_STATE_SLEEP: /* Idled core */
break; break;
} }
} }
@ -137,7 +141,7 @@ void
rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core) rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core)
{ {
if (id_core < RTE_KEEPALIVE_MAXCORES) { if (id_core < RTE_KEEPALIVE_MAXCORES) {
keepcfg->active_cores[id_core] = 1; keepcfg->active_cores[id_core] = RTE_KA_STATE_ALIVE;
keepcfg->last_alive[id_core] = rte_rdtsc(); keepcfg->last_alive[id_core] = rte_rdtsc();
} }
} }
@ -145,5 +149,5 @@ rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core)
void void
rte_keepalive_mark_alive(struct rte_keepalive *keepcfg) rte_keepalive_mark_alive(struct rte_keepalive *keepcfg)
{ {
keepcfg->state_flags[rte_lcore_id()] = ALIVE; keepcfg->state_flags[rte_lcore_id()] = RTE_KA_STATE_ALIVE;
} }