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"
|
#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.
|
|
|
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 CdiSgList * | RightSizeSgl (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) |
|
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.
◆ FreePayloadResources()
Free resources used for a payload.
- Parameters
-
connection_info_ptr | Pointer to connection info state data. |
user_data_ptr | Pointer 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_ptr | pointer to the linear source buffer address and size. |
item_ptr | the address of the SGL which describes the destination buffer. |
- Returns
- bool true always.
◆ RightSizeSgl()
Return a new, static SGL of smaller buffer size but pointing to the same buffer.
- Parameters
-
source_sgl_ptr | Pointer to the source SGL. |
new_size | Size of the new SGL to be constructed. |
tx_data_ptr | Pointer to thread-local data. |
- Returns
- Static SGL of specified size.
◆ TestAvmTxCallback()
Handle the Tx AVM callback.
- Parameters
-
cb_data_ptr | Pointer to Tx AVM callback data. |
◆ TestRawTxCallback()
Handle the Tx RAW callback.
- Parameters
-
cb_data_ptr | Pointer to Tx RAW callback data. |
◆ TestTxCreateThread()
Start up the test transmit connection as requested by the user, delaying if required, and then launch TestTxSendAllPayloads.
- Parameters
-
arg_ptr | Void 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_ptr | Pointer to core callback data. |
stream_index | Zero-based stream index. |
◆ TestTxSendAllPayloads()
Send all payloads for this connection as requested by the user.
- Parameters
-
connection_info_ptr | Pointer to the TestConnectionInfo data structure describing this connection. |
- Returns
- True if no errors; false if errors;
◆ TestTxSendPayload()
Construct a payload of the requested type and send it to the SDK.
- Parameters
-
connection_info_ptr | Pointer to the TestConnectionInfo data structure describing this connection. |
stream_index | Index of stream. |
payload_count | Current payload number. |
ptp_rate_count | Current PTP rate count. |
resend | If resending the same payload use true, otherwise false. |
- Returns
- A value from the CdiReturnStatus enumeration.
◆ TestTxSendTestData()
This function prepares for and sends all data for this transmitter connection, and then reports transfer statistics.
- Parameters
-
connection_info_ptr | Pointer 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_ptr | Pointer to the TestConnectionInfo data structure describing this connection. |
stream_index | The current stream number. |
payload_count | The current payload number. |
rate_next_start_time | The time that the current payload period is set to expire. |
ptp_rate_count | The current PTP rate count. |
is_queued_ptr | Address where to write returned queue status. Writes true if queued, otherwise writes false. |
- Returns
- True if no errors; false if errors;
◆ TestWaitSignalOrAbort()
This function is used when we are waiting for a signal, but also want to abort on a single other abort signal.
- Parameters
-
this_signal | The signal we are waiting for. |
abort_signal | The signal that will abort this wait. |
timeout_ms | A 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()
Check all requirements for the payload SGL generated by InitPoolSgl in run_test_generic.c.
- Parameters
-
sgl_ptr | Pointer to SGL to validate. |
buffer_type | The configured buffer type. |
expected_size | Expected 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_ptr | Pointer to the TestConnectionInfo data structure describing this connection. |
payload_count | The current payload number. |
timeout_ms | Maximum time to wait in milliseconds. |