15630257fSFerruh Yigit.. SPDX-License-Identifier: BSD-3-Clause 25630257fSFerruh Yigit Copyright(c) 2015-2016 Intel Corporation. 3e64833f2SRemy Horton 4e64833f2SRemy HortonKeep Alive Sample Application 5e64833f2SRemy Horton============================= 6e64833f2SRemy Horton 7e64833f2SRemy HortonThe Keep Alive application is a simple example of a 8e64833f2SRemy Hortonheartbeat/watchdog for packet processing cores. It demonstrates how 9e64833f2SRemy Hortonto detect 'failed' DPDK cores and notify a fault management entity 10e64833f2SRemy Hortonof this failure. Its purpose is to ensure the failure of the core 11e64833f2SRemy Hortondoes not result in a fault that is not detectable by a management 12e64833f2SRemy Hortonentity. 13e64833f2SRemy Horton 14e64833f2SRemy Horton 15e64833f2SRemy HortonOverview 16e64833f2SRemy Horton-------- 17e64833f2SRemy Horton 18e64833f2SRemy HortonThe application demonstrates how to protect against 'silent outages' 19cb056611SStephen Hemmingeron packet processing cores. A Keep Alive Monitor Agent Core (main) 20e64833f2SRemy Hortonmonitors the state of packet processing cores (worker cores) by 21e64833f2SRemy Hortondispatching pings at a regular time interval (default is 5ms) and 22e64833f2SRemy Hortonmonitoring the state of the cores. Cores states are: Alive, MIA, Dead 23e64833f2SRemy Hortonor Buried. MIA indicates a missed ping, and Dead indicates two missed 24e64833f2SRemy Hortonpings within the specified time interval. When a core is Dead, a 25e64833f2SRemy Hortoncallback function is invoked to restart the packet processing core; 26e64833f2SRemy HortonA real life application might use this callback function to notify a 27e64833f2SRemy Hortonhigher level fault management entity of the core failure in order to 28e64833f2SRemy Hortontake the appropriate corrective action. 29e64833f2SRemy Horton 30e64833f2SRemy HortonNote: Only the worker cores are monitored. A local (on the host) mechanism 31e64833f2SRemy Hortonor agent to supervise the Keep Alive Monitor Agent Core DPDK core is required 32e64833f2SRemy Hortonto detect its failure. 33e64833f2SRemy Horton 34513b0723SMauricio Vasquez BNote: This application is based on the :doc:`l2_forward_real_virtual`. As 35e64833f2SRemy Hortonsuch, the initialization and run-time paths are very similar to those 36e64833f2SRemy Hortonof the L2 forwarding application. 37e64833f2SRemy Horton 38e64833f2SRemy HortonCompiling the Application 39e64833f2SRemy Horton------------------------- 40e64833f2SRemy Horton 41*8750576fSNandini PersadTo compile the sample application, see :doc:`compiling`. 42e64833f2SRemy Horton 437cacb056SHerakliusz LipiecThe application is located in the ``l2fwd_keep_alive`` sub-directory. 44e64833f2SRemy Horton 45e64833f2SRemy HortonRunning the Application 46e64833f2SRemy Horton----------------------- 47e64833f2SRemy Horton 48e64833f2SRemy HortonThe application has a number of command line options: 49e64833f2SRemy Horton 50e64833f2SRemy Horton.. code-block:: console 51e64833f2SRemy Horton 52e2a94f9aSCiara Power ./<build_dir>/examples/dpdk-l2fwd-keepalive [EAL options] \ 53e64833f2SRemy Horton -- -p PORTMASK [-q NQ] [-K PERIOD] [-T PERIOD] 54e64833f2SRemy Horton 55e64833f2SRemy Hortonwhere, 56e64833f2SRemy Horton 57e64833f2SRemy Horton* ``p PORTMASK``: A hexadecimal bitmask of the ports to configure 58e64833f2SRemy Horton 59885807aeSStephen Hemminger* ``q NQ``: Maximum number of queues per lcore (default is 1) 60e64833f2SRemy Horton 61e64833f2SRemy Horton* ``K PERIOD``: Heartbeat check period in ms(5ms default; 86400 max) 62e64833f2SRemy Horton 63e64833f2SRemy Horton* ``T PERIOD``: statistics will be refreshed each PERIOD seconds (0 to 64e64833f2SRemy Horton disable, 10 default, 86400 maximum). 65e64833f2SRemy Horton 66218c4e68SBruce RichardsonTo run the application in linux environment with 4 lcores, 16 ports 67e64833f2SRemy Horton8 RX queues per lcore and a ping interval of 10ms, issue the command: 68e64833f2SRemy Horton 69e64833f2SRemy Horton.. code-block:: console 70e64833f2SRemy Horton 71e2a94f9aSCiara Power ./<build_dir>/examples/dpdk-l2fwd-keepalive -l 0-3 -n 4 -- -q 8 -p ffff -K 10 72e64833f2SRemy Horton 73e64833f2SRemy HortonRefer to the *DPDK Getting Started Guide* for general information on 74e64833f2SRemy Hortonrunning applications and the Environment Abstraction Layer (EAL) 75e64833f2SRemy Hortonoptions. 76e64833f2SRemy Horton 77e64833f2SRemy Horton 78e64833f2SRemy HortonExplanation 79e64833f2SRemy Horton----------- 80e64833f2SRemy Horton 81*8750576fSNandini PersadThe following sections provide explanation of the 82e64833f2SRemy HortonKeep-Alive/'Liveliness' conceptual scheme. As mentioned in the 83e64833f2SRemy Hortonoverview section, the initialization and run-time paths are very 84513b0723SMauricio Vasquez Bsimilar to those of the :doc:`l2_forward_real_virtual`. 85e64833f2SRemy Horton 86e64833f2SRemy HortonThe Keep-Alive/'Liveliness' conceptual scheme: 87e64833f2SRemy Horton 88e64833f2SRemy Horton* A Keep- Alive Agent Runs every N Milliseconds. 89e64833f2SRemy Horton 90e64833f2SRemy Horton* DPDK Cores respond to the keep-alive agent. 91e64833f2SRemy Horton 92*8750576fSNandini Persad* If a keep-alive agent detects time-outs, it notifies the 93e64833f2SRemy Horton fault management entity through a callback function. 94e64833f2SRemy Horton 95*8750576fSNandini PersadThe following sections provide explanation of the code aspects 96e64833f2SRemy Hortonthat are specific to the Keep Alive sample application. 97e64833f2SRemy Horton 9813f3f4f1SHarry van HaarenThe keepalive functionality is initialized with a struct 9913f3f4f1SHarry van Haarenrte_keepalive and the callback function to invoke in the 100e64833f2SRemy Hortoncase of a timeout. 101e64833f2SRemy Horton 1029a212dc0SConor Fogarty.. literalinclude:: ../../../examples/l2fwd-keepalive/main.c 1039a212dc0SConor Fogarty :language: c 1049a212dc0SConor Fogarty :start-after: Initialize keepalive functionality. 8< 1059a212dc0SConor Fogarty :end-before: >8 End of initializing keepalive functionality. 1069a212dc0SConor Fogarty :dedent: 2 107e64833f2SRemy Horton 10813f3f4f1SHarry van HaarenThe function that issues the pings keepalive_dispatch_pings() 109e64833f2SRemy Hortonis configured to run every check_period milliseconds. 110e64833f2SRemy Horton 1119a212dc0SConor Fogarty.. literalinclude:: ../../../examples/l2fwd-keepalive/main.c 1129a212dc0SConor Fogarty :language: c 1139a212dc0SConor Fogarty :start-after: Issues the pings keepalive_dispatch_pings(). 8< 1149a212dc0SConor Fogarty :end-before: >8 End of issuing the pings keepalive_dispatch_pings(). 1159a212dc0SConor Fogarty :dedent: 2 116e64833f2SRemy Horton 117*8750576fSNandini PersadThe rest of the initialization and run-time paths follow 1188f87ba70SThierry Herbelotthe same paths as the L2 forwarding application. The only 119e64833f2SRemy Hortonaddition to the main processing loop is the mark alive 120e64833f2SRemy Hortonfunctionality and the example random failures. 121e64833f2SRemy Horton 1229a212dc0SConor Fogarty.. literalinclude:: ../../../examples/l2fwd-keepalive/main.c 1239a212dc0SConor Fogarty :language: c 1249a212dc0SConor Fogarty :start-after: Keepalive heartbeat. 8< 1259a212dc0SConor Fogarty :end-before: >8 End of keepalive heartbeat. 1269a212dc0SConor Fogarty :dedent: 2 127e64833f2SRemy Horton 128e64833f2SRemy HortonThe rte_keepalive_mark_alive function simply sets the core state to alive. 129e64833f2SRemy Horton 130e64833f2SRemy Horton.. code-block:: c 131e64833f2SRemy Horton 132e64833f2SRemy Horton static inline void 13313f3f4f1SHarry van Haaren rte_keepalive_mark_alive(struct rte_keepalive *keepcfg) 134e64833f2SRemy Horton { 135462d9189SAndriy Berestovskyy keepcfg->live_data[rte_lcore_id()].core_state = RTE_KA_STATE_ALIVE; 136e64833f2SRemy Horton } 137