X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_mempool%2Frte_mempool.h;h=9745bf0d70b4a9e238f68652aca01f78c7ba6dad;hb=693f715da45c48ec1ec0fe4ba2f3b5ffd11ba53e;hp=6d4ce9abf4e578ddf17ea56c752a2ebbe23505e0;hpb=6cf14ce4ce6cb8a9a26c20769f20a8bf34a4491f;p=dpdk.git diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h index 6d4ce9abf4..9745bf0d70 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -142,6 +142,12 @@ struct rte_mempool_objsz { /** Mempool over one chunk of physically continuous memory */ #define MEMPOOL_PG_NUM_DEFAULT 1 +#ifndef RTE_MEMPOOL_ALIGN +#define RTE_MEMPOOL_ALIGN RTE_CACHE_LINE_SIZE +#endif + +#define RTE_MEMPOOL_ALIGN_MASK (RTE_MEMPOOL_ALIGN - 1) + /** * Mempool object header structure * @@ -262,13 +268,7 @@ struct rte_mempool { /* return the header of a mempool object (internal) */ 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 (struct rte_mempool_objhdr *)RTE_PTR_SUB(obj, sizeof(struct rte_mempool_objhdr)); } /** @@ -286,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 (struct rte_mempool_objtlr *)RTE_PTR_ADD(obj, mp->elt_size); +} + /** * @internal Check and update cookies or panic. * @@ -633,7 +640,6 @@ rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size, int socket_id, unsigned flags, void *vaddr, const phys_addr_t paddr[], uint32_t pg_num, uint32_t pg_shift); -#ifdef RTE_LIBRTE_XEN_DOM0 /** * Create a new mempool named *name* in memory on Xen Dom0. * @@ -721,7 +727,7 @@ rte_dom0_mempool_create(const char *name, unsigned n, unsigned elt_size, rte_mempool_ctor_t *mp_init, void *mp_init_arg, rte_mempool_obj_ctor_t *obj_init, void *obj_init_arg, int socket_id, unsigned flags); -#endif + /** * Dump the status of the mempool to the console. @@ -1254,7 +1260,7 @@ rte_mempool_virt2phy(const struct rte_mempool *mp, const void *elt) uintptr_t off; off = (const char *)elt - (const char *)mp->elt_va_start; - return (mp->elt_pa[off >> mp->pg_shift] + (off & mp->pg_mask)); + return mp->elt_pa[off >> mp->pg_shift] + (off & mp->pg_mask); } else { /* * If huge pages are disabled, we cannot assume the