:orphan: .. index:: pair: group; rxq_stats BPF program .. _doxid-group__tapi__bpf__rxq__stats: rxq_stats BPF program ===================== .. toctree:: :hidden: enum_tapi_bpf_rxq_stats_attach_mode.rst struct_tapi_bpf_rxq_stats.rst Overview ~~~~~~~~ Definition of API to control rxq_stats BPF program. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block // typedefs typedef struct :ref:`tapi_bpf_rxq_stats` :ref:`tapi_bpf_rxq_stats`; typedef enum :ref:`tapi_bpf_rxq_stats_attach_mode` :ref:`tapi_bpf_rxq_stats_attach_mode`; // enums enum :ref:`tapi_bpf_rxq_stats_attach_mode`; // structs struct :ref:`tapi_bpf_rxq_stats`; // global functions :ref:`te_errno` :ref:`tapi_bpf_rxq_stats_init`(const char* ta, const char* if_name, const char* prog_dir, unsigned int* bpf_id); :ref:`te_errno` :ref:`tapi_bpf_rxq_stats_init_mode`(const char* ta, const char* if_name, const char* prog_dir, :ref:`tapi_bpf_rxq_stats_attach_mode` attach_mode, unsigned int* bpf_id); :ref:`te_errno` :ref:`tapi_bpf_rxq_stats_fini`(const char* ta, const char* if_name, unsigned int bpf_id); :ref:`te_errno` :ref:`tapi_bpf_rxq_stats_get_id`(const char* ta, const char* if_name, unsigned int* bpf_id); :ref:`te_errno` :ref:`tapi_bpf_rxq_stats_set_params`(const char* ta, unsigned int bpf_id, int addr_family, const struct sockaddr* src_addr, const struct sockaddr* dst_addr, int protocol, bool enable); :ref:`te_errno` :ref:`tapi_bpf_rxq_stats_enable`(const char* ta, unsigned int bpf_id, bool enable); :ref:`te_errno` :ref:`tapi_bpf_rxq_stats_clear`(const char* ta, unsigned int bpf_id); :ref:`te_errno` :target:`tapi_bpf_rxq_stats_reset`(const char* ta, unsigned int bpf_id); :ref:`te_errno` :ref:`tapi_bpf_rxq_stats_read`(const char* ta, unsigned int bpf_id, :ref:`tapi_bpf_rxq_stats`** stats_out, unsigned int* count_out); void :ref:`tapi_bpf_rxq_stats_print`(const char* title, :ref:`tapi_bpf_rxq_stats`* stats, unsigned int count); :ref:`te_errno` :ref:`tapi_bpf_rxq_stats_check_single`(const char* ta, unsigned int bpf_id, unsigned int exp_queue, unsigned int exp_pkts, :ref:`rpc_socket_type` sock_type, const char* vpref); // macros #define :ref:`TAPI_BPF_RXQ_STATS_XSK_MAP` .. _details-group__tapi__bpf__rxq__stats: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Definition of API to control rxq_stats BPF program. Copyright (C) 2022-2022 OKTET Labs Ltd. All rights reserved. Typedefs -------- .. index:: pair: typedef; tapi_bpf_rxq_stats .. _doxid-group__tapi__bpf__rxq__stats_1gaf007138ff3ea1e397d6b6ebc9e510cb9: .. ref-code-block:: cpp :class: doxyrest-title-code-block typedef struct :ref:`tapi_bpf_rxq_stats` tapi_bpf_rxq_stats Per-queue received packets count .. index:: pair: typedef; tapi_bpf_rxq_stats_attach_mode .. _doxid-group__tapi__bpf__rxq__stats_1gaca90f1705c1f0764d48cc2bb7ef972cf: .. ref-code-block:: cpp :class: doxyrest-title-code-block typedef enum :ref:`tapi_bpf_rxq_stats_attach_mode` tapi_bpf_rxq_stats_attach_mode Modes to attach "rxq_stats" BPF program to XDP hook. Global Functions ---------------- .. index:: pair: function; tapi_bpf_rxq_stats_init .. _doxid-group__tapi__bpf__rxq__stats_1ga99f181a4c825e049e90bea5ca5c1b954: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_bpf_rxq_stats_init(const char* ta, const char* if_name, const char* prog_dir, unsigned int* bpf_id) Initialize "rxq_stats" BPF object, link it to an interface. This helper keeps backward-compatible default behavior (regular XDP attach mode). .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - ta - Test Agent * - if_name - Interface name * - prog_dir - Where rxq_stats object file is located (may be a path relative to TA directory) * - bpf_id - Where to save BPF object ID (may be ``NULL``) .. rubric:: Returns: Status code. .. index:: pair: function; tapi_bpf_rxq_stats_init_mode .. _doxid-group__tapi__bpf__rxq__stats_1gaf107e96dad53c3c0969ec519d58fc309: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_bpf_rxq_stats_init_mode(const char* ta, const char* if_name, const char* prog_dir, :ref:`tapi_bpf_rxq_stats_attach_mode` attach_mode, unsigned int* bpf_id) Initialize "rxq_stats" BPF object, link it to an interface with explicit attach mode selection. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - ta - Test Agent. * - if_name - Interface name. * - prog_dir - Where rxq_stats object file is located (may be a path relative to TA directory). * - attach_mode - XDP attach mode. * - bpf_id - Where to save BPF object ID (may be ``NULL``). .. rubric:: Returns: Status code. .. index:: pair: function; tapi_bpf_rxq_stats_fini .. _doxid-group__tapi__bpf__rxq__stats_1gafd893bc6ba0bc609b787a4378e090ce0: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_bpf_rxq_stats_fini(const char* ta, const char* if_name, unsigned int bpf_id) Unlink "rxq_stats" program from interface, destroy BPF object. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - ta - Test Agent * - if_name - Interface name * - bpf_id - BPF object ID .. rubric:: Returns: Status code. .. index:: pair: function; tapi_bpf_rxq_stats_get_id .. _doxid-group__tapi__bpf__rxq__stats_1ga93f05422c03eccca3ba92225b7ceb4bb: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_bpf_rxq_stats_get_id(const char* ta, const char* if_name, unsigned int* bpf_id) Get ID of BPF object of "rxq_stats" program linked to a given interface. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - ta - Test Agent * - if_name - Interface name * - bpf_id - Where to save BPF object ID .. rubric:: Returns: Status code. .. index:: pair: function; tapi_bpf_rxq_stats_set_params .. _doxid-group__tapi__bpf__rxq__stats_1ga9ccd8ddef48aad99de67c171129e64d6: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_bpf_rxq_stats_set_params(const char* ta, unsigned int bpf_id, int addr_family, const struct sockaddr* src_addr, const struct sockaddr* dst_addr, int protocol, bool enable) Set parameters for "rxq_stats" program. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - ta - Test Agent name * - bpf_id - BPF object ID * - addr_family - ``AF_INET`` or ``AF_INET6`` * - src_addr - Source address/port * - dst_addr - Destination address/port * - protocol - IP protocol (``IPPROTO_UDP``, ``IPPROTO_TCP``) * - enable - Whether counting of packets should be enabled now .. rubric:: Returns: Status code. .. index:: pair: function; tapi_bpf_rxq_stats_enable .. _doxid-group__tapi__bpf__rxq__stats_1gaca79cf21503fdc2b658c6e4af3c34d51: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_bpf_rxq_stats_enable(const char* ta, unsigned int bpf_id, bool enable) Enable or disable packets counting in "rxq_stats" program. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - ta - Test Agent name * - bpf_id - BPF object ID * - enable - Whether counting of packets should be enabled now .. rubric:: Returns: Status code. .. index:: pair: function; tapi_bpf_rxq_stats_clear .. _doxid-group__tapi__bpf__rxq__stats_1ga4d27b22e4f797dddb3081157c3a3b10c: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_bpf_rxq_stats_clear(const char* ta, unsigned int bpf_id) Clear statistics collected by "rxq_stats" program. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - ta - Test Agent name * - bpf_id - BPF object ID .. rubric:: Returns: Status code. .. index:: pair: function; tapi_bpf_rxq_stats_read .. _doxid-group__tapi__bpf__rxq__stats_1gaba38f2bda13fea063dc9a28927352aa1: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_bpf_rxq_stats_read(const char* ta, unsigned int bpf_id, :ref:`tapi_bpf_rxq_stats`** stats_out, unsigned int* count_out) Get statistics collected by "rxq_stats" program. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - ta - Test Agent name * - bpf_id - BPF object ID * - stats_out - Where to save statistics (number of packets received by every Rx queue) * - count_out - Where to save number of collected statistics .. rubric:: Returns: Status code. .. index:: pair: function; tapi_bpf_rxq_stats_print .. _doxid-group__tapi__bpf__rxq__stats_1gac615250432b96cdd639df405600386f0: .. ref-code-block:: cpp :class: doxyrest-title-code-block void tapi_bpf_rxq_stats_print(const char* title, :ref:`tapi_bpf_rxq_stats`* stats, unsigned int count) Log statistics retrieved with :ref:`tapi_bpf_rxq_stats_read() `. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - title - Title to print on the first line (if ``NULL`` or empty, default title will be used) * - stats - Array of statistics * - count - Number of elements in the array .. index:: pair: function; tapi_bpf_rxq_stats_check_single .. _doxid-group__tapi__bpf__rxq__stats_1gada6763a76c0ab918637a8307fa95c0c0: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_bpf_rxq_stats_check_single(const char* ta, unsigned int bpf_id, unsigned int exp_queue, unsigned int exp_pkts, :ref:`rpc_socket_type` sock_type, const char* vpref) Check whether expected Rx queue received all the expected packets. It is assumed that statistics were cleared before sending packets. .. note:: This function will print verdict in case of failure. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - ta - Test Agent name * - bpf_id - BPF object ID * - exp_queue - Expected Rx queue ID * - exp_pkts - Expected number of received packets * - sock_type - Socket type (``RPC_SOCK_STREAM``, ``RPC_SOCK_DGRAM``) * - vpref - Prefix to use in verdicts .. rubric:: Returns: Status code. Macros ------ .. index:: pair: define; TAPI_BPF_RXQ_STATS_XSK_MAP .. _doxid-group__tapi__bpf__rxq__stats_1gadbb626af90ef2e7318274ac44033b054: .. ref-code-block:: cpp :class: doxyrest-title-code-block #define TAPI_BPF_RXQ_STATS_XSK_MAP Name of the XSK map that can be used to redirect packets to AF_XDP sockets.