XLIO
The NVIDIA® Accelerated IO
Loading...
Searching...
No Matches
xlio_types.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
14#ifndef XLIO_TYPES_H
15#define XLIO_TYPES_H
16
17#include <stddef.h>
18#include <stdint.h>
19#include <netinet/in.h>
20#include <sys/socket.h>
21#include <sys/time.h>
22
23/*
24 * Options for setsockopt()/getsockopt()
25 */
26#define SO_XLIO_GET_API 2800
27#define SO_XLIO_RING_ALLOC_LOGIC 2810
28#define SO_XLIO_SHUTDOWN_RX 2821
29/*
30 * Insert an 802.1Q VLAN tag to the following TX packets. Doesn't affect RX packets handling.
31 * The option value is an integer of type `int` which represents the VLAN ID field of the VLAN tag.
32 * The value must be non-negative number less than 4096. Value 0 disables the feature.
33 * The option allows to set VLAN ID to the reserved values 1 and 0xFFF without restrictions.
34 *
35 * Limitations:
36 * - TCP sockets only
37 * - Incoming connections are not supported
38 * - Must be configured on a non-connected socket before calling connect() and affects the first
39 * SYN segment
40 */
41#define SO_XLIO_EXT_VLAN_TAG 2824
42
44 uint32_t rate; /* rate limit in Kbps */
45 uint32_t max_burst_sz; /* maximum burst size in bytes */
46 uint16_t typical_pkt_sz; /* typical packet size in bytes */
47};
48
49typedef enum {
50 RING_LOGIC_PER_INTERFACE = 0,
51 RING_LOGIC_PER_IP = 1,
52 RING_LOGIC_PER_SOCKET = 10,
53 RING_LOGIC_PER_USER_ID = 11,
54 RING_LOGIC_PER_THREAD = 20,
55 RING_LOGIC_PER_CORE = 30,
56 RING_LOGIC_PER_CORE_ATTACH_THREADS = 31,
57 RING_LOGIC_PER_OBJECT = 32,
58 RING_LOGIC_LAST
59} ring_logic_t;
60
61typedef enum {
62 XLIO_RING_ALLOC_MASK_RING_USER_ID = (1 << 0),
63 XLIO_RING_ALLOC_MASK_RING_INGRESS = (1 << 1),
64 XLIO_RING_ALLOC_MASK_RING_ENGRESS = (1 << 2),
65} xlio_ring_alloc_logic_attr_comp_mask;
66
67/*
68 * @brief pass this struct to process by the library using setsockopt with
69 * @ref SO_XLIO_RING_ALLOC_LOGIC
70 * to set the allocation logic of this FD when he requests a ring.
71 * @note ring_alloc_logic is a mandatory
72 * @param comp_mask - what fields are read when processing this struct
73 * see @ref xlio_ring_alloc_logic_attr_comp_mask
74 * @param ring_alloc_logic- allocation ratio to use
75 * @param user_idx - when used RING_LOGIC_PER_USER_ID int @ref ring_alloc_logic
76 * this is the user id to define. This lets you define the same ring for
77 * few FD's regardless the interface\thread\core.
78 * @param ingress - RX ring
79 * @param engress - TX ring
80 */
82 uint32_t comp_mask;
83 ring_logic_t ring_alloc_logic;
84 uint32_t user_id;
85 uint32_t ingress : 1;
86 uint32_t engress : 1;
87 uint32_t reserved : 30;
88};
89
101typedef uintptr_t xlio_poll_group_t;
102
109typedef uintptr_t xlio_socket_t;
110
135struct xlio_buf {
136 uint64_t userdata;
137};
138
// end of xlio_rx group
140
171typedef void (*xlio_memory_cb_t)(void *addr, size_t len, size_t hugepage_size);
172
174enum {
183};
184
212typedef void (*xlio_socket_event_cb_t)(xlio_socket_t sock, uintptr_t userdata_sq, int event,
213 int value);
214
236typedef void (*xlio_socket_comp_cb_t)(xlio_socket_t sock, uintptr_t userdata_sq,
237 uintptr_t userdata_op);
238
258typedef void (*xlio_socket_rx_cb_t)(xlio_socket_t sock, uintptr_t userdata_sq, void *data,
259 size_t len, struct xlio_buf *buf);
260
279 uintptr_t parent_userdata_sq);
280
// end of xlio_callbacks group
282
309 unsigned flags;
310 xlio_memory_cb_t memory_cb;
311
312 /* Optional external user allocator for XLIO buffers. */
313 void *(*memory_alloc)(size_t);
314 void (*memory_free)(void *);
315};
316
// end of xlio_init group
318
325#define XLIO_GROUP_FLAG_SAFE 0x1
327#define XLIO_GROUP_FLAG_DIRTY 0x2
328
352 unsigned flags;
353
354 xlio_socket_event_cb_t socket_event_cb;
355 xlio_socket_comp_cb_t socket_comp_cb;
356 xlio_socket_rx_cb_t socket_rx_cb;
357 xlio_socket_accept_cb_t socket_accept_cb;
358};
359
// end of xlio_poll_group group
361
388 unsigned flags;
389 int domain; /* AF_INET or AF_INET6 */
390 xlio_poll_group_t group;
391 uintptr_t userdata_sq;
392};
393
// end of xlio_socket group
395
402#define XLIO_SOCKET_SEND_FLAG_FLUSH 0x1
404#define XLIO_SOCKET_SEND_FLAG_INLINE 0x2
405
427 unsigned flags;
428 uint32_t mkey;
429 uintptr_t userdata_op;
430};
431
// end of xlio_tx group
433
// end of xlio_ultra_api group
435
436#endif /* XLIO_TYPES_H */
void(* xlio_socket_event_cb_t)(xlio_socket_t sock, uintptr_t userdata_sq, int event, int value)
Socket event callback function.
Definition xlio_types.h:212
void(* xlio_memory_cb_t)(void *addr, size_t len, size_t hugepage_size)
Memory allocation callback function.
Definition xlio_types.h:171
void(* xlio_socket_accept_cb_t)(xlio_socket_t sock, xlio_socket_t parent, uintptr_t parent_userdata_sq)
Accept callback function.
Definition xlio_types.h:278
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.
Definition xlio_types.h:258
void(* xlio_socket_comp_cb_t)(xlio_socket_t sock, uintptr_t userdata_sq, uintptr_t userdata_op)
Zero-copy completion callback function.
Definition xlio_types.h:236
@ XLIO_SOCKET_EVENT_ESTABLISHED
Definition xlio_types.h:176
@ XLIO_SOCKET_EVENT_ERROR
Definition xlio_types.h:182
@ XLIO_SOCKET_EVENT_CLOSED
Definition xlio_types.h:180
@ XLIO_SOCKET_EVENT_TERMINATED
Definition xlio_types.h:178
uintptr_t xlio_poll_group_t
Polling group handle.
Definition xlio_types.h:101
uintptr_t xlio_socket_t
Socket handle.
Definition xlio_types.h:109
Buffer descriptor.
Definition xlio_types.h:135
XLIO initialization attributes.
Definition xlio_types.h:308
Polling group attributes.
Definition xlio_types.h:351
Definition xlio_types.h:43
Definition xlio_types.h:81
Socket creation attributes.
Definition xlio_types.h:387
Send operation attributes.
Definition xlio_types.h:426