summaryrefslogtreecommitdiffstats
path: root/src/plugins/hs_apps/sapi/vpp_echo_bapi.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2020-12-08 17:50:45 -0800
committerFlorin Coras <fcoras@cisco.com>2020-12-24 23:08:43 -0800
commitc547e91df7083007c87615ac1e37b6f223e575e9 (patch)
tree0677e843f5307becf326c14d43d57c0e4b8c3329 /src/plugins/hs_apps/sapi/vpp_echo_bapi.c
parent8219f1f361083cc63022b70d11b08f52833d4789 (diff)
svm: split fifo into private and shared structs
Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: Id8e77e8b2623be719fd43a95e181eaa5b7df2b6e
Diffstat (limited to 'src/plugins/hs_apps/sapi/vpp_echo_bapi.c')
-rw-r--r--src/plugins/hs_apps/sapi/vpp_echo_bapi.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/plugins/hs_apps/sapi/vpp_echo_bapi.c b/src/plugins/hs_apps/sapi/vpp_echo_bapi.c
index e71c0e9adba..c643cec2ce3 100644
--- a/src/plugins/hs_apps/sapi/vpp_echo_bapi.c
+++ b/src/plugins/hs_apps/sapi/vpp_echo_bapi.c
@@ -262,6 +262,39 @@ echo_segment_detach (u64 segment_handle)
clib_spinlock_unlock (&em->segment_handles_lock);
}
+int
+echo_attach_session (uword segment_handle, uword rxf_offset, uword txf_offset,
+ echo_session_t *s)
+{
+ svm_fifo_shared_t *rx_fifo, *tx_fifo;
+ echo_main_t *em = &echo_main;
+ fifo_segment_t *fs;
+ u32 fs_index;
+
+ fs_index = echo_segment_lookup (segment_handle);
+ if (fs_index == (u32) ~0)
+ {
+ ECHO_LOG (0, "ERROR: segment for session %u is not mounted!",
+ s->session_index);
+ return -1;
+ }
+
+ rx_fifo = uword_to_pointer (rxf_offset, svm_fifo_shared_t *);
+ tx_fifo = uword_to_pointer (txf_offset, svm_fifo_shared_t *);
+ rx_fifo->client_session_index = s->session_index;
+ tx_fifo->client_session_index = s->session_index;
+
+ clib_spinlock_lock (&em->segment_handles_lock);
+
+ fs = fifo_segment_get_segment (&em->segment_main, fs_index);
+ s->rx_fifo = fifo_segment_alloc_fifo_w_shared (fs, rx_fifo);
+ s->tx_fifo = fifo_segment_alloc_fifo_w_shared (fs, tx_fifo);
+
+ clib_spinlock_unlock (&em->segment_handles_lock);
+
+ return 0;
+}
+
/*
*
* Binary API callbacks