From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 90FD15582 for ; Tue, 6 Dec 2016 20:49:45 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP; 06 Dec 2016 11:49:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,310,1477983600"; d="scan'208";a="1078335315" 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:42 -0800 To: Hemant Agrawal , dev@dpdk.org References: <1480875447-23680-1-git-send-email-hemant.agrawal@nxp.com> <1480875447-23680-20-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: <1b3c3956-d2d8-e6b4-b058-369dca9fa63a@intel.com> Date: Tue, 6 Dec 2016 19:49:42 +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-20-git-send-email-hemant.agrawal@nxp.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH 19/32] net/dpaa2: adding eth ops to dpaa2 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:49:48 -0000 On 12/4/2016 6:17 PM, Hemant Agrawal wrote: > Signed-off-by: Hemant Agrawal > --- > drivers/net/dpaa2/base/dpaa2_hw_dpni.h | 50 +++++++++++++ > drivers/net/dpaa2/dpaa2_ethdev.c | 130 ++++++++++++++++++++++++++++++++- > 2 files changed, 179 insertions(+), 1 deletion(-) > create mode 100644 drivers/net/dpaa2/base/dpaa2_hw_dpni.h > > diff --git a/drivers/net/dpaa2/base/dpaa2_hw_dpni.h b/drivers/net/dpaa2/base/dpaa2_hw_dpni.h > new file mode 100644 > index 0000000..1b655e4 > --- /dev/null > +++ b/drivers/net/dpaa2/base/dpaa2_hw_dpni.h > @@ -0,0 +1,50 @@ > +/*- > + * BSD LICENSE > + * > + * Copyright (c) 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_HW_DPNI_H_ > +#define _DPAA2_HW_DPNI_H_ > + > +#include > +#include > +/*! Global MCP list */ > +extern void *(*mcp_ptr_list); extern keyword not needed. > + > + > +struct dpaa2_dev_priv { Any reason this is not in dpaa2_ethdev.h but in a new header file, since this looks like ethernet device private data. Just asking. > + void *hw; > + int32_t hw_id; > + uint16_t token; > + > + uint8_t flags; /*dpaa2 config flags */ > +}; > +#endif /* _DPAA2_DPNI_H_ */ > diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c > index 17dfff6..daf59c1 100644 > --- a/drivers/net/dpaa2/dpaa2_ethdev.c > +++ b/drivers/net/dpaa2/dpaa2_ethdev.c > @@ -43,12 +43,140 @@ > #include > #include > #include > +#include > > +#include > +#include > /* DPDK Interfaces */ > #include > > +static int > +dpaa2_eth_dev_configure(struct rte_eth_dev *dev) > +{ > + struct rte_eth_dev_data *data = dev->data; > + struct rte_eth_conf *eth_conf = &data->dev_conf; > + > + PMD_INIT_FUNC_TRACE(); > + > + /* Check for correct configuration */ > + if (eth_conf->rxmode.mq_mode != ETH_MQ_RX_RSS && > + data->nb_rx_queues > 1) { > + PMD_INIT_LOG(ERR, "Distribution is not enabled, " > + "but Rx queues more than 1\n"); > + return -1; > + } > + > + return 0; > +} > + > +static int > +dpaa2_dev_start(struct rte_eth_dev *dev) > +{ > + struct dpaa2_dev_priv *priv = dev->data->dev_private; > + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; > + int ret; > + > + PMD_INIT_FUNC_TRACE(); > + > + ret = dpni_enable(dpni, CMD_PRI_LOW, priv->token); > + if (ret) { > + PMD_INIT_LOG(ERR, "Failure %d in enabling dpni %d device\n", > + ret, priv->hw_id); > + return ret; > + } > + > + return 0; > +} > + > +/** > + * This routine disables all traffic on the adapter by issuing a > + * global reset on the MAC. > + */ > +static void > +dpaa2_dev_stop(struct rte_eth_dev *dev) > +{ > + struct dpaa2_dev_priv *priv = dev->data->dev_private; > + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; > + int ret; > + > + PMD_INIT_FUNC_TRACE(); > + > + ret = dpni_disable(dpni, CMD_PRI_LOW, priv->token); > + if (ret) { > + PMD_INIT_LOG(ERR, "Failure (ret %d) in disabling dpni %d dev\n", > + ret, priv->hw_id); > + return; > + } > +} > + > +static void > +dpaa2_dev_close(struct rte_eth_dev *dev) > +{ > + struct dpaa2_dev_priv *priv = dev->data->dev_private; > + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; > + int ret; > + > + PMD_INIT_FUNC_TRACE(); > + > + /* Clean the device first */ > + ret = dpni_reset(dpni, CMD_PRI_LOW, priv->token); > + if (ret) { > + PMD_INIT_LOG(ERR, "Failure cleaning dpni device with" > + " error code %d\n", ret); > + return; > + } > +} > + > +static struct eth_dev_ops dpaa2_ethdev_ops = { > + .dev_configure = dpaa2_eth_dev_configure, > + .dev_start = dpaa2_dev_start, > + .dev_stop = dpaa2_dev_stop, > + .dev_close = dpaa2_dev_close, > +}; > + > int > -dpaa2_dev_init(struct rte_eth_dev *eth_dev __rte_unused) > +dpaa2_dev_init(struct rte_eth_dev *eth_dev) > { > + struct rte_device *dev = eth_dev->device; > + struct rte_dpaa2_device *dpaa2_dev; > + struct fsl_mc_io *dpni_dev; > + struct dpaa2_dev_priv *priv = eth_dev->data->dev_private; > + int ret, hw_id; > + > + PMD_INIT_FUNC_TRACE(); > + > + /* For secondary processes, the primary has done all the work */ > + if (rte_eal_process_type() != RTE_PROC_PRIMARY) > + return 0; > + > + dpaa2_dev = container_of(dev, struct rte_dpaa2_device, device); > + > + hw_id = dpaa2_dev->object_id; > + > + dpni_dev = (struct fsl_mc_io *)malloc(sizeof(struct fsl_mc_io)); > + if (!dpni_dev) { > + PMD_INIT_LOG(ERR, "malloc failed for dpni device\n"); > + return -1; > + } > + > + dpni_dev->regs = mcp_ptr_list[0]; > + ret = dpni_open(dpni_dev, CMD_PRI_LOW, hw_id, &priv->token); > + if (ret) { > + PMD_INIT_LOG(ERR, "Failure in opening dpni@%d device with" > + " error code %d\n", hw_id, ret); > + return -1; > + } > + > + /* Clean the device first */ > + ret = dpni_reset(dpni_dev, CMD_PRI_LOW, priv->token); > + if (ret) { > + PMD_INIT_LOG(ERR, "Failure cleaning dpni@%d device with" > + " error code %d\n", hw_id, ret); > + return -1; > + } Is rte_eth_copy_pci_info() equivalent something required here, to set some default values? > + > + priv->hw = dpni_dev; > + priv->hw_id = hw_id; > + eth_dev->dev_ops = &dpaa2_ethdev_ops; > return 0; > } >