[dpdk-dev] [PATCH RFC 05/11] mbuf: merge physaddr and buf_len in a bitfield
Olivier Matz
olivier.matz at 6wind.com
Fri May 9 16:50:32 CEST 2014
The physical address is never greater than (1 << 48) = 256 TB.
We can win 2 bytes in the mbuf structure by merging the physical
address and the buffer length in the same bitfield.
Signed-off-by: Olivier Matz <olivier.matz at 6wind.com>
---
lib/librte_mbuf/rte_mbuf.c | 3 ++-
lib/librte_mbuf/rte_mbuf.h | 7 ++++---
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index c229525..9879095 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -104,7 +104,8 @@ rte_pktmbuf_init(struct rte_mempool *mp,
m->buf_len = (uint16_t)buf_len;
/* keep some headroom between start of buffer and data */
- m->data = (char*) m->buf_addr + RTE_MIN(RTE_PKTMBUF_HEADROOM, m->buf_len);
+ m->data = (char*) m->buf_addr + RTE_MIN(RTE_PKTMBUF_HEADROOM,
+ (uint16_t)m->buf_len);
/* init some constant fields */
m->pool = mp;
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 803b223..275f6b2 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -130,8 +130,8 @@ union rte_vlan_macip {
struct rte_mbuf {
struct rte_mempool *pool; /**< Pool from which mbuf was allocated. */
void *buf_addr; /**< Virtual address of segment buffer. */
- phys_addr_t buf_physaddr; /**< Physical address of segment buffer. */
- uint16_t buf_len; /**< Length of segment buffer. */
+ uint64_t buf_physaddr:48; /**< Physical address of segment buffer. */
+ uint64_t buf_len:16; /**< Length of segment buffer. */
#ifdef RTE_MBUF_REFCNT
/**
* 16-bit Reference counter.
@@ -148,8 +148,9 @@ struct rte_mbuf {
#else
uint16_t refcnt_reserved; /**< Do not use this field */
#endif
- uint16_t reserved; /**< Unused field. Required for padding. */
+
uint16_t ol_flags; /**< Offload features. */
+ uint32_t reserved; /**< Unused field. Required for padding. */
/* valid for any segment */
struct rte_mbuf *next; /**< Next segment of scattered packet. */
--
1.9.2
More information about the dev
mailing list