]> git.proxmox.com Git - ceph.git/blame - ceph/src/seastar/dpdk/examples/l2fwd-keepalive/shm.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / seastar / dpdk / examples / l2fwd-keepalive / shm.h
CommitLineData
9f95a23c
TL
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2016 Intel Corporation
7c673cae
FG
3 */
4
5#define RTE_KEEPALIVE_SHM_NAME "/dpdk_keepalive_shm_name"
6
7#define RTE_KEEPALIVE_SHM_ALIVE 1
8#define RTE_KEEPALIVE_SHM_DEAD 2
9
10#include <fcntl.h>
11#include <string.h>
12#include <unistd.h>
13#include <sys/mman.h>
14#include <sys/stat.h>
15#include <semaphore.h>
16#include <rte_keepalive.h>
17
18/**
19 * Keepalive SHM structure.
20 *
21 * The shared memory allocated by the primary is this size, and contains the
22 * information as contained within this struct. A secondary may open the SHM,
23 * and read the contents.
24 */
25struct rte_keepalive_shm {
26 /** IPC semaphore. Posted when a core dies */
27 sem_t core_died;
28
29 /**
30 * Relayed status of each core.
31 */
32 enum rte_keepalive_state core_state[RTE_KEEPALIVE_MAXCORES];
33
34 /**
35 * Last-seen-alive timestamps for the cores
36 */
37 uint64_t core_last_seen_times[RTE_KEEPALIVE_MAXCORES];
38};
39
40/**
41 * Create shared host memory keepalive object.
42 * @return
43 * Pointer to SHM keepalive structure, or NULL on failure.
44 */
45struct rte_keepalive_shm *rte_keepalive_shm_create(void);
46
47/**
48 * Relays state for given core
49 * @param *shm
50 * Pointer to SHM keepalive structure.
51 * @param id_core
52 * Id of core
53 * @param core_state
54 * State of core
55 * @param last_alive
56 * Last seen timestamp for core
57 */
58void rte_keepalive_relayed_state(struct rte_keepalive_shm *shm,
59 const int id_core, const enum rte_keepalive_state core_state,
60 uint64_t last_alive);
11fdf7f2
TL
61
62/** Shutdown cleanup of shared host memory keepalive object.
63 * @param *shm
64 * Pointer to SHM keepalive structure. May be NULL.
65 *
66 * If *shm is NULL, this function will only attempt to remove the
67 * shared host memory handle and not unmap the underlying memory.
68 */
69void rte_keepalive_shm_cleanup(struct rte_keepalive_shm *ka_shm);