FD.io VPP  v17.04.2-2-ga8f93f8
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 (os_get_cpu_number () == 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  ASSERT (rte_mbuf_refcnt_read (mb0) == 0);
217  ASSERT (rte_mbuf_refcnt_read (mb1) == 0);
218  ASSERT (rte_mbuf_refcnt_read (mb2) == 0);
219  ASSERT (rte_mbuf_refcnt_read (mb3) == 0);
220 
221  rte_mbuf_refcnt_set (mb0, 1);
222  rte_mbuf_refcnt_set (mb1, 1);
223  rte_mbuf_refcnt_set (mb2, 1);
224  rte_mbuf_refcnt_set (mb3, 1);
225 
226  b0 = vlib_buffer_from_rte_mbuf (mb0);
227  b1 = vlib_buffer_from_rte_mbuf (mb1);
228  b2 = vlib_buffer_from_rte_mbuf (mb2);
229  b3 = vlib_buffer_from_rte_mbuf (mb3);
230 
231  bi0 = vlib_get_buffer_index (vm, b0);
232  bi1 = vlib_get_buffer_index (vm, b1);
233  bi2 = vlib_get_buffer_index (vm, b2);
234  bi3 = vlib_get_buffer_index (vm, b3);
235 
240 
245 
246  if (fl->buffer_init_function)
247  {
248  fl->buffer_init_function (vm, fl, &bi0, 1);
249  fl->buffer_init_function (vm, fl, &bi1, 1);
250  fl->buffer_init_function (vm, fl, &bi2, 1);
251  fl->buffer_init_function (vm, fl, &bi3, 1);
252  }
253  i += 4;
254  }
255 
256  while (i < n)
257  {
258  mb0 = vm->mbuf_alloc_list[i];
259 
260  ASSERT (rte_mbuf_refcnt_read (mb0) == 0);
261  rte_mbuf_refcnt_set (mb0, 1);
262 
263  b0 = vlib_buffer_from_rte_mbuf (mb0);
264  bi0 = vlib_get_buffer_index (vm, b0);
265 
267 
269 
270  if (fl->buffer_init_function)
271  fl->buffer_init_function (vm, fl, &bi0, 1);
272  i++;
273  }
274 
275  fl->n_alloc += n;
276 
277  return n;
278 }
279 
280 static u32
282  vlib_buffer_free_list_t * free_list,
283  u32 * alloc_buffers, u32 n_alloc_buffers)
284 {
285  u32 *dst, *src;
286  uword len, n_filled;
287 
288  dst = alloc_buffers;
289 
290  n_filled = fill_free_list (vm, free_list, n_alloc_buffers);
291  if (n_filled == 0)
292  return 0;
293 
294  len = vec_len (free_list->buffers);
295  ASSERT (len >= n_alloc_buffers);
296 
297  src = free_list->buffers + len - n_alloc_buffers;
298  clib_memcpy (dst, src, n_alloc_buffers * sizeof (u32));
299 
300  _vec_len (free_list->buffers) -= n_alloc_buffers;
301 
302  return n_alloc_buffers;
303 }
304 
305 /* Allocate a given number of buffers into given array.
306  Returns number actually allocated which will be either zero or
307  number requested. */
308 u32
309 dpdk_buffer_alloc (vlib_main_t * vm, u32 * buffers, u32 n_buffers)
310 {
312 
313  return alloc_from_free_list
314  (vm,
317  buffers, n_buffers);
318 }
319 
320 
321 u32
323  u32 * buffers,
324  u32 n_buffers, u32 free_list_index)
325 {
328  f = pool_elt_at_index (bm->buffer_free_list_pool, free_list_index);
329  return alloc_from_free_list (vm, f, buffers, n_buffers);
330 }
331 
334  u32 * buffers, u32 n_buffers, u32 follow_buffer_next)
335 {
338  u32 fi;
339  int i;
340  u32 (*cb) (vlib_main_t * vm, u32 * buffers, u32 n_buffers,
341  u32 follow_buffer_next);
342 
343  cb = bm->buffer_free_callback;
344 
345  if (PREDICT_FALSE (cb != 0))
346  n_buffers = (*cb) (vm, buffers, n_buffers, follow_buffer_next);
347 
348  if (!n_buffers)
349  return;
350 
351  for (i = 0; i < n_buffers; i++)
352  {
353  vlib_buffer_t *b;
354 
355  b = vlib_get_buffer (vm, buffers[i]);
356 
357  fl = vlib_buffer_get_buffer_free_list (vm, b, &fi);
358 
359  /* The only current use of this callback: multicast recycle */
361  {
362  int j;
363 
365  (vm, fl, buffers[i], (b->flags & VLIB_BUFFER_RECYCLE) == 0);
366 
367  for (j = 0; j < vec_len (bm->announce_list); j++)
368  {
369  if (fl == bm->announce_list[j])
370  goto already_announced;
371  }
372  vec_add1 (bm->announce_list, fl);
373  already_announced:
374  ;
375  }
376  else
377  {
378  if (PREDICT_TRUE ((b->flags & VLIB_BUFFER_RECYCLE) == 0))
379  dpdk_rte_pktmbuf_free (vm, b);
380  }
381  }
382  if (vec_len (bm->announce_list))
383  {
385  for (i = 0; i < vec_len (bm->announce_list); i++)
386  {
387  fl = bm->announce_list[i];
389  }
390  _vec_len (bm->announce_list) = 0;
391  }
392 }
393 
394 static void
395 dpdk_buffer_free (vlib_main_t * vm, u32 * buffers, u32 n_buffers)
396 {
397  vlib_buffer_free_inline (vm, buffers, n_buffers, /* follow_buffer_next */
398  1);
399 }
400 
401 static void
402 dpdk_buffer_free_no_next (vlib_main_t * vm, u32 * buffers, u32 n_buffers)
403 {
404  vlib_buffer_free_inline (vm, buffers, n_buffers, /* follow_buffer_next */
405  0);
406 }
407 
408 static void
410  void *vt,
411  void *packet_data,
412  uword n_packet_data_bytes,
413  uword min_n_buffers_each_physmem_alloc, u8 * name)
414 {
416 
418  memset (t, 0, sizeof (t[0]));
419 
420  vec_add (t->packet_data, packet_data, n_packet_data_bytes);
421 
423 }
424 
425 clib_error_t *
426 vlib_buffer_pool_create (vlib_main_t * vm, unsigned num_mbufs,
427  unsigned socket_id)
428 {
429  dpdk_main_t *dm = &dpdk_main;
430  vlib_physmem_main_t *vpm = &vm->physmem_main;
431  struct rte_mempool *rmp;
432  int i;
433 
435 
436  /* pool already exists, nothing to do */
437  if (dm->pktmbuf_pools[socket_id])
438  return 0;
439 
440  u8 *pool_name = format (0, "mbuf_pool_socket%u%c", socket_id, 0);
441 
442  rmp = rte_pktmbuf_pool_create ((char *) pool_name, /* pool name */
443  num_mbufs, /* number of mbufs */
444  512, /* cache size */
445  VLIB_BUFFER_HDR_SIZE, /* priv size */
446  VLIB_BUFFER_PRE_DATA_SIZE + VLIB_BUFFER_DATA_SIZE, /* dataroom size */
447  socket_id); /* cpu socket */
448 
449  if (rmp)
450  {
451  {
452  uword this_pool_end;
453  uword this_pool_start;
454  uword this_pool_size;
455  uword save_vpm_start, save_vpm_end, save_vpm_size;
456  struct rte_mempool_memhdr *memhdr;
457 
458  this_pool_start = ~0ULL;
459  this_pool_end = 0LL;
460 
461  STAILQ_FOREACH (memhdr, &rmp->mem_list, next)
462  {
463  if (((uword) (memhdr->addr + memhdr->len)) > this_pool_end)
464  this_pool_end = (uword) (memhdr->addr + memhdr->len);
465  if (((uword) memhdr->addr) < this_pool_start)
466  this_pool_start = (uword) (memhdr->addr);
467  }
468  ASSERT (this_pool_start < ~0ULL && this_pool_end > 0);
469  this_pool_size = this_pool_end - this_pool_start;
470 
471  if (CLIB_DEBUG > 1)
472  {
473  clib_warning ("%s: pool start %llx pool end %llx pool size %lld",
474  pool_name, this_pool_start, this_pool_end,
475  this_pool_size);
477  ("before: virtual.start %llx virtual.end %llx virtual.size %lld",
478  vpm->virtual.start, vpm->virtual.end, vpm->virtual.size);
479  }
480 
481  save_vpm_start = vpm->virtual.start;
482  save_vpm_end = vpm->virtual.end;
483  save_vpm_size = vpm->virtual.size;
484 
485  if ((this_pool_start < vpm->virtual.start) || vpm->virtual.start == 0)
486  vpm->virtual.start = this_pool_start;
487  if (this_pool_end > vpm->virtual.end)
488  vpm->virtual.end = this_pool_end;
489 
490  vpm->virtual.size = vpm->virtual.end - vpm->virtual.start;
491 
492  if (CLIB_DEBUG > 1)
493  {
495  ("after: virtual.start %llx virtual.end %llx virtual.size %lld",
496  vpm->virtual.start, vpm->virtual.end, vpm->virtual.size);
497  }
498 
499  /* check if fits into buffer index range */
500  if ((u64) vpm->virtual.size >
501  ((u64) 1 << (32 + CLIB_LOG2_CACHE_LINE_BYTES)))
502  {
503  clib_warning ("physmem: virtual size out of range!");
504  vpm->virtual.start = save_vpm_start;
505  vpm->virtual.end = save_vpm_end;
506  vpm->virtual.size = save_vpm_size;
507  rmp = 0;
508  }
509  }
510  if (rmp)
511  {
512  dm->pktmbuf_pools[socket_id] = rmp;
513  vec_free (pool_name);
514  return 0;
515  }
516  }
517 
518  vec_free (pool_name);
519 
520  /* no usable pool for this socket, try to use pool from another one */
521  for (i = 0; i < vec_len (dm->pktmbuf_pools); i++)
522  {
523  if (dm->pktmbuf_pools[i])
524  {
526  ("WARNING: Failed to allocate mempool for CPU socket %u. "
527  "Threads running on socket %u will use socket %u mempool.",
528  socket_id, socket_id, i);
529  dm->pktmbuf_pools[socket_id] = dm->pktmbuf_pools[i];
530  return 0;
531  }
532  }
533 
534  return clib_error_return (0, "failed to allocate mempool on socket %u",
535  socket_id);
536 }
537 
538 #if CLIB_DEBUG > 0
539 
543 
544 static clib_error_t *
546 {
547  void *oldheap;
548 
549  vlib_buffer_state_heap = mheap_alloc (0, 10 << 20);
550 
552 
556  clib_mem_set_heap (oldheap);
557  return 0;
558 }
559 
561 #endif
562 
563 static vlib_buffer_callbacks_t callbacks = {
565  .vlib_buffer_alloc_from_free_list_cb = &dpdk_buffer_alloc_from_free_list,
566  .vlib_buffer_free_cb = &dpdk_buffer_free,
567  .vlib_buffer_free_no_next_cb = &dpdk_buffer_free_no_next,
568  .vlib_packet_template_init_cb = &dpdk_packet_template_init,
569  .vlib_buffer_delete_free_list_cb = &dpdk_buffer_delete_free_list,
570 };
571 
572 static clib_error_t *
574 {
575  vlib_buffer_cb_register (vm, &callbacks);
576  return 0;
577 }
578 
580 
581 /** @endcond */
582 /*
583  * fd.io coding-style-patch-verification: ON
584  *
585  * Local Variables:
586  * eval: (c-set-style "gnu")
587  * End:
588  */
#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
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:343
void vlib_buffer_merge_free_lists(vlib_buffer_free_list_t *dst, vlib_buffer_free_list_t *src)
Definition: buffer.c:333
static clib_error_t * dpdk_buffer_init(vlib_main_t *vm)
Definition: buffer.c:573
#define VLIB_BUFFER_RECYCLE
Definition: buffer.h:91
dpdk_main_t dpdk_main
Definition: dpdk.h:422
int vlib_buffer_cb_register(struct vlib_main_t *vm, vlib_buffer_callbacks_t *cb)
Definition: buffer.c:1025
#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:953
u32 * vlib_buffer_state_validation_lock
Definition: buffer.c:540
#define VLIB_BUFFER_PRE_DATA_SIZE
Definition: buffer.h:51
#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:418
u32 min_n_buffers_each_physmem_alloc
Definition: buffer.h:328
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:447
vlib_main_t ** vlib_mains
Definition: buffer.c:285
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
Definition: vec.h:599
#define vec_add1_aligned(V, E, A)
Add 1 element to end of vector (alignment specified).
Definition: vec.h:532
u32 dpdk_buffer_alloc_from_free_list(vlib_main_t *vm, u32 *buffers, u32 n_buffers, u32 free_list_index)
Definition: buffer.c:322
static uword fill_free_list(vlib_main_t *vm, vlib_buffer_free_list_t *fl, uword min_free_buffers)
Definition: buffer.c:165
#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:346
uword * vlib_buffer_state_validation_hash
Definition: buffer.c:541
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:111
static_always_inline void dpdk_rte_pktmbuf_free(vlib_main_t *vm, vlib_buffer_t *b)
Definition: buffer.c:83
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
Definition: buffer.h:164
#define clib_error_return(e, args...)
Definition: error.h:111
unsigned long u64
Definition: types.h:89
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:404
#define rte_mbuf_from_vlib_buffer(x)
Definition: dpdk_priv.h:16
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:397
static clib_error_t * buffer_state_validation_init(vlib_main_t *vm)
Definition: buffer.c:545
static u32 vlib_buffer_get_free_list_with_size(vlib_main_t *vm, u32 size)
Definition: buffer_funcs.h:364
uword os_get_cpu_number(void)
Definition: unix-misc.c:224
#define VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX
Definition: buffer.h:390
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:241
#define PREDICT_FALSE(x)
Definition: clib.h:97
clib_error_t * vlib_buffer_pool_create(vlib_main_t *vm, unsigned num_mbufs, unsigned socket_id)
Definition: buffer.c:426
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:281
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
u32 dpdk_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Definition: buffer.c:309
STATIC_ASSERT(VLIB_BUFFER_PRE_DATA_SIZE==RTE_PKTMBUF_HEADROOM,"VLIB_BUFFER_PRE_DATA_SIZE must be equal to RTE_PKTMBUF_HEADROOM")
static_always_inline void vlib_buffer_free_inline(vlib_main_t *vm, u32 *buffers, u32 n_buffers, u32 follow_buffer_next)
Definition: buffer.c:649
u32(* buffer_free_callback)(struct vlib_main_t *vm, u32 *buffers, u32 n_buffers, u32 follow_buffer_next)
Definition: buffer.h:382
vlib_main_t * vm
Definition: buffer.c:276
#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
#define clib_warning(format, args...)
Definition: error.h:59
#define clib_memcpy(a, b, c)
Definition: string.h:69
static void del_free_list(vlib_main_t *vm, vlib_buffer_free_list_t *f)
Definition: buffer.c:111
void(* buffers_added_to_freelist_function)(struct vlib_main_t *vm, struct vlib_buffer_free_list_t *fl)
Definition: buffer.h:353
void vlib_worker_thread_barrier_sync(vlib_main_t *vm)
Definition: threads.c:1199
static uword round_pow2(uword x, uword pow2)
Definition: clib.h:278
void * vlib_buffer_state_heap
Definition: buffer.c:542
static void dpdk_buffer_delete_free_list(vlib_main_t *vm, u32 free_list_index)
Definition: buffer.c:128
#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
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
u32(* vlib_buffer_alloc_cb)(struct vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Definition: buffer.h:360
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:416
u8 n_add_refs
Number of additional references to this buffer.
Definition: buffer.h:124
#define clib_max(x, y)
Definition: clib.h:325
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:389
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:1231
vlib_physmem_region_t virtual
Definition: physmem.h:50
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:409
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:78
#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_no_next(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Definition: buffer.c:402
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
static void dpdk_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Definition: buffer.c:395