[dpdk-dev] [PATCH 28/32] net/dpaa2: add support for physical address usages

Ferruh Yigit ferruh.yigit at intel.com
Tue Dec 6 20:50:18 CET 2016


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 <hemant.agrawal at nxp.com>
> ---
>  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
> 



More information about the dev mailing list