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 D800A42C45; Wed, 7 Jun 2023 03:58:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D456942D17; Wed, 7 Jun 2023 03:57:57 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2100.outbound.protection.outlook.com [40.107.220.100]) by mails.dpdk.org (Postfix) with ESMTP id 5FE51427F5 for ; Wed, 7 Jun 2023 03:57:56 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eeNPhOkLbWnj7L6Euri5Faup2cgT82DuzFJUsbdPy5bmwwEJFzW5SKVWgDeq0lydNyrUrHDlQ64X3fq9R+HoSDyZLw+0SvwyQ+L9xTxGflrH9TFz8jwPkbaU9ip7mUrRSOJQxKCBjbPBOO+YT+jg/LsVjI0TfJUGj2lPYMV62anFEe5aix1xiadqc9Rhj+MeBTj/XPORLey5JNlxOd4RnVZgb12HUfT57qZk1z+Ax8N+vPYA6f8YBbv5kewQbFTvSV7T3zOGJG2CqHRcqtY0T7HRIJsl+zcNJBDYCf7Ib0qsTy1UTR8Yb87xpxyCMjvCTS05GxVXYyWHkzMf6BgpaQ== 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=4bjORmnstwaFsuh6VHph0cRR8KcG9UV1xhjdnNyjgjM=; b=ZXzVSf94A3nCEim5AIHSxTMxtAxdC1g63q8pHmrNVh069p6Pg/ErK8lcF14S+0cK19F6Zkp859LeM/Z9HpYLCTGEC6KxteUwXo55A5ztVtwdgCHHgpTzaEt/JC6M+HFL+IQwMNrCbynJHyWBaXraP7hCxd0/So1Ci7NaUfUNuleySHlHYpP5ttX78CJwPlVqlOpgCeMhNtpVfVnltOpbHoe/g+5ek3myKUyWyd76SWlD3J2svzdVLxDps/upfbTfRlqtYqdx5ohiBgtqLyUUkcfutOQEnrg5llZE6w5XQmLzTLpyFGy+gyeUrw9Y1dUtU4jAskWxswG04tvCej774A== 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=4bjORmnstwaFsuh6VHph0cRR8KcG9UV1xhjdnNyjgjM=; b=SGCMCgHLoKcBlJxAcKBRbWVzt1h6DS7b6+2yZO/Nu1v6xksI61AjTJKF94kKX07q7JedZNso/tK2C//TxyUR0D3Jpe0LQPi0MJkIhhmmMLyPia5nqMap8EFX3uXw+JtyckWUaWFzjYTbqVC8mMYeB5xvZ6+g36bQa2IjPGeds9E= 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 PH7PR13MB5453.namprd13.prod.outlook.com (2603:10b6:510:138::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Wed, 7 Jun 2023 01:57:54 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::d2cb:a650:e1ce:2174]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::d2cb:a650:e1ce:2174%3]) with mapi id 15.20.6455.030; Wed, 7 Jun 2023 01:57:54 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH 02/10] net/nfp: add a check function for the NFD version Date: Wed, 7 Jun 2023 09:57:01 +0800 Message-Id: <20230607015709.336420-3-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230607015709.336420-1-chaoyong.he@corigine.com> References: <20230607015709.336420-1-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SG2PR02CA0131.apcprd02.prod.outlook.com (2603:1096:4:188::6) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|PH7PR13MB5453:EE_ X-MS-Office365-Filtering-Correlation-Id: 2b30fdd2-0372-4fac-c417-08db66fa9bb1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ewy94DU2uNodMx+1buetO0uNTliM/npTswrvd1+oZk29IQ81toes6wy9+od2y27DkbEkxOII2b15uRuTjJDQYXNKZBjijifjROMseopMKCXLmyf+cT92c9sllVBtatia//1H6ZASX/WUF8cyoAvf+/vJy4M2z0H7gknhHBFZISN5wqMugafKATEilQGcl8BZ4C8dZkxeKmSIQK7HdQoPRVMDmYNstU5moZbUqsaH0cVMmfTxNTM2QSlLYiDsVYfh0be076JgW+QtkgeHtG2/jZzwznSWcCXuAjsg6IIMRZnVb6GuuLUP71i+ToYGbbGXWptIanv1oYqHcZhD39DzVp4cMk1kV/n9EEcoEq3MYS3I+ZzvGEIoOfiePffYccojCUPhulhYc3SEAN6V6cZl0g98JaH4ehf82iYK+by1b9JmFDmQ1M27aeNzM8oMLzHGc9ifN5Xr5wql9XbZ+ya4Dy5AdUyclLiGs8f4qL+zCvFhPt9TWgVyYLU6q8pjpml7LwXiZipfAthFXcQhJKxVpwjJxNkgWQy1Jq3bhItVQ1EaqpJ9XIEU/9Hd3ppCLyPHJviWBklyW8Q87RlnMNMrGvtHpdgPlDHwaJSNFoY1QQ0JdFJyTQclYCBEPyNhGjR0 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)(346002)(396003)(376002)(136003)(366004)(39840400004)(451199021)(107886003)(1076003)(6506007)(26005)(6512007)(36756003)(83380400001)(38350700002)(86362001)(38100700002)(186003)(2616005)(8676002)(4326008)(41300700001)(44832011)(6916009)(478600001)(66946007)(66476007)(2906002)(316002)(8936002)(5660300002)(6486002)(52116002)(66556008)(6666004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?VWNLcXJHWE1XdnRBcjlzZmZ1RFlDb3ZKeER6akFIVXRhb3M0bUJUbW1XY2VX?= =?utf-8?B?Y3ZYUGZHc0hBdzJSOG5xQzdjaU96NkVNTjVVeklXYVBTZC9vRXZyVnhNblVn?= =?utf-8?B?VmlIRzV4aHpxcEpnTWJxRGgrVWdJOEVHcEFETDVhcmhwZWk5clFGajB1VmxT?= =?utf-8?B?bGtwMTlZWEpjbjFBSlR5Nmx2a1RLZWQ2aGFOMTlqNnR6UTFLNUMwaE1INnBl?= =?utf-8?B?YWhOWnI1a3VXMDJqdDdKQ2dLKytQc211SWttRzE2VmlmUTlIRjN4ZUVZYjhN?= =?utf-8?B?YS8rQWV2UGRLN1FhSm1hLzIrT3pqaDE0R2J2czdOOTFYR08zZ0x6Q1cwVERo?= =?utf-8?B?d0luQzJBdm1tWWc0eW8zVlpJdVdqM1lVK0k4SHYyV3U0T09PM3NNVVhRNExI?= =?utf-8?B?T1lwZm5qaEhldUtwVHFkTzd2SFFkWjdFNCtENTY3UUxnd21ja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b1 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2023 01:57:54.5302 (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: VQZB5hX7r+vMeynMEuNzMUmBQytfD4nZ6xBpiOR9EYFvBdSezCr845EF98wDY0+L/QGk5DUNAjbHDR5jWb8Wsfp5W2ERdyMducB19bFM/kY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB5453 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 Add a check function for the NFD version, this will make the logics which using this version free from validaty check, thus simplify the driver. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- drivers/net/nfp/flower/nfp_flower.c | 3 +++ drivers/net/nfp/nfp_common.c | 37 ++++++++++++++++++----------- drivers/net/nfp/nfp_common.h | 1 + drivers/net/nfp/nfp_ethdev.c | 35 +++++++++------------------ drivers/net/nfp/nfp_ethdev_vf.c | 32 ++++++++----------------- drivers/net/nfp/nfp_rxtx.c | 14 ++--------- 6 files changed, 50 insertions(+), 72 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index c5cc537790..afb4e5b344 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -649,6 +649,9 @@ nfp_flower_init_vnic_common(struct nfp_net_hw *hw, const char *vnic_type) /* Get some of the read-only fields from the config BAR */ nfp_net_cfg_read_version(hw); + if (!nfp_net_is_valid_nfd_version(hw->ver)) + return -EINVAL; + 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 */ diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c index 497128f6a6..08f9529ead 100644 --- a/drivers/net/nfp/nfp_common.c +++ b/drivers/net/nfp/nfp_common.c @@ -1162,22 +1162,10 @@ nfp_net_tx_desc_limits(struct nfp_net_hw *hw, { uint16_t tx_dpp; - switch (hw->ver.extend) { - case NFP_NET_CFG_VERSION_DP_NFD3: + if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3) tx_dpp = NFD3_TX_DESC_PER_PKT; - break; - case NFP_NET_CFG_VERSION_DP_NFDK: - if (hw->ver.major < 5) { - PMD_DRV_LOG(ERR, "NFDK must use ABI 5 or newer, found: %d", - hw->ver.major); - return -EINVAL; - } + else tx_dpp = NFDK_TX_DESC_PER_SIMPLE_PKT; - break; - default: - PMD_DRV_LOG(ERR, "The version of firmware is not correct."); - return -EINVAL; - } *max_tx_desc = NFP_NET_MAX_TX_DESC / tx_dpp; @@ -2106,3 +2094,24 @@ nfp_repr_firmware_version_get(struct rte_eth_dev *dev, return 0; } + +bool +nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version) +{ + uint8_t nfd_version = version.extend; + + if (nfd_version == NFP_NET_CFG_VERSION_DP_NFD3) + return true; + + if (nfd_version == NFP_NET_CFG_VERSION_DP_NFDK) { + if (version.major < 5) { + PMD_INIT_LOG(ERR, "NFDK must use ABI 5 or newer, found: %d", + version.major); + return false; + } + + return true; + } + + return false; +} diff --git a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_common.h index 2281445861..acb34535c5 100644 --- a/drivers/net/nfp/nfp_common.h +++ b/drivers/net/nfp/nfp_common.h @@ -444,6 +444,7 @@ void nfp_net_init_metadata_format(struct nfp_net_hw *hw); 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); #define NFP_NET_DEV_PRIVATE_TO_HW(adapter)\ (&((struct nfp_net_adapter *)adapter)->hw) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index e84d2ac82e..0ccb543f14 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -474,31 +474,18 @@ static const struct eth_dev_ops nfp_net_eth_dev_ops = { .fw_version_get = nfp_net_firmware_version_get, }; -static inline int -nfp_net_ethdev_ops_mount(struct nfp_net_hw *hw, struct rte_eth_dev *eth_dev) +static inline void +nfp_net_ethdev_ops_mount(struct nfp_net_hw *hw, + struct rte_eth_dev *eth_dev) { - 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 (hw->ver.major < 5) { - PMD_DRV_LOG(ERR, "NFDK must use ABI 5 or newer, found: %d", - hw->ver.major); - return -EINVAL; - } - eth_dev->tx_pkt_burst = &nfp_net_nfdk_xmit_pkts; - break; - default: - PMD_DRV_LOG(ERR, "The version of firmware is not correct."); - return -EINVAL; - } + if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3) + eth_dev->tx_pkt_burst = nfp_net_nfd3_xmit_pkts; + else + eth_dev->tx_pkt_burst = nfp_net_nfdk_xmit_pkts; eth_dev->dev_ops = &nfp_net_eth_dev_ops; eth_dev->rx_queue_count = nfp_net_rx_queue_count; eth_dev->rx_pkt_burst = &nfp_net_recv_pkts; - - return 0; } static int @@ -583,12 +570,13 @@ nfp_net_init(struct rte_eth_dev *eth_dev) PMD_INIT_LOG(DEBUG, "MAC stats: %p", hw->mac_stats); 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) return -ENODEV; - if (nfp_net_ethdev_ops_mount(hw, eth_dev)) - return -EINVAL; + nfp_net_ethdev_ops_mount(hw, eth_dev); hw->max_rx_queues = nn_cfg_readl(hw, NFP_NET_CFG_MAX_RXRINGS); hw->max_tx_queues = nn_cfg_readl(hw, NFP_NET_CFG_MAX_TXRINGS); @@ -1133,8 +1121,7 @@ nfp_secondary_init_app_fw_nic(struct rte_pci_device *pci_dev, eth_dev->process_private = cpp; hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); - if (nfp_net_ethdev_ops_mount(hw, eth_dev)) - return -EINVAL; + nfp_net_ethdev_ops_mount(hw, eth_dev); rte_eth_dev_probing_finish(eth_dev); } diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c index 71f5020ecd..f971bb8903 100644 --- a/drivers/net/nfp/nfp_ethdev_vf.c +++ b/drivers/net/nfp/nfp_ethdev_vf.c @@ -244,31 +244,18 @@ static const struct eth_dev_ops nfp_netvf_eth_dev_ops = { .fw_version_get = nfp_net_firmware_version_get, }; -static inline int -nfp_netvf_ethdev_ops_mount(struct nfp_net_hw *hw, struct rte_eth_dev *eth_dev) +static inline void +nfp_netvf_ethdev_ops_mount(struct nfp_net_hw *hw, + struct rte_eth_dev *eth_dev) { - 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 (hw->ver.major < 5) { - PMD_DRV_LOG(ERR, "NFDK must use ABI 5 or newer, found: %d", - hw->ver.major); - return -EINVAL; - } - eth_dev->tx_pkt_burst = &nfp_net_nfdk_xmit_pkts; - break; - default: - PMD_DRV_LOG(ERR, "The version of firmware is not correct."); - return -EINVAL; - } + if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3) + eth_dev->tx_pkt_burst = nfp_net_nfd3_xmit_pkts; + else + eth_dev->tx_pkt_burst = nfp_net_nfdk_xmit_pkts; eth_dev->dev_ops = &nfp_netvf_eth_dev_ops; eth_dev->rx_queue_count = nfp_net_rx_queue_count; eth_dev->rx_pkt_burst = &nfp_net_recv_pkts; - - return 0; } static int @@ -300,12 +287,13 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev) PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->ctrl_bar); 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) return -ENODEV; - if (nfp_netvf_ethdev_ops_mount(hw, eth_dev)) - return -EINVAL; + nfp_netvf_ethdev_ops_mount(hw, eth_dev); /* For secondary processes, the primary has done all the work */ if (rte_eal_process_type() != RTE_PROC_PRIMARY) diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index 0ac9d6db03..ce9a07309e 100644 --- a/drivers/net/nfp/nfp_rxtx.c +++ b/drivers/net/nfp/nfp_rxtx.c @@ -889,20 +889,10 @@ nfp_net_tx_queue_setup(struct rte_eth_dev *dev, hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - switch (hw->ver.extend) { - case NFP_NET_CFG_VERSION_DP_NFD3: + if (hw->ver.extend == 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 (hw->ver.major < 5) { - PMD_DRV_LOG(ERR, "NFDK must use ABI 5 or newer, found: %d", - hw->ver.major); - return -EINVAL; - } + else return nfp_net_nfdk_tx_queue_setup(dev, queue_idx, nb_desc, socket_id, tx_conf); - default: - PMD_DRV_LOG(ERR, "The version of firmware is not correct."); - return -EINVAL; - } } -- 2.39.1