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 DFBF345628; Tue, 16 Jul 2024 14:02:36 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 72A04432EC; Tue, 16 Jul 2024 14:02:29 +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 CAA8140A71 for ; Tue, 16 Jul 2024 14:02:25 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2104.outbound.protection.outlook.com [104.47.17.104]) by mx-outbound8-202.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 16 Jul 2024 12:02:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ItSLq8klLk4Ov7or7DeyIsvyjhSc1OwAZOXm1PF6FL0AZ8GqtiHfOeoinEw7C4EmARYr7rzRxcGeaedJDyP0dR8cfJM2vTtY/YVPehGoBbzP5v6VUd81vZnxUaTHs6ax/Q+Uj+SsxeQNnbu5ktu4RVY9VqOLQ1/upI2uUu+AWa86mdnTfBFXNaTVExtJm7Im7rS0eRq0auzc5u1WGjGCls+1Nk8GzeMcvDFHiAtgS6gWQEbZqj8ZJFbZ5esXPQpz51BlL66ooShUxOogtNyHlPzJL1S8CtesxcmiHC4Ogw7GLGsQOsofp3v1IzguUbw9E0vP6qktIEtc/JS3hDL3OA== 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=Wu+NEozCNZSKaen5eUMs60EAhTREQUzFe5pTuWUA0U4=; b=NFXr3bCZf83PJUgooMlrobO5kx0xMlPRtwGUODTeQ4BA3KHRK33/w3SNTch2pW0gxNsIRyDVnJ412trugK9WkrNG2qr5WrCaK1HMyh9hWjZnMZtG5hcSRFNPYYbPhjXmDGCwktDtov/Ts4k1DMdLQVrjlaGuMuXB+4qhmPZiyue+OqGnvZ9C4wcKLHSxFD+DBaRrrm3U6WxDPgsDpJYQUHlLC3bbRMLDivT2u6jbuJGoln1nNQdqX7lG+aqFO5hR1yHQU7pG0PbdKkLWVU5WALu0BHDw8ki4ChseFEa7oaOBkeQhH5SkWt6i6H6gWAE2JtExmSl8FD6OnbWZj64tEw== 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=Wu+NEozCNZSKaen5eUMs60EAhTREQUzFe5pTuWUA0U4=; b=DYqY0JGy5UkD2sDAhzCvNH/gGbczn5p3Cc56tzio5oXgU1/W8biVdAJ1NwKcKIs7cf8fxIBEWbomn3+5SsIbsgvUa5mliWbfovLfe+Xckc9ezObpeJjDdrkJUqP1Pi14de2IvWFMkD6KF8eBQj1//OITWTuzo0jEKMhcmYPaQXM= Received: from DU7P195CA0013.EURP195.PROD.OUTLOOK.COM (2603:10a6:10:54d::8) by DB9P190MB1322.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:224::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.14; Tue, 16 Jul 2024 12:02:21 +0000 Received: from DU6PEPF0000A7DD.eurprd02.prod.outlook.com (2603:10a6:10:54d:cafe::e7) by DU7P195CA0013.outlook.office365.com (2603:10a6:10:54d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.14 via Frontend Transport; Tue, 16 Jul 2024 12:02:21 +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 DU6PEPF0000A7DD.mail.protection.outlook.com (10.167.8.37) with Microsoft SMTP Server id 15.20.7784.11 via Frontend Transport; Tue, 16 Jul 2024 12:02:21 +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 v9 03/21] net/ntnic: add minimal initialization for PCI device Date: Tue, 16 Jul 2024 14:01:52 +0200 Message-ID: <20240716120216.3032484-3-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240716120216.3032484-1-sil-plv@napatech.com> References: <20240530144929.4127931-1-sil-plv@napatech.com> <20240716120216.3032484-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU6PEPF0000A7DD:EE_|DB9P190MB1322:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 0557b40a-73ef-413b-9b9c-08dca58f2631 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|36860700013; X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M1y70OuECcjPd6FOtp+IJr0s0GY45A7E7IOsELxiERUkneveocZc06B8Q?= =?us-ascii?Q?idiA6JrhmyDIulq/bm2Z71646HznoZKLzL9CzuBjUMgLdOn2cYKZoI02l0as?= =?us-ascii?Q?mxnq4kYQftgT4RBO+YDVR9LG2cv1gF6HimWiALJK7ZWtIcV9otfes3FnPn+3?= =?us-ascii?Q?PKHsDVmtPcFCUUA5z0Bh3RwdpfdFjgqDQo5tPzAbi3kgT7BJnXIXV9pnjyMi?= =?us-ascii?Q?KXDfm1NBcV3YibvcMaSZYArIKwAAKoaM326+24IZ2HBkNPEkDbdmLOawrZb0?= =?us-ascii?Q?PJA0pxYx3FKcCvD9GfTmQhc1oTfV4FyfEm9uH2VLBlC6NtfLhEpgjpIhGKDH?= =?us-ascii?Q?FtaR4KHoCdG08vN3+32mFkZiG0WgK56AvADhMpXyasOPFXE4MnWWTJwoNBYT?= =?us-ascii?Q?2TXQxbKRhnMBK/9pQSoltP4YVSFeEXaQZB2W6HquHFJnNYgV52pFb3jDPZEy?= =?us-ascii?Q?JROlp2yeTfIzVpQQF8/DdGHSLGzs1vHdAd3A3KIp2c6kfLcR27lArqWWrHFz?= =?us-ascii?Q?61GVfrPD4D6zX2SvbqQ5potJ/+CXOKYHiJESctucI4zCJEeNSquWuqHUV58U?= =?us-ascii?Q?l9UtjdT2EQUVW6wjr/ZHPOU/fhCCIppA?= 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)(376014)(82310400026)(1800799024)(36860700013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: C16cHrGb6DsVx3drLPbItq6KTlMry0dBHaI5tuO8vN+so/52ZHFIPiCVXgfuwKw0HDxDHsSqotGLDQT/Mb4NdppzcTD2l+KJjNkXVIxmF+1pGnF4vOj/V33xyTT3QUCCfvbLpc0to2SoYpH+8SScno4LuV85D58+BaP0BzNWxziXzaDw4VCr7dE4mxw8SBgEmZrf0GrylgTlEA3TyVGZn/WJNCdaSB9XIye8DZ6Rtprw+tU4f9jL+d2yjZ8FbV1Pu+zsKIyNVJi8nqYstrCRNkCRJd8iJ2dHFH9c3kYp6cYh8mFyRlrvN7KDSpud6UZABcnCyc7cXH9q/yI3KemH90i3OuHs1lKM85k/QCbf4Ne3jYf2Xwd8XcQCEeL8q48nNCqPNIW+wKGFl+sD9NjdmQdDEKgS5L3Dqm+wjuM4ZJWoZ/xn4mLcDk4V8Wpjp+O8Gle6jZiAH71ceVIC+nA5VXdU/wSpMHZby9g/9tvOXu6KpWYW2Jts4o9+GQ3cPeS2WqfVmZUNROD+TpXK0H3HIyhv89lxDbJ+BLQm4lFvRuBkCbk/m2oX310y1+ZOgX8Hw7LggeRXmrQgIAmEqpqaOjNp9WxYo0uUkPByp5EPpo4D3xXzq8jobIEPGBGDwif8S/ihiMsa1eTCOzaIPFS7ldFOdiK4IQZlI9z9vgQG4Dw= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2024 12:02:21.6646 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0557b40a-73ef-413b-9b9c-08dca58f2631 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: DU6PEPF0000A7DD.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P190MB1322 X-BESS-ID: 1721131344-302250-12642-24268-1 X-BESS-VER: 2019.1_20240702.1505 X-BESS-Apparent-Source-IP: 104.47.17.104 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVibGFoZAVgZQ0NDA0NzQMM3IOC nZzDTV0swkOdnS3NjMxNzU3NjE1MxcqTYWAIHNqABBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.257662 [from cloudscan10-222.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 implementation for probe/init and remove/deinit of the PCI device. proper device deinitialization will be added letter. Signed-off-by: Serhii Iliushyk --- v6 * Add driver deinitialization * Add API rte_eth_dev_probing_finish * Add correct API for finishing probing the device * Remove duplicated calling 'rte_eth_copy_pci_info()' via 'eth_dev_pci_specific_init() * Remove unnecessary comments * Remove duplicatet initialization of the numa_node v9 Fix logs --- drivers/net/ntnic/ntnic_ethdev.c | 82 +++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c index 68df9be2ff..d5983cd0f8 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,14 +17,54 @@ 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; + } + + 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) { + NT_LOG_DBGX(DEBUG, NTNIC, "PCI device deinitialization\n"); return 0; } @@ -32,13 +73,52 @@ nthw_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct rte_pci_device *pci_dev) { int ret; + + 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"); + + ret = nthw_pci_dev_init(pci_dev); + + NT_LOG_DBGX(DEBUG, NTNIC, "leave: ret=%d\n", ret); return ret; } 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