19 #ifndef _MEMIF_PRIVATE_H_ 20 #define _MEMIF_PRIVATE_H_ 24 #include <sys/syscall.h> 28 #include <sys/timerfd.h> 34 #define MEMIF_NAME_LEN 32 36 "MEMIF_DEFAULT_APP_NAME max length is 32");
38 #define MEMIF_DEFAULT_SOCKET_PATH "/run/vpp/memif.sock" 39 #define MEMIF_DEFAULT_RING_SIZE 1024 40 #define MEMIF_DEFAULT_LOG2_RING_SIZE 10 41 #define MEMIF_DEFAULT_RX_QUEUES 1 42 #define MEMIF_DEFAULT_TX_QUEUES 1 43 #define MEMIF_DEFAULT_BUFFER_SIZE 2048 44 #define MEMIF_DEFAULT_RECONNECT_PERIOD_SEC 2 45 #define MEMIF_DEFAULT_RECONNECT_PERIOD_NSEC 0 47 #define MEMIF_MAX_M2S_RING 255 48 #define MEMIF_MAX_S2M_RING 255 49 #define MEMIF_MAX_REGION 255 50 #define MEMIF_MAX_LOG2_RING_SIZE 14 52 #define MEMIF_MAX_FDS 512 54 #define memif_min(a,b) (((a) < (b)) ? (a) : (b)) 56 #define EXPECT_TRUE(x) __builtin_expect((x),1) 57 #define EXPECT_FALSE(x) __builtin_expect((x),0) 60 #define DBG(...) do { \ 61 printf("MEMIF_DEBUG:%s:%s:%d: ", __FILE__, __func__, __LINE__); \ 62 printf(__VA_ARGS__); \ 123 struct libmemif_main;
144 uint8_t remote_disconnect_string[96];
155 #define MEMIF_CONNECTION_FLAG_WRITE (1 << 0) 171 struct libmemif_main *
lm;
177 typedef struct libmemif_main
183 struct itimerspec arm, disarm;
235 #ifndef __NR_memfd_create 236 #if defined __x86_64__ 237 #define __NR_memfd_create 319 238 #elif defined __arm__ 239 #define __NR_memfd_create 385 240 #elif defined __aarch64__ 241 #define __NR_memfd_create 279 243 #error "__NR_memfd_create unknown for this architecture" 247 #ifndef HAVE_MEMFD_CREATE 251 return syscall (__NR_memfd_create, name, flags);
259 return (conn->regions[ring->
desc[index].
region].addr +
263 #ifndef F_LINUX_SPECIFIC_BASE 264 #define F_LINUX_SPECIFIC_BASE 1024 267 #ifndef MFD_ALLOW_SEALING 268 #define MFD_ALLOW_SEALING 0x0002U 272 #define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9) 273 #define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10) 275 #define F_SEAL_SEAL 0x0001 276 #define F_SEAL_SHRINK 0x0002 277 #define F_SEAL_GROW 0x0004 278 #define F_SEAL_WRITE 0x0008
int memif_init_regions_and_queues(memif_connection_t *c)
memif_queue_t * rx_queues
vl_api_wireguard_peer_flags_t flags
Optimized string handling code, including c11-compliant "safe C library" variants.
int get_list_elt(memif_list_elt_t **e, memif_list_elt_t *list, uint16_t len, int key)
memif_del_external_region_t * del_external_region
#define MEMIF_DEFAULT_APP_NAME
Default name of application using libmemif.
int() memif_fn(memif_connection_t *conn)
memif_list_elt_t * interface_list
int on_connect(memif_conn_handle_t conn, void *private_ctx)
memif_connection_update_t * on_disconnect
libmemif_main_t libmemif_main
int free_list_elt(memif_list_elt_t *list, uint16_t len, int key)
struct libmemif_main * lm
int add_list_elt(libmemif_main_t *lm, memif_list_elt_t *e, memif_list_elt_t **list, uint16_t *len)
libmemif_main_t * get_libmemif_main(memif_socket_t *ms)
memif_region_index_t region
struct memif_msg_queue_elt memif_msg_queue_elt_t
memif_list_elt_t * pending_list
int() memif_add_external_region_t(void **addr, uint32_t size, int *fd, void *private_ctx)
Add external region.
struct memif_connection memif_connection_t
uint8_t memif_log2_ring_size_t
void * memif_socket_handle_t
Memif socket handle pointer of type void, pointing to internal structure.
int memif_connect1(memif_connection_t *c)
int() memif_del_external_region_t(void *addr, uint32_t size, int fd, void *private_ctx)
Delete external region.
memif_queue_t * tx_queues
struct memif_msg_queue_elt * next
int() memif_interrupt_t(memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
Memif interrupt occured (callback function)
int() memif_connection_update_t(memif_conn_handle_t conn, void *private_ctx)
Memif connection status update (callback function)
memif_list_elt_t * interrupt_list
uint16_t pending_list_len
void() memif_free_t(void *ptr)
Memif allocator free.
int memif_disconnect_internal(memif_connection_t *c)
int memif_syscall_error_handler(int err_code)
struct libmemif_main libmemif_main_t
memif_list_elt_t * control_list
memif_socket_handle_t default_socket
memif_msg_queue_elt_t * msg_queue
uint16_t interrupt_list_len
uint16_t control_list_len
void *() memif_realloc_t(void *ptr, size_t size)
Memif realloc.
static int memfd_create(const char *name, unsigned int flags)
memif_realloc_t * realloc
uint32_t() memif_get_external_buffer_offset_t(void *private_ctx)
Get external buffer offset (optional)
static void * memif_get_buffer(memif_connection_t *conn, memif_ring_t *ring, uint16_t index)
memif_get_external_region_addr_t * get_external_region_addr
memif_conn_run_args_t run_args
memif_region_offset_t offset
memif_interrupt_t * on_interrupt
memif_add_external_region_t * add_external_region
memif_get_external_buffer_offset_t * get_external_buffer_offset
void *() memif_alloc_t(size_t size)
Memif allocator alloc.
void *() memif_get_external_region_addr_t(uint32_t size, int fd, void *private_ctx)
Get external region address.
memif_log2_ring_size_t log2_ring_size
memif_control_fd_update_t * control_fd_update
memif_list_elt_t * socket_list
Memif connection arguments.
uint16_t interface_list_len
int() memif_control_fd_update_t(int fd, uint8_t events, void *private_ctx)
Memif control file descriptor update (callback function)