CDI SDK
SDK for transporting chunks of data reliably and with low latency using a polled mode network driver.
Loading...
Searching...
No Matches
protocol.h
Go to the documentation of this file.
1// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2// This file is part of the AWS CDI-SDK, licensed under the BSD 2-Clause "Simplified" License.
3// License details at: https://github.com/aws/aws-cdi-sdk/blob/mainline/LICENSE
4// -------------------------------------------------------------------------------------------
5
12#ifndef CDI_PROTOCOL_H__
13#define CDI_PROTOCOL_H__
14
15#include <assert.h>
16#include <stdbool.h>
17#include <stdint.h>
18
19#include "cdi_core_api.h"
20#include "cdi_pool_api.h"
21#include "payload.h"
22
23//*********************************************************************************************************************
24//***************************************** START OF DEFINITIONS AND TYPES ********************************************
25//*********************************************************************************************************************
26
27// --------------------------------------------------------------------
28// All structures in the block below are byte packed (no byte padding).
29// --------------------------------------------------------------------
30#pragma pack(push, 1)
31
34
43
44#pragma pack(pop)
45// --------------------------------------------------------------------
46// End of byte packed structures (no byte padding).
47// --------------------------------------------------------------------
48
56
75
95
100#define CDI_RAW_PACKET_HEADER_SIZE_V1 (34)
101
106#define CDI_RAW_PACKET_HEADER_SIZE_V2 (47)
107
120
133
141
153
157typedef struct {
160
168
197
202#define CDI_RAW_PROBE_HEADER_SIZE_V1 (257)
203
208#define CDI_RAW_PROBE_HEADER_SIZE_V2 (253)
209
213typedef struct {
215 uint8_t efa_data[EFA_PROBE_PACKET_DATA_SIZE];
217
233
238
248
250typedef void (*VtblPayloadHeaderDecode)(const void* encoded_data_ptr, int encoded_data_size,
251 CdiDecodedPacketHeader* dest_header_ptr);
253typedef int (*VtblPayloadHeaderInit)(void* header_ptr, int header_buffer_size, const TxPayloadState* payload_state_ptr);
255typedef void (*VtblPayloadPacketRxReorderInfo)(const CdiRawPacketHeader* header_ptr,
256 CdiPacketRxReorderInfo* ret_info_ptr);
258typedef CdiReturnStatus (*VtblProbeHeaderDecode)(const void* encoded_data_ptr, int encoded_data_size,
259 CdiDecodedProbeHeader* dest_header_ptr);
261typedef int (*VtblProbeHeaderEncode)(const CdiDecodedProbeHeader* state_ptr, CdiRawProbeHeader* dest_header_ptr);
262
273
274//*********************************************************************************************************************
275//******************************************* START OF PUBLIC FUNCTIONS ***********************************************
276//*********************************************************************************************************************
277
279typedef struct TxPayloadState TxPayloadState;
280
288void ProtocolVersionSet(const CdiProtocolVersionNumber* remote_version_ptr, CdiProtocolHandle* ret_handle_ptr);
289
295void ProtocolVersionSetLegacy(CdiProtocolHandle* ret_handle_ptr);
296
302void ProtocolVersionDestroy(CdiProtocolHandle protocol_handle);
303
312void ProtocolPayloadHeaderDecode(CdiProtocolHandle protocol_handle, void* encoded_data_ptr, int encoded_data_size,
313 CdiDecodedPacketHeader* dest_header_ptr);
324int ProtocolPayloadHeaderInit(CdiProtocolHandle protocol_handle, void* header_ptr, int header_buffer_size,
325 const TxPayloadState* payload_state_ptr);
326
334void ProtocolPayloadPacketRxReorderInfo(CdiProtocolHandle protocol_handle, const CdiRawPacketHeader* header_ptr,
335 CdiPacketRxReorderInfo* ret_info_ptr);
336
347CdiReturnStatus ProtocolProbeHeaderDecode(const void* encoded_data_ptr, int encoded_data_size,
348 CdiDecodedProbeHeader* dest_header_ptr);
349
359int ProtocolProbeHeaderEncode(CdiProtocolHandle protocol_handle, CdiDecodedProbeHeader* src_header_ptr,
360 CdiRawProbeHeader* dest_header_ptr);
361
362#endif // CDI_PROTOCOL_H__
This file declares the public API data types, structures and functions that comprise the CDI low-leve...
CdiReturnStatus
Values used for API function return codes.
Definition cdi_core_api.h:189
This file declares the public API data types, structures and functions that comprise the CDI Pool Uti...
#define EFA_PROBE_PACKET_DATA_SIZE
Defines the EFA interface probe packet data size.
Definition configuration.h:232
The declarations in this header file correspond to the definitions in payload.c.
CdiPayloadType
Enumeration used to identify packet type.
Definition payload.h:30
#define MAX_CDI_PACKET_EXTRA_DATA
Maximum number of bytes for CDI packet #0 extra data.
Definition private_avm.h:79
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 agains...
Definition protocol.c:105
int(* VtblProbeHeaderEncode)(const CdiDecodedProbeHeader *state_ptr, CdiRawProbeHeader *dest_header_ptr)
Prototype of function used for protocol version VTable API.
Definition protocol.h:261
void ProtocolVersionSetLegacy(CdiProtocolHandle *ret_handle_ptr)
Create a protocol version using the legacy version 1, which is compatible will all SDK versions.
Definition protocol.c:88
#define CDI_RAW_PACKET_HEADER_SIZE_V1
Define the size of the PacketHeaderUnion structure used in protocol V1. This is done so the size of t...
Definition protocol.h:100
int(* VtblPayloadHeaderInit)(void *header_ptr, int header_buffer_size, const TxPayloadState *payload_state_ptr)
Prototype of function used for protocol version VTable API.
Definition protocol.h:253
struct CdiProtocol * CdiProtocolHandle
Forward reference of structure to create pointers later.
Definition protocol.h:247
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.
Definition protocol.c:152
void(* VtblPayloadPacketRxReorderInfo)(const CdiRawPacketHeader *header_ptr, CdiPacketRxReorderInfo *ret_info_ptr)
Prototype of function used for protocol version VTable API.
Definition protocol.h:255
void ProtocolVersionDestroy(CdiProtocolHandle protocol_handle)
Freeup resources used by a protocol.
Definition protocol.c:122
ProbeCommand
This enumeration is used in the ProbePacketHeader structure to indicate a probe command....
Definition protocol.h:146
@ kProbeCommandAck
Packet is an ACK response to a previously sent command.
Definition protocol.h:150
@ kProbeCommandPing
Request to ping the connection.
Definition protocol.h:148
@ kProbeCommandConnected
Notification that connection has been established (probe has completed).
Definition protocol.h:149
@ kProbeCommandReset
Request to reset the connection. Start with 1 so no commands have the value 0.
Definition protocol.h:147
@ kProbeCommandProtocolVersion
Packet contains protocol version of sender.
Definition protocol.h:151
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.
Definition protocol.c:130
#define CDI_RAW_PROBE_HEADER_SIZE_V2
Define the size of the ProbeHeaderUnion structure used in protocol V2. This is done so the size of th...
Definition protocol.h:208
void ProtocolPayloadPacketRxReorderInfo(CdiProtocolHandle protocol_handle, const CdiRawPacketHeader *header_ptr, CdiPacketRxReorderInfo *ret_info_ptr)
Get Rx reorder information for the specified packet.
Definition protocol.c:144
#define CDI_RAW_PROBE_HEADER_SIZE_V1
Define the size of the ProbeHeaderUnion structure used in protocol V1. This is done so the size of th...
Definition protocol.h:202
#define CDI_RAW_PACKET_HEADER_SIZE_V2
Define the size of the PacketHeaderUnion structure used in protocol V2. This is done so the size of t...
Definition protocol.h:106
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.
Definition protocol.c:176
CdiReturnStatus(* VtblProbeHeaderDecode)(const void *encoded_data_ptr, int encoded_data_size, CdiDecodedProbeHeader *dest_header_ptr)
Prototype of function used for protocol version VTable API.
Definition protocol.h:258
void(* VtblPayloadHeaderDecode)(const void *encoded_data_ptr, int encoded_data_size, CdiDecodedPacketHeader *dest_header_ptr)
Prototype of function used for protocol version VTable API.
Definition protocol.h:250
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.
Definition protocol.c:137
Structure definition behind the connection handles shared with the user's application program....
Definition private.h:371
CDI decoded header for payload packets that contains a data offset value (payload type is kPayloadTyp...
Definition protocol.h:53
int payload_data_offset
Current offset of payload data.
Definition protocol.h:54
Union of decoded CDI packet headers. Use to reserve memory that can be used to hold any type of decod...
Definition protocol.h:80
int payload_num
Payload number this CDI packet is associated with.
Definition protocol.h:83
uint32_t packet_id
Packet ID. Increments by 1 for each packet across all payloads (wraps at 0). NOTE: Only valid for pro...
Definition protocol.h:88
CdiDecodedPacketDataOffsetInfo data_offset_info
Valid when payload_type is kPayloadTypeDataOffset.
Definition protocol.h:91
int packet_sequence_num
Packet sequence number for the payload.
Definition protocol.h:82
CdiPayloadType payload_type
Payload type from CdiPayloadType.
Definition protocol.h:81
int encoded_header_size
Size of encoded header in bytes.
Definition protocol.h:84
CdiDecodedPacketNum0Info num0_info
Valid when payload_type is kPayloadTypeData and packet_sequence_num=0.
Definition protocol.h:92
CDI decoded header for payload packet #0. This packet never uses payload_data_offset,...
Definition protocol.h:61
uint64_t payload_user_data
User data provided by transmitter that is related to the payload.
Definition protocol.h:67
uint64_t tx_start_time_microseconds
Payload Tx start time in microseconds since epoch. NOTE: Only valid for protocols 2 and later.
Definition protocol.h:73
CdiPtpTimestamp origination_ptp_timestamp
Origination RTP timestamp provided by transmitter that is related to the payload.
Definition protocol.h:66
void * extra_data_ptr
Pointer to extra data.
Definition protocol.h:70
int extra_data_size
Size of additional header data in bytes.
Definition protocol.h:69
int total_payload_size
Total size of payload in bytes.
Definition protocol.h:62
uint64_t max_latency_microsecs
Maximum latency payload in microseconds.
Definition protocol.h:63
Control ACK packet that is a response for a transmitted command.
Definition protocol.h:164
uint16_t ack_control_packet_num
Command's control packet number that ACK corresponds to.
Definition protocol.h:166
ProbeCommand ack_command
Command that ACK corresponds to.
Definition protocol.h:165
Probe command packet that is being transmitted.
Definition protocol.h:157
bool requires_ack
A control flag that, when true, indicates the specified command requires ack.
Definition protocol.h:158
Union of decoded probe headers. Use to reserve memory that can be used to hold any type of decoded CD...
Definition protocol.h:173
uint16_t senders_control_dest_port
Sender's control interface destination port. Sent from Tx (client) to Rx (server) so the Rx can estab...
Definition protocol.h:191
ProbeCommand command
Sender's command.
Definition protocol.h:176
const char * senders_ip_str
Pointer to sender's IP address.
Definition protocol.h:184
const char * senders_stream_name_str
Pointer to sender's stream name string.
Definition protocol.h:186
CdiDecodedProbeCommand command_packet
< Valid if command is not kProbeCommandAck. Command packet transmitted over the control interface.
Definition protocol.h:179
int senders_stream_identifier
Only valid for probe version 2.
Definition protocol.h:187
const uint8_t * senders_gid_array
Pointer to sender's device GID. contains GID + QPN (see efa_ep_addr).
Definition protocol.h:185
uint16_t control_packet_num
Probe packet number that is incremented for each command sent. Value begins at zero when a new connec...
Definition protocol.h:195
CdiProtocolVersionNumber senders_version
Sender's CDI protocol version number.
Definition protocol.h:174
Structure used to hold packet data used by Rx packet reordering.
Definition protocol.h:137
int packet_sequence_num
Packet sequence number for the payload.
Definition protocol.h:139
int payload_num
Payload number the packet is associated with.
Definition protocol.h:138
Type used to hold V-table of APIs that must be implemented by payload protocol versions.
Definition protocol.h:266
VtblPayloadHeaderDecode header_decode
Function pointer used to decode a raw packet header.
Definition protocol.h:267
VtblPayloadHeaderInit header_init
Function pointer used to initialize a raw packet header.
Definition protocol.h:268
VtblProbeHeaderDecode probe_decode
Function pointer used to decode a raw probe header.
Definition protocol.h:270
VtblProbeHeaderEncode probe_encode
Function pointer used to encode a raw probe header.
Definition protocol.h:271
VtblPayloadPacketRxReorderInfo rx_reorder_info
Function pointer used to get packet Rx reorder information.
Definition protocol.h:269
CDI header used to identify protocol version number information.
Definition protocol.h:38
uint8_t probe_version_num
CDI probe version number.
Definition protocol.h:41
uint8_t major_version_num
CDI protocol major version number.
Definition protocol.h:40
uint8_t version_num
CDI protocol version number.
Definition protocol.h:39
Structure used to hold negotiated protocol version information.
Definition protocol.h:242
CdiProtocolVersionNumber negotiated_version
Negotiated protocol version number.
Definition protocol.h:243
int payload_num_max
Maximum value for payload number. See CdiDecodedPacketHeader.payload_num.
Definition protocol.h:244
A structure for holding a PTP timestamp defined in seconds and nanoseconds. This PTP time as defined ...
Definition cdi_core_api.h:331
Union of raw CDI extra packet headers. Use to reserve memory that can be used to hold raw CDI packet ...
Definition protocol.h:127
uint8_t header_v2[CDI_RAW_PACKET_HEADER_SIZE_V2+MAX_CDI_PACKET_EXTRA_DATA]
For protocol version 2.
Definition protocol.h:130
uint8_t header_v1[CDI_RAW_PACKET_HEADER_SIZE_V1+MAX_CDI_PACKET_EXTRA_DATA]
For protocol version 1.
Definition protocol.h:129
Union of raw CDI packet headers. Use to reserve memory that can be used to hold raw CDI packet header...
Definition protocol.h:114
uint8_t header_v1[CDI_RAW_PACKET_HEADER_SIZE_V1]
For protocol version 1.
Definition protocol.h:116
uint8_t header_v2[CDI_RAW_PACKET_HEADER_SIZE_V2]
For protocol version 2.
Definition protocol.h:117
Union of raw probe headers. Use to reserve memory that can be used to hold any type of raw probe head...
Definition protocol.h:224
uint8_t header_v2[CDI_RAW_PROBE_HEADER_SIZE_V2]
For protocol version 2.
Definition protocol.h:227
uint8_t header_v1[CDI_RAW_PROBE_HEADER_SIZE_V1]
For protocol version 1.
Definition protocol.h:226
EfaProbePacket efa_packet
Packet used for EFA probe transmitted over the EFA interface.
Definition protocol.h:228
Packet format used by probe when sending probe packets over the EFA interface.
Definition protocol.h:213
uint16_t packet_sequence_num
Probe packet sequence number.
Definition protocol.h:214
This defines a structure that contains all of the state information for sending a single payload.
Definition private.h:141