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 A93364560F; Fri, 12 Jul 2024 11:49:42 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1D73242ED3; Fri, 12 Jul 2024 11:48:56 +0200 (CEST) Received: from egress-ip11b.ess.de.barracuda.com (egress-ip11b.ess.de.barracuda.com [18.185.115.215]) by mails.dpdk.org (Postfix) with ESMTP id 2372742EB5 for ; Fri, 12 Jul 2024 11:48:48 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2105.outbound.protection.outlook.com [104.47.17.105]) by mx-outbound45-239.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 12 Jul 2024 09:48:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KVRnWOkKl1tixA32WrmKcG8zSuzMZM2C8TdntDIZCrLhMgyqIWZWqd+ryHbX+Qx9yv5VomIrFp5jCFLFGdBjTAPh1fLba+wFqPPRHKVPfe7CwHe7VUzJqgRFmADPzrF146lFPzVcct+jWT7342i7zEqWGVpKchky+NC/WQxAZhO7RPGBE1qCY+FlI+Ai2v8kZeH/rrY81UdZ1c0yhM+/zhM+XAbB9Q5zPxvxXzEtzXoOpNbXB0lcsfOCeNpcoq0qMt7TU4CQwXzD09zsZRjZg1ET4Ljx7BkEIp8Dav+auT+w9O2JBHsRcWxyUsLRbp9/i5UUugGbPZvHn2GjVkvlBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Oy+NGzmF8Rwr+4TKDV2zDNNT66ZbwCnOetsuuV+VMcQ=; b=kNyVrr7pCqZICamaQGGbexOaUOUEvMJkFADT8b+peE5bld+ZLSPl7IY7PiqqTSgDSbAzRlT7wFxXI4HfjwnqqRT4ok8aaiYzxtLTP97nRG7mE+oKI0wH/7YU+AcAwjXSBrtEyEBOIbDEjMOy4aNqSIs50kTy0n9A4hsP8tX4Roy6MVD58OzsbqfHPynEcjxTwaWdnQU6f5XP6d6D+xAsFMf8+2RHm06qJCtvU7a5ZdEytYNBYCZza89q3nGhCQxywLeOZZg7wHbUFtTZqA4vklESGGjsVsxJlM6Yo5O73e/Mr9W3lHhOwMRj2u0lZspD2pC//44Iw6WEWvEbzDqlog== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 178.72.21.4) smtp.rcpttodomain=dpdk.org smtp.mailfrom=napatech.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=napatech.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=napatech.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Oy+NGzmF8Rwr+4TKDV2zDNNT66ZbwCnOetsuuV+VMcQ=; b=pKq87W3VJLQY5Jiq3khNLeFUXNPJKt4DII7x3i9T9QuRcJe7tkKQRk2VKoI5WM+lCWCdnM1x/dLPQsH01cTLFcku2TzMaqOFO2+Tp/Rbqzo0YDKXx+Nrbf4YHoxM68SK1YzLU1Po0EV5f8+2iovmP7PJiwo1N/9rq6ZyH5Ayg68= Received: from AS9PR06CA0519.eurprd06.prod.outlook.com (2603:10a6:20b:49d::14) by PR3P190MB0890.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:93::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.20; Fri, 12 Jul 2024 09:48:44 +0000 Received: from AM1PEPF000252DD.eurprd07.prod.outlook.com (2603:10a6:20b:49d:cafe::df) by AS9PR06CA0519.outlook.office365.com (2603:10a6:20b:49d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.23 via Frontend Transport; Fri, 12 Jul 2024 09:48:44 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 178.72.21.4) smtp.mailfrom=napatech.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=napatech.com; Received-SPF: Fail (protection.outlook.com: domain of napatech.com does not designate 178.72.21.4 as permitted sender) receiver=protection.outlook.com; client-ip=178.72.21.4; helo=localhost.localdomain; Received: from localhost.localdomain (178.72.21.4) by AM1PEPF000252DD.mail.protection.outlook.com (10.167.16.55) with Microsoft SMTP Server id 15.20.7762.17 via Frontend Transport; Fri, 12 Jul 2024 09:48:44 +0000 From: Serhii Iliushyk To: dev@dpdk.org Cc: mko-plv@napatech.com, sil-plv@napatech.com, ckm@napatech.com, andrew.rybchenko@oktetlabs.ru, ferruh.yigit@amd.com Subject: [PATCH v7 11/21] net/ntnic: add FPGA initialization functionality Date: Fri, 12 Jul 2024 11:48:16 +0200 Message-ID: <20240712094831.861260-11-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240712094831.861260-1-sil-plv@napatech.com> References: <20240530144929.4127931-1-sil-plv@napatech.com> <20240712094831.861260-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM1PEPF000252DD:EE_|PR3P190MB0890:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: a5cd453e-e603-4033-b03c-08dca257d1b0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?HAI4spd8bisAWzMYPEycWFeD0COe8mBmOydPbLxs5TEiZki4Mt+rzaub5iOq?= =?us-ascii?Q?N+8Ht+Ld4kx6e4ydvql46vKBQQbDcJHWxrTi41O9wtp0Ky5ZmPQLWvmkMMdx?= =?us-ascii?Q?37EQLN2wBPSTEFh+xKYibVQLBXaNDYejeweUFNZ24+Ucxpi9dDn0OoQOT1il?= =?us-ascii?Q?O/JfL/9+R8sx5BrGB7UO2y5FLU4Pc4ZxuLbu5FRpPNlZuVM7tXN4ZqlYBLMi?= =?us-ascii?Q?lhDvsjXOT7U9M1fNYigvDloNV7z96qoNmjemNo2AVUgapPyP5dTP34f+s6BI?= =?us-ascii?Q?Q9eG3J7MzoO6QZjtt9710+nR46AbtQgV6KOXQjqEiBC6bFug6pfxxSPvXIoI?= =?us-ascii?Q?QGD//qtAKciD+qA0COZsCLw/3lQ4VIZHI2aBaFlKadjGdlJXqK9BQHckeowY?= =?us-ascii?Q?6ECZh8tzps8hPGzhDNWpsMStkspoCVy+6VGWaZaQEPgyJUD4bbp5WbmU0lyB?= =?us-ascii?Q?hmxJx5R2R23gzKXrcVgJ4mWuZtfia6X1OXbWwlgJ/Lpz3Zu2rIt2z+Hkpmra?= =?us-ascii?Q?lPOkoPmlDSYhvaiZUnr94i1yo6H/YHt1fGedCtKJt/SSNlv5OzfrBYenrH4x?= =?us-ascii?Q?fFyP0bs9njQFvSrPM1DDvOwDdDVyQuf41Ast+FcL8pnyZpKqJTbkaOEoj/VF?= =?us-ascii?Q?xUU87Oq/bPqd8Xip4u8fh84J6wwOLcPa8+R1FA7xkNLhMrmHGDxdnV08FUde?= =?us-ascii?Q?N9K0jYJhCGPjjCLPE1SxDP8OuU1iVA4kjF0EQUCK3OjzAGSulhU6Q4anAkU0?= =?us-ascii?Q?CToqv//GiY9c2LSBviKTci2iLdjfF8relieShCSSO3gW1yVNqCFNbuORmTyh?= =?us-ascii?Q?xqLc+jAJCKrjc1PJp+XaFvRC3dABknvBEecxtONx7BqunaJqzIhzi5IdqiX5?= =?us-ascii?Q?FY/pgEF4NZ2ZL1rLqlhNuKFRlDUf2fbjFPI5im3AdBhDL8wZ4t8lFRHeaXJ0?= =?us-ascii?Q?gf/KsAW2+zkcyKUxDyl30/mg5VSrL6wC9MsrxNv37KP0pIyfOr5FTvVjgWV+?= =?us-ascii?Q?r+hNbrmvHU5pmDb3ZwEldyHHI1Ubg91JCYKzPlxHpt1VAhcX5ddwU5kbOW0a?= =?us-ascii?Q?yaxUfJ5IfAHNInlwOG1h9SJnf1gkEYbhtOmihM8Ge4odHoJzVryuafOnqiiU?= =?us-ascii?Q?CprmeD9ElMkycH2KYIpWlFbFJjG5YAjYObynjpNRqVLuPYz8hCMzMejPOzB7?= =?us-ascii?Q?9MNTxzfqeF3OFwDuVYTYXnnnv1+vLEd7s6ScAtmwhoUe39vdoKkcfEb2GJWS?= =?us-ascii?Q?BaI/oLioh3XhTutBEGnL27AU7blQJVhLTrj7ogLoLtxGID5B5FbkfwFmkSPI?= =?us-ascii?Q?p4mk8ysMFAJxSygoltM1QzMOWHrH86Ol/wJ3etcSWI8t7BgWTeQS1+0wMMbf?= =?us-ascii?Q?XaPv+X4uv2MRkQLzeH5mBN2NIdlnk3i4ygWAVjHbWBUfqUYqsw=3D=3D?= X-Forefront-Antispam-Report: CIP:178.72.21.4; CTRY:DK; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:localhost.localdomain; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(82310400026)(36860700013)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 3QszJbOQfxRregrdZGpNmTvmhNDRRuv9amc9wa1jUC4SHd06zW9rFUGNG/BRbG5fRiJkatUfFV/NYq9PGtyma2qGruO31bWxtxYyIK48oKxS53vXx86zRuroXER5yJ6lg5aEgKA1zO3TXHpdwEm5Z/q9jPQwFs1fKW/McTgLERFHBIwXAheBdBbyKlePlUnccgtbrvIejgehX7t3XCz5EdApRgQMt3kPGBdPf2NwJ4Ay6ZRqu9ZJnn9kMW1bOwFo/8BJ3+XNzQDhFUf/dIdQvknqsJrC1+2ykZecvpb2l9srUTVoEAUKNWrbkyS4dWLnczSPOGe2AP6aLiOBhTRgmCYoolG4twD7c9LLWQ3OGY5QKyOXOyOjFpmqa+4w4icx3jYCKmuObnonXtX1Zh1dba3c5SRILX0hEz5rwnKD7IAP4TWz9RNUbfi7GFWW1J90HUsajEvhkKnKEqb7A04YOfYiHHW/H+LRX9+LXmYrQNjdG4m8MFhlPnBWrRoJPS7llWO/7WE4GdJwcVwNQxKaNh2xceRF4wGP3S88kCYcTiJEvgwl//NsV7gEFQf25H8FqBJ4lL74/8KqTOO7zFX7m/a7LEc4aOZBpvGDCT3nPYlK5imJxrShvAX2EKRCLnjwSk8iiFVBG7eipiSVlrVfgQ== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2024 09:48:44.2233 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a5cd453e-e603-4033-b03c-08dca257d1b0 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: AM1PEPF000252DD.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P190MB0890 X-BESS-ID: 1720777726-311759-12664-7833-1 X-BESS-VER: 2019.1_20240702.1505 X-BESS-Apparent-Source-IP: 104.47.17.105 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYWpoaWQGYGUNQy1SjF0MTA2M DS0iTJLDklzdjEIs3IxDTFzMzUPDUtTak2FgCRfIThQgAAAA== X-BESS-Outbound-Spam-Score: 0.01 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.257571 [from cloudscan23-119.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound 0.01 BSF_SC7_SG0146_1 META: Custom rule SG0146_1 X-BESS-Outbound-Spam-Status: SCORE=0.01 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND, BSF_SC7_SG0146_1 X-BESS-BRTS-Status: 1 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 Enable FPGA initialization and adds ethdev fw_version_get. Signed-off-by: Serhii Iliushyk --- doc/guides/nics/features/ntnic.ini | 1 + doc/guides/nics/ntnic.rst | 5 + drivers/net/ntnic/adapter/nt4ga_adapter.c | 52 +++- drivers/net/ntnic/meson.build | 7 + .../net/ntnic/nthw/core/include/nthw_core.h | 4 + .../net/ntnic/nthw/core/include/nthw_fpga.h | 22 ++ drivers/net/ntnic/nthw/core/nthw_fpga.c | 222 ++++++++++++++++++ drivers/net/ntnic/nthw/nthw_drv.h | 1 + drivers/net/ntnic/nthw/nthw_register.h | 1 + drivers/net/ntnic/ntnic_ethdev.c | 39 ++- drivers/net/ntnic/ntnic_mod_reg.h | 1 + 11 files changed, 351 insertions(+), 4 deletions(-) create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_fpga.h create mode 100644 drivers/net/ntnic/nthw/core/nthw_fpga.c diff --git a/doc/guides/nics/features/ntnic.ini b/doc/guides/nics/features/ntnic.ini index 9ceb75a03b..03f4d5aac8 100644 --- a/doc/guides/nics/features/ntnic.ini +++ b/doc/guides/nics/features/ntnic.ini @@ -4,5 +4,6 @@ ; Refer to default.ini for the full list of available PMD features. ; [Features] +FW version = Y Linux = Y x86-64 = Y diff --git a/doc/guides/nics/ntnic.rst b/doc/guides/nics/ntnic.rst index 249d83d511..43caf3151d 100644 --- a/doc/guides/nics/ntnic.rst +++ b/doc/guides/nics/ntnic.rst @@ -29,6 +29,11 @@ Supported NICs All information about NT200A02 can be found by link below: https://www.napatech.com/products/nt200a02-smartnic-inline/ +Features +-------- + +- FW version + Limitations ~~~~~~~~~~~ diff --git a/drivers/net/ntnic/adapter/nt4ga_adapter.c b/drivers/net/ntnic/adapter/nt4ga_adapter.c index c9f228a8ed..3b113b9850 100644 --- a/drivers/net/ntnic/adapter/nt4ga_adapter.c +++ b/drivers/net/ntnic/adapter/nt4ga_adapter.c @@ -6,7 +6,7 @@ #include #include "ntlog.h" -#include "nt_util.h" +#include "nthw_fpga.h" #include "ntnic_mod_reg.h" static int nt4ga_adapter_show_info(struct adapter_info_s *p_adapter_info, FILE *pfh) @@ -15,6 +15,7 @@ static int nt4ga_adapter_show_info(struct adapter_info_s *p_adapter_info, FILE * const char *const p_adapter_id_str = p_adapter_info->mp_adapter_id_str; fpga_info_t *p_fpga_info = &p_adapter_info->fpga_info; hw_info_t *p_hw_info = &p_adapter_info->hw_info; + mcu_info_t *mcu_info = &p_adapter_info->fpga_info.mcu_info; char a_pci_ident_str[32]; snprintf(a_pci_ident_str, sizeof(a_pci_ident_str), PCIIDENT_PRINT_STR, @@ -37,7 +38,8 @@ static int nt4ga_adapter_show_info(struct adapter_info_s *p_adapter_info, FILE * fprintf(pfh, "%s: Hw=0x%02X_rev%d: %s\n", p_adapter_id_str, p_hw_info->hw_platform_id, p_fpga_info->nthw_hw_info.hw_id, p_fpga_info->nthw_hw_info.hw_plat_id_str); fprintf(pfh, "%s: MCU Details:\n", p_adapter_id_str); - + fprintf(pfh, "%s: HasMcu=%d McuType=%d McuDramSize=%d\n", p_adapter_id_str, + mcu_info->mb_has_mcu, mcu_info->mn_mcu_type, mcu_info->mn_mcu_dram_size); return 0; } @@ -49,6 +51,13 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info) fpga_info_t *fpga_info = &p_adapter_info->fpga_info; hw_info_t *p_hw_info = &p_adapter_info->hw_info; + /* + * IMPORTANT: Most variables cannot be determined before nthw fpga model is instantiated + * (nthw_fpga_init()) + */ + int n_phy_ports = -1; + int res = -1; + nthw_fpga_t *p_fpga = NULL; p_hw_info->n_nthw_adapter_id = nthw_platform_get_nthw_adapter_id(p_hw_info->pci_device_id); @@ -100,6 +109,39 @@ static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info) } } + res = nthw_fpga_init(&p_adapter_info->fpga_info); + + if (res) { + NT_LOG_DBGX(ERR, NTNIC, "%s: %s: FPGA=%04d res=x%08X\n", p_adapter_id_str, + p_dev_name, fpga_info->n_fpga_prod_id, res); + return res; + } + + assert(fpga_info); + p_fpga = fpga_info->mp_fpga; + assert(p_fpga); + n_phy_ports = fpga_info->n_phy_ports; + assert(n_phy_ports >= 1); + + { + assert(fpga_info->n_fpga_prod_id > 0); + + switch (fpga_info->n_fpga_prod_id) { + default: + NT_LOG(ERR, NTNIC, "Unsupported FPGA product: %04d\n", + fpga_info->n_fpga_prod_id); + res = -1; + break; + } + + if (res) { + NT_LOG_DBGX(ERR, NTNIC, "%s: %s: FPGA=%04d res=x%08X\n", + p_adapter_id_str, p_dev_name, + fpga_info->n_fpga_prod_id, res); + return res; + } + } + return 0; } @@ -107,8 +149,12 @@ static int nt4ga_adapter_deinit(struct adapter_info_s *p_adapter_info) { fpga_info_t *fpga_info = &p_adapter_info->fpga_info; int i; - int res = -1; + int res; + + nthw_fpga_shutdown(&p_adapter_info->fpga_info); + /* Rac rab reset flip flop */ + res = nthw_rac_rab_reset(fpga_info->mp_nthw_rac); /* Free adapter port ident strings */ for (i = 0; i < fpga_info->n_phy_ports; i++) { diff --git a/drivers/net/ntnic/meson.build b/drivers/net/ntnic/meson.build index 5dd1beada2..78f31097ab 100644 --- a/drivers/net/ntnic/meson.build +++ b/drivers/net/ntnic/meson.build @@ -16,6 +16,7 @@ includes = [ include_directories('nthw/core/include'), include_directories('nthw'), include_directories('nthw/supported'), + include_directories('nthw/model'), ] # all sources @@ -24,7 +25,13 @@ sources = files( 'nthw/supported/nthw_fpga_9563_055_039_0000.c', 'nthw/supported/nthw_fpga_instances.c', 'nthw/supported/nthw_fpga_mod_str_map.c', + 'nthw/core/nthw_fpga.c', + 'nthw/core/nthw_hif.c', + 'nthw/core/nthw_iic.c', + 'nthw/core/nthw_pcie3.c', + 'nthw/model/nthw_fpga_model.c', 'nthw/nthw_platform.c', + 'nthw/nthw_rac.c', 'ntlog/ntlog.c', 'ntutil/nt_util.c', 'ntnic_mod_reg.c', diff --git a/drivers/net/ntnic/nthw/core/include/nthw_core.h b/drivers/net/ntnic/nthw/core/include/nthw_core.h index c2602e396f..69af113816 100644 --- a/drivers/net/ntnic/nthw/core/include/nthw_core.h +++ b/drivers/net/ntnic/nthw/core/include/nthw_core.h @@ -11,6 +11,10 @@ #include #include "nthw_platform_drv.h" +#include "nthw_fpga_model.h" +#include "nthw_hif.h" +#include "nthw_pcie3.h" +#include "nthw_iic.h" #endif /* __NTHW_CORE_H__ */ diff --git a/drivers/net/ntnic/nthw/core/include/nthw_fpga.h b/drivers/net/ntnic/nthw/core/include/nthw_fpga.h new file mode 100644 index 0000000000..1943f6e225 --- /dev/null +++ b/drivers/net/ntnic/nthw/core/include/nthw_fpga.h @@ -0,0 +1,22 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#ifndef __NTHW_FPGA_H__ +#define __NTHW_FPGA_H__ + +#include "nthw_drv.h" + +#include "nthw_fpga_model.h" + +#include "nthw_rac.h" +#include "nthw_iic.h" + +int nthw_fpga_init(struct fpga_info_s *p_fpga_info); +int nthw_fpga_shutdown(struct fpga_info_s *p_fpga_info); + +int nthw_fpga_get_param_info(struct fpga_info_s *p_fpga_info, nthw_fpga_t *p_fpga); + + +#endif /* __NTHW_FPGA_H__ */ diff --git a/drivers/net/ntnic/nthw/core/nthw_fpga.c b/drivers/net/ntnic/nthw/core/nthw_fpga.c new file mode 100644 index 0000000000..df238ec4ef --- /dev/null +++ b/drivers/net/ntnic/nthw/core/nthw_fpga.c @@ -0,0 +1,222 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#include "ntlog.h" + +#include "nthw_drv.h" +#include "nthw_register.h" + +#include "nthw_fpga.h" + +#include "nthw_fpga_instances.h" +#include "nthw_fpga_mod_str_map.h" + +#include + +int nthw_fpga_get_param_info(struct fpga_info_s *p_fpga_info, nthw_fpga_t *p_fpga) +{ + mcu_info_t *p_mcu_info = &p_fpga_info->mcu_info; + + const int n_phy_ports = nthw_fpga_get_product_param(p_fpga, NT_PHY_PORTS, -1); + const int n_phy_quads = nthw_fpga_get_product_param(p_fpga, NT_PHY_QUADS, -1); + const int n_rx_ports = nthw_fpga_get_product_param(p_fpga, NT_RX_PORTS, -1); + const int n_tx_ports = nthw_fpga_get_product_param(p_fpga, NT_TX_PORTS, -1); + const int n_vf_offset = nthw_fpga_get_product_param(p_fpga, NT_HIF_VF_OFFSET, 4); + + p_fpga_info->n_phy_ports = n_phy_ports; + p_fpga_info->n_phy_quads = n_phy_quads; + p_fpga_info->n_rx_ports = n_rx_ports; + p_fpga_info->n_tx_ports = n_tx_ports; + p_fpga_info->n_vf_offset = n_vf_offset; + p_fpga_info->profile = FPGA_INFO_PROFILE_UNKNOWN; + + /* Check for MCU */ + if (nthw_fpga_get_product_param(p_fpga, NT_MCU_PRESENT, 0) != 0) { + p_mcu_info->mb_has_mcu = true; + /* Check MCU Type */ + p_mcu_info->mn_mcu_type = nthw_fpga_get_product_param(p_fpga, NT_MCU_TYPE, -1); + /* MCU DRAM size */ + p_mcu_info->mn_mcu_dram_size = + nthw_fpga_get_product_param(p_fpga, NT_MCU_DRAM_SIZE, -1); + + } else { + p_mcu_info->mb_has_mcu = false; + p_mcu_info->mn_mcu_type = -1; + p_mcu_info->mn_mcu_dram_size = -1; + } + + /* Check for VSWITCH FPGA */ + if (nthw_fpga_get_product_param(p_fpga, NT_NFV_OVS_PRODUCT, 0) != 0) { + p_fpga_info->profile = FPGA_INFO_PROFILE_VSWITCH; + + } else if (nthw_fpga_get_product_param(p_fpga, NT_IOA_PRESENT, 0) != 0) { + /* Check for VSWITCH FPGA - legacy */ + p_fpga_info->profile = FPGA_INFO_PROFILE_VSWITCH; + + } else if (nthw_fpga_get_product_param(p_fpga, NT_QM_PRESENT, 0) != 0) { + p_fpga_info->profile = FPGA_INFO_PROFILE_CAPTURE; + + } else { + p_fpga_info->profile = FPGA_INFO_PROFILE_INLINE; + } + + return 0; +} + +int nthw_fpga_init(struct fpga_info_s *p_fpga_info) +{ + const char *const p_adapter_id_str = p_fpga_info->mp_adapter_id_str; + + nthw_hif_t *p_nthw_hif = NULL; + nthw_pcie3_t *p_nthw_pcie3 = NULL; + nthw_rac_t *p_nthw_rac = NULL; + + mcu_info_t *p_mcu_info = &p_fpga_info->mcu_info; + uint64_t n_fpga_ident = 0; + nthw_fpga_mgr_t *p_fpga_mgr = NULL; + nthw_fpga_t *p_fpga = NULL; + + char s_fpga_prod_ver_rev_str[32] = { 0 }; + + int res = 0; + + assert(p_fpga_info); + + { + const uint64_t n_fpga_ident = nthw_fpga_read_ident(p_fpga_info); + const uint32_t n_fpga_build_time = nthw_fpga_read_buildtime(p_fpga_info); + const int n_fpga_type_id = nthw_fpga_extract_type_id(n_fpga_ident); + const int n_fpga_prod_id = nthw_fpga_extract_prod_id(n_fpga_ident); + const int n_fpga_ver_id = nthw_fpga_extract_ver_id(n_fpga_ident); + const int n_fpga_rev_id = nthw_fpga_extract_rev_id(n_fpga_ident); + + p_fpga_info->n_fpga_ident = n_fpga_ident; + p_fpga_info->n_fpga_type_id = n_fpga_type_id; + p_fpga_info->n_fpga_prod_id = n_fpga_prod_id; + p_fpga_info->n_fpga_ver_id = n_fpga_ver_id; + p_fpga_info->n_fpga_rev_id = n_fpga_rev_id; + p_fpga_info->n_fpga_build_time = n_fpga_build_time; + + snprintf(s_fpga_prod_ver_rev_str, sizeof(s_fpga_prod_ver_rev_str), + "%04d-%04d-%02d-%02d", n_fpga_type_id, n_fpga_prod_id, n_fpga_ver_id, + n_fpga_rev_id); + + NT_LOG(INF, NTHW, "%s: FPGA %s (%" PRIX64 ") [%08X]\n", p_adapter_id_str, + s_fpga_prod_ver_rev_str, n_fpga_ident, n_fpga_build_time); + } + + n_fpga_ident = p_fpga_info->n_fpga_ident; + + p_fpga_mgr = nthw_fpga_mgr_new(); + nthw_fpga_mgr_init(p_fpga_mgr, nthw_fpga_instances, + (const void *)sa_nthw_fpga_mod_str_map); + nthw_fpga_mgr_log_dump(p_fpga_mgr); + p_fpga = nthw_fpga_mgr_query_fpga(p_fpga_mgr, n_fpga_ident, p_fpga_info); + p_fpga_info->mp_fpga = p_fpga; + + if (p_fpga == NULL) { + NT_LOG(ERR, NTHW, "%s: Unsupported FPGA: %s (%08X)\n", p_adapter_id_str, + s_fpga_prod_ver_rev_str, p_fpga_info->n_fpga_build_time); + return -1; + } + + if (p_fpga_mgr) { + nthw_fpga_mgr_delete(p_fpga_mgr); + p_fpga_mgr = NULL; + } + + /* Read Fpga param info */ + nthw_fpga_get_param_info(p_fpga_info, p_fpga); + + /* debug: report params */ + NT_LOG(DBG, NTHW, "%s: NT_PHY_PORTS=%d\n", p_adapter_id_str, p_fpga_info->n_phy_ports); + NT_LOG(DBG, NTHW, "%s: NT_PHY_QUADS=%d\n", p_adapter_id_str, p_fpga_info->n_phy_quads); + NT_LOG(DBG, NTHW, "%s: NT_RX_PORTS=%d\n", p_adapter_id_str, p_fpga_info->n_rx_ports); + NT_LOG(DBG, NTHW, "%s: NT_TX_PORTS=%d\n", p_adapter_id_str, p_fpga_info->n_tx_ports); + NT_LOG(DBG, NTHW, "%s: nProfile=%d\n", p_adapter_id_str, (int)p_fpga_info->profile); + NT_LOG(DBG, NTHW, "%s: bHasMcu=%d\n", p_adapter_id_str, p_mcu_info->mb_has_mcu); + NT_LOG(DBG, NTHW, "%s: McuType=%d\n", p_adapter_id_str, p_mcu_info->mn_mcu_type); + NT_LOG(DBG, NTHW, "%s: McuDramSize=%d\n", p_adapter_id_str, p_mcu_info->mn_mcu_dram_size); + + p_nthw_rac = nthw_rac_new(); + + if (p_nthw_rac == NULL) { + NT_LOG(ERR, NTHW, "%s: Unsupported FPGA: RAC is not found: %s (%08X)\n", + p_adapter_id_str, s_fpga_prod_ver_rev_str, p_fpga_info->n_fpga_build_time); + return -1; + } + + nthw_rac_init(p_nthw_rac, p_fpga, p_fpga_info); + nthw_rac_rab_flush(p_nthw_rac); + p_fpga_info->mp_nthw_rac = p_nthw_rac; + + switch (p_fpga_info->n_nthw_adapter_id) { + default: + NT_LOG(ERR, NTHW, "%s: Unsupported HW product id: %d\n", p_adapter_id_str, + p_fpga_info->n_nthw_adapter_id); + res = -1; + break; + } + + if (res) { + NT_LOG(ERR, NTHW, "%s: status: 0x%08X\n", p_adapter_id_str, res); + return res; + } + + res = nthw_pcie3_init(NULL, p_fpga, 0); /* Probe for module */ + + if (res == 0) { + p_nthw_pcie3 = nthw_pcie3_new(); + + if (p_nthw_pcie3) { + res = nthw_pcie3_init(p_nthw_pcie3, p_fpga, 0); + + if (res == 0) { + NT_LOG(DBG, NTHW, "%s: Pcie3 module found\n", p_adapter_id_str); + nthw_pcie3_trigger_sample_time(p_nthw_pcie3); + + } else { + nthw_pcie3_delete(p_nthw_pcie3); + p_nthw_pcie3 = NULL; + } + } + + p_fpga_info->mp_nthw_pcie3 = p_nthw_pcie3; + } + + if (p_nthw_pcie3 == NULL) { + p_nthw_hif = nthw_hif_new(); + + if (p_nthw_hif) { + res = nthw_hif_init(p_nthw_hif, p_fpga, 0); + + if (res == 0) { + NT_LOG(DBG, NTHW, "%s: Hif module found\n", p_adapter_id_str); + nthw_hif_trigger_sample_time(p_nthw_hif); + + } else { + nthw_hif_delete(p_nthw_hif); + p_nthw_hif = NULL; + } + } + } + + p_fpga_info->mp_nthw_hif = p_nthw_hif; + + + return res; +} + +int nthw_fpga_shutdown(struct fpga_info_s *p_fpga_info) +{ + int res = -1; + + if (p_fpga_info) { + if (p_fpga_info && p_fpga_info->mp_nthw_rac) + res = nthw_rac_rab_reset(p_fpga_info->mp_nthw_rac); + } + + return res; +} diff --git a/drivers/net/ntnic/nthw/nthw_drv.h b/drivers/net/ntnic/nthw/nthw_drv.h index d7cd64bb1d..071618eb6e 100644 --- a/drivers/net/ntnic/nthw/nthw_drv.h +++ b/drivers/net/ntnic/nthw/nthw_drv.h @@ -22,6 +22,7 @@ enum fpga_info_profile { }; typedef struct mcu_info_s { + bool mb_has_mcu; int mn_mcu_type; int mn_mcu_dram_size; } mcu_info_t; diff --git a/drivers/net/ntnic/nthw/nthw_register.h b/drivers/net/ntnic/nthw/nthw_register.h index db006fcf72..ecc661a656 100644 --- a/drivers/net/ntnic/nthw/nthw_register.h +++ b/drivers/net/ntnic/nthw/nthw_register.h @@ -11,6 +11,7 @@ #include #include +#include "nthw_fpga_model.h" #include "fpga_model.h" diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c index ab4b66f4a3..10b3c803ae 100644 --- a/drivers/net/ntnic/ntnic_ethdev.c +++ b/drivers/net/ntnic/ntnic_ethdev.c @@ -178,12 +178,33 @@ eth_dev_close(struct rte_eth_dev *eth_dev) return 0; } +static int +eth_fw_version_get(struct rte_eth_dev *eth_dev, char *fw_version, size_t fw_size) +{ + struct pmd_internals *internals = (struct pmd_internals *)eth_dev->data->dev_private; + + fpga_info_t *fpga_info = &internals->p_drv->ntdrv.adapter_info.fpga_info; + const int length = snprintf(fw_version, fw_size, "%03d-%04d-%02d-%02d", + fpga_info->n_fpga_type_id, fpga_info->n_fpga_prod_id, + fpga_info->n_fpga_ver_id, fpga_info->n_fpga_rev_id); + + if ((size_t)length < fw_size) { + /* We have space for the version string */ + return 0; + + } else { + /* We do not have space for the version string -return the needed space */ + return length + 1; + } +} + static struct eth_dev_ops nthw_eth_dev_ops = { .dev_configure = eth_dev_configure, .dev_start = eth_dev_start, .dev_stop = eth_dev_stop, .dev_close = eth_dev_close, .dev_infos_get = eth_dev_infos_get, + .fw_version_get = eth_fw_version_get, }; static int @@ -200,6 +221,7 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) struct drv_s *p_drv; ntdrv_4ga_t *p_nt_drv; + fpga_info_t *fpga_info; hw_info_t *p_hw_info; (void)p_hw_info; uint32_t n_port_mask = -1; /* All ports enabled by default */ @@ -233,6 +255,7 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) /* context */ p_nt_drv = &p_drv->ntdrv; + fpga_info = &p_nt_drv->adapter_info.fpga_info; p_hw_info = &p_nt_drv->adapter_info.hw_info; p_drv->p_dev = pci_dev; @@ -243,6 +266,11 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) p_nt_drv->adapter_info.n_rx_host_buffers = nb_rx_queues; p_nt_drv->adapter_info.n_tx_host_buffers = nb_tx_queues; + fpga_info->bar0_addr = (void *)pci_dev->mem_resource[0].addr; + fpga_info->bar0_size = pci_dev->mem_resource[0].len; + fpga_info->numa_node = pci_dev->device.numa_node; + fpga_info->pciident = p_nt_drv->pciident; + fpga_info->adapter_no = p_drv->adapter_no; p_nt_drv->adapter_info.hw_info.pci_class_id = pci_dev->id.class_id; p_nt_drv->adapter_info.hw_info.pci_vendor_id = pci_dev->id.vendor_id; @@ -279,6 +307,15 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) /* mp_adapter_id_str is initialized after nt4ga_adapter_init(p_nt_drv) */ const char *const p_adapter_id_str = p_nt_drv->adapter_info.mp_adapter_id_str; (void)p_adapter_id_str; + NT_LOG(DBG, NTNIC, + "%s: %s: AdapterPCI=" PCIIDENT_PRINT_STR " Hw=0x%02X_rev%d PhyPorts=%d\n", + (pci_dev->name[0] ? pci_dev->name : "NA"), p_adapter_id_str, + PCIIDENT_TO_DOMAIN(p_nt_drv->adapter_info.fpga_info.pciident), + PCIIDENT_TO_BUSNR(p_nt_drv->adapter_info.fpga_info.pciident), + PCIIDENT_TO_DEVNR(p_nt_drv->adapter_info.fpga_info.pciident), + PCIIDENT_TO_FUNCNR(p_nt_drv->adapter_info.fpga_info.pciident), + p_hw_info->hw_platform_id, fpga_info->nthw_hw_info.hw_id, + fpga_info->n_phy_ports); } else { NT_LOG_DBGX(ERR, NTNIC, "%s: error=%d\n", @@ -286,7 +323,7 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) return -1; } - n_phy_ports = 0; + n_phy_ports = fpga_info->n_phy_ports; for (int n_intf_no = 0; n_intf_no < n_phy_ports; n_intf_no++) { const char *const p_port_id_str = p_nt_drv->adapter_info.mp_port_id_str[n_intf_no]; diff --git a/drivers/net/ntnic/ntnic_mod_reg.h b/drivers/net/ntnic/ntnic_mod_reg.h index 48a9f8f7b9..96fc829399 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.h +++ b/drivers/net/ntnic/ntnic_mod_reg.h @@ -7,6 +7,7 @@ #define __NTNIC_MOD_REG_H__ #include +#include "nthw_fpga_model.h" #include "nthw_platform_drv.h" #include "nthw_drv.h" #include "nt4ga_adapter.h" -- 2.45.0