CDI SDK
SDK for transporting chunks of data reliably and with low latency using a polled mode network driver.
|
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) |
This file contains internal definitions and implementation used for payloads.
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.
con_state_ptr | Pointer to connection state data. |
source_sgl_ptr | Pointer to Tx Payload source SGL list. |
payload_state_ptr | Pointer to payload state data. |
CdiPacketizerStateHandle PayloadPacketizerCreate | ( | void | ) |
Creates a packetizer state object. This must be destroyed with CdiPayloadPacketizerDestroy() when the connection is closed.
void PayloadPacketizerDestroy | ( | CdiPacketizerStateHandle | packetizer_state_handle | ) |
Frees the memory previously allocated for a packetizer state object through CdiPayloadPacketizerCreate().
packetizer_state_handle | The handle of the packetizer state to be destroyed. |
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.
protocol_handle | Handle of protocol to use. |
packetizer_state_handle | Handle of the packetizer state for this connection. |
header_ptr | Pointer to the header data structure to be filled in for the new packet. |
header_buffer_size | Size of header data buffer in bytes. |
packet_sgl_entry_pool_handle | CDI packet SGL list entry pool. |
payload_state_ptr | Pointer to payload state data. |
packet_sgl_ptr | Pointer to returned packet SGL list |
ret_is_last_packet_ptr | Pointer to returned last packet state. True if last packet, otherwise false. |
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.
packetizer_state_handle | Handle of packetizer object. |