From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hemant Agrawal Subject: Re: [PATCH 19/32] net/dpaa2: adding eth ops to dpaa2 Date: Mon, 19 Dec 2016 20:58:18 +0530 Message-ID: References: <1480875447-23680-1-git-send-email-hemant.agrawal@nxp.com> <1480875447-23680-20-git-send-email-hemant.agrawal@nxp.com> <1b3c3956-d2d8-e6b4-b058-369dca9fa63a@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Cc: , , To: Ferruh Yigit , Return-path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0042.outbound.protection.outlook.com [104.47.33.42]) by dpdk.org (Postfix) with ESMTP id 120FDF97F for ; Mon, 19 Dec 2016 16:28:27 +0100 (CET) In-Reply-To: <1b3c3956-d2d8-e6b4-b058-369dca9fa63a@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 12/7/2016 1:19 AM, Ferruh Yigit wrote: > 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. > I agree, I have taken care of it in v2. >> + 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? > No, it is not required for the dpaa2 type devices. the common data is being initialized in these function itself. >> + >> + priv->hw = dpni_dev; >> + priv->hw_id = hw_id; >> + eth_dev->dev_ops = &dpaa2_ethdev_ops; >> return 0; >> } >> > >