This will be used by DPDK for zero copy IO.
Signed-off-by: Pravin B Shelar <[email protected]>
---
v1-v2:
Added comment.
---
lib/ofpbuf.c | 7 ++++++-
lib/ofpbuf.h | 3 ++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/lib/ofpbuf.c b/lib/ofpbuf.c
index 0eed428..249fbaa 100644
--- a/lib/ofpbuf.c
+++ b/lib/ofpbuf.c
@@ -265,6 +265,9 @@ ofpbuf_resize__(struct ofpbuf *b, size_t new_headroom,
size_t new_tailroom)
new_allocated = new_headroom + b->size + new_tailroom;
switch (b->source) {
+ case OFPBUF_DPDK:
+ OVS_NOT_REACHED();
+
case OFPBUF_MALLOC:
if (new_headroom == ofpbuf_headroom(b)) {
new_base = xrealloc(b->base, new_allocated);
@@ -343,7 +346,7 @@ ofpbuf_prealloc_headroom(struct ofpbuf *b, size_t size)
void
ofpbuf_trim(struct ofpbuf *b)
{
- if (b->source == OFPBUF_MALLOC
+ if ((b->source == OFPBUF_MALLOC || b->source == OFPBUF_DPDK)
&& (ofpbuf_headroom(b) || ofpbuf_tailroom(b))) {
ofpbuf_resize__(b, 0, 0);
}
@@ -562,6 +565,8 @@ void *
ofpbuf_steal_data(struct ofpbuf *b)
{
void *p;
+ ovs_assert(b->source != OFPBUF_DPDK);
+
if (b->source == OFPBUF_MALLOC && b->data == b->base) {
p = b->data;
} else {
diff --git a/lib/ofpbuf.h b/lib/ofpbuf.h
index 7407d8b..7662989 100644
--- a/lib/ofpbuf.h
+++ b/lib/ofpbuf.h
@@ -29,7 +29,8 @@ extern "C" {
enum ofpbuf_source {
OFPBUF_MALLOC, /* Obtained via malloc(). */
OFPBUF_STACK, /* Un-movable stack space or static buffer. */
- OFPBUF_STUB /* Starts on stack, may expand into heap. */
+ OFPBUF_STUB, /* Starts on stack, may expand into heap. */
+ OFPBUF_DPDK, /* buffer data is from DPDK allocated memory.
*/
};
/* Buffer for holding arbitrary data. An ofpbuf is automatically reallocated
--
1.7.9.5
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev