aboutsummaryrefslogtreecommitdiffstats
path: root/extras/libmemif/src/libmemif.h
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/src/libmemif.h
parentb4ff07a2f843207b6d024e1ed8a31fa37324fe07 (diff)
libmemif: version 2
Change-Id: Ia2532695aa9199d2a7b684aebef43df0b8235531 Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
Diffstat (limited to 'extras/libmemif/src/libmemif.h')
-rw-r--r--extras/libmemif/src/libmemif.h69
1 files changed, 48 insertions, 21 deletions
diff --git a/extras/libmemif/src/libmemif.h b/extras/libmemif/src/libmemif.h
index a14a1025a54..14c450338ce 100644
--- a/extras/libmemif/src/libmemif.h
+++ b/extras/libmemif/src/libmemif.h
@@ -23,14 +23,12 @@
#define _LIBMEMIF_H_
/** Libmemif version. */
-#define LIBMEMIF_VERSION "1.0"
+#define LIBMEMIF_VERSION "2.0"
/** Default name of application using libmemif. */
#define MEMIF_DEFAULT_APP_NAME "libmemif-app"
#include <inttypes.h>
-#include <memif.h>
-
/*! Error codes */
typedef enum
{
@@ -95,10 +93,25 @@ typedef enum
#define MEMIF_FD_EVENT_MOD (1 << 4)
/** @} */
-/** *brief Memif connection handle
+/** \brief Memif connection handle
pointer of type void, pointing to internal structure
*/
typedef void *memif_conn_handle_t;
+
+/** \brief Memif allocator alloc
+ @param size - requested allocation size
+
+ custom memory allocator: alloc function template
+*/
+typedef void *(memif_alloc_t) (size_t size);
+
+/** \brief Memif allocator free
+ @param size - requested allocation size
+
+ custom memory allocator: free function template
+*/
+typedef void (memif_free_t) (void *ptr);
+
/**
* @defgroup CALLBACKS Callback functions definitions
* @ingroup libmemif
@@ -143,6 +156,15 @@ typedef int (memif_interrupt_t) (memif_conn_handle_t conn, void *private_ctx,
* @{
*/
+#ifndef _MEMIF_H_
+typedef enum
+{
+ MEMIF_INTERFACE_MODE_ETHERNET = 0,
+ MEMIF_INTERFACE_MODE_IP = 1,
+ MEMIF_INTERFACE_MODE_PUNT_INJECT = 2,
+} memif_interface_mode_t;
+#endif /* _MEMIF_H_ */
+
/** \brief Memif connection arguments
@param socket_filename - socket filename
@param secret - otional parameter used as interface autenthication
@@ -153,7 +175,6 @@ typedef int (memif_interrupt_t) (memif_conn_handle_t conn, void *private_ctx,
@param is_master - 0 == master, 1 == slave
@param interface_id - id used to identify peer connection
@param interface_name - interface name
- @param instance_name - application name
@param mode - 0 == ethernet, 1 == ip , 2 == punt/inject
*/
typedef struct
@@ -164,12 +185,11 @@ typedef struct
uint8_t num_s2m_rings; /*!< default = 1 */
uint8_t num_m2s_rings; /*!< default = 1 */
uint16_t buffer_size; /*!< default = 2048 */
- memif_log2_ring_size_t log2_ring_size; /*!< default = 10 (1024) */
+ uint8_t log2_ring_size; /*!< default = 10 (1024) */
uint8_t is_master;
- memif_interface_id_t interface_id;
+ uint32_t interface_id;
uint8_t interface_name[32];
- uint8_t instance_name[32]; /*!< deprecated, will be removed in 2.0 */
memif_interface_mode_t mode:8;
} memif_conn_args_t;
@@ -182,15 +202,16 @@ typedef enum
/** \brief Memif buffer
@param desc_index - ring descriptor index
- @param buffer_len - shared meory buffer length
- @param data_len - data length
+ @param len - buffer length
+ @param flags - memif buffer flags
@param data - pointer to shared memory data
*/
typedef struct
{
uint16_t desc_index;
- uint32_t buffer_len;
- uint32_t data_len;
+ uint32_t len;
+#define MEMIF_BUFFER_FLAG_NEXT (1 << 0)
+ uint8_t flags;
void *data;
} memif_buffer_t;
/** @} */
@@ -266,6 +287,12 @@ typedef struct
* @{
*/
+/** \brief Memif get version
+
+ \return ((MEMIF_VERSION_MAJOR << 8) | MEMIF_VERSION_MINOR)
+*/
+uint16_t memif_get_version ();
+
/** \biref Memif get queue event file descriptor
@param conn - memif connection handle
@param qid - queue id
@@ -309,6 +336,8 @@ int memif_get_details (memif_conn_handle_t conn, memif_details_t * md,
/** \brief Memif initialization
@param on_control_fd_update - if control fd updates inform user to watch new fd
@param app_name - application name (will be truncated to 32 chars)
+ @param memif_alloc - cutom memory allocator, NULL = default
+ @param memif_free - custom memory free, NULL = default
if param on_control_fd_update is set to NULL,
libmemif will handle file descriptor event polling
@@ -323,7 +352,8 @@ int memif_get_details (memif_conn_handle_t conn, memif_details_t * md,
\return memif_err_t
*/
int memif_init (memif_control_fd_update_t * on_control_fd_update,
- char *app_name);
+ char *app_name, memif_alloc_t * memif_alloc,
+ memif_free_t * memif_free);
/** \brief Memif cleanup
@@ -398,7 +428,7 @@ int memif_delete (memif_conn_handle_t * conn);
@param bufs - memif buffers
@param count - number of memif buffers to allocate
@param count_out - returns number of allocated buffers
- @param size - minimal buffer size, 0 = standard buffer size
+ @param size - buffer size, may return chained buffers if size > buffer_size
\return memif_err_t
*/
@@ -406,18 +436,15 @@ 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);
-/** \brief Memif buffer free
+/** \brief Memif refill ring
@param conn - memif conenction handle
@param qid - number indentifying queue
- @param bufs - memif buffers
- @param count - number of memif buffers to free
- @param count_out - returns number of freed buffers
+ @param count - number of buffers to be placed on ring
\return memif_err_t
*/
-int memif_buffer_free (memif_conn_handle_t conn, uint16_t qid,
- memif_buffer_t * bufs, uint16_t count,
- uint16_t * count_out);
+int memif_refill_queue (memif_conn_handle_t conn, uint16_t qid,
+ uint16_t count);
/** \brief Memif transmit buffer burst
@param conn - memif conenction handle