2
0
mirror of https://github.com/openvswitch/ovs synced 2025-09-03 07:45:30 +00:00

ofpbuf: Add ofpbuf_init_dpdk()

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
This commit is contained in:
Pravin Shelar
2014-03-31 13:22:39 -07:00
committed by Pravin B Shelar
parent 1f317cb5c2
commit d8a59e895d
2 changed files with 25 additions and 5 deletions

View File

@@ -22,6 +22,16 @@
#include "netdev-dpdk.h" #include "netdev-dpdk.h"
#include "util.h" #include "util.h"
static void
ofpbuf_init__(struct ofpbuf *b, size_t allocated, enum ofpbuf_source source)
{
b->allocated = allocated;
b->source = source;
b->l2 = NULL;
b->l2_5_ofs = b->l3_ofs = b->l4_ofs = UINT16_MAX;
list_poison(&b->list_node);
}
static void static void
ofpbuf_use__(struct ofpbuf *b, void *base, size_t allocated, ofpbuf_use__(struct ofpbuf *b, void *base, size_t allocated,
enum ofpbuf_source source) enum ofpbuf_source source)
@@ -30,11 +40,7 @@ ofpbuf_use__(struct ofpbuf *b, void *base, size_t allocated,
ofpbuf_set_data(b, base); ofpbuf_set_data(b, base);
ofpbuf_set_size(b, 0); ofpbuf_set_size(b, 0);
b->allocated = allocated; ofpbuf_init__(b, allocated, source);
b->source = source;
b->l2 = NULL;
b->l2_5_ofs = b->l3_ofs = b->l4_ofs = UINT16_MAX;
list_poison(&b->list_node);
} }
/* Initializes 'b' as an empty ofpbuf that contains the 'allocated' bytes of /* Initializes 'b' as an empty ofpbuf that contains the 'allocated' bytes of
@@ -101,6 +107,18 @@ ofpbuf_use_const(struct ofpbuf *b, const void *data, size_t size)
ofpbuf_set_size(b, size); ofpbuf_set_size(b, size);
} }
/* Initializes 'b' as an empty ofpbuf that contains the 'allocated' bytes of
* memory starting at 'base'. DPDK allocated ofpbuf and *data is allocated
* from one continous memory region, so in memory data start right after
* ofpbuf. Therefore there is special method to free this type of
* buffer. ofpbuf base, data and size are initialized by dpdk rcv() so no
* need to initialize those fields. */
void
ofpbuf_init_dpdk(struct ofpbuf *b, size_t allocated)
{
ofpbuf_init__(b, allocated, OFPBUF_DPDK);
}
/* Initializes 'b' as an empty ofpbuf with an initial capacity of 'size' /* Initializes 'b' as an empty ofpbuf with an initial capacity of 'size'
* bytes. */ * bytes. */
void void

View File

@@ -85,6 +85,8 @@ void ofpbuf_use_stack(struct ofpbuf *, void *, size_t);
void ofpbuf_use_stub(struct ofpbuf *, void *, size_t); void ofpbuf_use_stub(struct ofpbuf *, void *, size_t);
void ofpbuf_use_const(struct ofpbuf *, const void *, size_t); void ofpbuf_use_const(struct ofpbuf *, const void *, size_t);
void ofpbuf_init_dpdk(struct ofpbuf *b, size_t allocated);
void ofpbuf_init(struct ofpbuf *, size_t); void ofpbuf_init(struct ofpbuf *, size_t);
void ofpbuf_uninit(struct ofpbuf *); void ofpbuf_uninit(struct ofpbuf *);
static inline void *ofpbuf_get_uninit_pointer(struct ofpbuf *); static inline void *ofpbuf_get_uninit_pointer(struct ofpbuf *);