13#ifndef ADAPTER_API_H__
14#define ADAPTER_API_H__
54 struct SocketAdapterState {
57 struct sockaddr_in address;
58 } socket_adapter_state;
339 const char* bind_ip_addr_str);
643 const struct sockaddr_in* destination_address_ptr,
Packet* packet_ptr);
CdiReturnStatus CdiAdapterGetPort(const AdapterEndpointHandle handle, int *port_number_ptr)
Definition adapter.c:1088
CdiReturnStatus CdiAdapterEnqueueSendPackets(const AdapterEndpointHandle handle, const CdiSinglyLinkedList *packet_list_ptr)
Definition adapter.c:1048
void CdiAdapterPollThreadFlushResources(AdapterEndpointHandle handle)
Definition adapter.c:1106
CdiReturnStatus CdiAdapterCloseEndpoint(AdapterEndpointHandle handle)
Definition adapter.c:1017
EndpointTransmitQueueLevel
Definition adapter_api.h:82
@ kEndpointTransmitQueueFull
Transmit queue has room for no more packets.
Definition adapter_api.h:85
@ kEndpointTransmitQueueIntermediate
Transmit queue is somewhere between empty and full.
Definition adapter_api.h:84
@ kEndpointTransmitQueueNa
Endpoint is not a polled mode driver.
Definition adapter_api.h:86
@ kEndpointTransmitQueueEmpty
Transmit queue has no packets in it.
Definition adapter_api.h:83
void(* MessageFromEndpoint)(void *param_ptr, Packet *packet_ptr, EndpointMessageType message_type)
Prototype of function used to process packet messages from the endpoint.
Definition adapter_api.h:105
void CdiAdapterTxPacketComplete(AdapterEndpointHandle handle, const Packet *packet_ptr)
Definition adapter.c:1114
CdiReturnStatus CdiAdapterFreeBuffer(const AdapterEndpointHandle handle, const CdiSgList *sgl_ptr)
Definition adapter.c:1076
struct AdapterConnectionState * AdapterConnectionHandle
Forward declaration to create pointer to adapter connection state when used.
Definition adapter_api.h:322
CdiReturnStatus CdiAdapterStopConnection(AdapterConnectionHandle handle)
Definition adapter.c:829
struct ControlInterfaceState * ControlInterfaceHandle
Forward reference.
Definition adapter_api.h:28
EndpointDirection
The direction of packets that an endpoint will be used for.
Definition adapter_api.h:65
@ kEndpointDirectionBidirectional
Endpoint can send packets to and receive from the remote host.
Definition adapter_api.h:68
@ kEndpointDirectionSend
Endpoint can send packets to its remote host.
Definition adapter_api.h:66
@ kEndpointDirectionReceive
Endpoint can receive packets from its remote host.
Definition adapter_api.h:67
CdiReturnStatus CdiAdapterStartEndpoint(AdapterEndpointHandle handle)
Definition adapter.c:972
CdiReturnStatus CdiAdapterEnqueueSendPacket(const AdapterEndpointHandle handle, const struct sockaddr_in *destination_address_ptr, Packet *packet_ptr)
Definition adapter.c:1066
CdiReturnStatus CdiAdapterShutdown(CdiAdapterHandle adapter)
Definition adapter.c:1098
struct AdapterEndpointState * AdapterEndpointHandle
Forward declaration to create pointer to adapter endpoint state when used.
Definition adapter_api.h:166
CdiReturnStatus CdiAdapterPollEndpoint(AdapterEndpointHandle handle)
Definition adapter.c:959
CdiReturnStatus CdiAdapterCreateConnection(CdiAdapterConnectionConfigData *config_data_ptr, AdapterConnectionHandle *return_handle_ptr)
Definition adapter.c:594
EndpointDataType
The type of transmission data that an endpoint will be used for.
Definition adapter_api.h:74
@ kEndpointTypeData
Endpoint used for normal data transmission.
Definition adapter_api.h:75
@ kEndpointTypeControl
Endpoint used for control command transmission (uses sockets).
Definition adapter_api.h:76
PollState
Values used to determine current running state of a poll thread.
Definition adapter_api.h:180
@ kPollStopped
Poll thread stopped.
Definition adapter_api.h:184
@ kPollRunning
Poll thread has ran through at least one poll loop.
Definition adapter_api.h:182
@ kPollStopping
Poll thread is stopping.
Definition adapter_api.h:183
@ kPollStart
Poll thread is starting and has not ran through a pool loop yet.
Definition adapter_api.h:181
CdiReturnStatus CdiAdapterDestroyConnection(AdapterConnectionHandle handle)
Definition adapter.c:840
CdiReturnStatus EfaNetworkAdapterInitialize(CdiAdapterState *adapter_state_ptr, bool is_socket_based)
Definition adapter_efa.c:1019
EndpointTransmitQueueLevel CdiAdapterGetTransmitQueueLevel(AdapterEndpointHandle handle)
Definition adapter.c:1043
AdapterPacketAckStatus
Values used for adapter packet acknowledgment status.
Definition adapter_api.h:33
@ kAdapterPacketStatusNotConnected
The packet could not be sent because the adapter endpoint isn't connected.
Definition adapter_api.h:36
@ kAdapterPacketStatusOk
The transmitted packet was acknowledged to have been received.
Definition adapter_api.h:34
@ kAdapterPacketStatusFailed
The packet transmission resulted in an error.
Definition adapter_api.h:35
CdiReturnStatus SocketNetworkAdapterInitialize(CdiAdapterState *adapter_state_ptr)
Definition adapter_socket.c:510
CdiReturnStatus CdiAdapterOpenEndpoint(CdiAdapterEndpointConfigData *config_data_ptr, AdapterEndpointHandle *return_handle_ptr)
Definition adapter.c:881
EndpointMessageType
Definition adapter_api.h:93
@ kEndpointMessageTypePacketSent
Packet was sent.
Definition adapter_api.h:94
@ kEndpointMessageTypePacketReceived
Packet was received.
Definition adapter_api.h:95
CdiReturnStatus CdiAdapterResetEndpoint(AdapterEndpointHandle handle)
Definition adapter.c:994
CdiReturnStatus
Values used for API function return codes.
Definition cdi_core_api.h:189
CdiConnectionStatus
This enumeration is used to indicate the current state of a connection. NOTE: Any changes made here M...
Definition cdi_core_api.h:368
void * CdiUserCbParameter
Type used as user defined data that is passed to the registered user RX/TX callback functions.
Definition cdi_core_api.h:182
void(* CdiCoreConnectionCallback)(const CdiCoreConnectionCbData *data_ptr)
Prototype of connection callback function. The user code must implement a function with this prototyp...
Definition cdi_core_api.h:412
struct CdiSignalType_t * CdiSignalType
Define portable signal type. Don't use void* here, which prevents the compiler from type checking.
Definition cdi_os_api.h:189
pthread_mutex_t * CdiCsID
Define portable critical section.
Definition cdi_os_api.h:192
struct CdiThreadID_t * CdiThreadID
Define portable thread type. Separate name from type, otherwise the typedef that follows it will gene...
Definition cdi_os_api.h:312
struct CdiQueueState * CdiQueueHandle
Type used as the handle (pointer to an opaque structure) for a queue. Each handle represents a instan...
Definition cdi_queue_api.h:32
This file declares the public API data types, structures and functions that comprise the CDI Raw payl...
#define MAX_IP_STRING_LENGTH
Maximum IP string length.
Definition configuration.h:86
The declarations in this header file correspond to the definitions in endpoint_manager....
Structure used to hold adapter connection state.
Definition adapter_api.h:254
bool tx_header_buffer_is_hugepages
If true, tx_header_buffer_allocated_ptr is using hugepages, otherwise it is using heap memory.
Definition adapter_api.h:299
EndpointDirection direction
The direction that this endpoint supports.
Definition adapter_api.h:266
void * tx_header_buffer_allocated_ptr
Pointer to start of the allocated transmit buffers used by Tx probe packets, Tx headers and Tx extra ...
Definition adapter_api.h:306
bool can_receive
True if connection can receive.
Definition adapter_api.h:280
CdiSignalType shutdown_signal
Signal used to shutdown adapter connection threads.
Definition adapter_api.h:296
ControlInterfaceHandle control_interface_handle
Handle of control interface for the connection.
Definition adapter_api.h:314
ThreadUtilizationState load_state
Used for computing the CPU utilization of the poll thread for the connection.
Definition adapter_api.h:283
CdiPoolHandle tx_extra_header_pool_handle
Valid if direction supports transmit. Memory pool of Tx extra headers for packets (TxExtraPacketHeade...
Definition adapter_api.h:312
volatile CdiConnectionStatus connection_status_code
Current state of this endpoint. NOTE: Made volatile, since it is written to and read by different thr...
Definition adapter_api.h:261
CdiLogHandle log_handle
Handle (a pointer) to the log associated with the connection used by this endpoint.
Definition adapter_api.h:264
RxAdapterConnectionState rx_state
Valid if direction supports receive.
Definition adapter_api.h:267
CdiListEntry list_entry
Allow these structures to live in a list in the Adapter.
Definition adapter_api.h:255
PollThreadState * poll_thread_state_ptr
Pointer to poll thread state data associated with this connection.
Definition adapter_api.h:294
AdapterDataConnectionState data_state
Valid if PollThreadState.data_type = kEndpointTypeData. Data connection specific state data.
Definition adapter_api.h:271
PollState poll_state
State of poll operation for this adapter connection (start, running or stopped).
Definition adapter_api.h:277
void * type_specific_ptr
Adapter specific connection data.
Definition adapter_api.h:318
int port_number
Port number related to this connection.
Definition adapter_api.h:285
uint64_t tx_header_buffer_allocated_size
Size in bytes of Tx payload buffer allocated. Pointer to allocated buffer is in tx_buffer_allocated_p...
Definition adapter_api.h:302
bool can_transmit
True if connection can transmit.
Definition adapter_api.h:279
CdiPoolHandle tx_header_pool_handle
Valid if direction supports transmit. Memory pool of Tx headers for packets (TxPacketHeader).
Definition adapter_api.h:309
AdapterControlConnectionState control_state
Valid if PollThreadState.data_type = kEndpointTypeControl. Control interface connection specific stat...
Definition adapter_api.h:274
CdiAdapterState * adapter_state_ptr
Pointer back to the adapter that is being used by this connection.
Definition adapter_api.h:256
CdiCsID endpoint_lock
Lock used to protect access to endpoint resources.
Definition adapter_api.h:316
CdiSignalType tx_poll_do_work_signal
Valid if direction supports transmit. Tx Signal/flag used to notify PollThread() that it can sleep....
Definition adapter_api.h:292
This defines a structure that contains the state information for a control interface adapter connecti...
Definition adapter_api.h:202
AdapterEndpointHandle control_endpoint_handle
Control interface endpoint handle.
Definition adapter_api.h:203
This defines a structure that contains the state information for a data adapter connection (type is k...
Definition adapter_api.h:191
CdiConnectionHandle cdi_connection_handle
A handle to the CDI connection for this connection.
Definition adapter_api.h:192
CdiUserCbParameter connection_user_cb_param
User data for connection callback pointer.
Definition adapter_api.h:195
CdiCoreConnectionCallback connection_cb_ptr
Connection callback pointer.
Definition adapter_api.h:194
Structure used to hold adapter endpoint state.
Definition adapter_api.h:110
void * msg_from_endpoint_param_ptr
Parameter passed to queue message function.
Definition adapter_api.h:119
CdiQueueHandle tx_packet_queue_handle
Circular queue of TxPacketState structures.
Definition adapter_api.h:126
CdiAdapterEndpointStats * endpoint_stats_ptr
Address where to store adapter endpoint statistics.
Definition adapter_api.h:132
CdiSignalType shutdown_signal
Signal used to shutdown adapter endpoint threads.
Definition adapter_api.h:137
CdiSignalType start_signal
Signal used to start adapter endpoint threads. A separate signal is used for the connection (see Adap...
Definition adapter_api.h:136
void * type_specific_ptr
Adapter specific endpoint data.
Definition adapter_api.h:162
uint32_t tx_in_flight_ref_count
Number of Tx payloads/packets in flight. When a payload is being queued to transmit,...
Definition adapter_api.h:146
CdiListEntry list_entry
Allow these structures to live in a list in the adapter connection.
Definition adapter_api.h:111
volatile uint32_t tx_packets_in_process
Number of Tx packets that are in process (sent but haven't received ACK/error response).
Definition adapter_api.h:130
int maximum_payload_bytes
The maximum number of bytes that can be sent in a packet through this connection. The number is compu...
Definition adapter_api.h:152
CdiSinglyLinkedList tx_packet_waiting_list
List of packets from packet queue waiting to be sent.
Definition adapter_api.h:127
int maximum_tx_sgl_entries
The maximum number of SGL entries that can be used to represent a single Tx packet of data.
Definition adapter_api.h:155
CdiProtocolHandle protocol_handle
Handle of protocol being used. Value is NULL if none configured.
Definition adapter_api.h:139
MessageFromEndpoint msg_from_endpoint_func_ptr
Address of function used to queue packet messages from the endpoint.
Definition adapter_api.h:118
AdapterConnectionState * adapter_con_state_ptr
Pointer back to the adapter connection used by this endpoint.
Definition adapter_api.h:115
int msg_prefix_size
The size of any required message prefix buffer space that an application must provide in front of all...
Definition adapter_api.h:160
volatile CdiConnectionStatus connection_status_code
Current state of this endpoint. NOTE: Made volatile, since it is written to and read by different thr...
Definition adapter_api.h:124
CdiEndpointHandle cdi_endpoint_handle
Handle of CDI endpoint associated with this adapter endpoint.
Definition adapter_api.h:113
Structure definition used to define the virtual table API interface for adapters.
Definition adapter_api.h:327
CdiReturnStatus(* Poll)(AdapterEndpointHandle handle)
Perform poll on an endpoint.
Definition adapter_api.h:347
CdiReturnStatus(* Start)(AdapterEndpointHandle handle)
Start an open endpoint.
Definition adapter_api.h:373
CdiReturnStatus(* RxBuffersFree)(const AdapterEndpointHandle handle, const CdiSgList *sgl_ptr)
Returns a receive data buffer to the endpoint's free pool.
Definition adapter_api.h:361
CdiReturnStatus(* Reset)(AdapterEndpointHandle handle)
Reset an open endpoint.
Definition adapter_api.h:369
CdiReturnStatus(* Close)(AdapterEndpointHandle handle)
Closes an open endpoint.
Definition adapter_api.h:343
CdiReturnStatus(* CreateConnection)(AdapterConnectionHandle handle, int port_number, const char *bind_ip_addr_str)
Create a new connection.
Definition adapter_api.h:330
CdiReturnStatus(* Send)(const AdapterEndpointHandle handle, const Packet *packet_ptr, bool flush_packets)
Sends the data in memory specified by the SGL to the endpoint.
Definition adapter_api.h:357
CdiReturnStatus(* DestroyConnection)(AdapterConnectionHandle handle)
Destroy an open connection.
Definition adapter_api.h:334
EndpointTransmitQueueLevel(* GetTransmitQueueLevel)(AdapterEndpointHandle handle)
Checks transmit queue level. A polled mode endpoint will return kEndpointTransmitBufferFull when its ...
Definition adapter_api.h:353
CdiReturnStatus(* GetPort)(const AdapterEndpointHandle handle, int *ret_port_number_ptr)
Returns the port number being used by the endpoint.
Definition adapter_api.h:365
CdiReturnStatus(* Shutdown)(CdiAdapterHandle adapter)
Shuts down an adapter, freeing all of its associated resources.
Definition adapter_api.h:377
CdiReturnStatus(* Open)(AdapterEndpointHandle handle, const char *remote_address_str, int port_number, const char *bind_ip_addr_str)
Opens a new endpoint. For send type (transmit) endpoints, a pointer to the remote_address_str must be...
Definition adapter_api.h:338
Structure definition used to configure an adapter endpoint.
Definition adapter_api.h:440
CdiUserCbParameter connection_user_cb_param
User defined connection callback parameter.
Definition adapter_api.h:449
CdiConnectionHandle cdi_connection_handle
A handle to the CDI connection.
Definition adapter_api.h:442
EndpointDirection direction
Indicates whether the endpoint will be used for sending or for receiving packets.
Definition adapter_api.h:455
int thread_core_num
The core to dedicate to this connection's hardware poll thread. The value is the 0-based CPU number o...
Definition adapter_api.h:470
int port_number
For send type endpoints, the port number on the remote host to connect to. For receive type endpoints...
Definition adapter_api.h:459
int shared_thread_id
Identifier of poll thread to associate with this connection. Specify -1 to create a unique poll threa...
Definition adapter_api.h:466
CdiLogHandle log_handle
A handle to the log to use for this endpoint.
Definition adapter_api.h:452
CdiAdapterHandle cdi_adapter_handle
A handle to the adapter using this connection.
Definition adapter_api.h:441
EndpointManagerHandle endpoint_manager_handle
A handle to the Endpoint Manager for this connection.
Definition adapter_api.h:443
const char * bind_ip_addr_str
Address IP to bind to.
Definition adapter_api.h:462
RxAdapterConnectionState rx_state
Valid if direction = kEndpointDirectionReceive or kEndpointDirectionBidirectional.
Definition adapter_api.h:473
EndpointDataType data_type
Indicates the type of transmission data this endpoint supports.
Definition adapter_api.h:476
CdiCoreConnectionCallback connection_cb_ptr
Address of connection callback function.
Definition adapter_api.h:446
Configuration data used by the CdiCoreNetworkAdapterInitialize() API function.
Definition cdi_core_api.h:480
Structure definition used to configure an adapter endpoint.
Definition adapter_api.h:482
CdiEndpointHandle cdi_endpoint_handle
Handle of CDI endpoint associated with this adapter endpoint.
Definition adapter_api.h:484
const char * remote_address_str
A string representing a remote host's IP address in dotted decimal format. Only applies to send type ...
Definition adapter_api.h:495
AdapterConnectionHandle connection_handle
A handle to the adapter connection related to this endpoint.
Definition adapter_api.h:483
CdiAdapterEndpointStats * endpoint_stats_ptr
Address where to write adapter endpoint statistics.
Definition adapter_api.h:491
const char * bind_address_str
A string representing the IP address to bind to in dotted decimal format.
Definition adapter_api.h:502
int port_number
For send type endpoints, the port number on the remote host to connect to. For receive type endpoints...
Definition adapter_api.h:499
void * msg_from_endpoint_param_ptr
Pointer to parameter passed to queue message function.
Definition adapter_api.h:488
MessageFromEndpoint msg_from_endpoint_func_ptr
Address of function used to queue messages from this endpoint.
Definition adapter_api.h:487
Transfer statistics data specific to an adapter endpoint. Used in the CdiTransferStats structure as a...
Definition cdi_core_api.h:552
Structure definition behind the handles shared with the user's application program....
Definition adapter_api.h:384
CdiCsID adapter_lock
Lock used to protect access to adapter state data.
Definition adapter_api.h:392
void * type_specific_ptr
Data specific to the type of underlying adapter.
Definition adapter_api.h:415
CdiList poll_thread_list
List of poll threads using this adapter (holds PollThreadState*). NOTE: Must acquire adapter_lock bef...
Definition adapter_api.h:412
CdiList connection_list
List of connections using this adapter.
Definition adapter_api.h:408
bool tx_payload_buffer_is_hugepages
If true, tx_payload_buffer_allocated_ptr is using hugepages, otherwise it is using heap memory.
Definition adapter_api.h:418
uint32_t magic
Set to kMagicAdapter when allocated, checked at every API function to help ensure validity.
Definition adapter_api.h:389
CdiPoolHandle probe_work_request_pool_handle
Memory pool of Tx EFA probe packet work requests (ProbePacketWorkRequest).
Definition adapter_api.h:434
CdiAdapterData adapter_data
Adapter configuration data.
Definition adapter_api.h:399
CdiCsID connection_list_lock
Lock used to protect access to connection_list.
Definition adapter_api.h:405
struct AdapterVirtualFunctionPtrTable * functions_ptr
Pointer to the table of adapter specific operation functions.
Definition adapter_api.h:402
void * tx_payload_buffer_allocated_ptr
Pointer to start of the allocated transmit buffer. The buffer is available for the application....
Definition adapter_api.h:431
CdiListEntry list_entry
Used to store an instance of this object in a list using this element as the list item.
Definition adapter_api.h:386
uint64_t tx_payload_buffer_allocated_size
Size in bytes of Tx payload buffer allocated. Pointer to allocated buffer is in tx_payload_buffer_all...
Definition adapter_api.h:426
char adapter_ip_addr_str[MAX_IP_STRING_LENGTH]
Copy of the adapter's IP address string. "adapter_data.adapter_ip_addr_str" (see below) points to thi...
Definition adapter_api.h:396
uint64_t tx_payload_buffer_size_bytes
User configured size in bytes of a memory region for holding payload data to transmit....
Definition adapter_api.h:422
Structure definition behind the connection handles shared with the user's application program....
Definition private.h:371
Structure definition behind the connection handles shared with the user's application program....
Definition private.h:330
This structure represents a single list entry.
Definition list_api.h:34
This structure represents a list.
Definition list_api.h:42
Structure used to hold state data for a single log of any type (stdout, callback or file).
Definition logger.c:79
This structure represents the current state of a memory pool.
Definition pool.c:46
Structure used to hold negotiated protocol version information.
Definition protocol.h:242
This structure defines a scatter-gather list (SGL) which is used to represent an array of data compri...
Definition cdi_core_api.h:728
This structure represents a single list entry.
Definition singly_linked_list_api.h:49
This structure represents a list.
Definition singly_linked_list_api.h:56
Type used to hold control interface state data.
Definition adapter_control_interface.c:32
This defines a structure that contains all the state information for endpoint state changes.
Definition endpoint_manager.c:88
Definition adapter_api.h:42
CdiSinglyLinkedListEntry list_entry
This member is needed for these to be members of a list.
Definition adapter_api.h:43
bool payload_last_packet
True if last packet of a payload.
Definition adapter_api.h:45
AdapterPacketAckStatus ack_status
Status of the packet.
Definition adapter_api.h:48
CdiSgList sg_list
List of buffer fragments that comprise the packet's data.
Definition adapter_api.h:44
This defines a structure that contains the state information for a single instance of a poll thread.
Definition adapter_api.h:209
int thread_core_num
The core to dedicate to this hardware poll thread. The value is the 0-based CPU number or -1 to disab...
Definition adapter_api.h:218
bool only_transmit
True if all endpoints using this poll thread only transmit.
Definition adapter_api.h:226
EndpointDataType data_type
The type of endpoint data this poll thread supports.
Definition adapter_api.h:220
CdiCsID connection_list_lock
Lock used to protect access to connection_list.
Definition adapter_api.h:232
CdiSignalType start_signal
Signal used to start poll thread. A separate signal is used for endpoints (see AdapterEndpointState....
Definition adapter_api.h:238
bool is_poll
True if connection requires polling, otherwise connection does not require polling....
Definition adapter_api.h:224
CdiList connection_list
List of connections (AdapterConnectionState*) used by this poll thread.
Definition adapter_api.h:234
CdiThreadID thread_id
thread ID used by both Tx/Rx endpoints.
Definition adapter_api.h:212
int shared_thread_id
User defined shared poll thread identifier.
Definition adapter_api.h:214
CdiSignalType connection_list_changed_signal
Signal set when connection_list has been changed.
Definition adapter_api.h:228
CdiListEntry list_entry
Allow these structures to live in a list in the Adapter.
Definition adapter_api.h:210
CdiSignalType connection_list_processed_signal
Signal set when connection_list has been processed.
Definition adapter_api.h:229
This defines a structure that contains the state information for an rx adapter connection.
Definition adapter_api.h:171
int reserve_packet_buffers
Number of packet buffers to reserve for incoming payloads.
Definition adapter_api.h:173
Type used to hold thread utilization state data.
Definition adapter_api.h:244
uint64_t top_time
Time at start of each poll loop.
Definition adapter_api.h:245
uint64_t start_time
Time to use for start of each averaging period.
Definition adapter_api.h:248
uint64_t idle_accumulator
Number of idle microseconds accumulated over an averaging period.
Definition adapter_api.h:247
uint64_t busy_accumulator
Number of productive microseconds accumulated over an averaging period.
Definition adapter_api.h:246