FD.io VPP  v21.01.1
Vector Packet Processing
+ Collaboration diagram for Api calls:

Macros

#define MEMIF_HAVE_CANCEL_POLL_EVENT   1
 Send signal to stop concurrently running memif_poll_event(). More...
 

Functions

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 per thread 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...
 

Detailed Description

Macro Definition Documentation

◆ MEMIF_HAVE_CANCEL_POLL_EVENT

#define MEMIF_HAVE_CANCEL_POLL_EVENT   1

#include <extras/libmemif/src/libmemif.h>

Send signal to stop concurrently running memif_poll_event().

The function, however, does not wait for memif_poll_event() to stop. memif_poll_event() may still return simply because an event has occurred or the timeout has elapsed, but if called repeatedly in an infinite loop, a canceled memif_poll_event() is guaranteed to return MEMIF_ERR_POLL_CANCEL in the shortest possible time. This feature was not available in the first release. Use macro MEMIF_HAVE_CANCEL_POLL_EVENT to check if the feature is present.

Returns
memif_err_t

Definition at line 714 of file libmemif.h.

Function Documentation

◆ memif_buffer_alloc()

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 
)

#include <extras/libmemif/src/libmemif.h>

Memif buffer alloc.

Parameters
conn- memif connection handle
qid- number identifying queue
bufs- memif buffers
count- number of memif buffers to allocate
count_out- returns number of allocated buffers
size- buffer size, may return chained buffers if size > buffer_size
Returns
memif_err_t

Definition at line 2237 of file main.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ memif_buffer_enq_tx()

int memif_buffer_enq_tx ( memif_conn_handle_t  conn,
uint16_t  qid,
memif_buffer_t bufs,
uint16_t  count,
uint16_t *  count_out 
)

#include <extras/libmemif/src/libmemif.h>

Memif buffer enq tx.

Parameters
conn- memif connection handle
qid- number identifying queue
bufs- memif buffers
count- number of memif buffers to enqueue
count_out- returns number of allocated buffers

Slave is producer of buffers. If connection handle points to master returns MEMIF_ERR_INVAL_ARG.

Returns
memif_err_t

Definition at line 2157 of file main.c.

+ Here is the caller graph for this function:

◆ memif_cancel_poll_event()

int memif_cancel_poll_event ( )

#include <extras/libmemif/src/libmemif.h>

Definition at line 1618 of file main.c.

◆ memif_cleanup()

int memif_cleanup ( )

#include <extras/libmemif/src/libmemif.h>

Memif cleanup.

Free libmemif internal allocations.

Returns
0

Definition at line 2761 of file main.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ memif_control_fd_handler()

int memif_control_fd_handler ( int  fd,
uint8_t  events 
)

#include <extras/libmemif/src/libmemif.h>

Memif control file descriptor handler.

Parameters
fd- file descriptor on which the event occurred
events- event type(s) that occurred

If event occurs on any control fd, call memif_control_fd_handler. Internal - lib will "identify" fd (timerfd, listener, control) and handle event accordingly.

FD-TYPE - TIMERFD - Every disconnected memif in slave mode will request connection. LISTENER or CONTROL - Handle socket messaging (internal connection establishment). INTERRUPT - Call on_interrupt callback (if set).

Returns
memif_err_t

Definition at line 1307 of file main.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ memif_create()

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 
)

#include <extras/libmemif/src/libmemif.h>

Memory interface create function.

Parameters
conn- connection handle for client app
args- memory interface connection arguments
on_connect- inform user about connected status
on_disconnect- inform user about disconnected status
on_interrupt- informs user about interrupt, if set to null user will not be notified about interrupt, user can use memif_get_queue_efd call to get interrupt fd to poll for events
private_ctx- private context passed back to user with callback

Creates memory interface.

SLAVE-MODE - Start timer that will send events to timerfd. If this fd is passed to memif_control_fd_handler every disconnected memif in slave mode will send connection request. On success new fd is passed to user with memif_control_fd_update_t.

MASTER-MODE - Create listener socket and pass fd to user with memif_control_fd_update_t. If this fd is passed to memif_control_fd_handler accept will be called and new fd will be passed to user with memif_control_fd_update_t.

Returns
memif_err_t

Definition at line 1095 of file main.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ memif_create_socket()

int memif_create_socket ( memif_socket_handle_t sock,
const char *  filename,
void *  private_ctx 
)

#include <extras/libmemif/src/libmemif.h>

Create memif socket.

Parameters
sock- socket handle for client app
filename- path to socket file
private_ctx- private context

The first time an interface is assigned a socket, its type is determined. For master role it's 'listener', for slave role it's 'client'. Each interface requires socket of its respective type. Default socket is created if no socket handle is passed to memif_create(). It's private context is NULL. If all interfaces using this socket are deleted, the socket returns to its default state.

Returns
memif_err_t

Definition at line 932 of file main.c.

+ Here is the caller graph for this function:

◆ memif_delete()

int memif_delete ( memif_conn_handle_t conn)

#include <extras/libmemif/src/libmemif.h>

Memif delete.

Parameters
conn- pointer to memif connection handle

disconnect session (free queues and regions, close file descriptors, unmap shared memory) set connection handle to NULL, to avoid possible double free

Returns
memif_err_t

Definition at line 1816 of file main.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ memif_delete_socket()

int memif_delete_socket ( memif_socket_handle_t sock)

#include <extras/libmemif/src/libmemif.h>

Delete memif socket.

Parameters
sock- socket handle for client app

When trying to free socket in use, socket will not be freed and MEMIF_ERR_INVAL_ARG is returned.

Returns
memif_err_t

Definition at line 1794 of file main.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ memif_get_details()

int memif_get_details ( memif_conn_handle_t  conn,
memif_details_t md,
char *  buf,
ssize_t  buflen 
)

#include <extras/libmemif/src/libmemif.h>

Memif get details.

Parameters
conn- memif connection handle
md- pointer to memif details struct
buf- buffer containing details strings
buflen- length of buffer
Returns
memif_err_t

Definition at line 2577 of file main.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ memif_get_queue_efd()

int memif_get_queue_efd ( memif_conn_handle_t  conn,
uint16_t  qid,
int *  fd 
)

#include <extras/libmemif/src/libmemif.h>

Memif get queue event file descriptor.

Parameters
conn- memif connection handle
qid- queue id
[out]fd- returns event file descriptor
Returns
memif_err_t

Definition at line 2738 of file main.c.

+ Here is the caller graph for this function:

◆ memif_get_socket_filename()

const char* memif_get_socket_filename ( memif_socket_handle_t  sock)

#include <extras/libmemif/src/libmemif.h>

Get socket filename.

Parameters
sock- socket handle for client app

Return constant pointer to socket filename.

Returns
const char *

Definition at line 1783 of file main.c.

+ Here is the caller graph for this function:

◆ memif_get_version()

uint16_t memif_get_version ( )

#include <extras/libmemif/src/libmemif.h>

Memif get version.

Returns
((MEMIF_VERSION_MAJOR << 8) | MEMIF_VERSION_MINOR)

Definition at line 174 of file main.c.

+ Here is the caller graph for this function:

◆ memif_init()

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 
)

#include <extras/libmemif/src/libmemif.h>

Memif initialization.

Parameters
on_control_fd_update- if control fd updates inform user to watch new fd
app_name- application name (will be truncated to 32 chars)
memif_alloc- custom memory allocator, NULL = default
memif_realloc- custom memory reallocation, NULL = default
memif_free- custom memory free, NULL = default

if param on_control_fd_update is set to NULL, libmemif will handle file descriptor event polling if a valid callback is set, file descriptor event polling needs to be done by user application, all file descriptors and event types will be passed in this callback to user application

Initialize internal libmemif structures. Create timerfd (used to periodically request connection by disconnected memifs in slave mode, with no additional API call). This fd is passed to user with memif_control_fd_update_t timer is inactive at this state. It activates with if there is at least one memif in slave mode.

Returns
memif_err_t

Definition at line 505 of file main.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ memif_per_thread_cancel_poll_event()

int memif_per_thread_cancel_poll_event ( memif_per_thread_main_handle_t  pt_main)

#include <extras/libmemif/src/libmemif.h>

Send signal to stop concurrently running memif_poll_event().

Parameters
pt_main- per thread main handle

Per thread version of memif_cancel_poll_event.

Returns
memif_err_t

Definition at line 1634 of file main.c.

◆ memif_per_thread_cleanup()

int memif_per_thread_cleanup ( memif_per_thread_main_handle_t pt_main)

#include <extras/libmemif/src/libmemif.h>

Memif per thread cleanup.

Parameters
pt_main- per thread main handle

Free libmemif internal allocations and sets the handle to NULL.

Returns
memif_err_t

Definition at line 2789 of file main.c.

+ Here is the caller graph for this function:

◆ memif_per_thread_control_fd_handler()

int memif_per_thread_control_fd_handler ( memif_per_thread_main_handle_t  pt_main,
int  fd,
uint8_t  events 
)

#include <extras/libmemif/src/libmemif.h>

Memif per thread control file descriptor handler.

Parameters
pt_main- per thread main handle
fd- file descriptor on which the event occurred
events- event type(s) that occurred

Per thread version of memif_control_fd_handler.

Returns
memif_err_t

Definition at line 1419 of file main.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ memif_per_thread_create_socket()

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 
)

#include <extras/libmemif/src/libmemif.h>

Create memif socket.

Parameters
pt_main- per thread main handle
sock- socket handle for client app
filename- path to socket file
private_ctx- private context

Per thread version of memif_create_socket.

Returns
memif_err_t

Definition at line 1011 of file main.c.

+ Here is the caller graph for this function:

◆ memif_per_thread_init()

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 
)

#include <extras/libmemif/src/libmemif.h>

Memif per thread initialization.

Parameters
pt_main- per thread main handle
private_ctx- private context
on_control_fd_update- if control fd updates inform user to watch new fd
app_name- application name (will be truncated to 32 chars)
memif_alloc- custom memory allocator, NULL = default
memif_realloc- custom memory reallocation, NULL = default
memif_free- custom memory free, NULL = default

Per thread version of memif_init (). Instead of using global database, creates and initializes unique database, identified by 'memif_per_thread_main_handle_t'.

Returns
memif_err_t

Definition at line 655 of file main.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ memif_per_thread_poll_event()

int memif_per_thread_poll_event ( memif_per_thread_main_handle_t  pt_main,
int  timeout 
)

#include <extras/libmemif/src/libmemif.h>

Memif per thread poll event.

Parameters
pt_main- per thread main handle
timeout- timeout in seconds

Per thread version of memif_poll_event.

Returns
memif_err_t

Definition at line 1575 of file main.c.

+ Here is the call graph for this function:

◆ memif_per_thread_set_connection_request_timer()

int memif_per_thread_set_connection_request_timer ( memif_per_thread_main_handle_t  pt_main,
struct itimerspec  timer 
)

#include <extras/libmemif/src/libmemif.h>

Set connection request timer value.

Parameters
pt_main- per thread main handle
timer- new timer value

Per thread version of memif_set_connection_request_timer

Returns
memif_err_t

Definition at line 484 of file main.c.

+ Here is the call graph for this function:

◆ memif_poll_event()

int memif_poll_event ( int  timeout)

#include <extras/libmemif/src/libmemif.h>

Memif poll event.

Parameters
timeout- timeout in seconds

Passive event polling - timeout = 0 - dont wait for event, check event queue if there is an event and return. timeout = -1 - wait until event

Returns
memif_err_t

Definition at line 1533 of file main.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ memif_refill_queue()

int memif_refill_queue ( memif_conn_handle_t  conn,
uint16_t  qid,
uint16_t  count,
uint16_t  headroom 
)

#include <extras/libmemif/src/libmemif.h>

Memif refill ring.

Parameters
conn- memif connection handle
qid- number identifying queue
count- number of buffers to be placed on ring
headroom- offset the buffer by headroom
Returns
memif_err_t

Definition at line 2363 of file main.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ memif_request_connection()

int memif_request_connection ( memif_conn_handle_t  conn)

#include <extras/libmemif/src/libmemif.h>

Send connection request.

Parameters
conn- memif connection handle

Only slave interface can request connection.

Returns
memif_err_t

Definition at line 1233 of file main.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ memif_rx_burst()

int memif_rx_burst ( memif_conn_handle_t  conn,
uint16_t  qid,
memif_buffer_t bufs,
uint16_t  count,
uint16_t *  rx 
)

#include <extras/libmemif/src/libmemif.h>

Memif receive buffer burst.

Parameters
conn- memif connection handle
qid- number identifying queue
bufs- memif buffers
count- number of memif buffers to receive
rx- returns number of received buffers

Consume interrupt event for receive queue. The event is not consumed, if memif_rx_burst fails.

Returns
memif_err_t

Definition at line 2484 of file main.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ memif_set_connection_request_timer()

int memif_set_connection_request_timer ( struct itimerspec  timer)

#include <extras/libmemif/src/libmemif.h>

Set connection request timer value.

Parameters
timer- new timer value

Timer on which all disconnected slaves request connection. See system call 'timer_settime' man-page.

Returns
memif_err_t

Definition at line 465 of file main.c.

+ Here is the call graph for this function:

◆ memif_set_rx_mode()

int memif_set_rx_mode ( memif_conn_handle_t  conn,
memif_rx_mode_t  rx_mode,
uint16_t  qid 
)

#include <extras/libmemif/src/libmemif.h>

Memif set rx mode.

Parameters
conn- memif connection handle
rx_mode- receive mode
qid- queue id
Returns
memif_err_t

Definition at line 840 of file main.c.

+ Here is the caller graph for this function:

◆ memif_strerror()

char* memif_strerror ( int  err_code)

#include <extras/libmemif/src/libmemif.h>

Memif strerror.

Parameters
err_code- error code

Converts error code to error message.

Returns
Error string

Definition at line 157 of file main.c.

+ Here is the caller graph for this function:

◆ memif_tx_burst()

int memif_tx_burst ( memif_conn_handle_t  conn,
uint16_t  qid,
memif_buffer_t bufs,
uint16_t  count,
uint16_t *  tx 
)

#include <extras/libmemif/src/libmemif.h>

Memif transmit buffer burst.

Parameters
conn- memif connection handle
qid- number identifying queue
bufs- memif buffers
count- number of memif buffers to transmit
tx- returns number of transmitted buffers
Returns
memif_err_t

Definition at line 2417 of file main.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function: