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_DIR "/run/vpp" 39 #define MEMIF_DEFAULT_SOCKET_FILENAME "memif.sock" 40 #define MEMIF_DEFAULT_RING_SIZE 1024 41 #define MEMIF_DEFAULT_LOG2_RING_SIZE 10 42 #define MEMIF_DEFAULT_RX_QUEUES 1 43 #define MEMIF_DEFAULT_TX_QUEUES 1 44 #define MEMIF_DEFAULT_BUFFER_SIZE 2048 46 #define MEMIF_MAX_M2S_RING 255 47 #define MEMIF_MAX_S2M_RING 255 48 #define MEMIF_MAX_REGION 255 49 #define MEMIF_MAX_LOG2_RING_SIZE 14 51 #define MEMIF_MAX_FDS 512 53 #define memif_min(a,b) (((a) < (b)) ? (a) : (b)) 55 #define EXPECT_TRUE(x) __builtin_expect((x),1) 56 #define EXPECT_FALSE(x) __builtin_expect((x),0) 59 #define DBG(...) do { \ 60 printf("MEMIF_DEBUG:%s:%s:%d: ", __FILE__, __func__, __LINE__); \ 61 printf(__VA_ARGS__); \ 135 uint8_t remote_disconnect_string[96];
146 #define MEMIF_CONNECTION_FLAG_WRITE (1 << 0) 168 struct itimerspec arm, disarm;
211 uint16_t
len,
int key);
215 #ifndef __NR_memfd_create 216 #if defined __x86_64__ 217 #define __NR_memfd_create 319 218 #elif defined __arm__ 219 #define __NR_memfd_create 385 220 #elif defined __aarch64__ 221 #define __NR_memfd_create 279 223 #error "__NR_memfd_create unknown for this architecture" 227 #ifndef HAVE_MEMFD_CREATE 231 return syscall (__NR_memfd_create, name, flags);
239 return (conn->regions[ring->
desc[index].
region].addr +
243 #ifndef F_LINUX_SPECIFIC_BASE 244 #define F_LINUX_SPECIFIC_BASE 1024 247 #ifndef MFD_ALLOW_SEALING 248 #define MFD_ALLOW_SEALING 0x0002U 252 #define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9) 253 #define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10) 255 #define F_SEAL_SEAL 0x0001 256 #define F_SEAL_SHRINK 0x0002 257 #define F_SEAL_GROW 0x0004 258 #define F_SEAL_WRITE 0x0008
int memif_init_regions_and_queues(memif_connection_t *c)
memif_queue_t * rx_queues
Optimized string handling code, including c11-compliant "safe C library" variants.
memif_list_elt_t * pending_list
int get_list_elt(memif_list_elt_t **e, memif_list_elt_t *list, uint16_t len, int key)
memif_control_fd_update_t * control_fd_update
int() memif_control_fd_update_t(int fd, uint8_t events)
Memif control file descriptor update (callback function)
memif_get_external_buffer_offset_t * get_external_buffer_offset
#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
memif_list_elt_t * listener_list
memif_realloc_t * realloc
int free_list_elt(memif_list_elt_t *list, uint16_t len, int key)
int add_list_elt(memif_list_elt_t *e, memif_list_elt_t **list, uint16_t *len)
memif_list_elt_t * interrupt_list
memif_region_index_t region
struct memif_msg_queue_elt memif_msg_queue_elt_t
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
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_add_external_region_t * add_external_region
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)
memif_msg_queue_elt_t * msg_queue
void *() memif_realloc_t(void *ptr, size_t size)
Memif realloc.
static int memfd_create(const char *name, unsigned int flags)
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)
uint16_t interrupt_list_len
memif_conn_run_args_t run_args
memif_region_offset_t offset
memif_interrupt_t * on_interrupt
memif_del_external_region_t * del_external_region
uint16_t pending_list_len
memif_list_elt_t * control_list
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
uint16_t control_list_len
memif_get_external_region_addr_t * get_external_region_addr
uint16_t listener_list_len
Memif connection arguments.
uint16_t interface_list_len