Test API to control rxq_stats BPF program
Overview
Definition of API to control rxq_stats BPF program. More…
// typedefs typedef struct tapi_bpf_rxq_stats tapi_bpf_rxq_stats; // structs struct tapi_bpf_rxq_stats; // global functions te_errno tapi_bpf_rxq_stats_init(const char* ta, const char* if_name, const char* prog_dir, unsigned int* bpf_id); te_errno tapi_bpf_rxq_stats_fini(const char* ta, const char* if_name, unsigned int bpf_id); te_errno tapi_bpf_rxq_stats_get_id(const char* ta, const char* if_name, unsigned int* bpf_id); 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); te_errno tapi_bpf_rxq_stats_enable(const char* ta, unsigned int bpf_id, bool enable); te_errno tapi_bpf_rxq_stats_clear(const char* ta, unsigned int bpf_id); te_errno tapi_bpf_rxq_stats_reset(const char* ta, unsigned int bpf_id); te_errno tapi_bpf_rxq_stats_read(const char* ta, unsigned int bpf_id, tapi_bpf_rxq_stats** stats_out, unsigned int* count_out); void tapi_bpf_rxq_stats_print(const char* title, tapi_bpf_rxq_stats* stats, unsigned int count); te_errno tapi_bpf_rxq_stats_check_single(const char* ta, unsigned int bpf_id, unsigned int exp_queue, unsigned int exp_pkts, rpc_socket_type sock_type, const char* vpref); // macros #define TAPI_BPF_RXQ_STATS_XSK_MAP
Detailed Documentation
Definition of API to control rxq_stats BPF program.
Copyright (C) 2022-2022 OKTET Labs Ltd. All rights reserved.
Typedefs
typedef struct tapi_bpf_rxq_stats tapi_bpf_rxq_stats
Per-queue received packets count
Global Functions
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.
Parameters:
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 |
Returns:
Status code.
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.
Parameters:
ta |
Test Agent |
if_name |
Interface name |
bpf_id |
BPF object ID |
Returns:
Status code.
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.
Parameters:
ta |
Test Agent |
if_name |
Interface name |
bpf_id |
Where to save BPF object ID |
Returns:
Status code.
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.
Parameters:
ta |
Test Agent name |
bpf_id |
BPF object ID |
addr_family |
|
src_addr |
Source address/port |
dst_addr |
Destination address/port |
protocol |
IP protocol ( |
enable |
Whether counting of packets should be enabled now |
Returns:
Status code.
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.
Parameters:
ta |
Test Agent name |
bpf_id |
BPF object ID |
enable |
Whether counting of packets should be enabled now |
Returns:
Status code.
te_errno tapi_bpf_rxq_stats_clear(const char* ta, unsigned int bpf_id)
Clear statistics collected by “rxq_stats” program.
Parameters:
ta |
Test Agent name |
bpf_id |
BPF object ID |
Returns:
Status code.
te_errno tapi_bpf_rxq_stats_read(const char* ta, unsigned int bpf_id, tapi_bpf_rxq_stats** stats_out, unsigned int* count_out)
Get statistics collected by “rxq_stats” program.
Parameters:
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 |
Returns:
Status code.
void tapi_bpf_rxq_stats_print(const char* title, tapi_bpf_rxq_stats* stats, unsigned int count)
Log statistics retrieved with tapi_bpf_rxq_stats_read().
Parameters:
title |
Title to print on the first line (if |
stats |
Array of statistics |
count |
Number of elements in the array |
te_errno tapi_bpf_rxq_stats_check_single(const char* ta, unsigned int bpf_id, unsigned int exp_queue, unsigned int exp_pkts, 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.
This function will print verdict in case of failure.
Parameters:
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 ( |
vpref |
Prefix to use in verdicts |
Returns:
Status code.
Macros
#define TAPI_BPF_RXQ_STATS_XSK_MAP
Name of the XSK map that can be used to redirect packets to AF_XDP sockets.