summaryrefslogtreecommitdiffstats
path: root/src/vcl/vcl_private.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-08-24 18:17:34 -0700
committerFlorin Coras <florin.coras@gmail.com>2019-12-21 18:50:12 +0000
commitc4c4cf5066fbdceebd62a8819e3ecd0fc879f05d (patch)
tree2bd208ee7edb7e49440397b2fd44f3515c4e817d /src/vcl/vcl_private.c
parentd849edf3841c1c9774c5ce209a2b903415f2370a (diff)
session: move add/del segment msg to mq
Type: refactor Change-Id: I32234173ebd69f80acb1afa4039fffbd19157f6d Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vcl/vcl_private.c')
-rw-r--r--src/vcl/vcl_private.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/vcl/vcl_private.c b/src/vcl/vcl_private.c
index 6e887c878cd..f3cee5d6f8e 100644
--- a/src/vcl/vcl_private.c
+++ b/src/vcl/vcl_private.c
@@ -405,6 +405,47 @@ vcl_session_write_ready (vcl_session_t * session)
return svm_fifo_max_enqueue_prod (session->tx_fifo);
}
+int
+vcl_segment_attach (u64 segment_handle, char *name, ssvm_segment_type_t type,
+ int fd)
+{
+ fifo_segment_create_args_t _a, *a = &_a;
+ int rv;
+
+ memset (a, 0, sizeof (*a));
+ a->segment_name = (char *) name;
+ a->segment_type = type;
+
+ if (type == SSVM_SEGMENT_MEMFD)
+ a->memfd_fd = fd;
+
+ if ((rv = fifo_segment_attach (&vcm->segment_main, a)))
+ {
+ clib_warning ("svm_fifo_segment_attach ('%s') failed", name);
+ return rv;
+ }
+ vcl_segment_table_add (segment_handle, a->new_segment_indices[0]);
+ vec_reset_length (a->new_segment_indices);
+ return 0;
+}
+
+void
+vcl_segment_detach (u64 segment_handle)
+{
+ fifo_segment_main_t *sm = &vcm->segment_main;
+ fifo_segment_t *segment;
+ u32 segment_index;
+
+ segment_index = vcl_segment_table_lookup (segment_handle);
+ if (segment_index == (u32) ~ 0)
+ return;
+ segment = fifo_segment_get_segment (sm, segment_index);
+ fifo_segment_delete (sm, segment);
+ vcl_segment_table_del (segment_handle);
+ VDBG (0, "detached segment %u handle %u", segment_index, segment_handle);
+}
+
+
/*
* fd.io coding-style-patch-verification: ON
*