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 BEC6BA00C4; Fri, 5 Aug 2022 08:33:54 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 92C5D42C65; Fri, 5 Aug 2022 08:33:16 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2092.outbound.protection.outlook.com [40.107.220.92]) by mails.dpdk.org (Postfix) with ESMTP id 0B0FA42C48 for ; Fri, 5 Aug 2022 08:33:13 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LIhXCPRLoiALFWPIZVRSaBmV8j5ng1zg5L/Pd+HQzD8YW/mC2BXUHCY/cphTkX/p0aNUE8Azjn/XHDjDQ4SM51yZBSaXRayuFe/qAqksRD6knwyLkJi7laS6kCtzeNcPqqzRglpfsQghCbmSl0HjJy7ibHei2UJKs0+zag2RluTH5iGnoU6s7/2TzcFcAOPQLPlHURTPL8ceHTlSBy3NC0OY8NVGLEyCb6BBGePu3/yeMWnBQ71xRB0uPOk3SjPwbKfgDMQhEZmqf9TSu5dk+m2hpqKPhIAY5DpSKJUAeXcQafaourftKN43Z014wtTV5YIDGcGQofP+Q8sWrlgN6A== 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=DaIq60GDQZPlu3OzSK098pQQ/Nyj6FkNutLOwv9Wg9o=; b=Ywbouja1pI8Au8XJnQbF9s1zUgPp0VOlyhCOAu3t6nP9WnLUb2/8dAVSZxAWfOnvCGSKxaAyNj/kOa8GCCV72GhrknuOnnwlwpw4Ootra0LxzkVcEnI1ckCqvQ6GlzC6oqHadQn3oO4p7GayrSSb/N71oUZyPMVKB4CTnzCLjNd3bBnluncAI2/CFtQnClMR00BoNzFE0qPyoCII64dlMlI04MfJS9YRxwf7aCeJ5j8sLSRP6pvgm1m3DujnFPpWrJWzI430kKhKpOLqawvziXmbYYNTniG5fIBm7wTSMP5c6xRyr/1ilAHE/NRmR/svnYHB2CUwdcuXlKn1cTR1YA== 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=DaIq60GDQZPlu3OzSK098pQQ/Nyj6FkNutLOwv9Wg9o=; b=bFtIj8jiVrLczXa3yci/vffeWMYpXDIw5veuM46XECuAAonQ5F8poIx8jM+J6q3hedyA7FzEBunQEZG9DsTcAAyKLNQxmFKCFgMSIe0UTDwo1xRn7RDBIsRP8iaQbk52ywC/MG/rJhxu3egUpXlRmkt9+lllvz92DFGVc7SrNhE= 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 MW5PR13MB5854.namprd13.prod.outlook.com (2603:10b6:303:1c0::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Fri, 5 Aug 2022 06:33:12 +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.5504.014; Fri, 5 Aug 2022 06:33:12 +0000 From: Chaoyong He To: dev@dpdk.org Cc: niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v5 06/12] net/nfp: add flower PF related routines Date: Fri, 5 Aug 2022 14:32:29 +0800 Message-Id: <1659681155-16525-7-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1659681155-16525-1-git-send-email-chaoyong.he@corigine.com> References: <1659681155-16525-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SG2PR04CA0157.apcprd04.prod.outlook.com (2603:1096:4::19) 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: 820e850a-65fd-439e-ea7b-08da76ac5e78 X-MS-TrafficTypeDiagnostic: MW5PR13MB5854:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UMWoF5BCL23Bfg+5TnDpwC+ZBRcRLYKnD1RkAxpANS9HxOS1hQXCj9GvqxKGkZIIWHbiYi+l5VCyd+ZHYPA4SZeNq3U/Q87HOI19xi7sK5DjxbxnC46mx5+Wkk56fW5NY79mZeKORFDnxbfCUtNa5wzYQR/3VibX/IVSoCjgAGI/2G8Dhow+yRyPa5urJfgBFMg/Org9p//Y3eN7ioGXN+LET4cuMrvSteXm8M7CjNq/z3Kq7k7Xgo2gW15IIoWlaaSvVZD7pmC1kcArKhkFIO9ypjTGHQbPoB6QbjquiCxUpxuVSZoj3Mh2RV8HcZCKuuQGHxsahvCnO6QuctoesCh6gEW7mpts6Dnxi0gRkxSB9RVMjJ+riSn4kXkANN/vf33LEPwOxte4mQ7cVjBH6mNPgoZvj5Fu3bFbQcJoXeREaDgx63YIbTdpFiU9MTHJ6ihk+mQvsg2n/NtnxnrMG9anPiyQqkcikUaJe4ZjQROps1FR14frwmP+RIHzwl3zv8g30C47v3QpdWBuXYwtTCVgW+n2APiuptkJ00X40ESwQ674f1cHO0irsbnX/uSoR01631rGHPoHENzhEEb8t3UffRqh/XoFfSslo9C+4GI/myfguzD/DFe48l4YFHtj/qquxF41qvWp4GTsblNAjSWROYEvaaeeW4Kbfi4mlXuFN5ZgqFogRZy6yYeiuqQumYbYqlL/ZuF6lvq4n0gb/rPfZ4skekpHKjJkQ4VnLSimsBaQVmpV7yQJeJrGluWvltVLBcbL/bQ8WXlbf+Xjb4OBtv3dPElNlvI8FLf+kzQ= 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)(136003)(346002)(39840400004)(396003)(376002)(4326008)(6512007)(6506007)(52116002)(6486002)(66574015)(36756003)(26005)(41300700001)(6666004)(6916009)(186003)(316002)(66556008)(86362001)(66476007)(44832011)(8936002)(8676002)(2906002)(5660300002)(478600001)(2616005)(83380400001)(107886003)(66946007)(38100700002)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?UjFnYTZVTXRSUHlIckZNOS9mZlhCa1dEVjFRNVFweVM1YnJjYm5SdkJjU2Fi?= =?utf-8?B?SHFUMEVVRWtmblY4djBaN09RYklYZXBRcitLZDVjQ003T1RNbVMwZkNScGo0?= =?utf-8?B?eTY1Yi9Zd1ZES0FZN2VtT0haaFkyb05JWWFOdTJ5dmdwdWlBZnhaWHNHZENW?= =?utf-8?B?WFRDSVhZR0RoUXBZZGNTY1JudnNuMGZaRHZheFVyWHIweFFsekoyblE5MGY0?= =?utf-8?B?RVAyQXY2YjNPNGc4bVlZaXo3RnFwOVZva3B2ZVBESGQrd0lvdCtWYW1GbGF3?= =?utf-8?B?TVFlOEliV1lpaDNGL2ZwQUZ3cUswQXl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B?ajQrYXVZZ2pEcHlOTWt3amthQkYrVjBiN1E2bnhuTDBFTUlqWHlJRTRxUTM4?= =?utf-8?B?Nmc9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 820e850a-65fd-439e-ea7b-08da76ac5e78 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2022 06:33:12.0437 (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: BNXxLTIGu0bxyISceXNEd1vL7PkRHWK7UqBCDB8ifg+1QOVmcRg5OBqHxMUJnj7iVsqN1wTa8ik0pPlR9VweXTKN1SsK7gfwRoHCO/LkVQ0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR13MB5854 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 c05d4ca..2498020 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] = { @@ -375,6 +543,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) { @@ -432,6 +618,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