[dpdk-dev] [PATCH v7 9/9] eal/rte_malloc: honor iova mode in virt2phy

Burakov, Anatoly anatoly.burakov at intel.com
Mon Sep 4 17:44:03 CEST 2017


> From: Santosh Shukla [mailto:santosh.shukla at caviumnetworks.com]
> Sent: Thursday, August 31, 2017 4:26 AM
> To: dev at dpdk.org
> Cc: thomas at monjalon.net; jerin.jacob at caviumnetworks.com;
> hemant.agrawal at nxp.com; olivier.matz at 6wind.com;
> maxime.coquelin at redhat.com; Gonzalez Monroy, Sergio
> <sergio.gonzalez.monroy at intel.com>; Richardson, Bruce
> <bruce.richardson at intel.com>; shreyansh.jain at nxp.com;
> gaetan.rivet at 6wind.com; Burakov, Anatoly <anatoly.burakov at intel.com>;
> stephen at networkplumber.org; aconole at redhat.com; Santosh Shukla
> <santosh.shukla at caviumnetworks.com>
> Subject: [PATCH v7 9/9] eal/rte_malloc: honor iova mode in virt2phy
> 
> Check iova mode and accordingly return phy addr.
> 
> Signed-off-by: Santosh Shukla <santosh.shukla at caviumnetworks.com>
> Signed-off-by: Jerin Jacob <jerin.jacob at caviumnetworks.com>
> Reviewed-by: Maxime Coquelin <maxime.coquelin at redhat.com>
> ---
>  lib/librte_eal/common/rte_malloc.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/librte_eal/common/rte_malloc.c
> b/lib/librte_eal/common/rte_malloc.c
> index 5c0627bf4..d65c05a4d 100644
> --- a/lib/librte_eal/common/rte_malloc.c
> +++ b/lib/librte_eal/common/rte_malloc.c
> @@ -251,10 +251,17 @@ rte_malloc_set_limit(__rte_unused const char
> *type,  phys_addr_t  rte_malloc_virt2phy(const void *addr)  {
> +	phys_addr_t paddr;
>  	const struct malloc_elem *elem = malloc_elem_from_data(addr);
>  	if (elem == NULL)
>  		return RTE_BAD_PHYS_ADDR;
>  	if (elem->ms->phys_addr == RTE_BAD_PHYS_ADDR)
>  		return RTE_BAD_PHYS_ADDR;
> -	return elem->ms->phys_addr + ((uintptr_t)addr - (uintptr_t)elem-
> >ms->addr);
> +
> +	if (rte_eal_iova_mode() == RTE_IOVA_VA)
> +		paddr = (uintptr_t)addr;
> +	else
> +		paddr = elem->ms->phys_addr +
> +			((uintptr_t)addr - (uintptr_t)elem->ms->addr);
> +	return paddr;
>  }

Hi Santosh,

I think there's a RTE_PTR_DIFF macro for stuff like this, but otherwise

Reviewed-by: Anatoly Burakov <anatoly.burakov at intel.com>


More information about the dev mailing list