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 601FAA00C5; Tue, 21 Jun 2022 12:34:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4033342B74; Tue, 21 Jun 2022 12:34:10 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2135.outbound.protection.outlook.com [40.107.237.135]) by mails.dpdk.org (Postfix) with ESMTP id 0D76142B6E for ; Tue, 21 Jun 2022 12:34:08 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gjDPmYL6HDeFiiqZPAic/0b3Neour7oeFd/hVvl4/m26U7jbZ56+CjSG5kaC6Mjl0eDwYPswzM3kYFjZf//jgaLgN8YlLt9VIDI00+JdABbpvtHlUHaqj8ZkJy8lxGmh1Kq1vgT2rdhhZ/zekC/XBqhd+J6lUIY4BTcONwgn0ogxw0NSqVSq+K9ZNtab9xeSQOEUJYOBXFQ9AFDLaxYAfu1OeqPwGzfEI4uwfECGeSireFPqoajrWSzxxfpqPRmjYgKJjth9gkSKsEsVJFkMewhPcIBCpQH9mIds+lVcQ3XVg2aqcgnpBsbSAOBctWMLfFc9b279mwqy0vel8E88YA== 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=UZRQco2uVkvvOB18neWBmb5qSvgwIM9eiFPrHUx5zmoQv5qhBitFtwlA3zBOIQWGWyVmjnh+/9RTyzF/VIYAHYBVzRbUnuTClEEB7cEb1kj19vL5PAs+OVwtZDHz7oseLl9ReSAlkJxrAv/btjGM3VdFu0ZnQps+1rWePdShuZrOoTc+GxINpb0XVqw9IOzlM9Vze0jrGahccfpcHnu6lS5GP930bIIHrXibQdT8zv1MxUmjwOt7xXkfvNjGko6aLEgrxdza/Sep8pPxbcyog4flTAG8ja5BUAs7rxkYQBi8U7S60zqDLQHGjkrkIcMfX6tEC3JBPGRDmeCQkV8hIw== 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=BldzizuaeCbpIljyukQcRhBXAIg/wGNhHvxaOqPBSTMzn8Emi6DaME6y4WiOhjYMLhy1cluPQtwIY9c4xiZwxuvvPYkev+NAi/vqIwn/THgi7qmMcq8MbMmzRmIo5yMtTgHutEXdHtwtBBA5Oq9ZiOE2lamc6tq1QLfLCvo56JU= 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 MN2PR13MB3086.namprd13.prod.outlook.com (2603:10b6:208:135::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.15; Tue, 21 Jun 2022 10:34:06 +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; Tue, 21 Jun 2022 10:34:06 +0000 From: Chaoyong He To: dev@dpdk.org Cc: niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v2 06/12] net/nfp: add flower PF related routines Date: Tue, 21 Jun 2022 18:33:02 +0800 Message-Id: <1655807588-7320-7-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1655807588-7320-1-git-send-email-chaoyong.he@corigine.com> References: <1655807588-7320-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: OS0PR01CA0018.jpnprd01.prod.outlook.com (2603:1096:604:24::23) 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: ddffc835-8398-45c5-6729-08da53719162 X-MS-TrafficTypeDiagnostic: MN2PR13MB3086:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LWi4vdOaYIr7Hza6wKnQufqQ8FKAbzOmjnmhQ7yHnG0aNxdpL6WiS8h60EHFQgfKzxq3TLr8Z7ehPkiztITYnBmDFl5SLoHxfanNA1/DGoISTQv5cYjBot3auF+s11MzZYkzi2DchO1nsEHASxu2btIIUm4YD7gKNiwY2a/2aBerISM8s2GvfFzd0mQDhwd6w9YNvahuW+2Rq31Rc13l3nGysb1L1otwCoNhUch8g+NIqk/vPnnJJOBW7Vhy85x61NccSQdwrQlCVwHcY3+SD+YOS3v0ZAvmBbvVfNZNjIloAX61bQjeNW+PlTzUttp9jBX9jXybbxJm14qmx0PGRtIrmwJIq/tyaSyBtipywGHM6F5GY10QDr3fp8YNLxp6SxUqjzW12RwHQ1gOKxWTxRxre6mNH3fvjcefNVmAsVDvb1Wf55OhbFMccDHYuMQba1/hpfw5g5RFR3buS1GgoHyIJWcvUnhgLwUlSfYkq9St6gmJzqew6btRu7+bWdO1ODIhuDXzOvyslQr9dWZd9A+xgeT9SUZAQdH/IRUFHgrhnKLXw0zWbkQ1nzTVKeC2T59VN3QxK5Pd+O1RedVAfnamm4/8YGxbWvFkpn++p7/hRP9oHsBJ2SRCs5CKcuQUp3fky7k6xUaenb2aWV76YkPmMmZo4hX3DpXUnk6b2gXAcIo7NdHNNNI3mLIl+PzDGpZ15FJXhRhty4Y6nuP2BeGX9KWj5bbFIT6HFhvruCewU3qDtI+Y52321g5rk3Vm 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)(376002)(396003)(136003)(366004)(39830400003)(346002)(83380400001)(107886003)(186003)(66574015)(41300700001)(2616005)(38100700002)(38350700002)(6666004)(66476007)(4326008)(86362001)(5660300002)(8936002)(44832011)(6506007)(2906002)(52116002)(26005)(6512007)(6916009)(316002)(8676002)(66556008)(66946007)(6486002)(478600001)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?L1JlTmlKVTJHRFJUOGVVazJhZ0Y0VG9JOUh3dzFYT3FQUVJmaDcrUXhOYzhI?= =?utf-8?B?UVRMREQ2QWFOSjRWTEtGOXJhWWQreXlwQ0ZQM3Ryb0IwNVorOUgzWE1FSENo?= =?utf-8?B?blFpK1pUd1BtUnRXMFcvUGp1WFJ4cTExSGMzNjkzWVRwR1k1UXpySE9qSDJW?= =?utf-8?B?VVVzQUU0R01xdlV4Ri9McngxRVhmTDFLM1NGMkNtMlEzTVcwRkd3RkVuQ24w?= =?utf-8?B?Wi9hQllNaHNFZ01FTDNOcHdWZ2FKZ2NPcVRkdnV3WEpSVnBUV3doZnZyNjdU?= =?utf-8?B?V3N1anpjdmFZdHcvSnFtRFhDWlhSQVZjdkdoejhOU1JBYzRTRkx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aXhueWdyV29XV2g3b2pQZzRKZU9XdGFXZU9yenFrV2o2c3hKZzNX?= =?utf-8?B?bzMwUjhJQ2NvOTNsT0tPTXNzZlc0NmszdS9JcWwyQUZSa2NoMnlEaFN0Nkc2?= =?utf-8?B?MXNxWlg5bmkyT2ozUDJ3OW5qQnh4aVNIR2lHWG1XbHpCNWxUWUNUVUNDTFha?= =?utf-8?B?VEM0eU12WkhrdllzMnBCVzRpaWExSU1jVm9hRU9Na3h3bzhEVUVYeDBOa0g0?= =?utf-8?Q?cFwMd35PsWbDnW3g=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: ddffc835-8398-45c5-6729-08da53719162 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2022 10:34:06.5651 (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: FIfM+IblUFuRYXnCr5SIXpRmdf4fzorK1RXqe0FapNdegLv/pWHLV50KGLTVTBqzdlYB6D/aq/mkQIYyHv43Du3rhQfAYTjSRiOjj4W9Rt8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR13MB3086 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