Global Namespace
Overview
// typedefs typedef struct net_drv_conn net_drv_conn; typedef struct net_drv_flow net_drv_flow; typedef struct net_drv_phy_mode_info net_drv_phy_mode_info; typedef struct net_drv_phy_saved_state net_drv_phy_saved_state; typedef struct net_drv_rss_ctx net_drv_rss_ctx; typedef struct net_drv_xdp_sock net_drv_xdp_sock; typedef struct net_drv_xdp_cfg net_drv_xdp_cfg; // structs struct net_drv_conn; struct net_drv_flow; struct net_drv_phy_mode_info; struct net_drv_phy_saved_state; struct net_drv_rss_ctx; struct net_drv_xdp_cfg; struct net_drv_xdp_sock; // global functions void net_drv_conn_create(net_drv_conn* conn); te_errno net_drv_conn_destroy(net_drv_conn* conn); void net_drv_flow_prepare(net_drv_flow* flow); void net_drv_flow_start(net_drv_flow* flow); void net_drv_flow_finish(net_drv_flow* flow); te_errno net_drv_flow_destroy(net_drv_flow* flow); int net_drv_ethtool_reset(rcf_rpc_server* rpcs, int s, const char* if_name, unsigned int flags, unsigned int* ret_flags); te_errno net_drv_add_missing_ethtool_opt_tags(rcf_rpc_server* rpcs); void net_drv_phy_state_free(net_drv_phy_saved_state* state); te_errno net_drv_phy_state_save(const char* ta, const char* if_name, net_drv_phy_saved_state* state); te_errno net_drv_phy_state_restore(const char* ta, const char* if_name, const net_drv_phy_saved_state* state); void net_drv_phy_state_save_or_skip(const char* who, const char* ta, const char* if_name, net_drv_phy_saved_state* state); const net_drv_phy_mode_info* net_drv_phy_state_find_mode_by_name(const net_drv_phy_saved_state* state, const char* name); bool net_drv_phy_is_link_mode(const net_drv_phy_mode_info* mode); te_errno net_drv_phy_apply_autoneg_modes(const char* ta, const char* if_name, const net_drv_phy_saved_state* state, const char* mode1_name, const char* mode2_name); te_errno net_drv_phy_apply_fixed_mode(const char* ta, const char* if_name, int speed, int duplex); void net_drv_phy_check_autoneg_state(const char* where, const char* ta, const char* if_name, int expected); void net_drv_phy_check_lp_autoneg_state(const char* where, const char* ta, const char* if_name, int expected); void net_drv_phy_check_oper_mode(const char* where, const char* ta, const char* if_name, int expected_speed, int expected_duplex); void net_drv_phy_check_local_mode_advertised(const char* where, const char* ta, const char* if_name, const char* mode_name, bool expected); void net_drv_phy_check_partner_mode_advertised(const char* where, const char* ta, const char* if_name, const char* mode_name, bool expected); void net_drv_open_ptp_fd(rcf_rpc_server* rpcs, const char* if_name, int* fd, const char* vpref); bool net_drv_is_ptp_supported(rcf_rpc_server* rpcs, const char* if_name); double net_drv_timespec_diff(tarpc_timespec* tsa, tarpc_timespec* tsb); double net_drv_ptp_clock_time_diff(tarpc_ptp_clock_time* tsa, tarpc_ptp_clock_time* tsb); void net_drv_ptp_offs_check_dev_avg(double* values, unsigned int number, double avg_diff); void net_drv_ptp_offs_check_dev_gettime(rcf_rpc_server* rpcs, int ptp_fd, rpc_clock_id sys_clock, double ptp_offs); static void net_drv_ptp_ntpd_disable(rcf_rpc_server* rpcs); int rpc_net_drv_too_many_rx_rules(rcf_rpc_server* rpcs, int fd, const char* if_name, const struct sockaddr* src_addr, const struct sockaddr* dst_addr, rpc_socket_type sock_type, te_bool any_location, unsigned int queues_num, unsigned int* rules_count, te_errno* add_errno); int64_t rpc_net_drv_send_pkts_exact_delay(rcf_rpc_server* rpcs, int s, unsigned int delay, unsigned int time2run); int64_t rpc_net_drv_recv_pkts_exact_delay(rcf_rpc_server* rpcs, int s, unsigned int time2wait); char* net_drv_driver_name(const char* ta); te_bool net_drv_driver_unloadable(const char* ta, const char* module); te_errno net_drv_driver_set_loaded(const char* ta, const char* module, te_bool load); bool net_drv_req_if_feature_configurable(const char* ta, const char* if_name, const char* feature_name); void net_drv_req_if_feature_change(const char* ta, const char* if_name, const char* feature_name); void net_drv_set_if_feature(const char* ta, const char* if_name, const char* feature_name, int req_status); void net_drv_try_set_if_feature(const char* ta, const char* if_name, const char* feature_name, int req_status); size_t net_drv_send_recv_check(rcf_rpc_server* rpcs_sender, int s_sender, rcf_rpc_server* rpcs_receiver, int s_receiver, const char* vpref); size_t net_drv_send_recv_ext_check(rcf_rpc_server* rpcs_sender, int s_sender, rcf_rpc_server* rpcs_receiver, int s_receiver, bool jumbo, const char* vpref); size_t net_drv_sendto_recv_check(rcf_rpc_server* rpcs_sender, int s_sender, const struct sockaddr* dst_addr, rcf_rpc_server* rpcs_receiver, int s_receiver, const char* vpref); size_t net_drv_sendto_recv_check_may_loss(rcf_rpc_server* rpcs_sender, int s_sender, const struct sockaddr* dst_addr, rcf_rpc_server* rpcs_receiver, int s_receiver, const char* vpref); void net_drv_conn_check(rcf_rpc_server* rpcs1, int s1, const char* s1_name, rcf_rpc_server* rpcs2, int s2, const char* s2_name, const char* vpref); te_errno net_drv_cat_all_files(rcf_rpc_server* rpcs, uint32_t timeout, const char* path_fmt, ...); te_errno net_drv_set_phy_link(const char* ta, const char* if_name); int net_drv_ts_phy_autoneg_str2id(const char* autoneg_str); int net_drv_ts_phy_duplex_str2id(const char* duplex_str); int net_drv_ts_phy_speed_str2id(const char* speed_str); te_errno net_drv_set_check_mac(const char* ta, const char* if_name, const void* mac_addr); void net_drv_set_mtu(const char* ta, const char* if_name, int mtu, const char* where); te_errno net_drv_neigh_nodes_count(const char* ta, unsigned int* num); te_errno net_drv_wait_neigh_nodes_recover(const char* ta, unsigned int num); void net_drv_set_pci_param_uint(const char* pci_oid, const char* param_name, tapi_cfg_pci_param_cmode cmode, uint64_t value, const char* vpref); void net_drv_wait_up_gen(const char* ta, const char* if_name, te_bool cleanup); static void net_drv_wait_up(const char* ta, const char* if_name); void net_drv_ts_add_vlan(const char* ta1, const char* ta2, const char* if1, const char* if2, int af, uint16_t* vlan_id, struct sockaddr** vlan_addr1, struct sockaddr** vlan_addr2); te_errno net_drv_rss_send_check_stats(rcf_rpc_server* sender_rpcs, int sender_s, const struct sockaddr* sender_addr, rcf_rpc_server* receiver_rpcs, int receiver_s, const struct sockaddr* receiver_addr, rpc_socket_type sock_type, unsigned int exp_queue, unsigned int bpf_id, bool jumbo, const char* vpref); te_errno net_drv_rss_send_get_stats(rcf_rpc_server* sender_rpcs, int sender_s, const struct sockaddr* sender_addr, rcf_rpc_server* receiver_rpcs, int receiver_s, const struct sockaddr* receiver_addr, rpc_socket_type sock_type, unsigned int bpf_id, bool jumbo, tapi_bpf_rxq_stats** stats, unsigned int* stats_count, const char* vpref); te_errno net_drv_rss_check_set_hfunc(const char* ta, const char* if_name, unsigned int rss_context, const char* func_name); static void net_drv_rss_get_check_hkey(const char* ta, const char* if_name, unsigned int rss_context, uint8_t** key, size_t* len); void net_drv_rss_ctx_prepare(net_drv_rss_ctx* ctx, const char* ta, const char* if_name, unsigned int rss_ctx); void net_drv_rss_ctx_release(net_drv_rss_ctx* ctx); te_errno net_drv_rss_ctx_change_key(net_drv_rss_ctx* ctx, uint8_t* hash_key, unsigned int key_len); te_errno net_drv_rss_predict(net_drv_rss_ctx* ctx, const struct sockaddr* src_addr, const struct sockaddr* dst_addr, unsigned int* hash_out, unsigned int* idx_out, unsigned int* queue_out); void net_drv_rx_rules_check_table_size(const char* ta, const char* if_name, uint32_t* table_size); void net_drv_rx_rules_check_spec_loc(const char* ta, const char* if_name); te_errno net_drv_rx_rules_find_loc(const char* ta, const char* if_name, int64_t* location); void net_drv_add_tcpudp_rx_rule(const char* ta, const char* if_name, rpc_socket_type sock_type, const struct sockaddr* src_addr, const struct sockaddr* src_mask, const struct sockaddr* dst_addr, const struct sockaddr* dst_mask, unsigned int queue, const char* rule_name); te_errno net_drv_xdp_adjust_rx_size(const char* ta, const char* if_name, net_drv_xdp_cfg* cfg); te_errno net_drv_xdp_get_queues_num(const char* ta, const char* if_name, unsigned int* rx_queues, unsigned int* tx_queues); te_errno net_drv_xdp_create_sock(rcf_rpc_server* rpcs, const char* if_name, unsigned int queue_id, net_drv_xdp_cfg* cfg, int map_fd, net_drv_xdp_sock* sock); te_errno net_drv_xdp_destroy_sock(rcf_rpc_server* rpcs, net_drv_xdp_sock* sock); void net_drv_xdp_create_socks(rcf_rpc_server* rpcs, const char* if_name, net_drv_xdp_cfg* cfg, int map_fd, unsigned int socks_num, net_drv_xdp_sock** socks_out); te_errno net_drv_xdp_destroy_socks(rcf_rpc_server* rpcs, net_drv_xdp_sock* socks, unsigned int socks_num); void net_drv_xdp_echo(rcf_rpc_server* rpcs_udp, int s_udp, const struct sockaddr* dst_addr, rcf_rpc_server* rpcs_xdp, net_drv_xdp_sock* socks, unsigned int socks_num, unsigned int exp_sock, bool jumbo); // macros #define NET_DRV_CLEANUP_SET_UP_WAIT(_ta, _if_name) #define NET_DRV_CONN_INIT #define NET_DRV_DEF_PTP_INACC #define NET_DRV_FLOW_INIT #define NET_DRV_IONIC_DRIVER_NAME #define NET_DRV_PTP_OFFS_MAX_DEV_FROM_AVG #define NET_DRV_PTP_OFFS_MAX_DEV_FROM_GETTIME #define NET_DRV_RESET_FLAGS #define NET_DRV_RSS_CHECK_SET_HFUNC(_ta, _if_name, _rss_ctx, _func_name, _term_macro) #define NET_DRV_RSS_CTX_INIT #define NET_DRV_RX_RULE_LOC #define NET_DRV_WAIT_IF_STATS_UPDATE #define NET_DRV_WAIT_PHY_CHANGE #define NET_DRV_X3_DRIVER_NAME #define NET_DRV_XDP_CFG_DEF #define NET_DRV_XDP_COPY_MODE #define NET_DRV_XDP_SOCK_INIT #define NET_DRV_XDP_WAIT_SOCKS #define TEST_END_SPECIFIC #define TEST_START_SPECIFIC #define TEST_START_VARS
Detailed Documentation
Typedefs
typedef struct net_drv_conn net_drv_conn
A pair of connected sockets
typedef struct net_drv_flow net_drv_flow
Structure describing data flow between a pair of sockets
typedef struct net_drv_phy_mode_info net_drv_phy_mode_info
Description of one exact PHY mode exposed under /phy :/mode:*.
typedef struct net_drv_phy_saved_state net_drv_phy_saved_state
Saved PHY configuration for later restoration.
typedef struct net_drv_rss_ctx net_drv_rss_ctx
Helper structure for RSS tests
typedef struct net_drv_xdp_sock net_drv_xdp_sock
Structure describing AF_XDP socket
typedef struct net_drv_xdp_cfg net_drv_xdp_cfg
Configuration parameters for AF_XDP sockets
Global Functions
void net_drv_conn_create(net_drv_conn* conn)
Create a pair of connected sockets.
Parameters:
conn |
Where to get addresses/ports and etc, where to save created sockets. |
te_errno net_drv_conn_destroy(net_drv_conn* conn)
Destroy a pair of connected sockets.
Parameters:
conn |
Structure with sockets to close. |
void net_drv_flow_prepare(net_drv_flow* flow)
Make preparations before starting data flow (create RPC servers if necessary, initialize internal fields, etc).
Parameters:
flow |
Pointer to net_drv_flow structure to prepare. |
void net_drv_flow_start(net_drv_flow* flow)
Start sending/receiving data.
Parameters:
flow |
Pointer to net_drv_flow structure describing the flow. |
void net_drv_flow_finish(net_drv_flow* flow)
Wait until sending/receiving data is finished, check results of RPC calls.
Parameters:
flow |
Pointer to net_drv_flow structure describing the flow. |
te_errno net_drv_flow_destroy(net_drv_flow* flow)
Release resources allocated for sending and receiving data.
Parameters:
flow |
Pointer to net_drv_flow structure describing the flow. |
int net_drv_ethtool_reset(rcf_rpc_server* rpcs, int s, const char* if_name, unsigned int flags, unsigned int* ret_flags)
Call SIOCETHTOOL/ETHTOOL_RESET. This is simple wrapper over rpc_ioctl(); RPC_AWAIT_ERROR() can be used with it.
Parameters:
rpcs |
RPC server |
s |
Socket FD |
if_name |
Interface name |
flags |
Reset flags (see rpc_ethtool_reset_flags) |
ret_flags |
If not |
Returns:
Result of rpc_ioctl().
te_errno net_drv_add_missing_ethtool_opt_tags(rcf_rpc_server* rpcs)
Check whether CLI options used by TS tests are present in ethtool help output and add proper TRC tags if some are missing.
Parameters:
rpcs |
RPC server. |
Returns:
Status code.
void net_drv_phy_state_free(net_drv_phy_saved_state* state)
Release memory allocated inside saved PHY state.
Parameters:
state |
State to release. |
te_errno net_drv_phy_state_save(const char* ta, const char* if_name, net_drv_phy_saved_state* state)
Save current PHY configuration under /phy :/mode:*.
Parameters:
ta |
Test Agent name. |
if_name |
Interface name. |
state |
Where to save PHY configuration. |
Returns:
Status code.
te_errno net_drv_phy_state_restore(const char* ta, const char* if_name, const net_drv_phy_saved_state* state)
Restore PHY configuration.
Autonegotiation state is always restored. Administrative speed and duplex are restored only when saved autonegotiation state is off. Saved advertised states are restored only for exact PHY link modes with known speed and duplex; other /phy :/mode:* entries are left unchanged.
Parameters:
ta |
Test Agent name. |
if_name |
Interface name. |
state |
Previously saved PHY configuration. |
Returns:
Status code.
void net_drv_phy_state_save_or_skip(const char* who, const char* ta, const char* if_name, net_drv_phy_saved_state* state)
Save current PHY configuration or terminate the test with TEST_SKIP()/TEST_VERDICT() if the configuration cannot be accessed.
Parameters:
who |
Human-readable endpoint name for log messages. |
ta |
Test Agent name. |
if_name |
Interface name. |
state |
Where to save PHY configuration. |
const net_drv_phy_mode_info* net_drv_phy_state_find_mode_by_name(const net_drv_phy_saved_state* state, const char* name)
Find exact PHY mode by name in saved PHY state.
Parameters:
state |
Saved PHY state. |
name |
Exact PHY mode name to find. |
Returns:
Pointer to mode description, or NULL if it is absent.
bool net_drv_phy_is_link_mode(const net_drv_phy_mode_info* mode)
Check whether PHY mode description corresponds to a link mode.
Parameters:
mode |
PHY mode description. |
Returns:
true if both speed and duplex are known for this mode.
te_errno net_drv_phy_apply_autoneg_modes(const char* ta, const char* if_name, const net_drv_phy_saved_state* state, const char* mode1_name, const char* mode2_name)
Enable autonegotiation and advertise one or two exact PHY modes.
All exact PHY link modes with known speed and duplex not listed in arguments are disabled. Other /phy :/mode:* entries such as pause or FEC capabilities are left unchanged.
Parameters:
ta |
Test Agent name. |
if_name |
Interface name. |
state |
Saved PHY state used to enumerate available modes. |
mode1_name |
First exact PHY mode to advertise. |
mode2_name |
Optional second exact PHY mode to advertise. |
Returns:
Status code.
te_errno net_drv_phy_apply_fixed_mode(const char* ta, const char* if_name, int speed, int duplex)
Disable autonegotiation and configure a fixed administrative PHY mode.
Parameters:
ta |
Test Agent name. |
if_name |
Interface name. |
speed |
Administrative speed to set. |
duplex |
Administrative duplex to set. |
Returns:
Status code.
void net_drv_phy_check_autoneg_state(const char* where, const char* ta, const char* if_name, int expected)
Check local autonegotiation state and verdict on mismatch.
Parameters:
where |
Human-readable endpoint description. |
ta |
Test Agent name. |
if_name |
Interface name. |
expected |
Expected autonegotiation state. |
void net_drv_phy_check_lp_autoneg_state(const char* where, const char* ta, const char* if_name, int expected)
Check link partner autonegotiation state and verdict on mismatch.
If link partner advertised modes are not exposed in PHY tree for the endpoint, the helper logs a warning and skips the check.
Parameters:
where |
Human-readable endpoint description. |
ta |
Test Agent name. |
if_name |
Interface name. |
expected |
Expected partner autonegotiation state. |
void net_drv_phy_check_oper_mode(const char* where, const char* ta, const char* if_name, int expected_speed, int expected_duplex)
Check operational PHY mode and verdict on mismatch.
Parameters:
where |
Human-readable endpoint description. |
ta |
Test Agent name. |
if_name |
Interface name. |
expected_speed |
Expected operational speed. |
expected_duplex |
Expected operational duplex. |
void net_drv_phy_check_local_mode_advertised(const char* where, const char* ta, const char* if_name, const char* mode_name, bool expected)
Check whether a local exact PHY mode is advertised and verdict on mismatch.
Parameters:
where |
Human-readable endpoint description. |
ta |
Test Agent name. |
if_name |
Interface name. |
mode_name |
Exact PHY mode name. |
expected |
Expected advertised state. |
void net_drv_phy_check_partner_mode_advertised(const char* where, const char* ta, const char* if_name, const char* mode_name, bool expected)
Check whether an exact PHY mode is advertised by the link partner.
If link partner advertised modes are not exposed in PHY tree for the endpoint, the helper logs a warning and skips the check.
Parameters:
where |
Human-readable endpoint description. |
ta |
Test Agent name. |
if_name |
Interface name. |
mode_name |
Exact PHY mode name. |
expected |
Expected advertised state. |
void net_drv_open_ptp_fd(rcf_rpc_server* rpcs, const char* if_name, int* fd, const char* vpref)
Open PTP device associated with a given network interface. This function prints verdict and terminates test on failure.
Parameters:
rpcs |
RPC server |
if_name |
Interface name |
fd |
Where to save opened file descriptor |
vpref |
Prefix for verdicts (may be |
bool net_drv_is_ptp_supported(rcf_rpc_server* rpcs, const char* if_name)
Check PTP support for the interface.
Parameters:
rpcs |
RPC server. |
if_name |
Interface name. |
Returns:
true if PTP support is available, false otherwise.
double net_drv_timespec_diff(tarpc_timespec* tsa, tarpc_timespec* tsb)
Get difference between two timespec structures in seconds (tsa - tsb).
Parameters:
tsa |
The first timestamp |
tsb |
The second timestamp |
Returns:
Difference in seconds.
double net_drv_ptp_clock_time_diff(tarpc_ptp_clock_time* tsa, tarpc_ptp_clock_time* tsb)
Get difference between two tarpc_ptp_clock_time structures in seconds (tsa - tsb).
Parameters:
tsa |
The first timestamp |
tsb |
The second timestamp |
Returns:
Difference in seconds.
void net_drv_ptp_offs_check_dev_avg(double* values, unsigned int number, double avg_diff)
Check whether sample differences are close to the average when testing requests like PTP_SYS_OFFSET.
Parameters:
values |
Array of differences between clocks |
number |
Number of elements in the array |
avg_diff |
Average difference |
void net_drv_ptp_offs_check_dev_gettime(rcf_rpc_server* rpcs, int ptp_fd, rpc_clock_id sys_clock, double ptp_offs)
Check whether estimated difference between PTP clock and system clock is close to the difference computed with two consecutive clock_gettime() calls.
Parameters:
rpcs |
RPC server on which to call clock_gettime() |
ptp_fd |
PTP device FD |
sys_clock |
System clock to get system timestamp from |
ptp_offs |
Estimated difference between PTP and system clock, in seconds |
static void net_drv_ptp_ntpd_disable(rcf_rpc_server* rpcs)
Disable ntpd daemon if available.
Parameters:
rpcs |
RPC server. |
int rpc_net_drv_too_many_rx_rules(rcf_rpc_server* rpcs, int fd, const char* if_name, const struct sockaddr* src_addr, const struct sockaddr* dst_addr, rpc_socket_type sock_type, te_bool any_location, unsigned int queues_num, unsigned int* rules_count, te_errno* add_errno)
Create as many Rx classification rules as possible before it fails. Then remove all the created rules.
To make rules different, this function iterates over all possible TCP/UDP ports for source and destination. So this function can create up to 4294836225 rules.
Parameters:
rpcs |
RPC server. |
fd |
File descriptor on which to call ioctl() when creating Rx rules. |
if_name |
Interface name. |
src_addr |
Source IP address. |
dst_addr |
Destination IP address. |
sock_type |
|
any_location |
If |
queues_num |
Number of available Rx queues. |
rules_count |
How many rules were created. |
add_error |
Which error was encountered when trying to add the last rule. |
Returns:
0 on success, -1 on failure.
int64_t rpc_net_drv_send_pkts_exact_delay(rcf_rpc_server* rpcs, int s, unsigned int delay, unsigned int time2run)
Send packets trying to keep requested time intervals between them.
This is intended to be used with datagram sockets. Every packet has payload of 9 bytes, the first 8 bytes is 64-bit packet ordinal number in network byte order (to make it possible to detect lost packets). The last byte is 0xff, it makes it easy to skip small Ethernet frame padding at the end if it is retrieved by CSAP.
Parameters:
rpcs |
RPC server. |
s |
Socket FD. |
delay |
Delay between packets, in microseconds. |
time2run |
How long to send packets, in milliseconds. |
Returns:
Number of sent packets on success, -1 on failure.
int64_t rpc_net_drv_recv_pkts_exact_delay(rcf_rpc_server* rpcs, int s, unsigned int time2wait)
Receive and check packets sent with rpc_net_drv_send_pkts_exact_delay().
This function allows for packet losses.
Parameters:
rpcs |
RPC server. |
s |
Socket FD. |
time2wait |
How long to wait for new data, in milliseconds. If no new data comes during this time, the RPC call terminates. |
Returns:
Number of received packets on success, -1 on failure.
char* net_drv_driver_name(const char* ta)
Get tested driver name on TA.
Parameters:
ta |
Test Agent name. |
Returns:
Pointer to dynamically allocated string, it should be released by caller. On failure NULL is returned.
te_bool net_drv_driver_unloadable(const char* ta, const char* module)
Is driver unloadable?
Returns:
TRUE or FALSE.
te_errno net_drv_driver_set_loaded(const char* ta, const char* module, te_bool load)
Load or unload driver module, check that it succeeded.
Parameters:
ta |
Test Agent name. |
module |
Kernel module name. |
load |
If |
Returns:
Status code.
bool net_drv_req_if_feature_configurable(const char* ta, const char* if_name, const char* feature_name)
Check whether a given interface feature (/interface:/feature: node) is present and can be modified for a given network interface.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
feature_name |
Feature name |
Returns:
True if the feature is present and not read-only.
void net_drv_req_if_feature_change(const char* ta, const char* if_name, const char* feature_name)
Check whether a given interface feature (/interface:/feature: node) is present and can be modified for a given network interface. If it is not true, skip the test with TEST_SKIP().
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
feature_name |
Feature name |
void net_drv_set_if_feature(const char* ta, const char* if_name, const char* feature_name, int req_status)
Ensure that a given interface feature (/interface:/feature: node) has the requested status, change it if necessary. Absence of the feature is considered to be the same as it being disabled. If the requested feature status cannot be achieved, skip the test with TEST_SKIP().
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
feature_name |
Feature name |
req_status |
Requested status: |
void net_drv_try_set_if_feature(const char* ta, const char* if_name, const char* feature_name, int req_status)
Try to set a given interface feature (/interface:/feature: node). If the feature is not present or is read-only and has a wrong status, print warning but do not fail the test.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
feature_name |
Feature name |
req_status |
Requested status: |
size_t net_drv_send_recv_check(rcf_rpc_server* rpcs_sender, int s_sender, rcf_rpc_server* rpcs_receiver, int s_receiver, const char* vpref)
Send some data, receive it on peer, check it. In case of any failure, print verdict and stop the test.
Parameters:
rpcs_sender |
RPC server from which to send. |
s_sender |
Socket from which to send. |
rpcs_receiver |
RPC server on which to receive. |
s_receiver |
Socket on which to receive. |
vpref |
Prefix for verdicts. |
Returns:
Number of bytes sent and received.
size_t net_drv_send_recv_ext_check(rcf_rpc_server* rpcs_sender, int s_sender, rcf_rpc_server* rpcs_receiver, int s_receiver, bool jumbo, const char* vpref)
Same as net_drv_send_recv_check(), but allows to force bigger payloads.
Parameters:
rpcs_sender |
RPC server from which to send. |
s_sender |
Socket from which to send. |
rpcs_receiver |
RPC server on which to receive. |
s_receiver |
Socket on which to receive. |
jumbo |
If |
vpref |
Prefix for verdicts. |
Returns:
Number of bytes sent and received.
size_t net_drv_sendto_recv_check(rcf_rpc_server* rpcs_sender, int s_sender, const struct sockaddr* dst_addr, rcf_rpc_server* rpcs_receiver, int s_receiver, const char* vpref)
Same as net_drv_send_recv_check() but allows to specify destination address.
Parameters:
rpcs_sender |
RPC server from which to send. |
s_sender |
Socket from which to send. |
dst_addr |
If not |
rpcs_receiver |
RPC server on which to receive. |
s_receiver |
Socket on which to receive. |
vpref |
Prefix for verdicts. |
Returns:
Number of bytes sent and received.
size_t net_drv_sendto_recv_check_may_loss(rcf_rpc_server* rpcs_sender, int s_sender, const struct sockaddr* dst_addr, rcf_rpc_server* rpcs_receiver, int s_receiver, const char* vpref)
Same as net_drv_sendto_recv_check() but do not fail if receiver does not become readable and return 0.
Parameters:
rpcs_sender |
RPC server from which to send. |
s_sender |
Socket from which to send. |
dst_addr |
If not |
rpcs_receiver |
RPC server on which to receive. |
s_receiver |
Socket on which to receive. |
vpref |
Prefix for verdicts. |
Returns:
Number of bytes sent and received.
void net_drv_conn_check(rcf_rpc_server* rpcs1, int s1, const char* s1_name, rcf_rpc_server* rpcs2, int s2, const char* s2_name, const char* vpref)
Send data in both directions between a pair of connected sockets, check that it can be received. In case of any failure, print verdict and stop the test.
Parameters:
rpcs1 |
The first RPC server. |
s1 |
The first socket. |
s1_name |
Name of the first socket to be used in verdicts. |
rpcs2 |
The second RPC server. |
s2 |
The second socket. |
s2_name |
Name of the second socket to be used in verdicts. |
vpref |
Common prefix for verdicts. |
te_errno net_drv_cat_all_files(rcf_rpc_server* rpcs, uint32_t timeout, const char* path_fmt, ...)
Find all the readable files under a specified path and log their contents. The function will report failure if there is no matching files at all.
Parameters:
rpcs |
RPC server. |
timeout |
Timeout for logging all files call, if it is |
path_fmt... |
Path format string and arguments. |
Returns:
Status code.
te_errno net_drv_set_phy_link(const char* ta, const char* if_name)
Set PHY interface mode (autoneg, duplex and speed state) using "/local/phy/" subtree.
Parameters:
ta |
Test Agent name. |
if_name |
Interface name. |
Returns:
Status code.
int net_drv_ts_phy_autoneg_str2id(const char* autoneg_str)
Get PHY autoneg state by name string.
Parameters:
autoneg_str |
Autoneg state name string. Valid values:
|
Returns:
TE_PHY_AUTONEG_ON - autonegatiation on TE_PHY_AUTONEG_OFF - autonegatiation off TE_PHY_AUTONEG_UNKNOWN - if autoneg_str is TE_PHY_AUTONEG_UNKNOWN_STRING, NULL or empty.
int net_drv_ts_phy_duplex_str2id(const char* duplex_str)
Get PHY duplex state by name string.
Parameters:
duplex_str |
Duplex state name string. Valid values:
|
Returns:
TE_PHY_DUPLEX_FULL - full duplex mode TE_PHY_DUPLEX_HALF - half duplex mode TE_PHY_DUPLEX_UNKNOWN - if autoneg_str is TE_PHY_DUPLEX_UNKNOWN_STRING, NULL or empty.
int net_drv_ts_phy_speed_str2id(const char* speed_str)
Get PHY speed state by name string.
Parameters:
speed_str |
Speed state name string, in Mb/sec. |
Returns:
TE_PHY_SPEED_* or TE_PHY_SPEED_UNKNOWN - if speed_str is TE_PHY_SPEED_UNKNOWN, NULL or empty.
te_errno net_drv_set_check_mac(const char* ta, const char* if_name, const void* mac_addr)
Set a new MAC address on a network interface, check that the new address is reported for the interface in configuration tree after that.
Parameters:
ta |
Test Agent name. |
if_name |
Interface name. |
mac_addr |
Address to set (assumed to have |
Returns:
Status code.
void net_drv_set_mtu(const char* ta, const char* if_name, int mtu, const char* where)
Try to set MTU, print verdict if it fails.
Parameters:
ta |
Test Agent |
if_name |
Interface name |
mtu |
MTU value to set |
where |
Where MTU is set (to print in verdict) |
te_errno net_drv_neigh_nodes_count(const char* ta, unsigned int* num)
Get number of /agent:<name>/sys:/net:/ipv[46]:/neigh:<ifname> nodes currently present in configuration tree. This function is intended to be used with net_drv_wait_neigh_nodes_recover().
Parameters:
ta |
Test Agent name |
num |
Where to save number of neigh nodes |
Returns:
Status code.
te_errno net_drv_wait_neigh_nodes_recover(const char* ta, unsigned int num)
Wait until the number of neigh nodes in configuration tree is not less than a given number. This function can be used to check that interfaces are fully recovered after the driver is reloaded. For some reason sometimes it takes more time for all neigh nodes to reappear, and restoring configuration from backup fails in such case.
Parameters:
ta |
Test Agent name |
num |
Number of neigh nodes which should be present |
Returns:
Status code.
void net_drv_set_pci_param_uint(const char* pci_oid, const char* param_name, tapi_cfg_pci_param_cmode cmode, uint64_t value, const char* vpref)
Set PCI device parameter to a given value and check that its value is expected after that. In case of failure this function prints verdict and jumps to cleanup.
Parameters:
pci_oid |
PCI device OID |
param_name |
Parameter name |
cmode |
Configuration mode in which value should be set |
value |
Value to set |
vpref |
Prefix to print in verdicts in case of failure |
void net_drv_wait_up_gen(const char* ta, const char* if_name, te_bool cleanup)
Wait until link status for the IUT interface is reported to be UP in configuration tree.
Parameters:
ta |
Test Agent name |
if_name |
Interface name @oaram cleanup Whether to use verdict suitable for test section or for cleanup section |
void net_drv_ts_add_vlan(const char* ta1, const char* ta2, const char* if1, const char* if2, int af, uint16_t* vlan_id, struct sockaddr** vlan_addr1, struct sockaddr** vlan_addr2)
Create VLAN over pair of interfaces, allocate and assign IP addresses, use the same transport ports.
Parameters:
ta1 |
The first Test Agent. |
ta2 |
The second Test Agent. |
if1 |
Interface on the first Test Agent. |
if2 |
Interface on the second Test Agent. |
af |
Family of addresses to add. |
vlan_id |
Optional location with/for VLAN ID (if not |
vlan_addr1 |
Optional location for address assigned to the VLAN over the first interface. |
vlan_addr2 |
Optional location for address assigned to the VLAN over the second interface. |
te_errno net_drv_rss_send_check_stats(rcf_rpc_server* sender_rpcs, int sender_s, const struct sockaddr* sender_addr, rcf_rpc_server* receiver_rpcs, int receiver_s, const struct sockaddr* receiver_addr, rpc_socket_type sock_type, unsigned int exp_queue, unsigned int bpf_id, bool jumbo, const char* vpref)
Send a few packets and check whether expected Rx queue received them. This function clears XDP hook statistics before sending.
If both sender_addr and receiver_addr are NULL, the function assumes that XDP hook is already configured. If at least one of these parameters is not NULL, XDP hook is reconfigured to count only packets matching provided addresses and ports.
Parameters:
sender_rpcs |
Sender RPC server |
sender_s |
Sender socket |
sender_addr |
Sender address (may be |
receiver_rpcs |
Receiver RPC server |
receiver_s |
Receiver socket |
receiver_addr |
Receiver address (may be |
sock_type |
Socket type ( |
exp_queue |
Expected RSS queue ID |
bpf_id |
Id of XDP hook used to count packets |
jumbo |
If |
vpref |
Prefix to use in verdicts |
Returns:
Status code.
te_errno net_drv_rss_send_get_stats(rcf_rpc_server* sender_rpcs, int sender_s, const struct sockaddr* sender_addr, rcf_rpc_server* receiver_rpcs, int receiver_s, const struct sockaddr* receiver_addr, rpc_socket_type sock_type, unsigned int bpf_id, bool jumbo, tapi_bpf_rxq_stats** stats, unsigned int* stats_count, const char* vpref)
Send a few packets, retrieve Rx queues statistics. This function clears XDP hook statistics before sending.
If both sender_addr and receiver_addr are NULL, the function assumes that XDP hook is already configured. If at least one of these parameters is not NULL, XDP hook is reconfigured to count only packets matching provided addresses and ports.
Parameters:
sender_rpcs |
Sender RPC server |
sender_s |
Sender socket |
sender_addr |
Sender address (may be |
receiver_rpcs |
Receiver RPC server |
receiver_s |
Receiver socket |
receiver_addr |
Receiver address (may be |
sock_type |
Socket type ( |
bpf_id |
Id of XDP hook used to count packets |
jumbo |
If |
stats |
Array with retrieved statistics |
stats_count |
Number of elements in the retrieved array |
vpref |
Prefix to use in verdicts |
Returns:
Status code.
te_errno net_drv_rss_check_set_hfunc(const char* ta, const char* if_name, unsigned int rss_context, const char* func_name)
Check whether expected RSS hash function is enabled; if not, try to change configuration.
Parameters:
ta |
Test Agent name |
if_name |
Network interface name |
rss_context |
RSS context |
func_name |
Function name |
Returns:
Status code.
static void net_drv_rss_get_check_hkey(const char* ta, const char* if_name, unsigned int rss_context, uint8_t** key, size_t* len)
Get RSS hash key.
Parameters:
ta |
Test Agent name |
if_name |
Network interface name |
rss_context |
RSS context |
key |
Where to save pointer to hash key (should be released by caller) |
len |
Where to save key length |
void net_drv_rss_ctx_prepare(net_drv_rss_ctx* ctx, const char* ta, const char* if_name, unsigned int rss_ctx)
Fill fields of RSS test context.
This function can print verdict and jump to cleanup.
Parameters:
ctx |
Context structure to initialize |
ta |
Test agent name |
if_name |
Interface name |
rss_ctx |
RSS context id |
void net_drv_rss_ctx_release(net_drv_rss_ctx* ctx)
Release resources allocated for RSS test context.
Parameters:
ctx |
Pointer to context structure |
te_errno net_drv_rss_ctx_change_key(net_drv_rss_ctx* ctx, uint8_t* hash_key, unsigned int key_len)
Change hash key used for Toeplitz hash computation.
Parameters:
ctx |
Pointer to context structure |
hash_key |
New hash key |
key_len |
Key length |
Returns:
Status code.
te_errno net_drv_rss_predict(net_drv_rss_ctx* ctx, const struct sockaddr* src_addr, const struct sockaddr* dst_addr, unsigned int* hash_out, unsigned int* idx_out, unsigned int* queue_out)
Predict Toeplitz hash value, indirection table index and Rx queue id for given pairs of addresses/ports.
Parameters:
ctx |
RSS test context |
src_addr |
Source address/port |
dst_addr |
Destination address/port |
hash_out |
Where to save hash value (may be |
idx_out |
Where to save indirection table index (may be |
queue_out |
Where to save Rx queue id (may be |
Returns:
Status code.
void net_drv_rx_rules_check_table_size(const char* ta, const char* if_name, uint32_t* table_size)
Check that size of Rx rules table can be read and it is not zero. Stop the test if this check fails.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
table_size |
Retrieved table size (may be |
void net_drv_rx_rules_check_spec_loc(const char* ta, const char* if_name)
Check that special insert locations are supported. Skip the test if it is not the case.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
te_errno net_drv_rx_rules_find_loc(const char* ta, const char* if_name, int64_t* location)
Find appropriate location for a new rule, prefering TAPI_CFG_RX_RULE_ANY if special insert locations are supported.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
location |
Found location |
Returns:
Status code.
void net_drv_add_tcpudp_rx_rule(const char* ta, const char* if_name, rpc_socket_type sock_type, const struct sockaddr* src_addr, const struct sockaddr* src_mask, const struct sockaddr* dst_addr, const struct sockaddr* dst_mask, unsigned int queue, const char* rule_name)
Add a new TCP/UDP Rx classification rule at any available location.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
sock_type |
Socket type ( |
src_addr |
Source address (may be |
src_mask |
Source address mask (may be |
dst_addr |
Destination address (may be |
dst_mask |
Destination address mask (may be |
queue |
Rx queue to which to redirect packets |
rule_name |
Rule name to print in verdicts (may be empty) |
te_errno net_drv_xdp_adjust_rx_size(const char* ta, const char* if_name, net_drv_xdp_cfg* cfg)
Adjust number of Rx frames and size of Rx ring taking into account current size of Rx ring. Intel NICs drivers (X710, E810) do not work correctly unless we add enough buffers to FILL ring.
Parameters:
ta |
Test Agent name. |
if_name |
Interface name. |
cfg |
XDP configuration structure where to adjust fields. |
Returns:
Status code.
te_errno net_drv_xdp_get_queues_num(const char* ta, const char* if_name, unsigned int* rx_queues, unsigned int* tx_queues)
Get current total number of Rx and Tx queues for a network interface. The totals include dedicated and combined channels.
Parameters:
ta |
Test Agent name. |
if_name |
Interface name. |
rx_queues |
Where to save total Rx queues number. |
tx_queues |
Where to save total Tx queues number. |
Returns:
Status code.
te_errno net_drv_xdp_create_sock(rcf_rpc_server* rpcs, const char* if_name, unsigned int queue_id, net_drv_xdp_cfg* cfg, int map_fd, net_drv_xdp_sock* sock)
Create and configure AF_XDP socket.
Parameters:
rpcs |
RPC server |
if_name |
Interface name |
queue_id |
Rx queue index |
cfg |
Configuration parameters for UMEM and socket |
map_fd |
XSK map file descriptor |
sock |
Created socket data |
Returns:
Status code.
te_errno net_drv_xdp_destroy_sock(rcf_rpc_server* rpcs, net_drv_xdp_sock* sock)
Destroy AF_XDP socket created with net_drv_xdp_create_sock().
Parameters:
rpcs |
RPC server |
sock |
Pointer to socket structure |
Returns:
Status code.
void net_drv_xdp_create_socks(rcf_rpc_server* rpcs, const char* if_name, net_drv_xdp_cfg* cfg, int map_fd, unsigned int socks_num, net_drv_xdp_sock** socks_out)
Create array of AF_XDP sockets. For every socket use Rx queue of the same index and set entry of XSK map with the same index to its file descriptor.
This function prints verdict and exits in case of failure.
Parameters:
rpcs |
RPC server |
if_name |
Interface name |
cfg |
Configuration parameters for UMEM and socket |
map_fd |
XSK map file descriptor |
socks_num |
Number of sockets to create |
socks_out |
Created sockets array |
te_errno net_drv_xdp_destroy_socks(rcf_rpc_server* rpcs, net_drv_xdp_sock* socks, unsigned int socks_num)
Destroy array of AF_XDP sockets created with net_drv_xdp_create_socks().
Parameters:
rpcs |
RPC server |
socks |
Array of sockets |
socks_num |
Number of sockets |
Returns:
Status code.
void net_drv_xdp_echo(rcf_rpc_server* rpcs_udp, int s_udp, const struct sockaddr* dst_addr, rcf_rpc_server* rpcs_xdp, net_drv_xdp_sock* socks, unsigned int socks_num, unsigned int exp_sock, bool jumbo)
Send a packet from a UDP socket. Check that the expected AF_XDP socket gets that packet on a peer. Construct a reply by inverting addresses and ports of the received packet. Send it back to the UDP socket over the same AF_XDP socket if it has Tx capability, otherwise use another Tx-capable AF_XDP socket. Check that the UDP socket gets it and its payload is the same as in the previously sent packet.
This function can print verdict and fail the test.
Parameters:
rpcs_udp |
RPC server with UDP socket |
s_udp |
UDP socket |
dst_addr |
Destination address and port |
rpcs_xdp |
RPC server with AF_XDP sockets |
socks |
Array of AF_XDP sockets |
socks_num |
Number of sockets in the array |
exp_socket |
Index of the AF_XDP socket which should receive the packet |
Macros
#define NET_DRV_CLEANUP_SET_UP_WAIT(_ta, _if_name)
Cleanup macro for bringing up interface and waiting until link status for the IUT interface is reported to be UP in configuration tree.
Parameters:
ta |
Test Agent name |
if_name |
Interface name |
#define NET_DRV_CONN_INIT
Initializer for net_drv_conn structure
#define NET_DRV_DEF_PTP_INACC
Maximum inaccuracy in seconds when checking what clock_gettime() returns. It is assumed that this inaccuracy is largely due to TE delays (time required to call RPCs, etc).
#define NET_DRV_FLOW_INIT
Initializer for net_drv_flow structure
#define NET_DRV_PTP_OFFS_MAX_DEV_FROM_AVG
Maximum deviation from average time difference between PTP and system clocks when checking requests like PTP_SYS_OFFSET, in seconds.
#define NET_DRV_RESET_FLAGS
List of ETHTOOL_RESET flags for TEST_GET_ENUM_PARAM()
#define NET_DRV_RSS_CHECK_SET_HFUNC(_ta, _if_name, _rss_ctx, _func_name, _term_macro)
Make sure that specific RSS hash function is used.
Parameters:
_ta |
Test Agent name |
_if_name |
Interface name |
_rss_ctx |
RSS context |
_func_name |
Function name |
_term_macro |
Macro used to terminate the test if requested function is not known or not supported (TEST_SUCCESS, TEST_STOP, etc) |
#define NET_DRV_RSS_CTX_INIT
Initializer for net_drv_rss_ctx
#define NET_DRV_RX_RULE_LOC
List of values for rule location test parameter, to be used together with TEST_GET_ENUM_PARAM().
#define NET_DRV_WAIT_IF_STATS_UPDATE
Wait until interface statistics are updated after sending or receiving something. Increase sleep time from 1 to 2 according to X3-1135.
#define NET_DRV_WAIT_PHY_CHANGE
Wait until PHY changes are applied.
#define NET_DRV_XDP_CFG_DEF
Default configuration for AF_XDP sockets
#define NET_DRV_XDP_COPY_MODE
List of possible XDP copy mode flags for TEST_GET_ENUM_PARAM()
#define NET_DRV_XDP_SOCK_INIT
Initializer for net_drv_xdp_sock
#define NET_DRV_XDP_WAIT_SOCKS
Wait until AF_XDP sockets are fully configured