// ------------------------------------------------------------------------------------------- // Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. // This file is part of the AWS CDI-SDK, licensed under the BSD 2-Clause "Simplified" License. // License details at: https://github.com/aws/aws-cdi-sdk/blob/mainline/LICENSE // ------------------------------------------------------------------------------------------- /** * @file * @brief * The declarations in this header file correspond to the definitions in test_control.c. */ #ifndef TEST_CONTROL_H__ #define TEST_CONTROL_H__ #include #include #include "fifo_api.h" #include "cdi_pool_api.h" #include "cdi_raw_api.h" #include "test_args.h" //********************************************************************************************************************* //***************************************** START OF DEFINITIONS AND TYPES ******************************************** //********************************************************************************************************************* /// @brief The maximum length for a file name string (includes additional name characters added automatically by the /// test app. #define MAX_LOG_FILENAME_LENGTH (1024) /// @brief 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 MAX_SGL_ENTRIES_PER_PAYLOAD (7) extern CdiLoggerHandle test_app_logger_handle; /// @brief Send the log message to application's log for the connection specified by "connection_info_ptr->app_file_log_handle". #define TEST_LOG_CONNECTION(log_level, ...) \ CdiLogger(connection_info_ptr->app_file_log_handle, kLogComponentGeneric, log_level, __FUNCTION__, __LINE__, \ __VA_ARGS__) /// @brief The number of bytes in a test pattern word. #define BYTES_PER_PATTERN_WORD (sizeof(uint64_t)) /// @brief The maximum payload count in the test application, the upper byte is reserved. #define MAX_TEST_PAYLOAD_COUNT (0x00FFFFFF) /// Forward reference. typedef struct TestConnectionInfo TestConnectionInfo; /// Forward reference. typedef struct TestDynamicState* TestDynamicHandle; /** * @brief A structure for storing data to be sent with a payload as user_cb_data. */ typedef struct { /// Pointer to the TestConnection info data structure that holds state information for the given connection. TestConnectionInfo* test_connection_info_ptr; /// Time payload transmission started. uint64_t tx_payload_start_time; /// Zero-based stream index. int stream_index; /// Memory pool for Tx payload pointed to by tx_payload_sgl_ptr (see below). CdiPoolHandle tx_pool_handle; /// Pointer to SGL from the pool tx_pool_handle (see above) which describes the current Tx payload buffer. CdiSgList* tx_payload_sgl_ptr; } TestTxUserData; /** * @brief A structure for storing all connection info related to a specific stream, such as data buffer pointers * and file handles. */ typedef struct { /// File handle for file for reading payload data. CdiFileID user_data_read_file_handle; /// File handle for file to write received payload data to. CdiFileID user_data_write_file_handle; /// When riff_file=true then next_payload_size will be the size of the next payload to send. /// Otherwise next_payload_size is always equal to stream_settings->payload_size. int next_payload_size; /// Rx expected payload data buffer pointer. void* rx_expected_data_buffer_ptr; /// Payload buffer size in bytes (rounded-up from payload data size to allow for pattern creation). int payload_buffer_size; /// Tx payload memory pool buffer size in bytes required to hold all Tx payload buffers. int tx_pool_buffer_size; /// Handle of memory pool used to hold Tx payloads. CdiPoolHandle tx_pool_handle; /// The current number of payloads where config data has not been sent. Resets to 0 when matches /// test_settings->config_skip. int config_payload_skip_count; /// The current payload count for this stream. int payload_count; /// Start time for the connection. For TX this is the time of the first payload sent. For RX it is the time from the /// PTP timestamp of the first payload received. CdiPtpTimestamp connection_start_time; } TestConnectionStreamInfo; /** * @brief 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. */ struct TestConnectionInfo { /// Lock used to protect access to connection connection_handle. CdiCsID connection_handle_lock; /// The connection handle returned by the Cdi...TxCreate or Cdi...RxCreate functions. CdiConnectionHandle connection_handle; /// Array of Tx stream handles associated with this connection. Each handle is returned by the /// CdiAvmTxStreamEndpointCreate function. CdiEndpointHandle tx_stream_endpoint_handle_array[CDI_MAX_ENDPOINTS_PER_CONNECTION]; /// This connection's index; int my_index; /// The config data structure returned by the CdiRawTxCreate or CdiRawRxCreate functions. union { CdiRxConfigData rx; ///