1 .. SPDX-License-Identifier: BSD-3-Clause
2 Copyright(c) 2015-2016 Intel Corporation.
4 Keep Alive Sample Application
5 =============================
7 The Keep Alive application is a simple example of a
8 heartbeat/watchdog for packet processing cores. It demonstrates how
9 to detect 'failed' DPDK cores and notify a fault management entity
10 of this failure. Its purpose is to ensure the failure of the core
11 does not result in a fault that is not detectable by a management
18 The application demonstrates how to protect against 'silent outages'
19 on packet processing cores. A Keep Alive Monitor Agent Core (main)
20 monitors the state of packet processing cores (worker cores) by
21 dispatching pings at a regular time interval (default is 5ms) and
22 monitoring the state of the cores. Cores states are: Alive, MIA, Dead
23 or Buried. MIA indicates a missed ping, and Dead indicates two missed
24 pings within the specified time interval. When a core is Dead, a
25 callback function is invoked to restart the packet processing core;
26 A real life application might use this callback function to notify a
27 higher level fault management entity of the core failure in order to
28 take the appropriate corrective action.
30 Note: Only the worker cores are monitored. A local (on the host) mechanism
31 or agent to supervise the Keep Alive Monitor Agent Core DPDK core is required
32 to detect its failure.
34 Note: This application is based on the :doc:`l2_forward_real_virtual`. As
35 such, the initialization and run-time paths are very similar to those
36 of the L2 forwarding application.
38 Compiling the Application
39 -------------------------
41 To compile the sample application see :doc:`compiling`.
43 The application is located in the ``l2fwd_keep_alive`` sub-directory.
45 Running the Application
46 -----------------------
48 The application has a number of command line options:
50 .. code-block:: console
52 ./<build_dir>/examples/dpdk-l2fwd-keepalive [EAL options] \
53 -- -p PORTMASK [-q NQ] [-K PERIOD] [-T PERIOD]
57 * ``p PORTMASK``: A hexadecimal bitmask of the ports to configure
59 * ``q NQ``: A number of queues (=ports) per lcore (default is 1)
61 * ``K PERIOD``: Heartbeat check period in ms(5ms default; 86400 max)
63 * ``T PERIOD``: statistics will be refreshed each PERIOD seconds (0 to
64 disable, 10 default, 86400 maximum).
66 To run the application in linux environment with 4 lcores, 16 ports
67 8 RX queues per lcore and a ping interval of 10ms, issue the command:
69 .. code-block:: console
71 ./<build_dir>/examples/dpdk-l2fwd-keepalive -l 0-3 -n 4 -- -q 8 -p ffff -K 10
73 Refer to the *DPDK Getting Started Guide* for general information on
74 running applications and the Environment Abstraction Layer (EAL)
81 The following sections provide some explanation of the The
82 Keep-Alive/'Liveliness' conceptual scheme. As mentioned in the
83 overview section, the initialization and run-time paths are very
84 similar to those of the :doc:`l2_forward_real_virtual`.
86 The Keep-Alive/'Liveliness' conceptual scheme:
88 * A Keep- Alive Agent Runs every N Milliseconds.
90 * DPDK Cores respond to the keep-alive agent.
92 * If keep-alive agent detects time-outs, it notifies the
93 fault management entity through a callback function.
95 The following sections provide some explanation of the code aspects
96 that are specific to the Keep Alive sample application.
98 The keepalive functionality is initialized with a struct
99 rte_keepalive and the callback function to invoke in the
104 rte_global_keepalive_info = rte_keepalive_create(&dead_core, NULL);
105 if (rte_global_keepalive_info == NULL)
106 rte_exit(EXIT_FAILURE, "keepalive_create() failed");
108 The function that issues the pings keepalive_dispatch_pings()
109 is configured to run every check_period milliseconds.
113 if (rte_timer_reset(&hb_timer,
114 (check_period * rte_get_timer_hz()) / 1000,
117 &rte_keepalive_dispatch_pings,
118 rte_global_keepalive_info
120 rte_exit(EXIT_FAILURE, "Keepalive setup failure.\n");
122 The rest of the initialization and run-time path follows
123 the same paths as the L2 forwarding application. The only
124 addition to the main processing loop is the mark alive
125 functionality and the example random failures.
129 rte_keepalive_mark_alive(&rte_global_keepalive_info);
130 cur_tsc = rte_rdtsc();
132 /* Die randomly within 7 secs for demo purposes.. */
133 if (cur_tsc - tsc_initial > tsc_lifetime)
136 The rte_keepalive_mark_alive function simply sets the core state to alive.
141 rte_keepalive_mark_alive(struct rte_keepalive *keepcfg)
143 keepcfg->live_data[rte_lcore_id()].core_state = RTE_KA_STATE_ALIVE;