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

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

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

Data Structures

struct  CdiPacketizerState
 Structure to store the current state of a packet being constructed. Its purpose is to allow for the suspension of the creation of a packet if a pool from which items need to be allocated is empty. A state object is passed in to CdiPayloadInit() prior to calls to CdiPayloadParseCDIPacket() for a given payload. More...
 

Functions

bool PayloadInit (CdiConnectionState *con_state_ptr, const CdiSgList *source_sgl_ptr, TxPayloadState *payload_state_ptr)
 
CdiPacketizerStateHandle PayloadPacketizerCreate (void)
 
void PayloadPacketizerStateInit (CdiPacketizerStateHandle packetizer_state_handle)
 
void PayloadPacketizerDestroy (CdiPacketizerStateHandle packetizer_state_handle)
 
bool PayloadPacketizerPacketGet (CdiProtocolHandle protocol_handle, CdiPacketizerStateHandle packetizer_state_handle, char *header_ptr, int header_buffer_size, CdiPoolHandle packet_sgl_entry_pool_handle, TxPayloadState *payload_state_ptr, CdiSgList *packet_sgl_ptr, bool *ret_is_last_packet_ptr)
 

Detailed Description

This file contains internal definitions and implementation used for payloads.

Function Documentation

◆ PayloadInit()

bool PayloadInit ( CdiConnectionState * con_state_ptr,
const CdiSgList * source_sgl_ptr,
TxPayloadState * payload_state_ptr )

Initialize an CdiPayloadPacketState structure before using CdiPayloadPacketizerPacketGet() to split the payload into packets. NOTE: If an error occurs, caller is responsible for freeing the pool buffers that it allocates.

Parameters
con_state_ptrPointer to connection state data.
source_sgl_ptrPointer to Tx Payload source SGL list.
payload_state_ptrPointer to payload state data.
Returns
true if successful, otherwise an error occurred.

◆ PayloadPacketizerCreate()

CdiPacketizerStateHandle PayloadPacketizerCreate ( void )

Creates a packetizer state object. This must be destroyed with CdiPayloadPacketizerDestroy() when the connection is closed.

Returns
Handle for the created packetizer state or NULL if the creation failed.

◆ PayloadPacketizerDestroy()

void PayloadPacketizerDestroy ( CdiPacketizerStateHandle packetizer_state_handle)

Frees the memory previously allocated for a packetizer state object through CdiPayloadPacketizerCreate().

Parameters
packetizer_state_handleThe handle of the packetizer state to be destroyed.

◆ PayloadPacketizerPacketGet()

bool PayloadPacketizerPacketGet ( CdiProtocolHandle protocol_handle,
CdiPacketizerStateHandle packetizer_state_handle,
char * header_ptr,
int header_buffer_size,
CdiPoolHandle packet_sgl_entry_pool_handle,
TxPayloadState * payload_state_ptr,
CdiSgList * packet_sgl_ptr,
bool * ret_is_last_packet_ptr )

Get the next packet for a payload. Must use CdiPayloadPacketizerStateInit() for a new payload before using this function. If false is returned, one of the pools from which required resources are taken is dry so this function should be called again until it returns true.

NOTE: All the pools used in this function are not thread-safe, so must ensure that only one thread is accessing them at a time.

Parameters
protocol_handleHandle of protocol to use.
packetizer_state_handleHandle of the packetizer state for this connection.
header_ptrPointer to the header data structure to be filled in for the new packet.
header_buffer_sizeSize of header data buffer in bytes.
packet_sgl_entry_pool_handleCDI packet SGL list entry pool.
payload_state_ptrPointer to payload state data.
packet_sgl_ptrPointer to returned packet SGL list
ret_is_last_packet_ptrPointer to returned last packet state. True if last packet, otherwise false.
Returns
true if packet returned, otherwise a pool was empty so false is returned.

◆ PayloadPacketizerStateInit()

void PayloadPacketizerStateInit ( CdiPacketizerStateHandle packetizer_state_handle)

Initializes a packetizer state object. This function should be called before calling CdiPayloadPacketizerPacketGet() the first time for a given payload.

Parameters
packetizer_state_handleHandle of packetizer object.