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 49DB843220; Sat, 28 Oct 2023 08:17:48 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 86EAF40E2D; Sat, 28 Oct 2023 08:16:50 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2091.outbound.protection.outlook.com [40.107.92.91]) by mails.dpdk.org (Postfix) with ESMTP id 15BDB40A7A for ; Sat, 28 Oct 2023 08:16:48 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D+ecey2jeW71M02C/oYEtZr5Jn+8Kn2Q6iByd0phXipKo/5gdr5mUBxHZ+dvJnO53XiBMsVZ0TGbabjIOevCvRS04se65HGlEL8aoGE9WfVQwNLbS9CeFaC8wk4QMlnAA8IMY/+p3TELxFTFeriT3how6SJhi9YBCnX/LIuuieJaIRpo+HEmRPFOr+T+ngDXIFNaZj9bzhumUqVXVSIj8U4MWPORtZ4bgs+1FEEFR7IjP/P4o8X6iiDULzKfgiSe/yi89whIYMXoC22LlC7W5mPwAoES+femzCSkeJZAAZ/5mXbAXTZX5tjAD0aBCAYhxHELK9YlagMyztZ3AflTPw== 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=PQigPAiWim0+bmcoIU2urP+6uWNTejjBtHXylQfT7Do=; b=RSJ8IULWhBhy/nYVtAe0KG2Rk+U3+lW1tES2a6E4uTCWOOdNArziUY2ZjpodB8RDdVQUyTgbmCwckKkRJUsrDLi7/3KMPlDLwPfQAqcXN0Xn6Rnv5RtIvc065jNFjeE0B/DqYp8v0EFwyiCf/ADc+8XXEMGL5oWoTH6EbZm6eECyiHyq0puLNb6xR7LhZKPgaXUnAsCLvP5EFtxyVLMw8sL1k/u3NxkKaJfckEUeswh0nQGva+VB+Uz99AIpUphWEOPdvI6TZVmc1WEw/D0HbKnfyy2xe75er/IXewMbdk4dx6PPMiv0umgAyV+ZK4ea1Jbke/zp0Xmqqi5MjFYKxw== 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=PQigPAiWim0+bmcoIU2urP+6uWNTejjBtHXylQfT7Do=; b=aGrV/sVivSGD+U5Kg6OOsmWrOYTVekjTxsBhhApncrEDVAlfqqzRM9qGOkjeYhYM1hFpCAlMkV6MbS2mltfSZC/bXzWlvKW5snqQZoJNohh1tz63XOHSAxX0MLSMwV2+GhlEM8oJZACJYhOOxaJgfxNfN3SOUOZbb0hIku3xJEk= 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 PH7PR13MB6268.namprd13.prod.outlook.com (2603:10b6:510:24f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.22; Sat, 28 Oct 2023 06:16:45 +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:16:45 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He , Peng Zhang Subject: [PATCH 10/11] net/nfp: extract a helper function Date: Sat, 28 Oct 2023 14:15:57 +0800 Message-Id: <20231028061558.1842855-11-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231028061558.1842855-1-chaoyong.he@corigine.com> References: <20231028061558.1842855-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SJ0PR03CA0246.namprd03.prod.outlook.com (2603:10b6:a03:3a0::11) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|PH7PR13MB6268:EE_ X-MS-Office365-Filtering-Correlation-Id: 800e64e5-8be9-4a5b-06a2-08dbd77d75a4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: odswahzc4aqqIPRzgEVRJBmwAyoy1fPVC4zH0YmiTjb1WSKaIwpzpeLor08Jd5HcaT5wW0Mi3RXr2zti7UdRAjpl9+Aranw21PK9qxK3b3SBrdG1YUlA6dS70FvmEu33MLv2XWbzJjxb0+KHmcXe1VS4UAqDQ5WBa0EWB7GK4CAmB9kOdT6x5dKtpdwgrNbKz54Kd4w5qUdsKtdy4IrnDjnl/QbFscEkgtEYXQgOGpSjwe3/t+SHsQGC4VbW6SZvHDrZ8gYSOM8fOrU/VHQmXeZZ6o6MZ4sPyov1HpYNvWFyxFodkH/JUut3LH4p4IxArWbibkVt0N7DsnaDVFi55S+8vCh1GA0alG1kzqxd0VVjg+TSdHVt/rbO9A0zP4HKifb9OLZr7RrJlpV1WeU4Kg7s94yhuTFDfaGV8tWaLlQE5NF6mtzbaId7+/38whAmQ6QOFDvMOt9Y98NWIi9npEP+Tm73H4D9cCP6CuIAl1PIS7MKcLGQ1rrCkp8J5FrHDWPVP5yDRnKiz7o4XEvOpEjLCLZ7Gyy5lpZ88D5R3+d9oBpmHETeutAEzNxmON/qeo4GbKZBO3fly3rSC6DwxAPlDPAP7ZxL3Zptq94o+jYpbUiKmO0GaEoxB1khTA5WY4whX5KjBezqs0lJl2t5XU9ZytSxXmuQ2ZrWxGD2qxA= 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)(396003)(39830400003)(366004)(346002)(376002)(136003)(230922051799003)(186009)(1800799009)(451199024)(64100799003)(2906002)(38100700002)(30864003)(83380400001)(1076003)(107886003)(5660300002)(2616005)(86362001)(6512007)(41300700001)(44832011)(36756003)(38350700005)(66476007)(316002)(6916009)(66946007)(54906003)(66556008)(52116002)(6666004)(6506007)(6486002)(8676002)(26005)(478600001)(4326008)(8936002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?33MXvIu22r2e4poYokgFl2NKzjBb2kVosO5leTRM2hm9LOLvM0sJjp0v6Gjz?= =?us-ascii?Q?3iGXL0BidvBDjiLF1nJVJ9v/i70+qWk3EewV1ikO3f5Mqsdlkmg59v6d24j9?= =?us-ascii?Q?y2BVV4506F2GczIyYJUboZhpLdWvHjXox/DLWsinBgY1Rqj/iirOdH/8pHt5?= =?us-ascii?Q?sfly+Rpo1Z2f9V5fl4+nI0YQFzEgKrH+JUUFu+UEUQvizCdp9+h+AnakfQt3?= =?us-ascii?Q?BOWxItqWOZhrMKPmTu/aXTjrvd+7Vb1zTY6F+V3pRBP+z4vgL8brWIWFJPl0?= =?us-ascii?Q?Y0zloQ66kWrIpmVgeF9J+jSkCryTuHdPrHwilk/SmMEQdsHgZRtY77MX1IWy?= =?us-ascii?Q?lCSKh9uJAjGFDjIMHUD1TCRj+NWxsluHyfFr4KM9eJeDMlE1Iw1OuvNJdOp8?= =?us-ascii?Q?uWwxLoi6fCgvHgQCPPvkN0rNUurXRO1y+f6OQ3wx4/ufW5hcH4pHmyKwmZvZ?= =?us-ascii?Q?yWT4xHCimPGQn2WD2vOokrXMsS9BMBdPYc0QzY2Yc1if7K67sYAXCPrrGZCP?= =?us-ascii?Q?IzkCbIZlvVqiwS1zL+1Cl+xUUQ46FoCtWW6Drh29nmv+7FXPDi4YoLVAyKAg?= =?us-ascii?Q?MLcb/LJW/Hw4JqsbtjhjPLf+s2wcymXRaEyvfTdnxEU1fqy18fE2ILgyVm4N?= =?us-ascii?Q?KTke/BsAMOGkzxg+KPp0gD+bMn4I7UceJBmcBIjE7dgseGUWAQz5NKR4qYJ8?= =?us-ascii?Q?fY9ZYpJZct6Scdsw1jEsTr7ALZwnxxLFpXPC7LIYdfqPl8vfVdvgmjgEfhH4?= =?us-ascii?Q?hFCR3IGnuXrIDgiP2GbbOolEXdaHCCfZ2FMJ+iLz9M6WW3FPeAGf/Q33jETW?= =?us-ascii?Q?CCgiunHHzRLMHX7iC15VckmkfXyKYZ0ON5fL2u9w5mfAnVjKWv32IS7Q9/uj?= =?us-ascii?Q?o1Tr2m8XH1X1UR2wYUB7SftB4LLp15m5myhC0xtIy4vMu55hi0w3bjsoDnGe?= =?us-ascii?Q?F/UxYZcuBcwNvw6WlF8ICwz5uWe+QJwGvTY0gf4jdHo9oRl0FNZd/ZJndti8?= =?us-ascii?Q?zYGoXSWTWZJDiIFiHTEOIdX3jjeVQ/UXD4aJbQ01yDxPFeArOYMzckuIiFU8?= =?us-ascii?Q?j0Kz/ZgqoOE7sW8v8gOVQ9aR9cQvMa73vnvKEr3/1c1wCXKYacS8FgEn/yPP?= =?us-ascii?Q?EPJQn/27z2MtjDFDR6wf2wvx/DYNrZveNvNmAJHtY5rvfHsQWYjFvPFWFOMk?= =?us-ascii?Q?7HD5eo2+OAn9SgFgT7aRHyPOJU/7cC85IgZhKV5Xg01GTWYvNMg1chccWc6b?= =?us-ascii?Q?3j4K2jeVRB9/DmXOUgipTXqhVxYnvEnjqDuvKYeq4UGkgBU5wFNZ6YMLRisb?= =?us-ascii?Q?oGFLI8BYZcJXeJE7cc2/lJSg9IX9cUnhIpHpmTQIuERrjOSbozOXhpkDMAch?= =?us-ascii?Q?SdW5VPRU1azUPhRGIlnk9wi/5g2EHIti4Lh4emWnE4yWLXSjPpOzpzU+Kl7p?= =?us-ascii?Q?6a+9V0+mSehf/ke8ETKtxVXJWki4OOTDPf4LL4mVCq+A/TbRPoe49iJeTXgu?= =?us-ascii?Q?OI3yFF1Ni3WUFTahJ0zzG8EfBgqPj7h8VWFB6TOIE+5In3P2Jr/7c+6uynhM?= =?us-ascii?Q?fvxDDcJ3xZzbYd46q3CqQPWIc7c8+Rm9pC6g7dT0ObXpbOfoJFeuzeb/Zbno?= =?us-ascii?Q?mA=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 800e64e5-8be9-4a5b-06a2-08dbd77d75a4 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:16:45.0627 (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: EVxeWVcy83Vx54zCBrwInXa4LMsc0kZ1/O5zSP8CyIWK/8OXeN9MymnO3k9qeSK9NWK4G9FMtAwmvWq494dgWEd0qDffMSWC9XbpZxF3PN0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB6268 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 e3c3fa9985..6abd91965c 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