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

When packets are received from the transmitter, they can arrive in any order. The routines here will put the packets in order. More...

#include <stdbool.h>
#include "rx_reorder_packets.h"
#include "cdi_core_api.h"
#include "cdi_logger_api.h"
#include "cdi_pool_api.h"
#include "cdi_raw_api.h"
#include "private.h"
#include "utilities_api.h"

Functions

static bool AddSgListToReorderList (CdiProtocolHandle protocol_handle, CdiPoolHandle payload_sgl_entry_pool_handle, CdiSgList *sglist_ptr, const CdiSgList *new_sglist_ptr, int initial_offset, int *num_bytes_added_ptr)
 Adds a scatter-gather list to a reorder list. First entry of the SGL may have an offset.
 
static bool AddSgListToRxReorderListTop (CdiProtocolHandle protocol_handle, CdiPoolHandle payload_sgl_entry_pool_handle, CdiReorderList *cur_reorder_list_ptr, const CdiSgList *new_sglist_ptr, int sequence_num, int initial_offset, int *num_bytes_added_ptr)
 Adds an SGL list to the top of an existing reorder list. First SGL entry of SGL list may have offset.
 
static bool AddSgListToRxReorderListBottom (CdiProtocolHandle protocol_handle, CdiPoolHandle payload_sgl_entry_pool_handle, CdiReorderList *cur_reorder_list_ptr, const CdiSgList *new_sglist_ptr, int sequence_num, int initial_offset, int *num_bytes_added_ptr)
 Adds an SGL list to the bottom of an existing reorder list. First SGL entry of SGL list may have offset.
 
static void InsertRxReorderList (CdiReorderList *prev_reorder_list_ptr, CdiReorderList *next_reorder_list_ptr, CdiReorderList *new_reorder_list_ptr)
 Inserts a reorder list between two reorder lists.
 
static void AttachNextRxReorderList (CdiPoolHandle reorder_entries_pool_handle, CdiReorderList *cur_reorder_list_ptr)
 Attaches a list that is to the right of the current list and frees the attached list's memory space.
 
static bool CreateAndInsertRxReorderList (CdiProtocolHandle protocol_handle, CdiPoolHandle reorder_entries_pool_handle, CdiPoolHandle payload_sgl_entry_pool_handle, const CdiSgList *new_sglist_ptr, int sequence_num, int initial_offset, int *num_bytes_added_ptr, CdiReorderList *prev_reorder_list_ptr, CdiReorderList *next_reorder_list_ptr, CdiReorderList **new_reorder_list_ptr)
 Creates a new reorder list and then inserts it between two reorder lists. The SGL list is added to the created reorder list. First SGL entry of SGL list may have offset.
 
static bool ProcessList (CdiProtocolHandle protocol_handle, CdiPoolHandle reorder_entries_pool_handle, CdiPoolHandle payload_sgl_entry_pool_handle, int *num_bytes_added_ptr, CdiReorderList **cur_reorder_list_ptr, const CdiSgList *new_sglist_ptr, int sequence_num, int initial_offset)
 Walks the rxreorder list to the right, looking for a spot to place the new SGL list.
 
void RxReorderPacketFreeLists (CdiReorderList *reorder_list_ptr, CdiPoolHandle payload_sgl_entry_pool_handle, CdiPoolHandle reorder_entries_pool_handle)
 removes all lists and sgls used in processing the out of order packets
 
bool RxReorderPacketPayloadStateInit (CdiProtocolHandle protocol_handle, CdiPoolHandle payload_sgl_entry_pool_handle, CdiPoolHandle reorder_entries_pool_handle, RxPayloadState *payload_state_ptr, const CdiSgList *new_sglist_ptr, int initial_offset, int sequence_num)
 Adds initial entry to payload_state_ptr->reorder_list_ptr.
 
bool RxReorderPacket (CdiProtocolHandle protocol_handle, CdiPoolHandle payload_sgl_entry_pool_handle, CdiPoolHandle reorder_entries_pool_handle, RxPayloadState *payload_state_ptr, const CdiSgList *new_sglist_ptr, int initial_offset, int sequence_num)
 Adds an entry to the payload sgl. Also checks for and maintains outstanding packets that are received out of order. If an SGL arrives that is out of order, it will be added to a doubly linked list (reorder list) of outstanding dangling lists.
 

Detailed Description

When packets are received from the transmitter, they can arrive in any order. The routines here will put the packets in order.

For more information, including Theory of Operation: Rx Reorder Home Page

Function Documentation

◆ AddSgListToReorderList()

static bool AddSgListToReorderList ( CdiProtocolHandle protocol_handle,
CdiPoolHandle payload_sgl_entry_pool_handle,
CdiSgList * sglist_ptr,
const CdiSgList * new_sglist_ptr,
int initial_offset,
int * num_bytes_added_ptr )
static

Adds a scatter-gather list to a reorder list. First entry of the SGL may have an offset.

Parameters
protocol_handleHandle for protocol being used.
payload_sgl_entry_pool_handleHandle for free SGL memory.
sglist_ptrlist Which will be appended to.
new_sglist_ptrPointer to entry to be added to list.
initial_offsetFirst SGL entry will have this offset applied.
num_bytes_added_ptrPointer to the number of bytes that were successfully added to list.
Returns
True if adding SGL list is successful.

◆ AddSgListToRxReorderListBottom()

static bool AddSgListToRxReorderListBottom ( CdiProtocolHandle protocol_handle,
CdiPoolHandle payload_sgl_entry_pool_handle,
CdiReorderList * cur_reorder_list_ptr,
const CdiSgList * new_sglist_ptr,
int sequence_num,
int initial_offset,
int * num_bytes_added_ptr )
static

Adds an SGL list to the bottom of an existing reorder list. First SGL entry of SGL list may have offset.

Parameters
protocol_handleHandle for protocol being used.
payload_sgl_entry_pool_handleHandle for free SGL memory.
cur_reorder_list_ptrPointer to list which will be appended to.
new_sglist_ptrPointer to entry to be added to list.
sequence_numThe sequence number of this SGL list.
initial_offsetFirst SGL entry will have this offset applied.
num_bytes_added_ptrPointer to the number of bytes that were successfully added to list.
Returns
True if adding SGL list is successful.

◆ AddSgListToRxReorderListTop()

static bool AddSgListToRxReorderListTop ( CdiProtocolHandle protocol_handle,
CdiPoolHandle payload_sgl_entry_pool_handle,
CdiReorderList * cur_reorder_list_ptr,
const CdiSgList * new_sglist_ptr,
int sequence_num,
int initial_offset,
int * num_bytes_added_ptr )
static

Adds an SGL list to the top of an existing reorder list. First SGL entry of SGL list may have offset.

Parameters
protocol_handleHandle for protocol being used.
payload_sgl_entry_pool_handleHandle for free SGL memory.
cur_reorder_list_ptrPointer to list which will be appended to.
new_sglist_ptrPointer to entry to be added to list.
sequence_numThe sequence number of this SGL list.
initial_offsetFirst SGL entry will have this offset applied.
num_bytes_added_ptrPointer to the number of bytes that were successfully added to list.
Returns
True if adding SGL list is successful.

◆ AttachNextRxReorderList()

static void AttachNextRxReorderList ( CdiPoolHandle reorder_entries_pool_handle,
CdiReorderList * cur_reorder_list_ptr )
static

Attaches a list that is to the right of the current list and frees the attached list's memory space.

Parameters
reorder_entries_pool_handleHandle for free rx reorder list memory.
cur_reorder_list_ptrPointer to the list that will have it's next list attached.

◆ CreateAndInsertRxReorderList()

static bool CreateAndInsertRxReorderList ( CdiProtocolHandle protocol_handle,
CdiPoolHandle reorder_entries_pool_handle,
CdiPoolHandle payload_sgl_entry_pool_handle,
const CdiSgList * new_sglist_ptr,
int sequence_num,
int initial_offset,
int * num_bytes_added_ptr,
CdiReorderList * prev_reorder_list_ptr,
CdiReorderList * next_reorder_list_ptr,
CdiReorderList ** new_reorder_list_ptr )
static

Creates a new reorder list and then inserts it between two reorder lists. The SGL list is added to the created reorder list. First SGL entry of SGL list may have offset.

Parameters
protocol_handleHandle for protocol being used.
reorder_entries_pool_handleHandle for free rx reorder list memory.
payload_sgl_entry_pool_handleHandle for free SGL memory.
new_sglist_ptrPointer to entry to be added to list.
sequence_numThe sequence number of this SGL list.
initial_offsetFirst SGL entry will have this offset applied.
num_bytes_added_ptrPointer to the number of bytes that were successfully added to list.
prev_reorder_list_ptrPointer to list to left of new list being added.
next_reorder_list_ptrPointer to list to right of new list being added.
new_reorder_list_ptrPointer to pointer of newly created list.
Returns
True if creating reorder list and adding SGL list is successful.

◆ InsertRxReorderList()

static void InsertRxReorderList ( CdiReorderList * prev_reorder_list_ptr,
CdiReorderList * next_reorder_list_ptr,
CdiReorderList * new_reorder_list_ptr )
static

Inserts a reorder list between two reorder lists.

Parameters
prev_reorder_list_ptrPointer to list to left of new list being added.
next_reorder_list_ptrPointer to list to right of new list being added.
new_reorder_list_ptrPointer to list being added.

◆ ProcessList()

static bool ProcessList ( CdiProtocolHandle protocol_handle,
CdiPoolHandle reorder_entries_pool_handle,
CdiPoolHandle payload_sgl_entry_pool_handle,
int * num_bytes_added_ptr,
CdiReorderList ** cur_reorder_list_ptr,
const CdiSgList * new_sglist_ptr,
int sequence_num,
int initial_offset )
static

Walks the rxreorder list to the right, looking for a spot to place the new SGL list.

Parameters
protocol_handleHandle for protocol being used.
reorder_entries_pool_handleHandle for free rx reorder list memory.
payload_sgl_entry_pool_handleHandle for free SGL memory.
num_bytes_added_ptrPointer to the number of bytes that were successfully added to list.
cur_reorder_list_ptrPointer to list which will have new_sgl_list added to it.
new_sglist_ptrPointer to entry to be added to list.
sequence_numThe sequence number of this SGL list.
initial_offsetFirst SGL entry will have this offset applied.
Returns
True if adding SGL list is successful.

◆ RxReorderPacket()

bool RxReorderPacket ( CdiProtocolHandle protocol_handle,
CdiPoolHandle payload_sgl_entry_pool_handle,
CdiPoolHandle reorder_entries_pool_handle,
RxPayloadState * payload_state_ptr,
const CdiSgList * new_sglist_ptr,
int initial_offset,
int sequence_num )

Adds an entry to the payload sgl. Also checks for and maintains outstanding packets that are received out of order. If an SGL arrives that is out of order, it will be added to a doubly linked list (reorder list) of outstanding dangling lists.

Once all of the data for a payload is received, then the entries for payload_state_ptr->reorder_list_ptr->next_ptr and payload_state_ptr->reorder_list_ptr->prev_ptr will be NULL, otherwise there are dangling lists that have not been attached to the single payload list.

Parameters
protocol_handleHandle for protocol being used.
payload_sgl_entry_pool_handleHandle to memory pool of payload SGL entries.
reorder_entries_pool_handleHandle to memory pool of rx_reorder entries.
payload_state_ptrCurrent state of the payload, specifically a single rx_reorder entry.
new_sglist_ptrAn SGL to be added to the end of the payload sgl.
initial_offsetFirst SGL entry will have this offset applied
sequence_numThe sequence number of this SGL list.
Returns
True if successful.

◆ RxReorderPacketFreeLists()

void RxReorderPacketFreeLists ( CdiReorderList * reorder_list_ptr,
CdiPoolHandle payload_sgl_entry_pool_handle,
CdiPoolHandle reorder_entries_pool_handle )

removes all lists and sgls used in processing the out of order packets

Parameters
reorder_list_ptrpointer to a single list entry to start the removal process
payload_sgl_entry_pool_handlehandle to memory pool of sgls
reorder_entries_pool_handlehandle to memory pool of rx reorder lists

◆ RxReorderPacketPayloadStateInit()

bool RxReorderPacketPayloadStateInit ( CdiProtocolHandle protocol_handle,
CdiPoolHandle payload_sgl_entry_pool_handle,
CdiPoolHandle reorder_entries_pool_handle,
RxPayloadState * payload_state_ptr,
const CdiSgList * new_sglist_ptr,
int initial_offset,
int sequence_num )

Adds initial entry to payload_state_ptr->reorder_list_ptr.

Parameters
protocol_handleHandle for protocol being used.
payload_sgl_entry_pool_handleHandle to memory pool of payload SGL entries.
reorder_entries_pool_handleHandle to memory pool of rx_reorder entries.
payload_state_ptrCurrent state of the payload, specifically a single rx_reorder entry.
new_sglist_ptrAn SGL to be added to the end of the payload sgl.
initial_offsetFirst SGL entry will have this offset applied.
sequence_numThe sequence number of this SGL list.
Returns
True if successful.