DPDK helpers
Overview
TAPI to handle DPDK-related operations
Copyright (C) 2019-2022 OKTET Labs Ltd. More…
// typedefs typedef struct tapi_dpdk_testpmd_job_t tapi_dpdk_testpmd_job_t; // structs struct tapi_dpdk_testpmd_job_t; // global functions te_errno tapi_dpdk_create_testpmd_job(rcf_rpc_server* rpcs, tapi_env* env, unsigned int n_fwd_cpus, const tapi_cpu_prop_t* prop, te_kvpair_h* test_args, tapi_dpdk_testpmd_job_t* testpmd_job); te_errno tapi_dpdk_testpmd_is_opt_supported(rcf_rpc_server* rpcs, tapi_env* env, te_kvpair_h* opt, bool* opt_supported); te_errno tapi_dpdk_testpmd_start(tapi_dpdk_testpmd_job_t* testpmd_job); te_errno tapi_dpdk_testpmd_get_link_speed(tapi_dpdk_testpmd_job_t* testpmd_job, unsigned int* link_speed); te_errno tapi_dpdk_testpmd_get_link_speed_many_ports(tapi_dpdk_testpmd_job_t* testpmd_job, unsigned int n_ports, unsigned int* n_port_ids, unsigned int* port_ids, unsigned int* link_speed); te_errno tapi_dpdk_testpmd_get_stats(tapi_dpdk_testpmd_job_t* testpmd_job, te_meas_stats_t* tx, te_meas_stats_t* rx); te_errno tapi_dpdk_testpmd_get_stats_many_ports(tapi_dpdk_testpmd_job_t* testpmd_job, unsigned int n_ports, unsigned int* n_port_ids, unsigned int* port_ids, te_meas_stats_t* tx, te_meas_stats_t* rx); te_errno tapi_dpdk_testpmd_destroy(tapi_dpdk_testpmd_job_t* testpmd_job); bool tapi_dpdk_mtu_by_pkt_size(unsigned int packet_size, unsigned int* mtu); bool tapi_dpdk_mbuf_size_by_pkt_size(unsigned int packet_size, unsigned int* mbuf_size); void tapi_dpdk_append_argument(const char* argument, int* argc_p, char*** argv_out); te_errno tapi_dpdk_build_eal_arguments(rcf_rpc_server* rpcs, tapi_env* env, unsigned int n_cpus, tapi_cpu_index_t* cpu_ids, const char* program_name, int* argc_out, char*** argv_out); te_errno tapi_dpdk_grab_cpus(const char* ta, unsigned int n_cpus_preferred, unsigned int n_cpus_required, int numa_node, const tapi_cpu_prop_t* prop, unsigned int* n_cpus_grabbed, tapi_cpu_index_t* cpu_ids); te_errno tapi_dpdk_grab_cpus_nonstrict_prop(const char* ta, unsigned int n_cpus_preferred, unsigned int n_cpus_required, int numa_node, const tapi_cpu_prop_t* prop, unsigned int* n_cpus_grabbed, tapi_cpu_index_t* cpu_ids); const char* tapi_dpdk_get_vdev_eal_argument(int eal_argc, char** eal_argv); te_errno tapi_dpdk_get_vdev_port_number(const char* vdev, unsigned int* port_number); te_errno tapi_dpdk_attach_dbells_filter_rx(tapi_dpdk_testpmd_job_t* testpmd_job); te_errno tapi_dpdk_attach_dbells_filter_tx(tapi_dpdk_testpmd_job_t* testpmd_job); te_errno tapi_dpdk_add_rx_dbells_display(te_kvpair_h* test_params, const char* q_num); te_errno tapi_dpdk_add_tx_dbells_display(te_kvpair_h* test_params, const char* q_num); te_errno tapi_dpdk_stats_log_rx_dbells(const tapi_dpdk_testpmd_job_t* testpmd_job, const te_meas_stats_t* meas_stats_pps); te_errno tapi_dpdk_stats_log_tx_dbells(const tapi_dpdk_testpmd_job_t* testpmd_job, const te_meas_stats_t* meas_stats_pps); te_errno tapi_dpdk_attach_rx_pkts_bytes_filters(tapi_dpdk_testpmd_job_t* testpmd_job); te_errno tapi_dpdk_get_last_rx_pkts_bytes(tapi_dpdk_testpmd_job_t* testpmd_job, unsigned long* pkts, unsigned long* bytes); // macros #define TAPI_DPDK_L2FWD_NAME #define TAPI_DPDK_TESTPMD_ARG_NMAE_CHOP #define TAPI_DPDK_TESTPMD_ARG_PREFIX #define TAPI_DPDK_TESTPMD_COMMAND_PREFIX #define TAPI_DPDK_TESTPMD_NAME #define TAPI_DPDK_TESTPMD_RECEIVE_TIMEOUT_MS #define TAPI_DPDK_TESTPMD_TERM_TIMEOUT_MS #define TAPI_DPDK_TESTPMD_TSO_MSS_HDRS_LEN
Detailed Documentation
TAPI to handle DPDK-related operations
Copyright (C) 2019-2022 OKTET Labs Ltd. All rights reserved.
Global Functions
te_errno tapi_dpdk_create_testpmd_job(rcf_rpc_server* rpcs, tapi_env* env, unsigned int n_fwd_cpus, const tapi_cpu_prop_t* prop, te_kvpair_h* test_args, tapi_dpdk_testpmd_job_t* testpmd_job)
Create a job for test-pmd binary execution. The created job can be manipulated with other tapi_dpdk functions as well as passed to generic tapi_job functions.
Note
prop is advisory
Parameters:
rpcs |
RPC server to run test-pmd on |
env |
Test environment |
n_fwd_cpus |
Number of test-pmd forwarding CPUs |
prop |
Advisory properties of CPUs |
test_args |
Test arguments |
testpmd_job |
Handle of test-pmd job |
Returns:
Status code
te_errno tapi_dpdk_testpmd_is_opt_supported(rcf_rpc_server* rpcs, tapi_env* env, te_kvpair_h* opt, bool* opt_supported)
Check if option specified in opt is supported by test-pmd.
Parameters:
rpcs |
RPC server to run test-pmd on |
env |
Test environment |
opt |
Option to check support for |
opt_supported |
Result |
Returns:
Status code
te_errno tapi_dpdk_testpmd_start(tapi_dpdk_testpmd_job_t* testpmd_job)
Start test-pmd job
Parameters:
testpmd_job |
Handle of test-pmd job |
Returns:
Status code
te_errno tapi_dpdk_testpmd_get_link_speed(tapi_dpdk_testpmd_job_t* testpmd_job, unsigned int* link_speed)
Get link speed from running testpmd job.
The function reads the port report produced during testpmd startup. It reports the recorded state without waiting for the link to change.
Note
The startup report is consumed and cannot be read again.
Note
link_speed is not changed on failure.
Parameters:
testpmd_job |
Handle of test-pmd job |
link_speed |
Link speed in Mbps |
0 |
Link is up and its speed is returned. |
TE_ENETDOWN |
Testpmd reported that the link is down. |
TE_ENODATA |
Link is up, but its speed is unknown. |
TE_ETIMEDOUT |
The startup report was not received in time. |
Returns:
Other status code on failure.
te_errno tapi_dpdk_testpmd_get_link_speed_many_ports(tapi_dpdk_testpmd_job_t* testpmd_job, unsigned int n_ports, unsigned int* n_port_ids, unsigned int* port_ids, unsigned int* link_speed)
Get link speed from running testpmd job with many ports.
The function reads port reports produced during testpmd startup. It reports the recorded states without waiting for the links to change.
Note
The startup reports are consumed and cannot be read again.
Note
On failure, link_speed is not changed, while n_port_ids and port_ids may be updated.
Parameters:
testpmd_job |
Handle of test-pmd job |
n_ports |
Expected number of port reports |
n_port_ids |
Number of set port IDs |
port_ids |
Port IDs array |
link_speed |
Array of link speeds in Mbps |
0 |
All links are up and their speeds are returned. |
TE_ENETDOWN |
All reports were received and at least one link is down. |
TE_ENODATA |
All links are up, but at least one speed is unknown. |
TE_ETIMEDOUT |
Not all startup reports were received in time. |
Returns:
Other status code on failure.
te_errno tapi_dpdk_testpmd_get_stats(tapi_dpdk_testpmd_job_t* testpmd_job, te_meas_stats_t* tx, te_meas_stats_t* rx)
Get performance statistics from running test-pmd job.
Note
The testpmd_job must be started.
Parameters:
testpmd_job |
Handle of running test-pmd job |
tx |
Evaluated Tx statistics |
rx |
Evaluated Rx statistics |
Returns:
Status code
te_errno tapi_dpdk_testpmd_get_stats_many_ports(tapi_dpdk_testpmd_job_t* testpmd_job, unsigned int n_ports, unsigned int* n_port_ids, unsigned int* port_ids, te_meas_stats_t* tx, te_meas_stats_t* rx)
Get performance statistics from running test-pmd job with many ports.
Note
The testpmd_job must be started.
Parameters:
testpmd_job |
Handle of running test-pmd job |
n_ports |
Number of elements in |
n_port_ids |
Number of set port IDs |
port_ids |
Port IDs array |
tx |
Evaluated Tx statistics array |
rx |
Evaluated Rx statistics array |
Returns:
Status code
te_errno tapi_dpdk_testpmd_destroy(tapi_dpdk_testpmd_job_t* testpmd_job)
Destroy test-pmd job
Parameters:
testpmd_job |
Handle of test-pmd job |
Returns:
Status code
bool tapi_dpdk_mtu_by_pkt_size(unsigned int packet_size, unsigned int* mtu)
Calculate required MTU by given packet size and decide whether the MTU should be specified explicitly in the parameters.
c true Required MTU is greater than ETHER_DATA_LEN c false Required MTU is less or equal to ETHER_DATA_LEN
Parameters:
packet_size |
Size of a packet |
mtu |
Returns:
If required MTU is greater than ETHER_DATA_LEN
bool tapi_dpdk_mbuf_size_by_pkt_size(unsigned int packet_size, unsigned int* mbuf_size)
Calculate required mbuf size by given packet size and decide whether the mbuf size should be specified explicitly in the parameters.
Parameters:
packet_size |
Size of a packet |
mbuf_size |
Required mbuf size (set when the function returns |
Returns:
true - mbuf size should be set, false - should not be
void tapi_dpdk_append_argument(const char* argument, int* argc_p, char*** argv_out)
Append argument to the arguments storage Jumps out via TEST_FAIL in case of failure
Parameters:
argument |
Argument to add |
argc_p |
Pointer to the number of arguments |
argv_out |
Pointer to the arguments |
te_errno tapi_dpdk_build_eal_arguments(rcf_rpc_server* rpcs, tapi_env* env, unsigned int n_cpus, tapi_cpu_index_t* cpu_ids, const char* program_name, int* argc_out, char*** argv_out)
Build EAL arguments for TAPI jobs and store it to the arguments storage
Parameters:
rpcs |
RPC server to run job on |
env |
Test environment |
n_cpus |
Number of job forwarding CPUs |
cpu_ids |
Indices of job forwarding CPUs |
program_name |
Full path to the binary job |
argc_out |
Pointer to the number of arguments |
argv_out |
Pointer to the arguments |
Returns:
Status code
te_errno tapi_dpdk_attach_dbells_filter_rx(tapi_dpdk_testpmd_job_t* testpmd_job)
Attach filters to catch Rx doorbells rate and if they are supported.
Parameters:
testpmd_job |
Handle of running test-pmd job |
Returns:
Status code
te_errno tapi_dpdk_attach_dbells_filter_tx(tapi_dpdk_testpmd_job_t* testpmd_job)
Attach filters to catch Tx doorbells rate and if they are supported.
Parameters:
testpmd_job |
Handle of running test-pmd job |
Returns:
Status code
te_errno tapi_dpdk_add_rx_dbells_display(te_kvpair_h* test_params, const char* q_num)
Add display Rx doorbells xstats to dpdk-testpmd parameters.
Parameters:
test_params |
kvpair storing dpdk-testpmd parameters |
q_num |
Number of Rx queues. |
Returns:
Status code
te_errno tapi_dpdk_add_tx_dbells_display(te_kvpair_h* test_params, const char* q_num)
Add display Tx doorbells xstats to dpdk-testpmd parameters.
Parameters:
test_params |
kvpair storing dpdk-testpmd parameters |
q_num |
Number of Tx queues. |
Returns:
Status code
te_errno tapi_dpdk_stats_log_rx_dbells(const tapi_dpdk_testpmd_job_t* testpmd_job, const te_meas_stats_t* meas_stats_pps)
Report Rx doorbells rate and packets per doorbell as test artifacts.
Parameters:
testpmd_job |
Handle of running test-pmd job |
meas_stats_pps |
Statistics of packets per second |
Returns:
Status code
te_errno tapi_dpdk_stats_log_tx_dbells(const tapi_dpdk_testpmd_job_t* testpmd_job, const te_meas_stats_t* meas_stats_pps)
Report Tx doorbells rate and packets per doorbell as test artifacts.
Parameters:
testpmd_job |
Handle of running test-pmd job |
meas_stats_pps |
Statistics of packets per second |
Returns:
Status code
te_errno tapi_dpdk_attach_rx_pkts_bytes_filters(tapi_dpdk_testpmd_job_t* testpmd_job)
Attach Rx packets/bytes filters.
Parameters:
testpmd_job |
Handle of test-pmd job |
Returns:
Status code
te_errno tapi_dpdk_get_last_rx_pkts_bytes(tapi_dpdk_testpmd_job_t* testpmd_job, unsigned long* pkts, unsigned long* bytes)
Get latest values of Rx packets and bytes from filters attached by tapi_dpdk_attach_rx_pkts_bytes_filters().
Parameters:
testpmd_job |
Rx job channel handle |
pkts |
Latest Rx packets |
bytes |
Latest Rx bytes |
Returns:
Status code
Macros
#define TAPI_DPDK_L2FWD_NAME
Name of l2fwd tool
#define TAPI_DPDK_TESTPMD_NAME
Name of testpmd tool