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 D292444111; Thu, 30 May 2024 16:52:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1EE7D42D89; Thu, 30 May 2024 16:50:21 +0200 (CEST) Received: from egress-ip42a.ess.de.barracuda.com (egress-ip42a.ess.de.barracuda.com [18.185.115.201]) by mails.dpdk.org (Postfix) with ESMTP id 6EEF942D92 for ; Thu, 30 May 2024 16:50:16 +0200 (CEST) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04lp2045.outbound.protection.outlook.com [104.47.14.45]) by mx-outbound15-68.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 30 May 2024 14:50:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XPFOUvHjanJdJCd9+7AJYHhRA/dhw4NYuXOKusUPDj0ZgwXbd5E2QVMKVFnMk/c1OcZK3IY1vY7VxXUmR+pbrYkLcOWMjgdLtKw7NQCDpJn3Eh29eYAfwKYKDUUJIMdw1KK5pIz0FoAU3O20FhGd0UAqBz8RU9YE97rHruNl7J9FpRePSPHM45JxLGJ8YeYDoTtTufE0MAJQUv7fk+tKzgG2s3t8pR4BlwQmnnTFA+Sj5/crGPJ+hnbGDb51mK1a0n0F7QLAhlZM5y7y6s8ceDjeKSIbF0Y55IKyuOsXCbrJJkFS5O5T44LM7rsSZn+QbYomzYzD1J4GYO+mvfJ0+g== 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=Q8wlZ79l3S4VkDAt3yP00QLDd7KtGsrwmez/0UtigC0=; b=bXndO/8564Epf+eI/gciZLgbmCFxsZHCAqtqOFjjfKq8gu84zTlQWgARGyV0IaUDC13bhJRFZDVaFBCXEsmEpeTJ7HIsACpyi33E40+BrPI9pl6+xKbyATcnYp6EmNXXM/jronxUW+CORsn5Zgz8zXmtTf1Bdz3xiGxNzIoJTwx+TMmxjNAjiQ6F+l/2Aw3Pxh4s8fvtKrp0VddSHxz0vPUeLctuNKWuXU9ZdN4QDWkh2JyGIoI0VDoa1dpaop4phPLxLxeme778q2xljr+tdTrbGrQuq7FqxOKxZqSuc5W7KGjxVSk7NnZ6mstv0tmM4/768+6a98YfSbKGBDtSNw== 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=Q8wlZ79l3S4VkDAt3yP00QLDd7KtGsrwmez/0UtigC0=; b=cGZI6r2uusXxLwBgXWcHdJRr/T4Bnl7M7s2xS8Z159j6kQ6/C8quxstDtxgP9Q7WwtiSBeTQ/y7A/KNtdbd/QDr2LNMFli00gIjPI4xMe4LLQmgVHUT6ZaoJMvV8dvu//sugQH4Tah2hvEheKlRtmtwWH4686V1x4S1Cws0ZEoE= Received: from DU6P191CA0037.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:53f::16) by DBAP190MB0934.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:1ac::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Thu, 30 May 2024 14:50:03 +0000 Received: from DB1PEPF000509EB.eurprd03.prod.outlook.com (2603:10a6:10:53f:cafe::ee) by DU6P191CA0037.outlook.office365.com (2603:10a6:10:53f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21 via Frontend Transport; Thu, 30 May 2024 14:50:03 +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 DB1PEPF000509EB.mail.protection.outlook.com (10.167.242.69) with Microsoft SMTP Server id 15.20.7633.15 via Frontend Transport; Thu, 30 May 2024 14:50:03 +0000 From: Serhii Iliushyk To: dev@dpdk.org Cc: mko-plv@napatech.com, ckm@napatech.com, andrew.rybchenko@oktetlabs.ru, ferruh.yigit@amd.com Subject: [PATCH v1 14/17] net/ntnic: add adapter initialization API Date: Thu, 30 May 2024 16:49:11 +0200 Message-ID: <20240530144929.4127931-14-sil-plv@napatech.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240530144929.4127931-1-sil-plv@napatech.com> References: <20240530144929.4127931-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB1PEPF000509EB:EE_|DBAP190MB0934:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 3dea0e7f-3b4b-4da0-9f46-08dc80b7ca13 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|82310400017|36860700004|376005|1800799015; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?S5Wm+UlZJO6WpZXri0uNnWtDQBzYGbPSKHBzL99Xa3e/PbR6/hDfU+u4AX3d?= =?us-ascii?Q?2FeS580c5cZq63L5QgLOT57/dxLQF734gcQ5c7qzWbPytanKnfx8eeL5AX3v?= =?us-ascii?Q?ZftgWefDlBIUU29rkUyEbSQ5dOGiaN7kKf6gCzQM6SOMUpcgCjcGJe+wcGQa?= =?us-ascii?Q?1sEIlsO86a0ZOr+Qfz7j2hRX9P6tSuPZ6qZ3Gr0yLQ6sfbCLHm/igOsMUL8X?= =?us-ascii?Q?zTO0PfebtWQGR6nVY1ZwHC8s9RtSEjR6Xcq6HL+TJeOuDVap18vimei2Ugg8?= =?us-ascii?Q?b2RduMlenmOgR0GAyMMKEzgbHGtm87hKVQ/zzTjSzgqRElZ9H+tCoYvi2NYo?= =?us-ascii?Q?+QXsPqDo8vyTwKvmIP7hQsL4h8TRg9o1DDh7LsLnLSzruvfbQEREH7aO1Orq?= =?us-ascii?Q?D64Ls0w7WA4G5GGDcMdurLtR2SqI9NJvn6eZFDd8w8XRqYovptCDpbNQI/sa?= =?us-ascii?Q?ZUqomfdNmrdi8MFlgATehGeC9IE38hKAf9IrxqeMrJUKio65t+5UGMRPRA5X?= =?us-ascii?Q?SddIyFUN16BOD/mvCiRC90PhcYHgad0hYDrDPlr3I6VuT4MxpLxIkY13hif7?= =?us-ascii?Q?ZsK9YVqoGw1vuQybkGsgKyl3Py2okEQaP143mErINQmjQBiAVvJMX0QP3UJO?= =?us-ascii?Q?KOlGrfGMohNd0S1y+Xziyc8ctT1FeZFL3n13YX7ISDfM5WNzUHGycKYd5ikr?= =?us-ascii?Q?NH2tytOKZkIj/iJysDkWCMWO1S1r6BL+ZFHXyZ8+m5K+XLEtqFgXN7NcMj9d?= =?us-ascii?Q?SZiSd/Z+7Pcn7xm9V+eZtiLueV3JS84zTe+iG5yq+okY/s1RFrfvPT5zjJEz?= =?us-ascii?Q?xXa6YeYVO9+PoXLxJ2SVRusa+oS5JBuo1vPo5VK1eFZ2EpM1MQ2ArOh90qaE?= =?us-ascii?Q?Cnsq5Y97aUhYavsb1rVGcE1fVFZJVvRh9yCkwp6CTRa5OZ71jQbvifybuOFM?= =?us-ascii?Q?fdUYdK7osiDsIjaEZ/5B3JUH0SinWWZP++MckQIv0gXFl8nS+WGoaCQEfkCE?= =?us-ascii?Q?hapKWx8Fwca0L8HxHU3OvlsRqiDWWjLNxZMcf78dj5dw0ZQHXNmvEUtdaDVP?= =?us-ascii?Q?WqpGK0PZhgkQKOlyrauw/6FdYy6TCurTgJb4pSpEDfnOtnI6zCZhH0Gq5g3x?= =?us-ascii?Q?iQ+6W4OuDlvGTglmMSkKpbYOMi5yboB7M6J6d+ozeuC92Al48s949nOIWuLg?= =?us-ascii?Q?b//0QcmT4Rsb3Hj/+Op8sOIoyEBNgvTgOncCl2Se2sQ6XWdH79IUd0BfWlCo?= =?us-ascii?Q?AQTbKf4aLHkRal8j808ZNUXa8O6sxBIWtnmCg9wq7OaLQbbwjDNnzPMS3XBM?= =?us-ascii?Q?Nur9LChKX2WE0GOAkdXJfP00PytLbAaARLRwJUe3V0dpXIB/gV1rWQqOsu2i?= =?us-ascii?Q?BjbpjKg=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:(13230031)(82310400017)(36860700004)(376005)(1800799015); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: DHurSD1PzL86toq4Qa6jo+q/gznU4X66x5Ts5tW7S9W1RuftUGbCSKTMEfjio0F5PBaDL/yb873CilkPmZv7V56ijnuZKEqlZMEpqt/HpCPqFViesFOHpmh6/XhwB9Z+X7JFQxI+UWblDG/KjVV0E3cEa8YWVw1DQVC4NgI3IHrk7AH6Hj4siF1kn14dsd/0pUnlQjx91VygBtl2GXxD21+hellve5YEKbtaIZV/dvT7oXr/uD+pXAfusswBYjGhUzE/yTbzu/FyfuAHuMbzLazJmKXvF3lqmlODyIFzBh4T6ft6+C3IMlDp2NTDMY4w5Q0mVXQuYd5ZhZWi9gfbU2ySNR64dZ6PLRU4o9iolPNnOtgRVE4jRJx7Xp61BXoGVVOhvOwp1dDoXHD1hk6vYvI+QwhLsYBhEx0OsT7hSNM8FbTuKqaANWMWpqGlfEI1XOL9MqbAG8mce1UcR+7TnxgANPWRnyuWvjoDjKAVcQ9IMBZHUlptMxD1vl3kAMjyOGQZQRgYJQvX5TXiTNumoqudWHm8b1I9tDQ3pDaYy7sjXOw98fs6roUHGY3ZR+uEdEKEqbxaQSDZVXYEtP3+Bt44AAXmhUnrxqP4z8wxE4gBxslIj4Hwo4piPD04y78uWTvJ2jW2oHIbT6Ib0cYVNg== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2024 14:50:03.4921 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3dea0e7f-3b4b-4da0-9f46-08dc80b7ca13 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: DB1PEPF000509EB.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAP190MB0934 X-BESS-ID: 1717080605-303908-12706-38396-2 X-BESS-VER: 2019.1_20240429.2309 X-BESS-Apparent-Source-IP: 104.47.14.45 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoZmBgZmQGYGUDTVzNzYJMU8xS wpKTXV0MDEOMkiJdHUxNLEKDnV0NTERKk2FgAb+MGLQgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256603 [from cloudscan13-204.eu-central-1a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE7568M META: Custom Rule 7568M 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.50 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_RULE7568M, BSF_BESS_OUTBOUND 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 Add ntnic adapter initialization API. Signed-off-by: Serhii Iliushyk --- drivers/net/ntnic/adapter/nt4ga_adapter.c | 496 ++++++++++++++++++++++ drivers/net/ntnic/meson.build | 1 + 2 files changed, 497 insertions(+) create mode 100644 drivers/net/ntnic/adapter/nt4ga_adapter.c diff --git a/drivers/net/ntnic/adapter/nt4ga_adapter.c b/drivers/net/ntnic/adapter/nt4ga_adapter.c new file mode 100644 index 0000000000..6147481f3a --- /dev/null +++ b/drivers/net/ntnic/adapter/nt4ga_adapter.c @@ -0,0 +1,496 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#include "ntlog.h" + +#include "nthw_drv.h" +#include "nthw_fpga.h" +#include "nthw_register.h" +#include "nt4ga_adapter.h" +#include "nt4ga_pci_ta_tg.h" +#include "ntnic_mod_reg.h" + +#include "flow_filter.h" + +static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info); +static int nt4ga_adapter_deinit(struct adapter_info_s *p_adapter_info); + +static int nt4ga_adapter_show_info(struct adapter_info_s *p_adapter_info, FILE *pfh); + +/* + * Global variables shared by NT adapter types + */ +pthread_t monitor_tasks[NUM_ADAPTER_MAX]; +volatile int monitor_task_is_running[NUM_ADAPTER_MAX]; + +/* + * Signal-handler to stop all monitor threads + */ +static void stop_monitor_tasks(int signum) +{ + const size_t N = ARRAY_SIZE(monitor_task_is_running); + size_t i; + + /* Stop all monitor tasks */ + for (i = 0; i < N; i++) { + const int is_running = monitor_task_is_running[i]; + monitor_task_is_running[i] = 0; + + if (signum == -1 && is_running != 0) { + void *ret_val = NULL; + pthread_join(monitor_tasks[i], &ret_val); + memset(&monitor_tasks[i], 0, sizeof(monitor_tasks[0])); + } + } +} + +static int nt4ga_adapter_show_info(struct adapter_info_s *p_adapter_info, FILE *pfh) +{ + const char *const p_dev_name = p_adapter_info->p_dev_name; + 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]; + const struct nt4ga_stat_ops *nt4ga_stat_ops = get_nt4ga_stat_ops(); + + if (nt4ga_stat_ops != NULL) + nt4ga_stat_ops->nt4ga_stat_dump(p_adapter_info, pfh); + + snprintf(a_pci_ident_str, sizeof(a_pci_ident_str), "" PCIIDENT_PRINT_STR "", + PCIIDENT_TO_DOMAIN(p_fpga_info->pciident), + PCIIDENT_TO_BUSNR(p_fpga_info->pciident), + PCIIDENT_TO_DEVNR(p_fpga_info->pciident), + PCIIDENT_TO_FUNCNR(p_fpga_info->pciident)); + + fprintf(pfh, "%s: DeviceName: %s\n", p_adapter_id_str, (p_dev_name ? p_dev_name : "NA")); + fprintf(pfh, "%s: PCI Details:\n", p_adapter_id_str); + fprintf(pfh, "%s: %s: %08X: %04X:%04X %04X:%04X\n", p_adapter_id_str, a_pci_ident_str, + p_fpga_info->pciident, p_hw_info->pci_vendor_id, p_hw_info->pci_device_id, + p_hw_info->pci_sub_vendor_id, p_hw_info->pci_sub_device_id); + fprintf(pfh, "%s: FPGA Details:\n", p_adapter_id_str); + fprintf(pfh, "%s: %03d-%04d-%02d-%02d [%016" PRIX64 "] (%08X)\n", p_adapter_id_str, + p_fpga_info->n_fpga_type_id, p_fpga_info->n_fpga_prod_id, + p_fpga_info->n_fpga_ver_id, p_fpga_info->n_fpga_rev_id, p_fpga_info->n_fpga_ident, + p_fpga_info->n_fpga_build_time); + fprintf(pfh, "%s: FpgaDebugMode=0x%x\n", p_adapter_id_str, p_fpga_info->n_fpga_debug_mode); + fprintf(pfh, "%s: Nims=%d PhyPorts=%d PhyQuads=%d RxPorts=%d TxPorts=%d\n", + p_adapter_id_str, p_fpga_info->n_nims, p_fpga_info->n_phy_ports, + p_fpga_info->n_phy_quads, p_fpga_info->n_rx_ports, p_fpga_info->n_tx_ports); + 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); + + if (nt4ga_stat_ops != NULL) + nt4ga_stat_ops->nt4ga_stat_dump(p_adapter_info, pfh); + + return 0; +} + +/* + * SPI for sensors reading + */ +nthw_spis_t *new_sensors_t_spi(struct nthw_fpga_s *p_fpga) +{ + nthw_spis_t *sensors_t_spi = nthw_spis_new(); + + /* init SPI for sensor initialization process */ + if (sensors_t_spi == NULL) { + NT_LOG(ERR, ETHDEV, "%s: SPI allocation error\n", __func__); + return NULL; + } + + if (nthw_spis_init(sensors_t_spi, p_fpga, 0)) { + NT_LOG(ERR, ETHDEV, "%s: SPI initialization error\n", __func__); + nthw_spis_delete(sensors_t_spi); + return NULL; + } + + return sensors_t_spi; +} + +static int nt4ga_adapter_init(struct adapter_info_s *p_adapter_info) +{ + const struct flow_filter_ops *flow_filter_ops = get_flow_filter_ops(); + + if (flow_filter_ops == NULL) + NT_LOG(ERR, ETHDEV, "%s: flow_filter module uninitialized\n", __func__); + + char *const p_dev_name = malloc(24); + char *const p_adapter_id_str = malloc(24); + 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()) + */ + bool b_has_mcu = false; + int n_phy_ports = -1; + int n_nim_ports = -1; + int res = -1; + nthw_fpga_t *p_fpga = NULL; + + (void)b_has_mcu;/* currently UNUSED - prevent warning */ + (void)n_nim_ports; /* currently UNUSED - prevent warning */ + + p_hw_info->n_nthw_adapter_id = nthw_platform_get_nthw_adapter_id(p_hw_info->pci_device_id); + + fpga_info->n_nthw_adapter_id = p_hw_info->n_nthw_adapter_id; + /* ref: DN-0060 section 9 */ + p_hw_info->hw_product_type = p_hw_info->pci_device_id & 0x000f; + /* ref: DN-0060 section 9 */ + p_hw_info->hw_platform_id = (p_hw_info->pci_device_id >> 4) & 0x00ff; + /* ref: DN-0060 section 9 */ + p_hw_info->hw_reserved1 = (p_hw_info->pci_device_id >> 12) & 0x000f; + + /* mp_dev_name */ + p_adapter_info->p_dev_name = p_dev_name; + + if (p_dev_name) { + snprintf(p_dev_name, 24, "" PCIIDENT_PRINT_STR "", + PCIIDENT_TO_DOMAIN(p_adapter_info->fpga_info.pciident), + PCIIDENT_TO_BUSNR(p_adapter_info->fpga_info.pciident), + PCIIDENT_TO_DEVNR(p_adapter_info->fpga_info.pciident), + PCIIDENT_TO_FUNCNR(p_adapter_info->fpga_info.pciident)); + NT_LOG(DBG, ETHDEV, "%s: (0x%08X)\n", p_dev_name, + p_adapter_info->fpga_info.pciident); + } + + /* mp_adapter_id_str */ + p_adapter_info->mp_adapter_id_str = p_adapter_id_str; + + p_adapter_info->fpga_info.mp_adapter_id_str = p_adapter_id_str; + + if (p_adapter_id_str) { + snprintf(p_adapter_id_str, 24, "PCI:" PCIIDENT_PRINT_STR "", + PCIIDENT_TO_DOMAIN(p_adapter_info->fpga_info.pciident), + PCIIDENT_TO_BUSNR(p_adapter_info->fpga_info.pciident), + PCIIDENT_TO_DEVNR(p_adapter_info->fpga_info.pciident), + PCIIDENT_TO_FUNCNR(p_adapter_info->fpga_info.pciident)); + NT_LOG(DBG, ETHDEV, "%s: %s\n", p_adapter_id_str, p_dev_name); + } + + { + int i; + + for (i = 0; i < (int)ARRAY_SIZE(p_adapter_info->mp_port_id_str); i++) { + char *p = malloc(32); + + if (p) { + snprintf(p, 32, "%s:intf_%d", + (p_adapter_id_str ? p_adapter_id_str : "NA"), i); + } + + p_adapter_info->mp_port_id_str[i] = p; + } + } + + res = nthw_fpga_init(&p_adapter_info->fpga_info); + + if (res) { + NT_LOG(ERR, ETHDEV, "%s: %s: FPGA=%04d res=x%08X [%s:%u]\n", p_adapter_id_str, + p_dev_name, fpga_info->n_fpga_prod_id, res, __func__, __LINE__); + 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); + n_nim_ports = fpga_info->n_nims; + assert(n_nim_ports >= 1); + b_has_mcu = fpga_info->mcu_info.mb_has_mcu; + + /* NOTE: RX and TX queues for VFs shall be considered too */ + int max_rx_queues = nthw_fpga_get_product_param(p_fpga, NT_DBS_RX_QUEUES, -1); + int max_tx_queues = nthw_fpga_get_product_param(p_fpga, NT_DBS_TX_QUEUES, -1); + + if (max_rx_queues < 0 || max_tx_queues < 0 || + n_phy_ports * p_adapter_info->n_rx_host_buffers > max_rx_queues || + n_phy_ports * p_adapter_info->n_tx_host_buffers > max_tx_queues) { + NT_LOG(ERR, ETHDEV, + "%s: Too many queues requested: phy_ports=%d, rxqs=%d, txqs=%d, rx_queues_avail=%d, tx_queues_avail=%d\n", + p_adapter_info->mp_adapter_id_str, n_phy_ports, + p_adapter_info->n_rx_host_buffers, p_adapter_info->n_tx_host_buffers, + max_rx_queues, max_tx_queues); + nthw_fpga_shutdown(&p_adapter_info->fpga_info); + return -1; + } + + /* Nt4ga Init Filter */ + nt4ga_filter_t *p_filter = &p_adapter_info->nt4ga_filter; + + if (flow_filter_ops != NULL) { + res = flow_filter_ops->flow_filter_init(p_fpga, &p_filter->mp_flow_device, + p_adapter_info->adapter_no); + + if (res != 0) { + NT_LOG(ERR, ETHDEV, "%s: Cannot initialize filter\n", p_adapter_id_str); + return res; + } + } + + /* + * HIF/PCI TA/TG + */ + { + res = nt4ga_pci_ta_tg_init(p_adapter_info); + + if (res == 0) { + nt4ga_pci_ta_tg_measure_throughput_main(p_adapter_info, 0, 0, TG_PKT_SIZE, + TG_NUM_PACKETS, TG_DELAY); + + } else { + NT_LOG(WRN, ETHDEV, "%s: PCI TA/TG is not available - skipping\n", + p_adapter_id_str); + } + } + + { + int i; + const struct link_ops_s *link_ops = NULL; + assert(fpga_info->n_fpga_prod_id > 0); + + for (i = 0; i < NUM_ADAPTER_PORTS_MAX; i++) { + /* Disable all ports. Must be enabled later */ + p_adapter_info->nt4ga_link.port_action[i].port_disable = true; + } + + switch (fpga_info->n_fpga_prod_id) { + /* NT200A01: 2x100G (Xilinx) */ + case 9563: /* NT200A02 (Cap) */ + link_ops = get_100g_link_ops(); + + if (link_ops == NULL) { + NT_LOG(ERR, ETHDEV, + "%s: NT200A02 100G link module uninitialized\n", __func__); + res = -1; + break; + } + + res = link_ops->link_init(p_adapter_info, p_fpga); + break; + + /* NT200A0x: 2x10G/2x25G (Xilinx) */ + case 9530: /* NT200A02 (NFV) */ + case 9544: /* NT200A02 (NFV Lenovo) */ + link_ops = get_25g_link_ops(); + + if (link_ops == NULL) { + NT_LOG(ERR, ETHDEV, "%s: NT200A02 25G link module uninitialized\n", + __func__); + res = -1; + break; + } + + res = link_ops->link_init(p_adapter_info, p_fpga); + break; + + /* NT50b0x: 2x10G/2x25G (Xilinx) */ + case 9542: /* NT50B01 (NFV) */ + case 9547: /* NT50B01 (NFV Lenovo) */ + link_ops = get_25g_link_ops(); + + if (link_ops == NULL) { + NT_LOG(ERR, ETHDEV, "%s: NT50B01 25G link module uninitialized\n", + __func__); + res = -1; + break; + } + + res = link_ops->link_init(p_adapter_info, p_fpga); + break; + + case 9569: /* NT400D11 (Intel Agilex FPGA) */ + link_ops = get_agx_100g_link_ops(); + + if (link_ops == NULL) { + NT_LOG(ERR, ETHDEV, + "%s: NT400D11 100G link module uninitialized\n", __func__); + res = -1; + break; + } + + res = link_ops->link_init(p_adapter_info, p_fpga); + break; + + case 9572: + /* NT200A0x: 8x10G (Xilinx) */ + link_ops = get_8x10g_link_ops(); + + if (link_ops == NULL) { + NT_LOG(ERR, ETHDEV, + "%s: NT200A0x 8x10G link module uninitialized\n", __func__); + res = -1; + break; + } + + res = link_ops->link_init(p_adapter_info, p_fpga); + break; + + default: + NT_LOG(ERR, ETHDEV, "%s: Unsupported FPGA product: %04d\n", __func__, + fpga_info->n_fpga_prod_id); + res = -1; + break; + } + + if (res) { + NT_LOG(ERR, ETHDEV, "%s: %s: %s: %u: FPGA=%04d res=x%08X\n", + p_adapter_id_str, p_dev_name, __func__, __LINE__, + fpga_info->n_fpga_prod_id, res); + return res; + } + } + + /* + * HostBuffer Systems + */ + p_adapter_info->n_rx_host_buffers = 0; + p_adapter_info->n_tx_host_buffers = 0; + + p_adapter_info->fpga_info.mp_nthw_epp = NULL; + + if (nthw_epp_present(p_adapter_info->fpga_info.mp_fpga, 0)) { + p_adapter_info->fpga_info.mp_nthw_epp = nthw_epp_new(); + + if (p_adapter_info->fpga_info.mp_nthw_epp == NULL) { + NT_LOG(ERR, ETHDEV, "%s: Cannot create EPP\n", p_adapter_id_str); + return -1; + } + + res = nthw_epp_init(p_adapter_info->fpga_info.mp_nthw_epp, + p_adapter_info->fpga_info.mp_fpga, 0); + + if (res != 0) { + NT_LOG(ERR, ETHDEV, "%s: Cannot initialize EPP\n", p_adapter_id_str); + return res; + + } else { + NT_LOG(DBG, ETHDEV, "%s: Initialized EPP\n", p_adapter_id_str); + } + + res = nthw_epp_setup(p_adapter_info->fpga_info.mp_nthw_epp); + + if (res != 0) { + NT_LOG(ERR, ETHDEV, "%s: Cannot setup EPP\n", p_adapter_id_str); + return res; + } + } + + const struct nt4ga_stat_ops *nt4ga_stat_ops = get_nt4ga_stat_ops(); + + if (nt4ga_stat_ops != NULL) { + /* Nt4ga Stat init/setup */ + res = nt4ga_stat_ops->nt4ga_stat_init(p_adapter_info); + + if (res != 0) { + NT_LOG(ERR, ETHDEV, "%s: Cannot initialize the statistics module\n", + p_adapter_id_str); + return res; + } + + res = nt4ga_stat_ops->nt4ga_stat_setup(p_adapter_info); + + if (res != 0) { + NT_LOG(ERR, ETHDEV, "%s: Cannot setup the statistics module\n", + p_adapter_id_str); + return res; + } + } + + /* + * MCU testing + */ + + return 0; +} + +static int nt4ga_adapter_deinit(struct adapter_info_s *p_adapter_info) +{ + const struct sensor_ops *sensor_ops = get_sensor_ops(); + fpga_info_t *fpga_info = &p_adapter_info->fpga_info; + int i; + int res; + struct nt_sensor_group *cur_adapter_sensor = NULL; + struct nt_sensor_group *next_adapter_sensor = NULL; + struct nim_sensor_group *cur_nim_sensor = NULL; + struct nim_sensor_group *next_nim_sensor = NULL; + + stop_monitor_tasks(-1); + + const struct nt4ga_stat_ops *nt4ga_stat_ops = get_nt4ga_stat_ops(); + + if (nt4ga_stat_ops != NULL) + nt4ga_stat_ops->nt4ga_stat_stop(p_adapter_info); + + 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++) { + if (p_adapter_info->mp_port_id_str[i]) { + free(p_adapter_info->mp_port_id_str[i]); + p_adapter_info->mp_port_id_str[i] = NULL; + } + } + + /* Free adapter ident string */ + if (p_adapter_info->mp_adapter_id_str) { + free(p_adapter_info->mp_adapter_id_str); + p_adapter_info->mp_adapter_id_str = NULL; + } + + /* Free devname ident string */ + if (p_adapter_info->p_dev_name) { + free(p_adapter_info->p_dev_name); + p_adapter_info->p_dev_name = NULL; + } + + /* Free adapter sensors */ + if (p_adapter_info->adapter_sensors != NULL) { + do { + cur_adapter_sensor = p_adapter_info->adapter_sensors; + next_adapter_sensor = p_adapter_info->adapter_sensors->next; + p_adapter_info->adapter_sensors = next_adapter_sensor; + + if (sensor_ops != NULL) + sensor_ops->sensor_deinit(cur_adapter_sensor); + } while (next_adapter_sensor != NULL); + } + + /* Free NIM sensors */ + for (i = 0; i < fpga_info->n_phy_ports; i++) { + if (p_adapter_info->nim_sensors[i] != NULL) { + do { + cur_nim_sensor = p_adapter_info->nim_sensors[i]; + next_nim_sensor = p_adapter_info->nim_sensors[i]->next; + p_adapter_info->nim_sensors[i] = next_nim_sensor; + free(cur_nim_sensor->sensor); + free(cur_nim_sensor); + } while (next_nim_sensor != NULL); + } + } + + return res; +} + +static const struct adapter_ops ops = { + .init = nt4ga_adapter_init, + .deinit = nt4ga_adapter_deinit, + + .show_info = nt4ga_adapter_show_info, +}; + +static void __attribute__((constructor(65535))) adapter_init(void) +{ + register_adapter_ops(&ops); +} diff --git a/drivers/net/ntnic/meson.build b/drivers/net/ntnic/meson.build index 247d4ff7e4..9b1d75ef48 100644 --- a/drivers/net/ntnic/meson.build +++ b/drivers/net/ntnic/meson.build @@ -84,6 +84,7 @@ headers = files('rte_pmd_ntnic.h') # all sources sources = files( 'dpdk_mod_reg.c', + 'drivers/net/ntnic/driver/modules/adapter/nt4ga_adapter.c', 'drivers/net/ntnic/driver/modules/adapter/nt4ga_pci_ta_tg.c', 'drivers/net/ntnic/driver/modules/adapter/nt4ga_tfg.c', 'nthw/supported/nthw_fpga_9563_055_039_0000.c', -- 2.44.0