[dpdk-dev] [PATCH 1/4] xen: allow choosing dom0 support at runtime

Neil Horman nhorman at tuxdriver.com
Sat Feb 14 20:25:07 CET 2015


On Sat, Feb 14, 2015 at 01:06:45PM -0500, Stephen Hemminger wrote:
> The previous code would only allow building library and application
> so that it ran on Xen DOM0 or not on DOM0. This changes that to
> a runtime flag.
> 
> Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
> ---
>  lib/librte_eal/common/include/rte_memory.h |  4 +++
>  lib/librte_eal/linuxapp/eal/eal_memory.c   |  7 ++++
>  lib/librte_ether/rte_ethdev.c              | 22 ++++++++++++
>  lib/librte_ether/rte_ethdev.h              | 23 ++++++++++++
>  lib/librte_mempool/rte_mempool.c           | 26 +++++++-------
>  lib/librte_pmd_e1000/em_rxtx.c             | 30 +++-------------
>  lib/librte_pmd_e1000/igb_rxtx.c            | 52 +++++++++------------------
>  lib/librte_pmd_ixgbe/ixgbe_rxtx.c          | 58 +++++++++---------------------
>  8 files changed, 108 insertions(+), 114 deletions(-)
> 
> diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h
> index 7f8103f..ab6c1ff 100644
> --- a/lib/librte_eal/common/include/rte_memory.h
> +++ b/lib/librte_eal/common/include/rte_memory.h
> @@ -176,6 +176,10 @@ unsigned rte_memory_get_nchannel(void);
>  unsigned rte_memory_get_nrank(void);
>  
>  #ifdef RTE_LIBRTE_XEN_DOM0
> +
> +/**< Internal use only - should DOM0 memory mapping be used */
> +extern int is_xen_dom0_supported(void);
> +
>  /**
>   * Return the physical address of elt, which is an element of the pool mp.
>   *
> diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
> index a67a1b0..4afda2a 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_memory.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
> @@ -98,6 +98,13 @@
>  #include "eal_filesystem.h"
>  #include "eal_hugepages.h"
>  
> +#ifdef RTE_LIBRTE_XEN_DOM0
> +int is_xen_dom0_supported(void)
> +{
> +	return internal_config.xen_dom0_support;
> +}
> +#endif
> +
>  /**
>   * @file
>   * Huge page mapping under linux
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> index ea3a1fb..457e0bc 100644
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -2825,6 +2825,27 @@ _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
>  	}
>  	rte_spinlock_unlock(&rte_eth_dev_cb_lock);
>  }
> +
> +const struct rte_memzone *
> +rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name,
> +			 uint16_t queue_id, size_t size, unsigned align,
> +			 int socket_id)
> +{
> +	char z_name[RTE_MEMZONE_NAMESIZE];
> +	const struct rte_memzone *mz;
> +
> +	snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
> +		 dev->driver->pci_drv.name, ring_name,
> +		 dev->data->port_id, queue_id);
> +
> +	mz = rte_memzone_lookup(z_name);
> +	if (mz)
> +		return mz;
> +
> +	return rte_memzone_reserve_bounded(z_name, size,
> +					   socket_id, 0, align, RTE_PGSIZE_2M);
> +}
> +
>  #ifdef RTE_NIC_BYPASS
>  int rte_eth_dev_bypass_init(uint8_t port_id)
>  {
> @@ -3003,6 +3024,7 @@ rte_eth_dev_bypass_wd_reset(uint8_t port_id)
>  	(*dev->dev_ops->bypass_wd_reset)(dev);
>  	return 0;
>  }
> +
Nit: I think you meant to remove that space.

>  #endif
>  
>  int
> diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> index 1200c1c..747acb5 100644
> --- a/lib/librte_ether/rte_ethdev.h
> +++ b/lib/librte_ether/rte_ethdev.h
> @@ -3664,6 +3664,29 @@ int rte_eth_dev_filter_supported(uint8_t port_id, enum rte_filter_type filter_ty
>  int rte_eth_dev_filter_ctrl(uint8_t port_id, enum rte_filter_type filter_type,
>  			enum rte_filter_op filter_op, void *arg);
>  
> +/**
> + * Create memzone for HW rings.
> + * malloc can't be used as the physical address is needed.
> + * If the memzone is already created, then this function returns a ptr
> + * to the old one.
> + *
> + * @param eth_dev
> + *   The *eth_dev* pointer is the address of the *rte_eth_dev* structure
> + * @param name
> + *   The name of the memory zone
> + * @param queue_id
> + *   The index of the queue to add to name
> + * @param size
> + *   The sizeof of the memory area
> + * @param align
> + *   Alignment for resulting memzone. Must be a power of 2.
> + * @param socket_id
> + *   The *socket_id* argument is the socket identifier in case of NUMA.
> + */
> +const struct rte_memzone *
> +rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name,
> +			 uint16_t queue_id, size_t size,
> +			 unsigned align, int socket_id);
I think this is an exported funciton right?  It needs to be added to the version
map.

neil



More information about the dev mailing list