From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 31FAD5599 for ; Tue, 6 Dec 2016 20:50:22 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP; 06 Dec 2016 11:50:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,310,1477983600"; d="scan'208";a="1078335713" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.237.220.29]) ([10.237.220.29]) by fmsmga001.fm.intel.com with ESMTP; 06 Dec 2016 11:50:18 -0800 To: Hemant Agrawal , dev@dpdk.org References: <1480875447-23680-1-git-send-email-hemant.agrawal@nxp.com> <1480875447-23680-29-git-send-email-hemant.agrawal@nxp.com> Cc: thomas.monjalon@6wind.com, bruce.richardson@intel.com, shreyansh.jain@nxp.com From: Ferruh Yigit Message-ID: <37c0dd45-94e1-9855-82dd-9ace63a33599@intel.com> Date: Tue, 6 Dec 2016 19:50:18 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <1480875447-23680-29-git-send-email-hemant.agrawal@nxp.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH 28/32] net/dpaa2: add support for physical address usages X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Dec 2016 19:50:22 -0000 On 12/4/2016 6:17 PM, Hemant Agrawal wrote: > DPAA2 HW accelerators with ARM SMMU can be configured > to use virtual or physical address from users space. > Adding support for Physical address (default). > > Signed-off-by: Hemant Agrawal > --- > config/defconfig_arm64-dpaa2-linuxapp-gcc | 1 + > drivers/net/dpaa2/Makefile | 1 + > drivers/net/dpaa2/base/dpaa2_hw_dpbp.c | 1 + > drivers/net/dpaa2/base/dpaa2_hw_pvt.h | 59 +++++++++++++++++++++++++++++++ > 4 files changed, 62 insertions(+) > > diff --git a/config/defconfig_arm64-dpaa2-linuxapp-gcc b/config/defconfig_arm64-dpaa2-linuxapp-gcc > index bcb6e88..7dc6d2d 100644 > --- a/config/defconfig_arm64-dpaa2-linuxapp-gcc > +++ b/config/defconfig_arm64-dpaa2-linuxapp-gcc > @@ -50,5 +50,6 @@ CONFIG_RTE_MBUF_DEFAULT_MEMPOOL_OPS="dpaa2" > # Compile software PMD backed by NXP DPAA2 files > # > CONFIG_RTE_LIBRTE_DPAA2_PMD=y > +CONFIG_RTE_LIBRTE_DPAA2_USE_PHYS_IOVA=y > CONFIG_RTE_LIBRTE_DPAA2_DEBUG_INIT=n > CONFIG_RTE_LIBRTE_DPAA2_DEBUG_DRIVER=n > diff --git a/drivers/net/dpaa2/Makefile b/drivers/net/dpaa2/Makefile > index 9e693cd..a8c3c04 100644 > --- a/drivers/net/dpaa2/Makefile > +++ b/drivers/net/dpaa2/Makefile > @@ -42,6 +42,7 @@ else > CFLAGS += -O3 > CFLAGS += $(WERROR_FLAGS) > endif > +CFLAGS +=-Wno-unused-function Will this flag be removed when DPAA2_VADDR_TO_IOV and DPAA2_IOVA_TO_VADDR macros used in next patches? > > CFLAGS += -I$(RTE_SDK)/drivers/net/dpaa2 > CFLAGS += -I$(RTE_SDK)/drivers/common/dpaa2/mc > diff --git a/drivers/net/dpaa2/base/dpaa2_hw_dpbp.c b/drivers/net/dpaa2/base/dpaa2_hw_dpbp.c > index 2b30036..5b7d593 100644 > --- a/drivers/net/dpaa2/base/dpaa2_hw_dpbp.c > +++ b/drivers/net/dpaa2/base/dpaa2_hw_dpbp.c > @@ -322,6 +322,7 @@ int hw_mbuf_alloc_bulk(struct rte_mempool *pool, > * i.e. first buffer is valid, > * remaining 6 buffers may be null > */ > + DPAA2_MODIFY_IOVA_TO_VADDR(bufs[i], uint64_t); > obj_table[n] = (struct rte_mbuf *)(bufs[i] - mbuf_size); > rte_mbuf_refcnt_set((struct rte_mbuf *)obj_table[n], 0); > PMD_TX_LOG(DEBUG, "Acquired %p address %p from BMAN", > diff --git a/drivers/net/dpaa2/base/dpaa2_hw_pvt.h b/drivers/net/dpaa2/base/dpaa2_hw_pvt.h > index d116fcd..a1afa23 100644 > --- a/drivers/net/dpaa2/base/dpaa2_hw_pvt.h > +++ b/drivers/net/dpaa2/base/dpaa2_hw_pvt.h > @@ -169,8 +169,67 @@ struct qbman_fle { > */ > #define DPAA2_EQ_RESP_ALWAYS 1 > > +#ifdef RTE_LIBRTE_DPAA2_USE_PHYS_IOVA > +/* todo - this is costly, need to write a fast coversion routine */ > +static void *dpaa2_mem_ptov(phys_addr_t paddr) > +{ > + const struct rte_memseg *memseg = rte_eal_get_physmem_layout(); > + int i; > + > + for (i = 0; i < RTE_MAX_MEMSEG && memseg[i].addr_64 != 0; i++) { > + if (paddr >= memseg[i].phys_addr && > + (char *)paddr < (char *)memseg[i].phys_addr + memseg[i].len) > + return (void *)(memseg[i].addr_64 > + + (paddr - memseg[i].phys_addr)); > + } > + return NULL; > +} > + > +static phys_addr_t dpaa2_mem_vtop(uint64_t vaddr) > +{ > + const struct rte_memseg *memseg = rte_eal_get_physmem_layout(); > + int i; > + > + for (i = 0; i < RTE_MAX_MEMSEG && memseg[i].addr_64 != 0; i++) { > + if (vaddr >= memseg[i].addr_64 && > + vaddr < memseg[i].addr_64 + memseg[i].len) > + return memseg[i].phys_addr > + + (vaddr - memseg[i].addr_64); > + } > + return (phys_addr_t)(NULL); > +} > + > +/** > + * When we are using Physical addresses as IO Virtual Addresses, > + * Need to call conversion routines dpaa2_mem_vtop & dpaa2_mem_ptov > + * whereever required. > + * These routines are called with help of below MACRO's > + */ > + > +#define DPAA2_MBUF_VADDR_TO_IOVA(mbuf) (mbuf->buf_physaddr) > + > +/** > + * macro to convert Virtual address to IOVA > + */ > +#define DPAA2_VADDR_TO_IOVA(_vaddr) dpaa2_mem_vtop((uint64_t)(_vaddr)) > + > +/** > + * macro to convert IOVA to Virtual address > + */ > +#define DPAA2_IOVA_TO_VADDR(_iova) dpaa2_mem_ptov((phys_addr_t)(_iova)) > + > +/** > + * macro to convert modify the memory containing IOVA to Virtual address > + */ > +#define DPAA2_MODIFY_IOVA_TO_VADDR(_mem, _type) \ > + {_mem = (_type)(dpaa2_mem_ptov((phys_addr_t)(_mem))); } > + > +#else /* RTE_LIBRTE_DPAA2_USE_PHYS_IOVA */ > + > #define DPAA2_MBUF_VADDR_TO_IOVA(mbuf) (mbuf->buf_addr) > #define DPAA2_VADDR_TO_IOVA(_vaddr) (_vaddr) > #define DPAA2_IOVA_TO_VADDR(_iova) (_iova) > +#define DPAA2_MODIFY_IOVA_TO_VADDR(_mem, _type) > > +#endif /* RTE_LIBRTE_DPAA2_USE_PHYS_IOVA */ > #endif >