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 7DF49A00C5; Thu, 15 Sep 2022 12:45:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3E1EA42B82; Thu, 15 Sep 2022 12:45:06 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2122.outbound.protection.outlook.com [40.107.101.122]) by mails.dpdk.org (Postfix) with ESMTP id 071E642B76 for ; Thu, 15 Sep 2022 12:45:04 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jH+tfYtaHo3SAE7Gn66zXAhjZ/5/TQ+g/GPrxatBzw69EGB/lZYRPaOkl91dQ1/bB6Rsw1pZB24vnuvpLohsJ/PFouu+nAhAW1pK5ylZeWl7aYiBXO0NEVbkDAsxI/JCufThqXu+h6WV/hWJZKsSt092PZjvnAsFuiTg61xNtcv9NCOvTGRtTJoHx1q8gYi8c6tlzkZtLQKMCyuLPKzrd8UCMg3AOzEBVf9+vUcao5a73WryDoxDcAYt8Wh4HSDS2jGygJmCaOPwvro1Btw0J3hIN1ltJerXhE7bKx+43T443dSXJYmoJAeqcsLCwdjBsrxXBeysIP6NFJSejtKFKQ== 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=UHapacVK1I/t8Krwjz7LtdflzqdCvEYRxndht/SueBM=; b=cVHxXlkcbRh/+hKZyTlp7svd8ncLvcfTMUkf99KpsWzLWYLydjuj5Rp6WHuhXJ6Gv6ouqILHlPc+LK1bFNsI4OyjvbSiYjP/yk5O7HHEUaKuLow+N2CfrlZjUXIIvYN7Qqy3juaDUCEo+eWj/2IEL0GJENxeIrYdLONdiCDMnougsUG13tEPioVZJe/DAx+uy13uIPO/iBObmHrzHqF1M4jARcp7v3Bear+OSrDS+/3ri2O+lB0c4vmsh9hhMC+Ohr37RQWmWrGQSnxJ2ZulDZVjdbz9zHOvpiNDMasS2iklyXwf6FnZTcpzHZpZEeanyzlxXnnM+oRVKstfZFZitw== 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=UHapacVK1I/t8Krwjz7LtdflzqdCvEYRxndht/SueBM=; b=jv9gjS5EpKb6F2E8lC4bQ5lnCdaDAnvGLZcxShsKj/0VOtFc4cObX+62zD7rAYNjQtdGJaPCHG5BQzfwbVJIHv6oKSpPu8RFfwKqOLB4i+9BkaD05Cfv5e4pXexZTH865enMds4A+x2ULJEqS2fzkjYwSGmDlDohukCHLhrKs88= 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:02 +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:02 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v9 07/12] net/nfp: add flower ctrl VNIC related logics Date: Thu, 15 Sep 2022 18:44:24 +0800 Message-Id: <1663238669-12244-8-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: 3413fe75-aa05-49a9-e372-08da970757fc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: a5WdOx2gXB3QB/RSVS/ojFxSJ2l3LyZ5TI32BdCjFeD6Oy0JY7R0U3CAgHQjPjBH0A6NzZ8jQdBZv8eE8fIYt7lX4tLsSyHDEnka3O1ftxdcRehPho6VpBC0dTOupKSEKeiJ5TuhtBcdXXY9Vb9Qyl4rJaaN5ya9235WZ5bR9aJDZDO2LWoK6da8pq4i144OGxGBwKcBgsQtlvx/dpMhQL9ht8mK45S/jAEyu+a84bzHcKl2YnD+EIntVkABU0vuCfOsEx45gx772xYs+6U61Yz3jt/gyKuVwvlQv29IsWIpN+NOnzX36I8MBujp14Y49qMsEfen+M6K67d8gWyPU9cqmemcqJLcYrYNbLCb2qE0KRY/RQEVpzfnCZLwF25i43lvvB2aJni+KXyZC4RKqNGrUmPCl/AzAegncbtrbqWr9aMGiJsCRbUgDMAZwHvA4lfczt4u3KPpJZ4hyvJwGtzDsZlRtFbd8Y4wfVUnRoturG2ak0sdjaHCUI4pMlvZDrcFlD8QBrG+fgr6n5uYuspoQ9erpw3WP678EgJTVT57AdL28xXdy6OvGlfnVJgtZnQNOXq0Xu+qtrktJwPTXhOB0Itt6JzdSlkFn5G+oLQqABB8zFmNShYMHRCdQQdisFwEvHb9hUKoE81p8o4Oop9SsllgKdBLAPrVRXGygx1SVKaZ5aj7ESulxEV/I7OJK/IFa0mEwtHrEUyww/F/r59nX9RoNqIv+sC3UZwAhRRrwKcBZr1Dc0hB4C3oyjEyd2x93dgazmdFstH6C0g4PQ== 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)(30864003)(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?cWlQbUxZbkpzaW53am8zZ2lYYjRqYXhLU1hiUUxrNE9kdzBQbkdFaWdlY3VM?= =?utf-8?B?MFF4QzVmS2lwN3hGOFlrVGFxUEs3R1E4b05uc2pIL0VqWUE5ZEZNT0Q5NnpT?= =?utf-8?B?clRkOXZoQzlxdkx3TitwZHVzeHhDT3NnRkpscytwcGpUVTVCMUw3STZVWEc2?= =?utf-8?B?aGI5THlOME9Lam9KVHVvSGcwd25WSnRmSUd0bEx3aktlY1dybFN3TlAxNnd6?= =?utf-8?B?dVJzdmZEWU03clQ0clFNTkNwc0VGQjJLWnhPaHlyRVRpN3BhdEJMaEZyQ3FE?= =?utf-8?B?VDNyaldrMV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zYyUjFmUFcxdnAzdmQ5SjM3NkZ0Miti?= =?utf-8?B?VkxhRkVxZ0tJZXVLTVhnc1prMTBHbDUrY3BiTUNPRkQ4QWtvNVYrbjVlcFpk?= =?utf-8?B?eVE9PQ==?= 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 setup/start logic for the ctrl vNIC. This vNIC is used by the PMD and flower firmware application as a communication channel between driver and firmware. In the case of OVS it is also used to communicate flow statistics from hardware to the driver. A rte_eth device is not exposed to DPDK for this vNIC as it is strictly used internally by flower logic. Because of the add of ctrl vNIC, a new PCItoCPPBar is needed. Modify the related logics. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- drivers/net/nfp/flower/nfp_flower.c | 220 +++++++++++++++++++++++++++++ drivers/net/nfp/flower/nfp_flower.h | 6 + drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c | 31 ++-- 3 files changed, 245 insertions(+), 12 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index 24aa288..18ffa5c 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -27,6 +27,7 @@ #define DEFAULT_FLBUF_SIZE 9216 #define PF_VNIC_NB_DESC 1024 +#define CTRL_VNIC_NB_DESC 512 static const struct rte_eth_rxconf rx_conf = { .rx_free_thresh = DEFAULT_RX_FREE_THRESH, @@ -206,6 +207,11 @@ .dev_close = nfp_flower_pf_close, }; +static const struct eth_dev_ops nfp_flower_ctrl_vnic_ops = { + .dev_infos_get = nfp_net_infos_get, + .dev_configure = nfp_net_configure, +}; + struct dp_packet { struct rte_mbuf mbuf; uint32_t source; @@ -496,12 +502,192 @@ struct dp_packet { return 0; } +static int +nfp_flower_init_ctrl_vnic(struct nfp_net_hw *hw) +{ + uint32_t i; + int ret = 0; + uint16_t n_txq; + uint16_t n_rxq; + unsigned int numa_node; + struct rte_mempool *mp; + struct nfp_pf_dev *pf_dev; + struct rte_eth_dev *eth_dev; + struct nfp_app_fw_flower *app_fw_flower; + + /* Set up some pointers here for ease of use */ + pf_dev = hw->pf_dev; + app_fw_flower = NFP_PRIV_TO_APP_FW_FLOWER(pf_dev->app_fw_priv); + + ret = nfp_flower_init_vnic_common(hw, "ctrl_vnic"); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Could not init pf vnic"); + return -EINVAL; + } + + /* Allocate memory for the eth_dev of the vNIC */ + hw->eth_dev = rte_eth_dev_allocate("nfp_ctrl_vnic"); + if (hw->eth_dev == NULL) { + PMD_INIT_LOG(ERR, "Could not allocate ctrl vnic"); + return -ENOMEM; + } + + /* Grab the pointer to the newly created rte_eth_dev here */ + eth_dev = hw->eth_dev; + + numa_node = rte_socket_id(); + + /* Create a mbuf pool for the ctrl vNIC */ + app_fw_flower->ctrl_pktmbuf_pool = rte_pktmbuf_pool_create("ctrl_mbuf_pool", + 4 * CTRL_VNIC_NB_DESC, 64, 0, 9216, numa_node); + if (app_fw_flower->ctrl_pktmbuf_pool == NULL) { + PMD_INIT_LOG(ERR, "create mbuf pool for ctrl vnic failed"); + ret = -ENOMEM; + goto port_release; + } + + mp = app_fw_flower->ctrl_pktmbuf_pool; + + eth_dev->dev_ops = &nfp_flower_ctrl_vnic_ops; + rte_eth_dev_probing_finish(eth_dev); + + /* Configure the ctrl vNIC device */ + n_rxq = hw->max_rx_queues; + n_txq = hw->max_tx_queues; + eth_dev->data->rx_queues = rte_zmalloc("ethdev->rx_queues", + sizeof(eth_dev->data->rx_queues[0]) * n_rxq, + RTE_CACHE_LINE_SIZE); + if (eth_dev->data->rx_queues == NULL) { + PMD_INIT_LOG(ERR, "rte_zmalloc failed for ctrl vNIC rx queues"); + ret = -ENOMEM; + goto mempool_cleanup; + } + + eth_dev->data->tx_queues = rte_zmalloc("ethdev->tx_queues", + sizeof(eth_dev->data->tx_queues[0]) * n_txq, + RTE_CACHE_LINE_SIZE); + if (eth_dev->data->tx_queues == NULL) { + PMD_INIT_LOG(ERR, "rte_zmalloc failed for ctrl vNIC tx queues"); + ret = -ENOMEM; + goto rx_queue_free; + } + + /* Fill in some of the eth_dev fields */ + eth_dev->device = &pf_dev->pci_dev->device; + eth_dev->data->nb_tx_queues = n_rxq; + eth_dev->data->nb_rx_queues = n_txq; + eth_dev->data->dev_private = hw; + + /* Set up the Rx queues */ + for (i = 0; i < n_rxq; i++) { + ret = nfp_net_rx_queue_setup(eth_dev, i, CTRL_VNIC_NB_DESC, numa_node, + &rx_conf, mp); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Configure ctrl vNIC Rx queue %d failed", i); + goto rx_queue_cleanup; + } + } + + /* Set up the Tx queues */ + for (i = 0; i < n_txq; i++) { + ret = nfp_net_nfd3_tx_queue_setup(eth_dev, i, CTRL_VNIC_NB_DESC, numa_node, + &tx_conf); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Configure ctrl vNIC Tx queue %d failed", i); + goto tx_queue_cleanup; + } + } + + return 0; + +tx_queue_cleanup: + for (i = 0; i < n_txq; i++) + nfp_net_tx_queue_release(eth_dev, i); +rx_queue_cleanup: + for (i = 0; i < n_rxq; i++) + nfp_net_rx_queue_release(eth_dev, i); + rte_free(eth_dev->data->tx_queues); +rx_queue_free: + rte_free(eth_dev->data->rx_queues); +mempool_cleanup: + rte_mempool_free(mp); +port_release: + rte_eth_dev_release_port(hw->eth_dev); + + return ret; +} + +static void +nfp_flower_cleanup_ctrl_vnic(struct nfp_net_hw *hw) +{ + uint32_t i; + struct nfp_app_fw_flower *app_fw_flower; + + app_fw_flower = NFP_PRIV_TO_APP_FW_FLOWER(hw->pf_dev->app_fw_priv); + + for (i = 0; i < hw->max_tx_queues; i++) + nfp_net_tx_queue_release(hw->eth_dev, i); + + for (i = 0; i < hw->max_rx_queues; i++) + nfp_net_rx_queue_release(hw->eth_dev, i); + + rte_free(hw->eth_dev->data->tx_queues); + rte_free(hw->eth_dev->data->rx_queues); + rte_mempool_free(app_fw_flower->ctrl_pktmbuf_pool); + rte_eth_dev_release_port(hw->eth_dev); +} + +static int +nfp_flower_start_ctrl_vnic(struct nfp_net_hw *hw) +{ + int ret; + uint32_t update; + uint32_t new_ctrl; + struct rte_eth_dev *dev; + + dev = hw->eth_dev; + + /* Disabling queues just in case... */ + nfp_net_disable_queues(dev); + + /* Enabling the required queues in the device */ + nfp_net_enable_queues(dev); + + /* Writing configuration parameters in the device */ + nfp_net_params_setup(hw); + + new_ctrl = NFP_NET_CFG_CTRL_ENABLE; + update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING | + NFP_NET_CFG_UPDATE_MSIX; + + rte_wmb(); + + /* 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 ctrl 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 ctrl vNIC freelist setup"); + return -EIO; + } + + return 0; +} + int nfp_init_app_fw_flower(struct nfp_pf_dev *pf_dev) { int ret; unsigned int numa_node; struct nfp_net_hw *pf_hw; + struct nfp_net_hw *ctrl_hw; struct nfp_app_fw_flower *app_fw_flower; numa_node = rte_socket_id(); @@ -561,8 +747,42 @@ struct dp_packet { goto pf_vnic_cleanup; } + /* The ctrl vNIC struct comes directly after the PF one */ + app_fw_flower->ctrl_hw = pf_hw + 1; + ctrl_hw = app_fw_flower->ctrl_hw; + + /* Map the ctrl vNIC ctrl bar */ + ctrl_hw->ctrl_bar = nfp_rtsym_map(pf_dev->sym_tbl, "_pf0_net_ctrl_bar", + 32768, &ctrl_hw->ctrl_area); + if (ctrl_hw->ctrl_bar == NULL) { + PMD_INIT_LOG(ERR, "Cloud not map the ctrl vNIC ctrl bar"); + ret = -ENODEV; + goto pf_vnic_cleanup; + } + + /* Now populate the ctrl vNIC */ + ctrl_hw->pf_dev = pf_dev; + ctrl_hw->cpp = pf_dev->cpp; + + ret = nfp_flower_init_ctrl_vnic(app_fw_flower->ctrl_hw); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Could not initialize flower ctrl vNIC"); + goto ctrl_cpp_area_cleanup; + } + + /* Start the ctrl vNIC */ + ret = nfp_flower_start_ctrl_vnic(app_fw_flower->ctrl_hw); + if (ret != 0) { + PMD_INIT_LOG(ERR, "Could not start flower ctrl vNIC"); + goto ctrl_vnic_cleanup; + } + return 0; +ctrl_vnic_cleanup: + nfp_flower_cleanup_ctrl_vnic(app_fw_flower->ctrl_hw); +ctrl_cpp_area_cleanup: + nfp_cpp_area_free(ctrl_hw->ctrl_area); pf_vnic_cleanup: nfp_flower_cleanup_pf_vnic(app_fw_flower->pf_hw); pf_cpp_area_cleanup: diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h index 981d88d..e18703e 100644 --- a/drivers/net/nfp/flower/nfp_flower.h +++ b/drivers/net/nfp/flower/nfp_flower.h @@ -14,6 +14,12 @@ struct nfp_app_fw_flower { /* Pointer to the PF vNIC */ struct nfp_net_hw *pf_hw; + /* Pointer to a mempool for the ctrlvNIC */ + struct rte_mempool *ctrl_pktmbuf_pool; + + /* Pointer to the ctrl vNIC */ + struct nfp_net_hw *ctrl_hw; + /* the eth table as reported by firmware */ struct nfp_eth_table *nfp_eth_table; }; diff --git a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c index 08bc4e8..22c8bc4 100644 --- a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c +++ b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c @@ -91,7 +91,10 @@ * @refcnt: number of current users * @iomem: mapped IO memory */ +#define NFP_BAR_MIN 1 +#define NFP_BAR_MID 5 #define NFP_BAR_MAX 7 + struct nfp_bar { struct nfp_pcie_user *nfp; uint32_t barcfg; @@ -292,6 +295,7 @@ struct nfp_pcie_user { * BAR0.0: Reserved for General Mapping (for MSI-X access to PCIe SRAM) * * Halving PCItoCPPBars for primary and secondary processes. + * For CoreNIC firmware: * NFP PMD just requires two fixed slots, one for configuration BAR, * and another for accessing the hw queues. Another slot is needed * for setting the link up or down. Secondary processes do not need @@ -301,6 +305,9 @@ struct nfp_pcie_user { * supported. Due to this requirement and future extensions requiring * new slots per process, only one secondary process is supported by * now. + * For Flower firmware: + * NFP PMD need another fixed slots, used as the configureation BAR + * for ctrl vNIC. */ static int nfp_enable_bars(struct nfp_pcie_user *nfp) @@ -309,11 +316,11 @@ struct nfp_pcie_user { int x, start, end; if (rte_eal_process_type() == RTE_PROC_PRIMARY) { - start = 4; - end = 1; + start = NFP_BAR_MID; + end = NFP_BAR_MIN; } else { - start = 7; - end = 4; + start = NFP_BAR_MAX; + end = NFP_BAR_MID; } for (x = start; x > end; x--) { bar = &nfp->bar[x - 1]; @@ -341,11 +348,11 @@ struct nfp_pcie_user { int x, start, end; if (rte_eal_process_type() == RTE_PROC_PRIMARY) { - start = 4; - end = 1; + start = NFP_BAR_MID; + end = NFP_BAR_MIN; } else { - start = 7; - end = 4; + start = NFP_BAR_MAX; + end = NFP_BAR_MID; } for (x = start; x > end; x--) { bar = &nfp->bar[x - 1]; @@ -364,11 +371,11 @@ struct nfp_pcie_user { int x, start, end; if (rte_eal_process_type() == RTE_PROC_PRIMARY) { - start = 4; - end = 1; + start = NFP_BAR_MID; + end = NFP_BAR_MIN; } else { - start = 7; - end = 4; + start = NFP_BAR_MAX; + end = NFP_BAR_MID; } for (x = start; x > end; x--) { -- 1.8.3.1