summaryrefslogtreecommitdiffstats
path: root/vlib
diff options
context:
space:
mode:
Diffstat (limited to 'vlib')
-rw-r--r--vlib/vlib/buffer.c9
-rw-r--r--vlib/vlib/buffer_funcs.h1
-rw-r--r--vlib/vlib/dpdk_buffer.c19
3 files changed, 28 insertions, 1 deletions
diff --git a/vlib/vlib/buffer.c b/vlib/vlib/buffer.c
index 332b43044d3..c28a0c54889 100644
--- a/vlib/vlib/buffer.c
+++ b/vlib/vlib/buffer.c
@@ -1248,6 +1248,14 @@ vlib_buffer_chain_append_data_with_alloc(vlib_main_t *vm,
return copied;
}
+/*
+ * Fills in the required rte_mbuf fields for chained buffers given a VLIB chain.
+ */
+void vlib_buffer_chain_validate (vlib_main_t * vm, vlib_buffer_t * b_first)
+{
+ return;
+}
+
static void vlib_serialize_tx (serialize_main_header_t * m, serialize_stream_t * s)
{
vlib_main_t * vm;
@@ -1460,4 +1468,3 @@ VLIB_CLI_COMMAND (show_buffers_command, static) = {
.short_help = "Show packet buffer allocation",
.function = show_buffers,
};
-
diff --git a/vlib/vlib/buffer_funcs.h b/vlib/vlib/buffer_funcs.h
index 2ea506a094e..eea417a94f0 100644
--- a/vlib/vlib/buffer_funcs.h
+++ b/vlib/vlib/buffer_funcs.h
@@ -506,6 +506,7 @@ vlib_buffer_chain_append_data_with_alloc(vlib_main_t *vm,
vlib_buffer_t *first,
vlib_buffer_t **last,
void * data, u16 data_len);
+void vlib_buffer_chain_validate(vlib_main_t *vm, vlib_buffer_t *first);
format_function_t format_vlib_buffer, format_vlib_buffer_and_data, format_vlib_buffer_contents;
diff --git a/vlib/vlib/dpdk_buffer.c b/vlib/vlib/dpdk_buffer.c
index 145720dd7a4..04a6447d633 100644
--- a/vlib/vlib/dpdk_buffer.c
+++ b/vlib/vlib/dpdk_buffer.c
@@ -910,6 +910,25 @@ vlib_buffer_chain_append_data_with_alloc(vlib_main_t *vm,
return copied;
}
+/*
+ * Fills in the required rte_mbuf fields for chained buffers given a VLIB chain.
+ */
+void vlib_buffer_chain_validate (vlib_main_t * vm, vlib_buffer_t * b_first)
+{
+ vlib_buffer_t *b = b_first, *prev = b_first;
+ struct rte_mbuf *mb_first = ((struct rte_mbuf *) b) - 1;
+
+ mb_first->pkt_len = mb_first-> data_len = b_first->current_length;
+ while (b->flags & VLIB_BUFFER_NEXT_PRESENT) {
+ b = vlib_get_buffer(vm, b->next_buffer);
+ mb_first->nb_segs++;
+ mb_first->pkt_len += b->current_length;
+ (((struct rte_mbuf *) prev) - 1)->next = (((struct rte_mbuf *) b) - 1);
+ (((struct rte_mbuf *) b) - 1)->data_len = b->current_length;
+ prev = b;
+ }
+}
+
clib_error_t *
vlib_buffer_pool_create(vlib_main_t * vm, unsigned num_mbufs,
unsigned mbuf_size, unsigned socket_id)