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 0E1FC45509; Thu, 27 Jun 2024 09:39:31 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C959E406A2; Thu, 27 Jun 2024 09:39:30 +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 042B740697 for ; Thu, 27 Jun 2024 09:39:27 +0200 (CEST) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03lp2168.outbound.protection.outlook.com [104.47.51.168]) by mx-outbound43-83.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 27 Jun 2024 07:39:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EqxNeEP41/2qYoh1uKa+/gi6suoWIVrR8Glu+kYz2hP3tnQt9ucrk67e5iqxxUZClCu6LC/kzMcsNYdgDG8jiBEUnYu8ItP34eGJe5JFZR0tDNj2to/bdaLaPbN177actRHF1suKRJEmYfzzJZs3WN9AfLBch9Kl1XGJvHeG+VNsfX3XU5u8MIgLbPh/Y/BkBfNe7rKWiAQiZ8SqAzvwU51gBDS0jRY0CDmylOoLIEhm0K/SyOwsmNXTe/RPZ3RsCkw9I8ETdHHVJ6lh0zVvqd8Dn9Es54GndM205Ph0HRQtPQkWestjWiQ/KG6uM3GvwHahQMJQmVMvJ4XfEjR8Wg== 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=dcSBtUa4D8z12bM/jDgbPDQoUrNaCwtNAkNN07QXLBA=; b=RfYHQ7Ptr3uovmmmIrdO9aQQWS1vWpuCuemerg7YrghKhAXbnaS7k3scD3j/2OJR/Aq5u3KHCpwd2ly0b+Bpnio/D27yMfX9oaC5r9b9nLU33opBiE+9tAD8lcy2lCkJK4szC8fkGcXp+1zL4Dx/rMPGCk8bzV84Y5ixKK0itoW6yteLxLCa/Wg4dTXat4z7mOK5GSySSjvlDQ8P6hQ22Gm6NFwPjPdWsvY7E7bWN4wa12Bhgrc3SZdePYGhIfLRkyf9AxcnHf1P+M69JPqUvXIoEim3/+N1JMTjJOpFx5lBkH+2U8nEyzByxy1Rh1AY3rqKiKZi4us4FaNz8dC0GQ== 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=dcSBtUa4D8z12bM/jDgbPDQoUrNaCwtNAkNN07QXLBA=; b=kjnF7ZYTvJ3gwmAEdd52NQABLSmv5t1qJ32Smr/UqUf/cvcgVcMHk3oM2ymAjVyCIEZNIa715855IndizQAV0/lLONjifIepu3w5dFtM5nIcEO0JJlJrbZi1XnjXe2R38/9ROJPFZEkF8bN0ikesbw+QAfonorjnCOlzE7qNe/s= Received: from DUZPR01CA0345.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b8::28) by AS8P190MB1045.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2b7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.32; Thu, 27 Jun 2024 07:39:24 +0000 Received: from DB1PEPF000509E2.eurprd03.prod.outlook.com (2603:10a6:10:4b8:cafe::5e) by DUZPR01CA0345.outlook.office365.com (2603:10a6:10:4b8::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.25 via Frontend Transport; Thu, 27 Jun 2024 07:39:24 +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 DB1PEPF000509E2.mail.protection.outlook.com (10.167.242.52) with Microsoft SMTP Server id 15.20.7677.15 via Frontend Transport; Thu, 27 Jun 2024 07:39:24 +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 v5 03/23] net/ntnic: add minimal initialization for PCI device Date: Thu, 27 Jun 2024 09:38:44 +0200 Message-ID: <20240627073918.2039719-3-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240627073918.2039719-1-sil-plv@napatech.com> References: <20240530144929.4127931-1-sil-plv@napatech.com> <20240627073918.2039719-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB1PEPF000509E2:EE_|AS8P190MB1045:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 8ff704be-a067-4265-c34f-08dc967c4452 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Mwpjmp0HqQhuYnQUof6vor5mMe6cIFBKgev5Zu40xPt6oePjAHmW1ufpMmoz?= =?us-ascii?Q?aHs+KbDW4/Ot/Vy2cf2+OWy+xMNiJ7JNOYfCg+P0LxmqxT9i1zUHZFnsU+gS?= =?us-ascii?Q?NTPqt9b/eXgALYefcNyynOSDEVHWAKvdJUQeGoO3viwxl8RpSmqgUgBQGw40?= =?us-ascii?Q?iZPGF/ZHbueVlFxc7iLjVD96kZPazQIax2TqJVHMLBz4KM4E/jNf8sxxY6xV?= =?us-ascii?Q?AjWaxTU/LunYqub+DcXP2EsfSyzGFkckfFG3f/rF3Nwt9aGOlJAliCjjXrQ9?= =?us-ascii?Q?dk/lDu3SUYr3x62K8xR3Npye3BFyVwB41EphEOJ4yqliOqRZppk66O0FFnWx?= =?us-ascii?Q?pO/gOWk9u6nLGbbJGPMQRICBdT+4y1lLYcaYHiA7a/BoIaLXhVQDbgoBtlRI?= =?us-ascii?Q?rBV5Eh9P6mau/Bsq800voJF+CMl03yYaoFABcB8hub69hp/DYC161X70sseR?= =?us-ascii?Q?rjAFU9hQykEIMJerldYzRTax0gfX91fqMN0A1dtssO/I7G0SSe3A9GTQmN6D?= =?us-ascii?Q?NZXyaTiW7aMFvys9QJKOe+wQXBTxo3LqU2SmdQVMnYhUu1eJOxDId9WiP9RL?= =?us-ascii?Q?m1maQ49Cqm22y7nfnrKC/26x8p5G+xitjCsY9rP1vrp0TLoi9jRkK/cnfKEj?= =?us-ascii?Q?7QZ5qUCfBQYp29YSgHd4dPEYZ9iTZeAcgmgIHQSWD8VrEUvh79INSLK0lpyn?= =?us-ascii?Q?m2Tt6IoiPYXcitWaCwloweo3hovKCAMvD8YSlWU1deeMof8NoVvnvONF7mRK?= =?us-ascii?Q?4gNdfEjNNkGUZuOATzzNdNfIUiJH3QButK83vVUnqvq3ZRiYKvBWhIgO7OUp?= =?us-ascii?Q?S2xfp5OrvBInXPmj2YRqMerf4TJZfAaNbOpFegJdad9AQ8vleyH9Y06gCpFW?= =?us-ascii?Q?wK4CbW5ceSvFF2Wnm9CSZkXJH3YZP04MNjMgYGLcosasAXAlo7Dg80DX5i/F?= =?us-ascii?Q?UIUfDNVOgUJ9ZD50NGhQ8FzACoI8Rk7CXiyIlaDlv+jo/1jD9CKK3Vx7oZqC?= =?us-ascii?Q?arl5Wi5SDurHu0iLzmDcwDIOHoeIJJn5wUcmveA7mgY8iS6FMvARoczP5eBZ?= =?us-ascii?Q?owXJj60p3CEQQsP0CEBpW9Of8vcop386gRsIz2agzB+8/CZ6l9E2354F28Us?= =?us-ascii?Q?vuyuUTvZaYq3COp7BdHF9WYQIfYbqf6xP+dqoYCWQIzzaD3bmGwiuUn8Fc0r?= =?us-ascii?Q?e+2nqqvmzOMCA5Fa3ZgcHR+CENU35XNjCB/TTAKfcUC2DesGUBiw4CXnxjIe?= =?us-ascii?Q?LiLM+iAMt+b2QilA6FEIXdg//2L/l5TWVlEdoov3N6OYrjak46NgDJHNYSj6?= =?us-ascii?Q?stb48uTIj7I7skmDv5C0YOBppwQ4QIX1cXMqEqmgUE47MGiGNWKwAfVpfhTU?= =?us-ascii?Q?h0uZWYHly6IdFGTWaDTVlU5bSV+PeMbwVSXBqDBmFAkUJ6K+9GSg2GZ6s9Mo?= =?us-ascii?Q?WAJ+yA5PF32PbWJhUIic2TRJ4ekUsVwZ?= 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)(82310400026)(376014)(36860700013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: XNVYFt4rWit1Y8nQPMdSta9dM7UkACPzLep9EC7ITLvT7ohK7jdPo0PDKWxTh/jh3bt3hRqCrvzdIcOg6/d/CHdS02CwRBQhpeh9wRlqxrjvKJjkhyrjynvcffBokE6R/edHrs1hq5Vgb7aijPvcdS0Km+sJ2OAerMOGxq9JUmjDGoY/1cWPYKcT8KrLBYukGMI9pi4UFnMU2QFUvyVLw+I1yrKMASD7riS8EBfeNUJ5iVkLinr8H9S3EVXlNHUsh39N54FxTptmQp9YuDAR2DGQHYEsvrO6aL4rglQtGhiejMzogYpjDx77eY8F3y3+gk7El9q0eV2BUqTv5ooS5MorfcbG2yZ+jRhElLIw0i6leOWWvgp4Go4srIsirqTwxA651BHaBwqtFaW5KnPuQIa4Ox/tSTITe10QXWRfCgg9kqgIPVks7lk8sBRtWNqHhhkvzlSvwxtFCoIjM43zvebU5HKopCD6sZheNPbPr2N2GaLk2xE3eIv02gjFqtrxlHeyJWdTYx+/so9B4k3OhaRs+ICOfkRmMTeb2CTfhIFKNW29ogGeo1V1tHqoVF5H6GMBwYamMuQBKGdZ6OfTmdvKx2VG/CNpCd9jn4qG/dxAZtleAGNfcr3ZCOrnjPx7NlYvw8LjcQYtJWuWaNiRjQ== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2024 07:39:24.3341 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8ff704be-a067-4265-c34f-08dc967c4452 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: DB1PEPF000509E2.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P190MB1045 X-BESS-ID: 1719473966-311091-12764-2304-1 X-BESS-VER: 2019.1_20240620.2317 X-BESS-Apparent-Source-IP: 104.47.51.168 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVibmZmZAVgZQMMkoySzZPCXRwN DS0tLCPDXF2NzY2NAwOdE4MdHCJM1YqTYWAAWpkFVBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.257231 [from cloudscan14-182.eu-central-1a.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 | 104 ++++++++++++++++++++++++++++++- 1 file changed, 103 insertions(+), 1 deletion(-) diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c index 3079bd98e4..e9a584877f 100644 --- a/drivers/net/ntnic/ntnic_ethdev.c +++ b/drivers/net/ntnic/ntnic_ethdev.c @@ -17,14 +17,63 @@ /* Global static variables: */ 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); /* TODO: 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->data->numa_node = pci_dev->device.numa_node; + eth_dev->dev_ops = NULL; + eth_dev->state = RTE_ETH_DEV_ATTACHED; + + rte_eth_copy_pci_info(eth_dev, pci_dev); + /* performs rte_eth_copy_pci_info() */ + eth_dev_pci_specific_init(eth_dev, pci_dev); + + /* increase initialized ethernet devices - PF */ + } + return 0; } static int nthw_pci_dev_deinit(struct rte_eth_dev *eth_dev __rte_unused) { + NT_LOG_DBGX(DEBUG, NTNIC, "PCI device deinitialization\n"); return 0; } @@ -33,13 +82,65 @@ nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct rte_pci_device *pci_dev) { 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_has_pci = rte_eal_has_pci(); + NT_LOG(DBG, NTNIC, "has_pci=%d\n", n_rte_has_pci); + + if (n_rte_has_pci == 0) { + NT_LOG(ERR, NTNIC, "has_pci=%d: this PMD needs hugepages\n", n_rte_has_pci); + return -1; + } + + 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); + + if (n_rte_io_va_mode != RTE_IOVA_PA) { + NT_LOG(WRN, NTNIC, "iova mode (%d) should be PA for performance reasons\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", /* locstr */ + 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); } @@ -48,6 +149,7 @@ static struct rte_pci_driver rte_nthw_pmd = { .name = "net_ntnic", }, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING, .probe = nthw_pci_probe, .remove = nthw_pci_remove, }; -- 2.45.0