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 B8AAF4560F; Fri, 12 Jul 2024 11:48:43 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A101D42E91; Fri, 12 Jul 2024 11:48:43 +0200 (CEST) Received: from egress-ip42b.ess.de.barracuda.com (egress-ip42b.ess.de.barracuda.com [18.185.115.246]) by mails.dpdk.org (Postfix) with ESMTP id F3F13402AE for ; Fri, 12 Jul 2024 11:48:39 +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:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FaRfuLJiwOfLvtE/91n1xmoKx7S2/8H9LlLQxWbjcKmMYYHoGBf26v/cUz6cXFpxY6/LpUYIRizLpKYVSl3d5ndrl6hV2l1uAAaktAE7UejBsNyXFDkjoGo+A+Xj9MHX8nWHuQtXcBfuTbKC2KmEmu6xaEXdegwE0uROL2ubErvmikktTQxsn4mgFH0H1R8RRkchLVSHIgxitVfues3BxHRKnNQ4Z/fnkCUt9I0oQNstscCmeuwz4iBiVWDPawi3q8H2NvZBoWW68GoM6cebcc/G0C3pmgoLkWOWnyCWp+HntihkVwwpN4Q1e1rL3XvDC2DGJF1iZ2xQThyonAF1Zg== 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=amiB1K+Y9ychqZfiHTeaKIbPW5smu00pUhDNMAbhyhU=; b=Kfz57q7rND71tVHV8U5nWA7pic0BcI0jK0EsgmeZDm7cMMbJNLicMjez8q7QqN2Q7hbEOtpPBGhS+mPCXWK0V3ijPFQ0FtWR6aJrFpDBNw2oM8wo/UhTBMnr2d415kCXeGK2A05WYDTmGkbnEMjc6o3UvZCl4zZLMCb5WDn0ZrjtoD/lp7H7ewAuV08MHl+G/NFZyA7TiN3SDWxr1k7f1T2JgBod5QG4QbDitR0myHaRfjBrJZnOJ0w2bf6YO4hUNcQM4rQkMaBG4jsqCwROaB15IAXBmHC0IBWXSsIUqEBJzBPHMl4UqGoNHaMEymp6+Yxu239k4MB1TofJDrdlfw== 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=amiB1K+Y9ychqZfiHTeaKIbPW5smu00pUhDNMAbhyhU=; b=lhoty0hfDhpUPqLSY8VmN/R+4uBu5NNTrjezUzMRPS0e1b4XcpYliNioxO0OKgugid3GxOVOi55dHNVF8hnYAm+OTYw59E93GCDiClkVgyB56Mfp+NO0u7aKc6VQEX2RVO7+cypJs2YylomrhFOA7AyN3XvA6InNm0sA4/FzeHE= Received: from AS9PR06CA0514.eurprd06.prod.outlook.com (2603:10a6:20b:49d::9) by DB9P190MB1339.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:22d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35; Fri, 12 Jul 2024 09:48:37 +0000 Received: from AM1PEPF000252DD.eurprd07.prod.outlook.com (2603:10a6:20b:49d:cafe::53) by AS9PR06CA0514.outlook.office365.com (2603:10a6:20b:49d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.22 via Frontend Transport; Fri, 12 Jul 2024 09:48:37 +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:37 +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 03/21] net/ntnic: add minimal initialization for PCI device Date: Fri, 12 Jul 2024 11:48:08 +0200 Message-ID: <20240712094831.861260-3-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_|DB9P190MB1339:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 0fc67327-cf49-4390-a53a-08dca257cd97 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|1800799024|376014; X-Microsoft-Antispam-Message-Info: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CZcVyivLy0tKsoS05k0CjJ97a9Roa8?= =?us-ascii?Q?i8CCNbGJse4es6q8/B74JSJxcmn2rYdwy32XqMJMuQYtOd0tjJuBodmAAS2f?= =?us-ascii?Q?SZVKspywjiUZ9ts7lp62pOt9lKPu3UeZwJhZSFwMJLGCLB7nWMsL302kUns9?= =?us-ascii?Q?pu4yzT4YPvi2UtgcAKvF8Rl86kig+B+846YQGA2yo0tRpg1ObMTOCjTQVD7F?= =?us-ascii?Q?eo0YjP0tm5lg86hT2Fusm7wzhci3YXDBOkZPB/qvz1FG7dgnUVD+chAA/p8o?= =?us-ascii?Q?jiIeklWX/bkbdg9YBQvR7B+g2FYNmm8R3hi+KxaaiZfQML7HHESalxujL5PM?= =?us-ascii?Q?XPV3Dyu79z5mxBFUH0ldsur/iTOAKouG1gDQSZxD3kwtkJ3KRAXIYhoa9/Wd?= =?us-ascii?Q?gzfW/qKVIIBXUdZhPYlDVijrg2N+BeZvpXOBuIeig5PuXePS5P2yIpyfBFI4?= =?us-ascii?Q?SrzG8j/h8/WKjE5+JryPZf1tHo8z/8eHljmeq8pVsYhRmPUJ1bA9E65uMtBx?= =?us-ascii?Q?icxtPmmuIu4VvnHKroEbQHk0qc/0iOmBP0ufu0g1dwiBiCzaGQXq1zdXf3BX?= =?us-ascii?Q?N+nf/lT3bRSsXoKDBC/0s4EUk1/q1z0k?= 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)(82310400026)(36860700013)(1800799024)(376014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: wkMb+19B3dNZ6xLQvpxHm5zkifu6bX90vTHofSW6VvdE32wpOvNNt8UbgJrik/abEd07X1ABbzeP6QL2/YzqGqLNABtC4NTcF/GuNhAC/2Id5r6P4L1zVYl528Y+D2HVEoMzxTFJDhGSMJqrnKDCIHOkQrmqVhdZs1AxUQFUTv0sJ1W77qUkI8f99QfRekCf5ZzN8ARyye6y1Cyko7CWf4zWKa+63qphcbWEgoIBICnSYDLigrWUgzHj/Zknmgg6z6PjQiWVGqfbuLhbC9Zt0XJTb7h47uV/as/xyp776C3a5usI6EBbS4GkqwvsK44eKl0HqXi+8mGp/ADNjIvtbZPc2gcF4mpJiBK0V8DbiWlNI5tc+VLMX+MzgX38iiVNk654NjHQ5I+pqJzKsTZvWyfO9vg0VjOLKPvw40vz7Oh6i8VwNbRNilQoUYabeAHKJeIUCby6LO/rL7+Y1BE2Q1u7OqvMtp72fC6xlua9xGsOJRZNKP2J3Vr8TZEMCxasKJU2z2MVqAUxBVu89w6dVmJEoNC0f9QtK8r3BGVRPNxeOBJrDjnUeW92lPtx0evftToWSSK6k2K8RLunkRR62NzS/PDIkO6b91my4YnHCAXtGaoQyOAxeWRcirGKpNwgVAMlLF2bN9Zc4fGRe0JZaw== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2024 09:48:37.3327 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0fc67327-cf49-4390-a53a-08dca257cd97 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: DB9P190MB1339 X-BESS-ID: 1720777718-311759-12661-7821-1 X-BESS-VER: 2019.1_20240702.1505 X-BESS-Apparent-Source-IP: 104.47.17.105 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVibmBkZAVgZQ0NI00dAiJS010c jEwtzAxNzQ3NAozcI8KQ1IWqSmJCrVxgIAyEWTLEEAAAA= X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.257571 [from cloudscan21-75.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=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 implementation for probe/init and remove/deinit of the PCI device Signed-off-by: Serhii Iliushyk --- drivers/net/ntnic/ntnic_ethdev.c | 109 +++++++++++++++++++++++++++++-- 1 file changed, 104 insertions(+), 5 deletions(-) diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c index 68df9be2ff..a744f78adb 100644 --- a/drivers/net/ntnic/ntnic_ethdev.c +++ b/drivers/net/ntnic/ntnic_ethdev.c @@ -3,6 +3,7 @@ * Copyright(c) 2023 Napatech A/S */ +#include #include #include #include @@ -16,29 +17,127 @@ static const struct rte_pci_id nthw_pci_id_map[] = { }; static int -nthw_pci_dev_init(struct rte_pci_device *pci_dev __rte_unused) +nthw_pci_dev_init(struct rte_pci_device *pci_dev) { + uint32_t n_port_mask = -1; /* All ports enabled by default */ + int n_phy_ports; + NT_LOG_DBGX(DEBUG, NTNIC, "Dev %s PF #%i Init : %02x:%02x:%i\n", pci_dev->name, + pci_dev->addr.function, pci_dev->addr.bus, pci_dev->addr.devid, + pci_dev->addr.function); + + n_phy_ports = 0; + + for (int n_intf_no = 0; n_intf_no < n_phy_ports; n_intf_no++) { + struct rte_eth_dev *eth_dev = NULL; + char name[32]; + + if ((1 << n_intf_no) & ~n_port_mask) + continue; + + snprintf(name, sizeof(name), "ntnic%d", n_intf_no); + + eth_dev = rte_eth_dev_allocate(name); + + if (!eth_dev) { + NT_LOG_DBGX(ERR, NTNIC, "%s: %s: error=%d\n", + (pci_dev->name[0] ? pci_dev->name : "NA"), name, -1); + return -1; + } + + NT_LOG_DBGX(DEBUG, NTNIC, "eth_dev %p, port_id %u, if_index %u\n", + eth_dev, eth_dev->data->port_id, n_intf_no); + + + struct rte_eth_link pmd_link; + pmd_link.link_speed = RTE_ETH_SPEED_NUM_NONE; + pmd_link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX; + pmd_link.link_status = RTE_ETH_LINK_DOWN; + pmd_link.link_autoneg = RTE_ETH_LINK_AUTONEG; + + eth_dev->device = &pci_dev->device; + eth_dev->data->dev_link = pmd_link; + eth_dev->dev_ops = NULL; + + eth_dev_pci_specific_init(eth_dev, pci_dev); + rte_eth_dev_probing_finish(eth_dev); + } + return 0; } static int nthw_pci_dev_deinit(struct rte_eth_dev *eth_dev __rte_unused) { - return 0; + NT_LOG_DBGX(DEBUG, NTNIC, "PCI device deinitialization\n"); + + int i; + char name[32]; + + struct pmd_internals *internals = eth_dev->data->dev_private; + ntdrv_4ga_t *p_ntdrv = &internals->p_drv->ntdrv; + fpga_info_t *fpga_info = &p_ntdrv->adapter_info.fpga_info; + const int n_phy_ports = fpga_info->n_phy_ports; + for (i = 0; i < n_phy_ports; i++) { + sprintf(name, "ntnic%d", i); + eth_dev = rte_eth_dev_allocated(name); + if (eth_dev == NULL) + continue; /* port already released */ + rte_eth_dev_release_port(eth_dev); + } + return 0; } static int nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct rte_pci_device *pci_dev) { - int ret; - ret = nthw_pci_dev_init(pci_dev); - return ret; + int res; + + NT_LOG_DBGX(DEBUG, NTNIC, "pcidev: name: '%s'\n", pci_dev->name); + NT_LOG_DBGX(DEBUG, NTNIC, "devargs: name: '%s'\n", pci_dev->device.name); + + if (pci_dev->device.devargs) { + NT_LOG_DBGX(DEBUG, NTNIC, "devargs: args: '%s'\n", + (pci_dev->device.devargs->args ? pci_dev->device.devargs->args : "NULL")); + NT_LOG_DBGX(DEBUG, NTNIC, "devargs: data: '%s'\n", + (pci_dev->device.devargs->data ? pci_dev->device.devargs->data : "NULL")); + } + + const int n_rte_vfio_no_io_mmu_enabled = rte_vfio_noiommu_is_enabled(); + NT_LOG(DBG, NTNIC, "vfio_no_iommu_enabled=%d\n", n_rte_vfio_no_io_mmu_enabled); + + if (n_rte_vfio_no_io_mmu_enabled) { + NT_LOG(ERR, NTNIC, "vfio_no_iommu_enabled=%d: this PMD needs VFIO IOMMU\n", + n_rte_vfio_no_io_mmu_enabled); + return -1; + } + + const enum rte_iova_mode n_rte_io_va_mode = rte_eal_iova_mode(); + NT_LOG(DBG, NTNIC, "iova mode=%d\n", n_rte_io_va_mode); + + NT_LOG(DBG, NTNIC, + "busid=" PCI_PRI_FMT + " pciid=%04x:%04x_%04x:%04x locstr=%s @ numanode=%d: drv=%s drvalias=%s\n", + pci_dev->addr.domain, pci_dev->addr.bus, pci_dev->addr.devid, + pci_dev->addr.function, pci_dev->id.vendor_id, pci_dev->id.device_id, + pci_dev->id.subsystem_vendor_id, pci_dev->id.subsystem_device_id, + pci_dev->name[0] ? pci_dev->name : "NA", + pci_dev->device.numa_node, + pci_dev->driver->driver.name ? pci_dev->driver->driver.name : "NA", + pci_dev->driver->driver.alias ? pci_dev->driver->driver.alias : "NA"); + + + res = nthw_pci_dev_init(pci_dev); + + NT_LOG_DBGX(DEBUG, NTNIC, "leave: res=%d\n", res); + return res; } static int nthw_pci_remove(struct rte_pci_device *pci_dev) { + NT_LOG_DBGX(DEBUG, NTNIC); + return rte_eth_dev_pci_generic_remove(pci_dev, nthw_pci_dev_deinit); } -- 2.45.0