From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id 66A678D97 for ; Wed, 18 May 2016 13:05:15 +0200 (CEST) Received: from glumotte.dev.6wind.com (unknown [10.16.0.195]) by proxy.6wind.com (Postfix) with ESMTP id 1024629BA9; Wed, 18 May 2016 13:03:38 +0200 (CEST) From: Olivier Matz To: dev@dpdk.org Cc: bruce.richardson@intel.com, stephen@networkplumber.org, keith.wiles@intel.com Date: Wed, 18 May 2016 13:04:34 +0200 Message-Id: <1463569496-31086-14-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 2.8.0.rc3 In-Reply-To: <1463569496-31086-1-git-send-email-olivier.matz@6wind.com> References: <1460629199-32489-1-git-send-email-olivier.matz@6wind.com> <1463569496-31086-1-git-send-email-olivier.matz@6wind.com> Subject: [dpdk-dev] [PATCH v3 13/35] mempool: store physical address in objects X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 May 2016 11:05:15 -0000 Store the physical address of the object in its header. It simplifies rte_mempool_virt2phy() and prepares the removing of the paddr[] table in the mempool header. Signed-off-by: Olivier Matz --- lib/librte_mempool/rte_mempool.c | 17 +++++++++++------ lib/librte_mempool/rte_mempool.h | 11 ++++++----- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 61e191e..ce12db5 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -133,19 +133,22 @@ static unsigned optimize_object_size(unsigned obj_size) typedef void (*rte_mempool_obj_iter_t)(void * /*obj_iter_arg*/, void * /*obj_start*/, void * /*obj_end*/, - uint32_t /*obj_index */); + uint32_t /*obj_index */, + phys_addr_t /*physaddr*/); static void -mempool_add_elem(struct rte_mempool *mp, void *obj) +mempool_add_elem(struct rte_mempool *mp, void *obj, phys_addr_t physaddr) { struct rte_mempool_objhdr *hdr; struct rte_mempool_objtlr *tlr __rte_unused; obj = (char *)obj + mp->header_size; + physaddr += mp->header_size; /* set mempool ptr in header */ hdr = RTE_PTR_SUB(obj, sizeof(*hdr)); hdr->mp = mp; + hdr->physaddr = physaddr; STAILQ_INSERT_TAIL(&mp->elt_list, hdr, next); #ifdef RTE_LIBRTE_MEMPOOL_DEBUG @@ -175,6 +178,7 @@ rte_mempool_obj_mem_iter(void *vaddr, uint32_t elt_num, size_t total_elt_sz, uint32_t pgn, pgf; uintptr_t end, start, va; uintptr_t pg_sz; + phys_addr_t physaddr; pg_sz = (uintptr_t)1 << pg_shift; va = (uintptr_t)vaddr; @@ -210,9 +214,10 @@ rte_mempool_obj_mem_iter(void *vaddr, uint32_t elt_num, size_t total_elt_sz, * otherwise, just skip that chunk unused. */ if (k == pgn) { + physaddr = paddr[k] + (start & (pg_sz - 1)); if (obj_iter != NULL) obj_iter(obj_iter_arg, (void *)start, - (void *)end, i); + (void *)end, i, physaddr); va = end; j += pgf; i++; @@ -249,11 +254,11 @@ rte_mempool_obj_iter(struct rte_mempool *mp, static void mempool_obj_populate(void *arg, void *start, void *end, - __rte_unused uint32_t idx) + __rte_unused uint32_t idx, phys_addr_t physaddr) { struct rte_mempool *mp = arg; - mempool_add_elem(mp, start); + mempool_add_elem(mp, start, physaddr); mp->elt_va_end = (uintptr_t)end; } @@ -358,7 +363,7 @@ rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz, uint32_t pg_shift) */ static void mempool_lelem_iter(void *arg, __rte_unused void *start, void *end, - __rte_unused uint32_t idx) + __rte_unused uint32_t idx, __rte_unused phys_addr_t physaddr) { *(uintptr_t *)arg = (uintptr_t)end; } diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h index 12215f6..4f95bdf 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -159,6 +159,7 @@ struct rte_mempool_objsz { struct rte_mempool_objhdr { STAILQ_ENTRY(rte_mempool_objhdr) next; /**< Next in list. */ struct rte_mempool *mp; /**< The mempool owning the object. */ + phys_addr_t physaddr; /**< Physical address of the object. */ #ifdef RTE_LIBRTE_MEMPOOL_DEBUG uint64_t cookie; /**< Debug cookie. */ #endif @@ -1131,13 +1132,13 @@ rte_mempool_empty(const struct rte_mempool *mp) * The physical address of the elt element. */ static inline phys_addr_t -rte_mempool_virt2phy(const struct rte_mempool *mp, const void *elt) +rte_mempool_virt2phy(__rte_unused const struct rte_mempool *mp, const void *elt) { if (rte_eal_has_hugepages()) { - 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); + const struct rte_mempool_objhdr *hdr; + hdr = (const struct rte_mempool_objhdr *)RTE_PTR_SUB(elt, + sizeof(*hdr)); + return hdr->physaddr; } else { /* * If huge pages are disabled, we cannot assume the -- 2.8.0.rc3