[dpdk-dev] [PATCH 18/32] net/dpaa2: introducing dpaa2 pmd driver

Ferruh Yigit ferruh.yigit at intel.com
Tue Dec 6 20:49:32 CET 2016


On 12/4/2016 6:17 PM, Hemant Agrawal wrote:
> add support for dpaa2 architucture fsl-mc bus based dpaa2 pmd driver.
> 
> Signed-off-by: Hemant Agrawal <hemant.agrawal at nxp.com>
> ---
>  drivers/net/dpaa2/Makefile       |  1 +
>  drivers/net/dpaa2/dpaa2_bus.c    | 64 ++++++++++++++++++++++++++++++++++++++--
>  drivers/net/dpaa2/dpaa2_ethdev.c | 54 +++++++++++++++++++++++++++++++++
>  drivers/net/dpaa2/dpaa2_ethdev.h | 39 ++++++++++++++++++++++++
>  4 files changed, 155 insertions(+), 3 deletions(-)
>  create mode 100644 drivers/net/dpaa2/dpaa2_ethdev.c
>  create mode 100644 drivers/net/dpaa2/dpaa2_ethdev.h
> 
> diff --git a/drivers/net/dpaa2/Makefile b/drivers/net/dpaa2/Makefile
> index c4981b2..45e28d2 100644
> --- a/drivers/net/dpaa2/Makefile
> +++ b/drivers/net/dpaa2/Makefile
> @@ -61,6 +61,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += base/dpaa2_hw_dpbp.c
>  SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2_vfio.c
>  # Interfaces with DPDK
>  SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2_bus.c
> +SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2_ethdev.c
>  
>  # library dependencies
>  DEPDIRS-y += lib/librte_eal
> diff --git a/drivers/net/dpaa2/dpaa2_bus.c b/drivers/net/dpaa2/dpaa2_bus.c
> index fa88599..81eaca8 100644
> --- a/drivers/net/dpaa2/dpaa2_bus.c
> +++ b/drivers/net/dpaa2/dpaa2_bus.c
> @@ -44,6 +44,7 @@
>  
>  #include "eal_filesystem.h"
>  #include "eal_private.h"
> +#include "dpaa2_ethdev.h"
>  #include "dpaa2_vfio.h"
>  
>  #define DPAA2_BUS_LOG(level, fmt, args...) \
> @@ -77,10 +78,67 @@
>  	rte_eal_bus_remove_driver(&driver->driver);
>  }
>  
> -int rte_dpaa2_probe(struct rte_driver *driver __rte_unused,
> -				    struct rte_device *device __rte_unused)
> +static void
> +dpaa2_device_name(struct rte_dpaa2_device *dev __rte_unused, char *ethdev_name,
> +		      unsigned int len)
>  {
> -	return 0;
> +	/* Fill the name of the ethernet device based on the device info
> +	 */
> +	/* TODO This is dummy */
> +	strncpy(ethdev_name, "dpaa2_device", len);
> +}
> +
> +int rte_dpaa2_probe(struct rte_driver *drv, struct rte_device *dev)
> +{
> +	struct eth_driver    *eth_drv;
> +	struct rte_eth_dev *eth_dev;
> +	struct rte_dpaa2_driver *dpaa2_drv;
> +	struct rte_dpaa2_device *dpaa2_dev;
> +	char ethdev_name[RTE_ETH_NAME_MAX_LEN];
> +
> +	int diag;
> +
> +	dpaa2_drv = container_of(drv, struct rte_dpaa2_driver, driver);
> +	dpaa2_dev = container_of(dev, struct rte_dpaa2_device, device);
> +
> +	eth_drv = (struct eth_driver *)dpaa2_drv;
> +
> +	dpaa2_device_name(dpaa2_dev, ethdev_name, sizeof(ethdev_name));
> +
> +	eth_dev = rte_eth_dev_allocate(ethdev_name);
> +	if (eth_dev == NULL)
> +		return -ENOMEM;
> +
> +	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
> +		eth_dev->data->dev_private = rte_zmalloc(
> +						"ethdev private structure",
> +						eth_drv->dev_private_size,
> +						RTE_CACHE_LINE_SIZE);
> +		if (eth_dev->data->dev_private == NULL)
> +			rte_panic("Cannot allocate memzone for private port"
> +				  " data\n");

Should this error kill all app, or return an error for this PMD that is
probed.

> +	}
> +	eth_dev->device = &dpaa2_dev->device;
> +	eth_dev->driver = eth_drv;
> +	eth_dev->data->rx_mbuf_alloc_failed = 0;
> +
> +	/* init user callbacks */
> +	TAILQ_INIT(&eth_dev->link_intr_cbs);
> +
> +	/*
> +	 * Set the default MTU.
> +	 */
> +	eth_dev->data->mtu = ETHER_MTU;
> +
> +	/* Invoke PMD device initialization function */
> +	diag = dpaa2_dev_init(eth_dev);

This should call PMD specific init "eth_drv->eth_dev_init()" instead of
direct call the PMD function, right? What will happen if there are
multiple device/drivers in the bus?

> +	if (diag == 0)
> +		return 0;
> +
> +	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
> +		rte_free(eth_dev->data->dev_private);
> +	rte_eth_dev_release_port(eth_dev);
> +	return diag;
>  }
>  
>  int rte_dpaa2_scan(struct rte_bus *bus_d)
> diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
> new file mode 100644
> index 0000000..17dfff6
> --- /dev/null
> +++ b/drivers/net/dpaa2/dpaa2_ethdev.c
> @@ -0,0 +1,54 @@
> +/*-
> + *   BSD LICENSE
> + *
> + *   Copyright (c) 2015-2016 Freescale Semiconductor, Inc. All rights reserved.
> + *   Copyright (c) 2016 NXP. All rights reserved.
> + *
> + *   Redistribution and use in source and binary forms, with or without
> + *   modification, are permitted provided that the following conditions
> + *   are met:
> + *
> + *     * Redistributions of source code must retain the above copyright
> + *       notice, this list of conditions and the following disclaimer.
> + *     * Redistributions in binary form must reproduce the above copyright
> + *       notice, this list of conditions and the following disclaimer in
> + *       the documentation and/or other materials provided with the
> + *       distribution.
> + *     * Neither the name of Freescale Semiconductor, Inc nor the names of its
> + *       contributors may be used to endorse or promote products derived
> + *       from this software without specific prior written permission.
> + *
> + *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> + *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> + *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
> + *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
> + *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> + *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> + *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
> + *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
> + *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> + *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
> + *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + */
> +
> +#include <time.h>
> +#include <net/if.h>
> +
> +#include <rte_mbuf.h>
> +#include <rte_ethdev.h>
> +#include <rte_malloc.h>
> +#include <rte_memcpy.h>
> +#include <rte_string_fns.h>
> +#include <rte_cycles.h>
> +#include <rte_kvargs.h>
> +#include <rte_dev.h>
> +#include <rte_ethdev.h>
> +
> +/* DPDK Interfaces */
> +#include <dpaa2_ethdev.h>
> +
> +int
> +dpaa2_dev_init(struct rte_eth_dev *eth_dev __rte_unused)
> +{
> +	return 0;
> +}
> diff --git a/drivers/net/dpaa2/dpaa2_ethdev.h b/drivers/net/dpaa2/dpaa2_ethdev.h
> new file mode 100644
> index 0000000..0295868
> --- /dev/null
> +++ b/drivers/net/dpaa2/dpaa2_ethdev.h
> @@ -0,0 +1,39 @@
> +/*-
> + *   BSD LICENSE
> + *
> + *   Copyright (c) 2015-2016 Freescale Semiconductor, Inc. All rights reserved.
> + *   Copyright (c) 2016 NXP. All rights reserved.
> + *
> + *   Redistribution and use in source and binary forms, with or without
> + *   modification, are permitted provided that the following conditions
> + *   are met:
> + *
> + *     * Redistributions of source code must retain the above copyright
> + *       notice, this list of conditions and the following disclaimer.
> + *     * Redistributions in binary form must reproduce the above copyright
> + *       notice, this list of conditions and the following disclaimer in
> + *       the documentation and/or other materials provided with the
> + *       distribution.
> + *     * Neither the name of Freescale Semiconductor, Inc nor the names of its
> + *       contributors may be used to endorse or promote products derived
> + *       from this software without specific prior written permission.
> + *
> + *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> + *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> + *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
> + *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
> + *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> + *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> + *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
> + *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
> + *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> + *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
> + *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + */
> +
> +#ifndef _DPAA2_ETHDEV_H
> +#define _DPAA2_ETHDEV_H
> +
> +int dpaa2_dev_init(struct rte_eth_dev *eth_dev);
> +
> +#endif /* _DPAA2_ETHDEV_H */
> 



More information about the dev mailing list