124cd1b52SCiara Power.. SPDX-License-Identifier: BSD-3-Clause 224cd1b52SCiara Power Copyright(c) 2020 Intel Corporation. 324cd1b52SCiara Power 424cd1b52SCiara PowerTelemetry Library 524cd1b52SCiara Power================= 624cd1b52SCiara Power 724cd1b52SCiara PowerThe Telemetry library provides an interface to retrieve information from a 824cd1b52SCiara Powervariety of DPDK libraries. The library provides this information via socket 924cd1b52SCiara Powerconnection, taking requests from a connected client and replying with the JSON 1024cd1b52SCiara Powerresponse containing the requested telemetry information. 1124cd1b52SCiara Power 1224cd1b52SCiara PowerTelemetry is enabled to run by default when running a DPDK application, and the 1324cd1b52SCiara Powertelemetry information from enabled libraries is made available. Libraries are 1424cd1b52SCiara Powerresponsible for registering their own commands, and providing the callback 1524cd1b52SCiara Powerfunction that will format the library specific stats into the correct data 1624cd1b52SCiara Powerformat, when requested. 1724cd1b52SCiara Power 1824cd1b52SCiara Power 1924cd1b52SCiara PowerRegistering Commands 2024cd1b52SCiara Power-------------------- 2124cd1b52SCiara Power 2224cd1b52SCiara PowerLibraries and applications must register commands to make their information 2324cd1b52SCiara Poweravailable via the Telemetry library. This involves providing a string command 24*1474a341SCiara Powerin the required format ("/library/command"), the callback function that 25*1474a341SCiara Powerwill handle formatting the information when required, and help text for the 26*1474a341SCiara Powercommand. An example showing ethdev commands being registered is shown below: 2724cd1b52SCiara Power 2824cd1b52SCiara Power.. code-block:: c 2924cd1b52SCiara Power 30*1474a341SCiara Power rte_telemetry_register_cmd("/ethdev/list", handle_port_list, 31*1474a341SCiara Power "Returns list of available ethdev ports. Takes no parameters"); 32*1474a341SCiara Power rte_telemetry_register_cmd("/ethdev/xstats", handle_port_xstats, 33*1474a341SCiara Power "Returns the extended stats for a port. Parameters: int port_id"); 34*1474a341SCiara Power rte_telemetry_register_cmd("/ethdev/link_status", handle_port_link_status, 35*1474a341SCiara Power "Returns the link status for a port. Parameters: int port_id"); 3624cd1b52SCiara Power 3724cd1b52SCiara Power 3824cd1b52SCiara PowerFormatting JSON response 3924cd1b52SCiara Power------------------------ 4024cd1b52SCiara Power 4124cd1b52SCiara PowerThe callback function provided by the library must format its telemetry 4224cd1b52SCiara Powerinformation in the required data format. The Telemetry library provides a data 4324cd1b52SCiara Powerutilities API to build up the response. For example, the ethdev library provides a 4424cd1b52SCiara Powerlist of available ethdev ports in a formatted data response, constructed using the 4524cd1b52SCiara Powerfollowing functions to build up the list: 4624cd1b52SCiara Power 4724cd1b52SCiara Power.. code-block:: c 4824cd1b52SCiara Power 4924cd1b52SCiara Power rte_tel_data_start_array(d, RTE_TEL_INT_VAL); 5024cd1b52SCiara Power RTE_ETH_FOREACH_DEV(port_id) 5124cd1b52SCiara Power rte_tel_data_add_array_int(d, port_id); 5224cd1b52SCiara Power 5324cd1b52SCiara PowerThe data structure is then formatted into a JSON response before sending. 5424cd1b52SCiara PowerThe resulting response shows the port list data provided above by the handler 5524cd1b52SCiara Powerfunction in ethdev, placed in a JSON reply by telemetry: 5624cd1b52SCiara Power 5724cd1b52SCiara Power.. code-block:: console 5824cd1b52SCiara Power 5924cd1b52SCiara Power {"/ethdev/list": [0, 1]} 6024cd1b52SCiara Power 6124cd1b52SCiara PowerFor more information on the range of data functions available in the API, 6224cd1b52SCiara Powerplease refer to the docs. 63