aboutsummaryrefslogtreecommitdiffstats
path: root/extras/libmemif/src/memif_private.h
diff options
context:
space:
mode:
authorJakub Grajciar <jgrajcia@cisco.com>2019-07-31 14:40:52 +0200
committerDamjan Marion <dmarion@me.com>2019-08-21 14:45:43 +0000
commit17f2a7bbf25f54dbd71aa8f377875828b7b88e35 (patch)
treeab88f5d0759bfe703c818a40ea46d0e52b28783d /extras/libmemif/src/memif_private.h
parentb6103105f99e0c7f210a9596f205a1efd21b626f (diff)
libmemif: introduce 'memif_per_thread_' namespace
APIs in 'memif_per_thread_' namespace are used to split the global database into separate databases, to improve multi-thread use cases. Using 'memif_per_thread_init' client can create separate libmemif databases (libmemif_main_t). Client will reference these databases using memif_per_thread_handle_t. Each database requires unique socket. Created interface will be stored in the same database as the socket passed in connection arguments. Example code: extras/libmemif/examples/icmp_responder_3-1/main.c Type: feature Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com> Change-Id: I261563ecc34761a76e94f20c20015394398ddfd7 Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
Diffstat (limited to 'extras/libmemif/src/memif_private.h')
-rw-r--r--extras/libmemif/src/memif_private.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/extras/libmemif/src/memif_private.h b/extras/libmemif/src/memif_private.h
index eceac677752..88237dca265 100644
--- a/extras/libmemif/src/memif_private.h
+++ b/extras/libmemif/src/memif_private.h
@@ -120,6 +120,8 @@ typedef struct
memif_log2_ring_size_t log2_ring_size;
} memif_conn_run_args_t;
+struct libmemif_main;
+
typedef struct memif_connection
{
uint16_t index;
@@ -165,19 +167,25 @@ typedef struct
uint16_t use_count;
memif_socket_type_t type;
uint8_t *filename;
+ /* unique database */
+ struct libmemif_main *lm;
uint16_t interface_list_len;
void *private_ctx;
memif_list_elt_t *interface_list; /* memif master interfaces listening on this socket */
} memif_socket_t;
-typedef struct
+typedef struct libmemif_main
{
memif_control_fd_update_t *control_fd_update;
int timerfd;
+ int epfd;
+ int poll_cancel_fd;
struct itimerspec arm, disarm;
uint16_t disconn_slaves;
uint8_t app_name[MEMIF_NAME_LEN];
+ void *private_ctx;
+
memif_socket_handle_t default_socket;
memif_add_external_region_t *add_external_region;
@@ -200,7 +208,6 @@ typedef struct
} libmemif_main_t;
extern libmemif_main_t libmemif_main;
-extern int memif_epfd;
/* main.c */
@@ -215,7 +222,7 @@ int memif_disconnect_internal (memif_connection_t * c);
/* map errno to memif error code */
int memif_syscall_error_handler (int err_code);
-int add_list_elt (memif_list_elt_t * e, memif_list_elt_t ** list,
+int add_list_elt (libmemif_main_t *lm, memif_list_elt_t * e, memif_list_elt_t ** list,
uint16_t * len);
int get_list_elt (memif_list_elt_t ** e, memif_list_elt_t * list,
@@ -223,6 +230,8 @@ int get_list_elt (memif_list_elt_t ** e, memif_list_elt_t * list,
int free_list_elt (memif_list_elt_t * list, uint16_t len, int key);
+libmemif_main_t *get_libmemif_main (memif_socket_t * ms);
+
#ifndef __NR_memfd_create
#if defined __x86_64__
#define __NR_memfd_create 319