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 3082642B6F; Mon, 22 May 2023 13:40:43 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6A13642BB1; Mon, 22 May 2023 13:40:39 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2100.outbound.protection.outlook.com [40.107.236.100]) by mails.dpdk.org (Postfix) with ESMTP id C131442D39 for ; Mon, 22 May 2023 13:40:37 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K6zkAi8dMc+3nqI/ISCmQLokoBOkTSvL+LIRCkK8fSQBnGziQK1dGMYUM4wAphQKm5q9QfO/3TkD2ZOtUy+fuoDLKCQS3x16SOW4+IGXjOrOVfblFVv5ZVEiODMJdCwPXoFZoSrh5APwWnd2f+/s3jA4gCVY+RnTIJIsCN7fvDALBnW5visT8dOXDKLdIDdz7SBZu1wAuYuYUUMe5wiJyP7jyXMXGvW2fGX4zvByjoz5jcMIFkV/bnd+VHcQH6oWbow/tG5xquT+vzcpv/VQ80y4un6hOOb9cw5hHFGxFE4a241g+VDVm0k/2TAmSCl8aAEOi2sO+wuL23NDC7fM+w== 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=Qq0pFtmvnZ5ZUgpTfgb0hYjxKNwxD51OlhQ6lVSowb0=; b=PBim//TQfhtHPW6QvWqVD8FghSEnsDYHaUDYcAs5MI2w+Er0d8oqqUFabaxkn6sG9syIE9fRfg7tjnRM2E4Pa56NUyGwC2oDD+QeWgHfWTQt/TDgJb9qhwEL7bqhi2zeroXPKNxoqKtzxlGwk5d8L0X88HAtZ7w3fOvWHN1D1+UDWhO+UKC1Xl0EQ1TCbAEhJxTc83eCyXrIOSqUu9r28m9hZg0nG6xt7TW3KFzwMI9DkGU+zlQw78WT5rrmzIQIraJfe7F0hAQOhD61ko4pcO1MxZHxbbjIprD8SVD1FHyfC5uWXYofuC89xDg1SU/qu45E2WGrtX4WimZilYowIQ== 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=Qq0pFtmvnZ5ZUgpTfgb0hYjxKNwxD51OlhQ6lVSowb0=; b=Tx8wDELvZ4Pw4JR1NPmxXRNFoZat/QZn8IOyKMYRBLU6UKEOO9uZoI0BCNpFOdsooqs3avglpW+l1Zsti6j8eqWwky5/6HEG/QRLIb8aEMVCWBlfVP82Mx+00oiKJPP3S7mlb7PAz3Orap4dWBQsesH0il8cbIBJqKiQBMfg9tE= 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 SA1PR13MB5636.namprd13.prod.outlook.com (2603:10b6:806:233::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28; Mon, 22 May 2023 11:40:34 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ac2e:52b6:82ec:4994]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ac2e:52b6:82ec:4994%3]) with mapi id 15.20.6411.028; Mon, 22 May 2023 11:40:34 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH 1/2] net/nfp: align reading of version info with kernel driver Date: Mon, 22 May 2023 19:40:08 +0800 Message-Id: <20230522114009.2099371-2-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230522114009.2099371-1-chaoyong.he@corigine.com> References: <20230522114009.2099371-1-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2PR06CA0005.apcprd06.prod.outlook.com (2603:1096:4:186::12) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|SA1PR13MB5636:EE_ X-MS-Office365-Filtering-Correlation-Id: 9db4b185-992d-4722-fa28-08db5ab95adb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vnsRZKXUrKQn8u77h3brc4cXXNzI8ar3YVBXFSR++zBofU3M8xDUH4oxP8Jv/Jp/RBsE1ykCt5tqDlEsbVsfMhAQa/aiXk0MfN9ITdUY+sDDsqj9z6KDUqiWMrHUayZdOlVSTA+AAlzv7GVuyRCg8W/0c7s15GG8/rDIZa90mBNZ4J4PAwvn6y/7qA240xZHOgV2xPjrTw3Vvwjytcs64laRGliEKfsJixo8RAGVY8UaGIG/56IZvB8FzESbqaZuXvbxDInMQoewZf6bBKRRr5HCSpT0gK3TAmUWNxu8rU2XzGOn2O1JVMhtjWYfjiEh7B7bVNApdY5G08/HQPNM+2nNNhDqpNjzMzPMpHQcRhg2P+GCB7AgMtOxj5whgaGrIpeLeXb1pJRoRBSj5SLk9zeTmtqY8/FgIa+HQVCAyui1zaQv9lkiBocUpQT3isHnxsNvrBRRboAYKHe5a6KckNmbtWLAwGcGgFJoSzUppujyT8u9KyDdL2CoG3JSbNEfAQ+oOFb7CzAt0yXuzK9B3jG2VqEjF6g9m+8DEikqScO4wFKEx/Bu6mJoKwjO0PH9jEOW+WJ0QPu/DiiR460+npajXBwKDNqzj7DGXzDyqewr1fIYpyGkLGKDXp0dvyrHXvM82uLLyiFj3FeZ/lg+rWNUj/4L8fGF7kIqe9ztklE= 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:(13230028)(4636009)(39840400004)(136003)(366004)(376002)(346002)(396003)(451199021)(6666004)(86362001)(107886003)(316002)(478600001)(41300700001)(6486002)(66946007)(4326008)(66556008)(66476007)(6916009)(52116002)(38100700002)(38350700002)(8676002)(8936002)(5660300002)(83380400001)(2616005)(36756003)(44832011)(66574015)(26005)(2906002)(30864003)(186003)(1076003)(6512007)(6506007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ekhQaHU0eVRyQTNWSUdONDVkL0FJdTl3SkJxaFMzbmZYaTBPNldYY3FoTE1G?= =?utf-8?B?OWVjcVBZbXV4Q1FuazhSQTV6R09qZ1FzQUorY2lzWkFhNUJGbHFKTjBtVUhk?= =?utf-8?B?WlQvczEzeUNjRzdJMzBmOXZCUHB2NkJ4TlVLZUNFV0RsejA2a3A5cXNGdUlD?= =?utf-8?B?YzA4cTV0TkdTQjhRQ2ZYRUZJYUtmQmtCZE5waWpUQSt3R3FPbVZuWC8yK0Z0?= =?utf-8?B?ZWd0anlqKzhtd1F2bjdiOVY3b0NkQzJpVDQ2RHo2U3Q2bUlkdzNxd0YrMVJI?= =?utf-8?B?bnhySTdEL0xKS0hjWUhCRG9xTXRObG1GUlBRdm1sSEJhVllMWnNBK3V3eVVI?= =?utf-8?B?NFlHaXJIZXAvRllnblE3RHFFNkxwM2lBaV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==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9db4b185-992d-4722-fa28-08db5ab95adb X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 May 2023 11:40:34.6087 (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: wu+zFcq7pCViGuoOPN3m15Lrjwka0QU0FLadvfQtgj4YEDBRTzHWHt8+thIThBh+/bNy1+v5Nnp21E/N/S26KyL6h1mm/4ljc/OGnEAYaJE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR13MB5636 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 Align the method of reading the version information with the linux driver. This is done to make it easier to share code between the DPDK PMD and the kernel driver. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- drivers/net/nfp/flower/nfp_flower.c | 4 ++-- drivers/net/nfp/nfp_common.c | 30 +++++++++++++++++++---------- drivers/net/nfp/nfp_common.h | 21 ++------------------ drivers/net/nfp/nfp_ctrl.h | 22 +++++++++++++-------- drivers/net/nfp/nfp_ethdev.c | 10 +++++----- drivers/net/nfp/nfp_ethdev_vf.c | 10 +++++----- drivers/net/nfp/nfp_rxtx.c | 6 +++--- 7 files changed, 51 insertions(+), 52 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index 72933e55d0..778ea777dd 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -650,7 +650,7 @@ nfp_flower_init_vnic_common(struct nfp_net_hw *hw, const char *vnic_type) hw->rx_bar = pf_dev->hw_queues + rx_bar_off; /* Get some of the read-only fields from the config BAR */ - hw->ver = nn_cfg_readl(hw, NFP_NET_CFG_VERSION); + nfp_net_cfg_read_version(hw); hw->cap = nn_cfg_readl(hw, NFP_NET_CFG_CAP); hw->max_mtu = nn_cfg_readl(hw, NFP_NET_CFG_MAX_MTU); /* Set the current MTU to the maximum supported */ @@ -661,7 +661,7 @@ nfp_flower_init_vnic_common(struct nfp_net_hw *hw, const char *vnic_type) return -ENODEV; /* read the Rx offset configured from firmware */ - if (NFD_CFG_MAJOR_VERSION_of(hw->ver) < 2) + if (hw->ver.major < 2) hw->rx_offset = NFP_NET_RX_OFFSET; else hw->rx_offset = nn_cfg_readl(hw, NFP_NET_CFG_RX_OFFSET_ADDR); diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c index c9fea765a4..a9af215626 100644 --- a/drivers/net/nfp/nfp_common.c +++ b/drivers/net/nfp/nfp_common.c @@ -356,8 +356,7 @@ void nfp_net_log_device_information(const struct nfp_net_hw *hw) { PMD_INIT_LOG(INFO, "VER: %u.%u, Maximum supported MTU: %d", - NFD_CFG_MAJOR_VERSION_of(hw->ver), - NFD_CFG_MINOR_VERSION_of(hw->ver), hw->max_mtu); + hw->ver.major, hw->ver.minor, hw->max_mtu); PMD_INIT_LOG(INFO, "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", hw->cap, hw->cap & NFP_NET_CFG_CTRL_PROMISC ? "PROMISC " : "", @@ -1114,14 +1113,14 @@ nfp_net_tx_desc_limits(struct nfp_net_hw *hw, { uint16_t tx_dpp; - switch (NFD_CFG_CLASS_VER_of(hw->ver)) { + switch (hw->ver.extend) { case NFP_NET_CFG_VERSION_DP_NFD3: tx_dpp = NFD3_TX_DESC_PER_PKT; break; case NFP_NET_CFG_VERSION_DP_NFDK: - if (NFD_CFG_MAJOR_VERSION_of(hw->ver) < 5) { + if (hw->ver.major < 5) { PMD_DRV_LOG(ERR, "NFDK must use ABI 5 or newer, found: %d", - NFD_CFG_MAJOR_VERSION_of(hw->ver)); + hw->ver.major); return -EINVAL; } tx_dpp = NFDK_TX_DESC_PER_SIMPLE_PKT; @@ -1911,11 +1910,10 @@ nfp_net_set_vxlan_port(struct nfp_net_hw *hw, int nfp_net_check_dma_mask(struct nfp_net_hw *hw, char *name) { - if (NFD_CFG_CLASS_VER_of(hw->ver) == NFP_NET_CFG_VERSION_DP_NFD3 && + if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3 && rte_mem_check_dma_mask(40) != 0) { - PMD_DRV_LOG(ERR, - "The device %s can't be used: restricted dma mask to 40 bits!", - name); + PMD_DRV_LOG(ERR, "Device %s can't be used: restricted dma mask to 40 bits!", + name); return -ENODEV; } @@ -1930,7 +1928,7 @@ nfp_net_init_metadata_format(struct nfp_net_hw *hw) * single metadata if only RSS(v1) is supported by hw capability, and RSS(v2) * also indicate that we are using chained metadata. */ - if (NFD_CFG_MAJOR_VERSION_of(hw->ver) == 4) { + if (hw->ver.major == 4) { hw->meta_format = NFP_NET_METAFORMAT_CHAINED; } else if ((hw->cap & NFP_NET_CFG_CTRL_CHAIN_META) != 0) { hw->meta_format = NFP_NET_METAFORMAT_CHAINED; @@ -1944,3 +1942,15 @@ nfp_net_init_metadata_format(struct nfp_net_hw *hw) hw->meta_format = NFP_NET_METAFORMAT_SINGLE; } } + +void +nfp_net_cfg_read_version(struct nfp_net_hw *hw) +{ + union { + uint32_t whole; + struct nfp_net_fw_ver split; + } version; + + version.whole = nn_cfg_readl(hw, NFP_NET_CFG_VERSION); + hw->ver = version.split; +} diff --git a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_common.h index 47df0510c5..424b18b0ad 100644 --- a/drivers/net/nfp/nfp_common.h +++ b/drivers/net/nfp/nfp_common.h @@ -80,24 +80,6 @@ struct nfp_net_adapter; #define NFP_NET_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */ #define NFP_NET_LINK_UP_CHECK_TIMEOUT 1000 /* ms */ -/* Version number helper defines */ -#define NFD_CFG_CLASS_VER_msk 0xff -#define NFD_CFG_CLASS_VER_shf 24 -#define NFD_CFG_CLASS_VER(x) (((x) & 0xff) << 24) -#define NFD_CFG_CLASS_VER_of(x) (((x) >> 24) & 0xff) -#define NFD_CFG_CLASS_TYPE_msk 0xff -#define NFD_CFG_CLASS_TYPE_shf 16 -#define NFD_CFG_CLASS_TYPE(x) (((x) & 0xff) << 16) -#define NFD_CFG_CLASS_TYPE_of(x) (((x) >> 16) & 0xff) -#define NFD_CFG_MAJOR_VERSION_msk 0xff -#define NFD_CFG_MAJOR_VERSION_shf 8 -#define NFD_CFG_MAJOR_VERSION(x) (((x) & 0xff) << 8) -#define NFD_CFG_MAJOR_VERSION_of(x) (((x) >> 8) & 0xff) -#define NFD_CFG_MINOR_VERSION_msk 0xff -#define NFD_CFG_MINOR_VERSION_shf 0 -#define NFD_CFG_MINOR_VERSION(x) (((x) & 0xff) << 0) -#define NFD_CFG_MINOR_VERSION_of(x) (((x) >> 0) & 0xff) - /* Number of supported physical ports */ #define NFP_MAX_PHYPORTS 12 @@ -196,7 +178,7 @@ struct nfp_net_hw { struct rte_eth_dev *eth_dev; /* Info from the firmware */ - uint32_t ver; + struct nfp_net_fw_ver ver; uint32_t cap; uint32_t max_mtu; uint32_t mtu; @@ -490,6 +472,7 @@ int nfp_net_tx_desc_limits(struct nfp_net_hw *hw, uint16_t *max_tx_desc); int nfp_net_check_dma_mask(struct nfp_net_hw *hw, char *name); void nfp_net_init_metadata_format(struct nfp_net_hw *hw); +void nfp_net_cfg_read_version(struct nfp_net_hw *hw); #define NFP_NET_DEV_PRIVATE_TO_HW(adapter)\ (&((struct nfp_net_adapter *)adapter)->hw) diff --git a/drivers/net/nfp/nfp_ctrl.h b/drivers/net/nfp/nfp_ctrl.h index bca31ac311..ff2245dfff 100644 --- a/drivers/net/nfp/nfp_ctrl.h +++ b/drivers/net/nfp/nfp_ctrl.h @@ -130,6 +130,20 @@ #define NFP_NET_CFG_CTRL_CHAIN_META (NFP_NET_CFG_CTRL_RSS2 | \ NFP_NET_CFG_CTRL_CSUM_COMPLETE) + +/* Version number helper defines */ +struct nfp_net_fw_ver { + uint8_t minor; + uint8_t major; + uint8_t class; + /** + * This byte can be extended for more use. + * BIT0: NFD dp type, refer NFP_NET_CFG_VERSION_DP_NFDx + * BIT[7:1]: reserved + */ + uint8_t extend; +}; + /* * Read-only words (0x0030 - 0x0050): * @NFP_NET_CFG_VERSION: Firmware version number @@ -147,14 +161,6 @@ #define NFP_NET_CFG_VERSION 0x0030 #define NFP_NET_CFG_VERSION_DP_NFD3 0 #define NFP_NET_CFG_VERSION_DP_NFDK 1 -#define NFP_NET_CFG_VERSION_RESERVED_MASK (0xff << 24) -#define NFP_NET_CFG_VERSION_CLASS_MASK (0xff << 16) -#define NFP_NET_CFG_VERSION_CLASS(x) (((x) & 0xff) << 16) -#define NFP_NET_CFG_VERSION_CLASS_GENERIC 0 -#define NFP_NET_CFG_VERSION_MAJOR_MASK (0xff << 8) -#define NFP_NET_CFG_VERSION_MAJOR(x) (((x) & 0xff) << 8) -#define NFP_NET_CFG_VERSION_MINOR_MASK (0xff << 0) -#define NFP_NET_CFG_VERSION_MINOR(x) (((x) & 0xff) << 0) #define NFP_NET_CFG_STS 0x0034 #define NFP_NET_CFG_STS_LINK (0x1 << 0) /* Link up or down */ /* Link rate */ diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 722ec17dce..0b2dd7801b 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -466,14 +466,14 @@ static const struct eth_dev_ops nfp_net_eth_dev_ops = { static inline int nfp_net_ethdev_ops_mount(struct nfp_net_hw *hw, struct rte_eth_dev *eth_dev) { - switch (NFD_CFG_CLASS_VER_of(hw->ver)) { + switch (hw->ver.extend) { case NFP_NET_CFG_VERSION_DP_NFD3: eth_dev->tx_pkt_burst = &nfp_net_nfd3_xmit_pkts; break; case NFP_NET_CFG_VERSION_DP_NFDK: - if (NFD_CFG_MAJOR_VERSION_of(hw->ver) < 5) { + if (hw->ver.major < 5) { PMD_DRV_LOG(ERR, "NFDK must use ABI 5 or newer, found: %d", - NFD_CFG_MAJOR_VERSION_of(hw->ver)); + hw->ver.major); return -EINVAL; } eth_dev->tx_pkt_burst = &nfp_net_nfdk_xmit_pkts; @@ -571,7 +571,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", hw->mac_stats); - hw->ver = nn_cfg_readl(hw, NFP_NET_CFG_VERSION); + nfp_net_cfg_read_version(hw); if (nfp_net_check_dma_mask(hw, pci_dev->name) != 0) return -ENODEV; @@ -629,7 +629,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev) nfp_net_init_metadata_format(hw); - if (NFD_CFG_MAJOR_VERSION_of(hw->ver) < 2) + if (hw->ver.major < 2) hw->rx_offset = NFP_NET_RX_OFFSET; else hw->rx_offset = nn_cfg_readl(hw, NFP_NET_CFG_RX_OFFSET_ADDR); diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c index ce55e3b728..cf3548e63a 100644 --- a/drivers/net/nfp/nfp_ethdev_vf.c +++ b/drivers/net/nfp/nfp_ethdev_vf.c @@ -246,14 +246,14 @@ static const struct eth_dev_ops nfp_netvf_eth_dev_ops = { static inline int nfp_netvf_ethdev_ops_mount(struct nfp_net_hw *hw, struct rte_eth_dev *eth_dev) { - switch (NFD_CFG_CLASS_VER_of(hw->ver)) { + switch (hw->ver.extend) { case NFP_NET_CFG_VERSION_DP_NFD3: eth_dev->tx_pkt_burst = &nfp_net_nfd3_xmit_pkts; break; case NFP_NET_CFG_VERSION_DP_NFDK: - if (NFD_CFG_MAJOR_VERSION_of(hw->ver) < 5) { + if (hw->ver.major < 5) { PMD_DRV_LOG(ERR, "NFDK must use ABI 5 or newer, found: %d", - NFD_CFG_MAJOR_VERSION_of(hw->ver)); + hw->ver.major); return -EINVAL; } eth_dev->tx_pkt_burst = &nfp_net_nfdk_xmit_pkts; @@ -298,7 +298,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev) PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->ctrl_bar); - hw->ver = nn_cfg_readl(hw, NFP_NET_CFG_VERSION); + nfp_net_cfg_read_version(hw); if (nfp_net_check_dma_mask(hw, pci_dev->name) != 0) return -ENODEV; @@ -380,7 +380,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev) nfp_net_init_metadata_format(hw); - if (NFD_CFG_MAJOR_VERSION_of(hw->ver) < 2) + if (hw->ver.major < 2) hw->rx_offset = NFP_NET_RX_OFFSET; else hw->rx_offset = nn_cfg_readl(hw, NFP_NET_CFG_RX_OFFSET_ADDR); diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index 3c78557221..478752fa14 100644 --- a/drivers/net/nfp/nfp_rxtx.c +++ b/drivers/net/nfp/nfp_rxtx.c @@ -764,14 +764,14 @@ nfp_net_tx_queue_setup(struct rte_eth_dev *dev, hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - switch (NFD_CFG_CLASS_VER_of(hw->ver)) { + switch (hw->ver.extend) { case NFP_NET_CFG_VERSION_DP_NFD3: return nfp_net_nfd3_tx_queue_setup(dev, queue_idx, nb_desc, socket_id, tx_conf); case NFP_NET_CFG_VERSION_DP_NFDK: - if (NFD_CFG_MAJOR_VERSION_of(hw->ver) < 5) { + if (hw->ver.major < 5) { PMD_DRV_LOG(ERR, "NFDK must use ABI 5 or newer, found: %d", - NFD_CFG_MAJOR_VERSION_of(hw->ver)); + hw->ver.major); return -EINVAL; } return nfp_net_nfdk_tx_queue_setup(dev, queue_idx, -- 2.39.1