aboutsummaryrefslogtreecommitdiffstats
path: root/extras/libmemif/docs
diff options
context:
space:
mode:
authorJakub Grajciar <jgrajcia@cisco.com>2018-03-26 11:26:34 +0200
committerDamjan Marion <dmarion.lists@gmail.com>2018-03-26 12:01:49 +0000
commitecfa2aaa631933f5c77858ae3e5e15a76619dd77 (patch)
treeaa6dc67e3c1153ed7fe316a4798429a27c3544a5 /extras/libmemif/docs
parentb4ff07a2f843207b6d024e1ed8a31fa37324fe07 (diff)
libmemif: version 2
Change-Id: Ia2532695aa9199d2a7b684aebef43df0b8235531 Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
Diffstat (limited to 'extras/libmemif/docs')
-rw-r--r--extras/libmemif/docs/buildinstructions_doc.md22
-rw-r--r--extras/libmemif/docs/gettingstarted_doc.md30
2 files changed, 28 insertions, 24 deletions
diff --git a/extras/libmemif/docs/buildinstructions_doc.md b/extras/libmemif/docs/buildinstructions_doc.md
index 838e835a9a5..a226856b2b6 100644
--- a/extras/libmemif/docs/buildinstructions_doc.md
+++ b/extras/libmemif/docs/buildinstructions_doc.md
@@ -5,12 +5,10 @@ Install dependencies
# sudo apt-get install -y git autoconf pkg_config libtool check
```
-Clone repository to your local machine.
-```
-# git clone https://github.com/JakubGrajciar/libmemif.git
-```
+Libmemif is now part of VPP repository. Follow fd.io wiki to pull source code from VPP repository.
+[https://wiki.fd.io/view/VPP/Pulling,_Building,_Running,_Hacking_and_Pushing_VPP_Code#Pushing_Patches](https://wiki.fd.io/view/VPP/Pulling,_Building,_Running,_Hacking_and_Pushing_VPP_Code#Pushing_Patches)
-From root directory execute:
+Libmemif is located under extras/libmemif.
For debug build:
```
# ./bootstrap
@@ -33,21 +31,23 @@ Verify installation:
> Make sure to run the binary file from ./.libs. File ./icmp\_responder in libmemif root directory is script that links the library, so it only verifies successful build. Default install path is /usr/lib.
Use _help_ command to display build information and commands:
```
-ICMP_Responder:add_epoll_fd:204: fd 0 added to epoll
-MEMIF_DEBUG:src/main.c:memif_init:383: app name: ICMP_Responder
-ICMP_Responder:add_epoll_fd:204: fd 4 added to epoll
+ICMP_Responder:add_epoll_fd:233: fd 0 added to epoll
+ICMP_Responder:add_epoll_fd:233: fd 5 added to epoll
LIBMEMIF EXAMPLE APP: ICMP_Responder (debug)
==============================
-libmemif version: 1.0 (debug)
-memif version: 256
+libmemif version: 2.0 (debug)
+memif version: 512
commands:
help - prints this help
exit - exit app
- conn <index> - create memif (slave-mode)
+ conn <index> <mode> [<interrupt-desc>] - create memif. index is also used as interface id, mode 0 = slave 1 = master, interrupt-desc none = default 0 = if ring is full wait 1 = handle only ARP requests
del <index> - delete memif
show - show connection details
ip-set <index> <ip-addr> - set interface ip address
rx-mode <index> <qid> <polling|interrupt> - set queue rx mode
+ sh-count - print counters
+ cl-count - clear counters
+ send <index> <tx> <ip> <mac> - send icmp
```
#### Examples
diff --git a/extras/libmemif/docs/gettingstarted_doc.md b/extras/libmemif/docs/gettingstarted_doc.md
index e3ae6e5658e..dbe465c4b8a 100644
--- a/extras/libmemif/docs/gettingstarted_doc.md
+++ b/extras/libmemif/docs/gettingstarted_doc.md
@@ -15,10 +15,10 @@ control_fd_update (int fd, uint8_t events)
```
- Call memif initialization function. memif\_init
```C
-err = memif_init (control_fd_update, APP_NAME);
+err = memif_init (control_fd_update, APP_NAME, NULL, NULL);
```
-> If event occurres on any file descriptor returned by this callback, call memif\_control\_fd\_handler function.
+> If event occurres 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.
```C
memif_err = memif_control_fd_handler (evt.data.fd, events);
```
@@ -54,7 +54,6 @@ args.buffer_size = 2048;
args.num_s2m_rings = 2;
args.num_m2s_rings = 2;
strncpy ((char *) args.interface_name, IF_NAME, strlen (IF_NAME));
-strncpy ((char *) args.instance_name, APP_NAME, strlen (APP_NAME));
args.mode = 0;
args.interface_id = 0;
```
@@ -102,40 +101,45 @@ on_interrupt (memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
```
6. Memif buffers
- - Packet data are stored in memif\_buffer\_t. Pointer _data_ points to shared memory buffer, and unsigned integer *data\_len* contains packet data length.
+ - Packet data are stored in memif\_buffer\_t. Pointer _data_ points to shared memory buffer, and unsigned integer *_len* contains buffer length.
+ - flags: MEMIF\_BUFFER\_FLAG\_NEXT states that the buffer is not large enough to contain whole packet, so next buffer contains the rest of the packet. (chained buffers)
```C
typedef struct
{
uint16_t desc_index;
- uint32_t buffer_len;
- uint32_t data_len;
+ uint32_t len;
+ uint8_t flags;
void *data;
} memif_buffer_t;
```
5. Packet receive
- - Api call memif\_rx\_burst will set all required fields in memif buffers provided by user application.
+ - Api call memif\_rx\_burst will set all required fields in memif buffers provided by user application and dequeue received buffers.
```C
-err = memif_rx_burst (c->conn, qid, c->rx_bufs, MAX_MEMIF_BUFS, &rx);
+err = memif_rx_burst (c->conn, qid, c->bufs, MAX_MEMIF_BUFS, &rx);
```
- User application can then process packets.
- - Api call memif\_buffer\_free will make supplied memif buffers ready for next receive and mark shared memory buffers as free.
+ - Api call memif\_refill\_queue will enqueue rx buffers.
```C
-err = memif_buffer_free (c->conn, qid, c->rx_bufs, rx, &fb);
+err = memif_refill_queue (c->conn, qid, rx);
```
6. Packet transmit
- - Api call memif\_buffer\_alloc will set all required fields in memif buffers provided by user application.
+ - Api call memif\_buffer\_alloc will find free tx buffers and set all required fields in memif buffers provided by user application.
```C
err = memif_buffer_alloc (c->conn, qid, c->tx_bufs, n, &r);
```
- User application can populate shared memory buffers with packets.
- - Api call memif\_tx\_burst will inform peer interface (master memif on VPP) that there are packets ready to receive and mark memif buffers as free.
+ - Api call memif\_tx\_burst will enqueue tx buffers
```C
err = memif_tx_burst (c->conn, qid, c->tx_bufs, c->tx_buf_num, &r);
```
7. Helper functions
+ - Memif version
+```C
+uint16_t memif_ver = memif_get_version ();
+```
- Memif details
- Api call memif\_get\_details will return details about connection.
```C
@@ -172,7 +176,7 @@ ICMP Responder custom fd event polling.
ICMP Responder multi-thread.
- @ref extras/libmemif/examples/icmp_responder-mt
-> Simple example of libmemif multi-thread usage. Connection establishment is handled by main thread. There are two rx queues in this example. One in polling mode and second in interrupt mode.
+> 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:
```