XLIO
The NVIDIA® Accelerated IO
Loading...
Searching...
No Matches
xlio.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES
3 * Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
4 * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause
5 */
6
27#ifndef XLIO_H
28#define XLIO_H
29
30#include <fcntl.h>
31#include <poll.h>
32#include <sched.h>
33#include <signal.h>
34#include <stdint.h>
35#include <sys/epoll.h>
36#include <sys/stat.h>
37#include <sys/time.h>
38
39#include "xlio_types.h"
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
45int xlio_socket(int __domain, int __type, int __protocol);
46
47int xlio_close(int __fd);
48
49int xlio_shutdown(int __fd, int __how);
50
51int xlio_listen(int __fd, int backlog);
52
53int xlio_accept(int __fd, struct sockaddr *__addr, socklen_t *__addrlen);
54
55int xlio_accept4(int __fd, struct sockaddr *__addr, socklen_t *__addrlen, int __flags);
56
57int xlio_bind(int __fd, const struct sockaddr *__addr, socklen_t __addrlen);
58
59int xlio_connect(int __fd, const struct sockaddr *__to, socklen_t __tolen);
60
61int xlio_setsockopt(int __fd, int __level, int __optname, __const void *__optval,
62 socklen_t __optlen);
63
64int xlio_getsockopt(int __fd, int __level, int __optname, void *__optval, socklen_t *__optlen);
65
66int xlio_fcntl(int __fd, int __cmd, ...);
67
68int xlio_fcntl64(int __fd, int __cmd, ...);
69
70int xlio_getsockname(int __fd, struct sockaddr *__name, socklen_t *__namelen);
71
72int xlio_getpeername(int __fd, struct sockaddr *__name, socklen_t *__namelen);
73
74ssize_t xlio_read(int __fd, void *__buf, size_t __nbytes);
75
76ssize_t xlio_readv(int __fd, const struct iovec *iov, int iovcnt);
77
78ssize_t xlio_recv(int __fd, void *__buf, size_t __nbytes, int __flags);
79
80ssize_t xlio_recvmsg(int __fd, struct msghdr *__msg, int __flags);
81
82struct mmsghdr;
83
84int xlio_recvmmsg(int __fd, struct mmsghdr *__mmsghdr, unsigned int __vlen, int __flags,
85 const struct timespec *__timeout);
86
87ssize_t xlio_recvfrom(int __fd, void *__buf, size_t __nbytes, int __flags, struct sockaddr *__from,
88 socklen_t *__fromlen);
89
90ssize_t xlio_write(int __fd, __const void *__buf, size_t __nbytes);
91
92ssize_t xlio_writev(int __fd, const struct iovec *iov, int iovcnt);
93
94ssize_t xlio_send(int __fd, __const void *__buf, size_t __nbytes, int __flags);
95
96ssize_t xlio_sendmsg(int __fd, __const struct msghdr *__msg, int __flags);
97
98int xlio_sendmmsg(int __fd, struct mmsghdr *__mmsghdr, unsigned int __vlen, int __flags);
99
100ssize_t xlio_sendto(int __fd, __const void *__buf, size_t __nbytes, int __flags,
101 const struct sockaddr *__to, socklen_t __tolen);
102
103ssize_t xlio_sendfile(int out_fd, int in_fd, off_t *offset, size_t count);
104
105ssize_t xlio_sendfile64(int out_fd, int in_fd, __off64_t *offset, size_t count);
106
107int xlio_select(int __nfds, fd_set *__readfds, fd_set *__writefds, fd_set *__exceptfds,
108 struct timeval *__timeout);
109
110int xlio_pselect(int __nfds, fd_set *__readfds, fd_set *__writefds, fd_set *__errorfds,
111 const struct timespec *__timeout, const sigset_t *__sigmask);
112int xlio_poll(struct pollfd *__fds, nfds_t __nfds, int __timeout);
113
114int xlio_ppoll(struct pollfd *__fds, nfds_t __nfds, const struct timespec *__timeout,
115 const sigset_t *__sigmask);
116
117int xlio_epoll_create(int __size);
118
119int xlio_epoll_create1(int __flags);
120
121int xlio_epoll_ctl(int __epfd, int __op, int __fd, struct epoll_event *__event);
122
123int xlio_epoll_wait(int __epfd, struct epoll_event *__events, int __maxevents, int __timeout);
124
125int xlio_epoll_pwait(int __epfd, struct epoll_event *__events, int __maxevents, int __timeout,
126 const sigset_t *__sigmask);
127int xlio_socketpair(int __domain, int __type, int __protocol, int __sv[2]);
128
129int xlio_pipe(int __filedes[2]);
130
131int xlio_open(__const char *__file, int __oflag, ...);
132
133int xlio_creat(const char *__pathname, mode_t __mode);
134
135int xlio_dup(int __fd);
136
137int xlio_dup2(int __fd, int __fd2);
138
139/*
140 * Add a libxlio.conf rule to the top of the list.
141 * This rule will not apply to existing sockets which already considered the conf rules.
142 * (around connect/listen/send/recv ..)
143 * @param config_line A char buffer with the exact format as defined in libxlio.conf, and should
144 * end with '\0'.
145 * @return 0 on success, or error code on failure.
146 */
147int xlio_add_conf_rule(const char *config_line);
148
149/*
150 * Create sockets on pthread tid as offloaded/not-offloaded.
151 * This does not affect existing sockets.
152 * Offloaded sockets are still subject to libxlio.conf rules.
153 * @param offload 1 for offloaded, 0 for not-offloaded.
154 * @return 0 on success, or error code on failure.
155 */
156int xlio_thread_offload(int offload, pthread_t tid);
157
158/*
159 * Dump fd statistics using the library logger.
160 * @param fd to dump, 0 for all open fds.
161 * @param log_level dumping level corresponding vlog_levels_t enum (vlogger.h).
162 * @return 0 on success, or error code on failure.
163 */
164int xlio_dump_fd_stats(int fd, int log_level);
165
251/* Forward declaration. */
252struct ibv_pd;
253
275int xlio_init_ex(const struct xlio_init_attr *attr);
276
293int xlio_init(void);
294
302int xlio_exit(void);
303
// end of xlio_init group
305
350
361
376
390
// end of xlio_poll_group group
392
450int xlio_socket_create(const struct xlio_socket_attr *attr, xlio_socket_t *sock_out);
451
471
483int xlio_socket_update(xlio_socket_t sock, unsigned flags, uintptr_t userdata_sq);
484
500int xlio_socket_setsockopt(xlio_socket_t sock, int level, int optname, const void *optval,
501 socklen_t optlen);
502
515int xlio_socket_getsockname(xlio_socket_t sock, struct sockaddr *addr, socklen_t *addrlen);
516
529int xlio_socket_getpeername(xlio_socket_t sock, struct sockaddr *addr, socklen_t *addrlen);
530
547int xlio_socket_bind(xlio_socket_t sock, const struct sockaddr *addr, socklen_t addrlen);
548
572int xlio_socket_connect(xlio_socket_t sock, const struct sockaddr *to, socklen_t tolen);
573
595
608
628
646
// end of xlio_socket group
648
693int xlio_socket_send(xlio_socket_t sock, const void *data, size_t len,
694 const struct xlio_socket_send_attr *attr);
695
709int xlio_socket_sendv(xlio_socket_t sock, const struct iovec *iov, unsigned iovcnt,
710 const struct xlio_socket_send_attr *attr);
711
725
741
// end of xlio_tx group
743
781
794
// end of xlio_rx group
796
// end of xlio_ultra_api group
798
799#ifdef __cplusplus
800}
801#endif
802#endif /* XLIO_H */
int xlio_exit(void)
Finalize XLIO.
int xlio_init(void)
Initialize 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.
int xlio_poll_group_update(xlio_poll_group_t group, const struct xlio_poll_group_attr *attr)
Update polling group attributes.
uintptr_t xlio_poll_group_t
Polling group handle.
Definition xlio_types.h:101
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:109
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.
struct ibv_pd * xlio_socket_get_pd(xlio_socket_t sock)
Get InfiniBand protection domain.
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:135
XLIO initialization attributes.
Definition xlio_types.h:308
Polling group attributes.
Definition xlio_types.h:351
Socket creation attributes.
Definition xlio_types.h:387
Send operation attributes.
Definition xlio_types.h:426
XLIO API type definitions and structures.