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 C9B1C45635; Wed, 17 Jul 2024 15:35:26 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1712942DC3; Wed, 17 Jul 2024 15:33:46 +0200 (CEST) Received: from egress-ip11a.ess.de.barracuda.com (egress-ip11a.ess.de.barracuda.com [18.184.203.234]) by mails.dpdk.org (Postfix) with ESMTP id 242E440EDC for ; Wed, 17 Jul 2024 15:33:30 +0200 (CEST) Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02lp2104.outbound.protection.outlook.com [104.47.11.104]) by mx-outbound40-186.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 17 Jul 2024 13:33:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rP9p11ns8RkSqbAEeMYpfks9Z3leHRHu7DEVXDUXU/ITa/tkrHxUDEd8KFcVsNVPFn4MMCD7RYBLtI3KG+MgWT8IkBxvn2bkb+51YQftd6Be9FN5u+nXDKrKIeyw3SPFAGoL8OCIAjX1oq/nDwSatzu3kzxRsWTAEvh8J8Z+wS5rLZ7B0XIX0G0JdvHRfK2nOKn52t0BBUFHpEQ6lXCBeC5qlRkuqvdD2BH8tQT7rbGf8AvQumGUGkgRwP3qh+4O9gxx3i49MijcP7zk8vCxRTzceUJ+Is1cEAFKvzQEFqOUbqv7btjlD2YYvWrJ0+Se3ry9p3m0BBBmi8Ze3LnAOQ== 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=PYJli9fb2dbx6KRraCrv2810EXUQbPjfBoQ6n0wcUaY=; b=mtFvZF6v8HZ5o+uoDP/iKm5ipfPSK/zpFxeZSo0NFUhP7DZWA9LEL+34o7KayAJxyUBH/byLKnCJ4JG7WGrAtnY9cVazx3pWKiUK6248dn6fZRbDPPIeslHpAEgb+7MJOd9Jb3XD7RDB+DV5tC1b+LTVB8ScTk46EM0vP0hRfzfQlrJqvbh6C+dNoT7WgPuCyDbkAcnY7sFLFDiyl0nyHyZpmCZUS+lImqWXsrm7ATX1Zz/CvC91sKGS1+ZERQgy2Bv3DiN5UUjkf+5do5Dwbt0cKfz/l+SZZXo4fbTgu4qoQYvheaLtaAQmcBtIm/gXBPhResjAy3/u2IcaFLZzzg== 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=PYJli9fb2dbx6KRraCrv2810EXUQbPjfBoQ6n0wcUaY=; b=G4Z2DkIxx4DbGD8/n/lD17LmbDotC2yMdXMnayb1VFO2bomVS3iNAmkHu8S7ksdsXBfZBF/w7IU6uVN+IcHsc/P0uNA11rFHF91Ql37fTtJPIjOYNAj838gitYCnl+rG3yJqbEg8klSlkDIKRpjXolOFraEKa9N0+Zdg7C0Rlfg= Received: from AM0PR04CA0102.eurprd04.prod.outlook.com (2603:10a6:208:be::43) by AM8P190MB0929.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:1c5::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.14; Wed, 17 Jul 2024 13:33:23 +0000 Received: from AM3PEPF0000A799.eurprd04.prod.outlook.com (2603:10a6:208:be:cafe::b1) by AM0PR04CA0102.outlook.office365.com (2603:10a6:208:be::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.16 via Frontend Transport; Wed, 17 Jul 2024 13:33:23 +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 AM3PEPF0000A799.mail.protection.outlook.com (10.167.16.104) with Microsoft SMTP Server id 15.20.7784.11 via Frontend Transport; Wed, 17 Jul 2024 13:33:23 +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 v10 11/21] net/ntnic: add FPGA initialization functionality Date: Wed, 17 Jul 2024 15:32:58 +0200 Message-ID: <20240717133313.3104239-11-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240717133313.3104239-1-sil-plv@napatech.com> References: <20240530144929.4127931-1-sil-plv@napatech.com> <20240717133313.3104239-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM3PEPF0000A799:EE_|AM8P190MB0929:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: aa4bd8ad-8602-4a65-0caa-08dca665080c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?xa3FF5b1quc1Ko/kvhpFKanKjxQzRYVKbq0qxWQQvIQYTH/qT2RT/2AQaU0J?= =?us-ascii?Q?GVXYuiZH5l84IeoZeEoLM7BeHSHmaUXDk9+jzrDZhPExVC83O9woyl+vSiB1?= =?us-ascii?Q?swI5bUQDeaIptcFMVmFlFv3sZeJN2Ercxc+LHFnL0MHLrVG76n5PHMJ5BhZB?= =?us-ascii?Q?H1GTKY3rdXKLZe+jKXnLAg962DMbjXT/QnGwB768vzpfgsPoDFIy+MZHfF4q?= =?us-ascii?Q?/2GbNcUbcSfLm/P3I/lSri942+MgvAXY68yzKXaCsmKVMLRiBgBptwavsNUR?= =?us-ascii?Q?8lIolr9LFs5/pXHUQiCG420U5Y1jTaL41zLB+lsApp+NonyOr3/KxSsHB35O?= =?us-ascii?Q?HV8IRffDh8iEiPGSgBWe+lDFHZXk1qQEDXLc8n4TXajjlXDnWdmjxJv16w9p?= =?us-ascii?Q?XcX+nUBBVK+SvaxyFnnU5qfL/nWF2Buqtxo/9lzcohB/YcC+Fj72VXJ9Z9YC?= =?us-ascii?Q?HAM0ZixVuztNghvksmx/wtZqF0o33Uql/9YSren+VVmKkVQcQrbX7ZCXnylT?= =?us-ascii?Q?UN7KcwZpT4AqQhXWbyp3dsirlsOjvBaTjxy8SQ4wWG/PnDmfJMFDd1dzj/Pi?= =?us-ascii?Q?N5elMeJKuPi/I3SD4Wz99c9OGiGZPnt69TmPrDZKTY8dHU+g62RmZgayKAlh?= =?us-ascii?Q?Dt/XzisXEGPmAJwTv2lRvtmkFrNTyEgPO+vih9YcXhxK5kcCC1SVOibhmYGR?= =?us-ascii?Q?5IgJOXJvNTHIaEGwGySkhTueifcNDVer1DbZv7rzZ7UGZ2+QwXxYTfQKoRQU?= =?us-ascii?Q?sAlyS4tR6sZrOE+mf7Cl+G6R7Y7LTm2zFcm6XViLD8auXGWBlgQCIfk1Fm7U?= =?us-ascii?Q?IGAhFZBmHkiyPjPj2ieXP6aR7vBw7AVlM6MZ2lqiLI4/b6ARKDGkvb05m1I1?= =?us-ascii?Q?aRzTYDVQIXJtOK44ch6lK6xwbVoYglDokPA+Q+PgJjsL8+ZVVsp1BoD1TEax?= =?us-ascii?Q?zdooUdPozBz9RZo4ZO1yhRppGGvIYalGXR7f5W8RKDb6WqJWNB+8q6U1gcSo?= =?us-ascii?Q?n9fhXLwpa15vmnvNXBlY3lnJGcDu4/7qHlwig8pvEZVKZ5sF7C5djhgWMbZH?= =?us-ascii?Q?8+pDAofhhhC7UGyRK9FM1hr2DHGfhn1dI+02BiM5YxRqy6JVQjlbR/G+xb5S?= =?us-ascii?Q?KId4PlMPfMHa+Jbh4lTktjW5zxJDMtVVxURs4JVv/XfufNXb2ZGihqpOzCoD?= =?us-ascii?Q?StOxIcrfy87qp7f/PQc2SCtxQOBrbvP0iVYWh89SXlS69vwMB8t5Kw7D1+Qy?= =?us-ascii?Q?YapQtMdWEBnuL8l/FhMOFzCYRkm3UizmAfgsdHF7rpPowyuW04PTAQp+IB5g?= =?us-ascii?Q?Eia7IMkoT/GyDYtxB0W3gTDwWMY/OFScuSyGDk0zkzma9JxI/cLkg9x7mtd7?= =?us-ascii?Q?5kWOwfILjXLeNqmcVUOXUadlKpbiH52Yd9N2fY7Xo39SOn0dFQ=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)(1800799024)(36860700013)(376014)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 1aLlk7TCkvGpV3yQ65nsAmjAtkIj9C1vhZk//htFb23plZGxOu+4wKdPB//89i1Nu4ITh64uCqmU6CJ+3sz04hoMF6DuKZOAeiYLUgbU7DKUQ+gj71Oz1wU+0M9+klme9ai3CX9b16KRQ0WfPb1sVR85YuXW6IctAfwofYFwjBRy/oNq4LT+Cds3w/fBqanTh9NEJWXfw4/mR1n/0uUDYwmit5pzj8rXP9MXhUO1p1Q3//P8sqp9lO46wMvOFUqkId29SU/taVZDgJnqCaRsoXNAEnd3FJAC/y/8bMRlgC30Hxz7e+3CJ8xN2VNxl7+xKKWPInGsukCYtb3PkbhG2Le9YbiaOcxnE6hC3hdpSs5QgLYk9Smq6064lXwwkaD5Q+7GK7KoEfb6Sj+kgMNMsXuqTmcpY11WBfep4ulQ/OJJnjcEKudGEFI6LO99ajAFfNo9i8AULtrzMeSsAhJbFm4HukZYAh7jeT8cuhl8zTuudGr4I8/g9MQ5Ns/UWXkYbNjlXA9ZUHN+u+gK2pUXmhvgOr7m09RYBdA4r/ZSheiUBgmnPN95dN/SyQ4zBkWBbreWPHdQ9RUpjbyG1+9i+ITvsQm9KEtecfg68WZx7ybUbDfz5kgKqwTE/fX05cR10HZ63lZN/tRDUhZJpvtnng== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2024 13:33:23.5276 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aa4bd8ad-8602-4a65-0caa-08dca665080c 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: AM3PEPF0000A799.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8P190MB0929 X-BESS-ID: 1721223208-310426-12657-15018-1 X-BESS-VER: 2019.1_20240716.1757 X-BESS-Apparent-Source-IP: 104.47.11.104 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYWZpbmQGYGUDQp1TwxLTXV2M zSKNko0dTE3DAlzdA8Nck0NSk5MSkpSak2FgAkOcaWQgAAAA== X-BESS-Outbound-Spam-Score: 0.01 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.257687 [from cloudscan21-11.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 --- v5 * Fix Typo/Spelling v7 * Add FW update feature to documentation - INI and RST files v10 * Use 8 spaces as indentation in meson --- doc/guides/nics/features/ntnic.ini | 1 + doc/guides/nics/ntnic.rst | 5 + drivers/net/ntnic/adapter/nt4ga_adapter.c | 49 +++- 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 | 41 +++- drivers/net/ntnic/ntnic_mod_reg.h | 1 + 11 files changed, 352 insertions(+), 2 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 b150fe1481..db168e1686 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 42b3a98d21..381884349b 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,6 +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; } @@ -48,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); @@ -99,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; } @@ -108,6 +151,10 @@ static int nt4ga_adapter_deinit(struct adapter_info_s *p_adapter_info) int i; int res = -1; + 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 a3522ca20b..74d4f12425 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 5d154c8e38..b68fcba25b 100644 --- a/drivers/net/ntnic/ntnic_ethdev.c +++ b/drivers/net/ntnic/ntnic_ethdev.c @@ -175,12 +175,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 const 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 @@ -197,6 +218,8 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) struct drv_s *p_drv; ntdrv_4ga_t *p_nt_drv; + hw_info_t *p_hw_info; + fpga_info_t *fpga_info; uint32_t n_port_mask = -1; /* All ports enabled by default */ uint32_t nb_rx_queues = 1; uint32_t nb_tx_queues = 1; @@ -228,6 +251,8 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev) /* context */ p_nt_drv = &p_drv->ntdrv; + p_hw_info = &p_nt_drv->adapter_info.hw_info; + fpga_info = &p_nt_drv->adapter_info.fpga_info; p_drv->p_dev = pci_dev; @@ -237,6 +262,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; @@ -273,6 +303,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", @@ -280,7 +319,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.43.0