FD.io VPP  v20.09-64-g4f7b92f0a
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 initialized only if so configured */
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  /** Enable session manager at startup */
169 
170  /** vpp fifo event queue configured length */
172 
173  /** Session ssvm segment configs*/
178 
179  /** Session table size parameters */
188 
189  /** Transport table (preallocation) size parameters */
192 
193  /** Preallocate session config parameter */
195 
197 
202 
204 {
208 
209 #define TRANSPORT_PROTO_INVALID (session_main.last_transport_proto_type + 1)
210 #define TRANSPORT_N_PROTOS (session_main.last_transport_proto_type + 1)
211 
212 static inline session_evt_elt_t *
214 {
215  session_evt_elt_t *elt;
216  pool_get (wrk->event_elts, elt);
217  return elt;
218 }
219 
220 static inline void
222 {
223  pool_put (wrk->event_elts, elt);
224 }
225 
226 static inline void
228 {
229  clib_llist_add_tail (wrk->event_elts, evt_list, elt,
230  pool_elt_at_index (wrk->event_elts, wrk->old_head));
231 }
232 
233 static inline void
235 {
236  clib_llist_add (wrk->event_elts, evt_list, elt,
237  pool_elt_at_index (wrk->event_elts, wrk->old_head));
238 }
239 
240 
241 static inline u32
243 {
245  pool_get (wrk->ctrl_evts_data, data);
246  return (data - wrk->ctrl_evts_data);
247 }
248 
249 static inline session_evt_elt_t *
251 {
252  session_evt_elt_t *elt;
253  elt = session_evt_elt_alloc (wrk);
254  clib_llist_add_tail (wrk->event_elts, evt_list, elt,
255  pool_elt_at_index (wrk->event_elts, wrk->ctrl_head));
256  return elt;
257 }
258 
259 static inline void *
261 {
262  return (void *) (pool_elt_at_index (wrk->ctrl_evts_data,
263  elt->evt.ctrl_data_index));
264 }
265 
266 static inline void
268 {
269  ASSERT (elt->evt.event_type > SESSION_IO_EVT_BUILTIN_TX);
270  pool_put_index (wrk->ctrl_evts_data, elt->evt.ctrl_data_index);
271 }
272 
273 static inline session_evt_elt_t *
275 {
276  session_evt_elt_t *elt;
277  elt = session_evt_elt_alloc (wrk);
278  clib_llist_add_tail (wrk->event_elts, evt_list, elt,
279  pool_elt_at_index (wrk->event_elts, wrk->new_head));
280  return elt;
281 }
282 
283 static inline session_evt_elt_t *
285 {
286  session_evt_elt_t *elt;
287  elt = session_evt_elt_alloc (wrk);
288  clib_llist_add_tail (wrk->event_elts, evt_list, elt,
289  pool_elt_at_index (wrk->event_elts, wrk->old_head));
290  return elt;
291 }
292 
293 session_t *session_alloc (u32 thread_index);
294 void session_free (session_t * s);
297  session_handle_t ho_handle);
298 u8 session_is_valid (u32 si, u8 thread_index);
299 
301 session_get (u32 si, u32 thread_index)
302 {
303  ASSERT (session_is_valid (si, thread_index));
304  return pool_elt_at_index (session_main.wrk[thread_index].sessions, si);
305 }
306 
309 {
310  if (thread_index >= vec_len (session_main.wrk))
311  return 0;
312 
313  if (pool_is_free_index (session_main.wrk[thread_index].sessions, si))
314  return 0;
315 
316  ASSERT (session_is_valid (si, thread_index));
317  return pool_elt_at_index (session_main.wrk[thread_index].sessions, si);
318 }
319 
322 {
324  u32 session_index, thread_index;
325  session_parse_handle (handle, &session_index, &thread_index);
326  return pool_elt_at_index (smm->wrk[thread_index].sessions, session_index);
327 }
328 
331 {
332  u32 session_index, thread_index;
333  session_parse_handle (handle, &session_index, &thread_index);
334  return session_get_if_valid (session_index, thread_index);
335 }
336 
338 
339 /**
340  * Acquires a lock that blocks a session pool from expanding.
341  *
342  * This is typically used for safely peeking into other threads'
343  * pools in order to clone elements. Lock should be dropped as soon
344  * as possible by calling @ref session_pool_remove_peeker.
345  *
346  * NOTE: Avoid using pool_elt_at_index while the lock is held because
347  * it may lead to free elt bitmap expansion/contraction!
348  */
349 always_inline void
351 {
352  session_worker_t *wrk = &session_main.wrk[thread_index];
353  if (thread_index == vlib_get_thread_index ())
354  return;
356 }
357 
358 always_inline void
360 {
361  session_worker_t *wrk = &session_main.wrk[thread_index];
362  if (thread_index == vlib_get_thread_index ())
363  return;
365 }
366 
367 /**
368  * Get session from handle and 'lock' pool resize if not in same thread
369  *
370  * Caller should drop the peek 'lock' as soon as possible.
371  */
374 {
375  u32 thread_index = session_thread_from_handle (handle);
376  session_worker_t *wrk = &session_main.wrk[thread_index];
377 
378  if (thread_index == vlib_get_thread_index ())
379  {
380  return pool_elt_at_index (wrk->sessions,
381  session_index_from_handle (handle));
382  }
383  else
384  {
385  session_pool_add_peeker (thread_index);
386  /* Don't use pool_elt_at index. See @ref session_pool_add_peeker */
387  return wrk->sessions + session_index_from_handle (handle);
388  }
389 }
390 
393 {
394  return (s - session_main.wrk[s->thread_index].sessions);
395 }
396 
398 session_clone_safe (u32 session_index, u32 thread_index)
399 {
400  session_t *old_s, *new_s;
401  u32 current_thread_index = vlib_get_thread_index ();
402 
403  /* If during the memcpy pool is reallocated AND the memory allocator
404  * decides to give the old chunk of memory to somebody in a hurry to
405  * scribble something on it, we have a problem. So add this thread as
406  * a session pool peeker.
407  */
408  session_pool_add_peeker (thread_index);
409  new_s = session_alloc (current_thread_index);
410  old_s = session_main.wrk[thread_index].sessions + session_index;
411  clib_memcpy_fast (new_s, old_s, sizeof (*new_s));
412  session_pool_remove_peeker (thread_index);
413  new_s->thread_index = current_thread_index;
414  new_s->session_index = session_get_index (new_s);
415  return new_s;
416 }
417 
418 int session_open (u32 app_index, session_endpoint_t * tep, u32 opaque);
421 void session_close (session_t * s);
422 void session_reset (session_t * s);
427  session_evt_type_t evt_type);
430 int session_send_io_evt_to_thread_custom (void *data, u32 thread_index,
431  session_evt_type_t evt_type);
432 void session_send_rpc_evt_to_thread (u32 thread_index, void *fp,
433  void *rpc_args);
434 void session_send_rpc_evt_to_thread_force (u32 thread_index, void *fp,
435  void *rpc_args);
437  u8 has_prio);
441  u8 is_lcl);
442 
443 u8 *format_session (u8 * s, va_list * args);
444 uword unformat_session (unformat_input_t * input, va_list * args);
446  va_list * args);
447 
448 /*
449  * Interface to transport protos
450  */
451 
453  vlib_buffer_t * b, u32 offset,
454  u8 queue_event, u8 is_in_order);
456  session_dgram_hdr_t * hdr,
457  vlib_buffer_t * b, u8 proto,
458  u8 queue_event);
460  session_error_t err);
462  u32 old_thread_index,
463  session_t ** new_session);
468  session_handle_t ho_handle);
471 int session_stream_accept (transport_connection_t * tc, u32 listener_index,
472  u32 thread_index, u8 notify);
473 int session_dgram_accept (transport_connection_t * tc, u32 listener_index,
474  u32 thread_index);
475 /**
476  * Initialize session layer for given transport proto and ip version
477  *
478  * Allocates per session type (transport proto + ip version) data structures
479  * and adds arc from session queue node to session type output node.
480  *
481  * @param transport_proto transport proto to be registered
482  * @param vft virtual function table for transport
483  * @param is_ip4 flag that indicates if transports uses ipv4
484  * as underlying network layer
485  * @param output_node output node for transport
486  */
488  const transport_proto_vft_t * vft, u8 is_ip4,
489  u32 output_node);
492  u32 offset, u32 max_bytes);
494 
497 {
498  session_t *s = session_get (tc->s_index, tc->thread_index);
500 }
501 
504 {
505  session_t *s = session_get (tc->s_index, tc->thread_index);
507 }
508 
511 {
512  session_t *s = session_get (tc->s_index, tc->thread_index);
513  return svm_fifo_max_dequeue (s->rx_fifo);
514 }
515 
518 {
519  session_t *s = session_get (tc->s_index, tc->thread_index);
520  return svm_fifo_size (s->rx_fifo);
521 }
522 
525 {
526  session_t *s = session_get (tc->s_index, tc->thread_index);
527  return svm_fifo_size (s->tx_fifo);
528 }
529 
532 {
533  session_t *s = session_get (tc->c_index, tc->thread_index);
534  return svm_fifo_has_ooo_data (s->rx_fifo);
535 }
536 
538 transport_time_now (u32 thread_index)
539 {
540  return session_main.wrk[thread_index].last_vlib_time;
541 }
542 
545 {
546  return session_main.wrk[thread_index].last_vlib_us_time;
547 }
548 
549 always_inline void
551 {
552  session_t *s = session_get (tc->s_index, tc->thread_index);
553  if (svm_fifo_has_event (s->tx_fifo))
554  return;
556 }
557 
558 /*
559  * Listen sessions
560  */
561 
564 {
565  ASSERT (s->session_state == SESSION_STATE_LISTENING ||
566  session_get_transport_proto (s) == TRANSPORT_PROTO_QUIC);
567  return session_handle (s);
568 }
569 
572 {
573  return session_get_from_handle (handle);
574 }
575 
576 always_inline void
578  u32 * thread_index)
579 {
580  session_parse_handle (handle, index, thread_index);
581 }
582 
585 {
586  session_t *s;
587  s = session_alloc (thread_index);
588  s->session_type = type;
589  s->session_state = SESSION_STATE_LISTENING;
590  return s;
591 }
592 
595 {
596  return session_get (ls_index, 0);
597 }
598 
599 always_inline void
601 {
602  ASSERT (!s->rx_fifo);
603  session_free (s);
604 }
605 
607 
608 /*
609  * Session layer functions
610  */
611 
614 {
615  return &session_main;
616 }
617 
620 {
621  return &session_main.wrk[thread_index];
622 }
623 
624 static inline session_worker_t *
626 {
627  if (thread_index > vec_len (session_main.wrk))
628  return 0;
629  return &session_main.wrk[thread_index];
630 }
631 
634 {
635  return session_main.wrk[thread_index].vpp_event_queue;
636 }
637 
640 {
641  return session_main.is_enabled == 1;
642 }
643 
644 #define session_cli_return_if_not_enabled() \
645 do { \
646  if (!session_main.is_enabled) \
647  return clib_error_return (0, "session layer is not enabled"); \
648 } while (0)
649 
650 int session_main_flush_enqueue_events (u8 proto, u32 thread_index);
653 
654 /**
655  * Add session node pending buffer with custom node
656  *
657  * @param thread_index worker thread expected to send the buffer
658  * @param bi buffer index
659  * @param next_node next node edge index for buffer. Edge to next node
660  * must exist
661  */
662 always_inline void
663 session_add_pending_tx_buffer (u32 thread_index, u32 bi, u32 next_node)
664 {
665  session_worker_t *wrk = session_main_get_worker (thread_index);
666  vec_add1 (wrk->pending_tx_buffers, bi);
667  vec_add1 (wrk->pending_tx_nexts, next_node);
668 }
669 
671 void session_node_enable_disable (u8 is_en);
673 
675 
676 #endif /* __included_session_h__ */
677 
678 /*
679  * fd.io coding-style-patch-verification: ON
680  *
681  * Local Variables:
682  * eval: (c-set-style "gnu")
683  * End:
684  */
transport_connection_t * session_get_transport(session_t *s)
Definition: session.c:1620
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:167
u32 preallocated_sessions
Preallocate session config parameter.
Definition: session.h:194
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:176
u32 session_tx_fifo_dequeue_drop(transport_connection_t *tc, u32 max_bytes)
Definition: session.c:561
int session_tx_fifo_peek_bytes(transport_connection_t *tc, u8 *buffer, u32 offset, u32 max_bytes)
Definition: session.c:553
int session_listen(session_t *s, session_endpoint_cfg_t *sep)
Ask transport to listen on session endpoint.
Definition: session.c:1306
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:517
int session_stream_accept_notify(transport_connection_t *tc)
Definition: session.c:1086
static clib_time_type_t transport_time_now(u32 thread_index)
Definition: session.h:538
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:524
transport_connection_t * listen_session_get_transport(session_t *s)
Definition: session.c:1643
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:1602
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:666
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:630
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:633
u32 configured_v4_halfopen_table_buckets
Definition: session.h:182
u8 session_enable_asap
Enable session manager at startup.
Definition: session.h:168
#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:308
static u32 session_get_index(session_t *s)
Definition: session.h:392
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:571
int session_stop_listen(session_t *s)
Ask transport to stop listening on local transport endpoint.
Definition: session.c:1335
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:584
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:359
static session_t * session_get(u32 si, u32 thread_index)
Definition: session.h:301
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:260
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:398
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:252
u32 local_endpoints_table_memory
Transport table (preallocation) size parameters.
Definition: session.h:190
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:1145
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:89
static u32 session_evt_ctrl_data_alloc(session_worker_t *wrk)
Definition: session.h:242
session_t * sessions
Worker session pool.
Definition: session.h:77
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:213
void session_transport_cleanup(session_t *s)
Cleanup transport and session state.
Definition: session.c:1456
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:619
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:1036
static u32 svm_fifo_max_dequeue(svm_fifo_t *f)
Fifo max bytes to dequeue.
Definition: svm_fifo.h:433
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:404
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:1290
uword session_baseva
Session ssvm segment configs.
Definition: session.h:174
int session_dequeue_notify(session_t *s)
Definition: session.c:685
unsigned int u32
Definition: types.h:88
u64 session_segment_handle(session_t *s)
Definition: session.c:1550
struct _transport_proto_vft transport_proto_vft_t
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:187
void session_queue_run_on_main_thread(vlib_main_t *vm)
Definition: session.c:1650
u32 configured_v6_session_table_buckets
Definition: session.h:184
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:534
int session_stream_accept(transport_connection_t *tc, u32 listener_index, u32 thread_index, u8 notify)
Accept a stream session.
Definition: session.c:1110
session_event_t evt
Definition: session.h:64
uword session_va_space_size
Definition: session.h:175
u32 configured_v4_session_table_buckets
Session table size parameters.
Definition: session.h:180
static void clib_rwlock_reader_unlock(clib_rwlock_t *p)
Definition: lock.h:182
static session_t * session_get_from_handle(session_handle_t handle)
Definition: session.h:321
vl_api_ip_proto_t proto
Definition: acl_types.api:50
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:1572
struct _unformat_input_t unformat_input_t
u32 configured_v6_halfopen_table_buckets
Definition: session.h:186
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:267
u32 configured_event_queue_length
vpp fifo event queue configured length
Definition: session.h:171
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:510
#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:302
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:373
#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:284
void session_reset(session_t *s)
Force a close without waiting for data to be flushed.
Definition: session.c:1386
static u64 listen_session_get_handle(session_t *s)
Definition: session.h:563
static void session_pool_add_peeker(u32 thread_index)
Acquires a lock that blocks a session pool from expanding.
Definition: session.h:350
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:330
void session_node_enable_disable(u8 is_en)
Definition: session.c:1734
u8 evt_qs_use_memfd_seg
Definition: session.h:177
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 initialized only if so configured.
Definition: session.h:146
static void session_evt_elt_free(session_worker_t *wrk, session_evt_elt_t *elt)
Definition: session.h:221
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:906
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:531
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:299
static session_evt_elt_t * session_evt_alloc_new(session_worker_t *wrk)
Definition: session.h:274
void session_transport_delete_notify(transport_connection_t *tc)
Notification from transport that connection is being deleted.
Definition: session.c:970
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:1582
static clib_us_time_t transport_us_time_now(u32 thread_index)
Definition: session.h:544
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
Definition: session.c:1768
static u32 transport_max_tx_dequeue(transport_connection_t *tc)
Definition: session.h:503
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:331
#define ASSERT(truth)
void session_transport_reset_notify(transport_connection_t *tc)
Notify application that connection has been reset.
Definition: session.c:1071
int session_enqueue_notify(session_t *s)
Definition: session.c:647
void session_close(session_t *s)
Initialize session closing procedure.
Definition: session.c:1363
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:757
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:550
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:1432
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:183
u32 configured_v4_session_table_memory
Definition: session.h:181
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:1631
static void listen_session_free(session_t *s)
Definition: session.h:600
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:191
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
static void session_evt_add_old(session_worker_t *wrk, session_evt_elt_t *elt)
Definition: session.h:227
u32 index
Definition: flow_types.api:221
int session_main_flush_all_enqueue_events(u8 transport_proto)
Definition: session.c:747
static void session_evt_add_head_old(session_worker_t *wrk, session_evt_elt_t *elt)
Definition: session.h:234
#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:250
transport_connection_t * tc
Definition: session.h:47
u32 configured_v6_session_table_memory
Definition: session.h:185
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:203
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:687
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:715
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:613
static u32 transport_max_rx_enqueue(transport_connection_t *tc)
Definition: session.h:496
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:1404
void session_transport_closing_notify(transport_connection_t *tc)
Notification from transport that connection is being closed.
Definition: session.c:948
ssvm_private_t * session_main_get_evt_q_segment(void)
Definition: session.c:1541
static u32 transport_tx_fifo_size(transport_connection_t *tc)
Definition: session.h:524
static session_t * listen_session_get(u32 ls_index)
Definition: session.h:594
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:663
static session_worker_t * session_main_get_worker_if_valid(u32 thread_index)
Definition: session.h:625
static u8 session_main_is_enabled()
Definition: session.h:639
static void listen_session_parse_handle(session_handle_t handle, u32 *index, u32 *thread_index)
Definition: session.h:577