XLIO
The NVIDIA® Accelerated IO
Event Callbacks

Callback functions for handling socket events. More...

Typedefs

typedef void(* xlio_memory_cb_t) (void *addr, size_t len, size_t hugepage_size)
 Memory allocation callback function. More...
 
typedef void(* xlio_socket_event_cb_t) (xlio_socket_t sock, uintptr_t userdata_sq, int event, int value)
 Socket event callback function. More...
 
typedef void(* xlio_socket_comp_cb_t) (xlio_socket_t sock, uintptr_t userdata_sq, uintptr_t userdata_op)
 Zero-copy completion callback function. More...
 
typedef void(* xlio_socket_rx_cb_t) (xlio_socket_t sock, uintptr_t userdata_sq, void *data, size_t len, struct xlio_buf *buf)
 Receive data callback function. More...
 
typedef void(* xlio_socket_accept_cb_t) (xlio_socket_t sock, xlio_socket_t parent, uintptr_t parent_userdata_sq)
 Accept callback function. More...
 

Enumerations

enum  { XLIO_SOCKET_EVENT_ESTABLISHED = 1 , XLIO_SOCKET_EVENT_TERMINATED , XLIO_SOCKET_EVENT_CLOSED , XLIO_SOCKET_EVENT_ERROR }
 Socket events. More...
 

Detailed Description

Callback functions for handling socket events.

The XLIO Ultra API uses callbacks to notify applications of various events including connection state changes, data arrival, and completion of zero-copy operations.

Most of the callbacks are expected from the xlio_poll_group_poll() context.

Typedef Documentation

◆ xlio_memory_cb_t

typedef void(* xlio_memory_cb_t) (void *addr, size_t len, size_t hugepage_size)

Memory allocation callback function.

This callback is invoked when XLIO allocates memory regions that can be used for RX buffers. Applications can use this information for memory management or preparation.

Parameters
addrBase address of the allocated memory
lenSize of the allocated memory
hugepage_sizePage size if hugepages are used, 0 for regular pages
Note
If hugepage_size is non-zero, both addr and len are aligned to the page size boundary. For external allocators, hugepage_size is always reported as zero.
See also
xlio_init_attr

◆ xlio_socket_accept_cb_t

typedef void(* xlio_socket_accept_cb_t) (xlio_socket_t sock, xlio_socket_t parent, uintptr_t parent_userdata_sq)

Accept callback function.

This callback is invoked when a new connection is accepted on a listening socket. The new socket is automatically created and associated with the same polling group.

Parameters
sockThe newly accepted socket
parentThe listening socket that accepted the connection
parent_userdata_sqUser data from the parent socket
Note
The new socket inherits the polling group from the parent but may need additional configuration (e.g., userdata_sq update).
See also
xlio_socket_update()
xlio_poll_group_attr

◆ xlio_socket_comp_cb_t

typedef void(* xlio_socket_comp_cb_t) (xlio_socket_t sock, uintptr_t userdata_sq, uintptr_t userdata_op)

Zero-copy completion callback function.

This callback is invoked when a zero-copy send operation completes, allowing the application to reclaim or reuse the transmitted buffers.

Parameters
sockThe socket that completed the operation
userdata_sqUser data associated with the socket
userdata_opUser data associated with the specific operation
Calling Contexts:
Note
Send operations are allowed in this callback unless the socket is being destroyed.
See also
xlio_socket_send_attr
xlio_poll_group_attr

◆ xlio_socket_event_cb_t

typedef void(* xlio_socket_event_cb_t) (xlio_socket_t sock, uintptr_t userdata_sq, int event, int value)

Socket event callback function.

This callback is invoked when socket state changes occur, such as connection establishment, errors, or termination.

Parameters
sockThe socket generating the event
userdata_sqUser data associated with the socket
eventThe event type (XLIO_SOCKET_EVENT_*)
valueEvent-specific value (error code for ERROR events, 0 otherwise)
Event Types:
  • XLIO_SOCKET_EVENT_ESTABLISHED: TCP connection established
  • XLIO_SOCKET_EVENT_TERMINATED: Socket terminated, no further events
  • XLIO_SOCKET_EVENT_CLOSED: Passive close by remote peer
  • XLIO_SOCKET_EVENT_ERROR: Error occurred, see value for error code
Error Codes (for ERROR events):
  • ECONNABORTED: Connection aborted by local side
  • ECONNRESET: Connection reset by remote side
  • ECONNREFUSED: Connection refused during handshake
  • ETIMEDOUT: Connection timed out
Note
Send operations are allowed only from the ESTABLISHED event context.
See also
xlio_poll_group_attr

◆ xlio_socket_rx_cb_t

typedef void(* xlio_socket_rx_cb_t) (xlio_socket_t sock, uintptr_t userdata_sq, void *data, size_t len, struct xlio_buf *buf)

Receive data callback function.

This callback is invoked when TCP payload arrives on a socket. Each call provides a single contiguous buffer containing received data.

Parameters
sockThe socket that received the data
userdata_sqUser data associated with the socket
dataPointer to the received data
lenLength of the received data
bufBuffer descriptor that must be returned via xlio_*_buf_free()
Note
The data pointer is valid only until the buffer is freed. The buffer's userdata field can be used during user ownership.
See also
xlio_socket_buf_free()
xlio_poll_group_buf_free()
xlio_poll_group_attr

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Socket events.

Enumerator
XLIO_SOCKET_EVENT_ESTABLISHED 

TCP connection established.

XLIO_SOCKET_EVENT_TERMINATED 

Socket terminated and no further events are possible.

XLIO_SOCKET_EVENT_CLOSED 

Passive close.

XLIO_SOCKET_EVENT_ERROR 

An error occurred, see the error code value.