1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2015-2016 Intel Corporation.
6 * @file rte_keepalive.h
7 * DPDK RTE LCore Keepalive Monitor.
14 #include <rte_config.h>
15 #include <rte_memory.h>
17 #ifndef RTE_KEEPALIVE_MAXCORES
19 * Number of cores to track.
20 * @note Must be larger than the highest core id. */
21 #define RTE_KEEPALIVE_MAXCORES RTE_MAX_LCORE
24 enum rte_keepalive_state {
25 RTE_KA_STATE_UNUSED = 0,
26 RTE_KA_STATE_ALIVE = 1,
27 RTE_KA_STATE_MISSING = 4,
28 RTE_KA_STATE_DEAD = 2,
29 RTE_KA_STATE_GONE = 3,
30 RTE_KA_STATE_DOZING = 5,
31 RTE_KA_STATE_SLEEP = 6
35 * Keepalive failure callback.
37 * Receives a data pointer passed to rte_keepalive_create() and the id of the
39 * @param data Data pointer passed to rte_keepalive_create()
40 * @param id_core ID of the core that has failed
42 typedef void (*rte_keepalive_failure_callback_t)(
47 * Keepalive relay callback.
49 * Receives a data pointer passed to rte_keepalive_register_relay_callback(),
50 * the id of the core for which state is to be forwarded, and details of the
52 * @param data Data pointer passed to rte_keepalive_register_relay_callback()
53 * @param id_core ID of the core for which state is being reported
54 * @param core_state The current state of the core
55 * @param last_seen Timestamp of when core was last seen alive
57 typedef void (*rte_keepalive_relay_callback_t)(
60 enum rte_keepalive_state core_state,
65 * Keepalive state structure.
71 * Initialise keepalive sub-system.
73 * Function called upon detection of a dead core.
75 * Data pointer to be passed to function callback.
77 * Keepalive structure success, NULL on failure.
79 struct rte_keepalive *rte_keepalive_create(
80 rte_keepalive_failure_callback_t callback,
84 * Checks & handles keepalive state of monitored cores.
85 * @param *ptr_timer Triggering timer (unused)
86 * @param *ptr_data Data pointer (keepalive structure)
88 void rte_keepalive_dispatch_pings(void *ptr_timer, void *ptr_data);
91 * Registers a core for keepalive checks.
93 * Keepalive structure pointer
95 * ID number of core to register.
97 void rte_keepalive_register_core(struct rte_keepalive *keepcfg,
101 * Per-core keepalive check.
103 * Keepalive structure pointer
105 * This function needs to be called from within the main process loop of
106 * the LCore to be checked.
109 rte_keepalive_mark_alive(struct rte_keepalive *keepcfg);
112 * Per-core sleep-time indication.
114 * Keepalive structure pointer
116 * If CPU idling is enabled, this function needs to be called from within
117 * the main process loop of the LCore going to sleep, in order to avoid
118 * the LCore being mis-detected as dead.
121 rte_keepalive_mark_sleep(struct rte_keepalive *keepcfg);
124 * Registers a 'live core' callback.
126 * The complement of the 'dead core' callback. This is called when a
127 * core is known to be alive, and is intended for cases when an app
128 * needs to know 'liveness' beyond just knowing when a core has died.
131 * Keepalive structure pointer
133 * Function called upon detection of a dead core.
135 * Data pointer to be passed to function callback.
138 rte_keepalive_register_relay_callback(struct rte_keepalive *keepcfg,
139 rte_keepalive_relay_callback_t callback,
142 #endif /* _KEEPALIVE_H_ */