DPDK buf_len is only 16-bit wide ('allocated' was 32-bit), but it should be enough to store the number of allocated bytes.
This will reduce 'struct dp_packet' size. Signed-off-by: Daniele Di Proietto <diproiet...@vmware.com> --- lib/dp-packet.c | 6 +++--- lib/dp-packet.h | 26 +++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/lib/dp-packet.c b/lib/dp-packet.c index 375b7b7..31fe9d3 100644 --- a/lib/dp-packet.c +++ b/lib/dp-packet.c @@ -25,7 +25,7 @@ static void dp_packet_init__(struct dp_packet *b, size_t allocated, enum dp_packet_source source) { - b->allocated = allocated; + dp_packet_set_allocated(b, allocated); b->source = source; b->l2_pad_size = 0; b->l2_5_ofs = b->l3_ofs = b->l4_ofs = UINT16_MAX; @@ -243,7 +243,7 @@ dp_packet_resize__(struct dp_packet *b, size_t new_headroom, size_t new_tailroom OVS_NOT_REACHED(); } - b->allocated = new_allocated; + dp_packet_set_allocated(b, new_allocated); dp_packet_set_base(b, new_base); new_data = (char *) new_base + new_headroom; @@ -441,7 +441,7 @@ dp_packet_to_string(const struct dp_packet *b, size_t maxbytes) ds_init(&s); ds_put_format(&s, "size=%"PRIu32", allocated=%"PRIu32", head=%"PRIuSIZE", tail=%"PRIuSIZE"\n", - dp_packet_size(b), b->allocated, + dp_packet_size(b), dp_packet_get_allocated(b), dp_packet_headroom(b), dp_packet_tailroom(b)); ds_put_hex_dump(&s, dp_packet_data(b), MIN(dp_packet_size(b), maxbytes), 0, false); return ds_cstr(&s); diff --git a/lib/dp-packet.h b/lib/dp-packet.h index 54a3445..1d10d99 100644 --- a/lib/dp-packet.h +++ b/lib/dp-packet.h @@ -44,12 +44,11 @@ struct dp_packet { struct rte_mbuf mbuf; /* DPDK mbuf */ #else void *base_; /* First byte of allocated space. */ + uint16_t allocated_; /* Number of bytes allocated. */ uint16_t data_ofs; /* First byte actually in use. */ uint32_t size_; /* Number of bytes in use. */ uint32_t rss_hash; /* Packet hash. */ #endif - uint32_t allocated; /* Number of bytes allocated. */ - enum dp_packet_source source; /* Source of memory allocated as 'base'. */ uint8_t l2_pad_size; /* Detected l2 padding size. * Padding is non-pullable. */ @@ -69,6 +68,9 @@ static inline void dp_packet_set_base(struct dp_packet *, void *); static inline uint32_t dp_packet_size(const struct dp_packet *); static inline void dp_packet_set_size(struct dp_packet *, uint32_t); +static inline uint16_t dp_packet_get_allocated(const struct dp_packet *); +static inline void dp_packet_set_allocated(struct dp_packet *, uint16_t); + void * dp_packet_resize_l2(struct dp_packet *, int increment); void * dp_packet_resize_l2_5(struct dp_packet *, int increment); static inline void * dp_packet_l2(const struct dp_packet *); @@ -194,7 +196,7 @@ static inline void *dp_packet_tail(const struct dp_packet *b) * not necessarily in use) in 'b'. */ static inline void *dp_packet_end(const struct dp_packet *b) { - return (char *) dp_packet_base(b) + b->allocated; + return (char *) dp_packet_base(b) + dp_packet_get_allocated(b); } /* Returns the number of bytes of headroom in 'b', that is, the number of bytes @@ -408,6 +410,15 @@ static inline void __packet_set_data(struct dp_packet *b, uint16_t v) b->mbuf.data_off = v; } +static inline uint16_t dp_packet_get_allocated(const struct dp_packet *b) +{ + return b->mbuf.buf_len; +} + +static inline void dp_packet_set_allocated(struct dp_packet *b, uint16_t s) +{ + b->mbuf.buf_len = s; +} #else static inline void * dp_packet_base(const struct dp_packet *b) { @@ -439,6 +450,15 @@ static inline void __packet_set_data(struct dp_packet *b, uint16_t v) b->data_ofs = v; } +static inline uint16_t dp_packet_get_allocated(const struct dp_packet *b) +{ + return b->allocated_; +} + +static inline void dp_packet_set_allocated(struct dp_packet *b, uint16_t s) +{ + b->allocated_ = s; +} #endif static inline void * dp_packet_data(const struct dp_packet *b) -- 2.1.4 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev