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

This file contains the definitions of the functions that comprise the CDI Core SDK's API. More...

#include "cdi_core_api.h"
#include "internal.h"
#include "internal_rx.h"

Functions

CdiReturnStatus CdiCoreInitialize (const CdiCoreConfigData *core_config_ptr)
 
CdiReturnStatus CdiCoreNetworkAdapterInitialize (CdiAdapterData *adapter_data_ptr, CdiAdapterHandle *ret_handle_ptr)
 
CdiReturnStatus CdiCoreNetworkAdapterDestroy (CdiAdapterHandle handle)
 
CdiReturnStatus CdiCoreRxFreeBuffer (const CdiSgList *sgl_ptr)
 
int CdiCoreGather (const CdiSgList *sgl_ptr, int offset, void *dest_data, int byte_count)
 
CdiReturnStatus CdiCoreStatsReconfigure (CdiConnectionHandle handle, const CdiStatsConfigData *config_ptr)
 
CdiReturnStatus CdiCoreConnectionDestroy (CdiConnectionHandle handle)
 
CdiReturnStatus CdiCoreShutdown (void)
 
void CdiCoreGetUtcTime (struct timespec *ret_time_ptr)
 
CdiPtpTimestamp CdiCoreGetPtpTimestamp (CdiPtpTimestamp *ret_ptp_time_ptr)
 Get the current TAI time as a PTP timestamp.
 
uint64_t CdiCoreGetUtcTimeMicroseconds (void)
 
uint64_t CdiCoreGetTaiTimeMicroseconds (void)
 
const char * CdiCoreStatusToString (CdiReturnStatus status)
 
const CdiCoreReadOnlySettingsCdiCoreGetSettings ()
 

Detailed Description

This file contains the definitions of the functions that comprise the CDI Core SDK's API.

Function Documentation

◆ CdiCoreConnectionDestroy()

CdiReturnStatus CdiCoreConnectionDestroy ( CdiConnectionHandle handle)

Destroy a specific TX or RX connection and free resources that were created for it.

Parameters
handleConnection handle returned by Cdi...TxCreate() API functions.
Returns
A value from the CdiReturnStatus enumeration.

◆ CdiCoreGather()

int CdiCoreGather ( const CdiSgList * sgl_ptr,
int offset,
void * dest_data_ptr,
int byte_count )

Gather received data represented by a scatter-gather list into a contiguous buffer. The caller is responsible for ensuring that the destination buffer is large enough to hold the data.

A subset of the entire payload of the SGL can be extracted by using a non-zero value for offset and/or a smaller number for byte_count than sgl->total_data_size. The number of bytes copied is the smaller of (sgl->total_data_size - offset) or byte_count.

Parameters
sgl_ptrThe scatter-gather list containing the data to be gathered.
offsetNumber of bytes to skip in SGL before starting the copy.
dest_data_ptrWhere to write the gathered data in linear format.
byte_countThe number of bytes to copy.
Returns
The number of bytes copied. This will be less than byte_count if fewer than that number of bytes are present in the source SGL starting from the specified offset. A value of -1 indicates that a fatal error was encountered such as NULL values for sgl_ptr or dest_data_ptr.

◆ CdiCoreGetPtpTimestamp()

CdiPtpTimestamp CdiCoreGetPtpTimestamp ( CdiPtpTimestamp * ret_ptp_time_ptr)

Get the current TAI time as a PTP timestamp.

There seems to be no trivial solutions for automatically getting the current leap second adjustment. All leap second adjustments occur on either December 31st or June 30th. The next possible leap second introduction is June 30th 2021. This function applies a fixed 37 second adjustment to UTC time to get TAI time.

Parameters
ret_ptp_time_ptrPointer to CdiPtpTimestamp to return the current PtpTimestamp to. This may be NULL.
Returns
The same value that is written to the location pointed to by ret_ptp_time_ptr.

◆ CdiCoreGetSettings()

const CdiCoreReadOnlySettings * CdiCoreGetSettings ( )

Returns the core configuration read-only settings.

Returns
Pointer to const structure that contains the settings.

◆ CdiCoreGetTaiTimeMicroseconds()

uint64_t CdiCoreGetTaiTimeMicroseconds ( )

Get the current TAI time in microseconds.

Returns
Current TAI time in microseconds.

◆ CdiCoreGetUtcTime()

void CdiCoreGetUtcTime ( struct timespec * ret_time_ptr)

Get the current synced AWS network UTC time in a timespec structure. This function will be kept up to date with the best practices for getting high accuracy time from Amazon Time Sync Service as improved accuracy time is available. All EC2 instances that call this function should be using the Amazon Time Sync Service. Amazon Time Sync Service setup directions for Linux can be found at: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/set-time.html#configure-amazon-time-service. For Windows follow the directions at: https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/windows-set-time.html

Parameters
ret_time_ptrAddress where to write the UTC timestamp in a timespec structure as defined by time.h.

◆ CdiCoreGetUtcTimeMicroseconds()

uint64_t CdiCoreGetUtcTimeMicroseconds ( void )

Get the current synced AWS network UTC time in microseconds. It uses CdiCoreGetUtcTime().

Returns
Current UTC time in microseconds.

◆ CdiCoreInitialize()

CdiReturnStatus CdiCoreInitialize ( const CdiCoreConfigData * core_config_ptr)

Initialize the SDK. Must be called once before using any other SDK APIs. When done, must call CdiCoreShutdown() once.

NOTE: Newly created data structures that are passed in to this function should be properly initialized before being programmed with user values. Use memset or a zero structure initializer (= {0}) to set the whole structure to zero before setting the desired members to the actual values required.

Parameters
core_config_ptrPointer to core configuration data that is used to initialize the SDK. Value is required and cannot be NULL. Copies of the data in the configuration data structure are made as needed. A local variable can be used for composing the structure since its contents are not needed after this function returns.
Returns
A value from the CdiReturnStatus enumeration.

◆ CdiCoreNetworkAdapterDestroy()

CdiReturnStatus CdiCoreNetworkAdapterDestroy ( CdiAdapterHandle handle)

Free resources associated with the specified network adapter that was previously created using CdiCoreNetworkAdapterInitialize(). NOTE: Before calling this function, all connections that use the adapter should be closed using CdiCoreConnectionDestroy().

Parameters
handleHandle of network adapter to destroy.
Returns
A value from the CdiReturnStatus enumeration.

◆ CdiCoreNetworkAdapterInitialize()

CdiReturnStatus CdiCoreNetworkAdapterInitialize ( CdiAdapterData * adapter_data_ptr,
CdiAdapterHandle * ret_handle_ptr )

Create an instance of a network adapter. CdiCoreNetworkAdapterDestroy() must be called before CdiCoreShutdown() but after all connections using the adapter are closed using CdiCoreConnectionDestroy().

NOTE: Currently if the shared memory provider is enabled in the EFA Adapter (see FI_EFA_ENABLE_SHM_TRANSFER in CDI), libfabric uses fork() to determine capability (see rxr_check_cma_capability() in the EFA provider). This causes a double flush of cached write data of any open files. By default, the shared memory provider is disabled. If enabled, all open files must have used fflush() prior to using this API function. The CDI SDK always flushes all open log files that were created using the CDI logger API functions.

NOTE: Newly created data structures that are passed in to this function should be properly initialized before being programmed with user values. Use memset or a zero structure initializer (= {0}) to set the whole structure to zero before setting the desired members to the actual values required.

Parameters
adapter_data_ptrPointer to network adapter configuration data. Copies of the data in the configuration data structure are made as needed. A local variable can be used for composing the structure since its contents are not needed after this function returns.
ret_handle_ptrPointer to returned instance handle (used as parameter for other API functions).
Returns
A value from the CdiReturnStatus enumeration.

◆ CdiCoreRxFreeBuffer()

CdiReturnStatus CdiCoreRxFreeBuffer ( const CdiSgList * sgl_ptr)

Free the receive buffer that was used in one of the Cdi...RxCallback() API functions.

Parameters
sgl_ptrThe scatter-gather list containing the memory to be freed.
Returns
A value from the CdiReturnStatus enumeration.

◆ CdiCoreShutdown()

CdiReturnStatus CdiCoreShutdown ( void )

Application is shutting down. Stop open connections and free-up all resources being used by the SDK.

Returns
A value from the CdiReturnStatus enumeration.

◆ CdiCoreStatsReconfigure()

CdiReturnStatus CdiCoreStatsReconfigure ( CdiConnectionHandle handle,
const CdiStatsConfigData * config_ptr )

Configure transfer statistics.

Parameters
handleConnection handle returned by Cdi...TxCreate() API functions.
config_ptrPointer to statistics configuration data. Copies of the data in the configuration data structure are made as needed. A local variable can be used for composing the structure since its contents are not needed after this function returns.
Returns
A value from the CdiReturnStatus enumeration.

◆ CdiCoreStatusToString()

const char * CdiCoreStatusToString ( CdiReturnStatus status)

Returns a short string that briefly describes the meaning of an CDI status code.

Parameters
statusThe value to be converted to a string.
Returns
const char* A character array which describes the requested code.