summaryrefslogtreecommitdiffstats
path: root/src/vnet/session/session_api.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2020-12-11 13:58:12 -0800
committerFlorin Coras <fcoras@cisco.com>2020-12-29 12:11:07 -0800
commitb462418890240b2e38dbf522f9dd0196b79e0fa8 (patch)
tree3ae26a22edb23da8d40f2c2b54eb96b056bca565 /src/vnet/session/session_api.c
parent04943b4c42db300d0d895644f32da79a6d411c51 (diff)
svm: allow mq attachments at random offsets
Type: feature Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: Ic373cd2c11272da539eb4b0db27227f36f2f9688
Diffstat (limited to 'src/vnet/session/session_api.c')
-rw-r--r--src/vnet/session/session_api.c82
1 files changed, 47 insertions, 35 deletions
diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c
index 8fe1acf6a6e..4602a783e60 100644
--- a/src/vnet/session/session_api.c
+++ b/src/vnet/session/session_api.c
@@ -130,7 +130,8 @@ mq_send_session_accepted_cb (session_t * s)
{
app_worker_t *app_wrk = app_worker_get (s->app_wrk_index);
svm_msg_q_msg_t _msg, *msg = &_msg;
- svm_msg_q_t *vpp_queue, *app_mq;
+ svm_msg_q_t *app_mq;
+ fifo_segment_t *eq_seg;
session_t *listener;
session_accepted_msg_t *mp;
session_event_t *evt;
@@ -152,6 +153,8 @@ mq_send_session_accepted_cb (session_t * s)
mp->segment_handle = session_segment_handle (s);
mp->flags = s->flags;
+ eq_seg = session_main_get_evt_q_segment ();
+
if (session_has_transport (s))
{
listener = listen_session_get_from_handle (s->listener_handle);
@@ -164,8 +167,9 @@ mq_send_session_accepted_cb (session_t * s)
if (listener)
mp->listener_handle = listen_session_get_handle (listener);
}
- vpp_queue = session_main_get_vpp_event_queue (s->thread_index);
- mp->vpp_event_queue_address = pointer_to_uword (vpp_queue);
+ mp->vpp_event_queue_address =
+ fifo_segment_msg_q_offset (eq_seg, s->thread_index);
+ mp->mq_index = s->thread_index;
mp->handle = session_handle (s);
session_get_endpoint (s, &mp->rmt, 0 /* is_lcl */ );
@@ -180,8 +184,9 @@ mq_send_session_accepted_cb (session_t * s)
mp->rmt.is_ip4 = session_type_is_ip4 (listener->session_type);
mp->rmt.port = ct->c_rmt_port;
mp->handle = session_handle (s);
- vpp_queue = session_main_get_vpp_event_queue (s->thread_index);
- mp->vpp_event_queue_address = pointer_to_uword (vpp_queue);
+ mp->vpp_event_queue_address =
+ fifo_segment_msg_q_offset (eq_seg, s->thread_index);
+ mp->mq_index = s->thread_index;
}
svm_msg_q_add_and_unlock (app_mq, msg);
@@ -262,8 +267,9 @@ mq_send_session_connected_cb (u32 app_wrk_index, u32 api_context,
{
svm_msg_q_msg_t _msg, *msg = &_msg;
session_connected_msg_t *mp;
- svm_msg_q_t *vpp_mq, *app_mq;
+ svm_msg_q_t *app_mq;
transport_connection_t *tc;
+ fifo_segment_t *eq_seg;
app_worker_t *app_wrk;
session_event_t *evt;
@@ -289,6 +295,8 @@ mq_send_session_connected_cb (u32 app_wrk_index, u32 api_context,
if (err)
goto done;
+ eq_seg = session_main_get_evt_q_segment ();
+
if (session_has_transport (s))
{
tc = session_get_transport (s);
@@ -299,9 +307,9 @@ mq_send_session_connected_cb (u32 app_wrk_index, u32 api_context,
goto done;
}
- vpp_mq = session_main_get_vpp_event_queue (s->thread_index);
mp->handle = session_handle (s);
- mp->vpp_event_queue_address = pointer_to_uword (vpp_mq);
+ mp->vpp_event_queue_address =
+ fifo_segment_msg_q_offset (eq_seg, s->thread_index);
session_get_endpoint (s, &mp->lcl, 1 /* is_lcl */ );
@@ -318,8 +326,8 @@ mq_send_session_connected_cb (u32 app_wrk_index, u32 api_context,
mp->handle = session_handle (s);
mp->lcl.port = cct->c_lcl_port;
mp->lcl.is_ip4 = cct->c_is_ip4;
- vpp_mq = session_main_get_vpp_event_queue (s->thread_index);
- mp->vpp_event_queue_address = pointer_to_uword (vpp_mq);
+ mp->vpp_event_queue_address =
+ fifo_segment_msg_q_offset (eq_seg, s->thread_index);
mp->server_rx_fifo = pointer_to_uword (s->rx_fifo->shr);
mp->server_tx_fifo = pointer_to_uword (s->tx_fifo->shr);
mp->segment_handle = session_segment_handle (s);
@@ -341,9 +349,10 @@ mq_send_session_bound_cb (u32 app_wrk_index, u32 api_context,
session_handle_t handle, int rv)
{
svm_msg_q_msg_t _msg, *msg = &_msg;
- svm_msg_q_t *app_mq, *vpp_evt_q;
+ svm_msg_q_t *app_mq;
transport_endpoint_t tep;
session_bound_msg_t *mp;
+ fifo_segment_t *eq_seg;
app_worker_t *app_wrk;
session_event_t *evt;
app_listener_t *al;
@@ -381,8 +390,8 @@ mq_send_session_bound_cb (u32 app_wrk_index, u32 api_context,
mp->lcl_is_ip4 = tep.is_ip4;
clib_memcpy_fast (mp->lcl_ip, &tep.ip, sizeof (tep.ip));
- vpp_evt_q = session_main_get_vpp_event_queue (0);
- mp->vpp_evt_q = pointer_to_uword (vpp_evt_q);
+ eq_seg = session_main_get_evt_q_segment ();
+ mp->vpp_evt_q = fifo_segment_msg_q_offset (eq_seg, ls->thread_index);
if (session_transport_service_type (ls) == TRANSPORT_SERVICE_CL)
{
@@ -425,10 +434,14 @@ mq_send_session_migrate_cb (session_t * s, session_handle_t new_sh)
{
svm_msg_q_msg_t _msg, *msg = &_msg;
session_migrated_msg_t *mp;
- svm_msg_q_t *vpp_evt_q;
+ fifo_segment_t *eq_seg;
app_worker_t *app_wrk;
session_event_t *evt;
svm_msg_q_t *app_mq;
+ u32 thread_index;
+
+ thread_index = session_thread_from_handle (new_sh);
+ eq_seg = session_main_get_evt_q_segment ();
app_wrk = app_worker_get (s->app_wrk_index);
app_mq = app_wrk->event_queue;
@@ -441,9 +454,8 @@ mq_send_session_migrate_cb (session_t * s, session_handle_t new_sh)
mp = (session_migrated_msg_t *) evt->data;
mp->handle = session_handle (s);
mp->new_handle = new_sh;
- mp->vpp_thread_index = session_thread_from_handle (new_sh);
- vpp_evt_q = session_main_get_vpp_event_queue (mp->vpp_thread_index);
- mp->vpp_evt_q = pointer_to_uword (vpp_evt_q);
+ mp->vpp_thread_index = thread_index;
+ mp->vpp_evt_q = fifo_segment_msg_q_offset (eq_seg, thread_index);
mp->segment_handle = session_segment_handle (s);
svm_msg_q_add_and_unlock (app_mq, msg);
}
@@ -601,12 +613,10 @@ vl_api_app_attach_t_handler (vl_api_app_attach_t * mp)
{
int rv = 0, fds[SESSION_N_FD_TYPE], n_fds = 0;
vl_api_app_attach_reply_t *rmp;
- ssvm_private_t *segp;
+ fifo_segment_t *segp, *evt_q_segment = 0;
vnet_app_attach_args_t _a, *a = &_a;
- fifo_segment_t *evt_q_segment;
u8 fd_flags = 0, ctrl_thread;
vl_api_registration_t *reg;
- svm_msg_q_t *ctrl_mq;
reg = vl_api_client_index_to_registration (mp->client_index);
if (!reg)
@@ -669,19 +679,19 @@ done:
if (!rv)
{
ctrl_thread = vlib_num_workers () ? 1 : 0;
- ctrl_mq = session_main_get_vpp_event_queue (ctrl_thread);
- segp = a->segment;
+ segp = (fifo_segment_t *) a->segment;
rmp->app_index = clib_host_to_net_u32 (a->app_index);
- rmp->app_mq = pointer_to_uword (a->app_evt_q);
- rmp->vpp_ctrl_mq = pointer_to_uword (ctrl_mq);
+ rmp->app_mq = fifo_segment_msg_q_offset (segp, 0);
+ rmp->vpp_ctrl_mq =
+ fifo_segment_msg_q_offset (evt_q_segment, ctrl_thread);
rmp->vpp_ctrl_mq_thread = ctrl_thread;
rmp->n_fds = n_fds;
rmp->fd_flags = fd_flags;
- if (vec_len (segp->name))
+ if (vec_len (segp->ssvm.name))
{
- vl_api_vec_to_api_string (segp->name, &rmp->segment_name);
+ vl_api_vec_to_api_string (segp->ssvm.name, &rmp->segment_name);
}
- rmp->segment_size = segp->ssvm_size;
+ rmp->segment_size = segp->ssvm.ssvm_size;
rmp->segment_handle = clib_host_to_net_u64 (a->segment_handle);
}
}));
@@ -755,13 +765,14 @@ done:
rmp->segment_handle = clib_host_to_net_u64 (args.segment_handle);
if (!rv && mp->is_add)
{
+ rmp->app_event_queue_address =
+ fifo_segment_msg_q_offset ((fifo_segment_t *) args.segment, 0);
+ rmp->n_fds = n_fds;
+ rmp->fd_flags = fd_flags;
if (vec_len (args.segment->name))
{
vl_api_vec_to_api_string (args.segment->name, &rmp->segment_name);
}
- rmp->app_event_queue_address = pointer_to_uword (args.evt_q);
- rmp->n_fds = n_fds;
- rmp->fd_flags = fd_flags;
}
}));
/* *INDENT-ON* */
@@ -1341,7 +1352,6 @@ session_api_attach_handler (app_namespace_t * app_ns, clib_socket_t * cs,
app_ns_api_handle_t *handle;
app_sapi_msg_t msg = { 0 };
app_worker_t *app_wrk;
- svm_msg_q_t *ctrl_mq;
application_t *app;
/* Make sure name is null terminated */
@@ -1390,10 +1400,11 @@ done:
if (!rv)
{
ctrl_thread = vlib_num_workers ()? 1 : 0;
- ctrl_mq = session_main_get_vpp_event_queue (ctrl_thread);
rmp->app_index = a->app_index;
- rmp->app_mq = pointer_to_uword (a->app_evt_q);
- rmp->vpp_ctrl_mq = pointer_to_uword (ctrl_mq);
+ rmp->app_mq =
+ fifo_segment_msg_q_offset ((fifo_segment_t *) a->segment, 0);
+ rmp->vpp_ctrl_mq =
+ fifo_segment_msg_q_offset (evt_q_segment, ctrl_thread);
rmp->vpp_ctrl_mq_thread = ctrl_thread;
rmp->n_fds = n_fds;
rmp->fd_flags = fd_flags;
@@ -1502,7 +1513,8 @@ done:
if (!rv && mp->is_add)
{
/* No segment name and size. This supports only memfds */
- rmp->app_event_queue_address = pointer_to_uword (args.evt_q);
+ rmp->app_event_queue_address =
+ fifo_segment_msg_q_offset ((fifo_segment_t *) args.segment, 0);
rmp->n_fds = n_fds;
rmp->fd_flags = fd_flags;