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__); \ 134 uint8_t remote_disconnect_string[96];
142 #define MEMIF_CONNECTION_FLAG_WRITE (1 << 0) 164 struct itimerspec arm, disarm;
201 uint16_t len,
int key);
205 #ifndef __NR_memfd_create 206 #if defined __x86_64__ 207 #define __NR_memfd_create 319 208 #elif defined __arm__ 209 #define __NR_memfd_create 385 210 #elif defined __aarch64__ 211 #define __NR_memfd_create 279 213 #error "__NR_memfd_create unknown for this architecture" 217 #ifndef HAVE_MEMFD_CREATE 221 return syscall (__NR_memfd_create, name, flags);
229 return (conn->regions[ring->
desc[index].
region].shm +
233 #ifndef F_LINUX_SPECIFIC_BASE 234 #define F_LINUX_SPECIFIC_BASE 1024 237 #ifndef MFD_ALLOW_SEALING 238 #define MFD_ALLOW_SEALING 0x0002U 242 #define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9) 243 #define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10) 245 #define F_SEAL_SEAL 0x0001 246 #define F_SEAL_SHRINK 0x0002 247 #define F_SEAL_GROW 0x0004 248 #define F_SEAL_WRITE 0x0008
int memif_init_regions_and_queues(memif_connection_t *c)
memif_queue_t * rx_queues
int( memif_fn)(memif_connection_t *conn)
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)
int( memif_control_fd_update_t)(int fd, uint8_t events)
Memif control file descriptor update (callback function)
memif_control_fd_update_t * control_fd_update
#define MEMIF_DEFAULT_APP_NAME
Default name of application using libmemif.
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
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_interrupt_t)(memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
Memif interrupt occured (callback function)
struct memif_connection memif_connection_t
uint8_t memif_log2_ring_size_t
int( memif_connection_update_t)(memif_conn_handle_t conn, void *private_ctx)
Memif connection status update (callback function)
int memif_connect1(memif_connection_t *c)
memif_queue_t * tx_queues
struct memif_msg_queue_elt * next
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
static int memfd_create(const char *name, unsigned int flags)
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
uint16_t pending_list_len
memif_list_elt_t * control_list
memif_log2_ring_size_t log2_ring_size
uint16_t control_list_len
uint16_t listener_list_len
Memif connection arguments.
uint16_t interface_list_len
void *( memif_alloc_t)(size_t size)
Memif allocator alloc.