aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/session/segment_manager.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/session/segment_manager.h')
-rw-r--r--src/vnet/session/segment_manager.h84
1 files changed, 61 insertions, 23 deletions
diff --git a/src/vnet/session/segment_manager.h b/src/vnet/session/segment_manager.h
index b2a792d206b..9b1d4cd0c06 100644
--- a/src/vnet/session/segment_manager.h
+++ b/src/vnet/session/segment_manager.h
@@ -20,6 +20,7 @@
#include <svm/queue.h>
#include <vlibmemory/api.h>
#include <vppinfra/lock.h>
+#include <vppinfra/valloc.h>
typedef struct _segment_manager_properties
{
@@ -28,7 +29,7 @@ typedef struct _segment_manager_properties
u32 tx_fifo_size;
/** Preallocated pool sizes */
- u32 preallocated_fifo_pairs;
+// u32 preallocated_fifo_pairs;
/** Configured additional segment size */
u32 add_segment_size;
@@ -40,33 +41,58 @@ typedef struct _segment_manager_properties
ssvm_segment_type_t segment_type;
/** Use one or more private mheaps, instead of the global heap */
- u32 private_segment_count;
+// u32 private_segment_count;
} segment_manager_properties_t;
typedef struct _segment_manager
{
- clib_spinlock_t lockp;
+ /** Pool of segments allocated by this manager */
+ svm_fifo_segment_private_t *segments;
- /** segments mapped by this manager */
- u32 *segment_indices;
+ /** rwlock that protects the segments pool */
+ clib_rwlock_t segments_rwlock;
/** Owner app index */
u32 app_index;
/**
- * Pointer to manager properties. Could be shared among all of
- * an app's segment managers s
- */
- u32 properties_index;
-
- /**
* First segment should not be deleted unless segment manger is deleted.
* This also indicates that the segment manager is the first to have been
* allocated for the app.
*/
u8 first_is_protected;
+
+ /**
+ * App event queue allocated in first segment
+ */
+ svm_queue_t *event_queue;
} segment_manager_t;
+#define segment_manager_foreach_segment_w_lock(VAR, SM, BODY) \
+do { \
+ clib_rwlock_reader_lock (&(SM)->segments_rwlock); \
+ pool_foreach((VAR), ((SM)->segments), (BODY)); \
+ clib_rwlock_reader_unlock (&(SM)->segments_rwlock); \
+} while (0)
+
+typedef struct segment_manager_main_
+{
+ /** Pool of segment managers */
+ segment_manager_t *segment_managers;
+
+ /** Virtual address allocator */
+ clib_valloc_main_t va_allocator;
+
+} segment_manager_main_t;
+
+extern segment_manager_main_t segment_manager_main;
+
+typedef struct segment_manager_main_init_args_
+{
+ u64 baseva;
+ u64 size;
+} segment_manager_main_init_args_t;
+
#define SEGMENT_MANAGER_INVALID_APP_INDEX ((u32) ~0)
/** Pool of segment managers */
@@ -75,31 +101,44 @@ extern segment_manager_t *segment_managers;
always_inline segment_manager_t *
segment_manager_get (u32 index)
{
- return pool_elt_at_index (segment_managers, index);
+ return pool_elt_at_index (segment_manager_main.segment_managers, index);
}
always_inline segment_manager_t *
segment_manager_get_if_valid (u32 index)
{
- if (pool_is_free_index (segment_managers, index))
+ if (pool_is_free_index (segment_manager_main.segment_managers, index))
return 0;
- return pool_elt_at_index (segment_managers, index);
+ return pool_elt_at_index (segment_manager_main.segment_managers, index);
}
always_inline u32
segment_manager_index (segment_manager_t * sm)
{
- return sm - segment_managers;
+ return sm - segment_manager_main.segment_managers;
+}
+
+always_inline svm_queue_t *
+segment_manager_event_queue (segment_manager_t * sm)
+{
+ return sm->event_queue;
}
segment_manager_t *segment_manager_new ();
-int segment_manager_init (segment_manager_t * sm, u32 props_index,
- u32 seg_size, u32 evt_queue_size);
+int segment_manager_init (segment_manager_t * sm, u32 first_seg_size,
+ u32 evt_q_size, u32 prealloc_fifo_pairs);
+
+svm_fifo_segment_private_t *segment_manager_get_segment (segment_manager_t *
+ sm,
+ u32 segment_index);
+svm_fifo_segment_private_t
+ * segment_manager_get_segment_w_lock (segment_manager_t * sm,
+ u32 segment_index);
+void segment_manager_segment_reader_unlock (segment_manager_t * sm);
+void segment_manager_segment_writer_unlock (segment_manager_t * sm);
-svm_fifo_segment_private_t *segment_manager_get_segment (u32 segment_index);
int segment_manager_add_first_segment (segment_manager_t * sm,
u32 segment_size);
-int segment_manager_add_segment (segment_manager_t * sm);
void segment_manager_del_sessions (segment_manager_t * sm);
void segment_manager_del (segment_manager_t * sm);
void segment_manager_init_del (segment_manager_t * sm);
@@ -117,10 +156,9 @@ svm_queue_t *segment_manager_alloc_queue (segment_manager_t * sm,
void segment_manager_dealloc_queue (segment_manager_t * sm, svm_queue_t * q);
void segment_manager_app_detach (segment_manager_t * sm);
-segment_manager_properties_t *segment_manager_properties_alloc (void);
-void segment_manager_properties_free (segment_manager_properties_t * p);
-segment_manager_properties_t *segment_manager_properties_get (u32 smp_index);
-u32 segment_manager_properties_index (segment_manager_properties_t * p);
+void segment_manager_main_init (segment_manager_main_init_args_t * a);
+segment_manager_properties_t
+ * segment_manager_properties_init (segment_manager_properties_t * sm);
#endif /* SRC_VNET_SESSION_SEGMENT_MANAGER_H_ */
/*