XLIO
The NVIDIA® Accelerated IO
Socket Management

Functions for creating and managing XLIO sockets. More...

Classes

struct  xlio_socket_attr
 Socket creation attributes. More...
 

Typedefs

typedef uintptr_t xlio_socket_t
 Socket handle. More...
 

Functions

int xlio_socket_create (const struct xlio_socket_attr *attr, xlio_socket_t *sock_out)
 Create a new XLIO socket. More...
 
int xlio_socket_destroy (xlio_socket_t sock)
 Destroy an XLIO socket. More...
 
int xlio_socket_update (xlio_socket_t sock, unsigned flags, uintptr_t userdata_sq)
 Update socket attributes. More...
 
int xlio_socket_setsockopt (xlio_socket_t sock, int level, int optname, const void *optval, socklen_t optlen)
 Set socket options. More...
 
int xlio_socket_getsockname (xlio_socket_t sock, struct sockaddr *addr, socklen_t *addrlen)
 Get socket name. More...
 
int xlio_socket_getpeername (xlio_socket_t sock, struct sockaddr *addr, socklen_t *addrlen)
 Get peer name. More...
 
int xlio_socket_bind (xlio_socket_t sock, const struct sockaddr *addr, socklen_t addrlen)
 Bind socket to address. More...
 
int xlio_socket_connect (xlio_socket_t sock, const struct sockaddr *to, socklen_t tolen)
 Connect socket to remote address. More...
 
int xlio_socket_listen (xlio_socket_t sock)
 Listen for incoming connections. More...
 
struct ibv_pd * xlio_socket_get_pd (xlio_socket_t sock)
 Get InfiniBand protection domain. More...
 
int xlio_socket_detach_group (xlio_socket_t sock)
 Detach socket from polling group. More...
 
int xlio_socket_attach_group (xlio_socket_t sock, xlio_poll_group_t group)
 Attach socket to polling group. More...
 

Detailed Description

Functions for creating and managing XLIO sockets.

XLIO sockets are high-performance TCP socket abstractions that provide zero-copy capabilities. They are represented by opaque handles rather than file descriptors.

Typedef Documentation

◆ xlio_socket_t

typedef uintptr_t xlio_socket_t

Socket handle.

Opaque handle representing an XLIO high-performance socket.

Function Documentation

◆ xlio_socket_attach_group()

int xlio_socket_attach_group ( xlio_socket_t  sock,
xlio_poll_group_t  group 
)

Attach socket to polling group.

Attaches a previously detached socket to a polling group. The socket will begin generating events according to the group's configuration.

Parameters
sockThe socket to attach
groupThe polling group to attach to
Returns
0 on success, -1 on error
Error Codes:
  • EINVAL: Socket is already attached
  • ENOMEM: No memory to complete the operation
  • ENOTCONN: Failed to attach TX flow
  • ECONNABORTED: Failed to attach RX flow

◆ xlio_socket_bind()

int xlio_socket_bind ( xlio_socket_t  sock,
const struct sockaddr *  addr,
socklen_t  addrlen 
)

Bind socket to address.

Binds the socket to a local address, similar to bind().

Parameters
sockThe socket to bind
addrThe address to bind to
addrlenLength of the address
Returns
0 on success, -1 on error (errno is set)
Error Codes:
  • ENODEV: Trying to bind to a non-NVIDIA NIC
  • Inherits bind(2) error codes
See also
bind(2)

◆ xlio_socket_connect()

int xlio_socket_connect ( xlio_socket_t  sock,
const struct sockaddr *  to,
socklen_t  tolen 
)

Connect socket to remote address.

Initiates a connection to a remote address. The operation is non-blocking, and the connection status is reported via the socket event callback.

Parameters
sockThe socket to connect
toThe remote address to connect to
tolenLength of the remote address
Returns
0 on success, -1 on error (errno is set)
Error Codes:
  • EISCONN: The socket is already connected
  • EALREADY: Previous connect attempt hasn't been completed yet
  • ECONNABORTED: Previous connect attempt has failed
  • ENODEV: Cannot establish connection with XLIO Ultra API or NVIDIA NIC
Note
This function returns immediately. Connection establishment is indicated by the XLIO_SOCKET_EVENT_ESTABLISHED event. If a connection failure occurs an XLIO_SOCKET_EVENT_ERROR event will be delivered.
See also
connect(2)

◆ xlio_socket_create()

int xlio_socket_create ( const struct xlio_socket_attr attr,
xlio_socket_t sock_out 
)

Create a new XLIO socket.

Creates a new XLIO socket with the specified attributes. The socket is automatically associated with the specified polling group and configured for high-performance operation.

Parameters
attrSocket attributes
sock_outPointer to store the created socket handle
Returns
0 on success, -1 on error (errno is set)
Error Codes:
  • EINVAL: Invalid parameters (sock_out is NULL, attr is NULL, group is invalid, or domain is not AF_INET/AF_INET6)
  • ENOMEM: Insufficient memory
  • EMFILE: Too many open files
See also
xlio_socket_destroy()
xlio_socket_attr

◆ xlio_socket_destroy()

int xlio_socket_destroy ( xlio_socket_t  sock)

Destroy an XLIO socket.

Initiates the socket closing procedure. The process may be asynchronous, and socket events may continue to arrive until the XLIO_SOCKET_EVENT_TERMINATED event is received.

Parameters
sockThe socket to destroy
Returns
0 on success, -1 on error (errno is set)
Error Codes:
  • EINVAL: Invalid socket handle
Note
Zero-copy completion events may still arrive after calling this function until the TERMINATED event is received.

◆ xlio_socket_detach_group()

int xlio_socket_detach_group ( xlio_socket_t  sock)

Detach socket from polling group.

Removes the socket from its current polling group. The socket becomes inactive and will not generate events until attached to another group.

Parameters
sockThe socket to detach
Returns
0 on success, -1 on error
Error Codes:
  • EINVAL: Socket is not connected or already detached
  • ENOTSUP: Not supported with listen sockets
Note
During the 2-step socket migration (detach -> attach), there is a time window during which RX packets are dropped until the socket is completely attached to the new group. Applications should minimize this window to avoid packet loss and TCP retransmissions.

◆ xlio_socket_get_pd()

struct ibv_pd* xlio_socket_get_pd ( xlio_socket_t  sock)

Get InfiniBand protection domain.

Returns the InfiniBand protection domain associated with the socket. This can be used for registering memory regions for zero-copy operations.

Parameters
sockThe socket to query
Returns
Pointer to ibv_pd structure, or NULL on error
Note
Socket must be connected or in progress of connecting.

◆ xlio_socket_getpeername()

int xlio_socket_getpeername ( xlio_socket_t  sock,
struct sockaddr *  addr,
socklen_t *  addrlen 
)

Get peer name.

Retrieves the remote address of the socket, similar to getpeername().

Parameters
sockThe socket to query
addrBuffer to store the address
addrlenPointer to the address length
Returns
0 on success, -1 on error (errno is set)
See also
getpeername(2)

◆ xlio_socket_getsockname()

int xlio_socket_getsockname ( xlio_socket_t  sock,
struct sockaddr *  addr,
socklen_t *  addrlen 
)

Get socket name.

Retrieves the local address of the socket, similar to getsockname().

Parameters
sockThe socket to query
addrBuffer to store the address
addrlenPointer to the address length
Returns
0 on success, -1 on error (errno is set)
See also
getsockname(2)

◆ xlio_socket_listen()

int xlio_socket_listen ( xlio_socket_t  sock)

Listen for incoming connections.

Configures the socket to listen for incoming connections. Requires that the polling group has a socket_accept_cb callback registered.

Parameters
sockThe socket to configure for listening
Returns
0 on success, -1 on error (errno is set)
Error Codes:
  • ENOTCONN: No accept callback registered in the polling group
  • EINVAL: Socket is already connected
  • EADDRINUSE: Another socket is already listening on the same port
  • ENODEV: Trying to listen on a non-NVIDIA NIC or an internal error preventing the socket from being offloaded
Note
The socket must be bound before calling this function.
See also
listen(2)

◆ xlio_socket_setsockopt()

int xlio_socket_setsockopt ( xlio_socket_t  sock,
int  level,
int  optname,
const void *  optval,
socklen_t  optlen 
)

Set socket options.

Sets socket options, similar to the standard setsockopt() function. Supports standard socket options as well as XLIO-specific options.

Parameters
sockThe socket to configure
levelThe protocol level (SOL_SOCKET, IPPROTO_TCP, etc.)
optnameThe option name
optvalPointer to the option value
optlenLength of the option value
Returns
0 on success, -1 on error (errno is set)
See also
setsockopt(2)

◆ xlio_socket_update()

int xlio_socket_update ( xlio_socket_t  sock,
unsigned  flags,
uintptr_t  userdata_sq 
)

Update socket attributes.

Updates the flags and user data associated with a socket. This allows changing socket behavior and context without recreating the socket.

Parameters
sockThe socket to update
flagsNew flags for the socket
userdata_sqNew user data for the socket
Returns
0 on success, -1 on error