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

This file contains internal definitions and implementation used for payloads. More...

#include "protocol.h"
#include <stdbool.h>
#include <string.h>
#include "adapter_api.h"
#include "adapter_efa_probe.h"
#include "internal.h"
#include "private.h"

Data Structures

struct  CdiProtocolState
 Structure used to hold internal state data used by this module. More...
 

Functions

void ProtocolVersionSet1 (const CdiProtocolVersionNumber *remote_version_ptr, CdiProtocolHandle protocol_handle, CdiProtocolVTableApi **ret_api_ptr)
 Set protocol version to 1.
 
bool ProtocolVersionSet2 (const CdiProtocolVersionNumber *remote_version_ptr, CdiProtocolHandle protocol_handle, CdiProtocolVTableApi **ret_api_ptr)
 Set protocol version 2 if remote is compatible with it.
 
static void ProtocolVersionSetInternal (const CdiProtocolVersionNumber *remote_version_ptr, CdiProtocolState *state_ptr)
 
void ProtocolVersionSetLegacy (CdiProtocolHandle *ret_handle_ptr)
 Create a protocol version using the legacy version 1, which is compatible will all SDK versions.
 
void ProtocolVersionSet (const CdiProtocolVersionNumber *remote_version_ptr, CdiProtocolHandle *ret_handle_ptr)
 Create a protocol version using the specified remote protocol version. The version is compared against the versions in the current SDK and the most recent compatible version is returned.
 
void ProtocolVersionDestroy (CdiProtocolHandle protocol_handle)
 Freeup resources used by a protocol.
 
int ProtocolPayloadHeaderInit (CdiProtocolHandle protocol_handle, void *header_ptr, int header_buffer_size, const TxPayloadState *payload_state_ptr)
 Initialize raw packet encoded header data using the specified protocol and packet state data.
 
void ProtocolPayloadHeaderDecode (CdiProtocolHandle protocol_handle, void *encoded_data_ptr, int encoded_data_size, CdiDecodedPacketHeader *dest_header_ptr)
 Decode an encoded raw header into a header structure that is protocol version independent.
 
void ProtocolPayloadPacketRxReorderInfo (CdiProtocolHandle protocol_handle, const CdiRawPacketHeader *header_ptr, CdiPacketRxReorderInfo *ret_info_ptr)
 Get Rx reorder information for the specified packet.
 
CdiReturnStatus ProtocolProbeHeaderDecode (const void *encoded_data_ptr, int encoded_data_size, CdiDecodedProbeHeader *dest_header_ptr)
 Decode an encoded raw probe header into a header structure that is protocol version independent.
 
int ProtocolProbeHeaderEncode (CdiProtocolHandle protocol_handle, CdiDecodedProbeHeader *src_header_ptr, CdiRawProbeHeader *dest_header_ptr)
 Encode raw payload header data using the specified protocol and probe state data.
 

Detailed Description

This file contains internal definitions and implementation used for payloads.

Function Documentation

◆ ProtocolPayloadHeaderDecode()

void ProtocolPayloadHeaderDecode ( CdiProtocolHandle protocol_handle,
void * encoded_data_ptr,
int encoded_data_size,
CdiDecodedPacketHeader * dest_header_ptr )

Decode an encoded raw header into a header structure that is protocol version independent.

Parameters
protocol_handleHandle of protocol version.
encoded_data_ptrPointer to encoder header data.
encoded_data_sizeSize of encoded header data in bytes.
dest_header_ptrAddress where to write decoded header data.

◆ ProtocolPayloadHeaderInit()

int ProtocolPayloadHeaderInit ( CdiProtocolHandle protocol_handle,
void * header_ptr,
int header_buffer_size,
const TxPayloadState * payload_state_ptr )

Initialize raw packet encoded header data using the specified protocol and packet state data.

Parameters
protocol_handleHandle of protocol version.
header_ptrAddress where to write raw packet header.
header_buffer_sizeSize of header buffer in bytes.
payload_state_ptrPointer to TX payload state data.
Returns
Size of payload header in bytes.

◆ ProtocolPayloadPacketRxReorderInfo()

void ProtocolPayloadPacketRxReorderInfo ( CdiProtocolHandle protocol_handle,
const CdiRawPacketHeader * header_ptr,
CdiPacketRxReorderInfo * ret_info_ptr )

Get Rx reorder information for the specified packet.

Parameters
protocol_handleHandle of protocol version.
header_ptrPointer to raw encoded packet header to get Rx reorder information from.
ret_info_ptrAddress where to write returned Rx reorder info.

◆ ProtocolProbeHeaderDecode()

CdiReturnStatus ProtocolProbeHeaderDecode ( const void * encoded_data_ptr,
int encoded_data_size,
CdiDecodedProbeHeader * dest_header_ptr )

Decode an encoded raw probe header into a header structure that is protocol version independent.

Parameters
encoded_data_ptrPointer to encoder header data. NOTE: The caller must not free this data until done with the decoded version, since some of the decoded values contain pointers to it.
encoded_data_sizeSize of encoded header data in bytes.
dest_header_ptrAddress where to write decoded header data.
Returns
A value from the CdiReturnStatus enumeration.

◆ ProtocolProbeHeaderEncode()

int ProtocolProbeHeaderEncode ( CdiProtocolHandle protocol_handle,
CdiDecodedProbeHeader * src_header_ptr,
CdiRawProbeHeader * dest_header_ptr )

Encode raw payload header data using the specified protocol and probe state data.

Parameters
protocol_handleHandle of protocol version.
src_header_ptrPointer to source header data.
dest_header_ptrAddress where to write raw probe header.
Returns
Size of protocol header in bytes.

◆ ProtocolVersionDestroy()

void ProtocolVersionDestroy ( CdiProtocolHandle protocol_handle)

Freeup resources used by a protocol.

Parameters
protocol_handleHandle of protocol version.

◆ ProtocolVersionSet()

void ProtocolVersionSet ( const CdiProtocolVersionNumber * remote_version_ptr,
CdiProtocolHandle * ret_handle_ptr )

Create a protocol version using the specified remote protocol version. The version is compared against the versions in the current SDK and the most recent compatible version is returned.

Parameters
remote_version_ptrPointer to remote's protocol version.
ret_handle_ptrAddress where to write returned protocol handle.

◆ ProtocolVersionSet1()

void ProtocolVersionSet1 ( const CdiProtocolVersionNumber * remote_version_ptr,
CdiProtocolHandle protocol_handle,
CdiProtocolVTableApi ** ret_api_ptr )
extern

Set protocol version to 1.

Parameters
remote_version_ptrPointer to remote's protocol version information.
protocol_handleAddress where to write protocol version data that is available outside of this module.
ret_api_ptrAddress where to write protocol version VTable API.

◆ ProtocolVersionSet2()

bool ProtocolVersionSet2 ( const CdiProtocolVersionNumber * remote_version_ptr,
CdiProtocolHandle protocol_handle,
CdiProtocolVTableApi ** ret_api_ptr )
extern

Set protocol version 2 if remote is compatible with it.

Parameters
remote_version_ptrPointer to remote's protocol version information.
protocol_handleAddress where to write protocol version data that is available outside of this module.
ret_api_ptrAddress where to write protocol version VTable API. Only used if true is returned.
Returns
true if protocol version 2 is set, otherwise false is returned. Must then fallback to version 1 using PayloadProtocolVersionSet1().

◆ ProtocolVersionSetInternal()

static void ProtocolVersionSetInternal ( const CdiProtocolVersionNumber * remote_version_ptr,
CdiProtocolState * state_ptr )
static

Set negotiated protocol version based on remote version and current version of the SDK.

Parameters
remote_version_ptrPointer to remote's protocol version information.
state_ptrAddress where to write returned protocol state data.

◆ ProtocolVersionSetLegacy()

void ProtocolVersionSetLegacy ( CdiProtocolHandle * ret_handle_ptr)

Create a protocol version using the legacy version 1, which is compatible will all SDK versions.

Parameters
ret_handle_ptrAddress where to write returned protocol handle.