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 1D9C94588C; Tue, 3 Sep 2024 03:42:29 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B6BB840E2D; Tue, 3 Sep 2024 03:42:15 +0200 (CEST) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2124.outbound.protection.outlook.com [40.107.100.124]) by mails.dpdk.org (Postfix) with ESMTP id BB32140275 for ; Tue, 3 Sep 2024 03:42:11 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eyj8f4qNmnbor4JnKJQzRIBtFxwjT7MUezzgKc87xJS/rl3yOvZQILnq/TZTd3+3CGhJa0GQsRh8aJ5YtJrmk0vBdNqYQ5gqxVHWIUdm1xW71b9WVukaD/cTqvvLD5G8nLc5syhyi+Q35gl6wY5Qs7UHxjMxv53BMqOSLqJQqo/T8CEq104XOH25N+/EIJCPgxx0oVUznCq3ccOA56xda1ZMInFV7o9DX4s8tT+7iyZfuLHto0w5Co+2LkXnF9QuH2VPlYj424aKX+Koj/yk2Ig3TEiI2sPexSPtKXj342r3eDSwtzttTvARWPkc11lKHsONypjCBuuH40Jp0xjgxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=evQ8w+AKFaxAbw6wOT/zFyKWVPaLe4czFwWvXeoZTX4=; b=tV5w8fBsziNryxBmlaGixkntD63j1PU0QfepyRqWo1JAOL0VikAj0tANLBPFMRtY6qfPpZYvupfStBa3G8pGeAIAMhCrCeRPPVeAZTAqBDEOHKb8mU0O7CjfWFwYRDJ9ZMBIcAqbPnt9OyVNdroxXs2vCpLOrTeiX5j1H/vBtOVvArUtzhiEwAVfnOXqvV5VNy8Gc8PZzaX3huNZ3rJ/n98QVWhbrbJJw0lnhTSfGZy+PxOanh6axNZGgu0yc0ORKvhNkidbGDtaX/t0EooXZkaTTzXx5As95qxCtcGu1DnIjWZoiA0Nad8u0JOA0zQshd2EQLvW8OGArNJ9C3X0WQ== 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=evQ8w+AKFaxAbw6wOT/zFyKWVPaLe4czFwWvXeoZTX4=; b=AbnF5lvLO6v4B9GcX7QOmjiU01XAlnzEo4fqJBNl7BVqfBnZqKTl320XcCucS9gmJ4Ws6BI4naIDkhn/VyB2zwRRHZuWoykodHsRU6d/WBqEbPjPvjjX+cq43jEalQOpcjXiPquLI/xD2Vu+lGzWRPiv4MkHeazhUFa38I+4tC8= 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 DM8PR13MB5093.namprd13.prod.outlook.com (2603:10b6:8:20::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.24; Tue, 3 Sep 2024 01:42:10 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::b900:5f05:766f:833]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::b900:5f05:766f:833%4]) with mapi id 15.20.7918.020; Tue, 3 Sep 2024 01:42:10 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He , Long Wu Subject: [PATCH 2/4] net/nfp: refactor the firmware version logic Date: Tue, 3 Sep 2024 09:41:43 +0800 Message-Id: <20240903014145.2635710-3-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240903014145.2635710-1-chaoyong.he@corigine.com> References: <20240903014145.2635710-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SJ0PR05CA0176.namprd05.prod.outlook.com (2603:10b6:a03:339::31) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|DM8PR13MB5093:EE_ X-MS-Office365-Filtering-Correlation-Id: c1101a18-2e05-4bc2-a8a3-08dccbb9a041 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|1800799024|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?3K7I82SQFHMvWCP/rgyW44WOkMz/xm0DC20GwXdr6+frQj4q+c4BqXUdHGhk?= =?us-ascii?Q?s6lCUrLecbFVjqxVNGWcMCl7N2Zj6XuZkSMP3W6cDEej3KGNrskpFUfFFCr5?= =?us-ascii?Q?aN0e9MrmhTDDNluJOLkpg0SSaC9ao8WqbbXJxxBnWaG5I0qfYOx+mnnvq1A6?= =?us-ascii?Q?0jaLiKwq+rGqIRODQg4T9vpP7rJuzG6KBCuB+5wZulhrT39r8JSMWeB7XmPj?= =?us-ascii?Q?hlgr9IMpaC8RI7ebvyGolMsezhOKbR9GfaVL6PtzIFVfNocwWY1p4kQwhWRY?= =?us-ascii?Q?5su9MRGEN0qyiHJRP1MLM9VPA8u5kkOpVRWKOfo4YWIC7mzLQmx1IRsYdtT1?= =?us-ascii?Q?IibQKWidTxvCKi1Gdh9m/GVkFcxhRetjnV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cwY3IblxvOwrDBWPR/ITWVEtVY5F2Hw1jPXxwZwGoGoj+yZuaMf?= =?us-ascii?Q?ji5weHeGIZVS75OhpufmKmyWn9LXct5y7PVh0m8WVp1ve8ESVjtkKUxlTJ7a?= =?us-ascii?Q?VehCN+vsjAqUndGobbBqZkUcepFGaLRIB0xCO/bdhtZWixHJfQ=3D=3D?= 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:(13230040)(366016)(1800799024)(52116014)(376014)(38350700014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?LQWgOBeh5VYn4Id41DeQ9IwcjO/+GQIOWI0SPF6sCUBItJhenCg93DQCTO2B?= =?us-ascii?Q?CLpS90XdOnx7K2u9bFu6POFlRt6q2gWFmRO2QUwFplFIpYO6DSIU/Wr3Al8S?= =?us-ascii?Q?F0v2S4gnjuz6vMNH0El1QwxZBGnGRWjM0OTRYEO3KQdKmyYDid18YNKywXi0?= =?us-ascii?Q?M85Fdq2YmrzUC/2dYxPbn/Pg9hVBo5dlQUmHMJYlHoMXf4G4dvf51sE/UAsp?= =?us-ascii?Q?MOXH2uzyihV9/M96ieMFDyRLXsgsFe3aUuSRT6mOWzAzXbgOMpacH4VzOv4Y?= =?us-ascii?Q?p1Ww2ehTRC3cfBJOtjcNP8/ceVb37xbSVoG7AUABpjWQvCfETUNjUA9M2Q2k?= =?us-ascii?Q?F+XKzhKhX6f2IF2FAtkjYwkWRCz3IEgI+Iv0ehSJZOWpG6mJNm/edZkRnIBs?= =?us-ascii?Q?RzT9sUavYg0CpWop/ShxMM92+vhmlbcg/2wL6mDP332jCXtacNTTgQY9kRsy?= =?us-ascii?Q?T6+eMyiSob01hlwzCirNcgD470bePSj35FQ0FzVC5o0qxsCm2C/i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e0VrchZM+NHFKGSZ9Y7PlDwLPr9cjyzwvt?= =?us-ascii?Q?Xi502D6n8NhQfJdH4gfU6m4/kU6CQZMGMugJkf5ekVvaQv0zO5jYnDbLKnPy?= =?us-ascii?Q?fF5u7skuN4j9C7x6vFJnSh6S1v4AHVVc/KBLZOceKxhTtSECDLpDx15VDfzd?= =?us-ascii?Q?uiWdkY3xUKXVngD4IjOqcgOFcbPHK506vPzWAGF+0QMaPYxxlzQMa+zoRsWG?= =?us-ascii?Q?Wg=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: c1101a18-2e05-4bc2-a8a3-08dccbb9a041 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2024 01:42:10.0787 (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: DcU3CQbOKYKbQQl6LBggo1f0RRFP0Lie/NaqrZ6AYkK7ygyEiqipWCXBPgRxtFVO98J1EWVu94UTGb3g5dnqtuIF1tGIEGe33bBr1w7JNaM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR13MB5093 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 Move the 'ver' data field from 'struct nfp_net_hw' into 'struct nfp_pf_dev', also modify the related logic. Signed-off-by: Chaoyong He Reviewed-by: Long Wu --- drivers/net/nfp/flower/nfp_flower.c | 30 ++++++------- drivers/net/nfp/flower/nfp_flower_ctrl.c | 8 ++-- drivers/net/nfp/flower/nfp_flower_ctrl.h | 2 +- drivers/net/nfp/nfd3/nfp_nfd3_dp.c | 2 +- drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 2 +- drivers/net/nfp/nfp_ethdev.c | 29 +++++++----- drivers/net/nfp/nfp_ethdev_vf.c | 30 ++++++++++--- drivers/net/nfp/nfp_net_common.c | 56 ++++++++++++++---------- drivers/net/nfp/nfp_net_common.h | 16 ++++--- drivers/net/nfp/nfp_net_meta.c | 5 ++- drivers/net/nfp/nfp_net_meta.h | 5 ++- drivers/net/nfp/nfp_rxtx.c | 10 ++--- 12 files changed, 118 insertions(+), 77 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index 8d781658ea..4d91d548f7 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -166,15 +166,15 @@ nfp_flower_pf_nfdk_xmit_pkts(void *tx_queue, } static void -nfp_flower_pf_xmit_pkts_register(struct nfp_app_fw_flower *app_fw_flower) +nfp_flower_pf_xmit_pkts_register(struct nfp_pf_dev *pf_dev) { - struct nfp_net_hw *hw; struct nfp_flower_nfd_func *nfd_func; + struct nfp_app_fw_flower *app_fw_flower; - hw = app_fw_flower->pf_hw; + app_fw_flower = pf_dev->app_fw_priv; nfd_func = &app_fw_flower->nfd_func; - if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3) + if (pf_dev->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3) nfd_func->pf_xmit_t = nfp_flower_pf_nfd3_xmit_pkts; else nfd_func->pf_xmit_t = nfp_flower_pf_nfdk_xmit_pkts; @@ -204,14 +204,12 @@ nfp_flower_init_vnic_common(struct nfp_net_hw_priv *hw_priv, uint64_t rx_bar_off; uint64_t tx_bar_off; struct nfp_pf_dev *pf_dev; - struct rte_pci_device *pci_dev; pf_dev = hw_priv->pf_dev; - pci_dev = pf_dev->pci_dev; PMD_INIT_LOG(DEBUG, "%s vNIC ctrl bar: %p", vnic_type, hw->super.ctrl_bar); - err = nfp_net_common_init(pci_dev, hw); + err = nfp_net_common_init(pf_dev, hw); if (err != 0) return err; @@ -612,15 +610,15 @@ nfp_flower_start_ctrl_vnic(struct nfp_app_fw_flower *app_fw_flower) } static void -nfp_flower_pkt_add_metadata_register(struct nfp_app_fw_flower *app_fw_flower) +nfp_flower_pkt_add_metadata_register(struct nfp_pf_dev *pf_dev) { - struct nfp_net_hw *hw; struct nfp_flower_nfd_func *nfd_func; + struct nfp_app_fw_flower *app_fw_flower; - hw = app_fw_flower->pf_hw; + app_fw_flower = pf_dev->app_fw_priv; nfd_func = &app_fw_flower->nfd_func; - if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3) + if (pf_dev->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3) nfd_func->pkt_add_metadata_t = nfp_flower_nfd3_pkt_add_metadata; else nfd_func->pkt_add_metadata_t = nfp_flower_nfdk_pkt_add_metadata; @@ -635,11 +633,11 @@ nfp_flower_pkt_add_metadata(struct nfp_app_fw_flower *app_fw_flower, } static void -nfp_flower_nfd_func_register(struct nfp_app_fw_flower *app_fw_flower) +nfp_flower_nfd_func_register(struct nfp_pf_dev *pf_dev) { - nfp_flower_pkt_add_metadata_register(app_fw_flower); - nfp_flower_ctrl_vnic_xmit_register(app_fw_flower); - nfp_flower_pf_xmit_pkts_register(app_fw_flower); + nfp_flower_pkt_add_metadata_register(pf_dev); + nfp_flower_ctrl_vnic_xmit_register(pf_dev); + nfp_flower_pf_xmit_pkts_register(pf_dev); } int @@ -730,7 +728,7 @@ nfp_init_app_fw_flower(struct nfp_net_hw_priv *hw_priv) goto pf_cpp_area_cleanup; } - nfp_flower_nfd_func_register(app_fw_flower); + nfp_flower_nfd_func_register(pf_dev); /* The ctrl vNIC struct comes directly after the PF one */ app_fw_flower->ctrl_hw = pf_hw + 1; diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c index a46b849d1b..9b957e1f1e 100644 --- a/drivers/net/nfp/flower/nfp_flower_ctrl.c +++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c @@ -343,15 +343,15 @@ nfp_flower_ctrl_vnic_nfdk_xmit(struct nfp_app_fw_flower *app_fw_flower, } void -nfp_flower_ctrl_vnic_xmit_register(struct nfp_app_fw_flower *app_fw_flower) +nfp_flower_ctrl_vnic_xmit_register(struct nfp_pf_dev *pf_dev) { - struct nfp_net_hw *hw; struct nfp_flower_nfd_func *nfd_func; + struct nfp_app_fw_flower *app_fw_flower; - hw = app_fw_flower->pf_hw; + app_fw_flower = pf_dev->app_fw_priv; nfd_func = &app_fw_flower->nfd_func; - if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3) + if (pf_dev->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3) nfd_func->ctrl_vnic_xmit_t = nfp_flower_ctrl_vnic_nfd3_xmit; else nfd_func->ctrl_vnic_xmit_t = nfp_flower_ctrl_vnic_nfdk_xmit; diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.h b/drivers/net/nfp/flower/nfp_flower_ctrl.h index b5d0036c01..f18c8f4095 100644 --- a/drivers/net/nfp/flower/nfp_flower_ctrl.h +++ b/drivers/net/nfp/flower/nfp_flower_ctrl.h @@ -11,6 +11,6 @@ void nfp_flower_ctrl_vnic_process(struct nfp_net_hw_priv *hw_priv); uint16_t nfp_flower_ctrl_vnic_xmit(struct nfp_app_fw_flower *app_fw_flower, struct rte_mbuf *mbuf); -void nfp_flower_ctrl_vnic_xmit_register(struct nfp_app_fw_flower *app_fw_flower); +void nfp_flower_ctrl_vnic_xmit_register(struct nfp_pf_dev *pf_dev); #endif /* __NFP_FLOWER_CTRL_H__ */ diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c index ee96cd8e46..4ff1ae63b0 100644 --- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c +++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c @@ -390,7 +390,7 @@ nfp_net_nfd3_tx_queue_setup(struct rte_eth_dev *dev, hw = nfp_net_get_hw(dev); hw_priv = dev->process_private; - nfp_net_tx_desc_limits(hw, hw_priv, &min_tx_desc, &max_tx_desc); + nfp_net_tx_desc_limits(hw_priv, &min_tx_desc, &max_tx_desc); /* Validating number of descriptors */ tx_desc_sz = nb_desc * sizeof(struct nfp_net_nfd3_tx_desc); diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c index 2cea5688b3..68fcbe93da 100644 --- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c +++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c @@ -424,7 +424,7 @@ nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev, hw = nfp_net_get_hw(dev); hw_priv = dev->process_private; - nfp_net_tx_desc_limits(hw, hw_priv, &min_tx_desc, &max_tx_desc); + nfp_net_tx_desc_limits(hw_priv, &min_tx_desc, &max_tx_desc); /* Validating number of descriptors */ tx_desc_sz = nb_desc * sizeof(struct nfp_net_nfdk_tx_desc); diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 181fd74efe..d85993f70c 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -959,10 +959,10 @@ static const struct eth_dev_ops nfp_net_eth_dev_ops = { }; static inline void -nfp_net_ethdev_ops_mount(struct nfp_net_hw *hw, +nfp_net_ethdev_ops_mount(struct nfp_pf_dev *pf_dev, struct rte_eth_dev *eth_dev) { - if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3) + if (pf_dev->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3) eth_dev->tx_pkt_burst = nfp_net_nfd3_xmit_pkts; else nfp_net_nfdk_xmit_pkts_set(eth_dev); @@ -1030,7 +1030,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev, PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->ctrl_bar); PMD_INIT_LOG(DEBUG, "MAC stats: %p", net_hw->mac_stats); - err = nfp_net_common_init(pci_dev, net_hw); + err = nfp_net_common_init(pf_dev, net_hw); if (err != 0) return err; @@ -1046,7 +1046,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev, return err; } - nfp_net_ethdev_ops_mount(net_hw, eth_dev); + nfp_net_ethdev_ops_mount(pf_dev, eth_dev); net_hw->eth_xstats_base = rte_malloc("rte_eth_xstat", sizeof(struct rte_eth_xstat) * nfp_net_xstats_size(eth_dev), 0); @@ -1074,7 +1074,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev, if ((hw->cap & NFP_NET_CFG_CTRL_LSO2) != 0) hw->cap &= ~NFP_NET_CFG_CTRL_TXVLAN; - nfp_net_log_device_information(net_hw); + nfp_net_log_device_information(net_hw, pf_dev); /* Initializing spinlock for reconfigs */ rte_spinlock_init(&hw->reconfig_lock); @@ -1552,9 +1552,6 @@ nfp_enable_multi_pf(struct nfp_pf_dev *pf_dev) struct nfp_cpp_area *area; char name[RTE_ETH_NAME_MAX_LEN]; - if (!pf_dev->multi_pf.enabled) - return 0; - memset(&net_hw, 0, sizeof(struct nfp_net_hw)); /* Map the symbol table */ @@ -1570,6 +1567,16 @@ nfp_enable_multi_pf(struct nfp_pf_dev *pf_dev) hw = &net_hw.super; hw->ctrl_bar = ctrl_bar; + /* Check the version from firmware */ + if (!nfp_net_version_check(hw, pf_dev)) { + PMD_INIT_LOG(ERR, "Not the valid version."); + err = -EINVAL; + goto end; + } + + if (!pf_dev->multi_pf.enabled) + goto end; + cap_extend = nn_cfg_readl(hw, NFP_NET_CFG_CAP_WORD1); if ((cap_extend & NFP_NET_CFG_CTRL_MULTI_PF) == 0) { PMD_INIT_LOG(ERR, "Loaded firmware doesn't support multiple PF"); @@ -2358,10 +2365,10 @@ static int nfp_secondary_net_init(struct rte_eth_dev *eth_dev, void *para) { - struct nfp_net_hw *net_hw; + struct nfp_net_hw_priv *hw_priv; - net_hw = eth_dev->data->dev_private; - nfp_net_ethdev_ops_mount(net_hw, eth_dev); + hw_priv = para; + nfp_net_ethdev_ops_mount(hw_priv->pf_dev, eth_dev); eth_dev->process_private = para; diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c index cdf5da3af7..2e581c7e45 100644 --- a/drivers/net/nfp/nfp_ethdev_vf.c +++ b/drivers/net/nfp/nfp_ethdev_vf.c @@ -235,10 +235,10 @@ static const struct eth_dev_ops nfp_netvf_eth_dev_ops = { }; static inline void -nfp_netvf_ethdev_ops_mount(struct nfp_net_hw *hw, +nfp_netvf_ethdev_ops_mount(struct nfp_pf_dev *pf_dev, struct rte_eth_dev *eth_dev) { - if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3) + if (pf_dev->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3) eth_dev->tx_pkt_burst = nfp_net_nfd3_xmit_pkts; else nfp_net_nfdk_xmit_pkts_set(eth_dev); @@ -256,6 +256,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev) uint32_t start_q; struct nfp_hw *hw; struct nfp_net_hw *net_hw; + struct nfp_pf_dev *pf_dev; uint64_t tx_bar_off = 0; uint64_t rx_bar_off = 0; struct rte_pci_device *pci_dev; @@ -280,13 +281,27 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev) return -ENODEV; } + pf_dev = rte_zmalloc(NULL, sizeof(*pf_dev), 0); + if (pf_dev == NULL) { + PMD_INIT_LOG(ERR, "Can not allocate memory for the PF device."); + return -ENOMEM; + } + + pf_dev->pci_dev = pci_dev; + + /* Check the version from firmware */ + if (!nfp_net_version_check(hw, pf_dev)) { + err = -EINVAL; + goto pf_dev_free; + } + PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->ctrl_bar); - err = nfp_net_common_init(pci_dev, net_hw); + err = nfp_net_common_init(pf_dev, net_hw); if (err != 0) - return err; + goto pf_dev_free; - nfp_netvf_ethdev_ops_mount(net_hw, eth_dev); + nfp_netvf_ethdev_ops_mount(pf_dev, eth_dev); hw_priv = rte_zmalloc(NULL, sizeof(*hw_priv), 0); if (hw_priv == NULL) { @@ -296,6 +311,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev) } hw_priv->dev_info = dev_info; + hw_priv->pf_dev = pf_dev; eth_dev->process_private = hw_priv; @@ -330,7 +346,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev) if ((hw->cap & NFP_NET_CFG_CTRL_LSO2) != 0) hw->cap &= ~NFP_NET_CFG_CTRL_TXVLAN; - nfp_net_log_device_information(net_hw); + nfp_net_log_device_information(net_hw, pf_dev); /* Initializing spinlock for reconfigs */ rte_spinlock_init(&hw->reconfig_lock); @@ -381,6 +397,8 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev) rte_free(net_hw->eth_xstats_base); hw_priv_free: rte_free(hw_priv); +pf_dev_free: + rte_free(pf_dev); return err; } diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c index b471fd032a..e4e01d8c79 100644 --- a/drivers/net/nfp/nfp_net_common.c +++ b/drivers/net/nfp/nfp_net_common.c @@ -349,13 +349,14 @@ nfp_net_configure(struct rte_eth_dev *dev) } void -nfp_net_log_device_information(const struct nfp_net_hw *hw) +nfp_net_log_device_information(const struct nfp_net_hw *hw, + struct nfp_pf_dev *pf_dev) { uint32_t cap = hw->super.cap; uint32_t cap_ext = hw->super.cap_ext; PMD_INIT_LOG(INFO, "VER: %u.%u, Maximum supported MTU: %d", - hw->ver.major, hw->ver.minor, hw->max_mtu); + pf_dev->ver.major, pf_dev->ver.minor, hw->max_mtu); PMD_INIT_LOG(INFO, "CAP: %#x", cap); PMD_INIT_LOG(INFO, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", @@ -1235,14 +1236,13 @@ nfp_net_rx_desc_limits(struct nfp_net_hw_priv *hw_priv, } void -nfp_net_tx_desc_limits(struct nfp_net_hw *hw, - struct nfp_net_hw_priv *hw_priv, +nfp_net_tx_desc_limits(struct nfp_net_hw_priv *hw_priv, uint16_t *min_tx_desc, uint16_t *max_tx_desc) { uint16_t tx_dpp; - if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3) + if (hw_priv->pf_dev->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3) tx_dpp = NFD3_TX_DESC_PER_PKT; else tx_dpp = NFDK_TX_DESC_PER_SIMPLE_PKT; @@ -1269,7 +1269,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) return -EINVAL; nfp_net_rx_desc_limits(hw_priv, &min_rx_desc, &max_rx_desc); - nfp_net_tx_desc_limits(hw, hw_priv, &min_tx_desc, &max_tx_desc); + nfp_net_tx_desc_limits(hw_priv, &min_tx_desc, &max_tx_desc); dev_info->max_rx_queues = (uint16_t)hw->max_rx_queues; dev_info->max_tx_queues = (uint16_t)hw->max_tx_queues; @@ -1373,11 +1373,13 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) } int -nfp_net_common_init(struct rte_pci_device *pci_dev, +nfp_net_common_init(struct nfp_pf_dev *pf_dev, struct nfp_net_hw *hw) { const int stride = 4; + struct rte_pci_device *pci_dev; + pci_dev = pf_dev->pci_dev; hw->device_id = pci_dev->id.device_id; hw->vendor_id = pci_dev->id.vendor_id; hw->subsystem_device_id = pci_dev->id.subsystem_device_id; @@ -1391,11 +1393,7 @@ nfp_net_common_init(struct rte_pci_device *pci_dev, return -ENODEV; } - nfp_net_cfg_read_version(hw); - if (!nfp_net_is_valid_nfd_version(hw->ver)) - return -EINVAL; - - if (nfp_net_check_dma_mask(hw, pci_dev->name) != 0) + if (nfp_net_check_dma_mask(pf_dev, pci_dev->name) != 0) return -ENODEV; /* Get some of the read-only fields from the config BAR */ @@ -1404,10 +1402,10 @@ nfp_net_common_init(struct rte_pci_device *pci_dev, hw->max_mtu = nn_cfg_readl(&hw->super, NFP_NET_CFG_MAX_MTU); hw->flbufsz = DEFAULT_FLBUF_SIZE; - nfp_net_meta_init_format(hw); + nfp_net_meta_init_format(hw, pf_dev); /* Read the Rx offset configured from firmware */ - if (hw->ver.major < 2) + if (pf_dev->ver.major < 2) hw->rx_offset = NFP_NET_RX_OFFSET; else hw->rx_offset = nn_cfg_readl(&hw->super, NFP_NET_CFG_RX_OFFSET); @@ -2118,10 +2116,10 @@ nfp_net_set_vxlan_port(struct nfp_net_hw *net_hw, * than 40 bits. */ int -nfp_net_check_dma_mask(struct nfp_net_hw *hw, +nfp_net_check_dma_mask(struct nfp_pf_dev *pf_dev, char *name) { - if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3 && + if (pf_dev->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3 && rte_mem_check_dma_mask(40) != 0) { PMD_DRV_LOG(ERR, "Device %s can't be used: restricted dma mask to 40 bits!", name); @@ -2165,16 +2163,28 @@ nfp_net_txrwb_free(struct rte_eth_dev *eth_dev) net_hw->txrwb_mz = NULL; } -void -nfp_net_cfg_read_version(struct nfp_net_hw *hw) +static void +nfp_net_cfg_read_version(struct nfp_hw *hw, + struct nfp_pf_dev *pf_dev) { union { uint32_t whole; struct nfp_net_fw_ver split; } version; - version.whole = nn_cfg_readl(&hw->super, NFP_NET_CFG_VERSION); - hw->ver = version.split; + version.whole = nn_cfg_readl(hw, NFP_NET_CFG_VERSION); + pf_dev->ver = version.split; +} + +bool +nfp_net_version_check(struct nfp_hw *hw, + struct nfp_pf_dev *pf_dev) +{ + nfp_net_cfg_read_version(hw, pf_dev); + if (!nfp_net_is_valid_nfd_version(pf_dev->ver)) + return false; + + return true; } static void @@ -2249,6 +2259,7 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev, size_t fw_size) { struct nfp_net_hw *hw; + struct nfp_pf_dev *pf_dev; struct nfp_net_hw_priv *hw_priv; char app_name[FW_VER_LEN] = {0}; char mip_name[FW_VER_LEN] = {0}; @@ -2260,6 +2271,7 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev, hw = nfp_net_get_hw(dev); hw_priv = dev->process_private; + pf_dev = hw_priv->pf_dev; if (hw->fw_version[0] != 0) { snprintf(fw_version, FW_VER_LEN, "%s", hw->fw_version); @@ -2268,8 +2280,8 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev, if (!rte_eth_dev_is_repr(dev)) { snprintf(vnic_version, FW_VER_LEN, "%d.%d.%d.%d", - hw->ver.extend, hw->ver.class, - hw->ver.major, hw->ver.minor); + pf_dev->ver.extend, pf_dev->ver.class, + pf_dev->ver.major, pf_dev->ver.minor); } else { snprintf(vnic_version, FW_VER_LEN, "*"); } diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h index 67ec5a2d89..8d0922d48c 100644 --- a/drivers/net/nfp/nfp_net_common.h +++ b/drivers/net/nfp/nfp_net_common.h @@ -108,6 +108,8 @@ struct nfp_pf_dev { enum nfp_app_fw_id app_fw_id; + struct nfp_net_fw_ver ver; + /** Pointer to the app running on the PF */ void *app_fw_priv; @@ -219,7 +221,6 @@ struct nfp_net_hw { const struct rte_memzone *txrwb_mz; /** Info from the firmware */ - struct nfp_net_fw_ver ver; uint32_t max_mtu; uint32_t mtu; uint32_t rx_offset; @@ -276,8 +277,9 @@ nfp_qcp_queue_offset(const struct nfp_dev_info *dev_info, /* Prototypes for common NFP functions */ int nfp_net_mbox_reconfig(struct nfp_net_hw *hw, uint32_t mbox_cmd); int nfp_net_configure(struct rte_eth_dev *dev); -int nfp_net_common_init(struct rte_pci_device *pci_dev, struct nfp_net_hw *hw); -void nfp_net_log_device_information(const struct nfp_net_hw *hw); +int nfp_net_common_init(struct nfp_pf_dev *pf_dev, struct nfp_net_hw *hw); +void nfp_net_log_device_information(const struct nfp_net_hw *hw, + struct nfp_pf_dev *pf_dev); void nfp_net_enable_queues(struct rte_eth_dev *dev); void nfp_net_disable_queues(struct rte_eth_dev *dev); void nfp_net_params_setup(struct nfp_net_hw *hw); @@ -345,12 +347,10 @@ int nfp_net_set_vxlan_port(struct nfp_net_hw *hw, size_t idx, uint16_t port); void nfp_net_rx_desc_limits(struct nfp_net_hw_priv *hw_priv, uint16_t *min_rx_desc, uint16_t *max_rx_desc); -void nfp_net_tx_desc_limits(struct nfp_net_hw *hw, - struct nfp_net_hw_priv *hw_priv, +void nfp_net_tx_desc_limits(struct nfp_net_hw_priv *hw_priv, uint16_t *min_tx_desc, uint16_t *max_tx_desc); -int nfp_net_check_dma_mask(struct nfp_net_hw *hw, char *name); -void nfp_net_cfg_read_version(struct nfp_net_hw *hw); +int nfp_net_check_dma_mask(struct nfp_pf_dev *pf_dev, char *name); int nfp_net_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size); bool nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version); struct nfp_net_hw *nfp_net_get_hw(const struct rte_eth_dev *dev); @@ -377,6 +377,8 @@ uint8_t nfp_function_id_get(const struct nfp_pf_dev *pf_dev, uint8_t port_id); int nfp_net_vf_config_app_init(struct nfp_net_hw *net_hw, struct nfp_pf_dev *pf_dev); +bool nfp_net_version_check(struct nfp_hw *hw, + struct nfp_pf_dev *pf_dev); #define NFP_PRIV_TO_APP_FW_NIC(app_fw_priv)\ ((struct nfp_app_fw_nic *)app_fw_priv) diff --git a/drivers/net/nfp/nfp_net_meta.c b/drivers/net/nfp/nfp_net_meta.c index 07c6758d33..5a67f87bee 100644 --- a/drivers/net/nfp/nfp_net_meta.c +++ b/drivers/net/nfp/nfp_net_meta.c @@ -269,14 +269,15 @@ nfp_net_meta_parse(struct nfp_net_rx_desc *rxds, } void -nfp_net_meta_init_format(struct nfp_net_hw *hw) +nfp_net_meta_init_format(struct nfp_net_hw *hw, + struct nfp_pf_dev *pf_dev) { /* * ABI 4.x and ctrl vNIC always use chained metadata, in other cases we allow use of * single metadata if only RSS(v1) is supported by hw capability, and RSS(v2) * also indicate that we are using chained metadata. */ - if (hw->ver.major == 4) { + if (pf_dev->ver.major == 4) { hw->meta_format = NFP_NET_METAFORMAT_CHAINED; } else if ((hw->super.cap & NFP_NET_CFG_CTRL_CHAIN_META) != 0) { hw->meta_format = NFP_NET_METAFORMAT_CHAINED; diff --git a/drivers/net/nfp/nfp_net_meta.h b/drivers/net/nfp/nfp_net_meta.h index 69d08cf3a7..c3d84dff60 100644 --- a/drivers/net/nfp/nfp_net_meta.h +++ b/drivers/net/nfp/nfp_net_meta.h @@ -89,7 +89,10 @@ struct nfp_net_meta_parsed { } vlan[NFP_NET_META_MAX_VLANS]; }; -void nfp_net_meta_init_format(struct nfp_net_hw *hw); +struct nfp_pf_dev; + +void nfp_net_meta_init_format(struct nfp_net_hw *hw, + struct nfp_pf_dev *pf_dev); void nfp_net_meta_parse(struct nfp_net_rx_desc *rxds, struct nfp_net_rxq *rxq, struct nfp_net_hw *hw, diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index 05218537f7..d101477161 100644 --- a/drivers/net/nfp/nfp_rxtx.c +++ b/drivers/net/nfp/nfp_rxtx.c @@ -816,11 +816,11 @@ nfp_net_tx_queue_setup(struct rte_eth_dev *dev, unsigned int socket_id, const struct rte_eth_txconf *tx_conf) { - struct nfp_net_hw *hw; + struct nfp_net_hw_priv *hw_priv; - hw = nfp_net_get_hw(dev); + hw_priv = dev->process_private; - if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3) + if (hw_priv->pf_dev->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3) return nfp_net_nfd3_tx_queue_setup(dev, queue_idx, nb_desc, socket_id, tx_conf); else @@ -852,10 +852,10 @@ nfp_net_tx_queue_info_get(struct rte_eth_dev *dev, struct rte_eth_txq_info *info) { struct rte_eth_dev_info dev_info; - struct nfp_net_hw *hw = nfp_net_get_hw(dev); + struct nfp_net_hw_priv *hw_priv = dev->process_private; struct nfp_net_txq *txq = dev->data->tx_queues[queue_id]; - if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3) + if (hw_priv->pf_dev->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3) info->nb_desc = txq->tx_count / NFD3_TX_DESC_PER_PKT; else info->nb_desc = txq->tx_count / NFDK_TX_DESC_PER_SIMPLE_PKT; -- 2.39.1