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 1504B4411D; Fri, 31 May 2024 17:48:44 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C5BB642DC3; Fri, 31 May 2024 17:47:55 +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 1DB6842D89 for ; Fri, 31 May 2024 17:47:49 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2168.outbound.protection.outlook.com [104.47.17.168]) by mx-outbound41-244.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 31 May 2024 15:47:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QX1AOgsdIKZHXnISz0HjeYEdam8oGoK9dQmdajBmaXHxfsujMmCck4/kiIW1dxEy9ORJcnCh5xbdlHVhPdPLvyA5AwdhmpH2ugVw36hl2Y7xwBtac0+KVDrJ2nqB7LdHVVpzGPlP0WFDzPXFzKP4XzRsAb1yaWZntN7vHR/QJmrySTkIvz+0LNsHz1TMb2umx7m+3zSKQCfCug0JRNjEUOfF2xR/kKa/zKvF+ABqoJAnWty4Ol39oagS3ETlWwoHHTwLKBhl5ovIAR9Ki9dCbWsIv+VGIhsjGa3832Ylis9DMz7nlXLlk6qdTuQOqzWlhaLCoPSpWWmopR1ORwfrtw== 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=E0HrtEQqgexCHbOazzw4HiWxrhzZCvop0bRvmHKpZqM=; b=icB4Bd4VY5/lUb5TqQlXd+9uWwFtVmn7lgugWvYscyU5FeBGynMC9rSGw6pi7bs0SV/3sRfYpFLARd1oj30cRolIiicQpsKU6eBjOZ0x1lxCbIizbsfDNWbggRZWFn57wtuJ/xXkWIsVUcU1ZM6egNAxJstvUHyGPQXOfbvs1JJymE3jEwH06OhpYSfGyCaw5PEU3lqaElqtarXJEdfBFR0FEuQ3aOgZ6hCw+6iiPIx3C/c0C35ZX4XCEjjgBUeyYoj7g/NT/90ZY+lpDP/WZZach33+HsVNWYPwFKyldu5E97NRGqk3EuUy70apx2UVcbQ6J4mGQHr6RWOdnakLKg== 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=E0HrtEQqgexCHbOazzw4HiWxrhzZCvop0bRvmHKpZqM=; b=h20Wg4OlmH92y+Oy11nIoSxZ79sV3REQc6wVqABZRggMRWQxFhed1xVzql6Gef+rNsF1H0NPPqV6SIVgO2LSNleJG4zfM5NZElkN7hIKNvbb7PYACqjSicXyRDgoOKtR4unerqBjvhbftnrahnmyPma4xRfoESd55z4WvGxr9g8= Received: from AS4P251CA0017.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:5d3::6) by PRAP190MB1811.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:292::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22; Fri, 31 May 2024 15:47:46 +0000 Received: from AMS1EPF00000047.eurprd04.prod.outlook.com (2603:10a6:20b:5d3:cafe::51) by AS4P251CA0017.outlook.office365.com (2603:10a6:20b:5d3::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.24 via Frontend Transport; Fri, 31 May 2024 15:47:46 +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 AMS1EPF00000047.mail.protection.outlook.com (10.167.16.135) with Microsoft SMTP Server id 15.20.7633.15 via Frontend Transport; Fri, 31 May 2024 15:47:46 +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 v2 14/17] net/ntnic: add adapter initialization API Date: Fri, 31 May 2024 17:47:18 +0200 Message-ID: <20240531154731.1856874-14-sil-plv@napatech.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240531154731.1856874-1-sil-plv@napatech.com> References: <20240530144929.4127931-1-sil-plv@napatech.com> <20240531154731.1856874-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS1EPF00000047:EE_|PRAP190MB1811:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 5a270922-98d8-42e7-2c25-08dc81890439 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|36860700004|1800799015|376005|82310400017; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?NaKRs3DP+CqLyPzKRbD8pTwZdpqS9UpiIffZxE5kebgk1nSHttvbIL5eT4em?= =?us-ascii?Q?uhK4bsBTCw1u55C8tMmh4fudKiIYNMWcaajLAxKx6APmBYaTgMg/y1bt4x4X?= =?us-ascii?Q?ePYoWjxYoQay1xfyhSvYqN8b9uiaKeZtk/DD/qhpp1kKV6A/5gSB12y8PO02?= =?us-ascii?Q?6PxbGSp3EJOHVVfJ8V9Vlsi3/cmDLpYGGPp7HfCU5N16Pbh6b24PKBGH9oZt?= =?us-ascii?Q?K6JAO0q4U5X4FRVpTNCNY6HFQ+EgH/6FIWNmkePCUsurGz/6YAyxjgFMSAKs?= =?us-ascii?Q?lzkQdpzfkY0AsppOVkF3LCJSA+2srJZ1ofU5u9yj5uga0PJ2lwqMOjMC1oGv?= =?us-ascii?Q?uV6yauyIrlUGI3sFno5WQn+DOCnUneWSUo5c46aWF5ovIP2CzYbbVnhB+dSc?= =?us-ascii?Q?p/F2zurKklB7khW6MfM27pj+6OQmwDvBce9zCFo2p/sifHst+w6OQD5MxPUW?= =?us-ascii?Q?lamgpW01MfCs0NChlUVadxWw/w8PufI6zzyMkz7zJVr2nMKl6pPQY2ErAan6?= =?us-ascii?Q?lRuRnTnDdudFgS4Ra8ia7jVSlxQXMMESlwnZqzZ7+fvkusOHBN8y7/3ipGbR?= =?us-ascii?Q?1tHuilKxRwAcS7+VQUFPBFSrLpsq675pGyVrsYXMW60lgKUn8WZNgSXFcz2f?= =?us-ascii?Q?bYhqlf5Udm9hmfr0pTAZ0d/EBa0NID6kgoWcfZGFDai+I3eB6RMHF3TA1m9e?= =?us-ascii?Q?mReYoxV0d9S21tvWK7gOpYdfvcuFiIUZZkAgeQNur0wBtLmnzkp21jFq0wOh?= =?us-ascii?Q?stvcZYtN+pAOBRUUn544T0a7HyY7ct9r9rWhlNHUYvYwkLG64v3Xout8s2FL?= =?us-ascii?Q?hG7CADj45beenyzzQ18l6uzVr9V/PKJHZ3QNjlVfUKI8uXLS/sh+DKiHNBL3?= =?us-ascii?Q?HS/Nav13/RzZGq59mxyiezn1MRvbWnJpyLbGlR7msD0sVzwQDiCpQNbfqy4W?= =?us-ascii?Q?G0XRJb4WNIsxZHmdYMhCqd/B4Yikt7HwOFn8QhlXJBVEEHjFn+JdCj+HVhHp?= =?us-ascii?Q?Bfs52RxDccXR38nGybe0aOm8kYw272MNKykzQFlN23Xql22m7nPMsP93Ygdi?= =?us-ascii?Q?PwhZXGq049RAUPzX4hWGqlt92tC/c8SgW/Y2noRqjJCNBWVZtECNQB1fIRRG?= =?us-ascii?Q?fO3bAnZkCo29Pce9u17GtREAgeIAvrgc5Yzj07hlcpg+Tt1U6Oyis7oVIPKX?= =?us-ascii?Q?SV1KhvswUAc8nSyu3MV0U9Ld69DM7Wfnurii+E+z6rfsCMbKMeY3U8ouzJ7E?= =?us-ascii?Q?gobGPhDplFWN7NS9wWs7kzmYRfZlVOOOkKJJMGK85pL5rCk0QiCSBZLPuB+B?= =?us-ascii?Q?I9e4s1alZ7ViDYwH3sk/CaA0hP4IN+D5EDpOcd38sMmKSXei/3CIr9ULngGn?= =?us-ascii?Q?GjzsY2g=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)(36860700004)(1800799015)(376005)(82310400017); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: rgeOwXyyEw8HirqaOVO6xs4jbAkN0JBam78cW8a1WX3gYfjJ/11nSsUvd4RG939+mMsIotgDJJL08tbb54WIHgVxDebcCA4/94teBLrhbveKyytCxakRZtT/OuZdWYk10exxtrtcgTGRnSvb6S2gzN9H1AWAhMcp8H4EaomxOw6hRMc/Ix6tHbxGmcibXRdQ3RyUwQ+xVAnjLScnwpuujt1uNRTDJqtrxHBc0VuJrvx2uFrpujQgAJ5f+NyoeYH5PxF+w0JvdtIKAiMLV35FZD4EYE4HocvwV7OnhjbkBEGOQjThbNafzyb17xi0xoLjwzxPKAKZ2xFSf3JsdF1LwOdWs2X8rZYD3wZY8QpOQCHIwy/nHwEwmMxqmf1dD1MDRTYHuk5JMSadoHQ9TCXyDXsn/S4zvXRmCOG+oIpTfpFs28kBIPACxhCKj8NaZU4lp8+BQnNMvAwUY9UfxVihGiRWkPFKh+uKTZkL1pcHODli2Z8P61vSQSKLEvycmnSixzb7z+s1M3Bw9AXSCmmq4oX33D8Uf8HqQSOXMS0g5BQ6LNCoWyCR8WxkwIGT9EHYBg13+5FH5qVaPnNRC3+e+WXAku0lK4Wknx/QvMj/DT/W5V0RUFFSXLW1Tt/i5438swQfzk2jm0OqPcS++/MC6w== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2024 15:47:46.0032 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5a270922-98d8-42e7-2c25-08dc81890439 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: AMS1EPF00000047.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PRAP190MB1811 X-BESS-ID: 1717170467-310740-12728-27678-1 X-BESS-VER: 2019.1_20240530.1612 X-BESS-Apparent-Source-IP: 104.47.17.168 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoZmBgZmQGYGUNQi2dI4ycjU1N wy2SzRwMzI0iItzSAt1cTUyCDRxMwiRak2FgAAoeAGQgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256627 [from cloudscan13-195.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 1a56a0f6c4..c6e4a9fd5b 100644 --- a/drivers/net/ntnic/meson.build +++ b/drivers/net/ntnic/meson.build @@ -77,6 +77,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