CDI SDK
SDK for transporting chunks of data reliably and with low latency using a polled mode network driver.
|
When payloads are received from the transmitter, they can arrive in any order. The routines here will put the payloads in order. More...
#include <stdbool.h>
#include "rx_reorder_payloads.h"
#include "cdi_core_api.h"
#include "cdi_logger_api.h"
#include "cdi_pool_api.h"
#include "cdi_raw_api.h"
#include "internal_rx.h"
#include "private.h"
#include "utilities_api.h"
Functions | |
CDI_STATIC_ASSERT ((0==(CDI_MAX_RX_PAYLOAD_OUT_OF_ORDER_BUFFER % 2)), "The define must be a power of 2.") | |
Ensure define is a power of 2. | |
CDI_STATIC_ASSERT ((CDI_MAX_RX_PACKET_OUT_OF_ORDER_WINDOW<=CDI_MAX_RX_PAYLOAD_OUT_OF_ORDER_BUFFER), "...WINDOW must be <= ...BUFFER.") | |
Ensure the packet out of order window is less than or equal to the payload out of order buffer. | |
static int | AdvanceStateArrayIndex (int payload_num_max, int index) |
Advance the specified state array index value by 1. If a maximum limit is reached, the value wraps to zero. | |
static void | SetIgnoreState (RxPayloadState *payload_state_ptr) |
Set the specified payload to the ignore state. | |
static void | DecreasePacketWindowCount (RxEndpointState *endpoint_state_ptr, int packet_count) |
Decrease packet window count by the specified value. | |
static void | FreePayloadState (CdiEndpointState *endpoint_ptr, int index) |
Free payload state by removing it from the payload Rx reorder list and returning it to the pool. | |
static bool | SendPayloadIfCompleteOrError (CdiEndpointState *endpoint_ptr, int index) |
Send the payload if it is ready. | |
static void | FlushPartialPayload (CdiEndpointState *endpoint_ptr) |
void | RxReorderPayloadResetState (RxPayloadState *payload_state_ptr, int payload_num) |
void | RxReorderPayloadError (CdiEndpointState *endpoint_ptr, RxPayloadState *payload_state_ptr) |
Set payload in an error state and free associated payload resources (but not payload state). | |
bool | RxReorderPayloadIsStale (CdiEndpointState *endpoint_ptr, RxPayloadState *payload_state_ptr) |
Determine if a payload has not received any packets within the packet out of order window. See CDI_MAX_RX_PACKET_OUT_OF_ORDER_WINDOW. | |
RxPayloadState * | RxReorderPayloadStateGet (CdiEndpointState *endpoint_ptr, CdiPoolHandle rx_payload_state_pool_handle, int payload_num) |
void | RxReorderPayloadSendReadyPayloads (CdiEndpointState *endpoint_ptr) |
void | RxReorderPayloadSeekFirstPayload (CdiEndpointState *endpoint_ptr) |
When payloads are received from the transmitter, they can arrive in any order. The routines here will put the payloads in order.
|
inlinestatic |
Advance the specified state array index value by 1. If a maximum limit is reached, the value wraps to zero.
payload_num_max | Maximum value for payload number (protocol dependent). |
index | Current index value. |
|
static |
Decrease packet window count by the specified value.
endpoint_state_ptr | Pointer to endpoint state data. |
packet_count | Number of packets to decrease window by. |
|
static |
Starting at the window start index, flush partial payloads or erred payloads freeing up enough Rx packet reorder resources to get below the packet limit of MAX_RX_PACKET_OUT_OF_ORDER_WINDOW packets.
endpoint_ptr | Pointer to endpoint state structure. |
|
static |
Free payload state by removing it from the payload Rx reorder list and returning it to the pool.
endpoint_ptr | Pointer to endpoint data. |
index | Index of payload state pointer in payload_state_array_ptr. |
void RxReorderPayloadError | ( | CdiEndpointState * | endpoint_ptr, |
RxPayloadState * | payload_state_ptr ) |
Set payload in an error state and free associated payload resources (but not payload state).
endpoint_ptr | Pointer to endpoint state structure. |
payload_state_ptr | Pointer to the payload state. |
bool RxReorderPayloadIsStale | ( | CdiEndpointState * | endpoint_ptr, |
RxPayloadState * | payload_state_ptr ) |
Determine if a payload has not received any packets within the packet out of order window. See CDI_MAX_RX_PACKET_OUT_OF_ORDER_WINDOW.
endpoint_ptr | Pointer to endpoint state structure. |
payload_state_ptr | Pointer to the payload state. |
void RxReorderPayloadResetState | ( | RxPayloadState * | payload_state_ptr, |
int | payload_num ) |
Reset payload state data.
payload_state_ptr | Pointer to payload state data to reset. |
payload_num | Payload number to set. |
void RxReorderPayloadSeekFirstPayload | ( | CdiEndpointState * | endpoint_ptr | ) |
Advance the current Rx reorder window index to the first entry that contains a payload.
endpoint_ptr | Pointer to endpoint state structure. |
void RxReorderPayloadSendReadyPayloads | ( | CdiEndpointState * | endpoint_ptr | ) |
Starting at the beginning of the payload state list, sends any payloads that are complete or in an error state.
endpoint_ptr | Pointer to endpoint state structure. |
RxPayloadState * RxReorderPayloadStateGet | ( | CdiEndpointState * | endpoint_ptr, |
CdiPoolHandle | rx_payload_state_pool_handle, | ||
int | sequence_num ) |
Get pointer to Rx payload state structure for the specified payload sequence number. If one does not already exist then a new one is created.
endpoint_ptr | Pointer to endpoint state structure. |
rx_payload_state_pool_handle | Handle of Rx payload state pool to use when allocating new payload state structures. |
sequence_num | Payload sequence number. |
|
static |
Send the payload if it is ready.
endpoint_ptr | Pointer to endpoint state data. |
index | Index of payload state pointer in payload_state_array_ptr. |
|
static |
Set the specified payload to the ignore state.
payload_state_ptr | Pointer to payload state data. |