Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
session: segment manager refactor
[vpp.git]
/
src
/
tests
/
vnet
/
session
/
udp_echo.c
diff --git
a/src/tests/vnet/session/udp_echo.c
b/src/tests/vnet/session/udp_echo.c
index
ac94118
..
e425169
100644
(file)
--- a/
src/tests/vnet/session/udp_echo.c
+++ b/
src/tests/vnet/session/udp_echo.c
@@
-65,7
+65,7
@@
typedef struct
typedef struct
{
/* vpe input queue */
typedef struct
{
/* vpe input queue */
-
unix_shared_memory
_queue_t *vl_input_queue;
+
svm
_queue_t *vl_input_queue;
/* API client handle */
u32 my_client_index;
/* API client handle */
u32 my_client_index;
@@
-91,10
+91,10
@@
typedef struct
int i_am_master;
/* Our event queue */
int i_am_master;
/* Our event queue */
-
unix_shared_memory
_queue_t *our_event_queue;
+
svm
_queue_t *our_event_queue;
/* $$$ single thread only for the moment */
/* $$$ single thread only for the moment */
-
unix_shared_memory
_queue_t *vpp_event_queue;
+
svm
_queue_t *vpp_event_queue;
/* $$$$ hack: cut-through session index */
volatile u32 cut_through_session_index;
/* $$$$ hack: cut-through session index */
volatile u32 cut_through_session_index;
@@
-202,7
+202,7
@@
vl_api_application_attach_reply_t_handler (vl_api_application_attach_reply_t *
mp)
{
uri_udp_test_main_t *utm = &uri_udp_test_main;
mp)
{
uri_udp_test_main_t *utm = &uri_udp_test_main;
- svm_fifo_segment_create_args_t _a, *a = &_a;
+ svm_fifo_segment_create_args_t _a
= { 0 }
, *a = &_a;
int rv;
if (mp->retval)
int rv;
if (mp->retval)
@@
-233,8
+233,7
@@
vl_api_application_attach_reply_t_handler (vl_api_application_attach_reply_t *
}
utm->our_event_queue =
}
utm->our_event_queue =
- uword_to_pointer (mp->app_event_queue_address,
- unix_shared_memory_queue_t *);
+ uword_to_pointer (mp->app_event_queue_address, svm_queue_t *);
}
static void
}
static void
@@
-488,9
+487,8
@@
send_test_chunk (uri_udp_test_main_t * utm, svm_fifo_t * tx_fifo, int mypid,
evt.fifo = tx_fifo;
evt.event_type = FIFO_EVENT_APP_TX;
evt.fifo = tx_fifo;
evt.event_type = FIFO_EVENT_APP_TX;
- unix_shared_memory_queue_add (utm->vpp_event_queue,
- (u8 *) & evt,
- 0 /* do wait for mutex */ );
+ svm_queue_add (utm->vpp_event_queue,
+ (u8 *) & evt, 0 /* do wait for mutex */ );
}
}
}
}
}
}
@@
-636,7
+634,7
@@
vl_api_connect_uri_t_handler (vl_api_connect_uri_t * mp)
svm_fifo_segment_main_t *sm = &svm_fifo_segment_main;
svm_fifo_segment_create_args_t _a, *a = &_a;
svm_fifo_segment_private_t *seg;
svm_fifo_segment_main_t *sm = &svm_fifo_segment_main;
svm_fifo_segment_create_args_t _a, *a = &_a;
svm_fifo_segment_private_t *seg;
-
unix_shared_memory
_queue_t *client_q;
+
svm
_queue_t *client_q;
vl_api_connect_session_reply_t *rmp;
session_t *session = 0;
int rv = 0;
vl_api_connect_session_reply_t *rmp;
session_t *session = 0;
int rv = 0;
@@
-699,8
+697,7
@@
send_reply:
vec_free (a->segment_name);
vec_free (a->segment_name);
- client_q =
- uword_to_pointer (mp->client_queue_address, unix_shared_memory_queue_t *);
+ client_q = uword_to_pointer (mp->client_queue_address, svm_queue_t *);
vl_msg_api_send_shmem (client_q, (u8 *) & rmp);
}
vl_msg_api_send_shmem (client_q, (u8 *) & rmp);
}
@@
-728,8
+725,7
@@
vl_api_accept_session_t_handler (vl_api_accept_session_t * mp)
start_time = clib_time_now (&utm->clib_time);
utm->vpp_event_queue =
start_time = clib_time_now (&utm->clib_time);
utm->vpp_event_queue =
- uword_to_pointer (mp->vpp_event_queue_address,
- unix_shared_memory_queue_t *);
+ uword_to_pointer (mp->vpp_event_queue_address, svm_queue_t *);
pool_get (utm->sessions, session);
pool_get (utm->sessions, session);
@@
-850,12
+846,12
@@
vl_api_connect_session_reply_t_handler (vl_api_connect_session_reply_t * mp)
{
utm->connected_session = session - utm->sessions;
utm->vpp_event_queue = uword_to_pointer (mp->vpp_event_queue_address,
{
utm->connected_session = session - utm->sessions;
utm->vpp_event_queue = uword_to_pointer (mp->vpp_event_queue_address,
-
unix_shared_memory
_queue_t *);
+
svm
_queue_t *);
}
utm->state = STATE_READY;
}
}
utm->state = STATE_READY;
}
-#define foreach_
uri_msg
\
+#define foreach_
tcp_echo_msg
\
_(BIND_URI_REPLY, bind_uri_reply) \
_(CONNECT_URI, connect_uri) \
_(CONNECT_SESSION_REPLY, connect_session_reply) \
_(BIND_URI_REPLY, bind_uri_reply) \
_(CONNECT_URI, connect_uri) \
_(CONNECT_SESSION_REPLY, connect_session_reply) \
@@
-867,7
+863,7
@@
_(APPLICATION_ATTACH_REPLY, application_attach_reply) \
_(APPLICATION_DETACH_REPLY, application_detach_reply) \
void
_(APPLICATION_DETACH_REPLY, application_detach_reply) \
void
-
uri
_api_hookup (uri_udp_test_main_t * utm)
+
tcp_echo
_api_hookup (uri_udp_test_main_t * utm)
{
#define _(N,n) \
vl_msg_api_set_handlers(VL_API_##N, #n, \
{
#define _(N,n) \
vl_msg_api_set_handlers(VL_API_##N, #n, \
@@
-876,7
+872,7
@@
uri_api_hookup (uri_udp_test_main_t * utm)
vl_api_##n##_t_endian, \
vl_api_##n##_t_print, \
sizeof(vl_api_##n##_t), 1);
vl_api_##n##_t_endian, \
vl_api_##n##_t_print, \
sizeof(vl_api_##n##_t), 1);
- foreach_
uri
_msg;
+ foreach_
tcp_echo
_msg;
#undef _
}
#undef _
}
@@
-921,7
+917,7
@@
server_handle_fifo_event_rx (uri_udp_test_main_t * utm,
svm_fifo_t *rx_fifo, *tx_fifo;
int nbytes;
session_fifo_event_t evt;
svm_fifo_t *rx_fifo, *tx_fifo;
int nbytes;
session_fifo_event_t evt;
-
unix_shared_memory
_queue_t *q;
+
svm
_queue_t *q;
int rv;
rx_fifo = e->fifo;
int rv;
rx_fifo = e->fifo;
@@
-946,8
+942,7
@@
server_handle_fifo_event_rx (uri_udp_test_main_t * utm,
evt.fifo = tx_fifo;
evt.event_type = FIFO_EVENT_APP_TX;
q = utm->vpp_event_queue;
evt.fifo = tx_fifo;
evt.event_type = FIFO_EVENT_APP_TX;
q = utm->vpp_event_queue;
- unix_shared_memory_queue_add (q, (u8 *) & evt,
- 0 /* do wait for mutex */ );
+ svm_queue_add (q, (u8 *) & evt, 0 /* do wait for mutex */ );
}
}
}
}
@@
-961,8
+956,7
@@
server_handle_event_queue (uri_udp_test_main_t * utm)
while (1)
{
while (1)
{
- unix_shared_memory_queue_sub (utm->our_event_queue, (u8 *) e,
- 0 /* nowait */ );
+ svm_queue_sub (utm->our_event_queue, (u8 *) e, SVM_Q_WAIT, 0);
switch (e->event_type)
{
case FIFO_EVENT_APP_RX:
switch (e->event_type)
{
case FIFO_EVENT_APP_RX:
@@
-1050,15
+1044,16
@@
int
main (int argc, char **argv)
{
uri_udp_test_main_t *utm = &uri_udp_test_main;
main (int argc, char **argv)
{
uri_udp_test_main_t *utm = &uri_udp_test_main;
+ u8 *bind_name = (u8 *) "udp://0.0.0.0/1234";
unformat_input_t _argv, *a = &_argv;
unformat_input_t _argv, *a = &_argv;
+ int i_am_master = 1;
+ session_t *session;
u8 *chroot_prefix;
u8 *chroot_prefix;
+ char *app_name;
+ mheap_t *h;
u8 *heap;
u8 *heap;
- u8 *bind_name = (u8 *) "udp://0.0.0.0/1234";
u32 tmp;
u32 tmp;
- mheap_t *h;
- session_t *session;
int i;
int i;
- int i_am_master = 1;
clib_mem_init (0, 256 << 20);
clib_mem_init (0, 256 << 20);
@@
-1071,13
+1066,12
@@
main (int argc, char **argv)
vec_validate (utm->rx_buf, 8192);
utm->session_index_by_vpp_handles = hash_create (0, sizeof (uword));
vec_validate (utm->rx_buf, 8192);
utm->session_index_by_vpp_handles = hash_create (0, sizeof (uword));
-
utm->my_pid = getpid ();
utm->configured_segment_size = 1 << 20;
clib_time_init (&utm->clib_time);
init_error_string_table (utm);
utm->my_pid = getpid ();
utm->configured_segment_size = 1 << 20;
clib_time_init (&utm->clib_time);
init_error_string_table (utm);
- svm_fifo_segment_init (0x200000000ULL, 20);
+ svm_fifo_segment_
main_
init (0x200000000ULL, 20);
unformat_init_command_line (a, argv);
while (unformat_check_input (a) != UNFORMAT_END_OF_INPUT)
unformat_init_command_line (a, argv);
while (unformat_check_input (a) != UNFORMAT_END_OF_INPUT)
@@
-1107,14
+1101,13
@@
main (int argc, char **argv)
utm->uri = format (0, "%s%c", bind_name, 0);
utm->i_am_master = i_am_master;
utm->segment_main = &svm_fifo_segment_main;
utm->uri = format (0, "%s%c", bind_name, 0);
utm->i_am_master = i_am_master;
utm->segment_main = &svm_fifo_segment_main;
-
utm->connect_uri = format (0, "udp://6.0.1.2/1234%c", 0);
setup_signal_handlers ();
utm->connect_uri = format (0, "udp://6.0.1.2/1234%c", 0);
setup_signal_handlers ();
+ tcp_echo_api_hookup (utm);
- uri_api_hookup (utm);
-
- if (connect_to_vpp (i_am_master ? "uri_udp_master" : "uri_udp_slave") < 0)
+ app_name = i_am_master ? "udp_echo_master" : "udp_echo_slave";
+ if (connect_to_vpp (app_name) < 0)
{
svm_region_exit ();
fformat (stderr, "Couldn't connect to vpe, exiting...\n");
{
svm_region_exit ();
fformat (stderr, "Couldn't connect to vpe, exiting...\n");