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

This file contains definitions and functions for the transmit-side CDI test application logic. More...

#include "test_transmitter.h"
#include <assert.h>
#include <inttypes.h>
#include "configuration.h"
#include "cdi_avm_api.h"
#include "cdi_core_api.h"
#include "cdi_logger_api.h"
#include "cdi_os_api.h"
#include "cdi_raw_api.h"
#include "cdi_utility_api.h"
#include "cdi_test.h"
#include "riff.h"
#include "test_common.h"
#include "test_control.h"
#include "test_dynamic.h"
#include "utilities_api.h"

Data Structures

struct  InitFunctionArgs
 Structure used to pass arguments to InitStaticBufferContents() through CdiPoolForEachItem(). More...
 
struct  TestTxThreadLocalData
 Container for any data we need separate for each Tx thread. More...
 

Macros

#define SGL_ENTRY_SIZE_CALC_PERCENT   (90)
 When computing SGL entry size, this chooses what percent to reduce each entry by compared to the last.
 

Functions

static bool TestWaitSignalOrAbort (const CdiSignalType this_signal, const CdiSignalType abort_signal, const int timeout_ms)
 
static void FreePayloadResources (TestConnectionInfo *connection_info_ptr, TestTxUserData *user_data_ptr)
 
static int cdi_min (int a, int b)
 Helper for RightSizeSgl.
 
static CdiSgListRightSizeSgl (CdiSgList const *source_sgl_ptr, int new_size, TestTxThreadLocalData *tx_data_ptr)
 
static bool ValidateSgl (CdiSgList const *sgl_ptr, CdiBufferType buffer_type, int expected_size)
 
static CdiReturnStatus TestTxSendPayload (TestConnectionInfo *connection_info_ptr, int stream_index, int payload_count, int ptp_rate_count, bool resend)
 
static bool TestTxTrySendStreamPayload (TestConnectionInfo *connection_info_ptr, int stream_index, int payload_count, uint64_t rate_next_start_time, int ptp_rate_count, bool *is_queued_ptr)
 
static void WaitForTxPayloadsToComplete (TestConnectionInfo *connection_info_ptr, int payload_count, uint32_t timeout_ms)
 
static bool TestTxSendAllPayloads (TestConnectionInfo *connection_info_ptr)
 
static bool InitStaticBufferContents (const void *context_ptr, void *item_ptr)
 
static bool TestTxSendTestData (TestConnectionInfo *connection_info_ptr)
 
static void TestTxProcessCoreCallbackData (const CdiCoreCbData *core_cb_data_ptr, int stream_index)
 
static void TestRawTxCallback (const CdiRawTxCbData *cb_data_ptr)
 
static void TestAvmTxCallback (const CdiAvmTxCbData *cb_data_ptr)
 
CDI_THREAD TestTxCreateThread (void *arg_ptr)
 

Detailed Description

This file contains definitions and functions for the transmit-side CDI test application logic.

See CDI Test Application Architecture Transmit Logic for diagrams and detailed description of the transmit-side program flow.

Function Documentation

◆ FreePayloadResources()

static void FreePayloadResources ( TestConnectionInfo * connection_info_ptr,
TestTxUserData * user_data_ptr )
static

Free resources used for a payload.

Parameters
connection_info_ptrPointer to connection info state data.
user_data_ptrPointer to Tx user data structure passed along with a payload.

◆ InitStaticBufferContents()

static bool InitStaticBufferContents ( const void * context_ptr,
void * item_ptr )
static

Pool operator function used to initialize transmit buffers when their contents are static patterns. All it does is copies a linear source buffer into a destination as described by the SGL passed in through item_ptr.

Parameters
context_ptrpointer to the linear source buffer address and size.
item_ptrthe address of the SGL which describes the destination buffer.
Returns
bool true always.

◆ RightSizeSgl()

static CdiSgList * RightSizeSgl ( CdiSgList const * source_sgl_ptr,
int new_size,
TestTxThreadLocalData * tx_data_ptr )
static

Return a new, static SGL of smaller buffer size but pointing to the same buffer.

Parameters
source_sgl_ptrPointer to the source SGL.
new_sizeSize of the new SGL to be constructed.
tx_data_ptrPointer to thread-local data.
Returns
Static SGL of specified size.

◆ TestAvmTxCallback()

static void TestAvmTxCallback ( const CdiAvmTxCbData * cb_data_ptr)
static

Handle the Tx AVM callback.

Parameters
cb_data_ptrPointer to Tx AVM callback data.

◆ TestRawTxCallback()

static void TestRawTxCallback ( const CdiRawTxCbData * cb_data_ptr)
static

Handle the Tx RAW callback.

Parameters
cb_data_ptrPointer to Tx RAW callback data.

◆ TestTxCreateThread()

CDI_THREAD TestTxCreateThread ( void * arg_ptr)

Start up the test transmit connection as requested by the user, delaying if required, and then launch TestTxSendAllPayloads.

Parameters
arg_ptrVoid pointer to the connection_info data structure for this connection.
Returns
True if no errors; false if errors;

◆ TestTxProcessCoreCallbackData()

static void TestTxProcessCoreCallbackData ( const CdiCoreCbData * core_cb_data_ptr,
int stream_index )
static

Process core data from Tx callback that is common to both connection protocol types (RAW and AVM). If error, log error message and mark the connection as failed. If no error, then check the transmitted payload against expected test parameters.

Parameters
core_cb_data_ptrPointer to core callback data.
stream_indexZero-based stream index.

◆ TestTxSendAllPayloads()

static bool TestTxSendAllPayloads ( TestConnectionInfo * connection_info_ptr)
static

Send all payloads for this connection as requested by the user.

Parameters
connection_info_ptrPointer to the TestConnectionInfo data structure describing this connection.
Returns
True if no errors; false if errors;

◆ TestTxSendPayload()

static CdiReturnStatus TestTxSendPayload ( TestConnectionInfo * connection_info_ptr,
int stream_index,
int payload_count,
int ptp_rate_count,
bool resend )
static

Construct a payload of the requested type and send it to the SDK.

Parameters
connection_info_ptrPointer to the TestConnectionInfo data structure describing this connection.
stream_indexIndex of stream.
payload_countCurrent payload number.
ptp_rate_countCurrent PTP rate count.
resendIf resending the same payload use true, otherwise false.
Returns
A value from the CdiReturnStatus enumeration.

◆ TestTxSendTestData()

static bool TestTxSendTestData ( TestConnectionInfo * connection_info_ptr)
static

This function prepares for and sends all data for this transmitter connection, and then reports transfer statistics.

Parameters
connection_info_ptrPointer to the TestConnectionInfo data structure describing this connection.
Returns
True if no errors; false if errors;

◆ TestTxTrySendStreamPayload()

static bool TestTxTrySendStreamPayload ( TestConnectionInfo * connection_info_ptr,
int stream_index,
int payload_count,
uint64_t rate_next_start_time,
int ptp_rate_count,
bool * is_queued_ptr )
static

Try to send a payload for a given stream, handling retries and timeouts.

Parameters
connection_info_ptrPointer to the TestConnectionInfo data structure describing this connection.
stream_indexThe current stream number.
payload_countThe current payload number.
rate_next_start_timeThe time that the current payload period is set to expire.
ptp_rate_countThe current PTP rate count.
is_queued_ptrAddress where to write returned queue status. Writes true if queued, otherwise writes false.
Returns
True if no errors; false if errors;

◆ TestWaitSignalOrAbort()

static bool TestWaitSignalOrAbort ( const CdiSignalType this_signal,
const CdiSignalType abort_signal,
const int timeout_ms )
static

This function is used when we are waiting for a signal, but also want to abort on a single other abort signal.

Parameters
this_signalThe signal we are waiting for.
abort_signalThe signal that will abort this wait.
timeout_msA timeout in milliseconds that will also cause an abort if it is reached.
Returns
true if this_signal is set first; false if either abort_signal is set first or we time out.

◆ ValidateSgl()

static bool ValidateSgl ( CdiSgList const * sgl_ptr,
CdiBufferType buffer_type,
int expected_size )
static

Check all requirements for the payload SGL generated by InitPoolSgl in run_test_generic.c.

Parameters
sgl_ptrPointer to SGL to validate.
buffer_typeThe configured buffer type.
expected_sizeExpected buffer size.
Returns
True if and only if the SGL is as expected.

◆ WaitForTxPayloadsToComplete()

static void WaitForTxPayloadsToComplete ( TestConnectionInfo * connection_info_ptr,
int payload_count,
uint32_t timeout_ms )
static

Wait for Tx payloads that have been queued to transmit to complete (waits for pending Tx payload callbacks).

Parameters
connection_info_ptrPointer to the TestConnectionInfo data structure describing this connection.
payload_countThe current payload number.
timeout_msMaximum time to wait in milliseconds.