FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
buffer.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 /*
16  * buffer.c: allocate/free network buffers.
17  *
18  * Copyright (c) 2008 Eliot Dresselhaus
19  *
20  * Permission is hereby granted, free of charge, to any person obtaining
21  * a copy of this software and associated documentation files (the
22  * "Software"), to deal in the Software without restriction, including
23  * without limitation the rights to use, copy, modify, merge, publish,
24  * distribute, sublicense, and/or sell copies of the Software, and to
25  * permit persons to whom the Software is furnished to do so, subject to
26  * the following conditions:
27  *
28  * The above copyright notice and this permission notice shall be
29  * included in all copies or substantial portions of the Software.
30  *
31  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
35  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
36  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
37  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38  */
39 
40 /**
41  * @file
42  *
43  * Allocate/free network buffers.
44  */
45 
46 #include <vppinfra/linux/sysfs.h>
47 #include <vlib/vlib.h>
48 #include <vlib/unix/unix.h>
49 #include <vpp/stats/stat_segment.h>
50 
51 #define VLIB_BUFFER_DEFAULT_BUFFERS_PER_NUMA 16384
52 #define VLIB_BUFFER_DEFAULT_BUFFERS_PER_NUMA_UNPRIV 8192
53 
54 #ifdef CLIB_HAVE_VEC128
55 /* Assumptions by vlib_buffer_free_inline: */
57 STATIC_ASSERT_FITS_IN (vlib_buffer_t, ref_count, 16);
58 STATIC_ASSERT_FITS_IN (vlib_buffer_t, buffer_pool_index, 16);
59 #endif
60 
61 /* Make sure that buffer template size is not accidentally changed */
62 STATIC_ASSERT_OFFSET_OF (vlib_buffer_t, template_end, 64);
63 
64 u16 __vlib_buffer_external_hdr_size = 0;
65 
66 static void
68  u32 index);
69 
70 static void
72  u32 index);
73 
74 static void
76 
77 uword
79  vlib_buffer_t * b_first)
80 {
81  vlib_buffer_t *b = b_first;
82  uword l_first = b_first->current_length;
83  uword l = 0;
84  while (b->flags & VLIB_BUFFER_NEXT_PRESENT)
85  {
87  l += b->current_length;
88  }
90  b_first->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;
91  return l + l_first;
92 }
93 
94 u8 *
95 format_vlib_buffer_no_chain (u8 * s, va_list * args)
96 {
97  vlib_buffer_t *b = va_arg (*args, vlib_buffer_t *);
98  u32 indent = format_get_indent (s);
99  u8 *a = 0;
100 
101 #define _(bit, name, v) \
102  if (v && (b->flags & VLIB_BUFFER_##name)) \
103  a = format (a, "%s ", v);
105 #undef _
106  s = format (s, "current data %d, length %d, buffer-pool %d, "
107  "ref-count %u", b->current_data, b->current_length,
109 
110  if (b->flags & VLIB_BUFFER_TOTAL_LENGTH_VALID)
111  s = format (s, ", totlen-nifb %d",
113 
114  if (b->flags & VLIB_BUFFER_IS_TRACED)
115  s = format (s, ", trace handle 0x%x", b->trace_handle);
116 
117  if (a)
118  s = format (s, "\n%U%v", format_white_space, indent, a);
119  vec_free (a);
120 
121  return s;
122 }
123 
124 u8 *
125 format_vlib_buffer (u8 * s, va_list * args)
126 {
128  vlib_buffer_t *b = va_arg (*args, vlib_buffer_t *);
129  u32 indent = format_get_indent (s);
130 
131  s = format (s, "%U", format_vlib_buffer_no_chain, b);
132 
133  while (b->flags & VLIB_BUFFER_NEXT_PRESENT)
134  {
135  u32 next_buffer = b->next_buffer;
136  b = vlib_get_buffer (vm, next_buffer);
137 
138  s =
139  format (s, "\n%Unext-buffer 0x%x, segment length %d, ref-count %u",
140  format_white_space, indent, next_buffer, b->current_length,
141  b->ref_count);
142  }
143 
144  return s;
145 }
146 
147 u8 *
148 format_vlib_buffer_and_data (u8 * s, va_list * args)
149 {
150  vlib_buffer_t *b = va_arg (*args, vlib_buffer_t *);
151 
152  s = format (s, "%U, %U",
155 
156  return s;
157 }
158 
159 static u8 *
160 format_vlib_buffer_known_state (u8 * s, va_list * args)
161 {
163  char *t;
164 
165  switch (state)
166  {
167  case VLIB_BUFFER_UNKNOWN:
168  t = "unknown";
169  break;
170 
172  t = "known-allocated";
173  break;
174 
176  t = "known-free";
177  break;
178 
179  default:
180  t = "invalid";
181  break;
182  }
183 
184  return format (s, "%s", t);
185 }
186 
187 u8 *
188 format_vlib_buffer_contents (u8 * s, va_list * va)
189 {
190  vlib_main_t *vm = va_arg (*va, vlib_main_t *);
191  vlib_buffer_t *b = va_arg (*va, vlib_buffer_t *);
192 
193  while (1)
194  {
196  if (!(b->flags & VLIB_BUFFER_NEXT_PRESENT))
197  break;
199  }
200 
201  return s;
202 }
203 
204 static u8 *
206  u32 bi,
207  uword follow_buffer_next, uword ** unique_hash)
208 {
211 
212  if (vec_len (bm->buffer_pools) <= b->buffer_pool_index)
213  return format (0, "unknown buffer pool 0x%x", b->buffer_pool_index);
214 
215  if ((signed) b->current_data < (signed) -VLIB_BUFFER_PRE_DATA_SIZE)
216  return format (0, "current data %d before pre-data", b->current_data);
217 
218  if (b->current_data + b->current_length >
220  return format (0, "%d-%d beyond end of buffer %d", b->current_data,
222 
223  if (follow_buffer_next && (b->flags & VLIB_BUFFER_NEXT_PRESENT))
224  {
226  u8 *msg, *result;
227 
230  return format (0, "next 0x%x: %U",
232 
233  if (unique_hash)
234  {
235  if (hash_get (*unique_hash, b->next_buffer))
236  return format (0, "duplicate buffer 0x%x", b->next_buffer);
237 
238  hash_set1 (*unique_hash, b->next_buffer);
239  }
240 
241  msg = vlib_validate_buffer (vm, b->next_buffer, follow_buffer_next);
242  if (msg)
243  {
244  result = format (0, "next 0x%x: %v", b->next_buffer, msg);
245  vec_free (msg);
246  return result;
247  }
248  }
249 
250  return 0;
251 }
252 
253 u8 *
254 vlib_validate_buffer (vlib_main_t * vm, u32 bi, uword follow_buffer_next)
255 {
256  return vlib_validate_buffer_helper (vm, bi, follow_buffer_next,
257  /* unique_hash */ 0);
258 }
259 
260 u8 *
262  u32 * buffers,
263  uword next_buffer_stride,
265  vlib_buffer_known_state_t known_state,
266  uword follow_buffer_next)
267 {
268  uword i, *hash;
269  u32 bi, *b = buffers;
271  u8 *msg = 0, *result = 0;
272 
273  hash = hash_create (0, 0);
274  for (i = 0; i < n_buffers; i++)
275  {
276  bi = b[0];
277  b += next_buffer_stride;
278 
279  /* Buffer is not unique. */
280  if (hash_get (hash, bi))
281  {
282  msg = format (0, "not unique");
283  goto done;
284  }
285 
286  k = vlib_buffer_is_known (vm, bi);
287  if (k != known_state)
288  {
289  msg = format (0, "is %U; expected %U",
291  format_vlib_buffer_known_state, known_state);
292  goto done;
293  }
294 
295  msg = vlib_validate_buffer_helper (vm, bi, follow_buffer_next, &hash);
296  if (msg)
297  goto done;
298 
299  hash_set1 (hash, bi);
300  }
301 
302 done:
303  if (msg)
304  {
305  result = format (0, "0x%x: %v", bi, msg);
306  vec_free (msg);
307  }
308  hash_free (hash);
309  return result;
310 }
311 
312 /* When debugging validate that given buffers are either known allocated
313  or known free. */
314 void
316  u32 * buffers,
318  vlib_buffer_known_state_t expected_state)
319 {
321  u32 *b;
322  uword i, bi, is_free;
323 
324  if (CLIB_DEBUG == 0)
325  return;
326 
327  is_free = expected_state == VLIB_BUFFER_KNOWN_ALLOCATED;
328  b = buffers;
329  for (i = 0; i < n_buffers; i++)
330  {
332 
333  bi = b[0];
334  b += 1;
335  known = vlib_buffer_is_known (vm, bi);
336 
337  if (known == VLIB_BUFFER_UNKNOWN &&
338  expected_state == VLIB_BUFFER_KNOWN_FREE)
339  known = VLIB_BUFFER_KNOWN_FREE;
340 
341  if (known != expected_state)
342  {
343  clib_panic ("%s %U buffer 0x%x", is_free ? "freeing" : "allocating",
344  format_vlib_buffer_known_state, known, bi);
345  }
346 
351  }
352 }
353 
354 void
357  void *packet_data,
358  uword n_packet_data_bytes,
359  uword min_n_buffers_each_alloc, char *fmt, ...)
360 {
361  va_list va;
362 
363  va_start (va, fmt);
364  t->name = va_format (0, fmt, &va);
365  va_end (va);
366 
368 
369  clib_memset (t, 0, sizeof (t[0]));
370 
371  vec_add (t->packet_data, packet_data, n_packet_data_bytes);
372  t->min_n_buffers_each_alloc = min_n_buffers_each_alloc;
374 }
375 
376 void *
378  vlib_packet_template_t * t, u32 * bi_result)
379 {
380  u32 bi;
381  vlib_buffer_t *b;
382 
383  if (vlib_buffer_alloc (vm, &bi, 1) != 1)
384  return 0;
385 
386  *bi_result = bi;
387 
388  b = vlib_get_buffer (vm, bi);
390  t->packet_data, vec_len (t->packet_data));
392 
393  return b->data;
394 }
395 
396 /* Append given data to end of buffer, possibly allocating new buffers. */
397 int
398 vlib_buffer_add_data (vlib_main_t * vm, u32 * buffer_index, void *data,
399  u32 n_data_bytes)
400 {
401  u32 n_buffer_bytes, n_left, n_left_this_buffer, bi;
402  vlib_buffer_t *b;
403  void *d;
404 
405  bi = *buffer_index;
406  if (bi == ~0 && 1 != vlib_buffer_alloc (vm, &bi, 1))
407  goto out_of_buffers;
408 
409  d = data;
410  n_left = n_data_bytes;
411  n_buffer_bytes = vlib_buffer_get_default_data_size (vm);
412 
413  b = vlib_get_buffer (vm, bi);
414  b->flags &= ~VLIB_BUFFER_TOTAL_LENGTH_VALID;
415 
416  /* Get to the end of the chain before we try to append data... */
417  while (b->flags & VLIB_BUFFER_NEXT_PRESENT)
419 
420  while (1)
421  {
422  u32 n;
423 
424  ASSERT (n_buffer_bytes >= b->current_length);
425  n_left_this_buffer =
426  n_buffer_bytes - (b->current_data + b->current_length);
427  n = clib_min (n_left_this_buffer, n_left);
429  n);
430  b->current_length += n;
431  n_left -= n;
432  if (n_left == 0)
433  break;
434 
435  d += n;
436  if (1 != vlib_buffer_alloc (vm, &b->next_buffer, 1))
437  goto out_of_buffers;
438 
439  b->flags |= VLIB_BUFFER_NEXT_PRESENT;
440 
442  }
443 
444  *buffer_index = bi;
445  return 0;
446 
447 out_of_buffers:
448  clib_warning ("out of buffers");
449  return 1;
450 }
451 
452 u16
455  vlib_buffer_t ** last, void *data,
456  u16 data_len)
457 {
458  vlib_buffer_t *l = *last;
459  u32 n_buffer_bytes = vlib_buffer_get_default_data_size (vm);
460  u16 copied = 0;
461  ASSERT (n_buffer_bytes >= l->current_length + l->current_data);
462  while (data_len)
463  {
464  u16 max = n_buffer_bytes - l->current_length - l->current_data;
465  if (max == 0)
466  {
467  if (1 != vlib_buffer_alloc_from_pool (vm, &l->next_buffer, 1,
468  first->buffer_pool_index))
469  return copied;
471  max = n_buffer_bytes - l->current_length - l->current_data;
472  }
473 
474  u16 len = (data_len > max) ? max : data_len;
476  data + copied, len);
478  data_len -= len;
479  copied += len;
480  }
481  return copied;
482 }
483 
484 static uword
485 vlib_buffer_alloc_size (uword ext_hdr_size, uword data_size)
486 {
487  uword alloc_size = ext_hdr_size + sizeof (vlib_buffer_t) + data_size;
488  alloc_size = CLIB_CACHE_LINE_ROUND (alloc_size);
489 
490  /* in case when we have even number of cachelines, we add one more for
491  * better cache occupancy */
492  alloc_size |= CLIB_CACHE_LINE_BYTES;
493 
494  return alloc_size;
495 }
496 
497 u8
499  u32 physmem_map_index)
500 {
502  vlib_buffer_pool_t *bp;
503  vlib_physmem_map_t *m = vlib_physmem_get_map (vm, physmem_map_index);
504  uword start = pointer_to_uword (m->base);
505  uword size = (uword) m->n_pages << m->log2_page_size;
506  uword i, j;
507  u32 alloc_size, n_alloc_per_page;
508 
509  if (vec_len (bm->buffer_pools) >= 255)
510  return ~0;
511 
513 
514  if (bm->buffer_mem_size == 0)
515  {
516  bm->buffer_mem_start = start;
517  bm->buffer_mem_size = size;
518  }
519  else if (start < bm->buffer_mem_start)
520  {
521  bm->buffer_mem_size += bm->buffer_mem_start - start;
522  bm->buffer_mem_start = start;
523  if (size > bm->buffer_mem_size)
524  bm->buffer_mem_size = size;
525  }
526  else if (start > bm->buffer_mem_start)
527  {
528  uword new_size = start - bm->buffer_mem_start + size;
529  if (new_size > bm->buffer_mem_size)
530  bm->buffer_mem_size = new_size;
531  }
532 
533  if ((u64) bm->buffer_mem_size >
534  ((u64) 1 << (32 + CLIB_LOG2_CACHE_LINE_BYTES)))
535  {
536  clib_panic ("buffer memory size out of range!");
537  }
538 
539  bp->start = start;
540  bp->size = size;
541  bp->index = bp - bm->buffer_pools;
543  bp->buffer_template.ref_count = 1;
544  bp->physmem_map_index = physmem_map_index;
545  bp->name = format (0, "%s%c", name, 0);
546  bp->data_size = data_size;
547  bp->numa_node = m->numa_node;
548 
551 
552  alloc_size = vlib_buffer_alloc_size (bm->ext_hdr_size, data_size);
553  n_alloc_per_page = (1ULL << m->log2_page_size) / alloc_size;
554 
555  /* preallocate buffer indices memory */
556  bp->n_buffers = m->n_pages * n_alloc_per_page;
557  bp->buffers = clib_mem_alloc_aligned (bp->n_buffers * sizeof (u32),
559 
560  clib_spinlock_init (&bp->lock);
561 
562  for (j = 0; j < m->n_pages; j++)
563  for (i = 0; i < n_alloc_per_page; i++)
564  {
565  u8 *p;
566  u32 bi;
567 
568  p = m->base + (j << m->log2_page_size) + i * alloc_size;
569  p += bm->ext_hdr_size;
570 
571  /*
572  * Waste 1 buffer (maximum) so that 0 is never a valid buffer index.
573  * Allows various places to ASSERT (bi != 0). Much easier
574  * than debugging downstream crashes in successor nodes.
575  */
576  if (p == m->base)
577  continue;
578 
580 
581  bi = vlib_get_buffer_index (vm, (vlib_buffer_t *) p);
582 
583  bp->buffers[bp->n_avail++] = bi;
584 
585  vlib_get_buffer (vm, bi);
586  }
587 
588  return bp->index;
589 }
590 
591 static u8 *
592 format_vlib_buffer_pool (u8 * s, va_list * va)
593 {
594  vlib_main_t *vm = va_arg (*va, vlib_main_t *);
595  vlib_buffer_pool_t *bp = va_arg (*va, vlib_buffer_pool_t *);
597  u32 cached = 0;
598 
599  if (!bp)
600  return format (s, "%-20s%=6s%=6s%=6s%=11s%=6s%=8s%=8s%=8s",
601  "Pool Name", "Index", "NUMA", "Size", "Data Size",
602  "Total", "Avail", "Cached", "Used");
603 
604  /* *INDENT-OFF* */
605  vec_foreach (bpt, bp->threads)
606  cached += bpt->n_cached;
607  /* *INDENT-ON* */
608 
609  s = format (s, "%-20s%=6d%=6d%=6u%=11u%=6u%=8u%=8u%=8u",
610  bp->name, bp->index, bp->numa_node, bp->data_size +
612  bp->data_size, bp->n_buffers, bp->n_avail, cached,
613  bp->n_buffers - bp->n_avail - cached);
614 
615  return s;
616 }
617 
618 static clib_error_t *
620  unformat_input_t * input, vlib_cli_command_t * cmd)
621 {
623  vlib_buffer_pool_t *bp;
624 
626 
627  /* *INDENT-OFF* */
628  vec_foreach (bp, bm->buffer_pools)
630  /* *INDENT-ON* */
631 
632  return 0;
633 }
634 
635 /* *INDENT-OFF* */
637  .path = "show buffers",
638  .short_help = "Show packet buffer allocation",
639  .function = show_buffers,
640 };
641 /* *INDENT-ON* */
642 
643 clib_error_t *
645 {
647  vlib_buffer_pool_t *bp;
648 
649  /* *INDENT-OFF* */
650  vec_foreach (bp, bm->buffer_pools)
651  {
652  clib_spinlock_lock (&bp->lock);
655  clib_spinlock_unlock (&bp->lock);
656  }
657  /* *INDENT-ON* */
658 
659  return 0;
660 }
661 
663 
664 static clib_error_t *
666  u32 * physmem_map_index,
667  clib_mem_page_sz_t log2_page_size,
668  u8 unpriv)
669 {
671  u32 buffers_per_numa = bm->buffers_per_numa;
673  u32 buffer_size;
674  uword n_pages, pagesize;
675  u8 *name = 0;
676 
677  ASSERT (log2_page_size != CLIB_MEM_PAGE_SZ_UNKNOWN);
678 
679  pagesize = clib_mem_page_bytes (log2_page_size);
680  buffer_size = vlib_buffer_alloc_size (bm->ext_hdr_size,
682  (vm));
683  if (buffer_size > pagesize)
684  return clib_error_return (0, "buffer size (%llu) is greater than page "
685  "size (%llu)", buffer_size, pagesize);
686 
687  if (buffers_per_numa == 0)
688  buffers_per_numa = unpriv ? VLIB_BUFFER_DEFAULT_BUFFERS_PER_NUMA_UNPRIV :
690 
691  name = format (0, "buffers-numa-%d%c", numa_node, 0);
692  n_pages = (buffers_per_numa - 1) / (pagesize / buffer_size) + 1;
694  n_pages * pagesize,
695  min_log2 (pagesize), numa_node,
696  physmem_map_index);
697  vec_free (name);
698  return error;
699 }
700 
701 static clib_error_t *
703  u8 * index)
704 {
706  u32 physmem_map_index;
708  u8 *name = 0;
709 
711  {
713  &physmem_map_index,
715  0 /* unpriv */ );
716  if (!error)
717  goto buffer_pool_create;
718 
719  /* If alloc failed, retry without hugepages */
721  "numa[%u] falling back to non-hugepage backed "
722  "buffer pool (%U)", numa_node, format_clib_error, error);
724 
726  &physmem_map_index,
728  1 /* unpriv */ );
729  }
730  else
732  &physmem_map_index,
733  bm->log2_page_size,
734  0 /* unpriv */ );
735  if (error)
736  return error;
737 
738 buffer_pool_create:
739  name = format (name, "default-numa-%d%c", numa_node, 0);
740  *index = vlib_buffer_pool_create (vm, (char *) name,
742  physmem_map_index);
743 
744  if (*index == (u8) ~ 0)
745  error = clib_error_return (0, "maximum number of buffer pools reached");
746  vec_free (name);
747 
748 
749  return error;
750 }
751 
752 void
754 {
755  vlib_buffer_main_t *bm;
756 
757  if (vm->buffer_main)
758  return;
759 
760  vm->buffer_main = bm = clib_mem_alloc (sizeof (bm[0]));
761  clib_memset (vm->buffer_main, 0, sizeof (bm[0]));
763 }
764 
765 static u32
767 {
768  u32 cached = 0;
770 
771  clib_spinlock_lock (&bp->lock);
772 
773  /* *INDENT-OFF* */
774  vec_foreach (bpt, bp->threads)
775  cached += bpt->n_cached;
776  /* *INDENT-ON* */
777 
778  clib_spinlock_unlock (&bp->lock);
779 
780  return cached;
781 }
782 
783 static vlib_buffer_pool_t *
785 {
786  vlib_buffer_pool_t *bp;
787  if (!bm->buffer_pools || vec_len (bm->buffer_pools) < index)
788  return 0;
789  bp = vec_elt_at_index (bm->buffer_pools, index);
790 
791  return bp;
792 }
793 
794 static void
796 {
799  if (!bp)
800  return;
801 
802  e->value = bp->n_buffers - bp->n_avail - buffer_get_cached (bp);
803 }
804 
805 static void
807  u32 index)
808 {
811  if (!bp)
812  return;
813 
814  e->value = bp->n_avail;
815 }
816 
817 static void
819 {
822  if (!bp)
823  return;
824 
825  e->value = buffer_get_cached (bp);
826 }
827 
828 clib_error_t *
830 {
831  vlib_buffer_main_t *bm;
832  clib_error_t *err;
833  clib_bitmap_t *bmp = 0, *bmp_has_memory = 0;
834  u32 numa_node;
835  vlib_buffer_pool_t *bp;
836  u8 *name = 0, first_valid_buffer_pool_index = ~0;
837 
839 
840  bm = vm->buffer_main;
841  bm->log_default = vlib_log_register_class ("buffer", 0);
842  bm->ext_hdr_size = __vlib_buffer_external_hdr_size;
843 
845 
846  if ((err = clib_sysfs_read ("/sys/devices/system/node/online", "%U",
847  unformat_bitmap_list, &bmp)))
848  clib_error_free (err);
849 
850  if ((err = clib_sysfs_read ("/sys/devices/system/node/has_memory", "%U",
851  unformat_bitmap_list, &bmp_has_memory)))
852  clib_error_free (err);
853 
854  if (bmp && bmp_has_memory)
855  bmp = clib_bitmap_and (bmp, bmp_has_memory);
856 
857  /* no info from sysfs, assuming that only numa 0 exists */
858  if (bmp == 0)
859  bmp = clib_bitmap_set (bmp, 0, 1);
860 
862  clib_panic ("system have more than %u NUMA nodes",
864 
865  /* *INDENT-OFF* */
866  clib_bitmap_foreach (numa_node, bmp)
867  {
868  u8 *index = bm->default_buffer_pool_index_for_numa + numa_node;
869  index[0] = ~0;
870  if ((err = vlib_buffer_main_init_numa_node (vm, numa_node, index)))
871  {
872  clib_error_report (err);
873  clib_error_free (err);
874  continue;
875  }
876 
877  if (first_valid_buffer_pool_index == 0xff)
878  first_valid_buffer_pool_index = index[0];
879  }
880  /* *INDENT-ON* */
881 
882  if (first_valid_buffer_pool_index == (u8) ~ 0)
883  {
884  err = clib_error_return (0, "failed to allocate buffer pool(s)");
885  goto done;
886  }
887 
888  /* *INDENT-OFF* */
889  clib_bitmap_foreach (numa_node, bmp)
890  {
891  if (bm->default_buffer_pool_index_for_numa[numa_node] == (u8) ~0)
892  bm->default_buffer_pool_index_for_numa[numa_node] =
893  first_valid_buffer_pool_index;
894  }
895  /* *INDENT-ON* */
896 
897  vec_foreach (bp, bm->buffer_pools)
898  {
899  if (bp->n_buffers == 0)
900  continue;
901 
903  name = format (name, "/buffer-pools/%s/cached%c", bp->name, 0);
905  bp - bm->buffer_pools);
906 
908  name = format (name, "/buffer-pools/%s/used%c", bp->name, 0);
910  bp - bm->buffer_pools);
911 
913  name = format (name, "/buffer-pools/%s/available%c", bp->name, 0);
915  bp - bm->buffer_pools);
916  }
917 
918 done:
919  vec_free (bmp);
920  vec_free (bmp_has_memory);
921  vec_free (name);
922  return err;
923 }
924 
925 static clib_error_t *
927 {
928  vlib_buffer_main_t *bm;
929 
931 
932  bm = vm->buffer_main;
934 
936  {
937  if (unformat (input, "buffers-per-numa %u", &bm->buffers_per_numa))
938  ;
939  else if (unformat (input, "page-size %U", unformat_log2_page_size,
940  &bm->log2_page_size))
941  ;
942  else if (unformat (input, "default data-size %u",
943  &bm->default_data_size))
944  ;
945  else
946  return unformat_parse_error (input);
947  }
948 
949  unformat_free (input);
950  return 0;
951 }
952 
954 
955 #if VLIB_BUFFER_ALLOC_FAULT_INJECTOR > 0
956 u32
957 vlib_buffer_alloc_may_fail (vlib_main_t * vm, u32 n_buffers)
958 {
959  f64 r;
960 
962 
963  /* Fail this request? */
965  n_buffers--;
966  /* 5% chance of returning nothing at all */
967  if (r > vm->buffer_alloc_success_rate && r > 0.95)
968  n_buffers = 0;
969 
970  return n_buffers;
971 }
972 #endif
973 
974 /** @endcond */
975 /*
976  * fd.io coding-style-patch-verification: ON
977  *
978  * Local Variables:
979  * eval: (c-set-style "gnu")
980  * End:
981  */
vlib_physmem_map_t::base
void * base
Definition: physmem.h:49
vec_reset_length
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Definition: vec_bootstrap.h:194
vlib_buffer_main_t
Definition: buffer.h:475
vlib.h
clib_spinlock_init
static void clib_spinlock_init(clib_spinlock_t *p)
Definition: lock.h:65
vlib_buffer_pool_t::start
uword start
Definition: buffer.h:453
vlib_buffer_t::next_buffer
u32 next_buffer
Next buffer for this linked-list of buffers.
Definition: buffer.h:149
vlib_buffer_t::buffer_pool_index
u8 buffer_pool_index
index of buffer pool this buffer belongs.
Definition: buffer.h:142
vlib_packet_template_t::packet_data
u8 * packet_data
Definition: buffer_funcs.h:1439
vlib_worker_thread_barrier_release
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
Definition: threads.c:1386
vec_add
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
Definition: vec.h:688
vlib_buffer_chain_append_data_with_alloc
u16 vlib_buffer_chain_append_data_with_alloc(vlib_main_t *vm, vlib_buffer_t *first, vlib_buffer_t **last, void *data, u16 data_len)
Definition: buffer.c:453
vlib_packet_template_t
Definition: buffer_funcs.h:1436
vlib_buffer_pool_t::index
u8 index
Definition: buffer.h:456
n_buffers
u32 n_buffers
Definition: interface_output.c:401
vlib_buffer_chain_increase_length
static void vlib_buffer_chain_increase_length(vlib_buffer_t *first, vlib_buffer_t *last, i32 len)
Definition: buffer_funcs.h:1394
vlib_buffer_pool_create
u8 vlib_buffer_pool_create(vlib_main_t *vm, char *name, u32 data_size, u32 physmem_map_index)
Definition: buffer.c:498
vlib_buffer_main_t::buffers_per_numa
u32 buffers_per_numa
Definition: buffer.h:493
VLIB_BUFFER_DEFAULT_BUFFERS_PER_NUMA_UNPRIV
#define VLIB_BUFFER_DEFAULT_BUFFERS_PER_NUMA_UNPRIV
Definition: buffer.c:52
buffer_get_by_index
static vlib_buffer_pool_t * buffer_get_by_index(vlib_buffer_main_t *bm, u32 index)
Definition: buffer.c:784
CLIB_MEM_PAGE_SZ_DEFAULT_HUGE
@ CLIB_MEM_PAGE_SZ_DEFAULT_HUGE
Definition: mem.h:61
vlib_physmem_map_t
Definition: physmem.h:45
vlib_get_buffer
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:111
pointer_to_uword
static uword pointer_to_uword(const void *p)
Definition: types.h:131
name
string name[64]
Definition: fib.api:25
vlib_buffer_main_init_numa_node
static clib_error_t * vlib_buffer_main_init_numa_node(struct vlib_main_t *vm, u32 numa_node, u8 *index)
Definition: buffer.c:702
vlib_buffer_pool_t::data_size
u32 data_size
Definition: buffer.h:459
clib_bitmap_t
uword clib_bitmap_t
Definition: bitmap.h:50
vlib_log_register_class
vlib_log_class_t vlib_log_register_class(char *class, char *subclass)
Definition: log.c:339
format_hex_bytes
u8 * format_hex_bytes(u8 *s, va_list *va)
Definition: std-formats.c:84
vlib_buffer_pool_t
Definition: buffer.h:450
vlib_buffer_pool_t::physmem_map_index
u32 physmem_map_index
Definition: buffer.h:458
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
vlib_cli_command_t::path
char * path
Definition: cli.h:96
vlib_log_warn
#define vlib_log_warn(...)
Definition: log.h:134
u16
unsigned short u16
Definition: types.h:57
first
static heap_elt_t * first(heap_header_t *h)
Definition: heap.c:59
format_vlib_buffer_contents
u8 * format_vlib_buffer_contents(u8 *s, va_list *va)
Definition: buffer.c:188
buffer_gauges_update_cached_fn
static void buffer_gauges_update_cached_fn(stat_segment_directory_entry_t *e, u32 index)
Definition: buffer.c:818
vlib_main_t::buffer_main
vlib_buffer_main_t * buffer_main
Definition: main.h:165
unformat_parse_error
#define unformat_parse_error(input)
Definition: format.h:261
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
clib_mem_page_bytes
static_always_inline uword clib_mem_page_bytes(clib_mem_page_sz_t log2_page_size)
Definition: mem.h:547
vlib_buffers_configure
static clib_error_t * vlib_buffers_configure(vlib_main_t *vm, unformat_input_t *input)
Definition: buffer.c:926
state
vl_api_dhcp_client_state_t state
Definition: dhcp.api:201
va_format
__clib_export u8 * va_format(u8 *s, const char *fmt, va_list *va)
Definition: format.c:391
vlib_buffer_main_alloc
void vlib_buffer_main_alloc(vlib_main_t *vm)
Definition: buffer.c:753
vlib_physmem_get_map
vlib_physmem_map_t * vlib_physmem_get_map(vlib_main_t *vm, u32 index)
Definition: physmem.c:86
vlib_buffer_t::trace_handle
u32 trace_handle
Specifies trace buffer handle if VLIB_PACKET_IS_TRACED flag is set.
Definition: buffer.h:172
VLIB_BUFFER_DEFAULT_DATA_SIZE
#define VLIB_BUFFER_DEFAULT_DATA_SIZE
Definition: buffer.h:53
clib_error_report
#define clib_error_report(e)
Definition: error.h:113
unformat_input_t
struct _unformat_input_t unformat_input_t
r
vnet_hw_if_output_node_runtime_t * r
Definition: interface_output.c:1071
vlib_buffer_is_known
static vlib_buffer_known_state_t vlib_buffer_is_known(vlib_main_t *vm, u32 buffer_index)
Definition: buffer_funcs.h:529
hash_create
#define hash_create(elts, value_bytes)
Definition: hash.h:695
clib_memcpy_fast
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
Definition: string.h:92
random_f64
static f64 random_f64(u32 *seed)
Generate f64 random number in the interval [0,1].
Definition: random.h:145
vlib_buffer_main_t::log2_page_size
clib_mem_page_sz_t log2_page_size
Definition: buffer.h:496
vlib_physmem_map_t::log2_page_size
u32 log2_page_size
Definition: physmem.h:52
error
Definition: cJSON.c:88
sysfs.h
VLIB_EARLY_CONFIG_FUNCTION
#define VLIB_EARLY_CONFIG_FUNCTION(x, n,...)
Definition: init.h:220
vlib_main_t::buffer_alloc_success_rate
f64 buffer_alloc_success_rate
Definition: main.h:266
format_clib_error
__clib_export u8 * format_clib_error(u8 *s, va_list *va)
Definition: error.c:191
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
hash_set
#define hash_set(h, key, value)
Definition: hash.h:255
format_vlib_buffer_known_state
static u8 * format_vlib_buffer_known_state(u8 *s, va_list *args)
Definition: buffer.c:160
clib_sysfs_read
__clib_export clib_error_t * clib_sysfs_read(char *file_name, char *fmt,...)
Definition: sysfs.c:51
vlib_buffer_t::current_data
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:119
vlib_buffer_pool_t::threads
vlib_buffer_pool_thread_t * threads
Definition: buffer.h:467
STATIC_ASSERT_OFFSET_OF
STATIC_ASSERT_OFFSET_OF(vlib_buffer_t, template_end, 64)
vlib_buffer_pool_t::size
uword size
Definition: buffer.h:454
vlib_main_t::buffer_alloc_success_seed
u32 buffer_alloc_success_seed
Definition: main.h:265
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
unformat_free
static void unformat_free(unformat_input_t *i)
Definition: format.h:155
len
u8 len
Definition: ip_types.api:103
VLIB_BUFFER_DEFAULT_BUFFERS_PER_NUMA
#define VLIB_BUFFER_DEFAULT_BUFFERS_PER_NUMA
Definition: buffer.c:51
vlib_validate_buffers
u8 * vlib_validate_buffers(vlib_main_t *vm, u32 *buffers, uword next_buffer_stride, uword n_buffers, vlib_buffer_known_state_t known_state, uword follow_buffer_next)
Definition: buffer.c:261
vlib_physmem_map_t::n_pages
u32 n_pages
Definition: physmem.h:50
show_buffers
static clib_error_t * show_buffers(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: buffer.c:619
vlib_packet_template_t::min_n_buffers_each_alloc
u32 min_n_buffers_each_alloc
Definition: buffer_funcs.h:1442
vlib_buffer_pool_t::buffers
u32 * buffers
Definition: buffer.h:462
CLIB_CACHE_LINE_ROUND
#define CLIB_CACHE_LINE_ROUND(x)
Definition: cache.h:61
vlib_buffer_alloc
static __clib_warn_unused_result u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
Definition: buffer_funcs.h:708
vlib_buffer_main_t::log_default
vlib_log_class_t log_default
Definition: buffer.h:499
vlib_buffer_alloc_size
static uword vlib_buffer_alloc_size(uword ext_hdr_size, uword data_size)
Definition: buffer.c:485
hash_free
#define hash_free(h)
Definition: hash.h:310
vec_elt_at_index
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Definition: vec_bootstrap.h:203
vlib_buffer_pool_t::buffer_template
vlib_buffer_t buffer_template
Definition: buffer.h:470
vlib_worker_thread_barrier_sync
#define vlib_worker_thread_barrier_sync(X)
Definition: threads.h:194
STATIC_ASSERT_FITS_IN
#define STATIC_ASSERT_FITS_IN(s, e, o)
Definition: error_bootstrap.h:122
vlib_get_buffer_index
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
Definition: buffer_funcs.h:324
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
vlib_config_function_runtime_t
Definition: init.h:68
stat_segment_directory_entry_t::value
uint64_t value
Definition: stat_segment_shared.h:41
VLIB_BUFFER_MAX_NUMA_NODES
#define VLIB_BUFFER_MAX_NUMA_NODES
Definition: buffer.h:473
vec_validate_aligned
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:534
clib_spinlock_lock
static_always_inline void clib_spinlock_lock(clib_spinlock_t *p)
Definition: lock.h:82
uword
u64 uword
Definition: types.h:112
last
static heap_elt_t * last(heap_header_t *h)
Definition: heap.c:53
if
if(node->flags &VLIB_NODE_FLAG_TRACE) vnet_interface_output_trace(vm
hash_get
#define hash_get(h, key)
Definition: hash.h:249
VLIB_BUFFER_KNOWN_FREE
@ VLIB_BUFFER_KNOWN_FREE
Definition: buffer_funcs.h:519
vlib_buffer_main_t::default_buffer_pool_index_for_numa
u8 default_buffer_pool_index_for_numa[VLIB_BUFFER_MAX_NUMA_NODES]
Definition: buffer.h:490
vlib_buffer_worker_init
clib_error_t * vlib_buffer_worker_init(vlib_main_t *vm)
Definition: buffer.c:644
stat_segment_register_gauge
clib_error_t * stat_segment_register_gauge(u8 *names, stat_segment_update_fn update_fn, u32 index)
Definition: pnat_test_stubs.h:23
vlib_buffer_copy_template
static_always_inline void vlib_buffer_copy_template(vlib_buffer_t *b, vlib_buffer_t *bt)
Definition: buffer_funcs.h:171
i
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:261
f64
double f64
Definition: types.h:142
VLIB_WORKER_INIT_FUNCTION
VLIB_WORKER_INIT_FUNCTION(vlib_buffer_worker_init)
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
vlib_buffer_t::ref_count
volatile u8 ref_count
Reference count for this buffer.
Definition: buffer.h:139
vlib_physmem_map_t::numa_node
u32 numa_node
Definition: physmem.h:53
vlib_buffer_main_t::buffer_known_hash_lockp
clib_spinlock_t buffer_known_hash_lockp
Definition: buffer.h:489
vlib_buffer_pool_t::name
u8 * name
Definition: buffer.h:463
clib_bitmap_set
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap.
Definition: bitmap.h:167
clib_min
#define clib_min(x, y)
Definition: clib.h:342
vlib_buffer_main_t::buffer_mem_size
uword buffer_mem_size
Definition: buffer.h:481
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
vlib_physmem_shared_map_create
clib_error_t * vlib_physmem_shared_map_create(vlib_main_t *vm, char *name, uword size, u32 log2_page_sz, u32 numa_node, u32 *map_index)
Definition: physmem.c:41
fmt
int cJSON_bool fmt
Definition: cJSON.h:160
vlib_cli_output
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:716
vlib_buffer_main_t::buffer_mem_start
uword buffer_mem_start
Definition: buffer.h:480
vlib_buffer_t::current_length
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:122
stat_segment.h
clib_bitmap_and
static uword * clib_bitmap_and(uword *ai, uword *bi)
Logical operator across two bitmaps.
data
u8 data[128]
Definition: ipsec_types.api:92
vlib_buffer_main_t::ext_hdr_size
u16 ext_hdr_size
Definition: buffer.h:494
vec_add2_aligned
#define vec_add2_aligned(V, P, N, A)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:656
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
stat_segment_directory_entry_t
Definition: stat_segment_shared.h:31
size
u32 size
Definition: vhost_user.h:125
index
u32 index
Definition: flow_types.api:221
vlib_validate_buffer_helper
static u8 * vlib_validate_buffer_helper(vlib_main_t *vm, u32 bi, uword follow_buffer_next, uword **unique_hash)
Definition: buffer.c:205
vlib_packet_template_get_packet
void * vlib_packet_template_get_packet(vlib_main_t *vm, vlib_packet_template_t *t, u32 *bi_result)
Definition: buffer.c:377
foreach_vlib_buffer_flag
@ foreach_vlib_buffer_flag
Definition: buffer.h:85
vlib_buffer_main_t::buffer_pools
vlib_buffer_pool_t * buffer_pools
Definition: buffer.h:482
vlib_buffer_pool_t::numa_node
u32 numa_node
Definition: buffer.h:457
u64
unsigned long u64
Definition: types.h:89
show_buffers_command
static vlib_cli_command_t show_buffers_command
(constructor) VLIB_CLI_COMMAND (show_buffers_command)
Definition: buffer.c:636
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
format_get_indent
static u32 format_get_indent(u8 *s)
Definition: format.h:72
vlib_buffer_main_init_numa_alloc
static clib_error_t * vlib_buffer_main_init_numa_alloc(struct vlib_main_t *vm, u32 numa_node, u32 *physmem_map_index, clib_mem_page_sz_t log2_page_size, u8 unpriv)
Definition: buffer.c:665
data_len
u8 data_len
Definition: ikev2_types.api:24
VLIB_BUFFER_UNKNOWN
@ VLIB_BUFFER_UNKNOWN
Definition: buffer_funcs.h:516
VLIB_BUFFER_PRE_DATA_SIZE
#define VLIB_BUFFER_PRE_DATA_SIZE
Definition: buffer.h:51
vlib_buffer_get_default_data_size
static_always_inline u32 vlib_buffer_get_default_data_size(vlib_main_t *vm)
Definition: buffer_funcs.h:122
u32
unsigned int u32
Definition: types.h:88
format_vlib_buffer_no_chain
u8 * format_vlib_buffer_no_chain(u8 *s, va_list *args)
Definition: buffer.c:95
vlib_buffer_pool_thread_t::n_cached
u32 n_cached
Definition: buffer.h:447
CLIB_MEM_PAGE_SZ_DEFAULT
@ CLIB_MEM_PAGE_SZ_DEFAULT
Definition: mem.h:60
vlib_buffer_main_t::buffer_known_hash
uword * buffer_known_hash
Definition: buffer.h:488
CLIB_LOG2_CACHE_LINE_BYTES
#define CLIB_LOG2_CACHE_LINE_BYTES
Definition: cache.h:50
vlib_packet_template_t::name
u8 * name
Definition: buffer_funcs.h:1444
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
n_left
u32 n_left
Definition: interface_output.c:1078
vlib_buffer_chain_buffer
static vlib_buffer_t * vlib_buffer_chain_buffer(vlib_main_t *vm, vlib_buffer_t *last, u32 next_bi)
Definition: buffer_funcs.h:1379
buffer_gauges_update_used_fn
static void buffer_gauges_update_used_fn(stat_segment_directory_entry_t *e, u32 index)
Definition: buffer.c:795
clib_spinlock_unlock
static_always_inline void clib_spinlock_unlock(clib_spinlock_t *p)
Definition: lock.h:121
vlib_buffer_pool_t::n_avail
u32 n_avail
Definition: buffer.h:461
clib_bitmap_last_set
static uword clib_bitmap_last_set(uword *ai)
Return the higest numbered set bit in a bitmap.
Definition: bitmap.h:429
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
vlib_buffer_known_state_t
vlib_buffer_known_state_t
Definition: buffer_funcs.h:513
vlib_get_n_threads
static u32 vlib_get_n_threads()
Definition: global_funcs.h:23
clib_mem_page_sz_t
clib_mem_page_sz_t
Definition: mem.h:57
vlib_get_main
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:38
b
vlib_buffer_t ** b
Definition: nat44_ei_out2in.c:717
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
a
a
Definition: bitmap.h:544
unix.h
vlib_buffer_get_current
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:257
vlib_buffer_validate_alloc_free
void vlib_buffer_validate_alloc_free(vlib_main_t *vm, u32 *buffers, uword n_buffers, vlib_buffer_known_state_t expected_state)
Definition: buffer.c:315
format_vlib_buffer
u8 * format_vlib_buffer(u8 *s, va_list *args)
Definition: buffer.c:125
vlib_buffer_t::data
u8 data[]
Packet data.
Definition: buffer.h:204
vlib_validate_buffer
u8 * vlib_validate_buffer(vlib_main_t *vm, u32 bi, uword follow_buffer_next)
Definition: buffer.c:254
unformat_log2_page_size
unformat_function_t unformat_log2_page_size
Definition: format.h:294
clib_warning
#define clib_warning(format, args...)
Definition: error.h:59
clib_mem_alloc_aligned
static void * clib_mem_alloc_aligned(uword size, uword align)
Definition: mem.h:261
clib_error_free
#define clib_error_free(e)
Definition: error.h:86
vlib_buffer_pool_t::lock
clib_spinlock_t lock
Definition: buffer.h:464
format_vlib_buffer_pool
static u8 * format_vlib_buffer_pool(u8 *s, va_list *va)
Definition: buffer.c:592
vlib_buffer_pool_thread_t
Definition: buffer.h:443
VLIB_BUFFER_KNOWN_ALLOCATED
@ VLIB_BUFFER_KNOWN_ALLOCATED
Definition: buffer_funcs.h:520
format_vlib_buffer_and_data
u8 * format_vlib_buffer_and_data(u8 *s, va_list *args)
Definition: buffer.c:148
vlib_packet_template_init
void vlib_packet_template_init(vlib_main_t *vm, vlib_packet_template_t *t, void *packet_data, uword n_packet_data_bytes, uword min_n_buffers_each_alloc, char *fmt,...)
Definition: buffer.c:355
vlib_buffer_main_init
clib_error_t * vlib_buffer_main_init(struct vlib_main_t *vm)
Definition: buffer.c:829
clib_bitmap_foreach
#define clib_bitmap_foreach(i, ai)
Macro to iterate across set bits in a bitmap.
Definition: bitmap.h:361
vlib_buffer_add_data
int vlib_buffer_add_data(vlib_main_t *vm, u32 *buffer_index, void *data, u32 n_data_bytes)
Definition: buffer.c:398
clib_panic
#define clib_panic(format, args...)
Definition: error.h:72
min_log2
static uword min_log2(uword x)
Definition: clib.h:176
vlib_cli_command_t
Definition: cli.h:92
hash_set1
#define hash_set1(h, key)
Definition: hash.h:258
vlib_buffer_t::total_length_not_including_first_buffer
u32 total_length_not_including_first_buffer
Only valid for first buffer in chain.
Definition: buffer.h:176
CLIB_MEM_PAGE_SZ_UNKNOWN
@ CLIB_MEM_PAGE_SZ_UNKNOWN
Definition: mem.h:59
vlib_buffer_alloc_from_pool
static __clib_warn_unused_result u32 vlib_buffer_alloc_from_pool(vlib_main_t *vm, u32 *buffers, u32 n_buffers, u8 buffer_pool_index)
Allocate buffers from specific pool into supplied array.
Definition: buffer_funcs.h:597
clib_mem_alloc
static void * clib_mem_alloc(uword size)
Definition: mem.h:253
unformat_bitmap_list
__clib_export uword unformat_bitmap_list(unformat_input_t *input, va_list *va)
unformat a list of bit ranges into a bitmap (eg "0-3,5-7,11" )
Definition: bitmap.c:55
format_white_space
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:129
buffer_gauges_update_available_fn
static void buffer_gauges_update_available_fn(stat_segment_directory_entry_t *e, u32 index)
Definition: buffer.c:806
buffer_get_cached
static u32 buffer_get_cached(vlib_buffer_pool_t *bp)
Definition: buffer.c:766
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137
vlib_buffer_t::flags
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
Definition: buffer.h:133
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
vlib_buffer_length_in_chain_slow_path
uword vlib_buffer_length_in_chain_slow_path(vlib_main_t *vm, vlib_buffer_t *b_first)
Definition: buffer.c:78
vlib_buffer_main_t::default_data_size
u32 default_data_size
Definition: buffer.h:495
vlib_buffer_pool_t::n_buffers
u32 n_buffers
Definition: buffer.h:460
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105