From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 034C8A0032; Fri, 24 Jun 2022 04:55:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 736014282C; Fri, 24 Jun 2022 04:55:12 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2120.outbound.protection.outlook.com [40.107.237.120]) by mails.dpdk.org (Postfix) with ESMTP id F08F342B6D for ; Fri, 24 Jun 2022 04:55:08 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cFHpsW1RCTAeIFgJWA4vgiSPU9k6TmJvIztxT0FHZuX8Psj5aJ75qWVm3zQ1g/i6a6BSTVHaHKET9YT747O6BiA+AQaVMKEHANtmT7Yp6KSZIqzB8EANrG1yUu1pHATYXCG5g4kS7r5dbbSNg+itBD+03SLWgfkMuX1aT6RDAFyfBf5zeElRYVVtmn22TVET08UEwHc8el2GFn/LGpino+x1Ttmtl4mxe4ednfzXjQAAtcnlXveEF7ZoWBKIErwICHmddfW+uN+lxGxErahel5x2BxoF21NVhDSZNlZkBH1KoHa/8tXbHgMI66mCKMR4k/gyWgLvdnpFb+tM1Z+mYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cpnvv2m5wSiwn8P7s//J2yovHkcAe3eJDmqoCFV/paE=; b=ccpXT88SYg9qFK/g5apejZL4MjR6i0VuahIZWdvnGiLH7qY+9028S5gmiyGJ/2MMmer55oud979kBTWkLGRTBUJLa2GMGfLeyLBYWZ7F5CNP7dd/k5NUigHo3n5pMSuc1MxBerkqAiPyYhKEJJuHC+k0zOqrMlzUMosoABbjL5nsQD+n8cqcVAn3gKW+XHZ91Mr9O6Dwz5Wp/ZESZkrTtYQVF+B35A+uuYwPah131ouHVrQmxYx1kfEF1uhbSsM9sxvzGjDPh3GBIloOc5QGEnM4YLlJzjs13kt4viYfkB8726Uqf+tFSNKbnarZ+iYhqm7Jj8pgBOzHxwO6VX/wmg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cpnvv2m5wSiwn8P7s//J2yovHkcAe3eJDmqoCFV/paE=; b=cvD4FJUB/Mgj5l68bqExUrl8fhbWUnhcBR0eErrqAp+QWOJirB4BmnfYdN+CL98/d0Mkgpuaij6O4+IbnLgVWrGgz+frIetXE1PAXmXo+VRLKCG4ZcOKT0rcsZAADVfFjQcvyqr3I8gM0LOzr8RCDgwjHe+JRpJiSZtwQGCHpFA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by MN2PR13MB2752.namprd13.prod.outlook.com (2603:10b6:208:f2::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.15; Fri, 24 Jun 2022 02:55:07 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::5d9e:9ce5:51d1:2021]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::5d9e:9ce5:51d1:2021%7]) with mapi id 15.20.5373.015; Fri, 24 Jun 2022 02:55:07 +0000 From: Chaoyong He To: dev@dpdk.org Cc: niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v3 06/12] net/nfp: add flower PF related routines Date: Fri, 24 Jun 2022 10:53:55 +0800 Message-Id: <1656039241-20955-7-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1656039241-20955-1-git-send-email-chaoyong.he@corigine.com> References: <1656039241-20955-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2PR02CA0030.apcprd02.prod.outlook.com (2603:1096:4:195::17) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b8b8f094-d15f-4c3b-89dd-08da558cf201 X-MS-TrafficTypeDiagnostic: MN2PR13MB2752:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UHEVr1m699yW4k8EbQ0qVPtrJ5msUjgT78fz9/mR+frc4gufulEl2z8FDHxiRGkXGoCP4ZOI759ajdSyfsxfhKsosYYAWF1D5tFLmMEb/0fdVnITHSaG9M1BF4SXu2u5zABAMRuAU8lbNAPw1ytug9cEmG3PW/n5oR6hGVKTK9os/4OQYFndZI6fyqj0k3zu7bYl97aJbwQDkC3WP5ur/iu/D56sxXlWvmrGYyiFhtMaQYRE/omq8Yr5hVy3+Jdz3Dc5jOBeje6p6miIEc6O/dVycLn5/SQkr6TJpm3KlnQM2uGp5eM///I6YflI1kaqz+0q846PrMRpKmHcVPeG2hVF/YN852JUSwHxRQhkbjOJ47eIEdvQxMCxYBQqJLOubo+jBWRWzutg+ffjql4pyVVde0JelrM6U6O2nTknX0QqPGcJ+zGO86RdsnLIRUK130y7j4CXp711gbAQ2vOD9adL9i5LLeog2XxITITEpq5EWGToaLSYwSDKNfohVEa853ABfcNZSAGbh7GNS9jDJ61vHAwBvqvpQAf8Z8w2CVBno7+jnnW7lCyJOEyPk5J6Wjz43UUGjO9yn7GYkraMLsn2PX7jXdsJaVJziParrqxyX5IRHWnfklo2jlnMY7mU/dclWcM0Ui+3AE6Do8PUaXyUZkTP+Oqd8bbD5r3KYhLqy6RlDaaSnYK3ncr4k0LTtcc1LONApQ0WrqFyVtTKVTSvAJUfitijihQ/WST59nYzwEPOb53b7FycYaHjoV1pdh58U512uo/0YNRqymzu+PAyd8Rbl0FZ9IRZOFw+fp+4la1J0zln8wXWOQvkHpd5JtEEFipyFsJVdxdFHOr4ew== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(39830400003)(376002)(366004)(136003)(346002)(396003)(66556008)(2906002)(66946007)(26005)(83380400001)(6916009)(66476007)(6486002)(2616005)(8676002)(41300700001)(38100700002)(4326008)(6506007)(6512007)(66574015)(44832011)(86362001)(478600001)(36756003)(186003)(52116002)(316002)(6666004)(38350700002)(8936002)(107886003)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ZWhhODFtRU5VbG1MODBaZFlNSFlnTi95QjNPSmF6RE9xaTJVL2IvQXA4cVI0?= =?utf-8?B?N053U29ja3hZd21MSXJQVDFoUVZkdVNad1F2bWVoa2ZVMEx5K05tbERLeVRZ?= =?utf-8?B?Z3JLdC9TYkM5bndYWUZkNC9IdFdKMHhEbzEwZDlmUExHYXpyY2JFNGI3VDk3?= =?utf-8?B?b1hCbG54QTBxbTM4YnMrWU9YTS9JSEVVcWllcjZackl6V2dmb0pTUG9xMkpQ?= =?utf-8?B?UnNQa1hNZXErb2c2cWN1Y0k1TnpKeWxLWGJ4b0huSVlTaGZWZnhkRnJZQ2hZ?= =?utf-8?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lmRThFS25ZMXR4MUt1NktBUEk3?= =?utf-8?B?bXBwSm1YZ0I3STFkbG1qRXpHUGlSTi9KcEhqRU5ZRzZNc1pUNXUrejAvWWd0?= =?utf-8?B?Z1E9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: b8b8f094-d15f-4c3b-89dd-08da558cf201 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2022 02:55:07.2659 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DwaWHdirwxW/KIUKjh6e6MG6CysvhesHenwnFS3rsCB2358e3j8HaX7vaV/BtovmnyATh6i88TOA0IhQabBlh3NfM20s+G35fIb94EeJf0s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR13MB2752 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This commit adds the start/stop/close routine of the flower PF vNIC. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- drivers/net/nfp/flower/nfp_flower.c | 193 ++++++++++++++++++++++++++++++++++++ 1 file changed, 193 insertions(+) diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index 0a0b1db..417155e 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -37,11 +38,178 @@ return 0; } +static int +nfp_flower_pf_start(struct rte_eth_dev *dev) +{ + int ret; + uint32_t new_ctrl; + uint32_t update = 0; + struct nfp_net_hw *hw; + + hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + + /* Disabling queues just in case... */ + nfp_net_disable_queues(dev); + + /* Enabling the required queues in the device */ + nfp_net_enable_queues(dev); + + new_ctrl = nfp_check_offloads(dev); + + /* Writing configuration parameters in the device */ + nfp_net_params_setup(hw); + + nfp_net_rss_config_default(dev); + update |= NFP_NET_CFG_UPDATE_RSS; + + if (hw->cap & NFP_NET_CFG_CTRL_RSS2) + new_ctrl |= NFP_NET_CFG_CTRL_RSS2; + else + new_ctrl |= NFP_NET_CFG_CTRL_RSS; + + /* Enable device */ + new_ctrl |= NFP_NET_CFG_CTRL_ENABLE; + + update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING; + + if (hw->cap & NFP_NET_CFG_CTRL_RINGCFG) + new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG; + + nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl); + + /* If an error when reconfig we avoid to change hw state */ + ret = nfp_net_reconfig(hw, new_ctrl, update); + if (ret) { + PMD_INIT_LOG(ERR, "Failed to reconfig PF vnic"); + return -EIO; + } + + hw->ctrl = new_ctrl; + + /* Setup the freelist ring */ + ret = nfp_net_rx_freelist_setup(dev); + if (ret) { + PMD_INIT_LOG(ERR, "Error with flower PF vNIC freelist setup"); + return -EIO; + } + + return 0; +} + +/* Stop device: disable rx and tx functions to allow for reconfiguring. */ +static int +nfp_flower_pf_stop(struct rte_eth_dev *dev) +{ + uint16_t i; + struct nfp_net_hw *hw; + struct nfp_net_txq *this_tx_q; + struct nfp_net_rxq *this_rx_q; + + hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + + nfp_net_disable_queues(dev); + + /* Clear queues */ + for (i = 0; i < dev->data->nb_tx_queues; i++) { + this_tx_q = (struct nfp_net_txq *)dev->data->tx_queues[i]; + nfp_net_reset_tx_queue(this_tx_q); + } + + for (i = 0; i < dev->data->nb_rx_queues; i++) { + this_rx_q = (struct nfp_net_rxq *)dev->data->rx_queues[i]; + nfp_net_reset_rx_queue(this_rx_q); + } + + if (rte_eal_process_type() == RTE_PROC_PRIMARY) + /* Configure the physical port down */ + nfp_eth_set_configured(hw->cpp, hw->nfp_idx, 0); + else + nfp_eth_set_configured(dev->process_private, hw->nfp_idx, 0); + + return 0; +} + +/* Reset and stop device. The device can not be restarted. */ +static int +nfp_flower_pf_close(struct rte_eth_dev *dev) +{ + uint16_t i; + struct nfp_net_hw *hw; + struct nfp_pf_dev *pf_dev; + struct nfp_net_txq *this_tx_q; + struct nfp_net_rxq *this_rx_q; + struct rte_pci_device *pci_dev; + struct nfp_app_flower *app_flower; + + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + pf_dev = NFP_NET_DEV_PRIVATE_TO_PF(dev->data->dev_private); + hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + pci_dev = RTE_ETH_DEV_TO_PCI(dev); + app_flower = NFP_APP_PRIV_TO_APP_FLOWER(pf_dev->app_priv); + + /* + * We assume that the DPDK application is stopping all the + * threads/queues before calling the device close function. + */ + + nfp_net_disable_queues(dev); + + /* Clear queues */ + for (i = 0; i < dev->data->nb_tx_queues; i++) { + this_tx_q = (struct nfp_net_txq *)dev->data->tx_queues[i]; + nfp_net_reset_tx_queue(this_tx_q); + } + + for (i = 0; i < dev->data->nb_rx_queues; i++) { + this_rx_q = (struct nfp_net_rxq *)dev->data->rx_queues[i]; + nfp_net_reset_rx_queue(this_rx_q); + } + + /* Cancel possible impending LSC work here before releasing the port*/ + rte_eal_alarm_cancel(nfp_net_dev_interrupt_delayed_handler, (void *)dev); + + nn_cfg_writeb(hw, NFP_NET_CFG_LSC, 0xff); + + rte_eth_dev_release_port(dev); + + /* Now it is safe to free all PF resources */ + PMD_INIT_LOG(INFO, "Freeing PF resources"); + nfp_cpp_area_free(pf_dev->ctrl_area); + nfp_cpp_area_free(pf_dev->hwqueues_area); + free(pf_dev->hwinfo); + free(pf_dev->sym_tbl); + nfp_cpp_free(pf_dev->cpp); + rte_free(app_flower); + rte_free(pf_dev); + + rte_intr_disable(pci_dev->intr_handle); + + /* unregister callback func from eal lib */ + rte_intr_callback_unregister(pci_dev->intr_handle, + nfp_net_dev_interrupt_handler, (void *)dev); + + return 0; +} + +static int +nfp_flower_pf_link_update(__rte_unused struct rte_eth_dev *dev, + __rte_unused int wait_to_complete) +{ + return 0; +} + static const struct eth_dev_ops nfp_flower_pf_dev_ops = { .dev_configure = nfp_flower_pf_configure, /* Use the normal dev_infos_get functionality in the NFP PMD */ .dev_infos_get = nfp_net_infos_get, + + .dev_start = nfp_flower_pf_start, + .dev_stop = nfp_flower_pf_stop, + .dev_close = nfp_flower_pf_close, + .link_update = nfp_flower_pf_link_update, }; static struct rte_service_spec flower_services[NFP_FLOWER_SERVICE_MAX] = { @@ -381,6 +549,24 @@ return ret; } +static int +nfp_flower_start_pf_vnic(struct nfp_net_hw *hw) +{ + int ret; + uint16_t port_id; + + port_id = hw->eth_dev->data->port_id; + + /* Start the device */ + ret = rte_eth_dev_start(port_id); + if (ret) { + PMD_INIT_LOG(ERR, "Could not start PF device %d", port_id); + return ret; + } + + return 0; +} + int nfp_init_app_flower(struct nfp_pf_dev *pf_dev) { @@ -438,6 +624,13 @@ goto pf_cpp_area_cleanup; } + /* Start the PF vNIC */ + ret = nfp_flower_start_pf_vnic(app_flower->pf_hw); + if (ret) { + PMD_INIT_LOG(ERR, "Could not start flower PF vNIC"); + goto pf_vnic_cleanup; + } + /* Start up flower services */ if (nfp_flower_enable_services(app_flower)) { ret = -ESRCH; -- 1.8.3.1