FD.io VPP  v19.01.3-6-g70449b9b9
Vector Packet Processing
session.h
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 #ifndef __included_session_h__
16 #define __included_session_h__
17 
23 #include <svm/queue.h>
24 
25 #define HALF_OPEN_LOOKUP_INVALID_VALUE ((u64)~0)
26 #define INVALID_INDEX ((u32)~0)
27 #define SESSION_PROXY_LISTENER_INDEX ((u8)~0 - 1)
28 #define SESSION_LOCAL_HANDLE_PREFIX 0x7FFFFFFF
29 
30 /* TODO decide how much since we have pre-data as well */
31 #define MAX_HDRS_LEN 100 /* Max number of bytes for headers */
32 
33 typedef enum
34 {
57 
58 static inline const char *
59 fifo_event_type_str (session_evt_type_t et)
60 {
61  switch (et)
62  {
63  case FIFO_EVENT_APP_RX:
64  return "FIFO_EVENT_APP_RX";
65  case FIFO_EVENT_APP_TX:
66  return "FIFO_EVENT_APP_TX";
68  return "FIFO_EVENT_DISCONNECT";
70  return "FIFO_EVENT_BUILTIN_RX";
71  case FIFO_EVENT_RPC:
72  return "FIFO_EVENT_RPC";
73  default:
74  return "UNKNOWN FIFO EVENT";
75  }
76 }
77 
78 typedef enum
79 {
84 
85 #define foreach_session_input_error \
86 _(NO_SESSION, "No session drops") \
87 _(NO_LISTENER, "No listener for dst port drops") \
88 _(ENQUEUED, "Packets pushed into rx fifo") \
89 _(NOT_READY, "Session not ready packets") \
90 _(FIFO_FULL, "Packets dropped for lack of rx fifo space") \
91 _(EVENT_FIFO_FULL, "Events not sent for lack of event fifo space") \
92 _(API_QUEUE_FULL, "Sessions not created for lack of API queue space") \
93 _(NEW_SEG_NO_SPACE, "Created segment, couldn't allocate a fifo pair") \
94 _(NO_SPACE, "Couldn't allocate a fifo pair") \
95 _(SEG_CREATE, "Couldn't create a new segment")
96 
97 typedef enum
98 {
99 #define _(sym,str) SESSION_ERROR_##sym,
101 #undef _
104 
105 typedef struct
106 {
107  void *fp;
108  void *arg;
110 
112 
113 /* *INDENT-OFF* */
114 typedef struct
115 {
116  u8 event_type;
117  u8 postponed;
118  union
119  {
120  svm_fifo_t *fifo;
121  session_handle_t session_handle;
122  session_rpc_args_t rpc_args;
123  struct
124  {
125  u8 data[0];
126  };
127  };
128 } __clib_packed session_event_t;
129 /* *INDENT-ON* */
130 
131 #define SESSION_MSG_NULL { }
132 
134 {
138 
139 /* *INDENT-OFF* */
140 typedef CLIB_PACKED (struct session_dgram_header_
141 {
144  ip46_address_t rmt_ip;
145  ip46_address_t lcl_ip;
146  u16 rmt_port;
147  u16 lcl_port;
148  u8 is_ip4;
149 }) session_dgram_hdr_t;
150 /* *INDENT-ON* */
151 
152 #define SESSION_CONN_ID_LEN 37
153 #define SESSION_CONN_HDR_LEN 45
154 
155 STATIC_ASSERT (sizeof (session_dgram_hdr_t) == (SESSION_CONN_ID_LEN + 8),
156  "session conn id wrong length");
157 
158 typedef struct session_tx_context_
159 {
160  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
175  CLIB_CACHE_LINE_ALIGN_MARK (cacheline1);
176  session_dgram_hdr_t hdr;
178 
180 {
181  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
182 
183  /** Worker session pool */
185 
186  /** vpp event message queue for worker */
188 
189  /** Our approximation of a "complete" dispatch loop period */
191 
192  /** vlib_time_now last time around the track */
194 
195  /** Per-proto enqueue epoch counters */
196  u64 current_enqueue_epoch[TRANSPORT_N_PROTO];
197 
198  /** Per-proto vector of sessions to enqueue */
199  u32 *session_to_enqueue[TRANSPORT_N_PROTO];
200 
201  /** Context for session tx */
203 
204  /** Vector of tx buffer free lists */
206 
207  /** Vector of partially read events */
208  session_event_t *free_event_vector;
209 
210  /** Vector of active event vectors */
211  session_event_t *pending_event_vector;
212 
213  /** Vector of postponed disconnects */
214  session_event_t *pending_disconnects;
215 
216  /** Vector of postponed events */
217  session_event_t *postponed_event_vector;
218 
219  /** Peekers rw lock */
221 
223 
225 
227  vlib_node_runtime_t * node,
229  session_event_t * e, int *n_tx_pkts);
230 
234 
235 u8 session_node_lookup_fifo_event (svm_fifo_t * f, session_event_t * e);
236 
237 typedef struct session_manager_main_
238 {
239  /** Worker contexts */
241 
242  /** Event queues memfd segment initialized only if so configured */
244 
245  /** Unique segment name counter */
247 
248  /** Per transport rx function that can either dequeue or peek */
250 
251  /** Per session type output nodes. Could optimize to group nodes by
252  * fib but lookup would then require session type parsing in session node.
253  * Trade memory for speed, for now */
255 
256  /*
257  * Config parameters
258  */
259 
260  /** Session manager is enabled */
262 
263  /** vpp fifo event queue configured length */
265 
266  /** Session ssvm segment configs*/
271 
272  /** Session table size parameters */
281 
282  /** Transport table (preallocation) size parameters */
285 
286  /** Preallocate session config parameter */
288 
289 #if SESSION_DEBUG
290  /**
291  * last event poll time by thread
292  * Debug only. Will cause false cache-line sharing as-is
293  */
294  f64 *last_event_poll_by_thread;
295 #endif
296 
298 
302 
303 #define SESSION_Q_PROCESS_FLUSH_FRAMES 1
304 #define SESSION_Q_PROCESS_STOP 2
305 
306 /*
307  * Session manager function
308  */
311 {
312  return &session_manager_main;
313 }
314 
317 {
318  return &session_manager_main.wrk[thread_index];
319 }
320 
322 stream_session_is_valid (u32 si, u8 thread_index)
323 {
324  stream_session_t *s;
325  s = pool_elt_at_index (session_manager_main.wrk[thread_index].sessions, si);
326  if (s->thread_index != thread_index || s->session_index != si
327  /* || s->server_rx_fifo->master_session_index != si
328  || s->server_tx_fifo->master_session_index != si
329  || s->server_rx_fifo->master_thread_index != thread_index
330  || s->server_tx_fifo->master_thread_index != thread_index */ )
331  return 0;
332  return 1;
333 }
334 
335 stream_session_t *session_alloc (u32 thread_index);
337 void session_free (stream_session_t * s);
339 
341 session_get (u32 si, u32 thread_index)
342 {
343  ASSERT (stream_session_is_valid (si, thread_index));
344  return pool_elt_at_index (session_manager_main.wrk[thread_index].sessions,
345  si);
346 }
347 
349 session_get_if_valid (u64 si, u32 thread_index)
350 {
351  if (thread_index >= vec_len (session_manager_main.wrk))
352  return 0;
353 
354  if (pool_is_free_index (session_manager_main.wrk[thread_index].sessions,
355  si))
356  return 0;
357 
358  ASSERT (stream_session_is_valid (si, thread_index));
359  return pool_elt_at_index (session_manager_main.wrk[thread_index].sessions,
360  si);
361 }
362 
363 always_inline session_handle_t
365 {
366  return ((u64) s->thread_index << 32) | (u64) s->session_index;
367 }
368 
370 session_index_from_handle (session_handle_t handle)
371 {
372  return handle & 0xFFFFFFFF;
373 }
374 
376 session_thread_from_handle (session_handle_t handle)
377 {
378  return handle >> 32;
379 }
380 
381 always_inline void
382 session_parse_handle (session_handle_t handle, u32 * index,
383  u32 * thread_index)
384 {
385  *index = session_index_from_handle (handle);
386  *thread_index = session_thread_from_handle (handle);
387 }
388 
390 session_get_from_handle (session_handle_t handle)
391 {
393  u32 session_index, thread_index;
394  session_parse_handle (handle, &session_index, &thread_index);
395  return pool_elt_at_index (smm->wrk[thread_index].sessions, session_index);
396 }
397 
399 session_get_from_handle_if_valid (session_handle_t handle)
400 {
401  u32 session_index, thread_index;
402  session_parse_handle (handle, &session_index, &thread_index);
403  return session_get_if_valid (session_index, thread_index);
404 }
405 
407 session_handle_is_local (session_handle_t handle)
408 {
409  if ((handle >> 32) == SESSION_LOCAL_HANDLE_PREFIX)
410  return 1;
411  return 0;
412 }
413 
416 {
417  return (st >> 1);
418 }
419 
422 {
423  return (st & 1);
424 }
425 
428 {
429  return (s->session_type >> 1);
430 }
431 
434 {
435  u8 is_ip4 = s->session_type & 1;
436  return (is_ip4 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6);
437 }
438 
441 {
442  return (proto << 1 | is_ip4);
443 }
444 
447 {
448  svm_fifo_t *f = s->server_rx_fifo;
449  return segment_manager_make_segment_handle (f->segment_manager,
450  f->segment_index);
451 }
452 
455 {
457 }
458 
462 
463 /**
464  * Acquires a lock that blocks a session pool from expanding.
465  *
466  * This is typically used for safely peeking into other threads'
467  * pools in order to clone elements. Lock should be dropped as soon
468  * as possible by calling @ref session_pool_remove_peeker.
469  *
470  * NOTE: Avoid using pool_elt_at_index while the lock is held because
471  * it may lead to free elt bitmap expansion/contraction!
472  */
473 always_inline void
475 {
476  session_manager_worker_t *wrk = &session_manager_main.wrk[thread_index];
477  if (thread_index == vlib_get_thread_index ())
478  return;
480 }
481 
482 always_inline void
484 {
485  session_manager_worker_t *wrk = &session_manager_main.wrk[thread_index];
486  if (thread_index == vlib_get_thread_index ())
487  return;
489 }
490 
491 /**
492  * Get session from handle and 'lock' pool resize if not in same thread
493  *
494  * Caller should drop the peek 'lock' as soon as possible.
495  */
498 {
499  u32 thread_index = session_thread_from_handle (handle);
500  session_manager_worker_t *wrk = &session_manager_main.wrk[thread_index];
501 
502  if (thread_index == vlib_get_thread_index ())
503  {
504  return pool_elt_at_index (wrk->sessions,
505  session_index_from_handle (handle));
506  }
507  else
508  {
509  session_pool_add_peeker (thread_index);
510  /* Don't use pool_elt_at index. See @ref session_pool_add_peeker */
511  return wrk->sessions + session_index_from_handle (handle);
512  }
513 }
514 
517 {
518  stream_session_t *s = session_get (tc->s_index, tc->thread_index);
519  return svm_fifo_max_enqueue (s->server_rx_fifo);
520 }
521 
524 {
525  stream_session_t *s = session_get (tc->s_index, tc->thread_index);
526  return svm_fifo_max_dequeue (s->server_tx_fifo);
527 }
528 
531 {
532  stream_session_t *s = session_get (tc->s_index, tc->thread_index);
533  return s->server_rx_fifo->nitems;
534 }
535 
538 {
539  stream_session_t *s = session_get (tc->s_index, tc->thread_index);
540  return s->server_tx_fifo->nitems;
541 }
542 
545 {
546  stream_session_t *s = session_get (tc->c_index, tc->thread_index);
547  return svm_fifo_has_ooo_data (s->server_rx_fifo);
548 }
549 
552 {
553  return session_manager_main.wrk[thread_index].dispatch_period;
554 }
555 
557 transport_time_now (u32 thread_index)
558 {
559  return session_manager_main.wrk[thread_index].last_vlib_time;
560 }
561 
564 {
565  return (s - session_manager_main.wrk[s->thread_index].sessions);
566 }
567 
569 session_clone_safe (u32 session_index, u32 thread_index)
570 {
571  stream_session_t *old_s, *new_s;
572  u32 current_thread_index = vlib_get_thread_index ();
573 
574  /* If during the memcpy pool is reallocated AND the memory allocator
575  * decides to give the old chunk of memory to somebody in a hurry to
576  * scribble something on it, we have a problem. So add this thread as
577  * a session pool peeker.
578  */
579  session_pool_add_peeker (thread_index);
580  new_s = session_alloc (current_thread_index);
581  old_s = session_manager_main.wrk[thread_index].sessions + session_index;
582  clib_memcpy_fast (new_s, old_s, sizeof (*new_s));
583  session_pool_remove_peeker (thread_index);
584  new_s->thread_index = current_thread_index;
585  new_s->session_index = session_get_index (new_s);
586  return new_s;
587 }
588 
590 
592 
593 int
595  vlib_buffer_t * b, u32 offset,
596  u8 queue_event, u8 is_in_order);
598  session_dgram_hdr_t * hdr,
599  vlib_buffer_t * b, u8 proto,
600  u8 queue_event);
602  u32 offset, u32 max_bytes);
604 
607  u32 old_thread_index,
608  stream_session_t ** new_session);
611  u32 rx_pointer, u32 tx_pointer);
612 
618 int stream_session_accept (transport_connection_t * tc, u32 listener_index,
619  u8 notify);
620 int session_open (u32 app_index, session_endpoint_t * tep, u32 opaque);
627  session_evt_type_t evt_type);
628 int session_send_io_evt_to_thread_custom (void *data, u32 thread_index,
629  session_evt_type_t evt_type);
630 void session_send_rpc_evt_to_thread (u32 thread_index, void *fp,
631  void *rpc_args);
632 
634 
635 u8 *format_stream_session (u8 * s, va_list * args);
636 uword unformat_stream_session (unformat_input_t * input, va_list * args);
638  va_list * args);
639 
640 void session_register_transport (transport_proto_t transport_proto,
641  const transport_proto_vft_t * vft, u8 is_ip4,
642  u32 output_node);
643 
644 always_inline void
646 {
647  stream_session_t *s = session_get (tc->s_index, tc->thread_index);
648  if (svm_fifo_has_event (s->server_tx_fifo))
649  return;
651 }
652 
654 
657 {
658  return session_manager_main.wrk[thread_index].vpp_event_queue;
659 }
660 
661 int session_manager_flush_enqueue_events (u8 proto, u32 thread_index);
662 int session_manager_flush_all_enqueue_events (u8 transport_proto);
663 
666 {
667  ASSERT (s->session_state == SESSION_STATE_LISTENING);
668  return session_handle (s);
669 }
670 
672 listen_session_get_from_handle (session_handle_t handle)
673 {
674  return session_get_from_handle (handle);
675 }
676 
677 always_inline void
678 listen_session_parse_handle (session_handle_t handle, u32 * index,
679  u32 * thread_index)
680 {
681  session_parse_handle (handle, index, thread_index);
682 }
683 
686 {
687  stream_session_t *s;
688  s = session_alloc (thread_index);
689  s->session_type = type;
690  s->session_state = SESSION_STATE_LISTENING;
691  return s;
692 }
693 
696 {
697  return session_get (index, 0);
698 }
699 
700 always_inline void
702 {
703  session_free (s);
704 }
705 
707 
708 int
710  session_endpoint_t * sep);
711 
713 
716 {
717  return session_manager_main.is_enabled == 1;
718 }
719 
720 #define session_cli_return_if_not_enabled() \
721 do { \
722  if (!session_manager_main.is_enabled) \
723  return clib_error_return(0, "session layer is not enabled"); \
724 } while (0)
725 
726 void session_node_enable_disable (u8 is_en);
727 
728 #endif /* __included_session_h__ */
729 
730 /*
731  * fd.io coding-style-patch-verification: ON
732  *
733  * Local Variables:
734  * eval: (c-set-style "gnu")
735  * End:
736  */
u32 configured_v4_session_table_memory
Definition: session.h:274
static void clib_rwlock_reader_lock(clib_rwlock_t *p)
Definition: lock.h:139
f64 dispatch_period
Our approximation of a "complete" dispatch loop period.
Definition: session.h:190
static u64 session_segment_handle(stream_session_t *s)
Definition: session.h:446
void session_free_w_fifos(stream_session_t *s)
Definition: session.c:177
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
Definition: cache.h:60
clib_rwlock_t peekers_rw_locks
Peekers rw lock.
Definition: session.h:220
session_evt_type_t
Definition: session.h:33
static u32 transport_rx_fifo_size(transport_connection_t *tc)
Definition: session.h:530
struct session_manager_main_ session_manager_main_t
static f64 transport_time_now(u32 thread_index)
Definition: session.h:557
struct _transport_connection transport_connection_t
int session_dgram_connect_notify(transport_connection_t *tc, u32 old_thread_index, stream_session_t **new_session)
Move dgram session to the right thread.
Definition: session.c:735
vlib_buffer_t * b
Definition: session.h:164
uword unformat_transport_connection(unformat_input_t *input, va_list *args)
Definition: session_cli.c:184
static u8 svm_fifo_has_ooo_data(svm_fifo_t *f)
Definition: svm_fifo.h:154
ssvm_private_t evt_qs_segment
Event queues memfd segment initialized only if so configured.
Definition: session.h:243
u32 configured_v4_halfopen_table_memory
Definition: session.h:276
u32 configured_v6_session_table_buckets
Definition: session.h:277
unsigned long u64
Definition: types.h:89
struct session_tx_context_ session_tx_context_t
#define clib_memcpy_fast(a, b, c)
Definition: string.h:81
uword unformat_stream_session(unformat_input_t *input, va_list *args)
Definition: session_cli.c:153
void session_transport_close(stream_session_t *s)
Notify transport the session can be disconnected.
Definition: session.c:1165
int session_stop_listen(stream_session_t *s)
Ask transport to stop listening on local transport endpoint.
Definition: session.c:1106
struct _transport_proto_vft transport_proto_vft_t
ssvm_private_t * session_manager_get_evt_q_segment(void)
Definition: session.c:1305
session_event_t * pending_event_vector
Vector of active event vectors.
Definition: session.h:211
int session_listen(stream_session_t *s, session_endpoint_cfg_t *sep)
Ask transport to listen on session endpoint.
Definition: session.c:1076
session_event_t * postponed_event_vector
Vector of postponed events.
Definition: session.h:217
int stream_session_accept(transport_connection_t *tc, u32 listener_index, u8 notify)
Accept a stream session.
Definition: session.c:923
int session_stream_connect_notify(transport_connection_t *tc, u8 is_fail)
Definition: session.c:630
int session_dequeue_notify(stream_session_t *s)
Definition: session.c:552
static void session_parse_handle(session_handle_t handle, u32 *index, u32 *thread_index)
Definition: session.h:382
static u32 svm_fifo_max_enqueue(svm_fifo_t *f)
Definition: svm_fifo.h:142
static void session_pool_remove_peeker(u32 thread_index)
Definition: session.h:483
#define SESSION_LOCAL_HANDLE_PREFIX
Definition: session.h:28
u8 is_enabled
Session manager is enabled.
Definition: session.h:261
u64 session_handle_t
Definition: session.h:111
static u32 session_index_from_handle(session_handle_t handle)
Definition: session.h:370
static stream_session_t * session_get_from_handle(session_handle_t handle)
Definition: session.h:390
static u8 session_manager_is_enabled()
Definition: session.h:715
u32 configured_v6_halfopen_table_memory
Definition: session.h:280
int listen_session_get_local_session_endpoint(stream_session_t *listener, session_endpoint_t *sep)
Definition: session.c:1378
vlib_node_registration_t session_queue_node
(constructor) VLIB_REGISTER_NODE (session_queue_node)
enum transport_service_type_ transport_service_type_t
unsigned char u8
Definition: types.h:56
static stream_session_t * listen_session_get_from_handle(session_handle_t handle)
Definition: session.h:672
session_fifo_rx_fn session_tx_fifo_peek_and_snd
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
double f64
Definition: types.h:142
session_event_t * pending_disconnects
Vector of postponed disconnects.
Definition: session.h:214
struct _svm_fifo svm_fifo_t
static svm_msg_q_t * session_manager_get_vpp_event_queue(u32 thread_index)
Definition: session.h:656
void session_send_rpc_evt_to_thread(u32 thread_index, void *fp, void *rpc_args)
Definition: session.c:111
int session_enqueue_dgram_connection(stream_session_t *s, session_dgram_hdr_t *hdr, vlib_buffer_t *b, u8 proto, u8 queue_event)
Definition: session.c:445
#define always_inline
Definition: clib.h:98
void session_transport_closed_notify(transport_connection_t *tc)
Notification from transport that session can be closed.
Definition: session.c:875
static u32 svm_fifo_max_dequeue(svm_fifo_t *f)
Definition: svm_fifo.h:124
int session_open(u32 app_index, session_endpoint_t *tep, u32 opaque)
Ask transport to open connection to remote transport endpoint.
Definition: session.c:1061
static stream_session_t * listen_session_get(u32 index)
Definition: session.h:695
STATIC_ASSERT(sizeof(session_dgram_hdr_t)==(SESSION_CONN_ID_LEN+8), "session conn id wrong length")
stream_session_t * s
Definition: session.h:161
u32 stream_session_dequeue_drop(transport_connection_t *tc, u32 max_bytes)
Definition: session.c:515
unsigned int u32
Definition: types.h:88
u32 configured_v6_session_table_memory
Definition: session.h:278
struct _stream_session_t stream_session_t
int() session_fifo_rx_fn(vlib_main_t *vm, vlib_node_runtime_t *node, session_manager_worker_t *wrk, session_event_t *e, int *n_tx_pkts)
Definition: session.h:226
enum transport_dequeue_type_ transport_tx_fn_type_t
stream_session_t * sessions
Worker session pool.
Definition: session.h:184
u8 session_tx_is_dgram(stream_session_t *s)
Definition: session.c:1227
struct _session_endpoint_cfg session_endpoint_cfg_t
session_event_t * free_event_vector
Vector of partially read events.
Definition: session.h:208
static transport_proto_t session_get_transport_proto(stream_session_t *s)
Definition: session.h:427
static void listen_session_del(stream_session_t *s)
Definition: session.h:701
f64 last_vlib_time
vlib_time_now last time around the track
Definition: session.h:193
static session_manager_main_t * vnet_get_session_manager_main()
Definition: session.h:310
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:511
#define SESSION_CONN_ID_LEN
Definition: session.h:152
struct _session_endpoint session_endpoint_t
static void clib_rwlock_reader_unlock(clib_rwlock_t *p)
Definition: lock.h:157
transport_proto_vft_t * transport_vft
Definition: session.h:162
void session_register_transport(transport_proto_t transport_proto, const transport_proto_vft_t *vft, u8 is_ip4, u32 output_node)
Initialize session layer for given transport proto and ip version.
Definition: session.c:1329
static u8 session_handle_is_local(session_handle_t handle)
Definition: session.h:407
struct _unformat_input_t unformat_input_t
static u32 session_get_index(stream_session_t *s)
Definition: session.h:563
unsigned short u16
Definition: types.h:57
u32 configured_v6_halfopen_table_buckets
Definition: session.h:279
static session_handle_t session_handle(stream_session_t *s)
Definition: session.h:364
void stream_session_init_fifos_pointers(transport_connection_t *tc, u32 rx_pointer, u32 tx_pointer)
Init fifo tail and head pointers.
Definition: session.c:620
static stream_session_t * session_get_if_valid(u64 si, u32 thread_index)
Definition: session.h:349
typedef CLIB_PACKED(struct session_dgram_header_ { u32 data_length;u32 data_offset;ip46_address_t rmt_ip;ip46_address_t lcl_ip;u16 rmt_port;u16 lcl_port;u8 is_ip4;}) session_dgram_hdr_t
void session_close(stream_session_t *s)
Initialize session closing procedure.
Definition: session.c:1135
int stream_session_accept_notify(transport_connection_t *tc)
Definition: session.c:771
static stream_session_t * session_get(u32 si, u32 thread_index)
Definition: session.h:341
static void session_pool_add_peeker(u32 thread_index)
Acquires a lock that blocks a session pool from expanding.
Definition: session.h:474
static u32 session_thread_from_handle(session_handle_t handle)
Definition: session.h:376
void session_transport_cleanup(stream_session_t *s)
Cleanup transport and session state.
Definition: session.c:1197
session_tx_context_t ctx
Context for session tx.
Definition: session.h:202
void session_node_enable_disable(u8 is_en)
Definition: session.c:1495
struct session_manager_worker_ session_manager_worker_t
int session_manager_flush_enqueue_events(u8 proto, u32 thread_index)
Flushes queue of sessions that are to be notified of new data enqueued events.
Definition: session.c:576
session_fifo_rx_fn session_tx_fifo_dequeue_and_snd
static session_manager_worker_t * session_manager_get_worker(u32 thread_index)
Definition: session.h:316
static_always_inline uword vlib_get_thread_index(void)
Definition: threads.h:212
static session_type_t session_type_from_proto_and_ip(transport_proto_t proto, u8 is_ip4)
Definition: session.h:440
vlib_main_t * vm
Definition: buffer.c:301
static transport_proto_t session_type_transport_proto(session_type_t st)
Definition: session.h:415
u8 * format_stream_session(u8 *s, va_list *args)
Format stream session as per the following format.
Definition: session_cli.c:57
static u8 transport_rx_fifo_has_ooo_data(transport_connection_t *tc)
Definition: session.h:544
static stream_session_t * session_get_from_handle_safe(u64 handle)
Get session from handle and &#39;lock&#39; pool resize if not in same thread.
Definition: session.h:497
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:283
session_manager_main_t session_manager_main
Definition: session.c:27
void session_transport_delete_notify(transport_connection_t *tc)
Notification from transport that connection is being deleted.
Definition: session.c:820
session_mq_rings_e
Definition: session.h:78
static u8 session_has_transport(stream_session_t *s)
Definition: session.h:454
u32 configured_v4_halfopen_table_buckets
Definition: session.h:275
u32 local_endpoints_table_buckets
Definition: session.h:284
static u8 stream_session_is_valid(u32 si, u8 thread_index)
Definition: session.h:322
transport_tx_fn_type_t session_transport_tx_fn_type(stream_session_t *)
Definition: session.c:1219
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
Definition: session.c:1529
static u64 segment_manager_make_segment_handle(u32 segment_manager_index, u32 segment_index)
static stream_session_t * session_get_from_handle_if_valid(session_handle_t handle)
Definition: session.h:399
static u32 transport_max_tx_dequeue(transport_connection_t *tc)
Definition: session.h:523
session_fifo_rx_fn ** session_tx_fns
Per transport rx function that can either dequeue or peek.
Definition: session.h:249
#define ASSERT(truth)
void session_transport_reset_notify(transport_connection_t *tc)
Notify application that connection has been reset.
Definition: session.c:904
struct session_dgram_pre_hdr_ session_dgram_pre_hdr_t
u8 session_type_t
int session_send_io_evt_to_thread(svm_fifo_t *f, session_evt_type_t evt_type)
Definition: session.c:88
transport_connection_t * session_get_transport(stream_session_t *s)
Definition: session.c:1358
u32 * tx_buffers
Vector of tx buffer free lists.
Definition: session.h:205
u32 preallocated_sessions
Preallocate session config parameter.
Definition: session.h:287
static void transport_add_tx_event(transport_connection_t *tc)
Definition: session.h:645
int session_send_io_evt_to_thread_custom(void *data, u32 thread_index, session_evt_type_t evt_type)
Definition: session.c:94
int session_enqueue_stream_connection(transport_connection_t *tc, vlib_buffer_t *b, u32 offset, u8 queue_event, u8 is_in_order)
Definition: session.c:392
int session_manager_flush_all_enqueue_events(u8 transport_proto)
Definition: session.c:605
u32 * session_type_to_next
Per session type output nodes.
Definition: session.h:254
u32 session_tx_fifo_max_dequeue(transport_connection_t *tc)
Definition: session.c:498
u32 unique_segment_name_counter
Unique segment name counter.
Definition: session.h:246
session_dgram_hdr_t hdr
Definition: session.h:176
transport_service_type_t session_transport_service_type(stream_session_t *)
Definition: session.c:1211
void session_free(stream_session_t *s)
Definition: session.c:169
struct _vlib_node_registration vlib_node_registration_t
u32 configured_v4_session_table_buckets
Session table size parameters.
Definition: session.h:273
session_manager_worker_t * wrk
Worker contexts.
Definition: session.h:240
enum _transport_proto transport_proto_t
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
svm_msg_q_t * vpp_event_queue
vpp event message queue for worker
Definition: session.h:187
stream_session_t * session_alloc(u32 thread_index)
Definition: session.c:144
uword session_baseva
Session ssvm segment configs.
Definition: session.h:267
session_fifo_rx_fn session_tx_fifo_dequeue_internal
static stream_session_t * session_clone_safe(u32 session_index, u32 thread_index)
Definition: session.h:569
static stream_session_t * listen_session_new(u8 thread_index, session_type_t type)
Definition: session.h:685
u64 uword
Definition: types.h:112
struct _segment_manager segment_manager_t
session_error_t
Definition: session.h:97
#define foreach_session_input_error
Definition: session.h:85
int session_alloc_fifos(segment_manager_t *sm, stream_session_t *s)
Definition: session.c:202
transport_connection_t * tc
Definition: session.h:163
vlib_node_registration_t session_queue_process_node
(constructor) VLIB_REGISTER_NODE (session_queue_process_node)
u32 configured_event_queue_length
vpp fifo event queue configured length
Definition: session.h:264
static int svm_fifo_has_event(svm_fifo_t *f)
Definition: svm_fifo.h:148
int stream_session_peek_bytes(transport_connection_t *tc, u8 *buffer, u32 offset, u32 max_bytes)
Definition: session.c:507
u8 session_node_lookup_fifo_event(svm_fifo_t *f, session_event_t *e)
static u32 transport_max_rx_enqueue(transport_connection_t *tc)
Definition: session.h:516
u32 local_endpoints_table_memory
Transport table (preallocation) size parameters.
Definition: session.h:283
transport_connection_t * listen_session_get_transport(stream_session_t *s)
Definition: session.c:1371
static fib_protocol_t session_get_fib_proto(stream_session_t *s)
Definition: session.h:433
static u8 session_type_is_ip4(session_type_t st)
Definition: session.h:421
static u64 listen_session_get_handle(stream_session_t *s)
Definition: session.h:665
void session_transport_closing_notify(transport_connection_t *tc)
Notification from transport that connection is being closed.
Definition: session.c:794
static u32 transport_tx_fifo_size(transport_connection_t *tc)
Definition: session.h:537
static const char * fifo_event_type_str(session_evt_type_t et)
Definition: session.h:59
void session_flush_frames_main_thread(vlib_main_t *vm)
Definition: session.c:1398
static f64 transport_dispatch_period(u32 thread_index)
Definition: session.h:551
static void listen_session_parse_handle(session_handle_t handle, u32 *index, u32 *thread_index)
Definition: session.h:678
uword session_va_space_size
Definition: session.h:268