FD.io VPP  v21.01.1
Vector Packet Processing
session.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2019 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 
18 #include <vppinfra/llist.h>
22 #include <svm/message_queue.h>
23 #include <svm/ssvm.h>
24 
25 #define foreach_session_input_error \
26 _(NO_SESSION, "No session drops") \
27 _(NO_LISTENER, "No listener for dst port drops") \
28 _(ENQUEUED, "Packets pushed into rx fifo") \
29 _(NOT_READY, "Session not ready packets") \
30 _(FIFO_FULL, "Packets dropped for lack of rx fifo space") \
31 _(EVENT_FIFO_FULL, "Events not sent for lack of event fifo space") \
32 _(API_QUEUE_FULL, "Sessions not created for lack of API queue space") \
33 
34 typedef enum
35 {
36 #define _(sym,str) SESSION_ERROR_##sym,
38 #undef _
41 
42 typedef struct session_tx_context_
43 {
44  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
57  CLIB_CACHE_LINE_ALIGN_MARK (cacheline1);
60 
61 typedef struct session_evt_elt
62 {
64  session_event_t evt;
66 
67 typedef struct session_ctrl_evt_data_
68 {
71 
72 typedef struct session_worker_
73 {
74  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
75 
76  /** Worker session pool */
78 
79  /** vpp event message queue for worker */
81 
82  /** vlib_time_now last time around the track */
84 
85  /** vlib_time_now rounded to us precision and as u64 */
87 
88  /** Convenience pointer to this worker's vlib_main */
90 
91  /** Per-proto vector of sessions to enqueue */
93 
94  /** Context for session tx */
96 
97  /** Vector of tx buffer free lists */
99 
100  /** Pool of session event list elements */
102 
103  /** Pool of ctrl events data buffers */
105 
106  /** Head of control events list */
108 
109  /** Head of list of elements */
111 
112  /** Head of list of pending events */
114 
115  /** Peekers rw lock */
117 
118  /** Vector of buffers to be sent */
120 
121  /** Vector of nexts for the pending tx buffers */
123 
124 #if SESSION_DEBUG
125  /** last event poll time by thread */
126  clib_time_type_t last_event_poll;
127 #endif
129 
132  session_evt_elt_t * e, int *n_tx_packets);
133 
137 
138 u8 session_node_lookup_fifo_event (svm_fifo_t * f, session_event_t * e);
139 
140 typedef struct session_main_
141 {
142  /** Worker contexts */
144 
145  /** Event queues memfd segment */
147 
148  /** Unique segment name counter */
150 
151  /** Per transport rx function that can either dequeue or peek */
153 
154  /** Per session type output nodes. Could optimize to group nodes by
155  * fib but lookup would then require session type parsing in session node.
156  * Trade memory for speed, for now */
158 
160 
161  /*
162  * Config parameters
163  */
164 
165  /** Session manager is enabled */
167 
168  /** Session manager initialized (not necessarily enabled) */
170 
171  /** Enable session manager at startup */
173 
174  /** Poll session node in main thread */
176 
177  /** vpp fifo event queue configured length */
179 
180  /** Session ssvm segment configs*/
184 
185  /** Session table size parameters */
194 
195  /** Transport table (preallocation) size parameters */
198 
199  /** Preallocate session config parameter */
201 
203 
208 
210 {
214 
215 #define TRANSPORT_PROTO_INVALID (session_main.last_transport_proto_type + 1)
216 #define TRANSPORT_N_PROTOS (session_main.last_transport_proto_type + 1)
217 
218 static inline session_evt_elt_t *
220 {
221  session_evt_elt_t *elt;
222  pool_get (wrk->event_elts, elt);
223  return elt;
224 }
225 
226 static inline void
228 {
229  pool_put (wrk->event_elts, elt);
230 }
231 
232 static inline void
234 {
235  clib_llist_add_tail (wrk->event_elts, evt_list, elt,
236  pool_elt_at_index (wrk->event_elts, wrk->old_head));
237 }
238 
239 static inline void
241 {
242  clib_llist_add (wrk->event_elts, evt_list, elt,
243  pool_elt_at_index (wrk->event_elts, wrk->old_head));
244 }
245 
246 
247 static inline u32
249 {
251  pool_get (wrk->ctrl_evts_data, data);
252  return (data - wrk->ctrl_evts_data);
253 }
254 
255 static inline session_evt_elt_t *
257 {
258  session_evt_elt_t *elt;
259  elt = session_evt_elt_alloc (wrk);
260  clib_llist_add_tail (wrk->event_elts, evt_list, elt,
261  pool_elt_at_index (wrk->event_elts, wrk->ctrl_head));
262  return elt;
263 }
264 
265 static inline void *
267 {
268  return (void *) (pool_elt_at_index (wrk->ctrl_evts_data,
269  elt->evt.ctrl_data_index));
270 }
271 
272 static inline void
274 {
275  ASSERT (elt->evt.event_type > SESSION_IO_EVT_BUILTIN_TX);
276  pool_put_index (wrk->ctrl_evts_data, elt->evt.ctrl_data_index);
277 }
278 
279 static inline session_evt_elt_t *
281 {
282  session_evt_elt_t *elt;
283  elt = session_evt_elt_alloc (wrk);
284  clib_llist_add_tail (wrk->event_elts, evt_list, elt,
285  pool_elt_at_index (wrk->event_elts, wrk->new_head));
286  return elt;
287 }
288 
289 static inline session_evt_elt_t *
291 {
292  session_evt_elt_t *elt;
293  elt = session_evt_elt_alloc (wrk);
294  clib_llist_add_tail (wrk->event_elts, evt_list, elt,
295  pool_elt_at_index (wrk->event_elts, wrk->old_head));
296  return elt;
297 }
298 
299 session_t *session_alloc (u32 thread_index);
300 void session_free (session_t * s);
303  session_handle_t ho_handle);
304 u8 session_is_valid (u32 si, u8 thread_index);
305 
307 session_get (u32 si, u32 thread_index)
308 {
309  ASSERT (session_is_valid (si, thread_index));
310  return pool_elt_at_index (session_main.wrk[thread_index].sessions, si);
311 }
312 
315 {
316  if (thread_index >= vec_len (session_main.wrk))
317  return 0;
318 
319  if (pool_is_free_index (session_main.wrk[thread_index].sessions, si))
320  return 0;
321 
322  ASSERT (session_is_valid (si, thread_index));
323  return pool_elt_at_index (session_main.wrk[thread_index].sessions, si);
324 }
325 
328 {
330  u32 session_index, thread_index;
331  session_parse_handle (handle, &session_index, &thread_index);
332  return pool_elt_at_index (smm->wrk[thread_index].sessions, session_index);
333 }
334 
337 {
338  u32 session_index, thread_index;
339  session_parse_handle (handle, &session_index, &thread_index);
340  return session_get_if_valid (session_index, thread_index);
341 }
342 
344 
345 /**
346  * Acquires a lock that blocks a session pool from expanding.
347  *
348  * This is typically used for safely peeking into other threads'
349  * pools in order to clone elements. Lock should be dropped as soon
350  * as possible by calling @ref session_pool_remove_peeker.
351  *
352  * NOTE: Avoid using pool_elt_at_index while the lock is held because
353  * it may lead to free elt bitmap expansion/contraction!
354  */
355 always_inline void
357 {
358  session_worker_t *wrk = &session_main.wrk[thread_index];
359  if (thread_index == vlib_get_thread_index ())
360  return;
362 }
363 
364 always_inline void
366 {
367  session_worker_t *wrk = &session_main.wrk[thread_index];
368  if (thread_index == vlib_get_thread_index ())
369  return;
371 }
372 
373 /**
374  * Get session from handle and 'lock' pool resize if not in same thread
375  *
376  * Caller should drop the peek 'lock' as soon as possible.
377  */
380 {
381  u32 thread_index = session_thread_from_handle (handle);
382  session_worker_t *wrk = &session_main.wrk[thread_index];
383 
384  if (thread_index == vlib_get_thread_index ())
385  {
386  return pool_elt_at_index (wrk->sessions,
387  session_index_from_handle (handle));
388  }
389  else
390  {
391  session_pool_add_peeker (thread_index);
392  /* Don't use pool_elt_at index. See @ref session_pool_add_peeker */
393  return wrk->sessions + session_index_from_handle (handle);
394  }
395 }
396 
399 {
400  return (s - session_main.wrk[s->thread_index].sessions);
401 }
402 
404 session_clone_safe (u32 session_index, u32 thread_index)
405 {
406  session_t *old_s, *new_s;
407  u32 current_thread_index = vlib_get_thread_index ();
408 
409  /* If during the memcpy pool is reallocated AND the memory allocator
410  * decides to give the old chunk of memory to somebody in a hurry to
411  * scribble something on it, we have a problem. So add this thread as
412  * a session pool peeker.
413  */
414  session_pool_add_peeker (thread_index);
415  new_s = session_alloc (current_thread_index);
416  old_s = session_main.wrk[thread_index].sessions + session_index;
417  clib_memcpy_fast (new_s, old_s, sizeof (*new_s));
418  session_pool_remove_peeker (thread_index);
419  new_s->thread_index = current_thread_index;
420  new_s->session_index = session_get_index (new_s);
421  return new_s;
422 }
423 
424 int session_open (u32 app_index, session_endpoint_t * tep, u32 opaque);
427 void session_close (session_t * s);
428 void session_reset (session_t * s);
433  session_evt_type_t evt_type);
436 int session_send_io_evt_to_thread_custom (void *data, u32 thread_index,
437  session_evt_type_t evt_type);
438 void session_send_rpc_evt_to_thread (u32 thread_index, void *fp,
439  void *rpc_args);
440 void session_send_rpc_evt_to_thread_force (u32 thread_index, void *fp,
441  void *rpc_args);
443  u8 has_prio);
447  u8 is_lcl);
448 
449 u8 *format_session (u8 * s, va_list * args);
450 uword unformat_session (unformat_input_t * input, va_list * args);
452  va_list * args);
453 
454 /*
455  * Interface to transport protos
456  */
457 
459  vlib_buffer_t * b, u32 offset,
460  u8 queue_event, u8 is_in_order);
462  session_dgram_hdr_t * hdr,
463  vlib_buffer_t * b, u8 proto,
464  u8 queue_event);
466  session_error_t err);
468  u32 old_thread_index,
469  session_t ** new_session);
474  session_handle_t ho_handle);
477 int session_stream_accept (transport_connection_t * tc, u32 listener_index,
478  u32 thread_index, u8 notify);
479 int session_dgram_accept (transport_connection_t * tc, u32 listener_index,
480  u32 thread_index);
481 /**
482  * Initialize session layer for given transport proto and ip version
483  *
484  * Allocates per session type (transport proto + ip version) data structures
485  * and adds arc from session queue node to session type output node.
486  *
487  * @param transport_proto transport proto to be registered
488  * @param vft virtual function table for transport
489  * @param is_ip4 flag that indicates if transports uses ipv4
490  * as underlying network layer
491  * @param output_node output node for transport
492  */
494  const transport_proto_vft_t * vft, u8 is_ip4,
495  u32 output_node);
498  u32 offset, u32 max_bytes);
500 
503 {
504  session_t *s = session_get (tc->s_index, tc->thread_index);
506 }
507 
510 {
511  session_t *s = session_get (tc->s_index, tc->thread_index);
513 }
514 
517 {
518  session_t *s = session_get (tc->s_index, tc->thread_index);
519  return svm_fifo_max_dequeue (s->rx_fifo);
520 }
521 
524 {
525  session_t *s = session_get (tc->s_index, tc->thread_index);
526  return svm_fifo_size (s->rx_fifo);
527 }
528 
531 {
532  session_t *s = session_get (tc->s_index, tc->thread_index);
533  return svm_fifo_size (s->tx_fifo);
534 }
535 
538 {
539  session_t *s = session_get (tc->c_index, tc->thread_index);
540  return svm_fifo_has_ooo_data (s->rx_fifo);
541 }
542 
544 transport_time_now (u32 thread_index)
545 {
546  return session_main.wrk[thread_index].last_vlib_time;
547 }
548 
551 {
552  return session_main.wrk[thread_index].last_vlib_us_time;
553 }
554 
557 {
558  return session_main.wrk[thread_index].vm->seconds_per_loop;
559 }
560 
561 always_inline void
563 {
564  session_t *s = session_get (tc->s_index, tc->thread_index);
565  if (svm_fifo_has_event (s->tx_fifo))
566  return;
568 }
569 
570 /*
571  * Listen sessions
572  */
573 
576 {
577  ASSERT (s->session_state == SESSION_STATE_LISTENING ||
578  session_get_transport_proto (s) == TRANSPORT_PROTO_QUIC);
579  return session_handle (s);
580 }
581 
584 {
585  return session_get_from_handle (handle);
586 }
587 
588 always_inline void
590  u32 * thread_index)
591 {
592  session_parse_handle (handle, index, thread_index);
593 }
594 
597 {
598  session_t *s;
599  s = session_alloc (thread_index);
600  s->session_type = type;
601  s->session_state = SESSION_STATE_LISTENING;
602  return s;
603 }
604 
607 {
608  return session_get (ls_index, 0);
609 }
610 
611 always_inline void
613 {
614  ASSERT (!s->rx_fifo);
615  session_free (s);
616 }
617 
619 
620 /*
621  * Session layer functions
622  */
623 
626 {
627  return &session_main;
628 }
629 
632 {
633  return &session_main.wrk[thread_index];
634 }
635 
636 static inline session_worker_t *
638 {
639  if (thread_index > vec_len (session_main.wrk))
640  return 0;
641  return &session_main.wrk[thread_index];
642 }
643 
646 {
647  return session_main.wrk[thread_index].vpp_event_queue;
648 }
649 
652 {
653  return session_main.is_enabled == 1;
654 }
655 
656 #define session_cli_return_if_not_enabled() \
657 do { \
658  if (!session_main.is_enabled) \
659  return clib_error_return (0, "session layer is not enabled"); \
660 } while (0)
661 
662 int session_main_flush_enqueue_events (u8 proto, u32 thread_index);
665 
666 /**
667  * Add session node pending buffer with custom node
668  *
669  * @param thread_index worker thread expected to send the buffer
670  * @param bi buffer index
671  * @param next_node next node edge index for buffer. Edge to next node
672  * must exist
673  */
674 always_inline void
675 session_add_pending_tx_buffer (u32 thread_index, u32 bi, u32 next_node)
676 {
677  session_worker_t *wrk = session_main_get_worker (thread_index);
678  vec_add1 (wrk->pending_tx_buffers, bi);
679  vec_add1 (wrk->pending_tx_nexts, next_node);
680 }
681 
683 void session_node_enable_disable (u8 is_en);
685 
687 
688 #endif /* __included_session_h__ */
689 
690 /*
691  * fd.io coding-style-patch-verification: ON
692  *
693  * Local Variables:
694  * eval: (c-set-style "gnu")
695  * End:
696  */
transport_connection_t * session_get_transport(session_t *s)
Definition: session.c:1631
session_t * session_alloc_for_connection(transport_connection_t *tc)
Definition: session.c:300
static void clib_rwlock_reader_lock(clib_rwlock_t *p)
Definition: lock.h:169
u32 preallocated_sessions
Preallocate session config parameter.
Definition: session.h:200
int session_enqueue_dgram_connection(session_t *s, session_dgram_hdr_t *hdr, vlib_buffer_t *b, u8 proto, u8 queue_event)
Definition: session.c:515
uword evt_qs_segment_size
Definition: session.h:183
u32 session_tx_fifo_dequeue_drop(transport_connection_t *tc, u32 max_bytes)
Definition: session.c:588
int session_tx_fifo_peek_bytes(transport_connection_t *tc, u8 *buffer, u32 offset, u32 max_bytes)
Definition: session.c:580
int session_listen(session_t *s, session_endpoint_cfg_t *sep)
Ask transport to listen on session endpoint.
Definition: session.c:1335
f64 clib_time_type_t
Definition: time.h:203
session_type_t session_type
Type built from transport and network protocol types.
static u32 transport_rx_fifo_size(transport_connection_t *tc)
Definition: session.h:523
int session_stream_accept_notify(transport_connection_t *tc)
Definition: session.c:1113
static clib_time_type_t transport_time_now(u32 thread_index)
Definition: session.h:544
svm_msg_q_t * vpp_event_queue
vpp event message queue for worker
Definition: session.h:80
static u32 svm_fifo_max_enqueue_prod(svm_fifo_t *f)
Maximum number of bytes that can be enqueued into fifo.
Definition: svm_fifo.h:550
transport_connection_t * listen_session_get_transport(session_t *s)
Definition: session.c:1654
u8 * format_session(u8 *s, va_list *args)
Format stream session as per the following format.
Definition: session_cli.c:101
transport_proto_t session_add_transport_proto(void)
Definition: session.c:1613
transport_proto
Definition: session.api:22
session_input_error_t
Definition: session.h:34
svm_fifo_t * tx_fifo
static u32 svm_fifo_size(svm_fifo_t *f)
Definition: svm_fifo.h:692
uword unformat_transport_connection(unformat_input_t *input, va_list *args)
Definition: session_cli.c:265
static u8 svm_fifo_has_ooo_data(svm_fifo_t *f)
Check if fifo has out-of-order data.
Definition: svm_fifo.h:656
u32 session_index
Index in thread pool where session was allocated.
unsigned long u64
Definition: types.h:89
struct session_tx_context_ session_tx_context_t
static svm_msg_q_t * session_main_get_vpp_event_queue(u32 thread_index)
Definition: session.h:645
u32 configured_v4_halfopen_table_buckets
Definition: session.h:188
u8 session_enable_asap
Enable session manager at startup.
Definition: session.h:172
#define clib_llist_add_tail(LP, name, E, H)
Add entry after tail.
Definition: llist.h:181
#define clib_memcpy_fast(a, b, c)
Definition: string.h:81
session_t * s
Definition: session.h:45
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
session_worker_t * wrk
Worker contexts.
Definition: session.h:143
static session_t * session_get_if_valid(u64 si, u32 thread_index)
Definition: session.h:314
static u32 session_get_index(session_t *s)
Definition: session.h:398
u32 ** session_to_enqueue
Per-proto vector of sessions to enqueue.
Definition: session.h:92
static session_t * listen_session_get_from_handle(session_handle_t handle)
Definition: session.h:583
int session_stop_listen(session_t *s)
Ask transport to stop listening on local transport endpoint.
Definition: session.c:1364
session_evt_ctrl_data_t * ctrl_evts_data
Pool of ctrl events data buffers.
Definition: session.h:104
session_evt_type_t
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:592
static transport_proto_t session_get_transport_proto(session_t *s)
static session_t * listen_session_alloc(u8 thread_index, session_type_t type)
Definition: session.h:596
void sesssion_reschedule_tx(transport_connection_t *tc)
Definition: session.c:150
void session_add_self_custom_tx_evt(transport_connection_t *tc, u8 has_prio)
Definition: session.c:122
static void session_pool_remove_peeker(u32 thread_index)
Definition: session.h:365
static session_t * session_get(u32 si, u32 thread_index)
Definition: session.h:307
session_evt_elt_t * event_elts
Pool of session event list elements.
Definition: session.h:101
static void * session_evt_ctrl_data(session_worker_t *wrk, session_evt_elt_t *elt)
Definition: session.h:266
u32 unique_segment_name_counter
Unique segment name counter.
Definition: session.h:149
static session_t * session_clone_safe(u32 session_index, u32 thread_index)
Definition: session.h:404
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:251
u32 local_endpoints_table_memory
Transport table (preallocation) size parameters.
Definition: session.h:196
uword unformat_session(unformat_input_t *input, va_list *args)
Definition: session_cli.c:234
vlib_node_registration_t session_queue_node
(constructor) VLIB_REGISTER_NODE (session_queue_node)
static void session_parse_handle(session_handle_t handle, u32 *index, u32 *thread_index)
int session_dgram_accept(transport_connection_t *tc, u32 listener_index, u32 thread_index)
Definition: session.c:1172
unsigned char u8
Definition: types.h:56
session_fifo_rx_fn session_tx_fifo_peek_and_snd
transport_send_params_t sp
Definition: session.h:48
u16 * pending_tx_nexts
Vector of nexts for the pending tx buffers.
Definition: session.h:122
u8 data[128]
Definition: ipsec_types.api:90
static u32 session_evt_ctrl_data_alloc(session_worker_t *wrk)
Definition: session.h:248
session_t * sessions
Worker session pool.
Definition: session.h:77
static clib_time_type_t transport_seconds_per_loop(u32 thread_index)
Definition: session.h:556
struct session_evt_elt session_evt_elt_t
static session_handle_t session_handle(session_t *s)
CLIB_CACHE_LINE_ALIGN_MARK(cacheline0)
static session_evt_elt_t * session_evt_elt_alloc(session_worker_t *wrk)
Definition: session.h:219
void session_transport_cleanup(session_t *s)
Cleanup transport and session state.
Definition: session.c:1485
session_t * session_alloc(u32 thread_index)
Definition: session.c:184
u8 session_type_t
u32 * tx_buffers
Vector of tx buffer free lists.
Definition: session.h:98
#define clib_llist_add(LP, name, E, H)
Add entry after head.
Definition: llist.h:172
static session_worker_t * session_main_get_worker(u32 thread_index)
Definition: session.h:631
vlib_node_registration_t session_queue_pre_input_node
(constructor) VLIB_REGISTER_NODE (session_queue_pre_input_node)
vlib_main_t * vm
Convenience pointer to this worker&#39;s vlib_main.
Definition: session.h:89
void session_send_rpc_evt_to_thread(u32 thread_index, void *fp, void *rpc_args)
Definition: session.c:110
void session_half_open_delete_notify(transport_proto_t tp, session_handle_t ho_handle)
Definition: session.c:292
void session_transport_closed_notify(transport_connection_t *tc)
Notification from transport that it is closed.
Definition: session.c:1063
static u32 svm_fifo_max_dequeue(svm_fifo_t *f)
Fifo max bytes to dequeue.
Definition: svm_fifo.h:459
clib_llist_index_t new_head
Head of list of elements.
Definition: session.h:110
static u32 svm_fifo_max_dequeue_cons(svm_fifo_t *f)
Fifo max bytes to dequeue optimized for consumer.
Definition: svm_fifo.h:430
u32 * session_type_to_next
Per session type output nodes.
Definition: session.h:157
int session_open(u32 app_index, session_endpoint_t *tep, u32 opaque)
Ask transport to open connection to remote transport endpoint.
Definition: session.c:1319
uword session_baseva
Session ssvm segment configs.
Definition: session.h:181
int session_dequeue_notify(session_t *s)
Definition: session.c:712
unsigned int u32
Definition: types.h:88
u64 session_segment_handle(session_t *s)
Definition: session.c:1561
f64 seconds_per_loop
Definition: main.h:292
struct _transport_proto_vft transport_proto_vft_t
u8 is_initialized
Session manager initialized (not necessarily enabled)
Definition: session.h:169
struct _session_endpoint_cfg session_endpoint_cfg_t
vl_api_fib_path_type_t type
Definition: fib_types.api:123
u32 configured_v6_halfopen_table_memory
Definition: session.h:193
void session_queue_run_on_main_thread(vlib_main_t *vm)
Definition: session.c:1661
u32 configured_v6_session_table_buckets
Definition: session.h:190
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:546
int session_stream_accept(transport_connection_t *tc, u32 listener_index, u32 thread_index, u8 notify)
Accept a stream session.
Definition: session.c:1137
session_event_t evt
Definition: session.h:64
uword session_va_space_size
Definition: session.h:182
u32 configured_v4_session_table_buckets
Session table size parameters.
Definition: session.h:186
static void clib_rwlock_reader_unlock(clib_rwlock_t *p)
Definition: lock.h:184
static session_t * session_get_from_handle(session_handle_t handle)
Definition: session.h:327
vl_api_ip_proto_t proto
Definition: acl_types.api:51
transport_proto_vft_t * transport_vft
Definition: session.h:46
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:1583
struct _unformat_input_t unformat_input_t
u32 configured_v6_halfopen_table_buckets
Definition: session.h:192
unsigned short u16
Definition: types.h:57
static void session_evt_ctrl_data_free(session_worker_t *wrk, session_evt_elt_t *elt)
Definition: session.h:273
u32 configured_event_queue_length
vpp fifo event queue configured length
Definition: session.h:178
void session_free(session_t *s)
Definition: session.c:210
u8 is_enabled
Session manager is enabled.
Definition: session.h:166
static u32 transport_max_rx_dequeue(transport_connection_t *tc)
Definition: session.h:516
#define SESSION_CTRL_MSG_MAX_SIZE
Definition: session_types.h:24
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:301
static 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:379
#define always_inline
Definition: ipsec.h:28
session_fifo_rx_fn ** session_tx_fns
Per transport rx function that can either dequeue or peek.
Definition: session.h:152
static session_evt_elt_t * session_evt_alloc_old(session_worker_t *wrk)
Definition: session.h:290
void session_reset(session_t *s)
Force a close without waiting for data to be flushed.
Definition: session.c:1415
static u64 listen_session_get_handle(session_t *s)
Definition: session.h:575
static void session_pool_add_peeker(u32 thread_index)
Acquires a lock that blocks a session pool from expanding.
Definition: session.h:356
clib_rwlock_t peekers_rw_locks
Peekers rw lock.
Definition: session.h:116
static session_t * session_get_from_handle_if_valid(session_handle_t handle)
Definition: session.h:336
void session_node_enable_disable(u8 is_en)
Definition: session.c:1759
clib_llist_anchor_t evt_list
Definition: session.h:63
session_fifo_rx_fn session_tx_fifo_dequeue_and_snd
ssvm_private_t evt_qs_segment
Event queues memfd segment.
Definition: session.h:146
static void session_evt_elt_free(session_worker_t *wrk, session_evt_elt_t *elt)
Definition: session.h:227
int session_dgram_connect_notify(transport_connection_t *tc, u32 old_thread_index, session_t **new_session)
Move dgram session to the right thread.
Definition: session.c:933
transport_proto_t last_transport_proto_type
Definition: session.h:159
static_always_inline uword vlib_get_thread_index(void)
Definition: threads.h:219
Unidirectional shared-memory multi-ring message queue.
session_main_t session_main
Definition: session.c:25
static u8 transport_rx_fifo_has_ooo_data(transport_connection_t *tc)
Definition: session.h:537
char * buffer
Definition: cJSON.h:163
void session_free_w_fifos(session_t *s)
Definition: session.c:261
struct _transport_connection transport_connection_t
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:298
static session_evt_elt_t * session_evt_alloc_new(session_worker_t *wrk)
Definition: session.h:280
void session_transport_delete_notify(transport_connection_t *tc)
Notification from transport that connection is being deleted.
Definition: session.c:997
struct session_worker_ session_worker_t
u32 * pending_tx_buffers
Vector of buffers to be sent.
Definition: session.h:119
struct session_main_ session_main_t
void session_cleanup_half_open(transport_proto_t tp, session_handle_t ho_handle)
Definition: session.c:286
static u32 session_thread_from_handle(session_handle_t handle)
vlib_main_t vlib_node_runtime_t * node
Definition: in2out_ed.c:1580
static clib_us_time_t transport_us_time_now(u32 thread_index)
Definition: session.h:550
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
Definition: session.c:1793
static u32 transport_max_tx_dequeue(transport_connection_t *tc)
Definition: session.h:509
static u32 session_index_from_handle(session_handle_t handle)
#define pool_put_index(p, i)
Free pool element with given index.
Definition: pool.h:330
#define ASSERT(truth)
void session_transport_reset_notify(transport_connection_t *tc)
Notify application that connection has been reset.
Definition: session.c:1098
int session_enqueue_notify(session_t *s)
Definition: session.c:674
void session_close(session_t *s)
Initialize session closing procedure.
Definition: session.c:1392
struct session_ctrl_evt_data_ session_evt_ctrl_data_t
int session_send_io_evt_to_thread(svm_fifo_t *f, session_evt_type_t evt_type)
Definition: session.c:79
int session_stream_connect_notify(transport_connection_t *tc, session_error_t err)
Definition: session.c:784
u8 session_is_valid(u32 si, u8 thread_index)
Definition: session.c:224
session_tx_context_t ctx
Context for session tx.
Definition: session.h:95
static void transport_add_tx_event(transport_connection_t *tc)
Definition: session.h:562
int session_send_io_evt_to_thread_custom(void *data, u32 thread_index, session_evt_type_t evt_type)
Definition: session.c:86
u32 clib_llist_index_t
Definition: llist.h:27
void session_transport_reset(session_t *s)
Force transport close.
Definition: session.c:1461
enum _transport_proto transport_proto_t
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:460
clib_time_type_t last_vlib_time
vlib_time_now last time around the track
Definition: session.h:83
u32 configured_v4_halfopen_table_memory
Definition: session.h:189
u32 configured_v4_session_table_memory
Definition: session.h:187
void session_send_rpc_evt_to_thread_force(u32 thread_index, void *fp, void *rpc_args)
Definition: session.c:102
session_dgram_hdr_t hdr
Definition: session.h:58
int() session_fifo_rx_fn(session_worker_t *wrk, vlib_node_runtime_t *node, session_evt_elt_t *e, int *n_tx_packets)
Definition: session.h:130
u8 thread_index
Index of the thread that allocated the session.
void session_get_endpoint(session_t *s, transport_endpoint_t *tep, u8 is_lcl)
Definition: session.c:1642
static void listen_session_free(session_t *s)
Definition: session.h:612
struct _vlib_node_registration vlib_node_registration_t
template key/value backing page structure
Definition: bihash_doc.h:44
u32 local_endpoints_table_buckets
Definition: session.h:197
enum session_q_process_evt_ session_q_process_evt_t
u64 session_handle_t
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
session_fifo_rx_fn session_tx_fifo_dequeue_internal
clib_llist_index_t old_head
Head of list of pending events.
Definition: session.h:113
volatile u8 session_state
State in session layer state machine.
VLIB buffer representation.
Definition: buffer.h:102
u64 uword
Definition: types.h:112
u8 poll_main
Poll session node in main thread.
Definition: session.h:175
static void session_evt_add_old(session_worker_t *wrk, session_evt_elt_t *elt)
Definition: session.h:233
u32 index
Definition: flow_types.api:221
int session_main_flush_all_enqueue_events(u8 transport_proto)
Definition: session.c:774
static void session_evt_add_head_old(session_worker_t *wrk, session_evt_elt_t *elt)
Definition: session.h:240
#define foreach_session_input_error
Definition: session.h:25
static session_evt_elt_t * session_evt_alloc_ctrl(session_worker_t *wrk)
Definition: session.h:256
transport_connection_t * tc
Definition: session.h:47
u32 configured_v6_session_table_memory
Definition: session.h:191
clib_us_time_t last_vlib_us_time
vlib_time_now rounded to us precision and as u64
Definition: session.h:86
vlib_node_registration_t session_queue_process_node
(constructor) VLIB_REGISTER_NODE (session_queue_process_node)
session_q_process_evt_
Definition: session.h:209
enum session_error_ session_error_t
static int svm_fifo_has_event(svm_fifo_t *f)
Check if fifo has io event.
Definition: svm_fifo.h:713
int session_main_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:742
u8 session_node_lookup_fifo_event(svm_fifo_t *f, session_event_t *e)
static session_main_t * vnet_get_session_main()
Definition: session.h:625
static u32 transport_max_rx_enqueue(transport_connection_t *tc)
Definition: session.h:502
u8 si
Definition: lisp_types.api:47
clib_llist_index_t ctrl_head
Head of control events list.
Definition: session.h:107
struct _session_endpoint session_endpoint_t
u64 clib_us_time_t
Definition: time.h:204
struct _svm_fifo svm_fifo_t
void session_transport_close(session_t *s)
Notify transport the session can be disconnected.
Definition: session.c:1433
void session_transport_closing_notify(transport_connection_t *tc)
Notification from transport that connection is being closed.
Definition: session.c:975
ssvm_private_t * session_main_get_evt_q_segment(void)
Definition: session.c:1555
static u32 transport_tx_fifo_size(transport_connection_t *tc)
Definition: session.h:530
static session_t * listen_session_get(u32 ls_index)
Definition: session.h:606
static void session_add_pending_tx_buffer(u32 thread_index, u32 bi, u32 next_node)
Add session node pending buffer with custom node.
Definition: session.h:675
static session_worker_t * session_main_get_worker_if_valid(u32 thread_index)
Definition: session.h:637
static u8 session_main_is_enabled()
Definition: session.h:651
static void listen_session_parse_handle(session_handle_t handle, u32 *index, u32 *thread_index)
Definition: session.h:589