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 8502943220; Sat, 28 Oct 2023 08:54:51 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BA96442D87; Sat, 28 Oct 2023 08:54:07 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2102.outbound.protection.outlook.com [40.107.101.102]) by mails.dpdk.org (Postfix) with ESMTP id E41B642D6B for ; Sat, 28 Oct 2023 08:54:05 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KNxDf9CF+pFOWuL1zdlTKku/GLP1hHjb1zCEGV4vK8XZu+GZ9iofbLygMWN/iuHQMtXQFy31QMcV8QGwCd6x9Iijmm2uhXNEEeI4wQmq40jtlv5nI8DTgMg/2uYsK47GB+whwMZccguYDIP9mVdlIFUUEhD7H4yFmUZtXPmFFRrerbCw3aP+u6ThH8pqR0uQt6NrSZwt9rB0KSrg0iaD6ydym1dfwEI2OGrTlnNEiyQfEO/R1rqApGTcDqVcywq9JikvY97KVtqylNiiSZFIzHUv3Y34AVOg5zKtoeZvf7izAH8R47yO3c2gLXX5m0t27DEyJOCJPkL1uTd3eGFsNA== 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=2e51H7JoQoEzlMRoT5HsIny0WqMvE6GB9BdW0jP3Ns0=; b=bDfEMbfuMBE6h63k14UlrDLYDKie24ByN+h4D2DrfvnckQrG6+fFCPpL7hYyfn/gesbWq2p3b5Xb984hxjWJWc/lQAAaJaztItnjKWB5UsdD9jaCMdfJaqLsbjdMOsw3MW73UNpSNx11+IxR66jLf7znsQYnJjlQAzIWFTYWvhPxnrdqU3uuu6eH1GfYRQFQLGNWUxQ/B1lY7ms17qEbEd7fJRKKOFg9H7I52W8NQrWFOKrl7aXc3Apff7ls2kQ4O3mTzC/9cm1ILcDj+BZACj0v4YewcqxMEeZ7UNoyk1Zi6QPfHzlMXmm8JzuE0D3APZouLviXidNiCn1Wkzo2yA== 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=2e51H7JoQoEzlMRoT5HsIny0WqMvE6GB9BdW0jP3Ns0=; b=mHugcdFvYr6WS3kMNLiH8BFs8gidrM6atyfaqgSu8QKhPq6W+VedVMrun4iijZVl/FYaWplfTiY4994YJYePGFtIH6IVLxsLriiNa4xEJoSICyymxGYVmpONVs11KKjxKUXcNnLpo9sutJfDlvuV2L94lbi6zwqVS6oTTIpBWAk= 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 SA1PR13MB6055.namprd13.prod.outlook.com (2603:10b6:806:338::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.19; Sat, 28 Oct 2023 06:54:04 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::45b3:d83c:cff2:4a1b]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::45b3:d83c:cff2:4a1b%6]) with mapi id 15.20.6933.022; Sat, 28 Oct 2023 06:54:04 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He , Peng Zhang Subject: [PATCH v2 10/11] net/nfp: extract a helper function Date: Sat, 28 Oct 2023 14:53:14 +0800 Message-Id: <20231028065315.1937188-11-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231028065315.1937188-1-chaoyong.he@corigine.com> References: <20231028061558.1842855-1-chaoyong.he@corigine.com> <20231028065315.1937188-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SA0PR11CA0020.namprd11.prod.outlook.com (2603:10b6:806:d3::25) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|SA1PR13MB6055:EE_ X-MS-Office365-Filtering-Correlation-Id: 45b64c5b-0ffd-486a-96ae-08dbd782ac20 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3SWlv5nYJsJr8u9p7H+WN0Ij8ZFlkcOzzhhgQfnnCGn2fZigLYIAKHXsQRroSGWn3WUxsOqeQMTXFxgaTNlnXVlxzyyDQ93fQ0QLuy08AGFdAc24dRCAQGh49ReZ3N4lWAe9EGmLEYvhFIKYTPjusQMhHs+H7KLUJ5LzRvkjZlK4+glaLUwVAPdh7RW6TwkpAW3L11fxxTPYLcNAQxL+JLd741nGs0AAJONE2kXRFxKBAB6r7i83u5uvuAcIZXfqAs8U6cA/E2ty1fzUd9Otlur/1l4zAG7g2XVCjLGaCrCjyjXyPMu1/W3WyVCXg0P8XtdBE1VNhYjlGOYGfQdFsQElrd324F/e5e/Um5NpbIi6g4s1s3GwF0s2r74OPTyZlPznxdWK2QRw6X7LFqPF4MCdZChLxAEFb+H12f/yHbRhj9fgKs/eFCxr5r0Zal5PG5/BImdUXf064Wucmrxn1Gmkr0QZCTIKcEdqEzucJJvIQuV9ep+iBPhS7NwabH72OcYJzoznRI5wHTbLTrcxvTrEbcv0NibpdUXQfdlypbbazoXUisz3Gk0Pz8UYI7pH1wT5GiT8H+eaj1WyxbJP8AXYRC936CYTTDnOpDDrdsPvtNSOCNdgiGpP8qarH1A8bdszBCwtCWtMIRfk6+R9FzwhRyC0vlyze2R9g8Kt1kQ= 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:(13230031)(346002)(136003)(396003)(366004)(39830400003)(376002)(230922051799003)(451199024)(1800799009)(64100799003)(186009)(6486002)(8676002)(30864003)(8936002)(478600001)(6666004)(54906003)(66476007)(66946007)(66556008)(86362001)(4326008)(41300700001)(5660300002)(6916009)(2906002)(44832011)(316002)(6506007)(52116002)(38100700002)(36756003)(2616005)(1076003)(107886003)(6512007)(26005)(38350700005)(83380400001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Ty9VVfEqfXQRWhZtSj5EOOZknGIwlF+2NNcaf4njFZEhSWOimtR6ku1XEBYi?= =?us-ascii?Q?N+bZ4G0kloucLQDf0sN5GJwM1PkAT5S2Bycl/mricVNvE6Abi25xxkW6ApF2?= =?us-ascii?Q?suDKL5xUL7X03icX3qYJS91SQp04VVuBCYmjr3tW3R+ZpdcrCnt4D60EpZT+?= =?us-ascii?Q?aZcSsKK+dGMs/NSeqLTXKUnB8rbTsZJz09UwjjqBSDsbHXyY6RKw8GTBH+6F?= =?us-ascii?Q?knyr+AnwJHS71YOfHXWOSQU68xjl03qshMmQ0XDlB904TpR4T+GIxELBLcDT?= =?us-ascii?Q?oq/b5e65EUMQr7lpWYE++wHWV2vkPKX8c9IzLzFRpSAO425zGFHlv61YCZyf?= =?us-ascii?Q?jCZS1tDzDon9QoqR1AkRfqnfbGmgMbNHm1s5wbHzeoj88EQ/4YXADAfx1GEL?= =?us-ascii?Q?bpWFEf/6BExZm4tVDR+hrgue14QvMwGe1Fga3dIXij/nZ8Omny7Gc5rGKqRt?= =?us-ascii?Q?2QvPpuI2FvAMNolIwnDBKh/MZ2pRFoD6fqRHa7OYZuLNdfBYigORTJtjhblj?= =?us-ascii?Q?5q8pR2/0P5UvdbopGwgz93c44hlKEsRuAKPd1mNTKMVdSFFi8xHyIKl3pZNT?= =?us-ascii?Q?UXvpZNBspQsomSN/SMAwGU28i0lT7MiY+ALAJR9RxNYdzi0AnJjSACWSJQrf?= =?us-ascii?Q?9apjYB26hg56Wq4KrXPcSdys7UboJ+iioviC2e8W8KQdHP5K6W3XGB35fXJF?= =?us-ascii?Q?gEhkIlG4Xq51rckgJm3gozO0Sro6Geg0iyG7Uyd/ZdkieEHaqGqmMutJKZ4K?= =?us-ascii?Q?JqG7gVMzTps+ZzwUOFaEIjyV1cvR8Ltt6QV2GUyOkuWzhNrXvzbx+8aL2uEd?= =?us-ascii?Q?rGtaxXDIoEcrei1HrspNZu0no1V1yITtLFkuPoMTltvJ6lLdx7xCuLitjEqU?= =?us-ascii?Q?bo5/5nbwOz5frm/RAWdqvmhuQjkU2vDGQ8ZtuPhRZ+rX+hvIhQliu8DgcOSI?= =?us-ascii?Q?+byuoL7XbvvwJ8bIF8Ex5uO4bKzRxFue2tD5vU+hhehtgzmTRKICL2lKn5BQ?= =?us-ascii?Q?gaX/Dpno1lHz2c1jYayUVr/1v2lfMtUB9P5oPj5FIZkmV3JL9D8IByLT53lV?= =?us-ascii?Q?Ub7WWaKDogxzDeEAFbTwWiDeWPhTAfoFuIPsFApnDOy1n+RILODRzCI4WAYD?= =?us-ascii?Q?RkYsiRUQVBnLDfps8yIGot4a/LIsvkQ52STertTvI+Bhtd6jWBTynJyxh/Dk?= =?us-ascii?Q?6TiErTajVx33IX+tUKH0L+4SIwopVNJFK8qg7dTw2fR/C4sFr9TQkbghvrv4?= =?us-ascii?Q?EPPNtpo8TQkbfjMD5KzoBrWTSj5WzD7oJBCme/2U+ostIRJ9t5jdXLJOS4Rh?= =?us-ascii?Q?KlQeebsbgp6uMK0rHW2ux8ISfnfBmFHZwLRGTG4/PkuNavKrCJSN3+2Olzt+?= =?us-ascii?Q?6sHDES3APW6+k99shHfI88AUUd0IgUvrQI0yWtPA4dseWU6cF4eFVc7J+PPT?= =?us-ascii?Q?ms8QcT2g+M+Vmm1KQ5cnP6cldeyePV0TmzKQWij/B6rv1HoR0ymwZiqo2jMR?= =?us-ascii?Q?8WbilfK65r8AxWBseiW4ReYoX/lKP6WpJ/A0U8OsZOOVlwTNp1VUpEkkUOyH?= =?us-ascii?Q?iTsFx5qCYCe0K/S5RR446abT8BWjxNcYJ4+TSinKYk1mHcFlCYwUtVIZld2p?= =?us-ascii?Q?+g=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 45b64c5b-0ffd-486a-96ae-08dbd782ac20 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2023 06:54:04.0356 (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: 8eMYNgnzhQ/d0tC5XSU4049f9lhUS+i+MF0lvbKmojx6AySuwjJZxj0Xwb1Yo62y/yEHz1e+TcEqW7hcJvN6w6zNErRqx+qDbAfB8lrcoNo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR13MB6055 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 Extract a helper function to get the pointer of 'struct nfp_net_hw' for both normal port and representor pot, this will make the operation function can be used for both type port. Signed-off-by: Chaoyong He Reviewed-by: Peng Zhang --- drivers/net/nfp/flower/nfp_flower.c | 64 ++----------------------- drivers/net/nfp/nfp_net_common.c | 74 ++++++++++++++++------------- drivers/net/nfp/nfp_net_common.h | 1 + 3 files changed, 47 insertions(+), 92 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index 246dd2d454..0727e7fd9f 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -21,62 +21,6 @@ #define CTRL_VNIC_NB_DESC 512 -static void -nfp_pf_repr_enable_queues(struct rte_eth_dev *dev) -{ - uint16_t i; - struct nfp_hw *hw; - uint64_t enabled_queues = 0; - struct nfp_flower_representor *repr; - - repr = dev->data->dev_private; - hw = &repr->app_fw_flower->pf_hw->super; - - /* Enabling the required TX queues in the device */ - for (i = 0; i < dev->data->nb_tx_queues; i++) - enabled_queues |= (1 << i); - - nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, enabled_queues); - - enabled_queues = 0; - - /* Enabling the required RX queues in the device */ - for (i = 0; i < dev->data->nb_rx_queues; i++) - enabled_queues |= (1 << i); - - nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, enabled_queues); -} - -static void -nfp_pf_repr_disable_queues(struct rte_eth_dev *dev) -{ - uint32_t update; - uint32_t new_ctrl; - struct nfp_hw *hw; - struct nfp_net_hw *net_hw; - struct nfp_flower_representor *repr; - - repr = dev->data->dev_private; - net_hw = repr->app_fw_flower->pf_hw; - hw = &net_hw->super; - - nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0); - nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0); - - new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE; - update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING | - NFP_NET_CFG_UPDATE_MSIX; - - if (hw->cap & NFP_NET_CFG_CTRL_RINGCFG) - new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG; - - /* If an error when reconfig we avoid to change hw state */ - if (nfp_reconfig(hw, new_ctrl, update) < 0) - return; - - hw->ctrl = new_ctrl; -} - int nfp_flower_pf_start(struct rte_eth_dev *dev) { @@ -93,10 +37,10 @@ nfp_flower_pf_start(struct rte_eth_dev *dev) hw = &net_hw->super; /* Disabling queues just in case... */ - nfp_pf_repr_disable_queues(dev); + nfp_net_disable_queues(dev); /* Enabling the required queues in the device */ - nfp_pf_repr_enable_queues(dev); + nfp_net_enable_queues(dev); new_ctrl = nfp_check_offloads(dev); @@ -157,7 +101,7 @@ nfp_flower_pf_stop(struct rte_eth_dev *dev) repr = dev->data->dev_private; hw = repr->app_fw_flower->pf_hw; - nfp_pf_repr_disable_queues(dev); + nfp_net_disable_queues(dev); /* Clear queues */ for (i = 0; i < dev->data->nb_tx_queues; i++) { @@ -207,7 +151,7 @@ nfp_flower_pf_close(struct rte_eth_dev *dev) * We assume that the DPDK application is stopping all the * threads/queues before calling the device close function. */ - nfp_pf_repr_disable_queues(dev); + nfp_net_disable_queues(dev); /* Clear queues */ for (i = 0; i < dev->data->nb_tx_queues; i++) { diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c index d43a071a42..1be0d7d060 100644 --- a/drivers/net/nfp/nfp_net_common.c +++ b/drivers/net/nfp/nfp_net_common.c @@ -233,6 +233,22 @@ nfp_net_mbox_reconfig(struct nfp_net_hw *net_hw, return nn_cfg_readl(&net_hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_RET); } +struct nfp_net_hw * +nfp_net_get_hw(const struct rte_eth_dev *dev) +{ + struct nfp_net_hw *hw; + + if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) { + struct nfp_flower_representor *repr; + repr = dev->data->dev_private; + hw = repr->app_fw_flower->pf_hw; + } else { + hw = dev->data->dev_private; + } + + return hw; +} + /* * Configure an Ethernet device. * @@ -252,7 +268,7 @@ nfp_net_configure(struct rte_eth_dev *dev) struct rte_eth_rxmode *rxmode; struct rte_eth_txmode *txmode; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); dev_conf = &dev->data->dev_conf; rxmode = &dev_conf->rxmode; txmode = &dev_conf->txmode; @@ -329,7 +345,7 @@ nfp_net_enable_queues(struct rte_eth_dev *dev) { struct nfp_net_hw *hw; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); nfp_enable_queues(&hw->super, dev->data->nb_rx_queues, dev->data->nb_tx_queues); @@ -340,7 +356,7 @@ nfp_net_disable_queues(struct rte_eth_dev *dev) { struct nfp_net_hw *net_hw; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); nfp_disable_queues(&net_hw->super); } @@ -367,7 +383,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev, struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 && (hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) { @@ -407,7 +423,7 @@ nfp_configure_rx_interrupt(struct rte_eth_dev *dev, return -ENOMEM; } - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); if (rte_intr_type_get(intr_handle) == RTE_INTR_HANDLE_UIO) { PMD_DRV_LOG(INFO, "VF: enabling RX interrupt with UIO"); @@ -443,7 +459,7 @@ nfp_check_offloads(struct rte_eth_dev *dev) struct nfp_net_hw *hw; struct rte_eth_conf *dev_conf; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); cap = hw->super.cap; dev_conf = &dev->data->dev_conf; @@ -510,14 +526,8 @@ nfp_net_promisc_enable(struct rte_eth_dev *dev) uint32_t new_ctrl; struct nfp_hw *hw; struct nfp_net_hw *net_hw; - struct nfp_flower_representor *repr; - if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) { - repr = dev->data->dev_private; - net_hw = repr->app_fw_flower->pf_hw; - } else { - net_hw = dev->data->dev_private; - } + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; if ((hw->cap & NFP_NET_CFG_CTRL_PROMISC) == 0) { @@ -551,7 +561,7 @@ nfp_net_promisc_disable(struct rte_eth_dev *dev) struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; if ((hw->ctrl & NFP_NET_CFG_CTRL_PROMISC) == 0) { @@ -588,7 +598,7 @@ nfp_net_link_update(struct rte_eth_dev *dev, struct rte_eth_link link; struct nfp_eth_table *nfp_eth_table; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); memset(&link, 0, sizeof(struct rte_eth_link)); @@ -654,7 +664,7 @@ nfp_net_stats_get(struct rte_eth_dev *dev, if (stats == NULL) return -EINVAL; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); memset(&nfp_dev_stats, 0, sizeof(nfp_dev_stats)); @@ -732,7 +742,7 @@ nfp_net_stats_reset(struct rte_eth_dev *dev) uint16_t i; struct nfp_net_hw *hw; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); /* Reading per RX ring stats */ for (i = 0; i < dev->data->nb_rx_queues; i++) { @@ -794,7 +804,7 @@ nfp_net_xstats_size(const struct rte_eth_dev *dev) const uint32_t size = RTE_DIM(nfp_net_xstats); /* If the device is a VF, then there will be no MAC stats */ - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); if (hw->mac_stats == NULL) { for (count = 0; count < size; count++) { if (nfp_net_xstats[count].group == NFP_XSTAT_GROUP_MAC) @@ -828,7 +838,7 @@ nfp_net_xstats_value(const struct rte_eth_dev *dev, struct nfp_net_hw *hw; struct nfp_xstat xstat; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); xstat = nfp_net_xstats[index]; if (xstat.group == NFP_XSTAT_GROUP_MAC) @@ -967,7 +977,7 @@ nfp_net_xstats_reset(struct rte_eth_dev *dev) uint32_t read_size; struct nfp_net_hw *hw; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); read_size = nfp_net_xstats_size(dev); for (id = 0; id < read_size; id++) { @@ -1015,7 +1025,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) uint16_t max_tx_desc; struct nfp_net_hw *hw; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); nfp_net_rx_desc_limits(hw, &min_rx_desc, &max_rx_desc); nfp_net_tx_desc_limits(hw, &min_tx_desc, &max_tx_desc); @@ -1242,7 +1252,7 @@ nfp_rx_queue_intr_enable(struct rte_eth_dev *dev, /* Make sure all updates are written before un-masking */ rte_wmb(); - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); nn_cfg_writeb(&hw->super, NFP_NET_CFG_ICR(base + queue_id), NFP_NET_CFG_ICR_UNMASKED); return 0; @@ -1263,7 +1273,7 @@ nfp_rx_queue_intr_disable(struct rte_eth_dev *dev, /* Make sure all updates are written before un-masking */ rte_wmb(); - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); nn_cfg_writeb(&hw->super, NFP_NET_CFG_ICR(base + queue_id), NFP_NET_CFG_ICR_RXTX); return 0; @@ -1301,7 +1311,7 @@ nfp_net_irq_unmask(struct rte_eth_dev *dev) struct nfp_net_hw *hw; struct rte_pci_device *pci_dev; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); pci_dev = RTE_ETH_DEV_TO_PCI(dev); /* Make sure all updates are written before un-masking */ @@ -1376,7 +1386,7 @@ nfp_net_dev_mtu_set(struct rte_eth_dev *dev, { struct nfp_net_hw *hw; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); /* MTU setting is forbidden if port is started */ if (dev->data->dev_started) { @@ -1412,7 +1422,7 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev, struct nfp_net_hw *net_hw; uint32_t rxvlan_ctrl = 0; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; rx_offload = dev->data->dev_conf.rxmode.offloads; new_ctrl = hw->ctrl; @@ -1462,7 +1472,7 @@ nfp_net_rss_reta_write(struct rte_eth_dev *dev, struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; if (reta_size != NFP_NET_CFG_RSS_ITBL_SZ) { @@ -1518,7 +1528,7 @@ nfp_net_reta_update(struct rte_eth_dev *dev, struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) @@ -1551,7 +1561,7 @@ nfp_net_reta_query(struct rte_eth_dev *dev, struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) @@ -1601,7 +1611,7 @@ nfp_net_rss_hash_write(struct rte_eth_dev *dev, struct nfp_net_hw *net_hw; uint32_t cfg_rss_ctrl = 0; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; /* Writing the key byte by byte */ @@ -1657,7 +1667,7 @@ nfp_net_rss_hash_update(struct rte_eth_dev *dev, struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; rss_hf = rss_conf->rss_hf; @@ -1698,7 +1708,7 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev, uint32_t cfg_rss_ctrl; struct nfp_net_hw *net_hw; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h index 829e9c5333..e242251bc2 100644 --- a/drivers/net/nfp/nfp_net_common.h +++ b/drivers/net/nfp/nfp_net_common.h @@ -237,6 +237,7 @@ void nfp_net_cfg_read_version(struct nfp_net_hw *hw); int nfp_net_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size); int nfp_repr_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); #define NFP_PRIV_TO_APP_FW_NIC(app_fw_priv)\ ((struct nfp_app_fw_nic *)app_fw_priv) -- 2.39.1