From e01cda43a3551d8680787ed9db38c7eb38637c7a Mon Sep 17 00:00:00 2001 From: Yuichi Nakai Date: Wed, 22 Jul 2015 22:57:00 +0900 Subject: [PATCH] mempool: fix trailer address __mempool_get_trailer() calculated header's address. The address of trailer should set after element area. This patch fixes this calculating. Fixes: 97e7e685bfcd ("mempool: add structure for object trailers") Signed-off-by: Yuichi Nakai Acked-by: Olivier Matz --- lib/librte_mempool/rte_mempool.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h index ee67ce74dd..075bcdf200 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -271,12 +271,6 @@ static inline struct rte_mempool_objhdr *__mempool_get_header(void *obj) return RTE_PTR_SUB(obj, sizeof(struct rte_mempool_objhdr)); } -/* return the trailer of a mempool object (internal) */ -static inline struct rte_mempool_objtlr *__mempool_get_trailer(void *obj) -{ - return RTE_PTR_SUB(obj, sizeof(struct rte_mempool_objtlr)); -} - /** * Return a pointer to the mempool owning this object. * @@ -292,6 +286,13 @@ static inline struct rte_mempool *rte_mempool_from_obj(void *obj) return hdr->mp; } +/* return the trailer of a mempool object (internal) */ +static inline struct rte_mempool_objtlr *__mempool_get_trailer(void *obj) +{ + struct rte_mempool *mp = rte_mempool_from_obj(obj); + return RTE_PTR_ADD(obj, mp->elt_size); +} + /** * @internal Check and update cookies or panic. * -- 2.20.1