CDI SDK
SDK for transporting chunks of data reliably and with low latency using a polled mode network driver.
Loading...
Searching...
No Matches
test_control.h File Reference

The declarations in this header file correspond to the definitions in test_control.c. More...

#include <stdbool.h>
#include <stdint.h>
#include "fifo_api.h"
#include "cdi_pool_api.h"
#include "cdi_raw_api.h"
#include "test_args.h"

Go to the source code of this file.

Data Structures

struct  TestTxUserData
 A structure for storing data to be sent with a payload as user_cb_data. More...
 
struct  TestConnectionStreamInfo
 A structure for storing all connection info related to a specific stream, such as data buffer pointers and file handles. More...
 
struct  TestConnectionInfo
 A structure for storing all info related to a specific connection, including test settings, connection configuration data from the SDK, and state information for the test connection. More...
 

Macros

#define MAX_LOG_FILENAME_LENGTH   (1024)
 The maximum length for a file name string (includes additional name characters added automatically by the test app.
 
#define MAX_SGL_ENTRIES_PER_PAYLOAD   (7)
 The fixed number of SGL entries we will try to use when in SGL mode. If payload is too small to be broken into this number of SGL entries, then we will use a smaller number of entries that can accommodate the given payload. Must be greater than 0.
 
#define TEST_LOG_CONNECTION(log_level, ...)
 Send the log message to application's log for the connection specified by "connection_info_ptr->app_file_log_handle".
 
#define BYTES_PER_PATTERN_WORD   (sizeof(uint64_t))
 The number of bytes in a test pattern word.
 
#define MAX_TEST_PAYLOAD_COUNT   (0x00FFFFFF)
 The maximum payload count in the test application, the upper byte is reserved.
 
#define CDI_BYTES_PER_AUDIO_SAMPLE   (3)
 Number of bytes in CDI audio sample. CDI requests 24-bit int for audio, so needs three bytes.
 

Typedefs

typedef struct TestConnectionInfo TestConnectionInfo
 Forward reference.
 
typedef struct TestDynamicStateTestDynamicHandle
 Forward reference.
 

Functions

bool TestWaitForConnection (TestConnectionInfo *connection_info_ptr, int timeout_seconds)
 
void TestConnectionCallback (const CdiCoreConnectionCbData *cb_data_ptr)
 
void TestStatisticsCallback (const CdiCoreStatsCbData *cb_data_ptr)
 
void TestIncPayloadCount (TestConnectionInfo *connection_info_ptr, int stream_index)
 
bool PreparePayloadData (StreamSettings *stream_settings_ptr, int payload_buffer_size, CdiFileID *read_file_handle_ptr, void *buffer_ptr)
 
bool GetNextPayloadDataSgl (const TestConnectionInfo *connection_info_ptr, const StreamSettings *stream_settings_ptr, int payload_id, CdiFileID read_file_handle, CdiSgList *sgl_ptr)
 
bool GetNextPayloadDataLinear (const TestConnectionInfo *connection_info_ptr, const StreamSettings *stream_settings_ptr, TestConnectionStreamInfo *stream_info_ptr)
 
bool TestCreateConnectionLogFiles (TestConnectionInfo *connection_info_ptr, CdiLogMethodData *log_method_data_ptr, char *sdk_log_filename_buffer_str)
 
bool IsPayloadNumLessThanTotal (int current_payload_num, int total_payloads)
 
CdiPtpTimestamp GetVideoPtpTimestamp (const TestConnectionInfo *connection_info_ptr, const TestConnectionStreamInfo *stream_info_ptr, int ptp_rate_count)
 Get the next video PTP timestamp to use in the payload origination_ptp_timestamp.
 
CdiPtpTimestamp GetAudioPtpTimestamp (const StreamSettings *stream_settings_ptr, TestConnectionStreamInfo *stream_info_ptr, int audio_data_size)
 Get the next audio PTP timestamp to use in the payload origination_ptp_timestamp.
 
void LogTimestamps (const StreamSettings *stream_settings_ptr, TestConnectionStreamInfo *stream_info_ptr, CdiPtpTimestamp current_ptp_timestamp)
 Log timestamp, if enabled.
 

Variables

CdiLoggerHandle test_app_logger_handle
 Handle to log for test.
 

Detailed Description

The declarations in this header file correspond to the definitions in test_control.c.

Macro Definition Documentation

◆ TEST_LOG_CONNECTION

#define TEST_LOG_CONNECTION ( log_level,
... )
Value:
CdiLogger(connection_info_ptr->app_file_log_handle, kLogComponentGeneric, log_level, __FUNCTION__, __LINE__, \
__VA_ARGS__)
@ kLogComponentGeneric
Generic component.
Definition cdi_log_enums.h:36
CDI_INTERFACE void CdiLogger(CdiLogHandle handle, CdiLogComponent component, CdiLogLevel log_level, const char *function_name_str, int line_number, const char *format_str,...)
Definition logger.c:862

Send the log message to application's log for the connection specified by "connection_info_ptr->app_file_log_handle".

Function Documentation

◆ GetAudioPtpTimestamp()

CdiPtpTimestamp GetAudioPtpTimestamp ( const StreamSettings * stream_settings_ptr,
TestConnectionStreamInfo * stream_info_ptr,
int audio_data_size )

Get the next audio PTP timestamp to use in the payload origination_ptp_timestamp.

Parameters
stream_settings_ptrPointer to stream settings info.
stream_info_ptrPointer to stream info.
audio_data_sizeSize of audio data in bytes.
Returns
A PTP timestamp for the next payload to send.

◆ GetNextPayloadDataLinear()

bool GetNextPayloadDataLinear ( const TestConnectionInfo * connection_info_ptr,
const StreamSettings * stream_settings_ptr,
TestConnectionStreamInfo * stream_info_ptr )

Prepare next set of payload data. This is either reading the next payload from the file or incrementing the payload identifier value when using patterns.

Parameters
connection_info_ptrPointer to test connection information.
stream_settings_ptrPointer to stream settings.
stream_info_ptrPointer to stream state.
Returns
if successful return true, otherwise returns false.

◆ GetNextPayloadDataSgl()

bool GetNextPayloadDataSgl ( const TestConnectionInfo * connection_info_ptr,
const StreamSettings * stream_settings_ptr,
int payload_id,
CdiFileID read_file_handle,
CdiSgList * sgl_ptr )

Prepare next set of payload data. This is either reading the next payload from the file or incrementing the payload identifier value when using patterns.

Parameters
connection_info_ptrPointer to test connection information.
stream_settings_ptrPointer to stream settings.
payload_idPayload identifier.
read_file_handleThe file handle for reading the next pattern from, if the pattern type is from file.
sgl_ptrPointer to an SGL describing the buffer to be filled with payload data.
Returns
if successful return true, otherwise returns false.

◆ GetVideoPtpTimestamp()

CdiPtpTimestamp GetVideoPtpTimestamp ( const TestConnectionInfo * connection_info_ptr,
const TestConnectionStreamInfo * stream_info_ptr,
int ptp_rate_count )

Get the next video PTP timestamp to use in the payload origination_ptp_timestamp.

Parameters
connection_info_ptrPointer to test connection information.
stream_info_ptrPointer to stream info.
ptp_rate_countCurrent PTP rate counter value.
Returns
A PTP timestamp for the next payload to send.

◆ IsPayloadNumLessThanTotal()

bool IsPayloadNumLessThanTotal ( int current_payload_num,
int total_payloads )

Check whether the current payload number is less that the total payloads allowed.

Parameters
current_payload_numNumber that represents the current payload number.
total_payloadsNumber that represents the total number of payloads for this connection (0 is infinite).
Returns
bool Indicates if the current payload number is less than the total number of payloads. This is always true if infinite payloads.

◆ LogTimestamps()

void LogTimestamps ( const StreamSettings * stream_settings_ptr,
TestConnectionStreamInfo * stream_info_ptr,
CdiPtpTimestamp current_ptp_timestamp )

Log timestamp, if enabled.

Parameters
stream_settings_ptrPointer to stream settings.
stream_info_ptrPointer to stream info.
current_ptp_timestampCurrent PTP timestamp value to log.

◆ PreparePayloadData()

bool PreparePayloadData ( StreamSettings * stream_settings_ptr,
int payload_buffer_size,
CdiFileID * read_file_handle_ptr,
void * buffer_ptr )

Prepare next set of payload data. This is either reading the next payload from the file or incrementing the payload identifier value when using patterns. This function is shared for managing both Tx and Rx buffer patterns.

Parameters
stream_settings_ptrPointer to stream settings.
payload_buffer_sizePayload buffer size, rounded up to multiple of 8 bytes.
read_file_handle_ptrPointer to the user read data file handle which this function will set.
buffer_ptrPointer to buffer of payload size to be filled with initial pattern words if using patterns.
Returns
if successful return true, otherwise returns false.

◆ TestConnectionCallback()

void TestConnectionCallback ( const CdiCoreConnectionCbData * cb_data_ptr)

Handle the connection callback.

Parameters
cb_data_ptrPointer to core connection callback data.

◆ TestCreateConnectionLogFiles()

bool TestCreateConnectionLogFiles ( TestConnectionInfo * connection_info_ptr,
CdiLogMethodData * log_method_data_ptr,
char * sdk_log_filename_buffer_str )

Create a unique log file name for this application's connection and associate it with the current thread. This allows use of the CDI_LOG_THREAD() macro to direct log messages to the logger.

Parameters
connection_info_ptrPointer to test connection information.
log_method_data_ptrPointer to log method data.
sdk_log_filename_buffer_strPointer to buffer for return SDK log filename.
Returns
bool Returns true if successful, otherwise false is returned.

◆ TestIncPayloadCount()

void TestIncPayloadCount ( TestConnectionInfo * connection_info_ptr,
int stream_index )

Increment the connection's payload counter and mark done if we hit the user-specified total_payloads.

Parameters
connection_info_ptrPointer to connection info data for which we want to increment the payload count.
stream_indexStream index.

◆ TestStatisticsCallback()

void TestStatisticsCallback ( const CdiCoreStatsCbData * cb_data_ptr)

Handle the statistics callback.

Parameters
cb_data_ptrPointer to statistics callback data.

◆ TestWaitForConnection()

bool TestWaitForConnection ( TestConnectionInfo * connection_info_ptr,
int timeout_seconds )

Wait until the connection has been established.

Parameters
connection_info_ptrPointer to connection info data for which to wait for a connection.
timeout_secondsTimeout in seconds.
Returns
Returns true if successful, false if the timeout occurred while waiting.