FD.io VPP  v17.10-9-gd594711
Vector Packet Processing
session_node.c
Go to the documentation of this file.
1 /*
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 
16 #include <math.h>
17 #include <vlib/vlib.h>
18 #include <vnet/vnet.h>
19 #include <vnet/tcp/tcp.h>
20 #include <vppinfra/elog.h>
24 
26 
27 typedef struct
28 {
32 
33 /* packet trace format function */
34 static u8 *
35 format_session_queue_trace (u8 * s, va_list * args)
36 {
37  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
38  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
39  session_queue_trace_t *t = va_arg (*args, session_queue_trace_t *);
40 
41  s = format (s, "SESSION_QUEUE: session index %d, server thread index %d",
43  return s;
44 }
45 
47 
48 #define foreach_session_queue_error \
49 _(TX, "Packets transmitted") \
50 _(TIMER, "Timer events") \
51 _(NO_BUFFER, "Out of buffers")
52 
53 typedef enum
54 {
55 #define _(sym,str) SESSION_QUEUE_ERROR_##sym,
57 #undef _
60 
61 static char *session_queue_error_strings[] = {
62 #define _(sym,string) string,
64 #undef _
65 };
66 
72 };
73 
74 always_inline void
76  u8 thread_index, svm_fifo_t * fifo,
77  vlib_buffer_t * b0, u32 bi0, u8 n_bufs_per_seg,
78  u32 left_from_seg, u32 * left_to_snd0,
79  u16 * n_bufs, u32 * tx_offset, u16 deq_per_buf,
80  u8 peek_data)
81 {
82  vlib_buffer_t *chain_b0, *prev_b0;
83  u32 chain_bi0, to_deq;
84  u16 len_to_deq0, n_bytes_read;
85  u8 *data0, j;
86 
89 
90  chain_bi0 = bi0;
91  chain_b0 = b0;
92  to_deq = left_from_seg;
93  for (j = 1; j < n_bufs_per_seg; j++)
94  {
95  prev_b0 = chain_b0;
96  len_to_deq0 = clib_min (to_deq, deq_per_buf);
97 
98  *n_bufs -= 1;
99  chain_bi0 = smm->tx_buffers[thread_index][*n_bufs];
100  _vec_len (smm->tx_buffers[thread_index]) = *n_bufs;
101 
102  chain_b0 = vlib_get_buffer (vm, chain_bi0);
103  chain_b0->current_data = 0;
104  data0 = vlib_buffer_get_current (chain_b0);
105  if (peek_data)
106  {
107  n_bytes_read = svm_fifo_peek (fifo, *tx_offset, len_to_deq0, data0);
108  *tx_offset += n_bytes_read;
109  }
110  else
111  {
112  n_bytes_read = svm_fifo_dequeue_nowait (fifo, len_to_deq0, data0);
113  }
114  ASSERT (n_bytes_read == len_to_deq0);
115  chain_b0->current_length = n_bytes_read;
117 
118  /* update previous buffer */
119  prev_b0->next_buffer = chain_bi0;
120  prev_b0->flags |= VLIB_BUFFER_NEXT_PRESENT;
121 
122  /* update current buffer */
123  chain_b0->next_buffer = 0;
124 
125  to_deq -= n_bytes_read;
126  if (to_deq == 0)
127  break;
128  }
129  ASSERT (to_deq == 0
130  && b0->total_length_not_including_first_buffer == left_from_seg);
131  *left_to_snd0 -= left_from_seg;
132 }
133 
134 always_inline int
137  session_fifo_event_t * e0,
138  stream_session_t * s0, u32 thread_index,
139  int *n_tx_packets, u8 peek_data)
140 {
141  u32 n_trace = vlib_get_trace_count (vm, node);
142  u32 left_to_snd0, max_len_to_snd0, len_to_deq0, snd_space0;
143  u32 n_bufs_per_evt, n_frames_per_evt, n_bufs_per_frame;
145  transport_proto_vft_t *transport_vft;
146  u32 next_index, next0, *to_next, n_left_to_next, bi0;
147  vlib_buffer_t *b0;
148  u32 tx_offset = 0, max_dequeue0, n_bytes_per_seg, left_for_seg;
149  u16 snd_mss0, n_bufs_per_seg, n_bufs;
150  u8 *data0;
151  int i, n_bytes_read;
152  u32 n_bytes_per_buf, deq_per_buf, deq_per_first_buf;
153  u32 buffers_allocated, buffers_allocated_this_call;
154 
155  next_index = next0 = session_type_to_next[s0->session_type];
156 
157  transport_vft = session_get_transport_vft (s0->session_type);
158  tc0 = transport_vft->get_connection (s0->connection_index, thread_index);
159 
160  /* Make sure we have space to send and there's something to dequeue */
161  snd_mss0 = transport_vft->send_mss (tc0);
162  snd_space0 = transport_vft->send_space (tc0);
163 
164  /* Can't make any progress */
165  if (snd_space0 == 0 || snd_mss0 == 0)
166  {
167  vec_add1 (smm->pending_event_vector[thread_index], *e0);
168  return 0;
169  }
170 
171  /* Check how much we can pull. */
172  max_dequeue0 = svm_fifo_max_dequeue (s0->server_tx_fifo);
173 
174  if (peek_data)
175  {
176  /* Offset in rx fifo from where to peek data */
177  tx_offset = transport_vft->tx_fifo_offset (tc0);
178  if (PREDICT_FALSE (tx_offset >= max_dequeue0))
179  max_dequeue0 = 0;
180  else
181  max_dequeue0 -= tx_offset;
182  }
183 
184  /* Nothing to read return */
185  if (max_dequeue0 == 0)
186  {
187  svm_fifo_unset_event (s0->server_tx_fifo);
188  return 0;
189  }
190 
191  /* Ensure we're not writing more than transport window allows */
192  if (max_dequeue0 < snd_space0)
193  {
194  /* Constrained by tx queue. Try to send only fully formed segments */
195  max_len_to_snd0 = (max_dequeue0 > snd_mss0) ?
196  max_dequeue0 - max_dequeue0 % snd_mss0 : max_dequeue0;
197  /* TODO Nagle ? */
198  }
199  else
200  {
201  /* Expectation is that snd_space0 is already a multiple of snd_mss */
202  max_len_to_snd0 = snd_space0;
203  }
204 
205  n_bytes_per_buf = vlib_buffer_free_list_buffer_size
207  ASSERT (n_bytes_per_buf > MAX_HDRS_LEN);
208  n_bytes_per_seg = MAX_HDRS_LEN + snd_mss0;
209  n_bufs_per_seg = ceil ((double) n_bytes_per_seg / n_bytes_per_buf);
210  n_bufs_per_evt = ceil ((double) max_len_to_snd0 / n_bytes_per_seg);
211  n_frames_per_evt = ceil ((double) n_bufs_per_evt / VLIB_FRAME_SIZE);
212  n_bufs_per_frame = n_bufs_per_seg * VLIB_FRAME_SIZE;
213 
214  deq_per_buf = clib_min (snd_mss0, n_bytes_per_buf);
215  deq_per_first_buf = clib_min (snd_mss0, n_bytes_per_buf - MAX_HDRS_LEN);
216 
217  n_bufs = vec_len (smm->tx_buffers[thread_index]);
218  left_to_snd0 = max_len_to_snd0;
219  for (i = 0; i < n_frames_per_evt; i++)
220  {
221  /* Make sure we have at least one full frame of buffers ready */
222  if (PREDICT_FALSE (n_bufs < n_bufs_per_frame))
223  {
224  vec_validate (smm->tx_buffers[thread_index],
225  n_bufs + n_bufs_per_frame - 1);
226  buffers_allocated = 0;
227  do
228  {
229  buffers_allocated_this_call = vlib_buffer_alloc (vm,
230  &smm->tx_buffers
231  [thread_index]
232  [n_bufs +
233  buffers_allocated],
234  n_bufs_per_frame
235  -
236  buffers_allocated);
237  buffers_allocated += buffers_allocated_this_call;
238  }
239  while (buffers_allocated_this_call > 0
240  && ((buffers_allocated + n_bufs < n_bufs_per_frame)));
241 
242  n_bufs += buffers_allocated;
243  _vec_len (smm->tx_buffers[thread_index]) = n_bufs;
244 
245  if (PREDICT_FALSE (n_bufs < n_bufs_per_frame))
246  {
247  vec_add1 (smm->pending_event_vector[thread_index], *e0);
248  return -1;
249  }
250  ASSERT (n_bufs >= n_bufs_per_frame);
251  }
252  /* Allow enqueuing of a new event */
253  svm_fifo_unset_event (s0->server_tx_fifo);
254 
255  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
256  while (left_to_snd0 && n_left_to_next)
257  {
258  /*
259  * Handle first buffer in chain separately
260  */
261 
262  /* Get free buffer */
263  ASSERT (n_bufs >= 1);
264  bi0 = smm->tx_buffers[thread_index][--n_bufs];
265  _vec_len (smm->tx_buffers[thread_index]) = n_bufs;
266 
267  /* usual speculation, or the enqueue_x1 macro will barf */
268  to_next[0] = bi0;
269  to_next += 1;
270  n_left_to_next -= 1;
271 
272  b0 = vlib_get_buffer (vm, bi0);
273  b0->error = 0;
274  b0->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
275  b0->current_data = 0;
277 
278  len_to_deq0 = clib_min (left_to_snd0, deq_per_first_buf);
280  if (peek_data)
281  {
282  n_bytes_read = svm_fifo_peek (s0->server_tx_fifo, tx_offset,
283  len_to_deq0, data0);
284  if (n_bytes_read <= 0)
285  goto dequeue_fail;
286  /* Keep track of progress locally, transport is also supposed to
287  * increment it independently when pushing the header */
288  tx_offset += n_bytes_read;
289  }
290  else
291  {
292  n_bytes_read = svm_fifo_dequeue_nowait (s0->server_tx_fifo,
293  len_to_deq0, data0);
294  if (n_bytes_read <= 0)
295  goto dequeue_fail;
296  }
297 
298  b0->current_length = n_bytes_read;
299 
300  left_to_snd0 -= n_bytes_read;
301  *n_tx_packets = *n_tx_packets + 1;
302 
303  /*
304  * Fill in the remaining buffers in the chain, if any
305  */
306  if (PREDICT_FALSE (n_bufs_per_seg > 1 && left_to_snd0))
307  {
308  left_for_seg = clib_min (snd_mss0 - n_bytes_read, left_to_snd0);
309  session_tx_fifo_chain_tail (smm, vm, thread_index,
310  s0->server_tx_fifo, b0, bi0,
311  n_bufs_per_seg, left_for_seg,
312  &left_to_snd0, &n_bufs, &tx_offset,
313  deq_per_buf, peek_data);
314  }
315 
316  /* Ask transport to push header after current_length and
317  * total_length_not_including_first_buffer are updated */
318  transport_vft->push_header (tc0, b0);
319 
320  /* *INDENT-OFF* */
321  SESSION_EVT_DBG(SESSION_EVT_DEQ, s0, ({
322  ed->data[0] = e0->event_id;
323  ed->data[1] = max_dequeue0;
324  ed->data[2] = len_to_deq0;
325  ed->data[3] = left_to_snd0;
326  }));
327  /* *INDENT-ON* */
328 
331  b0->pre_data[1] = 3;
332 
333  if (PREDICT_FALSE (n_trace > 0))
334  {
336  vlib_trace_buffer (vm, node, next_index, b0,
337  1 /* follow_chain */ );
338  vlib_set_trace_count (vm, node, --n_trace);
339  t0 = vlib_add_trace (vm, node, b0, sizeof (*t0));
340  t0->session_index = s0->session_index;
341  t0->server_thread_index = s0->thread_index;
342  }
343 
344  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
345  to_next, n_left_to_next,
346  bi0, next0);
347  }
348  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
349  }
350 
351  /* If we couldn't dequeue all bytes mark as partially read */
352  if (max_len_to_snd0 < max_dequeue0)
353  {
354  /* If we don't already have new event */
355  if (svm_fifo_set_event (s0->server_tx_fifo))
356  {
357  vec_add1 (smm->pending_event_vector[thread_index], *e0);
358  }
359  }
360  return 0;
361 
362 dequeue_fail:
363  /*
364  * Can't read from fifo. If we don't already have an event, save as partially
365  * read, return buff to free list and return
366  */
367  clib_warning ("dequeue fail");
368 
369  if (svm_fifo_set_event (s0->server_tx_fifo))
370  {
371  vec_add1 (smm->pending_event_vector[thread_index], *e0);
372  }
373  vlib_put_next_frame (vm, node, next_index, n_left_to_next + 1);
374  _vec_len (smm->tx_buffers[thread_index]) += 1;
375 
376  return 0;
377 }
378 
379 int
382  session_fifo_event_t * e0,
383  stream_session_t * s0, u32 thread_index,
384  int *n_tx_pkts)
385 {
386  return session_tx_fifo_read_and_snd_i (vm, node, smm, e0, s0, thread_index,
387  n_tx_pkts, 1);
388 }
389 
390 int
393  session_fifo_event_t * e0,
394  stream_session_t * s0, u32 thread_index,
395  int *n_tx_pkts)
396 {
397  return session_tx_fifo_read_and_snd_i (vm, node, smm, e0, s0, thread_index,
398  n_tx_pkts, 0);
399 }
400 
402 session_event_get_session (session_fifo_event_t * e, u8 thread_index)
403 {
404  return stream_session_get_if_valid (e->fifo->master_session_index,
405  thread_index);
406 }
407 
408 void
410 {
413  u32 my_thread_index = vm->thread_index;
414  session_fifo_event_t _e, *e = &_e;
415  stream_session_t *s0;
416  int i, index;
417  i8 *headp;
418 
420  q = smm->vpp_event_queues[my_thread_index];
421 
422  index = q->head;
423 
424  for (i = 0; i < q->cursize; i++)
425  {
426  headp = (i8 *) (&q->data[0] + q->elsize * index);
427  clib_memcpy (e, headp, q->elsize);
428 
429  switch (e->event_type)
430  {
431  case FIFO_EVENT_APP_TX:
432  s0 = session_event_get_session (e, my_thread_index);
433  fformat (stdout, "[%04d] TX session %d\n", i, s0->session_index);
434  break;
435 
437  s0 = stream_session_get_from_handle (e->session_handle);
438  fformat (stdout, "[%04d] disconnect session %d\n", i,
439  s0->session_index);
440  break;
441 
443  s0 = session_event_get_session (e, my_thread_index);
444  fformat (stdout, "[%04d] builtin_rx %d\n", i, s0->session_index);
445  break;
446 
447  case FIFO_EVENT_RPC:
448  fformat (stdout, "[%04d] RPC call %llx with %llx\n",
449  i, (u64) (e->rpc_args.fp), (u64) (e->rpc_args.arg));
450  break;
451 
452  default:
453  fformat (stdout, "[%04d] unhandled event type %d\n",
454  i, e->event_type);
455  break;
456  }
457 
458  index++;
459 
460  if (index == q->maxsize)
461  index = 0;
462  }
463 }
464 
465 static u8
466 session_node_cmp_event (session_fifo_event_t * e, svm_fifo_t * f)
467 {
468  stream_session_t *s;
469  switch (e->event_type)
470  {
471  case FIFO_EVENT_APP_RX:
472  case FIFO_EVENT_APP_TX:
474  if (e->fifo == f)
475  return 1;
476  break;
478  break;
479  case FIFO_EVENT_RPC:
480  s = stream_session_get_from_handle (e->session_handle);
481  if (!s)
482  {
483  clib_warning ("session has event but doesn't exist!");
484  break;
485  }
486  if (s->server_rx_fifo == f || s->server_tx_fifo == f)
487  return 1;
488  break;
489  default:
490  break;
491  }
492  return 0;
493 }
494 
495 u8
496 session_node_lookup_fifo_event (svm_fifo_t * f, session_fifo_event_t * e)
497 {
500  session_fifo_event_t *pending_event_vector, *evt;
501  int i, index, found = 0;
502  i8 *headp;
503  u8 thread_index;
504 
505  ASSERT (e);
506  thread_index = f->master_thread_index;
507  /*
508  * Search evt queue
509  */
510  q = smm->vpp_event_queues[thread_index];
511  index = q->head;
512  for (i = 0; i < q->cursize; i++)
513  {
514  headp = (i8 *) (&q->data[0] + q->elsize * index);
515  clib_memcpy (e, headp, q->elsize);
516  found = session_node_cmp_event (e, f);
517  if (found)
518  break;
519  if (++index == q->maxsize)
520  index = 0;
521  }
522  /*
523  * Search pending events vector
524  */
525  pending_event_vector = smm->pending_event_vector[thread_index];
526  vec_foreach (evt, pending_event_vector)
527  {
528  found = session_node_cmp_event (evt, f);
529  if (found)
530  {
531  clib_memcpy (e, evt, sizeof (*evt));
532  break;
533  }
534  }
535  return found;
536 }
537 
538 static uword
540  vlib_frame_t * frame)
541 {
543  session_fifo_event_t *my_pending_event_vector, *e;
544  session_fifo_event_t *my_fifo_events;
545  u32 n_to_dequeue, n_events;
547  application_t *app;
548  int n_tx_packets = 0;
549  u32 my_thread_index = vm->thread_index;
550  int i, rv;
551  f64 now = vlib_time_now (vm);
552  void (*fp) (void *);
553 
554  SESSION_EVT_DBG (SESSION_EVT_POLL_GAP_TRACK, smm, my_thread_index);
555 
556  /*
557  * Update TCP time
558  */
559  tcp_update_time (now, my_thread_index);
560 
561  /*
562  * Get vpp queue events
563  */
564  q = smm->vpp_event_queues[my_thread_index];
565  if (PREDICT_FALSE (q == 0))
566  return 0;
567 
568  my_fifo_events = smm->free_event_vector[my_thread_index];
569 
570  /* min number of events we can dequeue without blocking */
571  n_to_dequeue = q->cursize;
572  my_pending_event_vector = smm->pending_event_vector[my_thread_index];
573 
574  if (n_to_dequeue == 0 && vec_len (my_pending_event_vector) == 0)
575  return 0;
576 
577  SESSION_EVT_DBG (SESSION_EVT_DEQ_NODE, 0);
578 
579  /*
580  * If we didn't manage to process previous events try going
581  * over them again without dequeuing new ones.
582  */
583  /* XXX: Block senders to sessions that can't keep up */
584  if (0 && vec_len (my_pending_event_vector) >= 100)
585  {
586  clib_warning ("too many fifo events unsolved");
587  goto skip_dequeue;
588  }
589 
590  /* See you in the next life, don't be late */
591  if (pthread_mutex_trylock (&q->mutex))
592  return 0;
593 
594  for (i = 0; i < n_to_dequeue; i++)
595  {
596  vec_add2 (my_fifo_events, e, 1);
598  }
599 
600  /* The other side of the connection is not polling */
601  if (q->cursize < (q->maxsize / 8))
602  (void) pthread_cond_broadcast (&q->condvar);
603  pthread_mutex_unlock (&q->mutex);
604 
605  vec_append (my_fifo_events, my_pending_event_vector);
606 
607  _vec_len (my_pending_event_vector) = 0;
608  smm->pending_event_vector[my_thread_index] = my_pending_event_vector;
609 
610 skip_dequeue:
611  n_events = vec_len (my_fifo_events);
612  for (i = 0; i < n_events; i++)
613  {
614  stream_session_t *s0; /* $$$ prefetch 1 ahead maybe */
615  session_fifo_event_t *e0;
616 
617  e0 = &my_fifo_events[i];
618 
619  switch (e0->event_type)
620  {
621  case FIFO_EVENT_APP_TX:
622  s0 = session_event_get_session (e0, my_thread_index);
623 
624  if (PREDICT_FALSE (!s0))
625  {
626  clib_warning ("It's dead, Jim!");
627  continue;
628  }
629  /* Can retransmit for closed sessions but can't do anything if
630  * session is not ready or closed */
631  if (PREDICT_FALSE (s0->session_state < SESSION_STATE_READY))
632  continue;
633  /* Spray packets in per session type frames, since they go to
634  * different nodes */
635  rv = (smm->session_tx_fns[s0->session_type]) (vm, node, smm, e0, s0,
636  my_thread_index,
637  &n_tx_packets);
638  /* Out of buffers */
639  if (PREDICT_FALSE (rv < 0))
640  {
642  SESSION_QUEUE_ERROR_NO_BUFFER, 1);
643  continue;
644  }
645  break;
647  s0 = stream_session_get_from_handle (e0->session_handle);
649  break;
651  s0 = session_event_get_session (e0, my_thread_index);
652  if (PREDICT_FALSE (!s0))
653  continue;
654  svm_fifo_unset_event (s0->server_rx_fifo);
655  app = application_get (s0->app_index);
656  app->cb_fns.builtin_server_rx_callback (s0);
657  break;
658  case FIFO_EVENT_RPC:
659  fp = e0->rpc_args.fp;
660  (*fp) (e0->rpc_args.arg);
661  break;
662 
663  default:
664  clib_warning ("unhandled event type %d", e0->event_type);
665  }
666  }
667 
668  _vec_len (my_fifo_events) = 0;
669  smm->free_event_vector[my_thread_index] = my_fifo_events;
670 
672  SESSION_QUEUE_ERROR_TX, n_tx_packets);
673 
674  SESSION_EVT_DBG (SESSION_EVT_DEQ_NODE, 1);
675 
676  return n_tx_packets;
677 }
678 
679 /* *INDENT-OFF* */
681 {
682  .function = session_queue_node_fn,
683  .name = "session-queue",
684  .format_trace = format_session_queue_trace,
685  .type = VLIB_NODE_TYPE_INPUT,
687  .error_strings = session_queue_error_strings,
688  .n_next_nodes = SESSION_QUEUE_N_NEXT,
689  .state = VLIB_NODE_STATE_DISABLED,
690  .next_nodes =
691  {
692  [SESSION_QUEUE_NEXT_DROP] = "error-drop",
693  [SESSION_QUEUE_NEXT_IP4_LOOKUP] = "ip4-lookup",
694  [SESSION_QUEUE_NEXT_IP6_LOOKUP] = "ip6-lookup",
695  [SESSION_QUEUE_NEXT_TCP_IP4_OUTPUT] = "tcp4-output",
696  [SESSION_QUEUE_NEXT_TCP_IP6_OUTPUT] = "tcp6-output",
697  },
698 };
699 /* *INDENT-ON* */
700 
701 /*
702  * fd.io coding-style-patch-verification: ON
703  *
704  * Local Variables:
705  * eval: (c-set-style "gnu")
706  * End:
707  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:432
vlib_main_t vlib_global_main
Definition: main.c:1650
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:337
#define clib_min(x, y)
Definition: clib.h:332
#define CLIB_UNUSED(x)
Definition: clib.h:79
static u32 vlib_get_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt)
Definition: trace_funcs.h:143
struct _transport_connection transport_connection_t
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:221
u32 thread_index
Definition: main.h:173
struct _transport_proto_vft transport_proto_vft_t
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:518
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.
Definition: vec.h:557
static uword session_queue_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: session_node.c:539
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
struct _svm_fifo svm_fifo_t
static void vlib_trace_buffer(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, vlib_buffer_t *b, int follow_chain)
Definition: trace_funcs.h:104
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)
Definition: session_node.c:135
void dump_thread_0_event_queue(void)
Definition: session_node.c:409
#define VLIB_BUFFER_NEXT_PRESENT
Definition: buffer.h:95
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:68
#define always_inline
Definition: clib.h:84
static u32 svm_fifo_max_dequeue(svm_fifo_t *f)
Definition: svm_fifo.h:100
#define VLIB_BUFFER_TOTAL_LENGTH_VALID
Definition: buffer.h:97
char i8
Definition: types.h:45
u8 pre_data[VLIB_BUFFER_PRE_DATA_SIZE]
Space for inserting data before buffer start.
Definition: buffer.h:149
unsigned long u64
Definition: types.h:89
struct _stream_session_t stream_session_t
static char * session_queue_error_strings[]
Definition: session_node.c:61
static session_manager_main_t * vnet_get_session_manager_main()
Definition: session.h:197
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:72
static void * vlib_buffer_make_headroom(vlib_buffer_t *b, u8 size)
Make head room, typically for packet headers.
Definition: buffer.h:305
#define MAX_HDRS_LEN
Definition: session.h:29
session_queue_error_t
Definition: session_node.c:53
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:193
#define VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX
Definition: buffer.h:422
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)
Definition: session_node.c:380
#define PREDICT_FALSE(x)
Definition: clib.h:97
static u32 vlib_buffer_free_list_buffer_size(vlib_main_t *vm, u32 free_list_index)
Definition: buffer_funcs.h:426
static void svm_fifo_unset_event(svm_fifo_t *f)
Unsets fifo event flag.
Definition: svm_fifo.h:133
int unix_shared_memory_queue_sub_raw(unix_shared_memory_queue_t *q, u8 *elem)
#define VLIB_FRAME_SIZE
Definition: node.h:328
u32 node_index
Node index.
Definition: node.h:437
struct _session_manager_main session_manager_main_t
Definition: session.h:113
#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.
Definition: buffer_node.h:216
#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).
Definition: node_funcs.h:364
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:113
word fformat(FILE *f, char *fmt,...)
Definition: format.c:453
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1158
static u8 svm_fifo_set_event(svm_fifo_t *f)
Sets fifo event flag.
Definition: svm_fifo.h:123
The fine-grained event logger allows lightweight, thread-safe event logging at minimum cost...
#define SESSION_EVT_DBG(_evt, _args...)
vlib_main_t * vm
Definition: buffer.c:283
#define clib_warning(format, args...)
Definition: error.h:59
#define clib_memcpy(a, b, c)
Definition: string.h:69
#define VLIB_BUFFER_TRACE_TRAJECTORY
Compile time buffer trajectory tracing option Turn this on if you run into "bad monkey" contexts...
Definition: buffer.h:512
struct _application application_t
#define ARRAY_LEN(x)
Definition: clib.h:59
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.
Definition: main.c:454
static stream_session_t * stream_session_get_if_valid(u64 si, u32 thread_index)
Definition: session.h:224
#define foreach_session_queue_error
Definition: session_node.c:48
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
static u8 session_node_cmp_event(session_fifo_event_t *e, svm_fifo_t *f)
Definition: session_node.c:466
u32 next_buffer
Next buffer for this linked-list of buffers.
Definition: buffer.h:109
#define vec_append(v1, v2)
Append v2 after v1.
Definition: vec.h:815
void stream_session_disconnect(stream_session_t *s)
Disconnect session and propagate to transport.
Definition: session.c:763
static stream_session_t * session_event_get_session(session_fifo_event_t *e, u8 thread_index)
Definition: session_node.c:402
static u8 * format_session_queue_trace(u8 *s, va_list *args)
Definition: session_node.c:35
u64 uword
Definition: types.h:112
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition: trace_funcs.h:55
u32 total_length_not_including_first_buffer
Only valid for first buffer in chain.
Definition: buffer.h:141
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)
Definition: session_node.c:391
unsigned short u16
Definition: types.h:57
static u32 session_type_to_next[]
Definition: session_node.c:67
static void tcp_update_time(f64 now, u32 thread_index)
Definition: tcp.h:672
transport_proto_vft_t * session_get_transport_vft(u8 session_type)
Get transport virtual function table.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
double f64
Definition: types.h:142
unsigned char u8
Definition: types.h:56
#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b)
Definition: buffer.h:517
application_t * application_get(u32 index)
Definition: application.c:224
vlib_node_registration_t session_queue_node
(constructor) VLIB_REGISTER_NODE (session_queue_node)
Definition: session_node.c:25
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:143
#define vec_foreach(var, vec)
Vector iterator.
static void session_tx_fifo_chain_tail(session_manager_main_t *smm, vlib_main_t *vm, u8 thread_index, svm_fifo_t *fifo, vlib_buffer_t *b0, u32 bi0, u8 n_bufs_per_seg, u32 left_from_seg, u32 *left_to_snd0, u16 *n_bufs, u32 *tx_offset, u16 deq_per_buf, u8 peek_data)
Definition: session_node.c:75
static void vlib_set_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt, u32 count)
Definition: trace_funcs.h:159
u8 session_node_lookup_fifo_event(svm_fifo_t *f, session_fifo_event_t *e)
Definition: session_node.c:496
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition: buffer.h:75
static u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
Definition: buffer_funcs.h:254
int svm_fifo_peek(svm_fifo_t *f, u32 relative_offset, u32 max_bytes, u8 *copy_here)
Definition: svm_fifo.c:756
int svm_fifo_dequeue_nowait(svm_fifo_t *f, u32 max_bytes, u8 *copy_here)
Definition: svm_fifo.c:690
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:57
static stream_session_t * stream_session_get_from_handle(u64 handle)
Definition: session.h:262
struct _unix_shared_memory_queue unix_shared_memory_queue_t