[dpdk-dev] [PATCH 2/5] enic: fix device to work with Xen DOM0

Liu, Jijiang jijiang.liu at intel.com
Tue Mar 10 08:08:44 CET 2015



> -----Original Message-----
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Stephen Hemminger
> Sent: Sunday, February 15, 2015 11:25 PM
> To: dev at dpdk.org
> Cc: Stephen Hemminger
> Subject: [dpdk-dev] [PATCH 2/5] enic: fix device to work with Xen DOM0
> 
> It is possible to passthrough a PCI device when running in Xen Paravirt mode.
> The device driver has to accomodate by using memory zones differently. This
> patch models the memory allocation for ENIC device based on changes already
> done for ixgbe and igb.
> 
> Build tested only; has not been tested on ENIC hardware.
> ---

Acked-by: Jijiang Liu <Jijiang.liu at intel.com>

> v2 -- this patch is added
> 
>  lib/librte_pmd_enic/enic_main.c     | 19 ++++++++++++++++---
>  lib/librte_pmd_enic/vnic/vnic_dev.c | 19 +++++++++++++++----
>  2 files changed, 31 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/librte_pmd_enic/enic_main.c b/lib/librte_pmd_enic/enic_main.c
> index 48fdca2..0be5172 100644
> --- a/lib/librte_pmd_enic/enic_main.c
> +++ b/lib/librte_pmd_enic/enic_main.c
> @@ -537,8 +537,14 @@ enic_alloc_consistent(__rte_unused void *priv, size_t
> size,
>  	const struct rte_memzone *rz;
>  	*dma_handle = 0;
> 
> -	rz = rte_memzone_reserve_aligned((const char *)name,
> -		size, 0, 0, ENIC_ALIGN);
> +#ifdef RTE_LIBRTE_XEN_DOM0
> +	if (is_xen_dom0_supported())
> +		rz = rte_memzone_reserve_bounded((char *)name, size,
> +					 0, 0, ENIC_ALIGN, RTE_PGSIZE_2M);
> +	else
> +#endif
> +		rz = rte_memzone_reserve_aligned((char *)name, size,
> +					 0, 0, ENIC_ALIGN);
>  	if (!rz) {
>  		pr_err("%s : Failed to allocate memory requested for %s",
>  			__func__, name);
> @@ -546,7 +552,14 @@ enic_alloc_consistent(__rte_unused void *priv, size_t
> size,
>  	}
> 
>  	vaddr = rz->addr;
> -	*dma_handle = (dma_addr_t)rz->phys_addr;
> +
> +#ifdef RTE_LIBRTE_XEN_DOM0
> +	if (is_xen_dom0_supported())
> +		*dma_handle = rte_mem_phy2mch(rz->memseg_id,
> +					      rz->phys_addr);
> +	else
> +#endif
> +		*dma_handle = (dma_addr_t)rz->phys_addr;
> 
>  	return vaddr;
>  }
> diff --git a/lib/librte_pmd_enic/vnic/vnic_dev.c
> b/lib/librte_pmd_enic/vnic/vnic_dev.c
> index 6407994..e660aaf 100644
> --- a/lib/librte_pmd_enic/vnic/vnic_dev.c
> +++ b/lib/librte_pmd_enic/vnic/vnic_dev.c
> @@ -276,9 +276,14 @@ int vnic_dev_alloc_desc_ring(__attribute__((unused))
> struct vnic_dev *vdev,
> 
>  	vnic_dev_desc_ring_size(ring, desc_count, desc_size);
> 
> -	rz = rte_memzone_reserve_aligned(z_name,
> -		ring->size_unaligned, socket_id,
> -		0, ENIC_ALIGN);
> +#ifdef RTE_LIBRTE_XEN_DOM0
> +	if (is_xen_dom0_supported())
> +		rz = rte_memzone_reserve_bounded(z_name, ring-
> >size_unaligned,
> +					 socket_id, 0, ENIC_ALIGN,
> RTE_PGSIZE_2M);
> +	else
> +#endif
> +		rz = rte_memzone_reserve_aligned(z_name, ring-
> >size_unaligned,
> +					 socket_id, 0, ENIC_ALIGN);
>  	if (!rz) {
>  		pr_err("Failed to allocate ring (size=%d), aborting\n",
>  			(int)ring->size);
> @@ -292,7 +297,13 @@ int vnic_dev_alloc_desc_ring(__attribute__((unused))
> struct vnic_dev *vdev,
>  		return -ENOMEM;
>  	}
> 
> -	ring->base_addr_unaligned = (dma_addr_t)rz->phys_addr;
> +#ifdef RTE_LIBRTE_XEN_DOM0
> +	if (is_xen_dom0_supported())
> +		ring->base_addr_unaligned = rte_mem_phy2mch(rz-
> >memseg_id,
> +							    rz->phys_addr);
> +	else
> +#endif
> +		ring->base_addr_unaligned = (dma_addr_t)rz->phys_addr;
> 
>  	ring->base_addr = ALIGN(ring->base_addr_unaligned,
>  		ring->base_align);
> --
> 2.1.4





More information about the dev mailing list