VPP-236 Support 64-bit vector lengths, shared memory segments >4 GB
Change-Id: I02aee33e96e7ae32094b9f82f6a667d30bb52f59
Signed-off-by: Dave Barach <dave@barachs.net>
diff --git a/vlib-api/vlibapi/api.h b/vlib-api/vlibapi/api.h
index 9d885c1..a932bf4 100644
--- a/vlib-api/vlibapi/api.h
+++ b/vlib-api/vlibapi/api.h
@@ -141,9 +141,25 @@
/* vector of message ranges */
vl_api_msg_range_t *msg_ranges;
+ /* uid for the api shared memory region */
+ int api_uid;
/* gid for the api shared memory region */
int api_gid;
- int api_uid;
+
+ /* base virtual address for global VM region */
+ u64 global_baseva;
+
+ /* size of the global VM region */
+ u64 global_size;
+
+ /* size of the API region */
+ u64 api_size;
+
+ /* size of the global VM private mheap */
+ u64 global_pvt_heap_size;
+
+ /* size of the api private mheap */
+ u64 api_pvt_heap_size;
/* Client-only data structures */
unix_shared_memory_queue_t *vl_input_queue;
diff --git a/vlib-api/vlibmemory/api.h b/vlib-api/vlibmemory/api.h
index e3a9584..bc4cfbf 100644
--- a/vlib-api/vlibmemory/api.h
+++ b/vlib-api/vlibmemory/api.h
@@ -142,6 +142,11 @@
void vl_set_memory_root_path (char *root_path);
void vl_set_memory_uid (int uid);
void vl_set_memory_gid (int gid);
+void vl_set_global_memory_baseva (u64 baseva);
+void vl_set_global_memory_size (u64 size);
+void vl_set_api_memory_size (u64 size);
+void vl_set_global_pvt_heap_size (u64 size);
+void vl_set_api_pvt_heap_size (u64 size);
void vl_enable_disable_memory_api (vlib_main_t * vm, int yesno);
void vl_client_disconnect_from_vlib (void);
int vl_client_connect_to_vlib (char *svm_name, char *client_name,
diff --git a/vlib-api/vlibmemory/memory_shared.c b/vlib-api/vlibmemory/memory_shared.c
index 53976fb..a2f2277 100644
--- a/vlib-api/vlibmemory/memory_shared.c
+++ b/vlib-api/vlibmemory/memory_shared.c
@@ -228,6 +228,46 @@
am->api_gid = gid;
}
+void
+vl_set_global_memory_baseva (u64 baseva)
+{
+ api_main_t *am = &api_main;
+
+ am->global_baseva = baseva;
+}
+
+void
+vl_set_global_memory_size (u64 size)
+{
+ api_main_t *am = &api_main;
+
+ am->global_size = size;
+}
+
+void
+vl_set_api_memory_size (u64 size)
+{
+ api_main_t *am = &api_main;
+
+ am->api_size = size;
+}
+
+void
+vl_set_global_pvt_heap_size (u64 size)
+{
+ api_main_t *am = &api_main;
+
+ am->global_pvt_heap_size = size;
+}
+
+void
+vl_set_api_pvt_heap_size (u64 size)
+{
+ api_main_t *am = &api_main;
+
+ am->api_pvt_heap_size = size;
+}
+
int
vl_map_shmem (char *region_name, int is_vlib)
{
@@ -245,10 +285,11 @@
memset (a, 0, sizeof (*a));
a->name = region_name;
- a->size = 16 << 20;
+ a->size = am->api_size ? am->api_size: (16 << 20);
a->flags = SVM_FLAGS_MHEAP;
a->uid = am->api_uid;
a->gid = am->api_gid;
+ a->pvt_heap_size = am->api_pvt_heap_size;
vlib_rp = svm_region_find_or_create (a);
diff --git a/vlib-api/vlibmemory/memory_vlib.c b/vlib-api/vlibmemory/memory_vlib.c
index 6875274..2212b46 100644
--- a/vlib-api/vlibmemory/memory_vlib.c
+++ b/vlib-api/vlibmemory/memory_vlib.c
@@ -1176,8 +1176,21 @@
vlibmemory_init (vlib_main_t * vm)
{
api_main_t *am = &api_main;
- /* Normally NULL / 0, set by cmd line "api-segment" */
- svm_region_init_chroot_uid_gid (am->root_path, am->api_uid, am->api_gid);
+ svm_map_region_args_t _a, *a = &_a;
+
+ memset (a, 0, sizeof (*a));
+ a->root_path = am->root_path;
+ a->name = SVM_GLOBAL_REGION_NAME;
+ a->baseva = (am->global_baseva != 0) ?
+ am->global_baseva : SVM_GLOBAL_REGION_BASEVA;
+ a->size = (am->global_size != 0) ? am->global_size : SVM_GLOBAL_REGION_SIZE;
+ a->flags = SVM_FLAGS_NODATA;
+ a->uid = am->api_uid;
+ a->gid = am->api_gid;
+ a->pvt_heap_size = (am->global_pvt_heap_size != 0) ? am->global_pvt_heap_size
+ : SVM_PVT_MHEAP_SIZE;
+
+ svm_region_init_args (a);
return 0;
}