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;
161 static int serial_number = 0;
164 ASSERT (s->thread_index == thread_index);
166 rx_fifo = s->server_rx_fifo;
167 tx_fifo = s->server_tx_fifo;
169 ASSERT (rx_fifo->master_thread_index == thread_index);
170 ASSERT (tx_fifo->master_thread_index == thread_index);
179 max_transfer = (max_dequeue < max_enqueue) ? max_dequeue : max_enqueue;
201 if (bsm->
rx_retries[thread_index][s->session_index] == 500000)
205 if (bsm->
rx_retries[thread_index][s->session_index] < 500001)
206 bsm->
rx_retries[thread_index][s->session_index]++;
212 _vec_len (bsm->
rx_buf[thread_index]) = max_transfer;
215 bsm->
rx_buf[thread_index]);
216 ASSERT (actual_transfer == max_transfer);
225 bsm->
rx_buf[thread_index]);
227 if (n_written != max_transfer)
235 evt.event_id = serial_number++;
278 u8 segment_name[128];
282 memset (a, 0,
sizeof (*a));
283 memset (options, 0,
sizeof (options));
293 a->options = options;
304 a->segment_name = segment_name;
305 a->segment_name_length =
ARRAY_LEN (segment_name);
321 memset (a, 0,
sizeof (*a));
349 for (i = 0; i < num_threads; i++)
370 u8 server_uri_set = 0;
392 else if (
unformat (input,
"private-segment-count %d",
395 else if (
unformat (input,
"private-segment-size %U",
398 if (tmp >= 0x100000000ULL)
400 (0,
"private segment size %lld (%llu) too large", tmp, tmp);
430 .path =
"test tcp server",
431 .short_help =
"test tcp server [no echo][fifo-size <mbytes>] " 432 "[rcv-buf-size <bytes>][prealloc-fifos <count>]" 433 "[private-segment-count <count>][private-segment-size <bytes[m|g]>]" 434 "[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)
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...)
static int server_attach()
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)
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 int server_create(vlib_main_t *vm)
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,...)
int vnet_application_attach(vnet_app_attach_args_t *a)
Attaches application.
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 stream_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
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