48 s =
format (s,
"SESSION_QUEUE: session index %d, server thread index %d",
55 #define foreach_session_queue_error \ 56 _(TX, "Packets transmitted") \ 57 _(TIMER, "Timer events") 61 #define _(sym,str) SESSION_QUEUE_ERROR_##sym, 68 #define _(sym,string) string, 83 session_fifo_event_t * e0,
85 int *n_tx_packets,
u8 peek_data)
88 u32 left_to_snd0, max_len_to_snd0, len_to_deq0, n_bufs, snd_space0;
89 u32 n_frame_bytes, n_frames_per_evt;
92 u32 next_index, next0, *to_next, n_left_to_next, bi0;
102 tc0 = transport_vft->get_connection (s0->connection_index, thread_index);
105 snd_space0 = transport_vft->send_space (tc0);
106 snd_mss0 = transport_vft->send_mss (tc0);
112 vec_add1 (smm->evts_partially_read[thread_index], *e0);
116 ASSERT (e0->enqueue_length > 0);
119 max_len_to_snd0 =
clib_min (e0->enqueue_length, snd_space0);
124 rx_offset = transport_vft->tx_fifo_offset (tc0);
131 n_frames_per_evt = ceil ((
double) max_len_to_snd0 / n_frame_bytes);
133 n_bufs =
vec_len (smm->tx_buffers[thread_index]);
134 left_to_snd0 = max_len_to_snd0;
135 for (i = 0; i < n_frames_per_evt; i++)
141 n_bufs + VLIB_FRAME_SIZE - 1);
151 if (left_to_snd0 != max_len_to_snd0)
153 e0->enqueue_length -= max_len_to_snd0 - left_to_snd0;
154 vec_add1 (smm->evts_partially_read[thread_index], *e0);
160 _vec_len (smm->tx_buffers[thread_index]) = n_bufs;
164 while (left_to_snd0 && n_left_to_next)
168 bi0 = smm->tx_buffers[thread_index][n_bufs];
169 _vec_len (smm->tx_buffers[thread_index]) = n_bufs;
198 len_to_deq0 = (left_to_snd0 < snd_mss0) ? left_to_snd0 : snd_mss0;
202 ed->data[0] = e0->event_id;
203 ed->data[1] = e0->enqueue_length;
204 ed->data[2] = len_to_deq0;
205 ed->data[3] = left_to_snd0;
219 rx_offset, len_to_deq0, data0);
220 if (n_bytes_read < 0)
225 rx_offset += n_bytes_read;
230 len_to_deq0, data0) < 0)
237 transport_vft->push_header (tc0, b0);
239 left_to_snd0 -= len_to_deq0;
240 *n_tx_packets = *n_tx_packets + 1;
243 to_next, n_left_to_next,
250 if (max_len_to_snd0 < e0->enqueue_length)
252 e0->enqueue_length -= max_len_to_snd0;
253 vec_add1 (smm->evts_partially_read[thread_index], *e0);
260 e0->enqueue_length -= max_len_to_snd0 - left_to_snd0;
261 vec_add1 (smm->evts_partially_read[thread_index], *e0);
265 _vec_len (smm->tx_buffers[thread_index]) += 1;
274 session_fifo_event_t * e0,
285 session_fifo_event_t * e0,
298 session_fifo_event_t *my_fifo_events, *e;
299 u32 n_to_dequeue, n_events;
301 int n_tx_packets = 0;
313 q = smm->vpp_event_queues[my_thread_index];
318 n_to_dequeue = q->cursize;
319 my_fifo_events = smm->fifo_events[my_thread_index];
321 if (n_to_dequeue == 0 &&
vec_len (my_fifo_events) == 0)
329 if (
vec_len (my_fifo_events) >= 100)
333 if (pthread_mutex_trylock (&q->mutex))
336 for (i = 0; i < n_to_dequeue; i++)
343 if (q->cursize < (q->maxsize / 8))
344 (void) pthread_cond_broadcast (&q->condvar);
345 pthread_mutex_unlock (&q->mutex);
347 smm->fifo_events[my_thread_index] = my_fifo_events;
350 n_events =
vec_len (my_fifo_events);
351 for (i = 0; i < n_events; i++)
355 u32 server_session_index0, server_thread_index0;
356 session_fifo_event_t *e0;
358 e0 = &my_fifo_events[
i];
364 ASSERT (server_thread_index0 == my_thread_index);
369 if (CLIB_DEBUG && !s0)
378 ASSERT (s0->thread_index == my_thread_index);
380 switch (e0->event_type)
385 rv = (smm->session_tx_fns[s0->session_type]) (vm, node, smm, e0, s0,
394 clib_warning (
"unhandled event type %d", e0->event_type);
403 session_fifo_event_t *partially_read =
404 smm->evts_partially_read[my_thread_index];
405 vec_add (partially_read, &my_fifo_events[i], n_events - i);
407 smm->fifo_events[my_thread_index] = partially_read;
408 smm->evts_partially_read[my_thread_index] = 0;
412 vec_free (smm->fifo_events[my_thread_index]);
413 smm->fifo_events[my_thread_index] =
414 smm->evts_partially_read[my_thread_index];
415 smm->evts_partially_read[my_thread_index] = 0;
419 SESSION_QUEUE_ERROR_TX, n_tx_packets);
428 .name =
"session-queue",
434 .state = VLIB_NODE_STATE_DISABLED,
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
sll srl srl sll sra u16x4 i
static u32 vlib_get_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt)
struct _transport_connection transport_connection_t
static f64 vlib_time_now(vlib_main_t *vm)
static u32 session_type_to_next[]
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
struct _vlib_node_registration vlib_node_registration_t
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
int session_tx_fifo_dequeue_and_snd(vlib_main_t *vm, vlib_node_runtime_t *node, session_manager_main_t *smm, session_fifo_event_t *e0, stream_session_t *s0, u32 thread_index, int *n_tx_pkts)
struct _stream_session_t stream_session_t
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
static void vlib_trace_buffer(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, vlib_buffer_t *b, int follow_chain)
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
static char * session_queue_error_strings[]
static u32 svm_fifo_max_dequeue(svm_fifo_t *f)
#define VLIB_BUFFER_TOTAL_LENGTH_VALID
int session_tx_fifo_peek_and_snd(vlib_main_t *vm, vlib_node_runtime_t *node, session_manager_main_t *smm, session_fifo_event_t *e0, stream_session_t *s0, u32 thread_index, int *n_tx_pkts)
struct _transport_proto_vft transport_proto_vft_t
static session_manager_main_t * vnet_get_session_manager_main()
u16 current_length
Nbytes between current data and the end of this buffer.
static void * vlib_buffer_make_headroom(vlib_buffer_t *b, u8 size)
Make head room, typically for packet headers.
int unix_shared_memory_queue_sub_raw(unix_shared_memory_queue_t *q, u8 *elem)
struct _session_manager_main session_manager_main_t
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
vlib_error_t error
Error code for buffers to be enqueued to error handler.
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
#define foreach_session_queue_error
#define VNET_BUFFER_LOCALLY_ORIGINATED
void tcp_update_time(f64 now, u32 thread_index)
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
static stream_session_t * stream_session_get_if_valid(u64 si, u32 thread_index)
vlib_node_registration_t session_queue_node
(constructor) VLIB_REGISTER_NODE (session_queue_node)
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
transport_proto_vft_t * session_get_transport_vft(u8 type)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
int svm_fifo_peek(svm_fifo_t *f, int pid, u32 offset, u32 max_bytes, u8 *copy_here)
#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b)
#define VLIB_REGISTER_NODE(x,...)
static int session_tx_fifo_read_and_snd_i(vlib_main_t *vm, vlib_node_runtime_t *node, session_manager_main_t *smm, session_fifo_event_t *e0, stream_session_t *s0, u32 thread_index, int *n_tx_packets, u8 peek_data)
int svm_fifo_dequeue_nowait(svm_fifo_t *f, int pid, u32 max_bytes, u8 *copy_here)
static u8 * format_session_queue_trace(u8 *s, va_list *args)
static void vlib_set_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt, u32 count)
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
static u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
#define SESSION_EVT_DBG(_s, _evt, _body)
static uword session_queue_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
struct _unix_shared_memory_queue unix_shared_memory_queue_t