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 18F11A0548; Thu, 8 Sep 2022 10:46:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5A73E42B79; Thu, 8 Sep 2022 10:45:41 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2138.outbound.protection.outlook.com [40.107.223.138]) by mails.dpdk.org (Postfix) with ESMTP id EE8A142B75 for ; Thu, 8 Sep 2022 10:45:39 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Id+5uBmR2cZ1R1DxDLjD58OOcBZZ5Hxjz9YTzw7cM/sSRTH0GIKkbaa2Eef0x86lJccRxg+33nLTt4xBEpqLGifUBw3zg6JEwUsvxToP567OexFmcMWGB92BcDSq6xUIcgV5rtly0Oj+B+LYnr8TrvysWmGooHeaaVx8cdMIT4L3ENoXhX7lYiSM8zSKxOXvGdgcye3CW6P7AxfdMAlN1xE6lK5cXuC/QKQpJ5iNVzlSOLLSNxPOemMbmkmO12wfbId74Kw6kywmCqbcCtt8jqB7xo2wJuDl60czO3mNr9CNiZh/qrxWuKtGT+/uo/ih57c79Al3E9DBR/MqhfXGFg== 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=ia8i+f2eKqE3RGc44L6jT68QzZQ1Yr1/rh885dhrU1A=; b=e4UaSfBH6Y5MWF1UM9xOnvWa0tl5fVWv+k1zTlGYe4FdVBqoDAR25YnUJay/W25OTNCyxVgl62dWmDbb3jQ9np78I6P+Ztc76aki4kRRh7Pn4c/cHuo1eKKu82N1Ga/osvdgeHfujO5L1yvHORjvkOEWmznPS+e12/ib6LYIJllwltYCfVV6W4yL4mF4vmYJYKAY8qBBTFyXWj8Tw4gZQGdZLwYkbEiTEH49DPnqLLxRdlpWs8VAqZyW0kO/doOJHqvrsXSn/sm+vbssGXa59czyTs5rA6q0WYneRZOwwu4F3VpENwgc6axY00b6X5fJ7K0LA+kBOSeSdTf8bKIbFQ== 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=ia8i+f2eKqE3RGc44L6jT68QzZQ1Yr1/rh885dhrU1A=; b=wD7UEvOKnQDd9iNO51mLC2CJQCKvaywHt30hQ+21TLsWV+rzFxQvkZIHVjXyBfG1xK4zN/IWzFoHMuiLwUsVuaNj6VOXGNddL6M8hXCZOnENwD8vnCV9vs/RvLGKsrrVo1dKV810RJ3N1idwnxtSFU/PxBMxp2Re3QP8ZEt3ZEw= 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 MW4PR13MB5940.namprd13.prod.outlook.com (2603:10b6:303:1b8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.3; Thu, 8 Sep 2022 08:45:38 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::402d:6abc:83a8:2431]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::402d:6abc:83a8:2431%6]) with mapi id 15.20.5612.009; Thu, 8 Sep 2022 08:45:38 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v8 06/12] net/nfp: add flower PF related routines Date: Thu, 8 Sep 2022 16:44:56 +0800 Message-Id: <1662626702-17254-7-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1662626702-17254-1-git-send-email-chaoyong.he@corigine.com> References: <1662626702-17254-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2PR01CA0023.apcprd01.prod.exchangelabs.com (2603:1096:4:192::17) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|MW4PR13MB5940:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ff966bc-e2db-4914-e1de-08da917680d1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fHL3evxpK+C/DoLPcLt1VDjhjRozW+9ukRZ4mMmLhdHcjfa2Z/CdIrcN75snooMh/eoHJYIPmzRmtyFBWO5aMeW76cH2n1ltJO6IP3HXci3aAP7sDWb72TejFy1orhInczCHehmkIUzJrOhKHiW67SBrCaz/8JLhsEDNXmUWifgMPKB8iB0OjNzaOJJ0exs+VyZW9n2VoJenD+UCJFlTXrFfR/ZG9SIH6pd8VlJwEKjfZ4dK/R5rvf5tkzwT6UnfoHzCxA2o4JPq4B6FI9PYZLU0RBo8wUrSBYAiXLVDSYUxEAuqOsecMD58mns47eVZEMtP4WC+VehSL/hBNl/AZPhZSKRM1oOLWy6Oz3wtUS4f23SAoZy8N2A9HkfmPysjXDiEUxMAOYXmRwPuVhraedawDESLu+dkgiq24XzbhIMmYsOIsvbcLd+edsOeQHKubAHu93KQSX3ZZ6kfCCoqJSjRJdbgZ68tYXpwaPhi5l+D3wbmIBibAD4YawnW0tsf3N2qzwUDQv8PQ/k1iP3cUksxcE/BiNCzy/zUe9F/rLuqVrNpKxMdtBDIAQSiESQyybaZcrlHU7P+CBg1uX1AsRrCNfawoJrN8/uWcWMDrijs35lMn7mUku6YR49bpyQoNRvgwAmRln4uTvv3keh42yEbJtgvGzjNP0rO1JlpxaJenuJe4MInxRNXjnPKbhbHVquQoz7m/E77nFcTwOyEqgBdE8r5EW39P28Zew4tkWEnb0R3he7rdqdWKMhD0HzG7w92QbLkP+rpw1/Z30ZMZw== 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)(396003)(366004)(39840400004)(346002)(376002)(136003)(107886003)(44832011)(2616005)(41300700001)(6916009)(38350700002)(83380400001)(66574015)(26005)(6512007)(186003)(36756003)(38100700002)(4326008)(2906002)(6506007)(316002)(66946007)(478600001)(86362001)(5660300002)(66476007)(52116002)(6486002)(6666004)(8936002)(8676002)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?SzZoU2lwRXkrclFUZEVGNSt4MXlRUTlWSGRMTUFHNjdqOW84bmxaNWNVc0M2?= =?utf-8?B?dmpHZXhReDNSbGhsZldtQW5RWGJ5aEJMQ3p1V2REbWlGa2lUM1VnM3JxQ2lM?= =?utf-8?B?VFovMUxRZ0JSOEphQXBwWEQxd1VHZlNwNzBkUVYzeEdlVHdjMWpaV21nTi9E?= =?utf-8?B?TmhlamgvU1RIcnk3ZXJzVWgvNG55ZHRkODFEbVk5NGlrWXFPYVpjUnRiaTFT?= =?utf-8?B?dWVLZDJ1RlI3TkVYcTB5eHhWS0FKWmNTRU9UOXIrSGQ3elFIVkFxaWF0YnFG?= =?utf-8?B?Q3ppTkZ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zJzZzAvcjJDR25rL08yeW1z?= =?utf-8?B?a1NFNEplbGxqYUVJdkcvZDByZUNuZE5ENFo5NXhUdndGajFVOFlCUzd0SEls?= =?utf-8?B?V0E9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR13MB5940 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 | 185 ++++++++++++++++++++++++++++++++++++ 1 file changed, 185 insertions(+) diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index ad0dff1..e0c0ab3 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -40,8 +41,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, }; static void @@ -310,6 +471,24 @@ } 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; +} + +static int nfp_flower_pf_vnic_service(void *arg) { int ret; @@ -321,6 +500,12 @@ goto pf_vnic_cleanup; } + ret = nfp_flower_start_pf_vnic(app_fw_flower->pf_hw); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Could not start flower PF vNIC"); + goto pf_vnic_cleanup; + } + return 0; pf_vnic_cleanup: -- 1.8.3.1