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 CA834425C9; Mon, 18 Sep 2023 04:49:55 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 60E2B42D66; Mon, 18 Sep 2023 04:47:53 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2105.outbound.protection.outlook.com [40.107.220.105]) by mails.dpdk.org (Postfix) with ESMTP id 6273A427DA for ; Mon, 18 Sep 2023 04:47:49 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DFxYljy35rlc2OZdRWw+U2dll90Bb9IHgMkxSGes/RQyaPqhPZYXHgH5i2T4p7OgalelwRojHVx/sSMaN36LfuaTDpQPeYkKFnwQn/I0f9uOkoh54OoSgafi9uZxnyWvDyGEsMmchJX9zTlayPgnR1kmDHR87W/KfZy/sDv5nBV7c/Ua6+CZxJOou2AKGEcDeq+KaBg+W5zQF4wX7QS/UCXpgNPn9JI+MBPSd1yLkjEisQ4DvQsJZ3FYt+hGG9ndPT/pk1lwdTbn638ivKQepnqhwoBvIVrM9k4GMbt9hYUyyzHFQwubMhmn1glZ1iL8tW6F42KB1/Tw88l+H3YkZg== 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=raJ/kBfcLcyqfwcGJn4yakB5gBm1kOcdlLWHCthR3q8=; b=Ok1iV91LxII+qg/HYCaADZcz0+3V8V3NrXyV9BuOGO4mPEsYMjG6WCZ8oWSq2kpRcxI42mw8MC34N1uYriwLdkpXXx3WZ4mkKww9GuIBX8UL2QcHlFJFEAwCxnYb9RCOKsr6Gg3NxdICcgar5pgHUXanh7nUtwPCoLkhnqyDBZ/IAWLQT4hLaFQg8CJ88llBc/wuR1fWItsDnsBOOyL2hmaGtSjKk+1nj0mIxekbFgXNwf3DIsA5DzMlY9FqnE8dtKfhgPdDBkoIhlvIxW3nsyvRP4Jd2NCNBTYfHHztSSj44uMyN13VElKEPBLSQ35PfU6Ec703DU7JF8cNWf1LTg== 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=raJ/kBfcLcyqfwcGJn4yakB5gBm1kOcdlLWHCthR3q8=; b=VN69M4daWVjNH74iJR5fdnP7ZjWUx1977oXCzo3Oc1gsv9kcURuyPAVqk65xRiZcpK3T83CMvsA0p7SC+dhAk2da794yiH0n2VVlhgBGcnobVDxxoWJWfCqDiXlasiY4Zcu86Gck6q3nmfZHrZetjoJ/gB5hPMkUWe6t3tJpUHY= 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 BL0PR13MB4401.namprd13.prod.outlook.com (2603:10b6:208:1c3::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.24; Mon, 18 Sep 2023 02:47:47 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::7a1c:2887:348a:84bd]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::7a1c:2887:348a:84bd%6]) with mapi id 15.20.6792.026; Mon, 18 Sep 2023 02:47:47 +0000 From: Chaoyong He To: dev@dpdk.org Cc: Chaoyong He , =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH v4 21/26] net/nfp: add the dev module Date: Mon, 18 Sep 2023 10:46:07 +0800 Message-Id: <20230918024612.1600536-22-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230918024612.1600536-1-chaoyong.he@corigine.com> References: <20230915091551.1459606-1-chaoyong.he@corigine.com> <20230918024612.1600536-1-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SE2P216CA0016.KORP216.PROD.OUTLOOK.COM (2603:1096:101:114::20) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|BL0PR13MB4401:EE_ X-MS-Office365-Filtering-Correlation-Id: b511db24-5f0d-400a-e0a3-08dbb7f1a445 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yNzrrCZI5BRtIwtBSPJM41nA6aty3KWn7kv4i1fhdWXlF2mq/voasodk7mnfGeIBjiGdhitD43JHG67GtksiwenDQKL98cg0Wp9npgxgeZxrJwIJ7GMEpLS/OykMPW0MjT1/l6ZtwLchdGZDJSc7xxZ4/heJUsf5o7lL3Hyv5PfrIXtQDRYXzqp/DkQvl5EfML4ToHFozaHcawYkRLZNolA1qgA9wupKNUSq/KfxsY5HR2viRc7YNdm5LmGkrRvcrlGwd3vYf6yKUoZZPVou3OJOo4qwS/jjfShednkYTrjcJFmCCsRzJ4MNIKqpVBzOu3n7NTgQQV9Rnzwr9RAzBCpkX++3vTCgtUB6zvJlO/iODAe1uyLrrYHIgy0pu9lCKoGfSrFJca69TGtfLV8gu8nufjzFBrfuPVbmFmlX8is/LzHV+XyCEnznVIbp0ZIqZMJMBNFzJ55oXSrQLEem1rDP1/yTpjU7H4zFi45YBMgYStIm31juPf5o6Cf9sv6Caktm2G8Uf7DsYMTXGd5DCHEBHjYQzUDdo97XDfPGEXYwbOJMElfmUBfUvxB/pE/Tt6xJUmPTB9/i3e4xlh8z5Iebzmy8etwXtTs86uV8E2L2mmz8mL0anv/664wL1LomGNMPxXjxDjYLGDP13StQ9TFih+3D0Xf6fQScpJfPvZ4= 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)(136003)(376002)(346002)(39830400003)(396003)(186009)(1800799009)(451199024)(5660300002)(26005)(107886003)(1076003)(8936002)(4326008)(8676002)(2616005)(2906002)(30864003)(86362001)(38350700002)(38100700002)(36756003)(83380400001)(66574015)(44832011)(66946007)(6506007)(6486002)(52116002)(66476007)(66556008)(54906003)(6666004)(478600001)(6512007)(41300700001)(316002)(6916009); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?NkQrdisvTEdVcGJPUksxNWRDKzcydVpHdm0yNEpGQlVJRjlxNXJYYXdDT3Nr?= =?utf-8?B?c0xIMmg1bmN4WDhxUXBDMks2aUZhZlBOOTZjclJ2WUo1S1NLampPTllrSldM?= =?utf-8?B?d0l2aDM4ZHphaEN5MHFrRU1hWVUrcHVxeXV2bTUzSnI1bFdNQURUOENNZCsw?= =?utf-8?B?Qk9yMU5BMkloYjZYVzVUMXV4UFBhYUNzMm9rZFJTa0lNQncvWk53aWFVdVdS?= =?utf-8?B?TURNeVJVN2t1dGwzUmZXK1UzQ0JreTAzL2x0c2VUWFZiMkZnV3ZHeW8rWXVF?= =?utf-8?B?U2VISjBScGNBNVZGUDFxZW0rS2M1djBBV3VLWVpVYktxdnhNZnI0L3RNTW9n?= =?utf-8?B?MjI4eVI5YUZIeExQ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TBzVXFGbXRZVzJs?= =?utf-8?B?eEE9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: b511db24-5f0d-400a-e0a3-08dbb7f1a445 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 02:47:47.7261 (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: 9no/jSA+/rk+4RX1QHJxkNNt+diXqrDhCCmJ7jvEvNMQLmYS8Dv4Fl2KvJv6TSGkzPvDtYfK2kCYzP+sP375LnRi+w3WIZE9pGfQooqtGkk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR13MB4401 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 fead917599..cb72a6a025 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 899d4dd253..46bedb6696 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