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 5D617430EF; Thu, 24 Aug 2023 13:13:51 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EB4EA432B3; Thu, 24 Aug 2023 13:11:29 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2135.outbound.protection.outlook.com [40.107.93.135]) by mails.dpdk.org (Postfix) with ESMTP id BF4904327D for ; Thu, 24 Aug 2023 13:11:27 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Su3n80mjx+tiCuqmdJmcQ9ASRcMjYAoY4ghsnSunaWCcg/aB5AvM69FmeB9NRWD1pR7WeDuNZX0JcdhcDKSs6pwbJw01/BpeKqSR7hiTUjOlKm/UTs5JSeYdtQ6Dxo/uOVcyS0dvHJ+dHi6OFTMPhiTDHYbsXAfCLIz/hQv9QN49DoUfGDd4Tz98cIBW5QzAoG93J87JofcqTXPG78rZS5HfMC/ymoIl62TTMZcUAFRMhBv2WQtTNKBAPar46Y0JEn+31Dp0H0XGSyS30/jp2Wvv+EWy+xYveVNvub6AvvkD9GQlJIRjwRsudfrsuGnesDZsNTO5b5gDBEwCf0bI6A== 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=a5yHR0shQCwWitEv0o8kfjuogvwPSxeofUrE/ZqUHwc=; b=a0FcExjAsgndbvda/WmhJtIeYWtsKzNpHN4EtHil64CI75x9mce3rdz+5GUA5uZLDu3OpA5O+bZfeSkNP844V2DBo+DOrvJAaHmmDZTRZqq+BNwgjZhGzqmvurspMwVh4yXj5wJlIqmlZdB5GyXuYVgIBzu/VVF6SCzcBxBG360vPdTJcawphNxpNYGh31QLNg3fotffahIf7hTfkGfnhFMjyee1FM6m6yGYjvhvdqP94W5wMp4Ib03tXpnGgwWtRCiz83/CrcjaT36JTgUa5d+W9h6GLnW8GKVeHsgnGn9StXuLLXRVVDD8kZ5pjZbYlmM8r1IciB3iiQ+8N/2N4w== 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=a5yHR0shQCwWitEv0o8kfjuogvwPSxeofUrE/ZqUHwc=; b=utPUS68AejhQqG0vOCM/xLcVqTxsWlrGqyQ8mBoILnb6dMbo092Q2JUnQwmPOTN9TKquL75jNAf1lWztnSfD1saoFW9M7hCFqto6UWc4uAlBgX+bpn/Un1Pea6RP/GT/rIcYXH4eO0MoMgGeh5UDxak0CUv9qhS2A8soNIHxsxg= 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 PH7PR13MB6116.namprd13.prod.outlook.com (2603:10b6:510:2b7::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20; Thu, 24 Aug 2023 11:11:25 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::51fe:5846:af8b:bace]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::51fe:5846:af8b:bace%3]) with mapi id 15.20.6699.020; Thu, 24 Aug 2023 11:11:25 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH 22/27] net/nfp: add the dev module Date: Thu, 24 Aug 2023 19:09:51 +0800 Message-Id: <20230824110956.1943559-23-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230824110956.1943559-1-chaoyong.he@corigine.com> References: <20230824110956.1943559-1-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SJ0PR05CA0005.namprd05.prod.outlook.com (2603:10b6:a03:33b::10) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|PH7PR13MB6116:EE_ X-MS-Office365-Filtering-Correlation-Id: 0ecd1510-cfbb-4137-5a36-08dba492db54 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: r4Dve7ISIUqaPJ1jXLxeHmVgmdIRFtC0MXSqmWJSniaTKY9mP4qO7WnS6sEVTDCkf+xP2hx1CDi63co8Z87oP35/evnUGA3plZUGO75fezNBdou/KjjcV1PbG/ndjoV+uTwfG6Xnzl9eZWeo0UAm3K2q8yeKuSbXWTi6Bn3UdpP/EXFS8+ktk8ArqTlJCWtZYFhZwOtU1PPWluSfB0TF9BFVgJloBxt9LqRNxzEKjlbSdWB4tdJaBulSESWty2mZpSxnw8//yuBINYGfdbmHpxZQTaSY7Cj8TeFFLNEaadxJQoGzDcAus5yWc7u9vSWfsItYkLhdPavrxIy5IIbk0fHadL/uEY5UD5F3sumhoqH700bUBagJbTHc9VnvhzNE/ezreTOpqmoWxOdgpfn6bYJyVuTIQ095e40wc3u9vfdqdl/OaLsUrkGy/IYJcsGy3hPWvFBrtKupDPGLv8/DWSDNWX+pDQcGauCCUgZ/DODYBNQ7yvH81GQL9OGfZopSB7db/sCZJAsYUEYYBrezZ2F8lIpCIEgXjYYc79tvtdp/UL9baeHmJGMmYhSD25jz6hl6qWqwb/THQEujnIk/WRr+/dDD4yHphyLDaVKuAhXMm/svXGmXjAHgh4bGw9HJ9ASYUMkNHG3ehF8/cf7Vb1+ZfKa9a5LzxgVZRNVby1R7uwpEccH0eH5pocZZzpuM 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)(366004)(39830400003)(346002)(396003)(136003)(376002)(1800799009)(186009)(451199024)(6506007)(26005)(1076003)(2616005)(107886003)(52116002)(12101799020)(6512007)(66574015)(6486002)(83380400001)(38100700002)(8676002)(8936002)(36756003)(316002)(4326008)(41300700001)(30864003)(2906002)(86362001)(5660300002)(44832011)(38350700002)(6666004)(6916009)(478600001)(66476007)(66946007)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?citZL1VOZUR3blN2MWVrKzkrUVlJVG9rMi9vY1FNUDQ4RXNuNmdSL0o1ZGhk?= =?utf-8?B?ZzljL1dkenRKaFY5dlVOSkxaVlpFUkxHd2dDaXVVUkN1V3ZYWWdMRXpYcjNr?= =?utf-8?B?eTZUZHhCTEsrY200dTlMeWRCZ1BoVnZaYlhMNHRaT3h6d3pMOXJLUGk1N1Ro?= =?utf-8?B?YUhWdDVMaDRUSTJXTTdqZHVGS283eTc2ZjN0YkpqZFhDTzRheHBkS3p6U3VH?= =?utf-8?B?TGhWN1kreERIOWpoOEcwc21MRXRrS1hDb1J0VlBTUFpBT051aHpicWFUaGtC?= =?utf-8?B?bTdaVGxCcG1aZURDakM3eHByM0IzNzgxclZoTG9aRG1CdXk0QXVjcTdNbzVC?= =?utf-8?B?OHd3V1dobmtLKzFNUDdSeHNpblBIUFNtT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TWHJk?= =?utf-8?B?VHc9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0ecd1510-cfbb-4137-5a36-08dba492db54 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 11:11:25.8361 (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: y377RJUg1wy2MPFfusYjw56RGCihCDh11xqeS5+n9darw0EcUT/pirtidxqhG0oEdbuRawGHlJ6FtEG4S8nb2X/9S+/SUIp7XUcFkBfiITs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB6116 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 the nfp_dev module to simplify the logic. The data structure we import can gather and replace several macro which scatter everywhere. Which also make the logic of choose value for different devices unnecessary and so eliminate such logic. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- drivers/net/nfp/flower/nfp_flower.c | 6 +- .../net/nfp/flower/nfp_flower_representor.c | 6 +- drivers/net/nfp/meson.build | 1 + drivers/net/nfp/nfd3/nfp_nfd3_dp.c | 5 +- drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 5 +- drivers/net/nfp/nfp_common.c | 50 ++---------- drivers/net/nfp/nfp_common.h | 48 +++-------- drivers/net/nfp/nfp_ethdev.c | 63 ++++++--------- drivers/net/nfp/nfp_ethdev_vf.c | 17 +--- drivers/net/nfp/nfp_rxtx.c | 5 +- drivers/net/nfp/nfp_rxtx.h | 12 --- drivers/net/nfp/nfpcore/nfp_dev.c | 81 +++++++++++++++++++ drivers/net/nfp/nfpcore/nfp_dev.h | 44 ++++++++++ 13 files changed, 185 insertions(+), 158 deletions(-) create mode 100644 drivers/net/nfp/nfpcore/nfp_dev.c create mode 100644 drivers/net/nfp/nfpcore/nfp_dev.h diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index 24a6878149..43263531c5 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -503,7 +503,8 @@ nfp_flower_init_ctrl_vnic(struct nfp_net_hw *hw) * resizing in later calls to the queue setup function. */ tz = rte_eth_dma_zone_reserve(eth_dev, "ctrl_rx_ring", i, - sizeof(struct nfp_net_rx_desc) * NFP_NET_MAX_RX_DESC, + sizeof(struct nfp_net_rx_desc) * + pf_dev->dev_info->max_qc_size, NFP_MEMZONE_ALIGN, numa_node); if (tz == NULL) { PMD_DRV_LOG(ERR, "Error allocating rx dma"); @@ -558,7 +559,8 @@ nfp_flower_init_ctrl_vnic(struct nfp_net_hw *hw) * resizing in later calls to the queue setup function. */ tz = rte_eth_dma_zone_reserve(eth_dev, "ctrl_tx_ring", i, - sizeof(struct nfp_net_nfd3_tx_desc) * NFP_NET_MAX_TX_DESC, + sizeof(struct nfp_net_nfd3_tx_desc) * + pf_dev->dev_info->max_qc_size, NFP_MEMZONE_ALIGN, numa_node); if (tz == NULL) { PMD_DRV_LOG(ERR, "Error allocating tx dma"); diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c index 5f94d20f1b..dc6a2c7a9a 100644 --- a/drivers/net/nfp/flower/nfp_flower_representor.c +++ b/drivers/net/nfp/flower/nfp_flower_representor.c @@ -67,7 +67,8 @@ nfp_pf_repr_rx_queue_setup(struct rte_eth_dev *dev, * resizing in later calls to the queue setup function. */ tz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, - sizeof(struct nfp_net_rx_desc) * NFP_NET_MAX_RX_DESC, + sizeof(struct nfp_net_rx_desc) * + hw->pf_dev->dev_info->max_qc_size, NFP_MEMZONE_ALIGN, socket_id); if (tz == NULL) { PMD_DRV_LOG(ERR, "Error allocating rx dma"); @@ -140,7 +141,8 @@ nfp_pf_repr_tx_queue_setup(struct rte_eth_dev *dev, * resizing in later calls to the queue setup function. */ tz = rte_eth_dma_zone_reserve(dev, "tx_ring", queue_idx, - sizeof(struct nfp_net_nfd3_tx_desc) * NFP_NET_MAX_TX_DESC, + sizeof(struct nfp_net_nfd3_tx_desc) * + hw->pf_dev->dev_info->max_qc_size, NFP_MEMZONE_ALIGN, socket_id); if (tz == NULL) { PMD_DRV_LOG(ERR, "Error allocating tx dma"); diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build index 93c708959c..580a478cd6 100644 --- a/drivers/net/nfp/meson.build +++ b/drivers/net/nfp/meson.build @@ -21,6 +21,7 @@ sources = files( 'nfpcore/nfp_rtsym.c', 'nfpcore/nfp_nsp_cmds.c', 'nfpcore/nfp_crc.c', + 'nfpcore/nfp_dev.c', 'nfpcore/nfp_mutex.c', 'nfpcore/nfp_nsp_eth.c', 'nfpcore/nfp_hwinfo.c', diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c index ee39686329..79e1e1041c 100644 --- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c +++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c @@ -262,7 +262,6 @@ nfp_net_nfd3_tx_queue_setup(struct rte_eth_dev *dev, unsigned int socket_id, const struct rte_eth_txconf *tx_conf) { - int ret; size_t size; uint32_t tx_desc_sz; uint16_t min_tx_desc; @@ -276,9 +275,7 @@ nfp_net_nfd3_tx_queue_setup(struct rte_eth_dev *dev, PMD_INIT_FUNC_TRACE(); - ret = nfp_net_tx_desc_limits(hw, &min_tx_desc, &max_tx_desc); - if (ret != 0) - return ret; + nfp_net_tx_desc_limits(hw, &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 f66802211f..48a74d109a 100644 --- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c +++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c @@ -357,7 +357,6 @@ nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev, unsigned int socket_id, const struct rte_eth_txconf *tx_conf) { - int ret; size_t size; uint32_t tx_desc_sz; uint16_t min_tx_desc; @@ -371,9 +370,7 @@ nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev, PMD_INIT_FUNC_TRACE(); - ret = nfp_net_tx_desc_limits(hw, &min_tx_desc, &max_tx_desc); - if (ret != 0) - return ret; + nfp_net_tx_desc_limits(hw, &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_common.c b/drivers/net/nfp/nfp_common.c index 5092e5869d..d6ff4f17ae 100644 --- a/drivers/net/nfp/nfp_common.c +++ b/drivers/net/nfp/nfp_common.c @@ -1146,30 +1146,16 @@ nfp_net_xstats_reset(struct rte_eth_dev *dev) return nfp_net_stats_reset(dev); } -int +void nfp_net_rx_desc_limits(struct nfp_net_hw *hw, uint16_t *min_rx_desc, uint16_t *max_rx_desc) { - *max_rx_desc = NFP_NET_MAX_RX_DESC; - - switch (hw->device_id) { - case PCI_DEVICE_ID_NFP3800_PF_NIC: - case PCI_DEVICE_ID_NFP3800_VF_NIC: - *min_rx_desc = NFP3800_NET_MIN_RX_DESC; - return 0; - case PCI_DEVICE_ID_NFP4000_PF_NIC: - case PCI_DEVICE_ID_NFP6000_PF_NIC: - case PCI_DEVICE_ID_NFP6000_VF_NIC: - *min_rx_desc = NFP_NET_MIN_RX_DESC; - return 0; - default: - PMD_DRV_LOG(ERR, "Unknown NFP device id."); - return -EINVAL; - } + *max_rx_desc = hw->pf_dev->dev_info->max_qc_size; + *min_rx_desc = hw->pf_dev->dev_info->min_qc_size; } -int +void nfp_net_tx_desc_limits(struct nfp_net_hw *hw, uint16_t *min_tx_desc, uint16_t *max_tx_desc) @@ -1181,28 +1167,13 @@ nfp_net_tx_desc_limits(struct nfp_net_hw *hw, else tx_dpp = NFDK_TX_DESC_PER_SIMPLE_PKT; - *max_tx_desc = NFP_NET_MAX_TX_DESC / tx_dpp; - - switch (hw->device_id) { - case PCI_DEVICE_ID_NFP3800_PF_NIC: - case PCI_DEVICE_ID_NFP3800_VF_NIC: - *min_tx_desc = NFP3800_NET_MIN_TX_DESC / tx_dpp; - return 0; - case PCI_DEVICE_ID_NFP4000_PF_NIC: - case PCI_DEVICE_ID_NFP6000_PF_NIC: - case PCI_DEVICE_ID_NFP6000_VF_NIC: - *min_tx_desc = NFP_NET_MIN_TX_DESC / tx_dpp; - return 0; - default: - PMD_DRV_LOG(ERR, "Unknown NFP device id."); - return -EINVAL; - } + *max_tx_desc = hw->pf_dev->dev_info->max_qc_size / tx_dpp; + *min_tx_desc = hw->pf_dev->dev_info->min_qc_size / tx_dpp; } int nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) { - int ret; uint16_t min_rx_desc; uint16_t max_rx_desc; uint16_t min_tx_desc; @@ -1211,13 +1182,8 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - ret = nfp_net_rx_desc_limits(hw, &min_rx_desc, &max_rx_desc); - if (ret != 0) - return ret; - - ret = nfp_net_tx_desc_limits(hw, &min_tx_desc, &max_tx_desc); - if (ret != 0) - return ret; + nfp_net_rx_desc_limits(hw, &min_rx_desc, &max_rx_desc); + nfp_net_tx_desc_limits(hw, &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; diff --git a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_common.h index 86c4e10040..5fc9f0ccda 100644 --- a/drivers/net/nfp/nfp_common.h +++ b/drivers/net/nfp/nfp_common.h @@ -7,16 +7,9 @@ #define _NFP_COMMON_H_ #include "nfp_ctrl.h" +#include "nfpcore/nfp_dev.h" #define NFP_NET_PMD_VERSION "0.1" -#define PCI_VENDOR_ID_NETRONOME 0x19ee -#define PCI_VENDOR_ID_CORIGINE 0x1da8 - -#define PCI_DEVICE_ID_NFP3800_PF_NIC 0x3800 -#define PCI_DEVICE_ID_NFP3800_VF_NIC 0x3803 -#define PCI_DEVICE_ID_NFP4000_PF_NIC 0x4000 -#define PCI_DEVICE_ID_NFP6000_PF_NIC 0x6000 -#define PCI_DEVICE_ID_NFP6000_VF_NIC 0x6003 /* Include NFP4000VF */ /* Forward declaration */ struct nfp_net_adapter; @@ -28,7 +21,6 @@ struct nfp_net_adapter; #define NFP_NET_CRTL_BAR 0 #define NFP_NET_TX_BAR 2 #define NFP_NET_RX_BAR 2 -#define NFP_QCP_QUEUE_AREA_SZ 0x80000 /* Macros for accessing the Queue Controller Peripheral 'CSRs' */ #define NFP_QCP_QUEUE_OFF(_x) ((_x) * 0x800) @@ -39,17 +31,6 @@ struct nfp_net_adapter; #define NFP_QCP_QUEUE_STS_HI 0x000c #define NFP_QCP_QUEUE_STS_HI_WRITEPTR_mask (0x3ffff) -#define NFP_PCIE_QCP_NFP3800_OFFSET 0x400000 -#define NFP_PCIE_QCP_NFP6000_OFFSET 0x80000 -#define NFP_PCIE_QUEUE_NFP3800_MASK 0x1ff -#define NFP_PCIE_QUEUE_NFP6000_MASK 0xff -#define NFP_PCIE_QCP_PF_OFFSET 0x0 -#define NFP_PCIE_QCP_VF_OFFSET 0x0 - -/* The offset of the queue controller queues in the PCIe Target */ -#define NFP_PCIE_QUEUE(_offset, _q, _mask) \ - ((_offset) + (NFP_QCP_QUEUE_ADDR_SZ * ((_q) & (_mask)))) - /* Interrupt definitions */ #define NFP_NET_IRQ_LSC_IDX 0 @@ -111,6 +92,9 @@ struct nfp_pf_dev { /* Backpointer to associated pci device */ struct rte_pci_device *pci_dev; + /** NFP ASIC params */ + const struct nfp_dev_info *dev_info; + enum nfp_app_fw_id app_fw_id; /* Pointer to the app running on the PF */ @@ -352,23 +336,11 @@ nfp_qcp_read(uint8_t *q, enum nfp_qcp_ptr ptr) } static inline uint32_t -nfp_pci_queue(struct rte_pci_device *pdev, uint16_t queue) +nfp_qcp_queue_offset(const struct nfp_dev_info *dev_info, + uint16_t queue) { - switch (pdev->id.device_id) { - case PCI_DEVICE_ID_NFP4000_PF_NIC: - case PCI_DEVICE_ID_NFP6000_PF_NIC: - return NFP_PCIE_QUEUE(NFP_PCIE_QCP_PF_OFFSET, queue, - NFP_PCIE_QUEUE_NFP6000_MASK); - case PCI_DEVICE_ID_NFP3800_VF_NIC: - return NFP_PCIE_QUEUE(NFP_PCIE_QCP_VF_OFFSET, queue, - NFP_PCIE_QUEUE_NFP3800_MASK); - case PCI_DEVICE_ID_NFP6000_VF_NIC: - return NFP_PCIE_QUEUE(NFP_PCIE_QCP_VF_OFFSET, queue, - NFP_PCIE_QUEUE_NFP6000_MASK); - default: - return NFP_PCIE_QUEUE(NFP_PCIE_QCP_PF_OFFSET, queue, - NFP_PCIE_QUEUE_NFP3800_MASK); - } + return dev_info->qc_addr_offset + NFP_QCP_QUEUE_ADDR_SZ * + (queue & dev_info->qc_idx_mask); } /* Prototypes for common NFP functions */ @@ -434,10 +406,10 @@ void nfp_net_close_rx_queue(struct rte_eth_dev *dev); void nfp_net_stop_tx_queue(struct rte_eth_dev *dev); void nfp_net_close_tx_queue(struct rte_eth_dev *dev); int nfp_net_set_vxlan_port(struct nfp_net_hw *hw, size_t idx, uint16_t port); -int nfp_net_rx_desc_limits(struct nfp_net_hw *hw, +void nfp_net_rx_desc_limits(struct nfp_net_hw *hw, uint16_t *min_rx_desc, uint16_t *max_rx_desc); -int nfp_net_tx_desc_limits(struct nfp_net_hw *hw, +void nfp_net_tx_desc_limits(struct nfp_net_hw *hw, uint16_t *min_tx_desc, uint16_t *max_tx_desc); int nfp_net_check_dma_mask(struct nfp_net_hw *hw, char *name); diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 3f5375deb9..c37d8a1449 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -496,9 +496,8 @@ nfp_net_init(struct rte_eth_dev *eth_dev) struct nfp_app_fw_nic *app_fw_nic; struct nfp_net_hw *hw; struct rte_ether_addr *tmp_ether_addr; - uint64_t rx_bar_off = 0; - uint64_t tx_bar_off = 0; - uint32_t start_q; + uint64_t rx_base; + uint64_t tx_base; int port = 0; int err; @@ -576,25 +575,14 @@ nfp_net_init(struct rte_eth_dev *eth_dev) /* Work out where in the BAR the queues start. */ - switch (pci_dev->id.device_id) { - case PCI_DEVICE_ID_NFP3800_PF_NIC: - case PCI_DEVICE_ID_NFP4000_PF_NIC: - case PCI_DEVICE_ID_NFP6000_PF_NIC: - start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_TXQ); - tx_bar_off = nfp_pci_queue(pci_dev, start_q); - start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_RXQ); - rx_bar_off = nfp_pci_queue(pci_dev, start_q); - break; - default: - PMD_DRV_LOG(ERR, "nfp_net: no device ID matching"); - return -ENODEV; - } + tx_base = nn_cfg_readl(hw, NFP_NET_CFG_START_TXQ); + rx_base = nn_cfg_readl(hw, NFP_NET_CFG_START_RXQ); - PMD_INIT_LOG(DEBUG, "tx_bar_off: 0x%" PRIx64 "", tx_bar_off); - PMD_INIT_LOG(DEBUG, "rx_bar_off: 0x%" PRIx64 "", rx_bar_off); + PMD_INIT_LOG(DEBUG, "tx_base: 0x%" PRIx64 "", tx_base); + PMD_INIT_LOG(DEBUG, "rx_base: 0x%" PRIx64 "", rx_base); - hw->tx_bar = pf_dev->qc_bar + tx_bar_off; - hw->rx_bar = pf_dev->qc_bar + rx_bar_off; + hw->tx_bar = pf_dev->qc_bar + tx_base * NFP_QCP_QUEUE_ADDR_SZ; + hw->rx_bar = pf_dev->qc_bar + rx_base * NFP_QCP_QUEUE_ADDR_SZ; eth_dev->data->dev_private = hw; PMD_INIT_LOG(DEBUG, "ctrl_bar: %p, tx_bar: %p, rx_bar: %p", @@ -902,10 +890,17 @@ nfp_pf_init(struct rte_pci_device *pci_dev) char name[RTE_ETH_NAME_MAX_LEN]; struct nfp_rtsym_table *sym_tbl; struct nfp_eth_table *nfp_eth_table; + const struct nfp_dev_info *dev_info; if (pci_dev == NULL) return -ENODEV; + dev_info = nfp_dev_info_get(pci_dev->id.device_id); + if (dev_info == NULL) { + PMD_INIT_LOG(ERR, "Not supported device ID"); + return -ENODEV; + } + /* * When device bound to UIO, the device could be used, by mistake, * by two DPDK apps, and the UIO driver does not avoid it. This @@ -976,27 +971,14 @@ nfp_pf_init(struct rte_pci_device *pci_dev) pf_dev->sym_tbl = sym_tbl; pf_dev->pci_dev = pci_dev; pf_dev->nfp_eth_table = nfp_eth_table; + pf_dev->dev_info = dev_info; /* configure access to tx/rx vNIC BARs */ - switch (pci_dev->id.device_id) { - case PCI_DEVICE_ID_NFP3800_PF_NIC: - addr = NFP_PCIE_QUEUE(NFP_PCIE_QCP_NFP3800_OFFSET, - 0, NFP_PCIE_QUEUE_NFP3800_MASK); - break; - case PCI_DEVICE_ID_NFP4000_PF_NIC: - case PCI_DEVICE_ID_NFP6000_PF_NIC: - addr = NFP_PCIE_QUEUE(NFP_PCIE_QCP_NFP6000_OFFSET, - 0, NFP_PCIE_QUEUE_NFP6000_MASK); - break; - default: - PMD_INIT_LOG(ERR, "nfp_net: no device ID matching"); - ret = -ENODEV; - goto pf_cleanup; - } - + addr = nfp_qcp_queue_offset(pf_dev->dev_info, 0); cpp_id = NFP_CPP_ISLAND_ID(0, NFP_CPP_ACTION_RW, 0, 0); + pf_dev->qc_bar = nfp_cpp_map_area(pf_dev->cpp, cpp_id, - addr, NFP_QCP_QUEUE_AREA_SZ, + addr, pf_dev->dev_info->qc_area_sz, &pf_dev->qc_area); if (pf_dev->qc_bar == NULL) { PMD_INIT_LOG(ERR, "nfp_rtsym_map fails for net.qc"); @@ -1111,10 +1093,17 @@ nfp_pf_secondary_init(struct rte_pci_device *pci_dev) struct nfp_cpp *cpp; enum nfp_app_fw_id app_fw_id; struct nfp_rtsym_table *sym_tbl; + const struct nfp_dev_info *dev_info; if (pci_dev == NULL) return -ENODEV; + dev_info = nfp_dev_info_get(pci_dev->id.device_id); + if (dev_info == NULL) { + PMD_INIT_LOG(ERR, "Not supported device ID"); + return -ENODEV; + } + /* * When device bound to UIO, the device could be used, by mistake, * by two DPDK apps, and the UIO driver does not avoid it. This diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c index eaf815d06d..cf60e56c28 100644 --- a/drivers/net/nfp/nfp_ethdev_vf.c +++ b/drivers/net/nfp/nfp_ethdev_vf.c @@ -305,19 +305,10 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev) } /* Work out where in the BAR the queues start. */ - switch (pci_dev->id.device_id) { - case PCI_DEVICE_ID_NFP3800_VF_NIC: - case PCI_DEVICE_ID_NFP6000_VF_NIC: - start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_TXQ); - tx_bar_off = nfp_pci_queue(pci_dev, start_q); - start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_RXQ); - rx_bar_off = nfp_pci_queue(pci_dev, start_q); - break; - default: - PMD_DRV_LOG(ERR, "nfp_net: no device ID matching"); - err = -ENODEV; - goto dev_err_ctrl_map; - } + start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_TXQ); + tx_bar_off = nfp_qcp_queue_offset(hw->pf_dev->dev_info, start_q); + start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_RXQ); + rx_bar_off = nfp_qcp_queue_offset(hw->pf_dev->dev_info, start_q); PMD_INIT_LOG(DEBUG, "tx_bar_off: 0x%" PRIx64 "", tx_bar_off); PMD_INIT_LOG(DEBUG, "rx_bar_off: 0x%" PRIx64 "", rx_bar_off); diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index f0c371ea2b..1b8bb3471d 100644 --- a/drivers/net/nfp/nfp_rxtx.c +++ b/drivers/net/nfp/nfp_rxtx.c @@ -677,7 +677,6 @@ nfp_net_rx_queue_setup(struct rte_eth_dev *dev, const struct rte_eth_rxconf *rx_conf, struct rte_mempool *mp) { - int ret; uint16_t min_rx_desc; uint16_t max_rx_desc; const struct rte_memzone *tz; @@ -689,9 +688,7 @@ nfp_net_rx_queue_setup(struct rte_eth_dev *dev, PMD_INIT_FUNC_TRACE(); - ret = nfp_net_rx_desc_limits(hw, &min_rx_desc, &max_rx_desc); - if (ret != 0) - return ret; + nfp_net_rx_desc_limits(hw, &min_rx_desc, &max_rx_desc); /* Validating number of descriptors */ rx_desc_sz = nb_desc * sizeof(struct nfp_net_rx_desc); diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h index 48e548b02d..6d1c8e4605 100644 --- a/drivers/net/nfp/nfp_rxtx.h +++ b/drivers/net/nfp/nfp_rxtx.h @@ -74,18 +74,6 @@ struct nfp_meta_parsed { } vlan[NFP_META_MAX_VLANS]; }; -/* - * The maximum number of descriptors is limited by design as - * DPDK uses uint16_t variables for these values - */ -#define NFP_NET_MAX_TX_DESC (32 * 1024) -#define NFP_NET_MIN_TX_DESC 256 -#define NFP3800_NET_MIN_TX_DESC 512 - -#define NFP_NET_MAX_RX_DESC (32 * 1024) -#define NFP_NET_MIN_RX_DESC 256 -#define NFP3800_NET_MIN_RX_DESC 512 - /* Descriptor alignment */ #define NFP_ALIGN_RING_DESC 128 diff --git a/drivers/net/nfp/nfpcore/nfp_dev.c b/drivers/net/nfp/nfpcore/nfp_dev.c new file mode 100644 index 0000000000..7799fa699a --- /dev/null +++ b/drivers/net/nfp/nfpcore/nfp_dev.c @@ -0,0 +1,81 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Corigine, Inc. + * All rights reserved. + */ + +#include "nfp_dev.h" + +#include + +#include "nfp_platform.h" + +/* + * Note: The value of 'max_qc_size' is different from kernel driver, + * because DPDK use 'uint16_t' as the data type. + */ +const struct nfp_dev_info nfp_dev_info[NFP_DEV_CNT] = { + [NFP_DEV_NFP3800] = { + .qc_idx_mask = GENMASK(8, 0), + .qc_addr_offset = 0x400000, + .min_qc_size = 512, + .max_qc_size = RTE_BIT32(15), /**< 32K */ + + .chip_names = "NFP3800", + .pcie_cfg_expbar_offset = 0x0a00, + .qc_area_sz = 0x100000, + .pf_num_per_unit = 4, + }, + [NFP_DEV_NFP3800_VF] = { + .qc_idx_mask = GENMASK(8, 0), + .qc_addr_offset = 0, + .min_qc_size = 512, + .max_qc_size = RTE_BIT32(15), /**< 32K */ + }, + [NFP_DEV_NFP6000] = { + .qc_idx_mask = GENMASK(7, 0), + .qc_addr_offset = 0x80000, + .min_qc_size = 256, + .max_qc_size = RTE_BIT32(15), /**< 32K */ + + .chip_names = "NFP4000/NFP6000", + .pcie_cfg_expbar_offset = 0x0400, + .qc_area_sz = 0x80000, + .pf_num_per_unit = 1, + }, + [NFP_DEV_NFP6000_VF] = { + .qc_idx_mask = GENMASK(7, 0), + .qc_addr_offset = 0, + .min_qc_size = 256, + .max_qc_size = RTE_BIT32(15), /**< 32K */ + }, +}; + +const struct nfp_dev_info * +nfp_dev_info_get(uint16_t device_id) +{ + enum nfp_dev_id id; + + switch (device_id) { + case PCI_DEVICE_ID_NFP3800_PF_NIC: + id = NFP_DEV_NFP3800; + break; + case PCI_DEVICE_ID_NFP3800_VF_NIC: + id = NFP_DEV_NFP3800_VF; + break; + case PCI_DEVICE_ID_NFP4000_PF_NIC: + case PCI_DEVICE_ID_NFP6000_PF_NIC: + id = NFP_DEV_NFP6000; + break; + case PCI_DEVICE_ID_NFP6000_VF_NIC: + id = NFP_DEV_NFP6000_VF; + break; + default: + id = NFP_DEV_CNT; + break; + } + + if (id >= NFP_DEV_CNT) + return NULL; + + return &nfp_dev_info[id]; +} diff --git a/drivers/net/nfp/nfpcore/nfp_dev.h b/drivers/net/nfp/nfpcore/nfp_dev.h new file mode 100644 index 0000000000..b0fffff619 --- /dev/null +++ b/drivers/net/nfp/nfpcore/nfp_dev.h @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Corigine, Inc. + * All rights reserved. + */ + +#ifndef __NFP_DEV_H__ +#define __NFP_DEV_H__ + +#include + +#define PCI_VENDOR_ID_NETRONOME 0x19ee +#define PCI_VENDOR_ID_CORIGINE 0x1da8 + +#define PCI_DEVICE_ID_NFP3800_PF_NIC 0x3800 +#define PCI_DEVICE_ID_NFP3800_VF_NIC 0x3803 +#define PCI_DEVICE_ID_NFP4000_PF_NIC 0x4000 +#define PCI_DEVICE_ID_NFP6000_PF_NIC 0x6000 +#define PCI_DEVICE_ID_NFP6000_VF_NIC 0x6003 /* Include NFP4000VF */ + +enum nfp_dev_id { + NFP_DEV_NFP3800, + NFP_DEV_NFP3800_VF, + NFP_DEV_NFP6000, + NFP_DEV_NFP6000_VF, + NFP_DEV_CNT, +}; + +struct nfp_dev_info { + /* Required fields */ + uint32_t qc_idx_mask; + uint32_t qc_addr_offset; + uint32_t min_qc_size; + uint32_t max_qc_size; + + /* PF-only fields */ + const char *chip_names; + uint32_t pcie_cfg_expbar_offset; + uint32_t qc_area_sz; + uint8_t pf_num_per_unit; +}; + +const struct nfp_dev_info *nfp_dev_info_get(uint16_t device_id); + +#endif /* __NFP_DEV_H__ */ -- 2.39.1