66 bsm->
rx_retries[s->thread_index][s->session_index] = 0;
99 const u8 * seg_name,
u32 seg_size)
118 for (i = 0; i < actual_transfer; i++)
124 bsm->
rx_buf[my_thread_id][i]);
141 rx_fifo = s->server_rx_fifo;
147 bsm->
rx_buf[my_thread_id]);
149 while (actual_transfer > 0);
156 u32 n_written, max_dequeue, max_enqueue, max_transfer;
160 session_fifo_event_t evt;
163 ASSERT (s->thread_index == thread_index);
165 rx_fifo = s->server_rx_fifo;
166 tx_fifo = s->server_tx_fifo;
168 ASSERT (rx_fifo->master_thread_index == thread_index);
169 ASSERT (tx_fifo->master_thread_index == thread_index);
178 max_transfer = (max_dequeue < max_enqueue) ? max_dequeue : max_enqueue;
199 if (bsm->
rx_retries[thread_index][s->session_index] == 500000)
203 if (bsm->
rx_retries[thread_index][s->session_index] < 500001)
204 bsm->
rx_retries[thread_index][s->session_index]++;
210 _vec_len (bsm->
rx_buf[thread_index]) = max_transfer;
213 bsm->
rx_buf[thread_index]);
214 ASSERT (actual_transfer == max_transfer);
223 bsm->
rx_buf[thread_index]);
225 if (n_written != max_transfer)
275 u8 segment_name[128];
278 u32 segment_size = 512 << 20;
280 memset (a, 0,
sizeof (*a));
281 memset (options, 0,
sizeof (options));
295 a->options = options;
306 a->namespace_id = appns_id;
310 a->segment_name = segment_name;
311 a->segment_name_length =
ARRAY_LEN (segment_name);
327 memset (a, 0,
sizeof (*a));
356 for (i = 0; i < num_threads; i++)
377 u8 server_uri_set = 0, *appns_id = 0;
378 u64 tmp, appns_flags = 0, appns_secret = 0;
399 else if (
unformat (input,
"private-segment-count %d",
402 else if (
unformat (input,
"private-segment-size %U",
405 if (tmp >= 0x100000000ULL)
407 (0,
"private segment size %lld (%llu) too large", tmp, tmp);
412 else if (
unformat (input,
"appns %_%v%_", &appns_id))
414 else if (
unformat (input,
"all-scope"))
415 appns_flags |= (APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE
416 | APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE);
417 else if (
unformat (input,
"local-scope"))
418 appns_flags |= APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE;
419 else if (
unformat (input,
"global-scope"))
420 appns_flags |= APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE;
421 else if (
unformat (input,
"secret %lu", &appns_secret))
433 rv =
server_create (vm, appns_id, appns_flags, appns_secret);
449 .path =
"test tcp server",
450 .short_help =
"test tcp server [no echo][fifo-size <mbytes>] " 451 "[rcv-buf-size <bytes>][prealloc-fifos <count>]" 452 "[private-segment-count <count>][private-segment-size <bytes[m|g]>]" 453 "[uri <tcp://ip/port>]",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
void test_bytes(builtin_server_main_t *bsm, int actual_transfer)
sll srl srl sll sra u16x4 i
u32 rcv_buffer_size
Rcv buffer size.
unix_shared_memory_queue_t ** vpp_queue
u32 private_segment_count
Number of private segments.
int vnet_bind_uri(vnet_bind_args_t *a)
static clib_error_t * server_create_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static int server_attach(u8 *appns_id, u64 appns_flags, u64 appns_secret)
unix_shared_memory_queue_t * vl_input_queue
int builtin_redirect_connect_callback(u32 client_index, void *mp)
u8 ** rx_buf
Per-thread RX buffer.
static u32 svm_fifo_max_enqueue(svm_fifo_t *f)
u32 prealloc_fifos
Preallocate fifos.
builtin_server_main_t builtin_server_main
struct _svm_fifo svm_fifo_t
u8 no_echo
Don't echo traffic.
#define VLIB_INIT_FUNCTION(x)
struct _vnet_disconnect_args_t vnet_disconnect_args_t
static u32 svm_fifo_max_dequeue(svm_fifo_t *f)
struct _stream_session_cb_vft session_cb_vft_t
unix_shared_memory_queue_t * vl_input_queue
Sever's event queue.
#define clib_error_return(e, args...)
char * server_uri
Server URI.
struct vl_shmem_hdr_ * shmem_hdr
Binary API shared-memory segment header pointer.
void stream_session_cleanup(stream_session_t *s)
Cleanup transport and session state.
struct _stream_session_t stream_session_t
static int create_api_loopback(vlib_main_t *vm)
struct _vnet_app_attach_args_t vnet_app_attach_args_t
vl_shmem_hdr_t * shmem_hdr
int unix_shared_memory_queue_add(unix_shared_memory_queue_t *q, u8 *elem, int nowait)
void builtin_session_disconnect_callback(stream_session_t *s)
static int server_create(vlib_main_t *vm, u8 *appns_id, u64 appns_flags, u64 appns_secret)
u32 my_client_index
API client handle.
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
API main structure, used by both vpp and binary API clients.
static u8 svm_fifo_set_event(svm_fifo_t *f)
Sets fifo event flag.
static unix_shared_memory_queue_t * session_manager_get_vpp_event_queue(u32 thread_index)
int builtin_add_segment_callback(u32 client_index, const u8 *seg_name, u32 seg_size)
static_always_inline uword vlib_get_thread_index(void)
u8 * format_stream_session(u8 *s, va_list *args)
Format stream session as per the following format.
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
u32 private_segment_size
Size of private segments.
u32 vl_api_memclnt_create_internal(char *, unix_shared_memory_queue_t *)
int vnet_disconnect_session(vnet_disconnect_args_t *a)
int svm_fifo_enqueue_nowait(svm_fifo_t *f, u32 max_bytes, u8 *copy_from_here)
int builtin_session_accept_callback(stream_session_t *s)
#define VLIB_CLI_COMMAND(x,...)
clib_error_t * builtin_tcp_server_main_init(vlib_main_t *vm)
int builtin_server_rx_callback(stream_session_t *s)
int builtin_server_rx_callback_no_echo(stream_session_t *s)
static u64 session_handle(stream_session_t *s)
u32 node_index
process node index for evnt scheduling
void builtin_session_reset_callback(stream_session_t *s)
static session_cb_vft_t builtin_session_cb_vft
clib_error_t * vnet_application_attach(vnet_app_attach_args_t *a)
Attach application to vpp.
static int server_listen()
int builtin_session_connected_callback(u32 app_index, u32 api_context, stream_session_t *s, u8 is_fail)
static vlib_thread_main_t * vlib_get_thread_main()
u32 app_index
Server app index.
int svm_fifo_dequeue_nowait(svm_fifo_t *f, u32 max_bytes, u8 *copy_here)
struct _vnet_bind_args_t vnet_bind_args_t
struct _unix_shared_memory_queue unix_shared_memory_queue_t