1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2015-2016 Intel Corporation.
6 * @file rte_keepalive.h
7 * DPDK RTE LCore Keepalive Monitor.
18 #include <rte_config.h>
19 #include <rte_memory.h>
21 #ifndef RTE_KEEPALIVE_MAXCORES
23 * Number of cores to track.
24 * @note Must be larger than the highest core id. */
25 #define RTE_KEEPALIVE_MAXCORES RTE_MAX_LCORE
28 enum rte_keepalive_state {
29 RTE_KA_STATE_UNUSED = 0,
30 RTE_KA_STATE_ALIVE = 1,
31 RTE_KA_STATE_MISSING = 4,
32 RTE_KA_STATE_DEAD = 2,
33 RTE_KA_STATE_GONE = 3,
34 RTE_KA_STATE_DOZING = 5,
35 RTE_KA_STATE_SLEEP = 6
39 * Keepalive failure callback.
41 * Receives a data pointer passed to rte_keepalive_create() and the id of the
43 * @param data Data pointer passed to rte_keepalive_create()
44 * @param id_core ID of the core that has failed
46 typedef void (*rte_keepalive_failure_callback_t)(
51 * Keepalive relay callback.
53 * Receives a data pointer passed to rte_keepalive_register_relay_callback(),
54 * the id of the core for which state is to be forwarded, and details of the
56 * @param data Data pointer passed to rte_keepalive_register_relay_callback()
57 * @param id_core ID of the core for which state is being reported
58 * @param core_state The current state of the core
59 * @param last_seen Timestamp of when core was last seen alive
61 typedef void (*rte_keepalive_relay_callback_t)(
64 enum rte_keepalive_state core_state,
69 * Keepalive state structure.
75 * Initialise keepalive sub-system.
77 * Function called upon detection of a dead core.
79 * Data pointer to be passed to function callback.
81 * Keepalive structure success, NULL on failure.
83 struct rte_keepalive *rte_keepalive_create(
84 rte_keepalive_failure_callback_t callback,
88 * Checks & handles keepalive state of monitored cores.
89 * @param *ptr_timer Triggering timer (unused)
90 * @param *ptr_data Data pointer (keepalive structure)
92 void rte_keepalive_dispatch_pings(void *ptr_timer, void *ptr_data);
95 * Registers a core for keepalive checks.
97 * Keepalive structure pointer
99 * ID number of core to register.
101 void rte_keepalive_register_core(struct rte_keepalive *keepcfg,
105 * Per-core keepalive check.
107 * Keepalive structure pointer
109 * This function needs to be called from within the main process loop of
110 * the LCore to be checked.
113 rte_keepalive_mark_alive(struct rte_keepalive *keepcfg);
116 * Per-core sleep-time indication.
118 * Keepalive structure pointer
120 * If CPU idling is enabled, this function needs to be called from within
121 * the main process loop of the LCore going to sleep, in order to avoid
122 * the LCore being mis-detected as dead.
125 rte_keepalive_mark_sleep(struct rte_keepalive *keepcfg);
128 * Registers a 'live core' callback.
130 * The complement of the 'dead core' callback. This is called when a
131 * core is known to be alive, and is intended for cases when an app
132 * needs to know 'liveness' beyond just knowing when a core has died.
135 * Keepalive structure pointer
137 * Function called upon detection of a dead core.
139 * Data pointer to be passed to function callback.
142 rte_keepalive_register_relay_callback(struct rte_keepalive *keepcfg,
143 rte_keepalive_relay_callback_t callback,
150 #endif /* _KEEPALIVE_H_ */