Global Namespace

Overview

// typedefs

typedef struct net_drv_conn net_drv_conn;
typedef struct net_drv_flow net_drv_flow;
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_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);
void net_drv_open_ptp_fd(rcf_rpc_server* rpcs, const char* if_name, int* fd, const char* vpref);
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);
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);
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_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_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, 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, 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_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);

// 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_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_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 NULL, flags not cleared by ioctl() will be saved here

Returns:

Result of rpc_ioctl().

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 NULL or empty)

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

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

RPC_SOCK_STREAM or RPC_SOCK_DGRAM - defines whether created rule is for TCP or for UDP.

any_location

If TRUE, use special "any" location when adding a rule. Otherwise set specific location.

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 TRUE, load the module, otherwise unload it.

Returns:

Status code.

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: 0 (disabled) or 1 (enabled)

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: 0 (disabled) or 1 (enabled)

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_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 NULL, sendto() should be called with this destination.

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 NULL, sendto() should be called with this destination.

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 0 then use default

path_fmt...

Path format string and arguments.

Returns:

Status code.

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 ETHER_ADDR_LEN bytes).

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 NULL and value is not 0, use specified ID, otherwise allocate random and return it here).

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, 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 NULL)

receiver_rpcs

Receiver RPC server

receiver_s

Receiver socket

receiver_addr

Receiver address (may be NULL)

sock_type

Socket type (RPC_SOCK_STREAM, RPC_SOCK_DGRAM)

exp_queue

Expected RSS queue ID

bpf_id

Id of XDP hook used to count packets

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, 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 NULL)

receiver_rpcs

Receiver RPC server

receiver_s

Receiver socket

receiver_addr

Receiver address (may be NULL)

sock_type

Socket type (RPC_SOCK_STREAM, RPC_SOCK_DGRAM)

bpf_id

Id of XDP hook used to count packets

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 NULL)

idx_out

Where to save indirection table index (may be NULL)

queue_out

Where to save Rx queue id (may be NULL)

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 NULL)

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 (RPC_SOCK_STREAM or RPC_SOCK_DGRAM)

src_addr

Source address (may be NULL)

src_mask

Source address mask (may be NULL)

dst_addr

Destination address (may be NULL)

dst_mask

Destination address mask (may be NULL)

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_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)

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. 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_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