mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
ofpbuf: Add OFPBUF_DPDK type.
This will be used by DPDK for zero copy IO. Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
This commit is contained in:
@@ -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,6 +346,8 @@ ofpbuf_prealloc_headroom(struct ofpbuf *b, size_t size)
|
||||
void
|
||||
ofpbuf_trim(struct ofpbuf *b)
|
||||
{
|
||||
ovs_assert(b->source != OFPBUF_DPDK);
|
||||
|
||||
if (b->source == OFPBUF_MALLOC
|
||||
&& (ofpbuf_headroom(b) || ofpbuf_tailroom(b))) {
|
||||
ofpbuf_resize__(b, 0, 0);
|
||||
@@ -562,6 +567,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 {
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user