X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_mempool%2Frte_mempool.h;h=9745bf0d70b4a9e238f68652aca01f78c7ba6dad;hb=693f715da45c48ec1ec0fe4ba2f3b5ffd11ba53e;hp=a8054e139e840dcab55c95a37729f36fe72d5a81;hpb=00e481412a4c48412dc03a0b63fcf0c3dd3085f3;p=dpdk.git diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h index a8054e139e..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,15 +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 (struct rte_mempool_objhdr *)((char *)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 (struct rte_mempool_objtlr *)((char *)obj - - sizeof(struct rte_mempool_objtlr)); + return (struct rte_mempool_objhdr *)RTE_PTR_SUB(obj, sizeof(struct rte_mempool_objhdr)); } /** @@ -288,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. * @@ -393,11 +398,11 @@ typedef void (*rte_mempool_obj_iter_t)(void * /*obj_iter_arg*/, * * Iterate across objects of the given size and alignment in the * provided chunk of memory. The given memory buffer can consist of - * disjoint physical pages. + * disjointed physical pages. * - * For each object, calls the provided callback (if any). This function - * is used to populate mempool, walk through all elements of the - * mempool, estimate how many elements of the given size could be + * For each object, call the provided callback (if any). This function + * is used to populate a mempool, or walk through all the elements of a + * mempool, or estimate how many elements of the given size could be * created in the given memory buffer. * * @param vaddr @@ -406,6 +411,8 @@ typedef void (*rte_mempool_obj_iter_t)(void * /*obj_iter_arg*/, * Maximum number of objects to iterate through. * @param elt_sz * Size of each object. + * @param align + * Alignment of each object. * @param paddr * Array of physical addresses of the pages that comprises given memory * buffer. @@ -421,7 +428,6 @@ typedef void (*rte_mempool_obj_iter_t)(void * /*obj_iter_arg*/, * @return * Number of objects iterated through. */ - uint32_t rte_mempool_obj_iter(void *vaddr, uint32_t elt_num, size_t elt_sz, size_t align, const phys_addr_t paddr[], uint32_t pg_num, uint32_t pg_shift, @@ -634,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. * @@ -722,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. @@ -1255,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