21 #include <sys/socket.h>
26 #define XLIO_MAGIC_NUMBER (0x4f494c584144564eULL)
36 XLIO_EXTRA_API_REGISTER_RECV_CALLBACK = (1 << 0),
37 XLIO_EXTRA_API_ADD_CONF_RULE = (1 << 3),
38 XLIO_EXTRA_API_THREAD_OFFLOAD = (1 << 4),
39 XLIO_EXTRA_API_DUMP_FD_STATS = (1 << 11),
40 XLIO_EXTRA_API_XLIO_ULTRA = (1 << 13),
43 struct __attribute__((packed)) xlio_api_t {
66 int (*add_conf_rule)(
const char *config_line);
75 int (*thread_offload)(
int offload, pthread_t tid);
83 int (*dump_fd_stats)(
int fd,
int log_level);
95 int (*register_recv_callback)(
int s, xlio_recv_callback_t callback,
void *context);
138 static inline struct xlio_api_t *xlio_get_api()
140 struct xlio_api_t *api_ptr = NULL;
141 socklen_t len =
sizeof(api_ptr);
144 int err = getsockopt(-2, SOL_SOCKET, SO_XLIO_GET_API, &api_ptr, &len);
148 if (len <
sizeof(
struct xlio_api_t *) || api_ptr == NULL ||
149 api_ptr->magic != XLIO_MAGIC_NUMBER) {
int xlio_exit(void)
Finalize XLIO.
int xlio_init_ex(const struct xlio_init_attr *attr)
Initialize the XLIO Ultra API.
int xlio_poll_group_destroy(xlio_poll_group_t group)
Destroy a polling group.
int xlio_poll_group_create(const struct xlio_poll_group_attr *attr, xlio_poll_group_t *group_out)
Create a new polling group.
uintptr_t xlio_poll_group_t
Polling group handle.
Definition: xlio_types.h:164
void xlio_poll_group_poll(xlio_poll_group_t group)
Poll for events on a polling group.
void xlio_socket_buf_free(xlio_socket_t sock, struct xlio_buf *buf)
Free a receive buffer (socket-specific)
void xlio_poll_group_buf_free(xlio_poll_group_t group, struct xlio_buf *buf)
Free a receive buffer (group-specific)
int xlio_socket_attach_group(xlio_socket_t sock, xlio_poll_group_t group)
Attach socket to polling group.
int xlio_socket_create(const struct xlio_socket_attr *attr, xlio_socket_t *sock_out)
Create a new XLIO socket.
int xlio_socket_update(xlio_socket_t sock, unsigned flags, uintptr_t userdata_sq)
Update socket attributes.
uintptr_t xlio_socket_t
Socket handle.
Definition: xlio_types.h:172
int xlio_socket_listen(xlio_socket_t sock)
Listen for incoming connections.
int xlio_socket_getsockname(xlio_socket_t sock, struct sockaddr *addr, socklen_t *addrlen)
Get socket name.
int xlio_socket_destroy(xlio_socket_t sock)
Destroy an XLIO socket.
int xlio_socket_getpeername(xlio_socket_t sock, struct sockaddr *addr, socklen_t *addrlen)
Get peer name.
int xlio_socket_detach_group(xlio_socket_t sock)
Detach socket from polling group.
int xlio_socket_setsockopt(xlio_socket_t sock, int level, int optname, const void *optval, socklen_t optlen)
Set socket options.
int xlio_socket_bind(xlio_socket_t sock, const struct sockaddr *addr, socklen_t addrlen)
Bind socket to address.
int xlio_socket_connect(xlio_socket_t sock, const struct sockaddr *to, socklen_t tolen)
Connect socket to remote address.
void xlio_poll_group_flush(xlio_poll_group_t group)
Flush all dirty sockets in a polling group.
int xlio_socket_sendv(xlio_socket_t sock, const struct iovec *iov, unsigned iovcnt, const struct xlio_socket_send_attr *attr)
Send vectored data on a socket.
int xlio_socket_send(xlio_socket_t sock, const void *data, size_t len, const struct xlio_socket_send_attr *attr)
Send data on a socket.
void xlio_socket_flush(xlio_socket_t sock)
Flush pending data on a socket.
Buffer descriptor.
Definition: xlio_types.h:198
XLIO initialization attributes.
Definition: xlio_types.h:371
Polling group attributes.
Definition: xlio_types.h:414
Socket creation attributes.
Definition: xlio_types.h:450
Send operation attributes.
Definition: xlio_types.h:489
XLIO API type definitions and structures.