|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
19 #include <rte_config.h>
21 #include <rte_ethdev.h>
23 #include <rte_version.h>
29 "VLIB_BUFFER_PRE_DATA_SIZE must be equal to RTE_PKTMBUF_HEADROOM");
32 #ifndef CLIB_MARCH_VARIANT
41 struct rte_mempool *mp, *nmp;
42 struct rte_pktmbuf_pool_private priv;
43 enum rte_iova_mode iova_mode;
48 sizeof (
struct rte_mbuf) + sizeof (
vlib_buffer_t) + bp->data_size;
58 mp = rte_mempool_create_empty ((
char *)
name, bp->n_buffers,
59 elt_size, 512, sizeof (priv),
65 "failed to create normal mempool for numa node %u",
72 nmp = rte_mempool_create_empty ((
char *)
name, bp->n_buffers,
73 elt_size, 0, sizeof (priv),
77 rte_mempool_free (mp);
80 "failed to create non-cache mempool for numa nude %u",
88 mp->pool_id = nmp->pool_id = bp->index;
90 rte_mempool_set_ops_byname (mp,
"vpp", NULL);
91 rte_mempool_set_ops_byname (nmp,
"vpp-no-cache", NULL);
94 memset (&priv, 0,
sizeof (priv));
98 rte_pktmbuf_pool_init (mp, &priv);
99 rte_pktmbuf_pool_init (nmp, &priv);
101 iova_mode = rte_eal_iova_mode ();
104 for (
i = 0;
i < bp->n_buffers;
i++)
106 struct rte_mempool_objhdr *hdr;
109 hdr = (
struct rte_mempool_objhdr *) RTE_PTR_SUB (mb,
sizeof (*hdr));
111 hdr->iova = (iova_mode == RTE_IOVA_VA) ?
113 STAILQ_INSERT_TAIL (&mp->elt_list, hdr,
next);
114 STAILQ_INSERT_TAIL (&nmp->elt_list, hdr,
next);
115 mp->populated_size++;
116 nmp->populated_size++;
120 rte_mempool_obj_iter (mp, rte_pktmbuf_init, 0);
127 (buffer_mem_start, *bp->buffers,
128 0)), sizeof (
struct rte_mbuf));
130 for (
i = 0;
i < bp->n_buffers;
i++)
138 if (rte_eth_dev_count_avail ())
150 char *va = ((
char *) pm->
base) +
i * page_sz;
151 uword pa = (iova_mode == RTE_IOVA_VA) ?
155 #
if RTE_VERSION < RTE_VERSION_NUM(19, 11, 0, 0)
158 rte_vfio_container_dma_map (RTE_VFIO_DEFAULT_CONTAINER_FD,
163 struct rte_mempool_memhdr *memhdr;
168 memhdr->len = page_sz;
172 STAILQ_INSERT_TAIL (&mp->mem_list, memhdr,
next);
200 struct rte_mbuf *mb = obj;
209 void *
const *obj_table,
unsigned n)
211 const int batch_size = 32;
214 u8 buffer_pool_index = mp->pool_id;
218 void *
const *obj = obj_table;
239 while (n >= batch_size)
243 sizeof (
struct rte_mbuf));
246 obj_table += batch_size;
252 n,
sizeof (
struct rte_mbuf));
263 struct rte_mempool *
new,
void *obj,
266 struct rte_mbuf *mb = obj;
280 void *
const *obj_table,
285 struct rte_mempool *mp;
287 u8 buffer_pool_index = cmp->pool_id;
326 struct rte_mbuf *mb = mba[0];
333 #ifdef CLIB_HAVE_VEC256
334 for (
i = 1;
i < 4;
i++)
337 for (
i = 2;
i < 8;
i++)
346 void **obj_table,
unsigned n)
348 const int batch_size = 32;
350 u32 bufs[batch_size], total = 0, n_alloc = 0;
351 u8 buffer_pool_index = mp->pool_id;
352 void **obj = obj_table;
355 while (n >= batch_size)
359 if (n_alloc != batch_size)
363 -(
i32)
sizeof (
struct rte_mbuf));
378 -(
i32)
sizeof (
struct rte_mbuf));
393 sizeof (
struct rte_mbuf));
404 #ifndef CLIB_MARCH_VARIANT
432 struct rte_mempool *cmp;
443 struct rte_mempool_ops ops = { };
445 strncpy (ops.name,
"vpp", 4);
451 rte_mempool_register_ops (&ops);
453 strncpy (ops.name,
"vpp-no-cache", 13);
457 rte_mempool_register_ops (&ops);
468 sizeof (
struct rte_mbuf));
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
u8 buffer_pool_index
index of buffer pool this buffer belongs.
STATIC_ASSERT(VLIB_BUFFER_PRE_DATA_SIZE==RTE_PKTMBUF_HEADROOM, "VLIB_BUFFER_PRE_DATA_SIZE must be equal to RTE_PKTMBUF_HEADROOM")
vlib_buffer_t * bufs[VLIB_FRAME_SIZE]
#define clib_memcpy(d, s, n)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static uword pointer_to_uword(const void *p)
static_always_inline void vlib_get_buffers_with_offset(vlib_main_t *vm, u32 *bi, void **b, int count, i32 offset)
Translate array of buffer indices into buffer pointers with offset.
static_always_inline void dpdk_mbuf_init_from_template(struct rte_mbuf **mba, struct rte_mbuf *mt, int count)
#define clib_error_return(e, args...)
#define CLIB_MULTIARCH_FN(fn)
vlib_buffer_main_t * buffer_main
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
vlib_physmem_map_t * vlib_physmem_get_map(vlib_main_t *vm, u32 index)
static_always_inline vlib_buffer_pool_t * vlib_get_buffer_pool(vlib_main_t *vm, u8 buffer_pool_index)
int CLIB_MULTIARCH_FN() dpdk_ops_vpp_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n)
STATIC_ASSERT_OFFSET_OF(vlib_buffer_t, template_end, 64)
static int dpdk_ops_vpp_dequeue_no_cache(struct rte_mempool *mp, void **obj_table, unsigned n)
static u64 vlib_physmem_get_pa(vlib_main_t *vm, void *mem)
CLIB_MARCH_FN_REGISTRATION(dpdk_ops_vpp_enqueue)
clib_error_t * dpdk_buffer_pool_init(vlib_main_t *vm, vlib_buffer_pool_t *bp)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
vlib_buffer_t buffer_template
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
#define static_always_inline
#define vlib_buffer_from_rte_mbuf(x)
static unsigned dpdk_ops_vpp_get_count(const struct rte_mempool *mp)
#define STATIC_ASSERT_SIZEOF(d, s)
#define VLIB_BUFFER_HDR_SIZE
static_always_inline void vlib_buffer_copy_template(vlib_buffer_t *b, vlib_buffer_t *bt)
sll srl srl sll sra u16x4 i
volatile u8 ref_count
Reference count for this buffer.
static_always_inline void vlib_get_buffer_indices_with_offset(vlib_main_t *vm, void **b, u32 *bi, uword count, i32 offset)
Translate array of buffer pointers into buffer indices with offset.
#define CLIB_CACHE_LINE_BYTES
#define clib_atomic_sub_fetch(a, b)
struct rte_mempool ** dpdk_no_cache_mempool_by_buffer_pool_index
#define rte_mbuf_from_vlib_buffer(x)
struct rte_mempool ** dpdk_mempool_by_buffer_pool_index
static_always_inline void vlib_buffer_pool_put(vlib_main_t *vm, u8 buffer_pool_index, u32 *buffers, u32 n_buffers)
#define vec_free(V)
Free vector's memory (no header).
struct rte_mbuf * dpdk_mbuf_template_by_pool_index
vlib_buffer_pool_t * buffer_pools
static_always_inline void dpdk_ops_vpp_enqueue_no_cache_one(vlib_main_t *vm, struct rte_mempool *old, struct rte_mempool *new, void *obj, vlib_buffer_t *bt)
#define STATIC_ASSERT_SIZEOF_ELT(d, e, s)
description fragment has unexpected format
static void dpdk_ops_vpp_free(struct rte_mempool *mp)
#define VLIB_BUFFER_PRE_DATA_SIZE
static_always_inline u32 vlib_buffer_get_default_data_size(vlib_main_t *vm)
VLIB_BUFFER_SET_EXT_HDR_SIZE(sizeof(struct rte_mempool_objhdr)+sizeof(struct rte_mbuf))
static int dpdk_ops_vpp_alloc(struct rte_mempool *mp)
#define vec_foreach(var, vec)
Vector iterator.
int CLIB_MULTIARCH_FN() dpdk_ops_vpp_enqueue_no_cache(struct rte_mempool *cmp, void *const *obj_table, unsigned n)
static void * vlib_buffer_ptr_from_index(uword buffer_mem_start, u32 buffer_index, uword offset)
static vlib_main_t * vlib_get_main(void)
#define clib_error(format, args...)
int CLIB_MULTIARCH_FN() dpdk_ops_vpp_enqueue(struct rte_mempool *mp, void *const *obj_table, unsigned n)
#define clib_warning(format, args...)
static unsigned dpdk_ops_vpp_get_count_no_cache(const struct rte_mempool *mp)
#define CLIB_MARCH_FN_POINTER(fn)
static_always_inline void dpdk_ops_vpp_enqueue_one(vlib_buffer_t *bt, void *obj)
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.
static void * clib_mem_alloc(uword size)
clib_error_t * dpdk_buffer_pools_create(vlib_main_t *vm)
VLIB buffer representation.