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

This file contains definitions and functions for the EFA adapter. More...

#include "adapter_efa.h"
#include <inttypes.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <dlfcn.h>
#include "adapter_efa_probe_control.h"
#include "internal.h"
#include "internal_log.h"
#include "internal_tx.h"
#include "internal_utility.h"
#include "libfabric_api.h"
#include "private.h"
#include "cdi_os_api.h"

Data Structures

struct  EfaAdapterState
 Structure used to hold EFA adapter state data. More...
 

Macros

#define MAX_TCP_PACKET_SIZE   (9001 - 20 - 20)
 Calculate the maximum TCP payload size by starting with the jumbo frame size supported by AWS networks and subtracting space for the IP and TCP headers. The space for the Ethernet headers has already been subtracted since the true jumbo frame size supported is 9023. Reference: https://aws.amazon.com/about-aws/whats-new/2018/10/aws-direct-connect-now-supports-jumbo-frames-for-amazon-virtual-private-cloud-traffic/ https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/network_mtu.html.
 
#define MAX_INT_STRING_LENGTH   (32)
 Maximum string length of an integer value.
 
#define DEFAULT_MSG_PREFIX_SIZE   (0)
 Variable for testing parts of the code dealing with libfabric's message prefix mode. The default should be zero. But even with prefix mode turned off and the default set to non-zero, all tests should pass. This may help in determining whether an issue with message prefix mode is likely caused by a bug in the SDK or a bug in libfabric.
 
#define CHECK_LIBFABRIC_RC(function, ret)
 Produce a log message when a libfabric call unexpectedly failed.
 
#define FI_OPT_EFA_RNR_RETRY   -(0xefa << 16)
 The define below is from libfabric_new/prov/psm3/inc/rdma/fi_ext.h.
 

Functions

static CdiReturnStatus EfaConnectionCreate (AdapterConnectionHandle handle, int port_number, const char *bind_ip_addr_str)
 Forward declaration of function.
 
static CdiReturnStatus EfaConnectionDestroy (AdapterConnectionHandle handle)
 Forward declaration of function.
 
static CdiReturnStatus EfaEndpointOpen (AdapterEndpointHandle endpoint_handle, const char *remote_address_str, int port_number, const char *bind_ip_addr_str)
 Forward declaration of function.
 
static CdiReturnStatus EfaEndpointPoll (AdapterEndpointHandle handle)
 Forward declaration of function.
 
static CdiReturnStatus EfaEndpointReset (AdapterEndpointHandle handle)
 Forward declaration of function.
 
static CdiReturnStatus EfaEndpointStart (AdapterEndpointHandle handle)
 Forward declaration of function.
 
static CdiReturnStatus EfaEndpointClose (AdapterEndpointHandle handle)
 Forward declaration of function.
 
static CdiReturnStatus EfaAdapterShutdown (CdiAdapterHandle adapter)
 Forward declaration of function.
 
static CdiReturnStatus LibFabricEndpointClose (EfaEndpointState *endpoint_ptr)
 Forward declaration.
 
static CdiReturnStatus SetMaximumEfaPayloadSize (struct fi_info *fi_ptr, EfaEndpointState *endpoint_ptr)
 
static struct fi_info * CreateHints (LibfabricApi *libfabric_api_ptr, bool is_socket_based)
 
static void LibfabricVersionSet (EfaEndpointState *endpoint_ptr, LibfabricApi *libfabric_api_ptr)
 Set libfabric API version for an endpoint.
 
static CdiReturnStatus LibFabricEndpointOpen (EfaEndpointState *endpoint_ptr)
 
static CdiReturnStatus EfaAdapterEndpointStop (EfaEndpointState *endpoint_ptr, bool reopen)
 
static CdiReturnStatus EnvironmentVariableSet (const char *name_str, int value)
 
CdiReturnStatus EfaNetworkAdapterInitialize (CdiAdapterState *adapter_state_ptr, bool is_socket_based)
 
CdiReturnStatus EfaAdapterProbeEndpointCreate (EfaEndpointState *endpoint_ptr, ProbeEndpointHandle *ret_probe_handle)
 
CdiReturnStatus EfaAdapterEndpointStart (EfaEndpointState *endpoint_ptr)
 
CdiAdapterHandle EfaAdapterGetAdapterControlInterface (AdapterConnectionState *adapter_con_state_ptr)
 
bool EfaAdapterEndpointProtocolVersionSet (EfaEndpointState *endpoint_ptr, const CdiProtocolVersionNumber *remote_version_ptr)
 Set the protocol version for the specified endpoint. The protocol version actually used is negotiated using the specified remote version and the current version of the CDI-SDK.
 

Variables

static struct AdapterVirtualFunctionPtrTable efa_endpoint_functions
 Define the virtual table API interface for this adapter.
 

Detailed Description

This file contains definitions and functions for the EFA adapter.

Macro Definition Documentation

◆ CHECK_LIBFABRIC_RC

#define CHECK_LIBFABRIC_RC ( function,
ret )
Value:
do { \
if (0 < ret) { \
SDK_LOG_GLOBAL(kLogError, #function " returned [%d] unexpectedly.", ret); \
} else if (0 > ret) { \
SDK_LOG_GLOBAL(kLogError, #function " returned [%d,%s] unexpectedly.", ret, \
endpoint_ptr->libfabric_api_ptr->fi_strerror(-ret)); \
} \
if (0 != ret) { \
} \
} while (0)
@ kCdiStatusFatal
An unspecified, unrecoverable error occurred.
Definition cdi_core_api.h:194
@ kLogError
Errors to the user.
Definition cdi_log_enums.h:53

Produce a log message when a libfabric call unexpectedly failed.

Function Documentation

◆ CreateHints()

static struct fi_info * CreateHints ( LibfabricApi * libfabric_api_ptr,
bool is_socket_based )
static

Allocate memory for a libfabric hints structure, initialize it for the EFA adapter and return a pointer to the next structure.

Parameters
libfabric_api_ptrPointer to libfabric V-table API.
is_socket_basedSpecifies whether the adapter is socket-based (true) or EFA-based (false).
Returns
Pointer to new hints structure. Returns NULL if unable to allocate memory.

◆ EfaAdapterEndpointProtocolVersionSet()

bool EfaAdapterEndpointProtocolVersionSet ( EfaEndpointState * endpoint_ptr,
const CdiProtocolVersionNumber * remote_version_ptr )

Set the protocol version for the specified endpoint. The protocol version actually used is negotiated using the specified remote version and the current version of the CDI-SDK.

Parameters
endpoint_ptrPointer to endpoint.
remote_version_ptrPointer to remote protocol version data.
Returns
True if successful, otherwise false is returned.

◆ EfaAdapterEndpointStart()

CdiReturnStatus EfaAdapterEndpointStart ( EfaEndpointState * endpoint_ptr)

Start the specified endpoint. This only allocates and starts low-level libfabric and EFA device driver resources. Other resources have already been created and started when the connection was created.

Parameters
endpoint_ptrPointer to the EFA endpoint to start.
Returns
kCdiStatusOk if successful, otherwise a value that indicates the nature of the failure is returned.

◆ EfaAdapterEndpointStop()

static CdiReturnStatus EfaAdapterEndpointStop ( EfaEndpointState * endpoint_ptr,
bool reopen )
static

Stop the specified endpoint. This only stops and frees low-level libfabric and EFA device driver resources. Other resources that were created when the connection was created are not affected.

Parameters
endpoint_ptrPointer to the adapter endpoint to stop.
reopenIf true re-opens the libfabric endpoint, otherwise does not re-open it.
Returns
kCdiStatusOk if successful, otherwise a value that indicates the nature of the failure is returned.

◆ EfaAdapterGetAdapterControlInterface()

CdiAdapterHandle EfaAdapterGetAdapterControlInterface ( AdapterConnectionState * adapter_con_state_ptr)

Get handle of adapter control inteface related to the specified EFA endpoint.

Parameters
adapter_con_state_ptrPointer to adapter connection state data.
Returns
Handle of control interface adapter.

◆ EfaAdapterProbeEndpointCreate()

CdiReturnStatus EfaAdapterProbeEndpointCreate ( EfaEndpointState * endpoint_ptr,
ProbeEndpointHandle * ret_probe_handle )

Create probe for the specified EFA endpoint.

Parameters
endpoint_ptrPointer to the adapter endpoint to create a probe for.
ret_probe_handlePointer to returned probe handle.
Returns
kCdiStatusOk if successful, otherwise a value that indicates the nature of the failure is returned.

◆ EfaAdapterShutdown()

static CdiReturnStatus EfaAdapterShutdown ( CdiAdapterHandle adapter_handle)
static

Forward declaration of function.

Shutdown the selected adapter instance.

Parameters
adapter_handleHandle of adapter to shutdown.
Returns
kCdiStatusOk if successful, otherwise a value that indicates the nature of the failure is returned.

◆ EfaConnectionCreate()

static CdiReturnStatus EfaConnectionCreate ( AdapterConnectionHandle handle,
int port_number,
const char * bind_ip_addr_str )
static

Forward declaration of function.

Create an EFA connection using the specified adapter.

Parameters
handleHandle of adapter connection to open.
port_numberControl interface port to use for the connection.
bind_ip_addr_strPointer to string IP address to bind to.
Returns
kCdiStatusOk if successful, otherwise a value that indicates the nature of the failure is returned.

◆ EfaConnectionDestroy()

static CdiReturnStatus EfaConnectionDestroy ( AdapterConnectionHandle handle)
static

Forward declaration of function.

Destroy an EFA connection to the specified adapter connection.

Parameters
handleHandle of adapter connection to close.
Returns
kCdiStatusOk if successful, otherwise a value that indicates the nature of the failure is returned.

◆ EfaEndpointClose()

static CdiReturnStatus EfaEndpointClose ( AdapterEndpointHandle endpoint_handle)
static

Forward declaration of function.

Close an EFA connection to the specified adapter endpoint.

Parameters
endpoint_handleHandle of adapter endpoint to close.
Returns
kCdiStatusOk if successful, otherwise a value that indicates the nature of the failure is returned.

◆ EfaEndpointOpen()

static CdiReturnStatus EfaEndpointOpen ( AdapterEndpointHandle endpoint_handle,
const char * remote_address_str,
int port_number,
const char * bind_ip_addr_str )
static

Forward declaration of function.

Open a EFA connection to the specified adapter endpoint.

Parameters
endpoint_handleHandle of adapter endpoint to open.
remote_address_strPointer to remote address string.
port_numberPort number for endpoint.
bind_ip_addr_strPointer to bind address string.
Returns
kCdiStatusOk if successful, otherwise a value that indicates the nature of the failure is returned.

◆ EfaEndpointPoll()

static CdiReturnStatus EfaEndpointPoll ( AdapterEndpointHandle endpoint_handle)
static

Forward declaration of function.

Used to poll pending EFA events and process them.

Parameters
endpoint_handlePointer endpoint state data.
Returns
either kCdiStatusInternalIdle or kCdiStatusOk if successful, otherwise a value that indicates the nature of the failure is returned. kCdiStatusInternalIdle means that the function performed no productive work while kCdiStatusOk says that did.

◆ EfaEndpointReset()

static CdiReturnStatus EfaEndpointReset ( AdapterEndpointHandle endpoint_handle)
static

Forward declaration of function.

Reset an EFA connection for the specified adapter endpoint.

Parameters
endpoint_handleHandle of adapter endpoint to reset.
Returns
kCdiStatusOk if successful, otherwise a value that indicates the nature of the failure is returned.

◆ EfaEndpointStart()

static CdiReturnStatus EfaEndpointStart ( AdapterEndpointHandle endpoint_handle)
static

Forward declaration of function.

Start an EFA connection for the specified adapter endpoint.

Parameters
endpoint_handleHandle of adapter endpoint to start.
Returns
kCdiStatusOk if successful, otherwise a value that indicates the nature of the failure is returned.

◆ EfaNetworkAdapterInitialize()

CdiReturnStatus EfaNetworkAdapterInitialize ( CdiAdapterState * adapter_state_ptr,
bool is_socket_based )

Initializes an EFA adapter specified by the values in the provided CdiAdapterState structure.

Parameters
adapter_state_ptrThe address of the generic adapter state preinitialized with the generic values including the CdiAdapterData structure which contains the values provided to the SDK by the user program.
is_socket_basedSpecifies whether the adapter is socket-based (true) or EFA-based (false).
Returns
CdiReturnStatus kCdiStausOk if successful, otherwise a value indicating the nature of failure.

◆ EnvironmentVariableSet()

static CdiReturnStatus EnvironmentVariableSet ( const char * name_str,
int value )
static

Set an environment variable.

Parameters
name_strPointer to name of variable to set.
valueInteger value to set.
Returns
kCdiStatusOk if successful, otherwise kCdiStatusFatal is returned.

◆ LibFabricEndpointClose()

static CdiReturnStatus LibFabricEndpointClose ( EfaEndpointState * endpoint_ptr)
static

Forward declaration.

Close a libfabric connection to the specified endpoint.

Parameters
endpoint_ptrPointer to EFA endpoint to close.
Returns
kCdiStatusOk if successful, otherwise a value that indicates the nature of the failure is returned.

◆ LibFabricEndpointOpen()

static CdiReturnStatus LibFabricEndpointOpen ( EfaEndpointState * endpoint_ptr)
static

Open a libfabric connection to the specified endpoint.

Parameters
endpoint_ptrPointer to EFA endpoint to open.
Returns
kCdiStatusOk if successful, otherwise a value that indicates the nature of the failure is returned.

◆ LibfabricVersionSet()

static void LibfabricVersionSet ( EfaEndpointState * endpoint_ptr,
LibfabricApi * libfabric_api_ptr )
static

Set libfabric API version for an endpoint.

Parameters
endpoint_ptrPointer to EFA endpoint to set version of libfabric.
libfabric_api_ptrPointer to libfabric API version to set.

◆ SetMaximumEfaPayloadSize()

static CdiReturnStatus SetMaximumEfaPayloadSize ( struct fi_info * fi_ptr,
EfaEndpointState * endpoint_ptr )
static

Determine maximum payload size that fits in a single link-level packet. Set both the adapter's maximum_payload_bytes and msg_prefix_size.

Parameters
fi_ptrPointer to name of variable to set.
endpoint_ptrPointer to the EFA endpoint state to be configured.

Variable Documentation

◆ efa_endpoint_functions

struct AdapterVirtualFunctionPtrTable efa_endpoint_functions
static
Initial value:
= {
.CreateConnection = EfaConnectionCreate,
.DestroyConnection = EfaConnectionDestroy,
.Open = EfaEndpointOpen,
.Close = EfaEndpointClose,
.Poll = EfaEndpointPoll,
.GetTransmitQueueLevel = EfaGetTransmitQueueLevel,
.RxBuffersFree = EfaRxEndpointRxBuffersFree,
.GetPort = NULL,
.Reset = EfaEndpointReset,
.Start = EfaEndpointStart,
.Shutdown = EfaAdapterShutdown,
}
static CdiReturnStatus EfaEndpointClose(AdapterEndpointHandle handle)
Forward declaration of function.
Definition adapter_efa.c:916
static CdiReturnStatus EfaConnectionCreate(AdapterConnectionHandle handle, int port_number, const char *bind_ip_addr_str)
Forward declaration of function.
Definition adapter_efa.c:675
static CdiReturnStatus EfaEndpointOpen(AdapterEndpointHandle endpoint_handle, const char *remote_address_str, int port_number, const char *bind_ip_addr_str)
Forward declaration of function.
Definition adapter_efa.c:764
static CdiReturnStatus EfaAdapterShutdown(CdiAdapterHandle adapter)
Forward declaration of function.
Definition adapter_efa.c:952
static CdiReturnStatus EfaConnectionDestroy(AdapterConnectionHandle handle)
Forward declaration of function.
Definition adapter_efa.c:727
static CdiReturnStatus EfaEndpointStart(AdapterEndpointHandle handle)
Forward declaration of function.
Definition adapter_efa.c:881
static CdiReturnStatus EfaEndpointReset(AdapterEndpointHandle handle)
Forward declaration of function.
Definition adapter_efa.c:852
static CdiReturnStatus EfaEndpointPoll(AdapterEndpointHandle handle)
Forward declaration of function.
Definition adapter_efa.c:825
EndpointTransmitQueueLevel EfaGetTransmitQueueLevel(const AdapterEndpointHandle handle)
Definition adapter_efa_tx.c:268
CdiReturnStatus EfaRxEndpointRxBuffersFree(const AdapterEndpointHandle handle, const CdiSgList *sgl_ptr)
Definition adapter_efa_rx.c:343
CdiReturnStatus EfaTxEndpointSend(const AdapterEndpointHandle handle, const Packet *packet_ptr, bool flush_packets)
Definition adapter_efa_tx.c:280

Define the virtual table API interface for this adapter.