From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olivier Matz Subject: [PATCH RFC 05/11] mbuf: merge physaddr and buf_len in a bitfield Date: Fri, 9 May 2014 16:50:32 +0200 Message-ID: <1399647038-15095-6-git-send-email-olivier.matz@6wind.com> References: <1399647038-15095-1-git-send-email-olivier.matz@6wind.com> To: dev-VfR2kkLFssw@public.gmane.org Return-path: In-Reply-To: <1399647038-15095-1-git-send-email-olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" 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 --- 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