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 47A3DA00C5; Thu, 15 Sep 2022 12:45:34 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E1DB842B76; Thu, 15 Sep 2022 12:45:04 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2094.outbound.protection.outlook.com [40.107.101.94]) by mails.dpdk.org (Postfix) with ESMTP id D141B42B6E for ; Thu, 15 Sep 2022 12:45:02 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JK/PYuoLxYljQVuvNs7+SzleAgiHUydbMbLWhRheZWJchvv0g6H26jfKxKY7+ppeoie+dwdTnxSDf9wv9gUo2wyjAZ4RUzi6ry+rYCyvoG73+2iSc3XVf2oOgyswa9Kj81tbXdr0yho/IJ1KKwVqlAD+JhGpAIYbMaZr55FPQzu2Nvrm3BY7rfICzzTylqTdUIAAMP7DQ3ZuqGZKwsReNnrXtoidnnyfgVwK59VKB6GGQJY5oJsgO4ITm20nfrL+zONCsfWTMGd7KRRT77zp1HDw4z6TIEVQQmT4lizpGbyApAHlT1trXfHpwD7hSsgLAsqJPxPxEFDI3EtnIjuDyQ== 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=sn+xswZXhv6zXIfkykQKYxpQ+1dz0CWx2C3E8cBP2k8=; b=Z2H4vtgzPJacS2I/nyeIa3qmLaE1SUZuWukifhttqZSLkQyH2SgBpPA5DI8x+PFnYq2THOdkOqaaxDIAm0k8ZyMsCQMN1BnzPhWTXzQR2mj8WExpKKSbrD/rzQ8tDkhxfZdezOf5JS8DTZmCiUMKN/Fa01CU8JcIO31XwVft80JKh/kLXn7wUK9J7pMyY4AMEzr28HJfl8Va0GdM3QZ2KWwcyavFEE5Gcwt9e17/dJ3cQ4ugET+osmo7KLbbBeoCIfC3w4v0nJyhnCrckQXHhPZM368zvme1tAc7MQ3uVW3LzGQspPL+Q3flwDjgxPtt1fLN+E4gp3+Nx9WJ28odrw== 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=sn+xswZXhv6zXIfkykQKYxpQ+1dz0CWx2C3E8cBP2k8=; b=sJvmOQxZJrxHdj8KX7J9Ely/e0H6Q0fen/ofiwzJ9uYdmqXafeo3J14t0CGUrLYYnOOtxpXjlyGA46bpMyFjMA7/yymmhbHE0xNeg6Si3L/bXNm9fPzBck8IgFKqDYASmYY82vyc7wH0szoTjnNHlF7N6RuTy6nBdW/ZNNi1ckg= 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 SA0PR13MB4158.namprd13.prod.outlook.com (2603:10b6:806:9b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.5; Thu, 15 Sep 2022 10:45:01 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::819:38c:6513:bf15]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::819:38c:6513:bf15%4]) with mapi id 15.20.5632.012; Thu, 15 Sep 2022 10:45:01 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v9 06/12] net/nfp: add flower PF related routines Date: Thu, 15 Sep 2022 18:44:23 +0800 Message-Id: <1663238669-12244-7-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1663238669-12244-1-git-send-email-chaoyong.he@corigine.com> References: <1663238669-12244-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: BYAPR11CA0071.namprd11.prod.outlook.com (2603:10b6:a03:80::48) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|SA0PR13MB4158:EE_ X-MS-Office365-Filtering-Correlation-Id: 4bbed4b2-73a1-4763-c1be-08da9707571c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VKlN6Ygr+ldbpgzJvffYyua9Ptoek68dA8VdPk3XL8oWJTpouhFEGKIcNnJMO335ya/grJwQ+m2L3hydn9DQMAiZVERDgGlszsQrw0AZ8xF0UiwTSDSU7UwSkOJoskE8jryGSfKL9rwivN99uetxmQXY8WrVzlMuvdBlZc6v9az4z7S70xk02A6eZwne11MZZ45lytMwvds1Vda4eQ84ZBkmGHuroIjHMj5kbVy+hSBEzAf/Pwr37R0Mwg9qhxMoBE0WOSK/5ST+/D2S7eYPNgYwN5fGOMOPxCrCAHR+ikMiC7DOddZp/+itibrg8jpjSZOalgx73/9QGlxaZGLX0ERlcTtIS4JccLF/ovsn+2gKa1Q7K9SuiNHykdah6GEkAsQV0W0dhmjvCT93uQDDHIT3OKx9mCMGCCwvzj5jF4mvFZoEZWhiPsf48UxGlnFkRVQ0C/SPI59OApUm35jeL0vBj2o5qRn6/JLq5f7RL9xq7NFypaa5elqFeYjPNh7Hh/mp1qgRu4RyhXTsfzC6cFfnsKODOL0WYTSkGlqw46hRPvvaWJhf1m8kgkEu01j+PwRswymE0qmj4XcX7VjkTsT9V9BUVRuHd7+a5OzR+xgnuFeE0p8MLyn5oyPyzzqnXRoxfwcdBKPxlUyvxvQTFwiyQ5y4UOfpCgE9nbvkqiEZIBkRSwwgd85R+3ohZOre//X0kTgtT3woOppEThMFwJv53I8hoDc/srGI8Bmq+PPWxn/1eoHUdVptLrRfAWWa/eQeMswaGlLMbktcR+9qeA== 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:(13230022)(4636009)(396003)(346002)(366004)(376002)(39840400004)(136003)(451199015)(2616005)(66574015)(38350700002)(38100700002)(186003)(86362001)(83380400001)(107886003)(8676002)(66946007)(66476007)(4326008)(66556008)(44832011)(8936002)(41300700001)(2906002)(5660300002)(6506007)(478600001)(6666004)(316002)(6512007)(26005)(6486002)(52116002)(6916009)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?eTl2Zk5ybFpsYkJkQ1Z4T3BVL3k3Nmt3MVRuS0p0VEVSbjhMakR6czhIdUMw?= =?utf-8?B?a1BqS2gySDZFYmVpQmJWZDJaWFJUT1ZwSUhrZnFXYTRDY1JNT2pOTnE1N3Ja?= =?utf-8?B?R3NXSjNiRlAxaEZqT3YveWFTNm91VjBGekduT0ttTG1YVjRYQi9jS0R0d0Z2?= =?utf-8?B?MkVKQ0UrN0ZKeklQM1lDSE0vNHJtUHBmOHhlWXZoRlVNR2ZLczhNZkdyQlFZ?= =?utf-8?B?enluNVhzelcremt5bTViNmxEUXpxcVR4RStzdENFNGNGTHBWSTZTenFCQlhS?= =?utf-8?B?THQ2YTM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kcDZZWWw2MndJeHpuZzYz?= =?utf-8?B?TFZGejRpY1R6VHV1STVLVDhoZFl5bUN2dXlZd1ZXQTBDbVluVC92Wlg4L3M3?= =?utf-8?B?MWc9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR13MB4158 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 | 193 +++++++++++++++++++++++++++++++++++- 1 file changed, 192 insertions(+), 1 deletion(-) diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index 34e60f8..24aa288 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_fw_flower *app_fw_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_fw_flower = NFP_PRIV_TO_APP_FW_FLOWER(pf_dev->app_fw_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_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_fw_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, }; struct dp_packet { @@ -293,7 +454,7 @@ struct dp_packet { return ret; } -__rte_unused static void +static void nfp_flower_cleanup_pf_vnic(struct nfp_net_hw *hw) { uint16_t i; @@ -314,6 +475,27 @@ struct dp_packet { rte_eth_dev_release_port(hw->eth_dev); } +static int +nfp_flower_start_pf_vnic(struct nfp_net_hw *hw) +{ + int ret; + struct rte_eth_dev *dev; + + dev = hw->eth_dev; + + /* Start the device */ + ret = nfp_flower_pf_start(dev); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Could not start pf vnic"); + return -EINVAL; + } + + dev->data->dev_started = 1; + nfp_net_link_update(dev, 0); + + return 0; +} + int nfp_init_app_fw_flower(struct nfp_pf_dev *pf_dev) { @@ -372,8 +554,17 @@ struct dp_packet { goto pf_cpp_area_cleanup; } + /* Start the PF vNIC */ + ret = nfp_flower_start_pf_vnic(app_fw_flower->pf_hw); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Could not start flower PF vNIC"); + goto pf_vnic_cleanup; + } + return 0; +pf_vnic_cleanup: + nfp_flower_cleanup_pf_vnic(app_fw_flower->pf_hw); pf_cpp_area_cleanup: nfp_cpp_area_free(pf_dev->ctrl_area); eth_tbl_cleanup: -- 1.8.3.1