FD.io VPP  v17.10-9-gd594711
Vector Packet Processing
segment_manager.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
17 #include <vnet/session/session.h>
19 
20 /**
21  * Counter used to build segment names
22  */
24 
25 /**
26  * Pool of segment managers
27  */
29 
30 /**
31  * Process private segment index
32  */
34 
35 /**
36  * Default fifo and segment size. TODO config.
37  */
40 
41 void
43 {
45  s = svm_fifo_segment_get_segment (index);
46  *name = s->h->segment_name;
47  *size = s->ssvm.ssvm_size;
48 }
49 
50 always_inline int
52  u8 * segment_name)
53 {
54  svm_fifo_segment_create_args_t _ca, *ca = &_ca;
55  int rv;
56 
57  memset (ca, 0, sizeof (*ca));
58 
59  if (!sm->properties->use_private_segment)
60  {
61  ca->segment_name = (char *) segment_name;
62  ca->segment_size = segment_size;
63  ca->rx_fifo_size = sm->properties->rx_fifo_size;
64  ca->tx_fifo_size = sm->properties->tx_fifo_size;
65  ca->preallocated_fifo_pairs = sm->properties->preallocated_fifo_pairs;
66 
67  rv = svm_fifo_segment_create (ca);
68  if (rv)
69  {
70  clib_warning ("svm_fifo_segment_create ('%s', %d) failed",
71  ca->segment_name, ca->segment_size);
72  return VNET_API_ERROR_SVM_SEGMENT_CREATE_FAIL;
73  }
74  }
75  else
76  {
77  u32 rx_fifo_size, tx_fifo_size, rx_rounded_data_size,
78  tx_rounded_data_size;
79  u32 approx_segment_count;
80  u64 approx_total_size;
81 
82  ca->segment_name = "process-private-segment";
83  ca->segment_size = ~0;
84  ca->rx_fifo_size = sm->properties->rx_fifo_size;
85  ca->tx_fifo_size = sm->properties->tx_fifo_size;
86  ca->preallocated_fifo_pairs = sm->properties->preallocated_fifo_pairs;
87  ca->private_segment_count = sm->properties->private_segment_count;
88  ca->private_segment_size = sm->properties->private_segment_size;
89 
90  /* Default to a small private segment */
91  if (ca->private_segment_size == 0)
92  ca->private_segment_size = 128 << 20;
93 
94  /* Calculate space requirements */
95  rx_rounded_data_size = (1 << (max_log2 (ca->rx_fifo_size)));
96  tx_rounded_data_size = (1 << (max_log2 (ca->tx_fifo_size)));
97 
98  rx_fifo_size = sizeof (svm_fifo_t) + rx_rounded_data_size;
99  tx_fifo_size = sizeof (svm_fifo_t) + tx_rounded_data_size;
100 
101  approx_total_size = (u64) ca->preallocated_fifo_pairs
102  * (rx_fifo_size + tx_fifo_size);
103  approx_segment_count =
104  (approx_total_size +
105  (ca->private_segment_size - 1)) / (u64) ca->private_segment_size;
106 
107  /* The user asked us to figure it out... */
108  if (ca->private_segment_count == 0)
109  {
110  ca->private_segment_count = approx_segment_count;
111  }
112  /* Follow directions, but issue a warning */
113  else if (approx_segment_count != ca->private_segment_count)
114  {
116  ("Honoring segment count %u, but calculated count was %u",
117  ca->private_segment_count, approx_segment_count);
118  }
119 
121  clib_warning ("Failed to create process private segment");
122 
124  }
125  vec_append (sm->segment_indices, ca->new_segment_indices);
127  return 0;
128 }
129 
130 int
132 {
133  u8 *segment_name;
134  svm_fifo_segment_create_args_t _ca, *ca = &_ca;
135  u32 add_segment_size;
136  int rv;
137 
138  memset (ca, 0, sizeof (*ca));
139  segment_name = format (0, "%d-%d%c", getpid (), segment_name_counter++, 0);
140  add_segment_size = sm->properties->add_segment_size ?
141  sm->properties->add_segment_size : default_segment_size;
142 
143  rv = session_manager_add_segment_i (sm, add_segment_size, segment_name);
144  vec_free (segment_name);
145  return rv;
146 }
147 
148 int
150 {
151  u8 *segment_name;
152  int rv;
153 
154  segment_name = format (0, "%d-%d%c", getpid (), segment_name_counter++, 0);
155  rv = session_manager_add_segment_i (sm, segment_size, segment_name);
156  vec_free (segment_name);
157  return rv;
158 }
159 
162 {
163  segment_manager_t *sm;
165  memset (sm, 0, sizeof (*sm));
166  return sm;
167 }
168 
169 /**
170  * Initializes segment manager based on options provided.
171  * Returns error if svm segment allocation fails.
172  */
173 int
175  segment_manager_properties_t * properties,
176  u32 first_seg_size)
177 {
178  int rv;
179 
180  /* app allocates these */
181  sm->properties = properties;
182 
183  first_seg_size = first_seg_size > 0 ? first_seg_size : default_segment_size;
184 
185  rv = session_manager_add_first_segment (sm, first_seg_size);
186  if (rv)
187  {
188  clib_warning ("Failed to allocate segment");
189  return rv;
190  }
191 
192  clib_spinlock_init (&sm->lockp);
193  return 0;
194 }
195 
196 u8
198 {
200  int i;
201 
202  for (i = 0; i < vec_len (sm->segment_indices); i++)
203  {
204  segment = svm_fifo_segment_get_segment (sm->segment_indices[i]);
205  if (CLIB_DEBUG && i && !svm_fifo_segment_has_fifos (segment)
206  && !(segment->h->flags & FIFO_SEGMENT_F_IS_PREALLOCATED))
207  clib_warning ("segment %d has no fifos!", sm->segment_indices[i]);
208  if (svm_fifo_segment_has_fifos (segment))
209  return 1;
210  }
211  return 0;
212 }
213 
214 static u8
216 {
217  return (sm->app_index == SEGMENT_MANAGER_INVALID_APP_INDEX);
218 }
219 
220 static void
222 {
223  svm_fifo_segment_private_t *fifo_segment;
224  u32 svm_segment_index;
225  clib_spinlock_lock (&sm->lockp);
226  svm_segment_index = sm->segment_indices[segment_index];
227  fifo_segment = svm_fifo_segment_get_segment (svm_segment_index);
228  if (!fifo_segment
229  || ((fifo_segment->h->flags & FIFO_SEGMENT_F_IS_PREALLOCATED)
231  {
232  clib_spinlock_unlock (&sm->lockp);
233  return;
234  }
235  svm_fifo_segment_delete (fifo_segment);
236  vec_del1 (sm->segment_indices, segment_index);
237  clib_spinlock_unlock (&sm->lockp);
238 }
239 
240 /**
241  * Initiate disconnects for all sessions 'owned' by a segment manager
242  */
243 void
245 {
246  int j;
247  svm_fifo_segment_private_t *fifo_segment;
248  svm_fifo_t *fifo;
249 
250  ASSERT (vec_len (sm->segment_indices));
251 
252  /* Across all fifo segments used by the server */
253  for (j = 0; j < vec_len (sm->segment_indices); j++)
254  {
255  fifo_segment = svm_fifo_segment_get_segment (sm->segment_indices[j]);
256  fifo = svm_fifo_segment_get_fifo_list (fifo_segment);
257 
258  /*
259  * Remove any residual sessions from the session lookup table
260  * Don't bother deleting the individual fifos, we're going to
261  * throw away the fifo segment in a minute.
262  */
263  while (fifo)
264  {
265  u32 session_index, thread_index;
266  stream_session_t *session;
267 
268  session_index = fifo->master_session_index;
269  thread_index = fifo->master_thread_index;
270  session = stream_session_get (session_index, thread_index);
271 
272  /* Instead of directly removing the session call disconnect */
273  if (session->session_state != SESSION_STATE_CLOSED)
274  {
275  session->session_state = SESSION_STATE_CLOSED;
277  (session),
279  thread_index);
280  }
281  fifo = fifo->next;
282  }
283 
284  /* Instead of removing the segment, test when cleaning up disconnected
285  * sessions if the segment can be removed.
286  */
287  }
288 }
289 
290 /**
291  * Removes segment manager.
292  *
293  * Since the fifos allocated in the segment keep backpointers to the sessions
294  * prior to removing the segment, we call session disconnect. This
295  * subsequently propagates into transport.
296  */
297 void
299 {
300  int i;
301 
304 
305  /* If we have empty preallocated segments that haven't been removed, remove
306  * them now. Apart from that, the first segment in the first segment manager
307  * is not removed when all fifos are removed. It can only be removed when
308  * the manager is explicitly deleted/detached by the app. */
309  for (i = vec_len (sm->segment_indices) - 1; i >= 0; i--)
310  {
311  if (CLIB_DEBUG)
312  {
314  segment = svm_fifo_segment_get_segment (sm->segment_indices[i]);
315  ASSERT (!svm_fifo_segment_has_fifos (segment));
316  }
318  }
319  clib_spinlock_free (&sm->lockp);
320  if (CLIB_DEBUG)
321  memset (sm, 0xfe, sizeof (*sm));
323 }
324 
325 void
327 {
328  if (segment_manager_has_fifos (sm))
330  else
331  {
332  ASSERT (!sm->first_is_protected || segment_manager_app_detached (sm));
333  segment_manager_del (sm);
334  }
335 }
336 
337 int
339  svm_fifo_t ** server_rx_fifo,
340  svm_fifo_t ** server_tx_fifo,
341  u32 * fifo_segment_index)
342 {
343  svm_fifo_segment_private_t *fifo_segment;
344  u32 fifo_size, sm_index;
345  u8 added_a_segment = 0;
346  int i;
347 
348  ASSERT (vec_len (sm->segment_indices));
349 
350  /* Make sure we don't have multiple threads trying to allocate segments
351  * at the same time. */
352  clib_spinlock_lock (&sm->lockp);
353 
354  /* Allocate svm fifos */
355 again:
356  for (i = 0; i < vec_len (sm->segment_indices); i++)
357  {
358  *fifo_segment_index = sm->segment_indices[i];
359  fifo_segment = svm_fifo_segment_get_segment (*fifo_segment_index);
360 
361  fifo_size = sm->properties->rx_fifo_size;
362  fifo_size = (fifo_size == 0) ? default_fifo_size : fifo_size;
363  *server_rx_fifo =
364  svm_fifo_segment_alloc_fifo (fifo_segment, fifo_size,
366 
367  fifo_size = sm->properties->tx_fifo_size;
368  fifo_size = (fifo_size == 0) ? default_fifo_size : fifo_size;
369  *server_tx_fifo =
370  svm_fifo_segment_alloc_fifo (fifo_segment, fifo_size,
372 
373  if (*server_rx_fifo == 0)
374  {
375  /* This would be very odd, but handle it... */
376  if (*server_tx_fifo != 0)
377  {
378  svm_fifo_segment_free_fifo (fifo_segment, *server_tx_fifo,
380  *server_tx_fifo = 0;
381  }
382  continue;
383  }
384  if (*server_tx_fifo == 0)
385  {
386  if (*server_rx_fifo != 0)
387  {
388  svm_fifo_segment_free_fifo (fifo_segment, *server_rx_fifo,
390  *server_rx_fifo = 0;
391  }
392  continue;
393  }
394  break;
395  }
396 
397  /* See if we're supposed to create another segment */
398  if (*server_rx_fifo == 0)
399  {
400  if (sm->properties->add_segment && !sm->properties->use_private_segment)
401  {
402  if (added_a_segment)
403  {
404  clib_warning ("added a segment, still can't allocate a fifo");
405  clib_spinlock_unlock (&sm->lockp);
406  return SESSION_ERROR_NEW_SEG_NO_SPACE;
407  }
408 
410  {
411  clib_spinlock_unlock (&sm->lockp);
412  return VNET_API_ERROR_URI_FIFO_CREATE_FAILED;
413  }
414 
415  added_a_segment = 1;
416  goto again;
417  }
418  else
419  {
420  clib_warning ("No space to allocate fifos!");
421  clib_spinlock_unlock (&sm->lockp);
422  return SESSION_ERROR_NO_SPACE;
423  }
424  }
425 
426  /* Backpointers to segment manager */
427  sm_index = segment_manager_index (sm);
428  (*server_tx_fifo)->segment_manager = sm_index;
429  (*server_rx_fifo)->segment_manager = sm_index;
430 
431  clib_spinlock_unlock (&sm->lockp);
432 
433  if (added_a_segment)
434  return application_add_segment_notify (sm->app_index,
435  *fifo_segment_index);
436 
437  return 0;
438 }
439 
440 void
441 segment_manager_dealloc_fifos (u32 svm_segment_index, svm_fifo_t * rx_fifo,
442  svm_fifo_t * tx_fifo)
443 {
444  segment_manager_t *sm;
445  svm_fifo_segment_private_t *fifo_segment;
446  u32 i, segment_index = ~0;
447  u8 is_first;
448 
449  sm = segment_manager_get_if_valid (rx_fifo->segment_manager);
450 
451  /* It's possible to have no segment manager if the session was removed
452  * as result of a detach. */
453  if (!sm)
454  return;
455 
456  fifo_segment = svm_fifo_segment_get_segment (svm_segment_index);
457  svm_fifo_segment_free_fifo (fifo_segment, rx_fifo,
459  svm_fifo_segment_free_fifo (fifo_segment, tx_fifo,
461 
462  /*
463  * Try to remove svm segment if it has no fifos. This can be done only if
464  * the segment is not the first in the segment manager or if it is first
465  * and it is not protected. Moreover, if the segment is first and the app
466  * has detached from the segment manager, remove the segment manager.
467  */
468  if (!svm_fifo_segment_has_fifos (fifo_segment))
469  {
470  is_first = sm->segment_indices[0] == svm_segment_index;
471 
472  /* Remove segment if it holds no fifos or first but not protected */
473  if (!is_first || !sm->first_is_protected)
474  {
475  /* Find the segment manager segment index */
476  for (i = 0; i < vec_len (sm->segment_indices); i++)
477  if (sm->segment_indices[i] == svm_segment_index)
478  {
479  segment_index = i;
480  break;
481  }
482  ASSERT (segment_index != (u32) ~ 0);
483  segment_manager_del_segment (sm, segment_index);
484  }
485 
486  /* Remove segment manager if no sessions and detached from app */
488  && !segment_manager_has_fifos (sm))
489  segment_manager_del (sm);
490  }
491 }
492 
493 /**
494  * Allocates shm queue in the first segment
495  */
498 {
502  void *oldheap;
503 
504  ASSERT (sm->segment_indices != 0);
505 
506  segment = svm_fifo_segment_get_segment (sm->segment_indices[0]);
507  sh = segment->ssvm.sh;
508 
509  oldheap = ssvm_push_heap (sh);
510  q = unix_shared_memory_queue_init (queue_size,
511  sizeof (session_fifo_event_t),
512  0 /* consumer pid */ ,
513  0 /* signal when queue non-empty */ );
514  ssvm_pop_heap (oldheap);
515  return q;
516 }
517 
518 /**
519  * Frees shm queue allocated in the first segment
520  */
521 void
524 {
527  void *oldheap;
528 
529  ASSERT (sm->segment_indices != 0);
530 
531  segment = svm_fifo_segment_get_segment (sm->segment_indices[0]);
532  sh = segment->ssvm.sh;
533 
534  oldheap = ssvm_push_heap (sh);
536  ssvm_pop_heap (oldheap);
537 }
538 
539 static clib_error_t *
541  vlib_cli_command_t * cmd)
542 {
543  svm_fifo_segment_private_t *segments, *seg;
544  segment_manager_t *sm;
545  u8 show_segments = 0, verbose = 0, *name;
546  uword address;
547  u64 size;
548  u32 active_fifos;
549  u32 free_fifos;
550 
552 
554  {
555  if (unformat (input, "segments"))
556  show_segments = 1;
557  else if (unformat (input, "verbose"))
558  verbose = 1;
559  else
560  return clib_error_return (0, "unknown input `%U'",
561  format_unformat_error, input);
562  }
563  vlib_cli_output (vm, "%d segment managers allocated",
565  if (verbose && pool_elts (segment_managers))
566  {
567  vlib_cli_output (vm, "%-10s%=15s%=12s", "Index", "App Index",
568  "Segments");
569 
570  /* *INDENT-OFF* */
572  vlib_cli_output (vm, "%-10d%=15d%=12d", segment_manager_index(sm),
573  sm->app_index, vec_len (sm->segment_indices));
574  }));
575  /* *INDENT-ON* */
576 
577  }
578  if (show_segments)
579  {
580  segments = svm_fifo_segment_segments_pool ();
581  vlib_cli_output (vm, "%d svm fifo segments allocated",
582  pool_elts (segments));
583  vlib_cli_output (vm, "%-20s%=12s%=16s%=16s%=16s", "Name",
584  "HeapSize (M)", "ActiveFifos", "FreeFifos", "Address");
585 
586  /* *INDENT-OFF* */
587  pool_foreach (seg, segments, ({
588  if (seg->h->flags & FIFO_SEGMENT_F_IS_PRIVATE)
589  {
590  address = pointer_to_uword (seg->ssvm.sh->heap);
591  if (seg->h->flags & FIFO_SEGMENT_F_IS_MAIN_HEAP)
592  name = format (0, "main heap");
593  else
594  name = format (0, "private heap");
595  heap_header = mheap_header (seg->ssvm.sh->heap);
596  size = heap_header->max_size;
597  }
598  else
599  {
600  address = seg->ssvm.sh->ssvm_va;
601  size = seg->ssvm.ssvm_size;
602  name = seg->ssvm.sh->name;
603  }
604  active_fifos = svm_fifo_segment_num_fifos (seg);
605  free_fifos = svm_fifo_segment_num_free_fifos (seg, ~0 /* size */);
606  vlib_cli_output (vm, "%-20v%=16llu%=16u%=16u%16llx",
607  name, size >> 20ULL, active_fifos, free_fifos,
608  address);
609  if (verbose)
610  vlib_cli_output (vm, "%U",
611  format_svm_fifo_segment, seg, verbose);
612  if (seg->h->flags & FIFO_SEGMENT_F_IS_PRIVATE)
613  vec_free (name);
614  }));
615  /* *INDENT-ON* */
616 
617  }
618  return 0;
619 }
620 
621  /* *INDENT-OFF* */
622 VLIB_CLI_COMMAND (segment_manager_show_command, static) =
623 {
624  .path = "show segment-manager",
625  .short_help = "show segment-manager [segments][verbose]",
626  .function = segment_manager_show_fn,
627 };
628 /* *INDENT-ON* */
629 
630 /*
631  * fd.io coding-style-patch-verification: ON
632  *
633  * Local Variables:
634  * eval: (c-set-style "gnu")
635  * End:
636  */
u64 ssvm_size
Definition: ssvm.h:77
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:337
int application_add_segment_notify(u32 app_index, u32 fifo_segment_index)
Definition: application.c:409
static_always_inline void clib_spinlock_unlock(clib_spinlock_t *p)
Definition: lock.h:72
static_always_inline void clib_spinlock_lock(clib_spinlock_t *p)
Definition: lock.h:50
int segment_manager_alloc_session_fifos(segment_manager_t *sm, svm_fifo_t **server_rx_fifo, svm_fifo_t **server_tx_fifo, u32 *fifo_segment_index)
static segment_manager_t * segment_manager_get_if_valid(u32 index)
struct _segment_manager_properties segment_manager_properties_t
u32 default_segment_size
void unix_shared_memory_queue_free(unix_shared_memory_queue_t *q)
int session_manager_add_first_segment(segment_manager_t *sm, u32 segment_size)
segment_manager_t * segment_managers
Pool of segment managers.
#define FIFO_SEGMENT_F_IS_PREALLOCATED
static void segment_manager_del_segment(segment_manager_t *sm, u32 segment_index)
ssvm_shared_header_t * sh
Definition: ssvm.h:76
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:225
static void clib_spinlock_free(clib_spinlock_t *p)
Definition: lock.h:40
struct _svm_fifo svm_fifo_t
static int session_manager_add_segment_i(segment_manager_t *sm, u32 segment_size, u8 *segment_name)
void segment_manager_get_segment_info(u32 index, u8 **name, u32 *size)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:437
static u8 segment_manager_app_detached(segment_manager_t *sm)
#define always_inline
Definition: clib.h:84
static void * ssvm_push_heap(ssvm_shared_header_t *sh)
Definition: ssvm.h:134
#define clib_error_return(e, args...)
Definition: error.h:99
unix_shared_memory_queue_t * segment_manager_alloc_queue(segment_manager_t *sm, u32 queue_size)
Allocates shm queue in the first segment.
format_function_t format_svm_fifo_segment
unsigned long u64
Definition: types.h:89
struct _stream_session_t stream_session_t
u32 * private_segment_indices
Process private segment index.
static void ssvm_pop_heap(void *oldheap)
Definition: ssvm.h:142
void session_send_session_evt_to_thread(u64 session_handle, fifo_event_type_t evt_type, u32 thread_index)
Definition: session.c:730
segment_manager_t * segment_manager_new()
static void clib_spinlock_init(clib_spinlock_t *p)
Definition: lock.h:33
int svm_fifo_segment_create_process_private(svm_fifo_segment_create_args_t *a)
Create an svm fifo segment in process-private memory.
static svm_fifo_t * svm_fifo_segment_get_fifo_list(svm_fifo_segment_private_t *fifo_segment)
u32 svm_fifo_segment_num_fifos(svm_fifo_segment_private_t *fifo_segment)
Get number of active fifos.
u8 * segment_name
Segment name.
struct _unformat_input_t unformat_input_t
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:270
u8 segment_manager_has_fifos(segment_manager_t *sm)
#define vec_del1(v, i)
Delete the element at index I.
Definition: vec.h:801
svm_fifo_segment_header_t * h
#define FIFO_SEGMENT_F_IS_PRIVATE
#define SEGMENT_MANAGER_INVALID_APP_INDEX
static u8 svm_fifo_segment_has_fifos(svm_fifo_segment_private_t *fifo_segment)
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
vlib_main_t * vm
Definition: buffer.c:283
void segment_manager_dealloc_queue(segment_manager_t *sm, unix_shared_memory_queue_t *q)
Frees shm queue allocated in the first segment.
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:336
#define clib_warning(format, args...)
Definition: error.h:59
static svm_fifo_segment_private_t * svm_fifo_segment_get_segment(u32 segment_index)
static u32 segment_manager_index(segment_manager_t *sm)
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:154
void segment_manager_init_del(segment_manager_t *sm)
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
unix_shared_memory_queue_t * unix_shared_memory_queue_init(int nels, int elsize, int consumer_pid, int signal_when_queue_non_empty)
u64 size
Definition: vhost-user.h:76
#define vec_append(v1, v2)
Append v2 after v1.
Definition: vec.h:815
static heap_header_t * heap_header(void *v)
Definition: heap.h:161
void svm_fifo_segment_free_fifo(svm_fifo_segment_private_t *s, svm_fifo_t *f, svm_fifo_segment_freelist_t list_index)
int svm_fifo_segment_create(svm_fifo_segment_create_args_t *a)
(master) create an svm fifo segment
u64 uword
Definition: types.h:112
void segment_manager_del(segment_manager_t *sm)
Removes segment manager.
static u64 stream_session_handle(stream_session_t *s)
Definition: session.h:237
int segment_manager_init(segment_manager_t *sm, segment_manager_properties_t *properties, u32 first_seg_size)
Initializes segment manager based on options provided.
svm_fifo_segment_private_t * svm_fifo_segment_segments_pool(void)
Retrieve svm segments pool.
void segment_manager_dealloc_fifos(u32 svm_segment_index, svm_fifo_t *rx_fifo, svm_fifo_t *tx_fifo)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
static uword max_log2(uword x)
Definition: clib.h:228
u32 segment_name_counter
Counter used to build segment names.
void segment_manager_del_sessions(segment_manager_t *sm)
Initiate disconnects for all sessions &#39;owned&#39; by a segment manager.
struct _segment_manager segment_manager_t
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
u32 svm_fifo_segment_num_free_fifos(svm_fifo_segment_private_t *fifo_segment, u32 fifo_size_in_bytes)
static clib_error_t * segment_manager_show_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
int session_manager_add_segment(segment_manager_t *sm)
u32 default_fifo_size
Default fifo and segment size.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:680
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972
void svm_fifo_segment_delete(svm_fifo_segment_private_t *s)
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:169
struct _unix_shared_memory_queue unix_shared_memory_queue_t
static stream_session_t * stream_session_get(u32 si, u32 thread_index)
Definition: session.h:217
svm_fifo_t * svm_fifo_segment_alloc_fifo(svm_fifo_segment_private_t *s, u32 data_size_in_bytes, svm_fifo_segment_freelist_t list_index)
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:128