FD.io VPP  v17.10-9-gd594711
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 
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  b0 = vlib_buffer_from_rte_mbuf (mb0);
217  b1 = vlib_buffer_from_rte_mbuf (mb1);
218  b2 = vlib_buffer_from_rte_mbuf (mb2);
219  b3 = vlib_buffer_from_rte_mbuf (mb3);
220 
221  bi0 = vlib_get_buffer_index (vm, b0);
222  bi1 = vlib_get_buffer_index (vm, b1);
223  bi2 = vlib_get_buffer_index (vm, b2);
224  bi3 = vlib_get_buffer_index (vm, b3);
225 
230 
235 
236  if (fl->buffer_init_function)
237  {
238  fl->buffer_init_function (vm, fl, &bi0, 1);
239  fl->buffer_init_function (vm, fl, &bi1, 1);
240  fl->buffer_init_function (vm, fl, &bi2, 1);
241  fl->buffer_init_function (vm, fl, &bi3, 1);
242  }
243  i += 4;
244  }
245 
246  while (i < n)
247  {
248  mb0 = vm->mbuf_alloc_list[i];
249 
250  b0 = vlib_buffer_from_rte_mbuf (mb0);
251  bi0 = vlib_get_buffer_index (vm, b0);
252 
254 
256 
257  if (fl->buffer_init_function)
258  fl->buffer_init_function (vm, fl, &bi0, 1);
259  i++;
260  }
261 
262  fl->n_alloc += n;
263 
264  return n;
265 }
266 
267 static u32
269  vlib_buffer_free_list_t * free_list,
270  u32 * alloc_buffers, u32 n_alloc_buffers)
271 {
272  u32 *dst, *src;
273  uword len, n_filled;
274 
275  dst = alloc_buffers;
276 
277  n_filled = fill_free_list (vm, free_list, n_alloc_buffers);
278  if (n_filled == 0)
279  return 0;
280 
281  len = vec_len (free_list->buffers);
282  ASSERT (len >= n_alloc_buffers);
283 
284  src = free_list->buffers + len - n_alloc_buffers;
285  clib_memcpy (dst, src, n_alloc_buffers * sizeof (u32));
286 
287  _vec_len (free_list->buffers) -= n_alloc_buffers;
288 
289  return n_alloc_buffers;
290 }
291 
292 /* Allocate a given number of buffers into given array.
293  Returns number actually allocated which will be either zero or
294  number requested. */
295 u32
296 dpdk_buffer_alloc (vlib_main_t * vm, u32 * buffers, u32 n_buffers)
297 {
299 
300  return alloc_from_free_list
301  (vm,
304  buffers, n_buffers);
305 }
306 
307 
308 u32
310  u32 * buffers,
311  u32 n_buffers, u32 free_list_index)
312 {
315  f = pool_elt_at_index (bm->buffer_free_list_pool, free_list_index);
316  return alloc_from_free_list (vm, f, buffers, n_buffers);
317 }
318 
321  u32 * buffers, u32 n_buffers, u32 follow_buffer_next)
322 {
325  u32 fi;
326  int i;
327  u32 (*cb) (vlib_main_t * vm, u32 * buffers, u32 n_buffers,
328  u32 follow_buffer_next);
329 
330  cb = bm->buffer_free_callback;
331 
332  if (PREDICT_FALSE (cb != 0))
333  n_buffers = (*cb) (vm, buffers, n_buffers, follow_buffer_next);
334 
335  if (!n_buffers)
336  return;
337 
338  for (i = 0; i < n_buffers; i++)
339  {
340  vlib_buffer_t *b;
341 
342  b = vlib_get_buffer (vm, buffers[i]);
344  fl = vlib_buffer_get_buffer_free_list (vm, b, &fi);
345 
346  /* The only current use of this callback: multicast recycle */
348  {
349  int j;
350 
352  (vm, fl, buffers[i], (b->flags & VLIB_BUFFER_RECYCLE) == 0);
353 
354  for (j = 0; j < vec_len (bm->announce_list); j++)
355  {
356  if (fl == bm->announce_list[j])
357  goto already_announced;
358  }
359  vec_add1 (bm->announce_list, fl);
360  already_announced:
361  ;
362  }
363  else
364  {
365  if (PREDICT_TRUE ((b->flags & VLIB_BUFFER_RECYCLE) == 0))
366  dpdk_rte_pktmbuf_free (vm, b);
367  }
368  }
369  if (vec_len (bm->announce_list))
370  {
372  for (i = 0; i < vec_len (bm->announce_list); i++)
373  {
374  fl = bm->announce_list[i];
376  }
377  _vec_len (bm->announce_list) = 0;
378  }
379 }
380 
381 static void
382 dpdk_buffer_free (vlib_main_t * vm, u32 * buffers, u32 n_buffers)
383 {
384  vlib_buffer_free_inline (vm, buffers, n_buffers, /* follow_buffer_next */
385  1);
386 }
387 
388 static void
389 dpdk_buffer_free_no_next (vlib_main_t * vm, u32 * buffers, u32 n_buffers)
390 {
391  vlib_buffer_free_inline (vm, buffers, n_buffers, /* follow_buffer_next */
392  0);
393 }
394 
395 static void
397  void *vt,
398  void *packet_data,
399  uword n_packet_data_bytes,
400  uword min_n_buffers_each_physmem_alloc, u8 * name)
401 {
403 
405  memset (t, 0, sizeof (t[0]));
406 
407  vec_add (t->packet_data, packet_data, n_packet_data_bytes);
408 
410 }
411 
412 clib_error_t *
413 dpdk_buffer_pool_create (vlib_main_t * vm, unsigned num_mbufs,
414  unsigned socket_id)
415 {
416  dpdk_main_t *dm = &dpdk_main;
417  struct rte_mempool *rmp;
418  int i;
419 
421 
422  /* pool already exists, nothing to do */
423  if (dm->pktmbuf_pools[socket_id])
424  return 0;
425 
426  u8 *pool_name = format (0, "mbuf_pool_socket%u%c", socket_id, 0);
427 
428  rmp = rte_pktmbuf_pool_create ((char *) pool_name, /* pool name */
429  num_mbufs, /* number of mbufs */
430  512, /* cache size */
431  VLIB_BUFFER_HDR_SIZE, /* priv size */
432  VLIB_BUFFER_PRE_DATA_SIZE + VLIB_BUFFER_DATA_SIZE, /* dataroom size */
433  socket_id); /* cpu socket */
434 
435  if (rmp)
436  {
437  {
438  struct rte_mempool_memhdr *memhdr;
439 
440  STAILQ_FOREACH (memhdr, &rmp->mem_list, next)
441  vlib_buffer_add_mem_range (vm, (uword) memhdr->addr, memhdr->len);
442  }
443  if (rmp)
444  {
445  dm->pktmbuf_pools[socket_id] = rmp;
446  vec_free (pool_name);
447  return 0;
448  }
449  }
450 
451  vec_free (pool_name);
452 
453  /* no usable pool for this socket, try to use pool from another one */
454  for (i = 0; i < vec_len (dm->pktmbuf_pools); i++)
455  {
456  if (dm->pktmbuf_pools[i])
457  {
459  ("WARNING: Failed to allocate mempool for CPU socket %u. "
460  "Threads running on socket %u will use socket %u mempool.",
461  socket_id, socket_id, i);
462  dm->pktmbuf_pools[socket_id] = dm->pktmbuf_pools[i];
463  return 0;
464  }
465  }
466 
467  return clib_error_return (0, "failed to allocate mempool on socket %u",
468  socket_id);
469 }
470 
471 #if CLIB_DEBUG > 0
472 
476 
477 static clib_error_t *
479 {
480  void *oldheap;
481 
482  vlib_buffer_state_heap = mheap_alloc (0, 10 << 20);
483 
485 
489  clib_mem_set_heap (oldheap);
490  return 0;
491 }
492 
494 #endif
495 
496 #if CLI_DEBUG
497 struct dpdk_validate_buf_result
498 {
499  u32 invalid;
500  u32 uninitialized;
501 };
502 
503 #define DPDK_TRAJECTORY_POISON 31
504 
505 static void
506 dpdk_buffer_validate_trajectory (struct rte_mempool *mp, void *opaque,
507  void *obj, unsigned obj_idx)
508 {
509  vlib_buffer_t *b;
510  struct dpdk_validate_buf_result *counter = opaque;
511  b = vlib_buffer_from_rte_mbuf ((struct rte_mbuf *) obj);
512  if (b->pre_data[0] != 0)
513  {
514  if (b->pre_data[0] == DPDK_TRAJECTORY_POISON)
515  counter->uninitialized++;
516  else
517  counter->invalid++;
518  }
519 }
520 
521 int
522 dpdk_buffer_validate_trajectory_all (u32 * uninitialized)
523 {
524  dpdk_main_t *dm = &dpdk_main;
525  struct dpdk_validate_buf_result counter = { 0 };
526  int i;
527 
528  for (i = 0; i < vec_len (dm->pktmbuf_pools); i++)
529  rte_mempool_obj_iter (dm->pktmbuf_pools[i],
530  dpdk_buffer_validate_trajectory, &counter);
531  if (uninitialized)
532  *uninitialized = counter.uninitialized;
533  return counter.invalid;
534 }
535 
536 static void
537 dpdk_buffer_poison_trajectory (struct rte_mempool *mp, void *opaque,
538  void *obj, unsigned obj_idx)
539 {
540  vlib_buffer_t *b;
541  b = vlib_buffer_from_rte_mbuf ((struct rte_mbuf *) obj);
542  b->pre_data[0] = DPDK_TRAJECTORY_POISON;
543 }
544 
545 void
546 dpdk_buffer_poison_trajectory_all (void)
547 {
548  dpdk_main_t *dm = &dpdk_main;
549  int i;
550 
551  for (i = 0; i < vec_len (dm->pktmbuf_pools); i++)
552  rte_mempool_obj_iter (dm->pktmbuf_pools[i], dpdk_buffer_poison_trajectory,
553  0);
554 }
555 #endif
556 
557 /* *INDENT-OFF* */
558 VLIB_BUFFER_REGISTER_CALLBACKS (dpdk, static) = {
559  .vlib_buffer_alloc_cb = &dpdk_buffer_alloc,
560  .vlib_buffer_alloc_from_free_list_cb = &dpdk_buffer_alloc_from_free_list,
561  .vlib_buffer_free_cb = &dpdk_buffer_free,
562  .vlib_buffer_free_no_next_cb = &dpdk_buffer_free_no_next,
563  .vlib_packet_template_init_cb = &dpdk_packet_template_init,
564  .vlib_buffer_delete_free_list_cb = &dpdk_buffer_delete_free_list,
565 };
566 /* *INDENT-ON* */
567 
568 /** @endcond */
569 /*
570  * fd.io coding-style-patch-verification: ON
571  *
572  * Local Variables:
573  * eval: (c-set-style "gnu")
574  * End:
575  */
#define vlib_buffer_from_rte_mbuf(x)
Definition: dpdk_priv.h:17
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:337
void vlib_buffer_merge_free_lists(vlib_buffer_free_list_t *dst, vlib_buffer_free_list_t *src)
Definition: buffer.c:334
#define VLIB_BUFFER_RECYCLE
Definition: buffer.h:99
void vlib_buffer_add_mem_range(vlib_main_t *vm, uword start, uword size)
Definition: buffer.c:964
dpdk_main_t dpdk_main
Definition: init.c:37
#define PREDICT_TRUE(x)
Definition: clib.h:98
void * mheap_alloc(void *memory, uword size)
Definition: mheap.c:947
u32 * vlib_buffer_state_validation_lock
Definition: buffer.c:473
#define VLIB_BUFFER_PRE_DATA_SIZE
Definition: buffer.h:52
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:518
vlib_buffer_main_t * buffer_main
Definition: main.h:106
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
u32 min_n_buffers_each_physmem_alloc
Definition: buffer.h:345
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:443
vlib_main_t ** vlib_mains
Definition: buffer.c:292
#define vlib_worker_thread_barrier_sync(X)
Definition: threads.h:212
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
Definition: vec.h:595
#define vec_add1_aligned(V, E, A)
Add 1 element to end of vector (alignment specified).
Definition: vec.h:528
u32 dpdk_buffer_alloc_from_free_list(vlib_main_t *vm, u32 *buffers, u32 n_buffers, u32 free_list_index)
Definition: buffer.c:309
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:95
#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:369
uword * vlib_buffer_state_validation_hash
Definition: buffer.c:474
#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:169
#define clib_error_return(e, args...)
Definition: error.h:99
u8 pre_data[VLIB_BUFFER_PRE_DATA_SIZE]
Space for inserting data before buffer start.
Definition: buffer.h:149
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
Definition: buffer_funcs.h:74
#define fl(x, y)
vlib_buffer_free_list_t ** announce_list
Definition: buffer.h:437
#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:458
clib_error_t * dpdk_buffer_pool_create(vlib_main_t *vm, unsigned num_mbufs, unsigned socket_id)
Definition: buffer.c:413
static clib_error_t * buffer_state_validation_init(vlib_main_t *vm)
Definition: buffer.c:478
static u32 vlib_buffer_get_free_list_with_size(vlib_main_t *vm, u32 size)
Definition: buffer_funcs.h:391
#define VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX
Definition: buffer.h:422
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:270
#define PREDICT_FALSE(x)
Definition: clib.h:97
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:268
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:809
u32 dpdk_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Definition: buffer.c:296
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:665
static_always_inline uword vlib_get_thread_index(void)
Definition: threads.h:221
u32(* buffer_free_callback)(struct vlib_main_t *vm, u32 *buffers, u32 n_buffers, u32 follow_buffer_next)
Definition: buffer.h:414
vlib_main_t * vm
Definition: buffer.c:283
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:336
static void * clib_mem_set_heap(void *heap)
Definition: mem.h:226
#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:376
static uword round_pow2(uword x, uword pow2)
Definition: clib.h:278
void * vlib_buffer_state_heap
Definition: buffer.c:475
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:51
#define VLIB_BUFFER_HDR_SIZE
Definition: buffer.h:160
#define hash_create(elts, value_bytes)
Definition: hash.h:658
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
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:401
u32 next_buffer
Next buffer for this linked-list of buffers.
Definition: buffer.h:109
struct rte_mempool ** pktmbuf_pools
Definition: dpdk.h:391
VLIB_BUFFER_REGISTER_CALLBACKS(dpdk, static)
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:175
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b)
Definition: buffer.h:517
vlib_buffer_free_list_t * buffer_free_list_pool
Definition: buffer.h:421
static void vlib_buffer_init_for_free_list(vlib_buffer_t *dst, vlib_buffer_free_list_t *fl)
Definition: buffer_funcs.h:770
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
Definition: threads.c:1488
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:396
static vlib_buffer_free_list_t * vlib_buffer_get_free_list(vlib_main_t *vm, u32 free_list_index)
Definition: buffer_funcs.h:412
u32 flags
Definition: vhost-user.h:77
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:67
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition: buffer.h:75
static void dpdk_buffer_free_no_next(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Definition: buffer.c:389
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:382