FD.io VPP  v17.07.01-10-g3be13f0
Vector Packet Processing
buffer.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 /*
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 <rte_config.h>
47 
48 #include <rte_common.h>
49 #include <rte_log.h>
50 #include <rte_memory.h>
51 #include <rte_memzone.h>
52 #include <rte_tailq.h>
53 #include <rte_eal.h>
54 #include <rte_per_lcore.h>
55 #include <rte_launch.h>
56 #include <rte_atomic.h>
57 #include <rte_cycles.h>
58 #include <rte_prefetch.h>
59 #include <rte_lcore.h>
60 #include <rte_per_lcore.h>
61 #include <rte_branch_prediction.h>
62 #include <rte_interrupts.h>
63 #include <rte_pci.h>
64 #include <rte_random.h>
65 #include <rte_debug.h>
66 #include <rte_ether.h>
67 #include <rte_ethdev.h>
68 #include <rte_ring.h>
69 #include <rte_mempool.h>
70 #include <rte_mbuf.h>
71 #include <rte_version.h>
72 
73 #include <vlib/vlib.h>
74 #include <vnet/vnet.h>
75 #include <dpdk/device/dpdk.h>
76 #include <dpdk/device/dpdk_priv.h>
77 
78 
79 STATIC_ASSERT (VLIB_BUFFER_PRE_DATA_SIZE == RTE_PKTMBUF_HEADROOM,
80  "VLIB_BUFFER_PRE_DATA_SIZE must be equal to RTE_PKTMBUF_HEADROOM");
81 
84 {
85  vlib_buffer_t *hb = b;
86  struct rte_mbuf *mb;
87  u32 next, flags;
88  mb = rte_mbuf_from_vlib_buffer (hb);
89 
90 next:
91  flags = b->flags;
92  next = b->next_buffer;
94 
95  if (PREDICT_FALSE (b->n_add_refs))
96  {
97  rte_mbuf_refcnt_update (mb, b->n_add_refs);
98  b->n_add_refs = 0;
99  }
100 
101  rte_pktmbuf_free_seg (mb);
102 
103  if (flags & VLIB_BUFFER_NEXT_PRESENT)
104  {
105  b = vlib_get_buffer (vm, next);
106  goto next;
107  }
108 }
109 
110 static void
112 {
113  u32 i;
114  vlib_buffer_t *b;
115 
116  for (i = 0; i < vec_len (f->buffers); i++)
117  {
118  b = vlib_get_buffer (vm, f->buffers[i]);
119  dpdk_rte_pktmbuf_free (vm, b);
120  }
121 
122  vec_free (f->name);
123  vec_free (f->buffers);
124 }
125 
126 /* Add buffer free list. */
127 static void
129 {
132  u32 merge_index;
133  int i;
134 
135  ASSERT (vlib_get_thread_index () == 0);
136 
137  f = vlib_buffer_get_free_list (vm, free_list_index);
138 
139  merge_index = vlib_buffer_get_free_list_with_size (vm, f->n_data_bytes);
140  if (merge_index != ~0 && merge_index != free_list_index)
141  {
143  (bm->buffer_free_list_pool, merge_index),
144  f);
145  }
146 
147  del_free_list (vm, f);
148 
149  /* Poison it. */
150  memset (f, 0xab, sizeof (f[0]));
151 
153 
154  for (i = 1; i < vec_len (vlib_mains); i++)
155  {
156  bm = vlib_mains[i]->buffer_main;
157  f = vlib_buffer_get_free_list (vlib_mains[i], free_list_index);;
158  memset (f, 0xab, sizeof (f[0]));
160  }
161 }
162 
163 /* Make sure free list has at least given number of free buffers. */
164 static uword
166  vlib_buffer_free_list_t * fl, uword min_free_buffers)
167 {
168  dpdk_main_t *dm = &dpdk_main;
169  vlib_buffer_t *b0, *b1, *b2, *b3;
170  int n, i;
171  u32 bi0, bi1, bi2, bi3;
172  unsigned socket_id = rte_socket_id ();
173  struct rte_mempool *rmp = dm->pktmbuf_pools[socket_id];
174  struct rte_mbuf *mb0, *mb1, *mb2, *mb3;
175 
176  /* Too early? */
177  if (PREDICT_FALSE (rmp == 0))
178  return 0;
179 
180  /* Already have enough free buffers on free list? */
181  n = min_free_buffers - vec_len (fl->buffers);
182  if (n <= 0)
183  return min_free_buffers;
184 
185  /* Always allocate round number of buffers. */
186  n = round_pow2 (n, CLIB_CACHE_LINE_BYTES / sizeof (u32));
187 
188  /* Always allocate new buffers in reasonably large sized chunks. */
190 
191  vec_validate (vm->mbuf_alloc_list, n - 1);
192 
193  if (rte_mempool_get_bulk (rmp, vm->mbuf_alloc_list, n) < 0)
194  return 0;
195 
196  _vec_len (vm->mbuf_alloc_list) = n;
197 
198  i = 0;
199 
200  while (i < (n - 7))
201  {
203  (vm->mbuf_alloc_list[i + 4]), STORE);
205  (vm->mbuf_alloc_list[i + 5]), STORE);
207  (vm->mbuf_alloc_list[i + 6]), STORE);
209  (vm->mbuf_alloc_list[i + 7]), STORE);
210 
211  mb0 = vm->mbuf_alloc_list[i];
212  mb1 = vm->mbuf_alloc_list[i + 1];
213  mb2 = vm->mbuf_alloc_list[i + 2];
214  mb3 = vm->mbuf_alloc_list[i + 3];
215 
216 #if RTE_VERSION < RTE_VERSION_NUM(17, 5, 0, 0)
217  ASSERT (rte_mbuf_refcnt_read (mb0) == 0);
218  ASSERT (rte_mbuf_refcnt_read (mb1) == 0);
219  ASSERT (rte_mbuf_refcnt_read (mb2) == 0);
220  ASSERT (rte_mbuf_refcnt_read (mb3) == 0);
221 
222  rte_mbuf_refcnt_set (mb0, 1);
223  rte_mbuf_refcnt_set (mb1, 1);
224  rte_mbuf_refcnt_set (mb2, 1);
225  rte_mbuf_refcnt_set (mb3, 1);
226 #endif
227 
228  b0 = vlib_buffer_from_rte_mbuf (mb0);
229  b1 = vlib_buffer_from_rte_mbuf (mb1);
230  b2 = vlib_buffer_from_rte_mbuf (mb2);
231  b3 = vlib_buffer_from_rte_mbuf (mb3);
232 
233  bi0 = vlib_get_buffer_index (vm, b0);
234  bi1 = vlib_get_buffer_index (vm, b1);
235  bi2 = vlib_get_buffer_index (vm, b2);
236  bi3 = vlib_get_buffer_index (vm, b3);
237 
242 
247 
248  if (fl->buffer_init_function)
249  {
250  fl->buffer_init_function (vm, fl, &bi0, 1);
251  fl->buffer_init_function (vm, fl, &bi1, 1);
252  fl->buffer_init_function (vm, fl, &bi2, 1);
253  fl->buffer_init_function (vm, fl, &bi3, 1);
254  }
255  i += 4;
256  }
257 
258  while (i < n)
259  {
260  mb0 = vm->mbuf_alloc_list[i];
261 
262 #if RTE_VERSION < RTE_VERSION_NUM(17, 5, 0, 0)
263  ASSERT (rte_mbuf_refcnt_read (mb0) == 0);
264  rte_mbuf_refcnt_set (mb0, 1);
265 #endif
266 
267  b0 = vlib_buffer_from_rte_mbuf (mb0);
268  bi0 = vlib_get_buffer_index (vm, b0);
269 
271 
273 
274  if (fl->buffer_init_function)
275  fl->buffer_init_function (vm, fl, &bi0, 1);
276  i++;
277  }
278 
279  fl->n_alloc += n;
280 
281  return n;
282 }
283 
284 static u32
286  vlib_buffer_free_list_t * free_list,
287  u32 * alloc_buffers, u32 n_alloc_buffers)
288 {
289  u32 *dst, *src;
290  uword len, n_filled;
291 
292  dst = alloc_buffers;
293 
294  n_filled = fill_free_list (vm, free_list, n_alloc_buffers);
295  if (n_filled == 0)
296  return 0;
297 
298  len = vec_len (free_list->buffers);
299  ASSERT (len >= n_alloc_buffers);
300 
301  src = free_list->buffers + len - n_alloc_buffers;
302  clib_memcpy (dst, src, n_alloc_buffers * sizeof (u32));
303 
304  _vec_len (free_list->buffers) -= n_alloc_buffers;
305 
306  return n_alloc_buffers;
307 }
308 
309 /* Allocate a given number of buffers into given array.
310  Returns number actually allocated which will be either zero or
311  number requested. */
312 u32
313 dpdk_buffer_alloc (vlib_main_t * vm, u32 * buffers, u32 n_buffers)
314 {
316 
317  return alloc_from_free_list
318  (vm,
321  buffers, n_buffers);
322 }
323 
324 
325 u32
327  u32 * buffers,
328  u32 n_buffers, u32 free_list_index)
329 {
332  f = pool_elt_at_index (bm->buffer_free_list_pool, free_list_index);
333  return alloc_from_free_list (vm, f, buffers, n_buffers);
334 }
335 
338  u32 * buffers, u32 n_buffers, u32 follow_buffer_next)
339 {
342  u32 fi;
343  int i;
344  u32 (*cb) (vlib_main_t * vm, u32 * buffers, u32 n_buffers,
345  u32 follow_buffer_next);
346 
347  cb = bm->buffer_free_callback;
348 
349  if (PREDICT_FALSE (cb != 0))
350  n_buffers = (*cb) (vm, buffers, n_buffers, follow_buffer_next);
351 
352  if (!n_buffers)
353  return;
354 
355  for (i = 0; i < n_buffers; i++)
356  {
357  vlib_buffer_t *b;
358 
359  b = vlib_get_buffer (vm, buffers[i]);
360 
361  fl = vlib_buffer_get_buffer_free_list (vm, b, &fi);
362 
363  /* The only current use of this callback: multicast recycle */
365  {
366  int j;
367 
369  (vm, fl, buffers[i], (b->flags & VLIB_BUFFER_RECYCLE) == 0);
370 
371  for (j = 0; j < vec_len (bm->announce_list); j++)
372  {
373  if (fl == bm->announce_list[j])
374  goto already_announced;
375  }
376  vec_add1 (bm->announce_list, fl);
377  already_announced:
378  ;
379  }
380  else
381  {
382  if (PREDICT_TRUE ((b->flags & VLIB_BUFFER_RECYCLE) == 0))
383  dpdk_rte_pktmbuf_free (vm, b);
384  }
385  }
386  if (vec_len (bm->announce_list))
387  {
389  for (i = 0; i < vec_len (bm->announce_list); i++)
390  {
391  fl = bm->announce_list[i];
393  }
394  _vec_len (bm->announce_list) = 0;
395  }
396 }
397 
398 static void
399 dpdk_buffer_free (vlib_main_t * vm, u32 * buffers, u32 n_buffers)
400 {
401  vlib_buffer_free_inline (vm, buffers, n_buffers, /* follow_buffer_next */
402  1);
403 }
404 
405 static void
406 dpdk_buffer_free_no_next (vlib_main_t * vm, u32 * buffers, u32 n_buffers)
407 {
408  vlib_buffer_free_inline (vm, buffers, n_buffers, /* follow_buffer_next */
409  0);
410 }
411 
412 static void
414  void *vt,
415  void *packet_data,
416  uword n_packet_data_bytes,
417  uword min_n_buffers_each_physmem_alloc, u8 * name)
418 {
420 
422  memset (t, 0, sizeof (t[0]));
423 
424  vec_add (t->packet_data, packet_data, n_packet_data_bytes);
425 
427 }
428 
429 clib_error_t *
430 vlib_buffer_pool_create (vlib_main_t * vm, unsigned num_mbufs,
431  unsigned socket_id)
432 {
433  dpdk_main_t *dm = &dpdk_main;
434  vlib_physmem_main_t *vpm = &vm->physmem_main;
435  struct rte_mempool *rmp;
436  int i;
437 
439 
440  /* pool already exists, nothing to do */
441  if (dm->pktmbuf_pools[socket_id])
442  return 0;
443 
444  u8 *pool_name = format (0, "mbuf_pool_socket%u%c", socket_id, 0);
445 
446  rmp = rte_pktmbuf_pool_create ((char *) pool_name, /* pool name */
447  num_mbufs, /* number of mbufs */
448  512, /* cache size */
449  VLIB_BUFFER_HDR_SIZE, /* priv size */
450  VLIB_BUFFER_PRE_DATA_SIZE + VLIB_BUFFER_DATA_SIZE, /* dataroom size */
451  socket_id); /* cpu socket */
452 
453  if (rmp)
454  {
455  {
456  uword this_pool_end;
457  uword this_pool_start;
458  uword this_pool_size;
459  uword save_vpm_start, save_vpm_end, save_vpm_size;
460  struct rte_mempool_memhdr *memhdr;
461 
462  this_pool_start = ~0;
463  this_pool_end = 0;
464 
465  STAILQ_FOREACH (memhdr, &rmp->mem_list, next)
466  {
467  if (((uword) (memhdr->addr + memhdr->len)) > this_pool_end)
468  this_pool_end = (uword) (memhdr->addr + memhdr->len);
469  if (((uword) memhdr->addr) < this_pool_start)
470  this_pool_start = (uword) (memhdr->addr);
471  }
472  ASSERT (this_pool_start < ~0 && this_pool_end > 0);
473  this_pool_size = this_pool_end - this_pool_start;
474 
475  if (CLIB_DEBUG > 1)
476  {
477  clib_warning ("%s: pool start %llx pool end %llx pool size %lld",
478  pool_name, this_pool_start, this_pool_end,
479  this_pool_size);
481  ("before: virtual.start %llx virtual.end %llx virtual.size %lld",
482  vpm->virtual.start, vpm->virtual.end, vpm->virtual.size);
483  }
484 
485  save_vpm_start = vpm->virtual.start;
486  save_vpm_end = vpm->virtual.end;
487  save_vpm_size = vpm->virtual.size;
488 
489  if ((this_pool_start < vpm->virtual.start) || vpm->virtual.start == 0)
490  vpm->virtual.start = this_pool_start;
491  if (this_pool_end > vpm->virtual.end)
492  vpm->virtual.end = this_pool_end;
493 
494  vpm->virtual.size = vpm->virtual.end - vpm->virtual.start;
495 
496  if (CLIB_DEBUG > 1)
497  {
499  ("after: virtual.start %llx virtual.end %llx virtual.size %lld",
500  vpm->virtual.start, vpm->virtual.end, vpm->virtual.size);
501  }
502 
503  /* check if fits into buffer index range */
504  if ((u64) vpm->virtual.size >
505  ((u64) 1 << (32 + CLIB_LOG2_CACHE_LINE_BYTES)))
506  {
507  clib_warning ("physmem: virtual size out of range!");
508  vpm->virtual.start = save_vpm_start;
509  vpm->virtual.end = save_vpm_end;
510  vpm->virtual.size = save_vpm_size;
511  rmp = 0;
512  }
513  }
514  if (rmp)
515  {
516  dm->pktmbuf_pools[socket_id] = rmp;
517  vec_free (pool_name);
518  return 0;
519  }
520  }
521 
522  vec_free (pool_name);
523 
524  /* no usable pool for this socket, try to use pool from another one */
525  for (i = 0; i < vec_len (dm->pktmbuf_pools); i++)
526  {
527  if (dm->pktmbuf_pools[i])
528  {
530  ("WARNING: Failed to allocate mempool for CPU socket %u. "
531  "Threads running on socket %u will use socket %u mempool.",
532  socket_id, socket_id, i);
533  dm->pktmbuf_pools[socket_id] = dm->pktmbuf_pools[i];
534  return 0;
535  }
536  }
537 
538  return clib_error_return (0, "failed to allocate mempool on socket %u",
539  socket_id);
540 }
541 
542 #if CLIB_DEBUG > 0
543 
547 
548 static clib_error_t *
550 {
551  void *oldheap;
552 
553  vlib_buffer_state_heap = mheap_alloc (0, 10 << 20);
554 
556 
560  clib_mem_set_heap (oldheap);
561  return 0;
562 }
563 
565 #endif
566 
567 static vlib_buffer_callbacks_t callbacks = {
569  .vlib_buffer_alloc_from_free_list_cb = &dpdk_buffer_alloc_from_free_list,
570  .vlib_buffer_free_cb = &dpdk_buffer_free,
571  .vlib_buffer_free_no_next_cb = &dpdk_buffer_free_no_next,
572  .vlib_packet_template_init_cb = &dpdk_packet_template_init,
573  .vlib_buffer_delete_free_list_cb = &dpdk_buffer_delete_free_list,
574 };
575 
576 static clib_error_t *
578 {
579  vlib_buffer_cb_register (vm, &callbacks);
580  return 0;
581 }
582 
584 
585 /** @endcond */
586 /*
587  * fd.io coding-style-patch-verification: ON
588  *
589  * Local Variables:
590  * eval: (c-set-style "gnu")
591  * End:
592  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:436
#define vlib_buffer_from_rte_mbuf(x)
Definition: dpdk_priv.h:17
u32 dpdk_buffer_alloc_from_free_list(vlib_main_t *vm, u32 *buffers, u32 n_buffers, u32 free_list_index)
Definition: buffer.c:326
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:337
static void del_free_list(vlib_main_t *vm, vlib_buffer_free_list_t *f)
Definition: buffer.c:111
#define VLIB_BUFFER_RECYCLE
Definition: buffer.h:91
dpdk_main_t dpdk_main
Definition: init.c:36
static_always_inline void dpdk_rte_pktmbuf_free(vlib_main_t *vm, vlib_buffer_t *b)
Definition: buffer.c:83
#define PREDICT_TRUE(x)
Definition: clib.h:98
vlib_physmem_main_t physmem_main
Definition: main.h:106
void * mheap_alloc(void *memory, uword size)
Definition: mheap.c:947
void vlib_buffer_merge_free_lists(vlib_buffer_free_list_t *dst, vlib_buffer_free_list_t *src)
#define VLIB_BUFFER_PRE_DATA_SIZE
Definition: buffer.h:51
static uword fill_free_list(vlib_main_t *vm, vlib_buffer_free_list_t *fl, uword min_free_buffers)
Definition: buffer.c:165
#define CLIB_LOG2_CACHE_LINE_BYTES
Definition: cache.h:49
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:522
vlib_buffer_main_t * buffer_main
Definition: main.h:104
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
u32 min_n_buffers_each_physmem_alloc
Definition: buffer.h:340
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:447
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
Definition: vec.h:599
static void dpdk_buffer_delete_free_list(vlib_main_t *vm, u32 free_list_index)
Definition: buffer.c:128
#define vec_add1_aligned(V, E, A)
Add 1 element to end of vector (alignment specified).
Definition: vec.h:532
#define VLIB_BUFFER_NEXT_PRESENT
Definition: buffer.h:87
#define static_always_inline
Definition: clib.h:85
void(* buffer_init_function)(struct vlib_main_t *vm, struct vlib_buffer_free_list_t *fl, u32 *buffers, u32 n_buffers)
Definition: buffer.h:358
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:111
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
Definition: buffer.h:164
#define clib_error_return(e, args...)
Definition: error.h:99
void * vlib_buffer_state_heap
Definition: buffer.c:546
unsigned long u64
Definition: types.h:89
static u32 alloc_from_free_list(vlib_main_t *vm, vlib_buffer_free_list_t *free_list, u32 *alloc_buffers, u32 n_alloc_buffers)
Definition: buffer.c:285
u32 dpdk_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Definition: buffer.c:313
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
Definition: buffer_funcs.h:70
vlib_buffer_free_list_t ** announce_list
Definition: buffer.h:416
#define rte_mbuf_from_vlib_buffer(x)
Definition: dpdk_priv.h:16
static void dpdk_buffer_free_no_next(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Definition: buffer.c:406
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:397
u32 * vlib_buffer_state_validation_lock
Definition: buffer.c:544
static u32 vlib_buffer_get_free_list_with_size(vlib_main_t *vm, u32 size)
Definition: buffer_funcs.h:364
#define VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX
Definition: buffer.h:402
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:241
#define PREDICT_FALSE(x)
Definition: clib.h:97
static void vlib_buffer_add_to_free_list(vlib_main_t *vm, vlib_buffer_free_list_t *f, u32 buffer_index, u8 do_init)
Definition: buffer_funcs.h:812
static_always_inline uword vlib_get_thread_index(void)
Definition: threads.h:185
u32(* buffer_free_callback)(struct vlib_main_t *vm, u32 *buffers, u32 n_buffers, u32 follow_buffer_next)
Definition: buffer.h:394
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:340
static void * clib_mem_set_heap(void *heap)
Definition: mem.h:223
static void dpdk_packet_template_init(vlib_main_t *vm, void *vt, void *packet_data, uword n_packet_data_bytes, uword min_n_buffers_each_physmem_alloc, u8 *name)
Definition: buffer.c:413
#define clib_warning(format, args...)
Definition: error.h:59
#define clib_memcpy(a, b, c)
Definition: string.h:69
void(* buffers_added_to_freelist_function)(struct vlib_main_t *vm, struct vlib_buffer_free_list_t *fl)
Definition: buffer.h:365
void vlib_worker_thread_barrier_sync(vlib_main_t *vm)
Definition: threads.c:1166
static uword round_pow2(uword x, uword pow2)
Definition: clib.h:278
#define VLIB_BUFFER_DATA_SIZE
Definition: buffer.h:50
#define VLIB_BUFFER_HDR_SIZE
Definition: buffer.h:155
#define hash_create(elts, value_bytes)
Definition: hash.h:658
static clib_error_t * buffer_state_validation_init(vlib_main_t *vm)
Definition: buffer.c:549
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
int vlib_buffer_cb_register(struct vlib_main_t *vm, vlib_buffer_callbacks_t *cb)
u32(* vlib_buffer_alloc_cb)(struct vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Definition: buffer.h:372
static_always_inline void vlib_buffer_free_inline(vlib_main_t *vm, u32 *buffers, u32 n_buffers, u32 follow_buffer_next)
Definition: buffer.c:337
static vlib_buffer_free_list_t * vlib_buffer_get_buffer_free_list(vlib_main_t *vm, vlib_buffer_t *b, u32 *index)
Definition: buffer_funcs.h:374
u32 next_buffer
Next buffer for this linked-list of buffers.
Definition: buffer.h:109
struct rte_mempool ** pktmbuf_pools
Definition: dpdk.h:387
STATIC_ASSERT(VLIB_BUFFER_PRE_DATA_SIZE==RTE_PKTMBUF_HEADROOM,"VLIB_BUFFER_PRE_DATA_SIZE must be equal to RTE_PKTMBUF_HEADROOM")
u8 n_add_refs
Number of additional references to this buffer.
Definition: buffer.h:124
#define clib_max(x, y)
Definition: clib.h:325
clib_error_t * vlib_buffer_pool_create(vlib_main_t *vm, unsigned num_mbufs, unsigned socket_id)
Definition: buffer.c:430
u64 uword
Definition: types.h:112
void ** mbuf_alloc_list
Definition: main.h:161
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
vlib_buffer_free_list_t * buffer_free_list_pool
Definition: buffer.h:401
vlib_main_t ** vlib_mains
static clib_error_t * dpdk_buffer_init(vlib_main_t *vm)
Definition: buffer.c:577
uword * vlib_buffer_state_validation_hash
Definition: buffer.c:545
static void vlib_buffer_init_for_free_list(vlib_buffer_t *dst, vlib_buffer_free_list_t *fl)
Definition: buffer_funcs.h:777
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
Definition: threads.c:1198
vlib_physmem_region_t virtual
Definition: physmem.h:50
static vlib_buffer_free_list_t * vlib_buffer_get_free_list(vlib_main_t *vm, u32 free_list_index)
Definition: buffer_funcs.h:385
u32 flags
Definition: vhost-user.h:76
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:67
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition: buffer.h:74
static void dpdk_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Definition: buffer.c:399
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:57