From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 5572437B8 for ; Tue, 6 Dec 2016 20:49:59 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP; 06 Dec 2016 11:49:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,310,1477983600"; d="scan'208";a="1078335247" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.237.220.29]) ([10.237.220.29]) by fmsmga001.fm.intel.com with ESMTP; 06 Dec 2016 11:49:33 -0800 To: Hemant Agrawal , dev@dpdk.org References: <1480875447-23680-1-git-send-email-hemant.agrawal@nxp.com> <1480875447-23680-19-git-send-email-hemant.agrawal@nxp.com> Cc: thomas.monjalon@6wind.com, bruce.richardson@intel.com, shreyansh.jain@nxp.com From: Ferruh Yigit Message-ID: <2023a9a6-f342-8986-7ded-3703b3623a70@intel.com> Date: Tue, 6 Dec 2016 19:49:32 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <1480875447-23680-19-git-send-email-hemant.agrawal@nxp.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH 18/32] net/dpaa2: introducing dpaa2 pmd driver X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Dec 2016 19:50:00 -0000 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 > --- > 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(ð_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 > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +/* DPDK Interfaces */ > +#include > + > +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 */ >