blob: 85fd28db7a9a2de75835763fb18ec9189cb76403 [file] [log] [blame]
Dave Barach68b0fb02017-02-28 15:15:56 -05001/*
2 * Copyright (c) 2017 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
Florin Coras6792ec02017-03-13 03:49:51 -070016#include <math.h>
Dave Barach68b0fb02017-02-28 15:15:56 -050017#include <vlib/vlib.h>
18#include <vnet/vnet.h>
Dave Barach68b0fb02017-02-28 15:15:56 -050019#include <vppinfra/elog.h>
Florin Coras561af9b2017-12-09 10:19:43 -080020#include <vnet/session/transport.h>
Florin Coras8e43d042018-05-04 15:46:57 -070021#include <vnet/session/session.h>
Florin Coras6792ec02017-03-13 03:49:51 -070022#include <vnet/session/application.h>
Florin Corase69f4952017-03-07 10:06:24 -080023#include <vnet/session/session_debug.h>
Florin Corase86a8ed2018-01-05 03:20:25 -080024#include <svm/queue.h>
Dave Barach68b0fb02017-02-28 15:15:56 -050025
26vlib_node_registration_t session_queue_node;
27
28typedef struct
29{
30 u32 session_index;
31 u32 server_thread_index;
32} session_queue_trace_t;
33
34/* packet trace format function */
35static u8 *
36format_session_queue_trace (u8 * s, va_list * args)
37{
38 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
39 CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
40 session_queue_trace_t *t = va_arg (*args, session_queue_trace_t *);
41
42 s = format (s, "SESSION_QUEUE: session index %d, server thread index %d",
43 t->session_index, t->server_thread_index);
44 return s;
45}
46
47vlib_node_registration_t session_queue_node;
48
Florin Coras6792ec02017-03-13 03:49:51 -070049#define foreach_session_queue_error \
50_(TX, "Packets transmitted") \
Florin Coras93992a92017-05-24 18:03:56 -070051_(TIMER, "Timer events") \
52_(NO_BUFFER, "Out of buffers")
Dave Barach68b0fb02017-02-28 15:15:56 -050053
54typedef enum
55{
56#define _(sym,str) SESSION_QUEUE_ERROR_##sym,
57 foreach_session_queue_error
58#undef _
59 SESSION_QUEUE_N_ERROR,
60} session_queue_error_t;
61
62static char *session_queue_error_strings[] = {
63#define _(sym,string) string,
64 foreach_session_queue_error
65#undef _
66};
67
Florin Coras0d60a0f2018-06-29 02:02:08 -070068enum
69{
70 SESSION_TX_NO_BUFFERS = -2,
71 SESSION_TX_NO_DATA,
72 SESSION_TX_OK
73};
74
75
Florin Coras66cf5e02018-06-08 09:17:39 -070076static void
77session_tx_trace_frame (vlib_main_t * vm, vlib_node_runtime_t * node,
78 u32 next_index, u32 * to_next, u16 n_segs,
79 stream_session_t * s, u32 n_trace)
Florin Corasf6d68ed2017-05-07 19:12:02 -070080{
Florin Coras8e43d042018-05-04 15:46:57 -070081 session_queue_trace_t *t;
Florin Coras66cf5e02018-06-08 09:17:39 -070082 vlib_buffer_t *b;
83 int i;
84
85 for (i = 0; i < clib_min (n_trace, n_segs); i++)
86 {
87 b = vlib_get_buffer (vm, to_next[i - n_segs]);
88 vlib_trace_buffer (vm, node, next_index, b, 1 /* follow_chain */ );
Florin Coras66cf5e02018-06-08 09:17:39 -070089 t = vlib_add_trace (vm, node, b, sizeof (*t));
90 t->session_index = s->session_index;
91 t->server_thread_index = s->thread_index;
92 }
Florin Coras4df38712018-06-20 12:44:16 -070093 vlib_set_trace_count (vm, node, n_trace - i);
Florin Coras8e43d042018-05-04 15:46:57 -070094}
Florin Corasf6d68ed2017-05-07 19:12:02 -070095
Florin Coras8e43d042018-05-04 15:46:57 -070096always_inline void
97session_tx_fifo_chain_tail (vlib_main_t * vm, session_tx_context_t * ctx,
98 vlib_buffer_t * b, u16 * n_bufs, u8 peek_data)
99{
100 session_manager_main_t *smm = &session_manager_main;
101 vlib_buffer_t *chain_b, *prev_b;
102 u32 chain_bi0, to_deq, left_from_seg;
103 u16 len_to_deq, n_bytes_read;
104 u8 *data, j;
Florin Corasb2215d62017-08-01 16:56:58 -0700105
Florin Coras8e43d042018-05-04 15:46:57 -0700106 b->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;
107 b->total_length_not_including_first_buffer = 0;
108
109 chain_b = b;
110 left_from_seg = clib_min (ctx->snd_mss - b->current_length,
111 ctx->left_to_snd);
Florin Corasb2215d62017-08-01 16:56:58 -0700112 to_deq = left_from_seg;
Florin Coras8e43d042018-05-04 15:46:57 -0700113 for (j = 1; j < ctx->n_bufs_per_seg; j++)
Florin Corasf6d68ed2017-05-07 19:12:02 -0700114 {
Florin Coras8e43d042018-05-04 15:46:57 -0700115 prev_b = chain_b;
116 len_to_deq = clib_min (to_deq, ctx->deq_per_buf);
Florin Corasf6d68ed2017-05-07 19:12:02 -0700117
118 *n_bufs -= 1;
Florin Coras8e43d042018-05-04 15:46:57 -0700119 chain_bi0 = smm->tx_buffers[ctx->s->thread_index][*n_bufs];
120 _vec_len (smm->tx_buffers[ctx->s->thread_index]) = *n_bufs;
Florin Corasf6d68ed2017-05-07 19:12:02 -0700121
Florin Coras8e43d042018-05-04 15:46:57 -0700122 chain_b = vlib_get_buffer (vm, chain_bi0);
123 chain_b->current_data = 0;
124 data = vlib_buffer_get_current (chain_b);
Florin Corasf6d68ed2017-05-07 19:12:02 -0700125 if (peek_data)
126 {
Florin Coras8e43d042018-05-04 15:46:57 -0700127 n_bytes_read = svm_fifo_peek (ctx->s->server_tx_fifo,
128 ctx->tx_offset, len_to_deq, data);
129 ctx->tx_offset += n_bytes_read;
Florin Corasf6d68ed2017-05-07 19:12:02 -0700130 }
131 else
132 {
Florin Coras8e43d042018-05-04 15:46:57 -0700133 if (ctx->transport_vft->tx_type == TRANSPORT_TX_DGRAM)
Florin Coras7fb0fe12018-04-09 09:24:52 -0700134 {
Florin Coras8e43d042018-05-04 15:46:57 -0700135 svm_fifo_t *f = ctx->s->server_tx_fifo;
136 session_dgram_hdr_t *hdr = &ctx->hdr;
Florin Coras7fb0fe12018-04-09 09:24:52 -0700137 u16 deq_now;
Florin Coras7fb0fe12018-04-09 09:24:52 -0700138 deq_now = clib_min (hdr->data_length - hdr->data_offset,
Florin Coras8e43d042018-05-04 15:46:57 -0700139 len_to_deq);
140 n_bytes_read = svm_fifo_peek (f, hdr->data_offset, deq_now,
141 data);
Florin Coras7fb0fe12018-04-09 09:24:52 -0700142 ASSERT (n_bytes_read > 0);
143
144 hdr->data_offset += n_bytes_read;
145 if (hdr->data_offset == hdr->data_length)
Florin Coras8e43d042018-05-04 15:46:57 -0700146 svm_fifo_dequeue_drop (f, hdr->data_length);
Florin Coras7fb0fe12018-04-09 09:24:52 -0700147 }
148 else
Florin Coras8e43d042018-05-04 15:46:57 -0700149 n_bytes_read = svm_fifo_dequeue_nowait (ctx->s->server_tx_fifo,
150 len_to_deq, data);
Florin Corasf6d68ed2017-05-07 19:12:02 -0700151 }
Florin Coras8e43d042018-05-04 15:46:57 -0700152 ASSERT (n_bytes_read == len_to_deq);
153 chain_b->current_length = n_bytes_read;
154 b->total_length_not_including_first_buffer += chain_b->current_length;
Florin Corasf6d68ed2017-05-07 19:12:02 -0700155
156 /* update previous buffer */
Florin Coras8e43d042018-05-04 15:46:57 -0700157 prev_b->next_buffer = chain_bi0;
158 prev_b->flags |= VLIB_BUFFER_NEXT_PRESENT;
Florin Corasf6d68ed2017-05-07 19:12:02 -0700159
160 /* update current buffer */
Florin Coras8e43d042018-05-04 15:46:57 -0700161 chain_b->next_buffer = 0;
Florin Corasf6d68ed2017-05-07 19:12:02 -0700162
Florin Corasb2215d62017-08-01 16:56:58 -0700163 to_deq -= n_bytes_read;
164 if (to_deq == 0)
Florin Corasf6d68ed2017-05-07 19:12:02 -0700165 break;
166 }
Florin Coras1f152cd2017-08-18 19:28:03 -0700167 ASSERT (to_deq == 0
Florin Coras8e43d042018-05-04 15:46:57 -0700168 && b->total_length_not_including_first_buffer == left_from_seg);
169 ctx->left_to_snd -= left_from_seg;
Florin Corasf6d68ed2017-05-07 19:12:02 -0700170}
171
Dave Barach68b0fb02017-02-28 15:15:56 -0500172always_inline int
Florin Coras8e43d042018-05-04 15:46:57 -0700173session_output_try_get_buffers (vlib_main_t * vm,
Florin Corasd79b41e2017-03-04 05:37:52 -0800174 session_manager_main_t * smm,
Florin Coras8e43d042018-05-04 15:46:57 -0700175 u32 thread_index, u16 * n_bufs, u32 wanted)
Dave Barach68b0fb02017-02-28 15:15:56 -0500176{
Florin Corasf08f26d2018-05-10 13:20:47 -0700177 u32 n_alloc;
178 vec_validate_aligned (smm->tx_buffers[thread_index], wanted - 1,
Florin Coras8e43d042018-05-04 15:46:57 -0700179 CLIB_CACHE_LINE_BYTES);
Florin Corasf08f26d2018-05-10 13:20:47 -0700180 n_alloc = vlib_buffer_alloc (vm, &smm->tx_buffers[thread_index][*n_bufs],
181 wanted - *n_bufs);
182 *n_bufs += n_alloc;
Florin Coras8e43d042018-05-04 15:46:57 -0700183 _vec_len (smm->tx_buffers[thread_index]) = *n_bufs;
Florin Corasf08f26d2018-05-10 13:20:47 -0700184 return n_alloc;
Florin Coras8e43d042018-05-04 15:46:57 -0700185}
186
187always_inline void
188session_tx_fill_buffer (vlib_main_t * vm, session_tx_context_t * ctx,
189 vlib_buffer_t * b, u16 * n_bufs, u8 peek_data)
190{
191 u32 len_to_deq;
192 u8 *data0;
193 int n_bytes_read;
194
195 /*
196 * Start with the first buffer in chain
197 */
198 b->error = 0;
199 b->flags = VNET_BUFFER_F_LOCALLY_ORIGINATED;
200 b->current_data = 0;
Florin Coras8e43d042018-05-04 15:46:57 -0700201
202 data0 = vlib_buffer_make_headroom (b, MAX_HDRS_LEN);
203 len_to_deq = clib_min (ctx->left_to_snd, ctx->deq_per_first_buf);
204
Florin Coras7fb0fe12018-04-09 09:24:52 -0700205 if (peek_data)
206 {
Florin Coras8e43d042018-05-04 15:46:57 -0700207 n_bytes_read = svm_fifo_peek (ctx->s->server_tx_fifo, ctx->tx_offset,
208 len_to_deq, data0);
209 ASSERT (n_bytes_read > 0);
210 /* Keep track of progress locally, transport is also supposed to
211 * increment it independently when pushing the header */
212 ctx->tx_offset += n_bytes_read;
Florin Coras7fb0fe12018-04-09 09:24:52 -0700213 }
214 else
215 {
Florin Coras8e43d042018-05-04 15:46:57 -0700216 if (ctx->transport_vft->tx_type == TRANSPORT_TX_DGRAM)
217 {
218 session_dgram_hdr_t *hdr = &ctx->hdr;
219 svm_fifo_t *f = ctx->s->server_tx_fifo;
220 u16 deq_now;
221 u32 offset;
222
223 ASSERT (hdr->data_length > hdr->data_offset);
224 deq_now = clib_min (hdr->data_length - hdr->data_offset,
225 len_to_deq);
226 offset = hdr->data_offset + SESSION_CONN_HDR_LEN;
227 n_bytes_read = svm_fifo_peek (f, offset, deq_now, data0);
228 ASSERT (n_bytes_read > 0);
229
230 if (ctx->s->session_state == SESSION_STATE_LISTENING)
231 {
232 ip_copy (&ctx->tc->rmt_ip, &hdr->rmt_ip, ctx->tc->is_ip4);
233 ctx->tc->rmt_port = hdr->rmt_port;
234 }
235 hdr->data_offset += n_bytes_read;
236 if (hdr->data_offset == hdr->data_length)
237 {
238 offset = hdr->data_length + SESSION_CONN_HDR_LEN;
239 svm_fifo_dequeue_drop (f, offset);
240 }
241 }
Florin Coras7fb0fe12018-04-09 09:24:52 -0700242 else
243 {
Florin Coras8e43d042018-05-04 15:46:57 -0700244 n_bytes_read = svm_fifo_dequeue_nowait (ctx->s->server_tx_fifo,
245 len_to_deq, data0);
246 ASSERT (n_bytes_read > 0);
Florin Coras7fb0fe12018-04-09 09:24:52 -0700247 }
248 }
Florin Coras8e43d042018-05-04 15:46:57 -0700249 b->current_length = n_bytes_read;
250 ctx->left_to_snd -= n_bytes_read;
Dave Barach68b0fb02017-02-28 15:15:56 -0500251
Florin Coras8e43d042018-05-04 15:46:57 -0700252 /*
253 * Fill in the remaining buffers in the chain, if any
254 */
255 if (PREDICT_FALSE (ctx->n_bufs_per_seg > 1 && ctx->left_to_snd))
256 session_tx_fifo_chain_tail (vm, ctx, b, n_bufs, peek_data);
Dave Barach68b0fb02017-02-28 15:15:56 -0500257
Florin Coras8e43d042018-05-04 15:46:57 -0700258 /* *INDENT-OFF* */
Florin Coras8b20bf52018-06-14 14:55:50 -0700259 SESSION_EVT_DBG(SESSION_EVT_DEQ, ctx->s, ({
260 ed->data[0] = FIFO_EVENT_APP_TX;
261 ed->data[1] = ctx->max_dequeue;
Florin Coras8e43d042018-05-04 15:46:57 -0700262 ed->data[2] = len_to_deq;
Florin Coras8b20bf52018-06-14 14:55:50 -0700263 ed->data[3] = ctx->left_to_snd;
Florin Coras8e43d042018-05-04 15:46:57 -0700264 }));
265 /* *INDENT-ON* */
266}
267
268always_inline u8
269session_tx_not_ready (stream_session_t * s, u8 peek_data)
270{
271 if (peek_data)
Florin Corase04c2992017-03-01 08:17:34 -0800272 {
Florin Coras8e43d042018-05-04 15:46:57 -0700273 /* Can retransmit for closed sessions but can't send new data if
274 * session is not ready or closed */
275 if (s->session_state < SESSION_STATE_READY)
276 return 1;
Florin Corasca1c8f32018-05-23 21:01:30 -0700277 if (s->session_state == SESSION_STATE_CLOSED)
278 return 2;
Florin Corase04c2992017-03-01 08:17:34 -0800279 }
Florin Coras8e43d042018-05-04 15:46:57 -0700280 return 0;
281}
Dave Barach68b0fb02017-02-28 15:15:56 -0500282
Florin Coras8e43d042018-05-04 15:46:57 -0700283always_inline transport_connection_t *
284session_tx_get_transport (session_tx_context_t * ctx, u8 peek_data)
285{
286 if (peek_data)
287 {
288 return ctx->transport_vft->get_connection (ctx->s->connection_index,
289 ctx->s->thread_index);
290 }
291 else
292 {
293 if (ctx->s->session_state == SESSION_STATE_LISTENING)
294 return ctx->transport_vft->get_listener (ctx->s->connection_index);
295 else
296 {
297 return ctx->transport_vft->get_connection (ctx->s->connection_index,
298 ctx->s->thread_index);
299 }
300 }
301}
Florin Coras6a9b68b2017-11-21 04:20:42 -0800302
Florin Coras8e43d042018-05-04 15:46:57 -0700303always_inline void
304session_tx_set_dequeue_params (vlib_main_t * vm, session_tx_context_t * ctx,
Florin Corasf08f26d2018-05-10 13:20:47 -0700305 u32 max_segs, u8 peek_data)
Florin Coras8e43d042018-05-04 15:46:57 -0700306{
307 u32 n_bytes_per_buf, n_bytes_per_seg;
308 ctx->max_dequeue = svm_fifo_max_dequeue (ctx->s->server_tx_fifo);
Dave Barach68b0fb02017-02-28 15:15:56 -0500309 if (peek_data)
310 {
Florin Coras9d063042017-09-14 03:08:00 -0400311 /* Offset in rx fifo from where to peek data */
Florin Coras8e43d042018-05-04 15:46:57 -0700312 ctx->tx_offset = ctx->transport_vft->tx_fifo_offset (ctx->tc);
313 if (PREDICT_FALSE (ctx->tx_offset >= ctx->max_dequeue))
314 {
315 ctx->max_len_to_snd = 0;
316 return;
317 }
318 ctx->max_dequeue -= ctx->tx_offset;
Dave Barach68b0fb02017-02-28 15:15:56 -0500319 }
Florin Coras7fb0fe12018-04-09 09:24:52 -0700320 else
321 {
Florin Coras8e43d042018-05-04 15:46:57 -0700322 if (ctx->transport_vft->tx_type == TRANSPORT_TX_DGRAM)
Florin Coras7fb0fe12018-04-09 09:24:52 -0700323 {
Florin Coras8e43d042018-05-04 15:46:57 -0700324 if (ctx->max_dequeue <= sizeof (ctx->hdr))
325 {
326 ctx->max_len_to_snd = 0;
327 return;
328 }
329 svm_fifo_peek (ctx->s->server_tx_fifo, 0, sizeof (ctx->hdr),
330 (u8 *) & ctx->hdr);
331 ASSERT (ctx->hdr.data_length > ctx->hdr.data_offset);
332 ctx->max_dequeue = ctx->hdr.data_length - ctx->hdr.data_offset;
Florin Coras7fb0fe12018-04-09 09:24:52 -0700333 }
334 }
Florin Coras8e43d042018-05-04 15:46:57 -0700335 ASSERT (ctx->max_dequeue > 0);
Florin Coras6792ec02017-03-13 03:49:51 -0700336
337 /* Ensure we're not writing more than transport window allows */
Florin Coras8e43d042018-05-04 15:46:57 -0700338 if (ctx->max_dequeue < ctx->snd_space)
Florin Coras3e350af2017-03-30 02:54:28 -0700339 {
340 /* Constrained by tx queue. Try to send only fully formed segments */
Florin Coras8e43d042018-05-04 15:46:57 -0700341 ctx->max_len_to_snd =
342 (ctx->max_dequeue > ctx->snd_mss) ?
343 ctx->max_dequeue - ctx->max_dequeue % ctx->snd_mss : ctx->max_dequeue;
Florin Coras3e350af2017-03-30 02:54:28 -0700344 /* TODO Nagle ? */
345 }
346 else
347 {
Florin Coras1f152cd2017-08-18 19:28:03 -0700348 /* Expectation is that snd_space0 is already a multiple of snd_mss */
Florin Coras8e43d042018-05-04 15:46:57 -0700349 ctx->max_len_to_snd = ctx->snd_space;
Florin Coras3e350af2017-03-30 02:54:28 -0700350 }
Dave Barach68b0fb02017-02-28 15:15:56 -0500351
Florin Corasf08f26d2018-05-10 13:20:47 -0700352 /* Check if we're tx constrained by the node */
353 ctx->n_segs_per_evt = ceil ((f64) ctx->max_len_to_snd / ctx->snd_mss);
354 if (ctx->n_segs_per_evt > max_segs)
355 {
356 ctx->n_segs_per_evt = max_segs;
357 ctx->max_len_to_snd = max_segs * ctx->snd_mss;
358 }
359
Florin Coras8e43d042018-05-04 15:46:57 -0700360 n_bytes_per_buf = vlib_buffer_free_list_buffer_size (vm,
361 VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
Florin Corase87216f2017-08-17 16:59:22 -0700362 ASSERT (n_bytes_per_buf > MAX_HDRS_LEN);
Florin Coras8e43d042018-05-04 15:46:57 -0700363 n_bytes_per_seg = MAX_HDRS_LEN + ctx->snd_mss;
Florin Corasf08f26d2018-05-10 13:20:47 -0700364 ctx->n_bufs_per_seg = ceil ((f64) n_bytes_per_seg / n_bytes_per_buf);
Florin Coras8e43d042018-05-04 15:46:57 -0700365 ctx->deq_per_buf = clib_min (ctx->snd_mss, n_bytes_per_buf);
366 ctx->deq_per_first_buf = clib_min (ctx->snd_mss,
367 n_bytes_per_buf - MAX_HDRS_LEN);
368}
Florin Corasf6d68ed2017-05-07 19:12:02 -0700369
Florin Coras8e43d042018-05-04 15:46:57 -0700370always_inline int
371session_tx_fifo_read_and_snd_i (vlib_main_t * vm, vlib_node_runtime_t * node,
372 session_fifo_event_t * e,
373 stream_session_t * s, int *n_tx_packets,
374 u8 peek_data)
375{
Florin Coras66cf5e02018-06-08 09:17:39 -0700376 u32 next_index, next0, next1, *to_next, n_left_to_next;
Florin Corasf08f26d2018-05-10 13:20:47 -0700377 u32 n_trace = vlib_get_trace_count (vm, node), n_bufs_needed = 0;
378 u32 thread_index = s->thread_index, n_left, pbi;
Florin Coras8e43d042018-05-04 15:46:57 -0700379 session_manager_main_t *smm = &session_manager_main;
380 session_tx_context_t *ctx = &smm->ctx[thread_index];
381 transport_proto_t tp;
382 vlib_buffer_t *pb;
Florin Corasca1c8f32018-05-23 21:01:30 -0700383 u16 n_bufs, rv;
Florin Coras8e43d042018-05-04 15:46:57 -0700384
Florin Corasca1c8f32018-05-23 21:01:30 -0700385 if (PREDICT_FALSE ((rv = session_tx_not_ready (s, peek_data))))
Florin Coras8e43d042018-05-04 15:46:57 -0700386 {
Florin Corasca1c8f32018-05-23 21:01:30 -0700387 if (rv < 2)
388 vec_add1 (smm->pending_event_vector[thread_index], *e);
Florin Coras0d60a0f2018-06-29 02:02:08 -0700389 return SESSION_TX_NO_DATA;
Florin Coras8e43d042018-05-04 15:46:57 -0700390 }
391
392 next_index = smm->session_type_to_next[s->session_type];
Florin Coras66cf5e02018-06-08 09:17:39 -0700393 next0 = next1 = next_index;
Florin Coras8e43d042018-05-04 15:46:57 -0700394
395 tp = session_get_transport_proto (s);
396 ctx->s = s;
397 ctx->transport_vft = transport_protocol_get_vft (tp);
398 ctx->tc = session_tx_get_transport (ctx, peek_data);
399 ctx->snd_mss = ctx->transport_vft->send_mss (ctx->tc);
400 ctx->snd_space = ctx->transport_vft->send_space (ctx->tc);
401 if (ctx->snd_space == 0 || ctx->snd_mss == 0)
402 {
403 vec_add1 (smm->pending_event_vector[thread_index], *e);
Florin Coras0d60a0f2018-06-29 02:02:08 -0700404 return SESSION_TX_NO_DATA;
Florin Coras8e43d042018-05-04 15:46:57 -0700405 }
406
407 /* Allow enqueuing of a new event */
408 svm_fifo_unset_event (s->server_tx_fifo);
409
410 /* Check how much we can pull. */
Florin Corasf08f26d2018-05-10 13:20:47 -0700411 session_tx_set_dequeue_params (vm, ctx, VLIB_FRAME_SIZE - *n_tx_packets,
412 peek_data);
413
Florin Coras8e43d042018-05-04 15:46:57 -0700414 if (PREDICT_FALSE (!ctx->max_len_to_snd))
Florin Coras0d60a0f2018-06-29 02:02:08 -0700415 return SESSION_TX_NO_DATA;
Dave Barach68b0fb02017-02-28 15:15:56 -0500416
417 n_bufs = vec_len (smm->tx_buffers[thread_index]);
Florin Corasf08f26d2018-05-10 13:20:47 -0700418 n_bufs_needed = ctx->n_segs_per_evt * ctx->n_bufs_per_seg;
Florin Coras8e43d042018-05-04 15:46:57 -0700419
420 /*
421 * Make sure we have at least one full frame of buffers ready
422 */
Florin Corasf08f26d2018-05-10 13:20:47 -0700423 if (n_bufs < n_bufs_needed)
Dave Barach68b0fb02017-02-28 15:15:56 -0500424 {
Florin Coras8e43d042018-05-04 15:46:57 -0700425 session_output_try_get_buffers (vm, smm, thread_index, &n_bufs,
Florin Corasf08f26d2018-05-10 13:20:47 -0700426 ctx->n_bufs_per_seg * VLIB_FRAME_SIZE);
427 if (PREDICT_FALSE (n_bufs < n_bufs_needed))
Dave Barach68b0fb02017-02-28 15:15:56 -0500428 {
Florin Coras8e43d042018-05-04 15:46:57 -0700429 vec_add1 (smm->pending_event_vector[thread_index], *e);
Florin Coras0d60a0f2018-06-29 02:02:08 -0700430 return SESSION_TX_NO_BUFFERS;
Dave Barach68b0fb02017-02-28 15:15:56 -0500431 }
Florin Coras8e43d042018-05-04 15:46:57 -0700432 }
Dave Barach68b0fb02017-02-28 15:15:56 -0500433
Florin Coras8e43d042018-05-04 15:46:57 -0700434 /*
435 * Write until we fill up a frame
436 */
437 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
Florin Corasf08f26d2018-05-10 13:20:47 -0700438 if (PREDICT_FALSE (ctx->n_segs_per_evt > n_left_to_next))
Florin Coras8e43d042018-05-04 15:46:57 -0700439 {
Florin Corasf08f26d2018-05-10 13:20:47 -0700440 ctx->n_segs_per_evt = n_left_to_next;
441 ctx->max_len_to_snd = ctx->snd_mss * n_left_to_next;
442 }
443 ctx->left_to_snd = ctx->max_len_to_snd;
444 n_left = ctx->n_segs_per_evt;
Florin Coras66cf5e02018-06-08 09:17:39 -0700445
446 while (n_left >= 4)
447 {
448 vlib_buffer_t *b0, *b1;
449 u32 bi0, bi1;
450
451 pbi = smm->tx_buffers[thread_index][n_bufs - 3];
452 pb = vlib_get_buffer (vm, pbi);
453 vlib_prefetch_buffer_header (pb, STORE);
454 pbi = smm->tx_buffers[thread_index][n_bufs - 4];
455 pb = vlib_get_buffer (vm, pbi);
456 vlib_prefetch_buffer_header (pb, STORE);
457
458 to_next[0] = bi0 = smm->tx_buffers[thread_index][--n_bufs];
459 to_next[1] = bi1 = smm->tx_buffers[thread_index][--n_bufs];
460
461 b0 = vlib_get_buffer (vm, bi0);
462 b1 = vlib_get_buffer (vm, bi1);
463
464 session_tx_fill_buffer (vm, ctx, b0, &n_bufs, peek_data);
465 session_tx_fill_buffer (vm, ctx, b1, &n_bufs, peek_data);
466
467 ctx->transport_vft->push_header (ctx->tc, b0);
468 ctx->transport_vft->push_header (ctx->tc, b1);
469
470 to_next += 2;
471 n_left_to_next -= 2;
472 n_left -= 2;
473
474 VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b0);
475 VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b1);
476
477 vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next,
478 n_left_to_next, bi0, bi1, next0,
479 next1);
480 }
Florin Corasf08f26d2018-05-10 13:20:47 -0700481 while (n_left)
482 {
Florin Coras66cf5e02018-06-08 09:17:39 -0700483 vlib_buffer_t *b0;
484 u32 bi0;
Florin Corasf6d68ed2017-05-07 19:12:02 -0700485
Florin Coras91ca4622018-06-30 11:27:59 -0700486 if (n_left > 1)
487 {
488 pbi = smm->tx_buffers[thread_index][n_bufs - 2];
489 pb = vlib_get_buffer (vm, pbi);
490 vlib_prefetch_buffer_header (pb, STORE);
491 }
492
Florin Coras66cf5e02018-06-08 09:17:39 -0700493 to_next[0] = bi0 = smm->tx_buffers[thread_index][--n_bufs];
494 b0 = vlib_get_buffer (vm, bi0);
495 session_tx_fill_buffer (vm, ctx, b0, &n_bufs, peek_data);
Florin Coras81a13db2018-03-16 08:48:31 -0700496
Florin Coras66cf5e02018-06-08 09:17:39 -0700497 /* Ask transport to push header after current_length and
498 * total_length_not_including_first_buffer are updated */
499 ctx->transport_vft->push_header (ctx->tc, b0);
Florin Corasf6359c82017-06-19 12:26:09 -0400500
Florin Coras66cf5e02018-06-08 09:17:39 -0700501 to_next += 1;
502 n_left_to_next -= 1;
503 n_left -= 1;
Dave Barach68b0fb02017-02-28 15:15:56 -0500504
Florin Coras66cf5e02018-06-08 09:17:39 -0700505 VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b0);
Florin Coras7fb0fe12018-04-09 09:24:52 -0700506
Florin Coras66cf5e02018-06-08 09:17:39 -0700507 vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
508 n_left_to_next, bi0, next0);
Dave Barach68b0fb02017-02-28 15:15:56 -0500509 }
Florin Coras66cf5e02018-06-08 09:17:39 -0700510
511 if (PREDICT_FALSE (n_trace > 0))
512 session_tx_trace_frame (vm, node, next_index, to_next,
513 ctx->n_segs_per_evt, s, n_trace);
514
Florin Coras8e43d042018-05-04 15:46:57 -0700515 _vec_len (smm->tx_buffers[thread_index]) = n_bufs;
Florin Corasf08f26d2018-05-10 13:20:47 -0700516 *n_tx_packets += ctx->n_segs_per_evt;
Florin Coras8e43d042018-05-04 15:46:57 -0700517 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
Dave Barach68b0fb02017-02-28 15:15:56 -0500518
Florin Coras6792ec02017-03-13 03:49:51 -0700519 /* If we couldn't dequeue all bytes mark as partially read */
Florin Corasf08f26d2018-05-10 13:20:47 -0700520 ASSERT (ctx->left_to_snd == 0);
Florin Coras8e43d042018-05-04 15:46:57 -0700521 if (ctx->max_len_to_snd < ctx->max_dequeue)
522 if (svm_fifo_set_event (s->server_tx_fifo))
523 vec_add1 (smm->pending_event_vector[thread_index], *e);
Florin Coras7fb0fe12018-04-09 09:24:52 -0700524
Florin Coras8e43d042018-05-04 15:46:57 -0700525 if (!peek_data && ctx->transport_vft->tx_type == TRANSPORT_TX_DGRAM)
Dave Barach68b0fb02017-02-28 15:15:56 -0500526 {
Florin Coras7fb0fe12018-04-09 09:24:52 -0700527 /* Fix dgram pre header */
Florin Coras8e43d042018-05-04 15:46:57 -0700528 if (ctx->max_len_to_snd < ctx->max_dequeue)
529 svm_fifo_overwrite_head (s->server_tx_fifo, (u8 *) & ctx->hdr,
Florin Coras7fb0fe12018-04-09 09:24:52 -0700530 sizeof (session_dgram_pre_hdr_t));
531 /* More data needs to be read */
Florin Coras8e43d042018-05-04 15:46:57 -0700532 else if (svm_fifo_max_dequeue (s->server_tx_fifo) > 0)
533 if (svm_fifo_set_event (s->server_tx_fifo))
534 vec_add1 (smm->pending_event_vector[thread_index], *e);
Dave Barach68b0fb02017-02-28 15:15:56 -0500535 }
Florin Coras0d60a0f2018-06-29 02:02:08 -0700536 return SESSION_TX_OK;
Dave Barach68b0fb02017-02-28 15:15:56 -0500537}
538
539int
Florin Corasd79b41e2017-03-04 05:37:52 -0800540session_tx_fifo_peek_and_snd (vlib_main_t * vm, vlib_node_runtime_t * node,
Florin Coras0d60a0f2018-06-29 02:02:08 -0700541 session_fifo_event_t * e,
542 stream_session_t * s, int *n_tx_pkts)
Dave Barach68b0fb02017-02-28 15:15:56 -0500543{
Florin Coras0d60a0f2018-06-29 02:02:08 -0700544 return session_tx_fifo_read_and_snd_i (vm, node, e, s, n_tx_pkts, 1);
Dave Barach68b0fb02017-02-28 15:15:56 -0500545}
546
547int
Florin Corasd79b41e2017-03-04 05:37:52 -0800548session_tx_fifo_dequeue_and_snd (vlib_main_t * vm, vlib_node_runtime_t * node,
Florin Coras0d60a0f2018-06-29 02:02:08 -0700549 session_fifo_event_t * e,
550 stream_session_t * s, int *n_tx_pkts)
Dave Barach68b0fb02017-02-28 15:15:56 -0500551{
Florin Coras0d60a0f2018-06-29 02:02:08 -0700552 return session_tx_fifo_read_and_snd_i (vm, node, e, s, n_tx_pkts, 0);
Dave Barach68b0fb02017-02-28 15:15:56 -0500553}
554
Florin Coras371ca502018-02-21 12:07:41 -0800555int
556session_tx_fifo_dequeue_internal (vlib_main_t * vm,
557 vlib_node_runtime_t * node,
Florin Coras0d60a0f2018-06-29 02:02:08 -0700558 session_fifo_event_t * e,
559 stream_session_t * s, int *n_tx_pkts)
Florin Coras371ca502018-02-21 12:07:41 -0800560{
561 application_t *app;
Florin Coras0d60a0f2018-06-29 02:02:08 -0700562 app = application_get (s->opaque);
563 svm_fifo_unset_event (s->server_tx_fifo);
564 return app->cb_fns.builtin_app_tx_callback (s);
Florin Coras371ca502018-02-21 12:07:41 -0800565}
566
Dave Barach2c25a622017-06-26 11:35:07 -0400567always_inline stream_session_t *
568session_event_get_session (session_fifo_event_t * e, u8 thread_index)
Florin Corasa5464812017-04-19 13:00:05 -0700569{
Florin Coras3cbc04b2017-10-02 00:18:51 -0700570 return session_get_if_valid (e->fifo->master_session_index, thread_index);
Florin Corasa5464812017-04-19 13:00:05 -0700571}
572
Florin Coras0d60a0f2018-06-29 02:02:08 -0700573static uword
574session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
575 vlib_frame_t * frame)
576{
577 session_manager_main_t *smm = vnet_get_session_manager_main ();
578 session_fifo_event_t *pending_events, *e;
579 session_fifo_event_t *fifo_events;
580 u32 n_to_dequeue, n_events;
581 svm_queue_t *q;
582 application_t *app;
583 int n_tx_packets = 0;
584 u32 thread_index = vm->thread_index;
585 int i, rv;
586 f64 now = vlib_time_now (vm);
587 void (*fp) (void *);
588
589 SESSION_EVT_DBG (SESSION_EVT_POLL_GAP_TRACK, smm, thread_index);
590
591 /*
592 * Update transport time
593 */
594 transport_update_time (now, thread_index);
595
596 /*
597 * Get vpp queue events
598 */
599 q = smm->vpp_event_queues[thread_index];
600 if (PREDICT_FALSE (q == 0))
601 return 0;
602
603 fifo_events = smm->free_event_vector[thread_index];
604
605 /* min number of events we can dequeue without blocking */
606 n_to_dequeue = q->cursize;
607 pending_events = smm->pending_event_vector[thread_index];
608
609 if (!n_to_dequeue && !vec_len (pending_events)
610 && !vec_len (smm->pending_disconnects[thread_index]))
611 return 0;
612
613 SESSION_EVT_DBG (SESSION_EVT_DEQ_NODE, 0);
614
615 /*
616 * If we didn't manage to process previous events try going
617 * over them again without dequeuing new ones.
618 * XXX: Handle senders to sessions that can't keep up
619 */
620 if (0 && vec_len (pending_events) >= 100)
621 {
622 clib_warning ("too many fifo events unsolved");
623 goto skip_dequeue;
624 }
625
626 /* See you in the next life, don't be late
627 * XXX: we may need priorities here
628 */
629 if (pthread_mutex_trylock (&q->mutex))
630 return 0;
631
632 for (i = 0; i < n_to_dequeue; i++)
633 {
634 vec_add2 (fifo_events, e, 1);
635 svm_queue_sub_raw (q, (u8 *) e);
636 }
637
638 /* The other side of the connection is not polling */
639 if (q->cursize < (q->maxsize / 8))
640 (void) pthread_cond_broadcast (&q->condvar);
641 pthread_mutex_unlock (&q->mutex);
642
643 vec_append (fifo_events, pending_events);
644 vec_append (fifo_events, smm->pending_disconnects[thread_index]);
645
646 _vec_len (pending_events) = 0;
647 smm->pending_event_vector[thread_index] = pending_events;
648 _vec_len (smm->pending_disconnects[thread_index]) = 0;
649
650skip_dequeue:
651 n_events = vec_len (fifo_events);
652 for (i = 0; i < n_events; i++)
653 {
654 stream_session_t *s; /* $$$ prefetch 1 ahead maybe */
655 session_fifo_event_t *e;
Florin Coras46f001d2018-07-11 05:25:06 -0700656 u32 to_dequeue;
Florin Coras0d60a0f2018-06-29 02:02:08 -0700657
658 e = &fifo_events[i];
659 switch (e->event_type)
660 {
661 case FIFO_EVENT_APP_TX:
662 /* Don't try to send more that one frame per dispatch cycle */
663 if (n_tx_packets == VLIB_FRAME_SIZE)
664 {
665 vec_add1 (smm->pending_event_vector[thread_index], *e);
666 break;
667 }
668
669 s = session_event_get_session (e, thread_index);
670 if (PREDICT_FALSE (!s))
671 {
672 clib_warning ("It's dead, Jim!");
673 continue;
674 }
Florin Coras46f001d2018-07-11 05:25:06 -0700675 to_dequeue = svm_fifo_max_dequeue (s->server_tx_fifo);
Florin Coras0d60a0f2018-06-29 02:02:08 -0700676
677 /* Spray packets in per session type frames, since they go to
678 * different nodes */
679 rv = (smm->session_tx_fns[s->session_type]) (vm, node, e, s,
680 &n_tx_packets);
681 if (PREDICT_TRUE (rv == SESSION_TX_OK))
682 {
Florin Coras46f001d2018-07-11 05:25:06 -0700683 /* Notify app there's tx space if not polling */
684 if (PREDICT_FALSE (to_dequeue == s->server_tx_fifo->nitems
685 && !svm_fifo_has_event (s->server_tx_fifo)))
686 session_dequeue_notify (s);
Florin Coras0d60a0f2018-06-29 02:02:08 -0700687 }
688 else if (PREDICT_FALSE (rv == SESSION_TX_NO_BUFFERS))
689 {
690 vlib_node_increment_counter (vm, node->node_index,
691 SESSION_QUEUE_ERROR_NO_BUFFER, 1);
692 continue;
693 }
694 break;
695 case FIFO_EVENT_DISCONNECT:
696 /* Make sure stream disconnects run after the pending list is
697 * drained */
698 s = session_get_from_handle (e->session_handle);
699 if (!e->postponed)
700 {
701 e->postponed = 1;
702 vec_add1 (smm->pending_disconnects[thread_index], *e);
703 continue;
704 }
705 /* If tx queue is still not empty, wait */
706 if (svm_fifo_max_dequeue (s->server_tx_fifo))
707 {
708 vec_add1 (smm->pending_disconnects[thread_index], *e);
709 continue;
710 }
711
712 stream_session_disconnect_transport (s);
713 break;
714 case FIFO_EVENT_BUILTIN_RX:
715 s = session_event_get_session (e, thread_index);
716 if (PREDICT_FALSE (!s))
717 continue;
718 svm_fifo_unset_event (s->server_rx_fifo);
719 app = application_get (s->app_index);
720 app->cb_fns.builtin_app_rx_callback (s);
721 break;
722 case FIFO_EVENT_RPC:
723 fp = e->rpc_args.fp;
724 (*fp) (e->rpc_args.arg);
725 break;
726
727 default:
728 clib_warning ("unhandled event type %d", e->event_type);
729 }
730 }
731
732 _vec_len (fifo_events) = 0;
733 smm->free_event_vector[thread_index] = fifo_events;
734
735 vlib_node_increment_counter (vm, session_queue_node.index,
736 SESSION_QUEUE_ERROR_TX, n_tx_packets);
737
738 SESSION_EVT_DBG (SESSION_EVT_DISPATCH_END, smm, thread_index);
739
740 return n_tx_packets;
741}
742
743/* *INDENT-OFF* */
744VLIB_REGISTER_NODE (session_queue_node) =
745{
746 .function = session_queue_node_fn,
747 .name = "session-queue",
748 .format_trace = format_session_queue_trace,
749 .type = VLIB_NODE_TYPE_INPUT,
750 .n_errors = ARRAY_LEN (session_queue_error_strings),
751 .error_strings = session_queue_error_strings,
752 .state = VLIB_NODE_STATE_DISABLED,
753};
754/* *INDENT-ON* */
755
Dave Barachacd2a6a2017-05-16 17:41:34 -0400756void
757dump_thread_0_event_queue (void)
758{
759 session_manager_main_t *smm = vnet_get_session_manager_main ();
760 vlib_main_t *vm = &vlib_global_main;
761 u32 my_thread_index = vm->thread_index;
762 session_fifo_event_t _e, *e = &_e;
763 stream_session_t *s0;
764 int i, index;
765 i8 *headp;
766
Florin Corase86a8ed2018-01-05 03:20:25 -0800767 svm_queue_t *q;
Dave Barachacd2a6a2017-05-16 17:41:34 -0400768 q = smm->vpp_event_queues[my_thread_index];
769
770 index = q->head;
771
772 for (i = 0; i < q->cursize; i++)
773 {
774 headp = (i8 *) (&q->data[0] + q->elsize * index);
775 clib_memcpy (e, headp, q->elsize);
776
777 switch (e->event_type)
778 {
779 case FIFO_EVENT_APP_TX:
780 s0 = session_event_get_session (e, my_thread_index);
781 fformat (stdout, "[%04d] TX session %d\n", i, s0->session_index);
782 break;
783
784 case FIFO_EVENT_DISCONNECT:
Florin Corascea194d2017-10-02 00:18:51 -0700785 s0 = session_get_from_handle (e->session_handle);
Dave Barachacd2a6a2017-05-16 17:41:34 -0400786 fformat (stdout, "[%04d] disconnect session %d\n", i,
787 s0->session_index);
788 break;
789
790 case FIFO_EVENT_BUILTIN_RX:
791 s0 = session_event_get_session (e, my_thread_index);
792 fformat (stdout, "[%04d] builtin_rx %d\n", i, s0->session_index);
793 break;
794
795 case FIFO_EVENT_RPC:
796 fformat (stdout, "[%04d] RPC call %llx with %llx\n",
797 i, (u64) (e->rpc_args.fp), (u64) (e->rpc_args.arg));
798 break;
799
800 default:
801 fformat (stdout, "[%04d] unhandled event type %d\n",
802 i, e->event_type);
803 break;
804 }
805
806 index++;
807
808 if (index == q->maxsize)
809 index = 0;
810 }
811}
812
Florin Coras6534b7a2017-07-18 05:38:03 -0400813static u8
814session_node_cmp_event (session_fifo_event_t * e, svm_fifo_t * f)
815{
816 stream_session_t *s;
817 switch (e->event_type)
818 {
819 case FIFO_EVENT_APP_RX:
820 case FIFO_EVENT_APP_TX:
821 case FIFO_EVENT_BUILTIN_RX:
822 if (e->fifo == f)
823 return 1;
824 break;
825 case FIFO_EVENT_DISCONNECT:
826 break;
827 case FIFO_EVENT_RPC:
Florin Corascea194d2017-10-02 00:18:51 -0700828 s = session_get_from_handle (e->session_handle);
Florin Coras6534b7a2017-07-18 05:38:03 -0400829 if (!s)
830 {
831 clib_warning ("session has event but doesn't exist!");
832 break;
833 }
834 if (s->server_rx_fifo == f || s->server_tx_fifo == f)
835 return 1;
836 break;
837 default:
838 break;
839 }
840 return 0;
841}
842
843u8
844session_node_lookup_fifo_event (svm_fifo_t * f, session_fifo_event_t * e)
845{
846 session_manager_main_t *smm = vnet_get_session_manager_main ();
Florin Corase86a8ed2018-01-05 03:20:25 -0800847 svm_queue_t *q;
Florin Coras6534b7a2017-07-18 05:38:03 -0400848 session_fifo_event_t *pending_event_vector, *evt;
849 int i, index, found = 0;
850 i8 *headp;
851 u8 thread_index;
852
853 ASSERT (e);
854 thread_index = f->master_thread_index;
855 /*
856 * Search evt queue
857 */
858 q = smm->vpp_event_queues[thread_index];
859 index = q->head;
860 for (i = 0; i < q->cursize; i++)
861 {
862 headp = (i8 *) (&q->data[0] + q->elsize * index);
863 clib_memcpy (e, headp, q->elsize);
864 found = session_node_cmp_event (e, f);
865 if (found)
Florin Coras371ca502018-02-21 12:07:41 -0800866 return 1;
Florin Coras6534b7a2017-07-18 05:38:03 -0400867 if (++index == q->maxsize)
868 index = 0;
869 }
870 /*
871 * Search pending events vector
872 */
873 pending_event_vector = smm->pending_event_vector[thread_index];
874 vec_foreach (evt, pending_event_vector)
875 {
876 found = session_node_cmp_event (evt, f);
877 if (found)
878 {
879 clib_memcpy (e, evt, sizeof (*evt));
880 break;
881 }
882 }
883 return found;
884}
885
Dave Barach2a863912017-11-28 10:11:42 -0500886static clib_error_t *
887session_queue_exit (vlib_main_t * vm)
888{
889 if (vec_len (vlib_mains) < 2)
890 return 0;
891
892 /*
893 * Shut off (especially) worker-thread session nodes.
894 * Otherwise, vpp can crash as the main thread unmaps the
895 * API segment.
896 */
897 vlib_worker_thread_barrier_sync (vm);
898 session_node_enable_disable (0 /* is_enable */ );
899 vlib_worker_thread_barrier_release (vm);
900 return 0;
901}
902
903VLIB_MAIN_LOOP_EXIT_FUNCTION (session_queue_exit);
904
Florin Corasfd542f12018-05-16 19:28:24 -0700905static uword
906session_queue_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
907 vlib_frame_t * f)
908{
909 f64 now, timeout = 1.0;
910 uword *event_data = 0;
911 uword event_type;
912
913 while (1)
914 {
915 vlib_process_wait_for_event_or_clock (vm, timeout);
916 now = vlib_time_now (vm);
917 event_type = vlib_process_get_events (vm, (uword **) & event_data);
918
919 switch (event_type)
920 {
921 case SESSION_Q_PROCESS_FLUSH_FRAMES:
922 /* Flush the frames by updating all transports times */
923 transport_update_time (now, 0);
924 break;
925 case SESSION_Q_PROCESS_STOP:
926 timeout = 100000.0;
927 break;
928 case ~0:
929 /* Timed out. Update time for all transports to trigger all
930 * outstanding retransmits. */
931 transport_update_time (now, 0);
932 break;
933 }
934 vec_reset_length (event_data);
935 }
936 return 0;
937}
938
939/* *INDENT-OFF* */
940VLIB_REGISTER_NODE (session_queue_process_node) =
941{
942 .function = session_queue_process,
943 .type = VLIB_NODE_TYPE_PROCESS,
944 .name = "session-queue-process",
945 .state = VLIB_NODE_STATE_DISABLED,
946};
947/* *INDENT-ON* */
948
949
Dave Barach68b0fb02017-02-28 15:15:56 -0500950/*
951 * fd.io coding-style-patch-verification: ON
952 *
953 * Local Variables:
954 * eval: (c-set-style "gnu")
955 * End:
956 */