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 104FFA0543; Tue, 21 Jun 2022 10:10:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C44FF42B8C; Tue, 21 Jun 2022 10:09:24 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2132.outbound.protection.outlook.com [40.107.243.132]) by mails.dpdk.org (Postfix) with ESMTP id 4B6BA42B86 for ; Tue, 21 Jun 2022 10:09:22 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nt8zjO7sd4bT1as6oOWxgJjuNZlnzvqvux5TNZdTu5UtN9vX/dVWoKuG1t0TuG4Sh1Ef+7dafYdMcCRGQeN5WN9LOuMcTDYzF0UVmfwWlgb+W5/wPEY8hgOr5qjawhKKpiNcCGwmyZXz4rFvBlQvmGhfoQ6XUHA4Qdqsi1pvZbN2FSW6K1Zgd4dFSwmICRTVwuNu1SCIVFKbnCS59Z2oyQEIah/P2IrOd0v25uwuNRVzIQKuWdiQNQ2XBal2LWz4W8rvcCyOYN36tNCc3T4ahLtCO2zSnCpYCC63SEIkaNiKgmaEzG5J7BYTtCeyDA88OZfe6uFuhY/W5jVkDfNxog== 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=gdVN+jUy1j3RKaADRfgGW1FaSdg+hjepc3VzTeRdwepphRXBkkc8Jqx9F7bPWpUApVRvAFTAn+xzTwQFzyifRUURkmIVpJv2tbNIL3PldtyiQEcViDBXsaAkmQayPiP9m8IFMO+EQn5VHywRVmok+k0QVJQMlfdiL1aOiOpSBa5gIOhw7/RHk8llLyIGODbYAD6hxvyFlvfQkiSxb0VN/Y9lIPnf0THkxItMiNMzd156Zovpi+PtmOX1V9zGZUwbtEwAs+/3Ev82S6oaggxdYPRYJmOVQGXnxGZF2lvzaXdCZM0g8absF0O2ysvUFLbt4OBkg/PlHGVy0musuu/6Fw== 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=iLWn4OloJ2aKFBmderxF2HDv4OGKkrHiNk/XcKsUuhbIy8+89D/IftfiOMh2vlcweTyGtNCUez4hRqI2IdfHUHvqnBufsMJNRrTsuwuSq8Wu567PNsLkBukfmdZd5O9x+P02iB4lx6EZ1FdIzmRL6PdIWZAXqBjn76YigOl98fI= 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 DM5PR13MB1756.namprd13.prod.outlook.com (2603:10b6:3:12f::22) 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 08:09:21 +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 08:09:21 +0000 From: Chaoyong He To: dev@dpdk.org Cc: niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH 06/12] net/nfp: add flower PF related routines Date: Tue, 21 Jun 2022 16:08:33 +0800 Message-Id: <1655798919-38659-7-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1655798919-38659-1-git-send-email-chaoyong.he@corigine.com> References: <1655798919-38659-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: OS0P286CA0009.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:9c::14) 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: 2d6cce4d-ef92-4d9f-7a00-08da535d587c X-MS-TrafficTypeDiagnostic: DM5PR13MB1756: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: HIUB0o1wzcfbAF8CfEIOuirKX4RpfkL+7mY5QnA9S3yZep2RmZzqdSZS6qyRP/kWj36GIPBQ7iRjFf2a78zVqRb/5HMXuzfvOFEqnIfizB94kmG42AEms7zi3Al1H323ZdTtIc3fNN5w/po1EgHzXVU5XQnz9m+0jCSfCPpgdC/UGvHKYaCwcH9Kd8xXQIEADD3KwGES5QFo112BuA3UHNJM4bEdMVfscEUqFnHjhD7xmpUtv6EEJwJgYX/udCjcK/yCFsBKggmZL8H1plu35zCWuT3Byie0YFAUpJuQlnAoekaMWcryg4LjBYplpciKH3+qyeGOIi7ZH1fd6eJz9PmUApUSwA+mEbtklobYaY+5S5v/0fvQqvSXeIBCMrDxZ5YTgi4U3/uxZAnhEcgf6esGLcuq/DS6gkH0+YNCip3akpIC2wIB35hjSIXg92a2J9INyTjGF23WB6ZyvXzmqML+YG5eMhDcu/DlRC7r/nDel5dna5dODFbJlf9yBBAZSLaWCvcvZ6LPk2C7qIT6G3PtM6SwdtCLnuStCNEGhXPmL68rwRhCWpG3aG9YftyB5EePZWRNqTK1FPlgrhv/ndVxr7MjcOpc1LlIb4g7ZRQNomuxfR3/KTKCell0KwP6EykzSovXQwN7aoJNifi3tMQ9QX1K37UVFUqeM0nc3Kq8LHsQb8njwRd1vrH2Q+NgjMAHKxAgzYCS9n5SN8llmg== 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)(136003)(366004)(396003)(39840400004)(346002)(26005)(2906002)(6666004)(6512007)(8936002)(36756003)(107886003)(83380400001)(44832011)(5660300002)(66574015)(186003)(86362001)(4326008)(2616005)(6916009)(316002)(6486002)(8676002)(41300700001)(66476007)(66556008)(66946007)(478600001)(52116002)(38100700002)(6506007)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?eGV4em5SWFYxZEh2b3hGSWpoQWlZSUIvRnFLRzV4Uk9kZUZDdnZMb2tPNUlv?= =?utf-8?B?UjlRUFBwbVNLTGR2aTNQb2NHRjFzN0xCaTN6NGdmOGx4SUpIcUdadmJWdmVw?= =?utf-8?B?Y3VwcVI1Rm12MGM3MVBQSXVmTER1enlwRnpnZXBuN0ZQaXYvU3hwcFdQK1hE?= =?utf-8?B?SmVGdThpNEhnN3FEQk5tWktLV0NOTm5lT0dlRDFBRU11dk0rS0I3VlV1Q0hs?= =?utf-8?B?NUxndU9nRE1PeDBTc0g5KzM1cUFjS25DMlgyUVhpbElpYUY5UzA4aEFhVWxD?= =?utf-8?B?VzA0V0JOd3pubjV3cnFoQlFIdFluK1pZd0JpTTA4UnlCOHFTYzdtUG1nVkJD?= =?utf-8?B?NFRsc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1rNCs1N09LSVM5TmR2ZkNtRnN3eXAzNXAy?= =?utf-8?B?WHU0Y2QwZHZJTWhJNWVFUCtFVHRUSXhlMXkzNVZibHV2azh3c3NsNFZQNklU?= =?utf-8?B?V3AwME03RzRFaHV5VStDOXZ6ZWdQc2Uzc0dyQTRSbENBeGxMWFkvMk95eWs3?= =?utf-8?B?Y1lZQ3VRcWRBQ01TNmpIeDgwNzZ5azM3ZWhQVm54bnRIT1gyNVYxNGZ0SDdU?= =?utf-8?Q?SqrbwasGUF7/aXZg=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d6cce4d-ef92-4d9f-7a00-08da535d587c X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2022 08:09:21.0150 (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: nGf/YTMnpRkBbTDB4dIZ8JAqRhI7vlZj4kFPgvQCmfi+OIeEIgAG1cF3rh7FM2bdSBCzHQlSUcOLg1Vvm8bZfw8UJy39wRB1onr7CX79HCA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR13MB1756 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