FD.io VPP  v20.09-64-g4f7b92f0a
Vector Packet Processing
libmemif.h File Reference
+ Include dependency graph for libmemif.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  memif_conn_args_t
 Memif connection arguments. More...
 
struct  memif_buffer_t
 Memif buffer. More...
 
struct  memif_queue_details_t
 Memif queue details. More...
 
struct  memif_region_details_t
 Memif region details. More...
 
struct  memif_details_t
 Memif details. More...
 

Macros

#define LIBMEMIF_VERSION   "3.1"
 Libmemif version. More...
 
#define MEMIF_DEFAULT_APP_NAME   "libmemif-app"
 Default name of application using libmemif. More...
 
#define MEMIF_FD_EVENT_READ   (1 << 0)
 user needs to set events that occured on fd and pass them to memif_control_fd_handler More...
 
#define MEMIF_FD_EVENT_WRITE   (1 << 1)
 
#define MEMIF_FD_EVENT_ERROR   (1 << 2)
 inform libmemif that error occured on fd More...
 
#define MEMIF_FD_EVENT_DEL   (1 << 3)
 if set, informs that fd is going to be closed (user may want to stop watching for events on this fd) More...
 
#define MEMIF_FD_EVENT_MOD   (1 << 4)
 update events More...
 
#define MEMIF_BUFFER_FLAG_NEXT   (1 << 0)
 next buffer present (chained buffers) More...
 
#define MEMIF_BUFFER_FLAG_RX   (1 << 1)
 states that buffer is from rx ring More...
 
#define MEMIF_QUEUE_FLAG_POLLING   1
 if set queue is in polling mode, else in interrupt mode More...
 
#define MEMIF_HAVE_CANCEL_POLL_EVENT   1
 Send signal to stop concurrently running memif_poll_event(). More...
 

Typedefs

typedef void * memif_per_thread_main_handle_t
 Memif per thread main handle Pointer of type void, pointing to internal structure. More...
 
typedef void * memif_conn_handle_t
 Memif connection handle pointer of type void, pointing to internal structure. More...
 
typedef void * memif_socket_handle_t
 Memif socket handle pointer of type void, pointing to internal structure. More...
 
typedef void *() memif_alloc_t(size_t size)
 Memif allocator alloc. More...
 
typedef void *() memif_realloc_t(void *ptr, size_t size)
 Memif realloc. More...
 
typedef void() memif_free_t(void *ptr)
 Memif allocator free. More...
 
typedef int() memif_control_fd_update_t(int fd, uint8_t events, void *private_ctx)
 Memif control file descriptor update (callback function) More...
 
typedef int() memif_connection_update_t(memif_conn_handle_t conn, void *private_ctx)
 Memif connection status update (callback function) More...
 
typedef int() memif_interrupt_t(memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
 Memif interrupt occured (callback function) More...
 
typedef uint32_t() memif_get_external_buffer_offset_t(void *private_ctx)
 Get external buffer offset (optional) More...
 
typedef int() memif_add_external_region_t(void **addr, uint32_t size, int *fd, void *private_ctx)
 Add external region. More...
 
typedef void *() memif_get_external_region_addr_t(uint32_t size, int fd, void *private_ctx)
 Get external region address. More...
 
typedef int() memif_del_external_region_t(void *addr, uint32_t size, int fd, void *private_ctx)
 Delete external region. More...
 

Enumerations

enum  memif_err_t {
  MEMIF_ERR_SUCCESS = 0, MEMIF_ERR_SYSCALL, MEMIF_ERR_CONNREFUSED, MEMIF_ERR_ACCES,
  MEMIF_ERR_NO_FILE, MEMIF_ERR_FILE_LIMIT, MEMIF_ERR_PROC_FILE_LIMIT, MEMIF_ERR_ALREADY,
  MEMIF_ERR_AGAIN, MEMIF_ERR_BAD_FD, MEMIF_ERR_NOMEM, MEMIF_ERR_INVAL_ARG,
  MEMIF_ERR_NOCONN, MEMIF_ERR_CONN, MEMIF_ERR_CB_FDUPDATE, MEMIF_ERR_FILE_NOT_SOCK,
  MEMIF_ERR_NO_SHMFD, MEMIF_ERR_COOKIE, MEMIF_ERR_NOBUF_RING, MEMIF_ERR_NOBUF,
  MEMIF_ERR_NOBUF_DET, MEMIF_ERR_INT_WRITE, MEMIF_ERR_MFMSG, MEMIF_ERR_QID,
  MEMIF_ERR_PROTO, MEMIF_ERR_ID, MEMIF_ERR_ACCSLAVE, MEMIF_ERR_ALRCONN,
  MEMIF_ERR_MODE, MEMIF_ERR_SECRET, MEMIF_ERR_NOSECRET, MEMIF_ERR_MAXREG,
  MEMIF_ERR_MAXRING, MEMIF_ERR_NO_INTFD, MEMIF_ERR_DISCONNECT, MEMIF_ERR_DISCONNECTED,
  MEMIF_ERR_UNKNOWN_MSG, MEMIF_ERR_POLL_CANCEL, MEMIF_ERR_MAX_RING, MEMIF_ERR_PRIVHDR
}
 
enum  memif_interface_mode_t {
  MEMIF_INTERFACE_MODE_ETHERNET = 0, MEMIF_INTERFACE_MODE_IP = 1, MEMIF_INTERFACE_MODE_PUNT_INJECT = 2, MEMIF_INTERFACE_MODE_ETHERNET = 0,
  MEMIF_INTERFACE_MODE_IP = 1, MEMIF_INTERFACE_MODE_PUNT_INJECT = 2, MEMIF_INTERFACE_MODE_ETHERNET = 0, MEMIF_INTERFACE_MODE_IP = 1,
  MEMIF_INTERFACE_MODE_PUNT_INJECT = 2
}
 
enum  memif_rx_mode_t { MEMIF_RX_MODE_INTERRUPT = 0, MEMIF_RX_MODE_POLLING }
 

Functions

void memif_register_external_region (memif_add_external_region_t *ar, memif_get_external_region_addr_t *gr, memif_del_external_region_t *dr, memif_get_external_buffer_offset_t *go)
 Register external region. More...
 
void memif_per_thread_register_external_region (memif_per_thread_main_handle_t pt_main, memif_add_external_region_t *ar, memif_get_external_region_addr_t *gr, memif_del_external_region_t *dr, memif_get_external_buffer_offset_t *go)
 Register external region. More...
 
uint16_t memif_get_version ()
 Memif get version. More...
 
int memif_get_queue_efd (memif_conn_handle_t conn, uint16_t qid, int *fd)
 Memif get queue event file descriptor. More...
 
int memif_set_rx_mode (memif_conn_handle_t conn, memif_rx_mode_t rx_mode, uint16_t qid)
 Memif set rx mode. More...
 
char * memif_strerror (int err_code)
 Memif strerror. More...
 
int memif_get_details (memif_conn_handle_t conn, memif_details_t *md, char *buf, ssize_t buflen)
 Memif get details. More...
 
int memif_init (memif_control_fd_update_t *on_control_fd_update, char *app_name, memif_alloc_t *memif_alloc, memif_realloc_t *memif_realloc, memif_free_t *memif_free)
 Memif initialization. More...
 
int memif_per_thread_init (memif_per_thread_main_handle_t *pt_main, void *private_ctx, memif_control_fd_update_t *on_control_fd_update, char *app_name, memif_alloc_t *memif_alloc, memif_realloc_t *memif_realloc, memif_free_t *memif_free)
 Memif per thread initialization. More...
 
int memif_cleanup ()
 Memif cleanup. More...
 
int memif_per_thread_cleanup (memif_per_thread_main_handle_t *pt_main)
 Memif per thread cleanup. More...
 
int memif_create (memif_conn_handle_t *conn, memif_conn_args_t *args, memif_connection_update_t *on_connect, memif_connection_update_t *on_disconnect, memif_interrupt_t *on_interrupt, void *private_ctx)
 Memory interface create function. More...
 
int memif_control_fd_handler (int fd, uint8_t events)
 Memif control file descriptor handler. More...
 
int memif_per_thread_control_fd_handler (memif_per_thread_main_handle_t pt_main, int fd, uint8_t events)
 Memif per thread control file descriptor handler. More...
 
int memif_delete (memif_conn_handle_t *conn)
 Memif delete. More...
 
int memif_buffer_enq_tx (memif_conn_handle_t conn, uint16_t qid, memif_buffer_t *bufs, uint16_t count, uint16_t *count_out)
 Memif buffer enq tx. More...
 
int memif_buffer_alloc (memif_conn_handle_t conn, uint16_t qid, memif_buffer_t *bufs, uint16_t count, uint16_t *count_out, uint16_t size)
 Memif buffer alloc. More...
 
int memif_refill_queue (memif_conn_handle_t conn, uint16_t qid, uint16_t count, uint16_t headroom)
 Memif refill ring. More...
 
int memif_tx_burst (memif_conn_handle_t conn, uint16_t qid, memif_buffer_t *bufs, uint16_t count, uint16_t *tx)
 Memif transmit buffer burst. More...
 
int memif_rx_burst (memif_conn_handle_t conn, uint16_t qid, memif_buffer_t *bufs, uint16_t count, uint16_t *rx)
 Memif receive buffer burst. More...
 
int memif_poll_event (int timeout)
 Memif poll event. More...
 
int memif_per_thread_poll_event (memif_per_thread_main_handle_t pt_main, int timeout)
 Memif poll event. More...
 
int memif_cancel_poll_event ()
 
int memif_per_thread_cancel_poll_event (memif_per_thread_main_handle_t pt_main)
 Send signal to stop concurrently running memif_poll_event(). More...
 
int memif_set_connection_request_timer (struct itimerspec timer)
 Set connection request timer value. More...
 
int memif_per_thread_set_connection_request_timer (memif_per_thread_main_handle_t pt_main, struct itimerspec timer)
 Set connection request timer value. More...
 
int memif_request_connection (memif_conn_handle_t conn)
 Send connection request. More...
 
int memif_create_socket (memif_socket_handle_t *sock, const char *filename, void *private_ctx)
 Create memif socket. More...
 
int memif_per_thread_create_socket (memif_per_thread_main_handle_t pt_main, memif_socket_handle_t *sock, const char *filename, void *private_ctx)
 Create memif socket. More...
 
int memif_delete_socket (memif_socket_handle_t *sock)
 Delete memif socket. More...
 
const char * memif_get_socket_filename (memif_socket_handle_t sock)
 Get socket filename. More...
 

Macro Definition Documentation

◆ LIBMEMIF_VERSION

#define LIBMEMIF_VERSION   "3.1"

Libmemif version.

Definition at line 26 of file libmemif.h.

◆ MEMIF_BUFFER_FLAG_NEXT

#define MEMIF_BUFFER_FLAG_NEXT   (1 << 0)

next buffer present (chained buffers)

Definition at line 329 of file libmemif.h.

◆ MEMIF_BUFFER_FLAG_RX

#define MEMIF_BUFFER_FLAG_RX   (1 << 1)

states that buffer is from rx ring

Definition at line 331 of file libmemif.h.

◆ MEMIF_DEFAULT_APP_NAME

#define MEMIF_DEFAULT_APP_NAME   "libmemif-app"

Default name of application using libmemif.

Definition at line 28 of file libmemif.h.

◆ MEMIF_QUEUE_FLAG_POLLING

#define MEMIF_QUEUE_FLAG_POLLING   1

if set queue is in polling mode, else in interrupt mode

Definition at line 359 of file libmemif.h.

Typedef Documentation

◆ memif_alloc_t

typedef void*() memif_alloc_t(size_t size)

Memif allocator alloc.

Parameters
size- requested allocation size

custom memory allocator: alloc function template

Definition at line 120 of file libmemif.h.

◆ memif_conn_handle_t

typedef void* memif_conn_handle_t

Memif connection handle pointer of type void, pointing to internal structure.

Definition at line 108 of file libmemif.h.

◆ memif_free_t

typedef void() memif_free_t(void *ptr)

Memif allocator free.

Parameters
size- requested allocation size

custom memory allocator: free function template

Definition at line 136 of file libmemif.h.

◆ memif_per_thread_main_handle_t

Memif per thread main handle Pointer of type void, pointing to internal structure.

Used to identify internal per thread database.

Definition at line 103 of file libmemif.h.

◆ memif_realloc_t

typedef void*() memif_realloc_t(void *ptr, size_t size)

Memif realloc.

Parameters
ptr- pointer to memory block
size- requested allocation size

custom memory reallocation

Definition at line 129 of file libmemif.h.

◆ memif_socket_handle_t

typedef void* memif_socket_handle_t

Memif socket handle pointer of type void, pointing to internal structure.

Definition at line 113 of file libmemif.h.

Enumeration Type Documentation

◆ memif_err_t

Error codes

Enumerator
MEMIF_ERR_SUCCESS 

success

MEMIF_ERR_SYSCALL 

other syscall error

MEMIF_ERR_CONNREFUSED 

connection refused

MEMIF_ERR_ACCES 

permission denied

MEMIF_ERR_NO_FILE 

file does not exist

MEMIF_ERR_FILE_LIMIT 

system open file limit

MEMIF_ERR_PROC_FILE_LIMIT 

process open file limit

MEMIF_ERR_ALREADY 

connection already requested

MEMIF_ERR_AGAIN 

fd is not socket, or operation would block

MEMIF_ERR_BAD_FD 

invalid fd

MEMIF_ERR_NOMEM 

out of memory

MEMIF_ERR_INVAL_ARG 

invalid argument

MEMIF_ERR_NOCONN 

handle points to no connection

MEMIF_ERR_CONN 

handle points to existing connection

MEMIF_ERR_CB_FDUPDATE 

user defined callback memif_control_fd_update_t error

MEMIF_ERR_FILE_NOT_SOCK 

file specified by socket filename exists, but it's not socket

MEMIF_ERR_NO_SHMFD 

missing shm fd

MEMIF_ERR_COOKIE 

wrong cookie on ring

MEMIF_ERR_NOBUF_RING 

ring buffer full

MEMIF_ERR_NOBUF 

not enough memif buffers

MEMIF_ERR_NOBUF_DET 

memif details needs larger buffer

MEMIF_ERR_INT_WRITE 

send interrupt error

MEMIF_ERR_MFMSG 

malformed msg received

MEMIF_ERR_QID 

invalid queue id

MEMIF_ERR_PROTO 

incompatible protocol version

MEMIF_ERR_ID 

unmatched interface id

MEMIF_ERR_ACCSLAVE 

slave cannot accept connection requests

MEMIF_ERR_ALRCONN 

memif is already connected

MEMIF_ERR_MODE 

mode mismatch

MEMIF_ERR_SECRET 

secret mismatch

MEMIF_ERR_NOSECRET 

secret required

MEMIF_ERR_MAXREG 

max region limit reached

MEMIF_ERR_MAXRING 

max ring limit reached

MEMIF_ERR_NO_INTFD 

missing interrupt fd

MEMIF_ERR_DISCONNECT 

disconnect received

MEMIF_ERR_DISCONNECTED 

peer interface disconnected

MEMIF_ERR_UNKNOWN_MSG 

unknown message type

MEMIF_ERR_POLL_CANCEL 

memif_poll_event() was cancelled

MEMIF_ERR_MAX_RING 

too large ring size

MEMIF_ERR_PRIVHDR 

private hdrs not supported

Definition at line 34 of file libmemif.h.