From patchwork Fri Jun 24 02:53:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chaoyong He X-Patchwork-Id: 113368 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org 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> 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?q?eha81mENUlmL80ZdYMHYgN/yB3OJ?= =?utf-8?q?azDOqi2U/b/Ap8qR47NwSockxYwmLIrPT1hQVduSZwQvmehkfU0Ly+NmlDKyTYgrK?= =?utf-8?q?t/SbC9nwXYFd4/HtWJ0xDo10d9fPLGazrcbE4b7T97oXBlnxA0qm38bs+YOXM/IHE?= =?utf-8?q?Uqier6ZrIzWgfoJSPoq2JPRsPkXMeq+og6qcucI5NzJylK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/NCLbnbyjJ?= =?utf-8?q?gkeSW+r7yQCckoqo3qjzxNtvmDRTg5cxE9eX/6H4kJU6dbD3c7hmbKO64+An8xic5?= =?utf-8?q?qqshoA69ysYTxcJVPYqWu/J8wbKIyKto8Px2bZnuaji/BN+w98VFNwsZkMvrtKVYL?= =?utf-8?q?6JECN8NKwcuZy+Td0Iq+UK+yjju1uDcAfDuUjOV9TCpHjKM5PhRs9piLc6I8X0Pyu?= =?utf-8?q?85VgSxmAWxSw2rrQPaND0sscab1PfvYpWjRCfg4P3Smrl90FKrarQymbeksgACtkk?= =?utf-8?q?5Ofmf/oaZpRpLcKRZyU9iji5k6gKyu8dD+HRP7/EPK+4XeveGWzuNVHaFWwa7QE/K?= =?utf-8?q?9FcoIBctc1vj0XN98LsVHShw8Nv968z2ALcJF0LgwWysS2EITkt75s0pVVV1KcNig?= =?utf-8?q?HFJESTGuVZJYvHfNR0c3/w/rl4RJgmMfyfE8EKnY1tx1Ku6KAPI7mppJmXgB7I1dl?= =?utf-8?q?mjEzGPiRN/JpHjENYG6MsZT5u+z0/YgtgQ=3D=3D?= 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;