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 2813BA0543; Fri, 12 Aug 2022 11:23:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B210B42C2E; Fri, 12 Aug 2022 11:22:50 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2101.outbound.protection.outlook.com [40.107.223.101]) by mails.dpdk.org (Postfix) with ESMTP id 0C2D442C2B for ; Fri, 12 Aug 2022 11:22:49 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=niVXEVX14URkKhTb71QxIPA34fxDohb5yWDab2s+Af8aSSXbUZG50cUdw2iThapPBJDXgzKBVLYOSTAYx/lGYn1g5THlTVZqn0sFRwg0M3wKTfQI2r6JoMAlCMaX1eQCFGq4NreU2FF7S7LHvMa2ioy9ZSw+sGQDNhOdSCx3XG/0mVYRXJkbNc8PcPbbS/948T+s0s2/Mc9x3Bl0J2fKKLBlTDp01t0btO7zfDnAEEC7dKJbExAD0vsA4NWMc1xOgcCfsLJNKHjjQ58x7syyR9XThgUAsZZJJ1OUnIqYZS0GV0duXbQSj8TsgjyyIQIZQ2uYUCeDI+CXYtyZkeumqA== 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=337qzlyEq4J1xNo9eJDjcNDPLVLCA4v/zYU8n3CnO5c=; b=SzaosJdG8H4ck9nf9N78+dMPKi1rjmwxNYs5ghfPpSr6l1yxSC0eYuIvSzWIig7F0/cGWH9+vTAoPWNq0VTww8M5RPBFoWzTvx5ZBwoevbthuQyynUtABPb+Y9KmNoHeAMVbsOp+/mdveoLo6tyRdWyYLZ3NmflaFQwBtY9/DN5bOTgt8m0WrUjNh2+mZ58qYuBEQmn8kfcORs0PVZMe0PcNE2xn+Qn5iHzLAgDY/KcfXBRYqZvI1Ru3Bfvujq04ma27zFjON6d1FCySZiWndTqjzrO9o7GsSxXpx2v2v5nKU71UCI6OeKsDBKKcZA/mFVPGQ/m7X3khS4km6gO2HQ== 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=337qzlyEq4J1xNo9eJDjcNDPLVLCA4v/zYU8n3CnO5c=; b=jrjjpb1J/YEiny4aWA35LYz74ujfOXcJzx0P6Su2jD3NK1GLHqfrZ96QBsE9GjgQrFp9OpDS7oZCbi4iyGhMCewIdTK7A/5HgcH/vcR7az0w0NBy4btkZbjasjhI28bhzcLHeq/itY/fC5kTWpTiE5bmUx58brNn3oExfsSDVG4= 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 PH0PR13MB5284.namprd13.prod.outlook.com (2603:10b6:510:f5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.9; Fri, 12 Aug 2022 09:22:47 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::402d:6abc:83a8:2431]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::402d:6abc:83a8:2431%5]) with mapi id 15.20.5525.009; Fri, 12 Aug 2022 09:22:47 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v6 06/12] net/nfp: add flower PF related routines Date: Fri, 12 Aug 2022 17:22:07 +0800 Message-Id: <1660296133-35266-7-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1660296133-35266-1-git-send-email-chaoyong.he@corigine.com> References: <1660296133-35266-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2PR01CA0046.apcprd01.prod.exchangelabs.com (2603:1096:4:193::18) 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: 65918bae-4bea-4964-af40-08da7c443888 X-MS-TrafficTypeDiagnostic: PH0PR13MB5284:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Nl7VajVdWWGNbzzTG2/8gwA/FN5z7engqu3MxYEFQ5y7Q85PMcboH1UK2l/36ZgrzkQrV5CCMmVDPg9rp5h3xrZoIT9zTCp4cEH3HBRYTbhfLsFh/oj8s4ixFoOzFmD8RwY+BgNVI3F6N7VvcRhHtlKnhPKsTju4T68uK8ye0RCsINUB7rdjkaMVfbQM/jcYCBXJgN6d0QCiya1CMufbWKrcsQTvL7XzXsYbDgtxCaY7dOpalo2GwHVE5rNQaIF4TVmN6Yz2/e1Ht9/dNZZeBhKuJ3Ap3uWo1KIfF36sJM/YiqxhPniOXHocN0anC/69bak0dslCauMqznbvTRsE/52S2k4k9HM5k3CNN/KU0ljthCmlRUdmV5mISIRUTQ/HX5HgoIkARyVLhbKtv0Kxkw5E+sKjdHlHnWqfkfulevyt3Yn1fFffVik8zZdN5iwwCXm2NX6a6zVHQr3S4o2BVmax+bNDk+4fCElQm/sTuxqRoScKTMCAMQW9MxQXIA8TjvFxSqrfddX+5c9sNODOD4fq+pOW+LoDkapdciif5oeXGftaqvtB2PXEFcp6iB5/SWcaDipvXnkcETznUIeWqxQxEedq/wG6UlKmjF7HCG8bxJZC+/0PqNrQ5q35djrc3dcoJMsvXoM7rPSMDBxw3L9dKPqYcadLQC9XD9A/MAlXWvoZSK2zbJQtPMu87JAXFC4yz+hkzgCVmVsVanW1Oub5FNYdUNtOoyE0LZZw87Z/VgV2Xk5tuKjpNoFgAZ7cLwhIsu9+cr+rJE4RNpWPCYScRlE9kMrzw80Nq+6FspS1EQvUei+OZCyN4LkGsnBQk6iJXLiR0PO4ihFzsx2vYQWEg/yZWtRhSGPOH8k9sd0= 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)(346002)(376002)(39850400004)(136003)(396003)(366004)(86362001)(36756003)(6666004)(41300700001)(44832011)(38100700002)(38350700002)(83380400001)(186003)(6506007)(66574015)(6916009)(26005)(107886003)(6512007)(2616005)(5660300002)(8936002)(478600001)(52116002)(2906002)(6486002)(8676002)(316002)(66476007)(4326008)(66946007)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Vkl5ZkRya1dnMSt6NWVBL3NMNWxXUC9pOVZxUW1TdkhRakt1d3AwRkkyRFVU?= =?utf-8?B?UHFsc20waDMwTFFTcUFydm5LQmhCdDR6UlVWZ2Z3Y0Z1UlVlWlZtWHh3dFVK?= =?utf-8?B?N3VGWTYxeXFGSHc1YkhWL213NjZnSUpuaU9WZlRGVENVcXJGTjFOS3BDME9x?= =?utf-8?B?RmVBZ2xUTXFpUkVISk5iSi9CZjZ6OGRvTnNQMC9CTFpTV0hKbVJBclhnNkZ3?= =?utf-8?B?M3Z2N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lRYVFRTRXdlYmN6Y3ov?= =?utf-8?B?aCtGaTNMWWcxZm1lM0NHZ1kzS2tDRkJxS2QzeWdqNVA3cmxEdzhxdjFhZHZT?= =?utf-8?B?N3NRcWZwNndyMXFjZHpqL0xwMFpMOGtJeHV4ejZoUXViR1JNNVMzeHV3dDYy?= =?utf-8?B?Rnc9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 65918bae-4bea-4964-af40-08da7c443888 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2022 09:22:47.6792 (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: Za7mHVgyYuSZh8Rt2wg3s3jiYfgghJtgsTnv5h1E5eJ13JnLupkDTOttQMixCtlXYeZEHB0A0s7t9T6c19Yea3yEbjBvMt/AgmRR9ZWWxRM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5284 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 Adds the start/stop/close routine of the flower PF vNIC. And we reuse the configure/link_update routine. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- drivers/net/nfp/flower/nfp_flower.c | 186 ++++++++++++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index 6f6af19..43d4667 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 @@ -41,8 +42,168 @@ .tx_free_thresh = DEFAULT_TX_FREE_THRESH, }; +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 != 0) { + 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 != 0) { + 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_flower_priv_get(pf_dev); + + /* + * 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_DRV_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 const struct eth_dev_ops nfp_flower_pf_vnic_ops = { .dev_infos_get = nfp_net_infos_get, + .link_update = nfp_net_link_update, + .dev_configure = nfp_net_configure, + + .dev_start = nfp_flower_pf_start, + .dev_stop = nfp_flower_pf_stop, + .dev_close = nfp_flower_pf_close, }; static struct rte_service_spec flower_services[NFP_FLOWER_SERVICE_MAX] = { @@ -343,6 +504,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 != 0) { + 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) { @@ -400,6 +579,13 @@ goto pf_cpp_area_cleanup; } + /* Start the PF vNIC */ + ret = nfp_flower_start_pf_vnic(app_flower->pf_hw); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Could not start flower PF vNIC"); + goto pf_vnic_cleanup; + } + /* Start up flower services */ ret = nfp_flower_enable_services(app_flower); if (ret != 0) { -- 1.8.3.1