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

This file contains internal definitions and implementation used with the SDK that is not part of the API. More...

#include "internal_tx.h"
#include <string.h>
#include "cdi_queue_api.h"
#include "endpoint_manager.h"
#include "internal.h"
#include "payload.h"
#include "private.h"
#include "statistics.h"

Functions

static uint16_t GetNextPayloadNum (CdiEndpointState *endpoint_ptr)
 
static void PutWorkRequestInPool (CdiConnectionState *con_state_ptr, TxPacketWorkRequest *work_request_ptr)
 Return work request to pool.
 
static void ProcessWorkRequestCompletionQueue (CdiConnectionState *con_state_ptr)
 
static CDI_THREAD TxPayloadThread (void *ptr)
 
static bool TxPacketWorkRequestPoolItemFree (const void *context_ptr, void *item_ptr)
 
static CdiReturnStatus TxCreateConnection (CdiConnectionProtocolType protocol_type, CdiTxConfigData *config_data_ptr, CdiCallback tx_cb_ptr, CdiConnectionHandle *ret_handle_ptr)
 
static void PayloadTransferComplete (CdiEndpointState *endpoint_ptr, TxPayloadState *payload_state_ptr)
 
static void FlushFailedPayload (CdiEndpointState *endpoint_ptr, TxPayloadState *payload_state_ptr)
 
CdiReturnStatus TxCreateInternal (CdiConnectionProtocolType protocol_type, CdiTxConfigData *config_data_ptr, CdiCallback tx_cb_ptr, CdiConnectionHandle *ret_handle_ptr)
 
CdiReturnStatus TxStreamConnectionCreateInternal (CdiTxConfigData *config_data_ptr, CdiCallback tx_cb_ptr, CdiConnectionHandle *ret_handle_ptr)
 
CdiReturnStatus TxStreamEndpointCreateInternal (CdiConnectionHandle handle, CdiTxConfigDataStream *stream_config_ptr, CdiEndpointHandle *ret_handle_ptr)
 
CdiReturnStatus TxPayloadInternal (CdiEndpointState *endpoint_ptr, const CdiCoreTxPayloadConfig *core_payload_config_ptr, const CdiSgList *sgl_ptr, int max_latency_microsecs, int extra_data_size, uint8_t *extra_data_ptr)
 
void TxPayloadThreadFlushResources (CdiEndpointState *endpoint_ptr)
 
CdiReturnStatus TxConnectionThreadJoin (CdiConnectionHandle con_handle)
 
void TxConnectionDestroyInternal (CdiConnectionHandle con_handle)
 
void TxEndpointDestroy (CdiEndpointHandle handle)
 
void TxPacketWorkRequestComplete (void *param_ptr, Packet *packet_ptr, EndpointMessageType message_type)
 
void TxInvokeAppPayloadCallback (CdiConnectionState *con_state_ptr, AppPayloadCallbackData *app_cb_data_ptr)
 

Detailed Description

This file contains internal definitions and implementation used with the SDK that is not part of the API.

Function Documentation

◆ FlushFailedPayload()

static void FlushFailedPayload ( CdiEndpointState * endpoint_ptr,
TxPayloadState * payload_state_ptr )
static

Flush a payload that did not complete transferring. This will set the payload's status and queue a payload message to the application.

Parameters
endpoint_ptrPointer to endpoint state data.
payload_state_ptrPointer to payload state data. The pointer is not longer valid after function returns.

◆ GetNextPayloadNum()

static uint16_t GetNextPayloadNum ( CdiEndpointState * endpoint_ptr)
static

Return the next payload number to use for the specified connection. This is an incrementing value.

Parameters
endpoint_ptrPointer to endpoint state data.
Returns
The payload number.

◆ PayloadTransferComplete()

static void PayloadTransferComplete ( CdiEndpointState * endpoint_ptr,
TxPayloadState * payload_state_ptr )
static

Payload transfer has completed either successfully or in error. Update stats and queue payload message to application.

Parameters
endpoint_ptrPointer to endpoint state data.
payload_state_ptrPointer to payload state data. The pointer is no longer valid after function returns.

◆ ProcessWorkRequestCompletionQueue()

static void ProcessWorkRequestCompletionQueue ( CdiConnectionState * con_state_ptr)
static

Pop all items in the work request completion queue freeing resources associated with each one.

Parameters
con_state_ptrPointer to connection state data.

◆ PutWorkRequestInPool()

static void PutWorkRequestInPool ( CdiConnectionState * con_state_ptr,
TxPacketWorkRequest * work_request_ptr )
static

Return work request to pool.

Parameters
con_state_ptrPointer to connection state structure.
work_request_ptrPointer to work request structure.

◆ TxConnectionDestroyInternal()

void TxConnectionDestroyInternal ( CdiConnectionHandle con_handle)

◆ TxConnectionThreadJoin()

CdiReturnStatus TxConnectionThreadJoin ( CdiConnectionHandle con_handle)

Join Tx connection threads as part of shutting down a connection. This function waits for them to stop.

Parameters
con_handleConnection handle.

◆ TxCreateConnection()

static CdiReturnStatus TxCreateConnection ( CdiConnectionProtocolType protocol_type,
CdiTxConfigData * config_data_ptr,
CdiCallback tx_cb_ptr,
CdiConnectionHandle * ret_handle_ptr )
static

Create an instance of a connection.

Parameters
protocol_typeConnection protocol type.
config_data_ptrPointer to transmitter configuration data.
tx_cb_ptrAddress of the user function to call whenever a payload being transmitted has been received by the receiver.
ret_handle_ptrPointer to returned connection handle.
Returns
A value from the CdiReturnStatus enumeration.

◆ TxCreateInternal()

CdiReturnStatus TxCreateInternal ( CdiConnectionProtocolType protocol_type,
CdiTxConfigData * config_data_ptr,
CdiCallback tx_cb_ptr,
CdiConnectionHandle * ret_handle_ptr )
See also
CdiRawTxCreate

◆ TxEndpointDestroy()

void TxEndpointDestroy ( CdiEndpointHandle handle)

Destroy resources associated with the specified endpoint.

Parameters
handleHandle of endpoint to destroy.

◆ TxInvokeAppPayloadCallback()

void TxInvokeAppPayloadCallback ( CdiConnectionState * con_state_ptr,
AppPayloadCallbackData * app_cb_data_ptr )

Invoke the user registered Tx callback function for a payload.

Parameters
con_state_ptrPointer to connection state data.
app_cb_data_ptrPointer to application callback data.

◆ TxPacketWorkRequestComplete()

void TxPacketWorkRequestComplete ( void * param_ptr,
Packet * packet_ptr,
EndpointMessageType message_type )

A packet has been acknowledged as being received by the receiver. The SGL needs to be freed and we need to determine when the entire payload has been freed and then tell the application.

Parameters
param_ptrPointer to connection that the packet was transmitted on as a void*.
packet_ptrPointer to packet state data.
message_typeEndpoint message type.

◆ TxPacketWorkRequestPoolItemFree()

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

Free function for Tx packet work request pool item.

Parameters
context_ptrUnused, reserve for future use.
item_ptrPointer to item being initialized.
Returns
true always

◆ TxPayloadInternal()

CdiReturnStatus TxPayloadInternal ( CdiEndpointState * endpoint_ptr,
const CdiCoreTxPayloadConfig * core_payload_config_ptr,
const CdiSgList * sgl_ptr,
int max_latency_microsecs,
int extra_data_size,
uint8_t * extra_data_ptr )
See also
CdiRawTxPayload

◆ TxPayloadThread()

static CDI_THREAD TxPayloadThread ( void * ptr)
static

Payload thread used to transmit a payload.

Parameters
ptrPointer to thread specific data. In this case, a pointer to CdiConnectionState.
Returns
The return value is not used.

◆ TxPayloadThreadFlushResources()

void TxPayloadThreadFlushResources ( CdiEndpointState * endpoint_ptr)

Flush resources associate with TxPayloadThread(). NOTE: This function should only be called after the thread has been paused using EndpointManagerThreadWait().

Parameters
endpoint_ptrPointer to endpoint to flush resources.

◆ TxStreamConnectionCreateInternal()

CdiReturnStatus TxStreamConnectionCreateInternal ( CdiTxConfigData * config_data_ptr,
CdiCallback tx_cb_ptr,
CdiConnectionHandle * ret_handle_ptr )

◆ TxStreamEndpointCreateInternal()

CdiReturnStatus TxStreamEndpointCreateInternal ( CdiConnectionHandle handle,
CdiTxConfigDataStream * stream_config_ptr,
CdiEndpointHandle * ret_handle_ptr )