summaryrefslogtreecommitdiffstats
path: root/src/vcl
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2021-01-27 18:08:25 -0800
committerDave Barach <openvpp@barachs.net>2021-01-28 15:57:33 +0000
commit80b742592bd227cedb22362abb6286838977ba4f (patch)
treeca87e72c58df443744cc6b50a65feaf947ef36de /src/vcl
parentb13ba133fbdb3a66a6c3ddf19a2bc80525b92606 (diff)
svm vcl: add helper fn that discovers mqs in segment
Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I1b083ee793a7cf91b1001bfe88353fa5e6515c42
Diffstat (limited to 'src/vcl')
-rw-r--r--src/vcl/vcl_bapi.c12
-rw-r--r--src/vcl/vcl_private.c23
-rw-r--r--src/vcl/vcl_private.h1
-rw-r--r--src/vcl/vcl_sapi.c10
4 files changed, 37 insertions, 9 deletions
diff --git a/src/vcl/vcl_bapi.c b/src/vcl/vcl_bapi.c
index 48695a31a3e..618a46d0a7e 100644
--- a/src/vcl/vcl_bapi.c
+++ b/src/vcl/vcl_bapi.c
@@ -100,11 +100,6 @@ vl_api_app_attach_reply_t_handler (vl_api_app_attach_reply_t * mp)
fds[n_fds++]))
goto failed;
- vcl_segment_attach_mq (vcl_vpp_worker_segment_handle (0),
- mp->vpp_ctrl_mq, mp->vpp_ctrl_mq_thread,
- &wrk->ctrl_mq);
- vcm->ctrl_mq = wrk->ctrl_mq;
-
if (mp->fd_flags & SESSION_FD_F_MEMFD_SEGMENT)
{
segment_name = vl_api_from_api_to_new_c_string (&mp->segment_name);
@@ -126,6 +121,13 @@ vl_api_app_attach_reply_t_handler (vl_api_app_attach_reply_t * mp)
n_fds++;
}
+ vcl_segment_discover_mqs (vcl_vpp_worker_segment_handle (0), fds + n_fds,
+ mp->n_fds - n_fds);
+ vcl_segment_attach_mq (vcl_vpp_worker_segment_handle (0),
+ mp->vpp_ctrl_mq, mp->vpp_ctrl_mq_thread,
+ &wrk->ctrl_mq);
+ vcm->ctrl_mq = wrk->ctrl_mq;
+
vec_free (fds);
}
else
diff --git a/src/vcl/vcl_private.c b/src/vcl/vcl_private.c
index b9745d27e4e..85fe0a8b06e 100644
--- a/src/vcl/vcl_private.c
+++ b/src/vcl/vcl_private.c
@@ -456,6 +456,29 @@ vcl_segment_attach_mq (uword segment_handle, uword mq_offset, u32 mq_index,
return 0;
}
+int
+vcl_segment_discover_mqs (uword segment_handle, int *fds, u32 n_fds)
+{
+ fifo_segment_t *fs;
+ u32 fs_index;
+
+ fs_index = vcl_segment_table_lookup (segment_handle);
+ if (fs_index == VCL_INVALID_SEGMENT_INDEX)
+ {
+ VDBG (0, "ERROR: mq segment %lx for is not attached!", segment_handle);
+ return -1;
+ }
+
+ clib_rwlock_reader_lock (&vcm->segment_table_lock);
+
+ fs = fifo_segment_get_segment (&vcm->segment_main, fs_index);
+ fifo_segment_msg_qs_discover (fs, fds, n_fds);
+
+ clib_rwlock_reader_unlock (&vcm->segment_table_lock);
+
+ return 0;
+}
+
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/vcl/vcl_private.h b/src/vcl/vcl_private.h
index 7104adc4452..e4e73e0430d 100644
--- a/src/vcl/vcl_private.h
+++ b/src/vcl/vcl_private.h
@@ -699,6 +699,7 @@ int vcl_segment_attach_session (uword segment_handle, uword rxf_offset,
vcl_session_t *s);
int vcl_segment_attach_mq (uword segment_handle, uword mq_offset, u32 mq_index,
svm_msg_q_t **mq);
+int vcl_segment_discover_mqs (uword segment_handle, int *fds, u32 n_fds);
/*
* VCL Binary API
diff --git a/src/vcl/vcl_sapi.c b/src/vcl/vcl_sapi.c
index 1bab7eaba13..5258722a484 100644
--- a/src/vcl/vcl_sapi.c
+++ b/src/vcl/vcl_sapi.c
@@ -71,10 +71,6 @@ vcl_api_attach_reply_handler (app_sapi_attach_reply_msg_t * mp, int *fds)
SSVM_SEGMENT_MEMFD, fds[n_fds_used++]))
goto failed;
- vcl_segment_attach_mq (vcl_vpp_worker_segment_handle (0), mp->vpp_ctrl_mq,
- mp->vpp_ctrl_mq_thread, &wrk->ctrl_mq);
- vcm->ctrl_mq = wrk->ctrl_mq;
-
if (mp->fd_flags & SESSION_FD_F_MEMFD_SEGMENT)
{
segment_name = format (0, "memfd-%ld%c", segment_handle, 0);
@@ -93,6 +89,12 @@ vcl_api_attach_reply_handler (app_sapi_attach_reply_msg_t * mp, int *fds)
vcl_mq_epoll_add_evfd (wrk, wrk->app_event_queue);
}
+ vcl_segment_discover_mqs (vcl_vpp_worker_segment_handle (0),
+ fds + n_fds_used, mp->n_fds - n_fds_used);
+ vcl_segment_attach_mq (vcl_vpp_worker_segment_handle (0), mp->vpp_ctrl_mq,
+ mp->vpp_ctrl_mq_thread, &wrk->ctrl_mq);
+ vcm->ctrl_mq = wrk->ctrl_mq;
+
vcm->app_index = mp->app_index;
return 0;