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 ABC8FA0543; Fri, 12 Aug 2022 12:23:31 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D34AB42C33; Fri, 12 Aug 2022 12:22:56 +0200 (CEST) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2127.outbound.protection.outlook.com [40.107.100.127]) by mails.dpdk.org (Postfix) with ESMTP id D8F3B42C13 for ; Fri, 12 Aug 2022 12:22:55 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ksBHry0ORVxa03c/5XFAsCDJW8WLjZf6RmqMN65YUhb3UViAH2V0+iiqIrPjeuhk75OkfvWq13NohSH52cU8imsUX0TRoaRi0ZPswUG6m/HcbGBCLPhW0SzcinVg5mcnWXf7NhWIqoAKJWEvDPFNHFLnAgd0dbTvcrzYlR8jJFKeUROACycm5b32sXYclNyi/+o/QuQlDsNhIylTH63ozRIbcyY5BRQ1M0xqRL6WPqcm2SJ8cTd6/wM5MYNgDXy4etBkzXVzzbH726rs+HMZ8sXLntSpyR5N1vV1Sb3fixDiUAIYggvcOwyRhGRAztVTYYlgKcIA/q/ZdjzdQ6MJjg== 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=i8Nc5lnoCo1qS0Njv5twPs6iZ9Mma+u313BToX1Ai/k8xALucqAWjognRWx8nykrvvYwKB2x5zHbi3GoVzX02DOytrN8MlxiFRkEBeaTQfFQVbOuqG2znGpFE1SNJM1xPBeea/6/Zi2vA7gvfBgvespRlVZI4DaEzRiORtIP7oA89DLf2cn4wc2lYg9ggXnh4GynfhoB7kcNuMlTJiT/nbJa0OCcpCbVhG+ii64agbtXbB1jwV33OrrEgURXiydhAZxm+b8/gqz/2M5pgqcKB6zT5wta2gLR0Tb1E1uwH17JQR0/Wsd3cFYg6U1FP9hoAUjl9IuN0thp/Pw41EmvDQ== 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=en2Ql/9fe9lVbyS45hbQm4+TaOUzQ1fufN5MR+CjDdtuarjWvXCXDohTZhLswroSBDACBoJkrvPcsdMLq8k283yEWwLtus8lDcbHtFy7h/LbVuy7GRXTSeUTbiL5Ii8t2CfMvjVep9ZPINK8u+uwot72z/BKnmEPjuNZRrc+aE4= 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 MN2PR13MB2624.namprd13.prod.outlook.com (2603:10b6:208:ed::10) 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 10:22:54 +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 10:22:54 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v7 06/12] net/nfp: add flower PF related routines Date: Fri, 12 Aug 2022 18:22:24 +0800 Message-Id: <1660299750-10668-7-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1660299750-10668-1-git-send-email-chaoyong.he@corigine.com> References: <1660299750-10668-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: BYAPR01CA0019.prod.exchangelabs.com (2603:10b6:a02:80::32) 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: 260548e5-1596-4cce-15bd-08da7c4c9e54 X-MS-TrafficTypeDiagnostic: MN2PR13MB2624:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4PnUOyaKXi7eM6fIINJadptIqF4dy+3AI/ZFPLBVm7NVxcPWTKFU26qcTpW5sh7XAV5ZgIQX/XiunGEB2tAU3W4e7yAZkUW+GnkCF9g8nY4ZLkDtfsQYKjzTQ+sgKfMV8T2ozYMtrab1BldzreyZp7uOcVr9c1+xrhJs5s7EGbd08knZ2GNmHI+Tg7AWkOU1tc+PH3jBqyL9hiZmdAu2D6cF0F44zkVAlsQQwkCMNhxg3FTLwNJz21zTnklBYJRKBCTfL7SwjTyGdDfpTeHldDxVuyZpDIevG36g3+6RGIuvuuz5DwhMvh7UMhrYgsvk3wYo23IhB/7abO51GDgYh82zU41Q8kTldFL4/6TEatRkaUgMzUSqw0opBpWCWDs1MOXbfZNxDBBl9PZqO5t1MVmi/dyvXN0u5kVanZCJta+z863t88TbLHIzYRIy1vT9N5m/r4gUvKmGH3DuyjkjRk0R/WJ7m/IuQLDC8FgsoZwKSJhDXCe2oossqe6MJSvV9J7oy1AVMhTJxOYtj0hBGUj/1prOZzRfRNOjoRX/s6fYS5AV7IvvR2zzQ+gYXOFxbPLLw1CJo3IpvjYU6RnO3gFPIuD72X1r0oJNT7Anfr/Clf18/VZtfJk5hIluI272Mq18WzSuexIpsQeJBAoNjk9Rh8wcPw8cuRKJAurnYxGxfuTEyPMijLLOcCa7eHRDjA7KiEKd4hl+GX9m3As0zZ/VeidpXbpO4fcgosWxdbtWM3ZzCJ71QfwgE7DfM8d0wsmYppJhK7OjbpC3BakC1K7SvSF+Eqq+gt+jS6TYny0= 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)(366004)(396003)(346002)(39840400004)(376002)(136003)(52116002)(41300700001)(6916009)(316002)(26005)(478600001)(6486002)(6512007)(186003)(6666004)(36756003)(83380400001)(5660300002)(66574015)(2616005)(107886003)(6506007)(66476007)(8676002)(4326008)(66556008)(66946007)(44832011)(86362001)(2906002)(8936002)(38100700002)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?YzlEMC9LUmtmZGJZRFlxZnlOWWhwdUllRXVSVHdncXZ6NHRQSHk4dys3OVJ6?= =?utf-8?B?N1dIcVRHTzB4RnlzbFZCN2U1Wm5zMGRZc1dTejdwWVN4M01vK0wwVkFPNytH?= =?utf-8?B?VHhmQ2RGMVY2V2RQOGR4aWdUaUpPRlJOK1QzbTdMdEpmd25yV0hWMkk4Wlp2?= =?utf-8?B?OXB6b0ozS3RqZk9iRktQa1JBb2g3QjBqZnJYazBic1g3dno4NVJDL1Fub2hI?= =?utf-8?B?bGdQSmQ2TGVIZEQrSm1UM1ZoR3R3WXd5U0xkWTV3enZva1Roa2tQdTlIMWNX?= =?utf-8?B?OW43Mkp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SHdkMDJZeGdT?= =?utf-8?B?bWcyWU93TkQzS3pxQ0NHZ295UXZOSEJBQzlLUXRIZ2k4ZFpUUEsxSVZNdm1w?= =?utf-8?B?c0E9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 260548e5-1596-4cce-15bd-08da7c4c9e54 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2022 10:22:54.4202 (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: v4LNETlSNqpS4M9wLqlkaR99I2Rkt47Y9Y5oabCLzVpT42L9WM23hFoREQ9LF9C4NiPVBbzNsoljJaZVX7kCA8UoBNADiK7+6zORPRH5zN4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR13MB2624 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