FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
For detailed information on api calls and structures please refer to libmemif.h.
If event occurs on any file descriptor returned by this callback, call memif_control_fd_handler function. Since version 2.0, last two optional arguments are used to specify custom memory allocation.
If callback function parameter for memif_init function is set to NULL, libmemif will handle file descriptor event polling.
Api call memif_poll_event will call epoll_pwait with user defined timeout to poll event on file descriptors opened by libmemif.
Memif initialization function will initialize internal structures and create timer file descriptor, which will be used for sending periodic connection requests. Timer is disarmed if no memif interface is created.
example app uses struct that contains connection handle, rx/tx buffers and other connection specific information.
If connection is in slave mode, arms timer file descriptor. If on interrupt callback is set to NULL, user will not be notified about interrupt. Use memif_get_queue_efd call to get interrupt file descriptor for specific queue.
- User application can then process packets. - Api call memif\_refill\_queue will enqueue rx buffers.
- User application can populate shared memory buffers with packets. - Api call memif\_tx\_burst will enqueue tx buffers
- Memif details - Api call memif\_get\_details will return details about connection.
- Memif error messages - Every api call returns error code (integer value) mapped to error string. - Call memif\_strerror will return error message assigned to specific error code.
- Not all syscall errors are translated to memif error codes. If error code 1 (MEMIF\_ERR\_SYSCALL) is returned then libmemif needs to be compiled with -DMEMIF_DBG flag to print error message. Use _make -B_ to rebuild libmemif in debug mode.
Optional argument: transmit queue id.
Set transmit queue id to 1. Default is 0. Application will create memif interface in slave mode and try to connect to VPP. Exit using Ctrl+C. Application will handle SIGINT signal, free allocated memory and exit with EXIT_SUCCESS.
ICMP Responder custom fd event polling.
ICMP Responder multi-thread.
Simple example of libmemif multi-thread usage. Connection establishment is handled by main thread. There are two rx/tx queues in this example. One in polling mode and second in interrupt mode.
VPP config:
For multiple rings (queues) support run VPP with worker threads: example startup.conf:
VPP config:
Master mode queue number is limited by worker threads. Slave mode interface needs to specify number of queues.
Example applications use VPP default socket file for memif: /run/vpp/memif.sock For master mode, socket directory must exist prior to memif_create call.
Unit tests use Check framework. This framework must be installed in order to build unit_test binary. Ubuntu/Debian: