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 D7C8645614; Fri, 12 Jul 2024 17:48:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E555342EEE; Fri, 12 Jul 2024 17:47:50 +0200 (CEST) Received: from egress-ip11b.ess.de.barracuda.com (egress-ip11b.ess.de.barracuda.com [18.185.115.215]) by mails.dpdk.org (Postfix) with ESMTP id 9B36442F55 for ; Fri, 12 Jul 2024 17:47:47 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2104.outbound.protection.outlook.com [104.47.18.104]) by mx-outbound23-2.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 12 Jul 2024 15:47:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GgRAPfex3KAi5PzXDZYDEG1L4KiOpvXmseTNQ6XudpAG/SUeq/p7KtbtY+T1NB0CTSIPQ0ay6BIxXnXNC8WpW3fwK/+J+9mAjpTVl5s7Ehs9Wz1yeJwyz0dcQiLPEYSrzr+wjhVNAERi3jJGhA/SZbcUonMebdLhKPfg/VmxXSt02do05OR6oGcG7SUAlEWylLENlj7hgUapy0nZXU4K7QDZZoMwGVcBvbSm6oQIiEUj2SupPojwMraEM3y47wsxF71kbmyqkusDBagIYMs0isHujPlCMujx7GuV8+ZLeK28xTkydmqhLvIwTnhPRdEQKRCoKY9gkM6Nm2t6rIOxdA== 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=e/86QTzf6jKZcK3h5e5aX71s4pRjsED1PrT285DBxQ4=; b=LBEafp34mFcVthkjEWfIR+3WiV0uij7vx+52mZCS2hIvXzSGeBTX/mg0YNND/KqUlAHZ86/u+vKnregxBw+zkk1midjxWK5nhNnEIqdYbmExTlOOA+fQUkR7Vavro3iBH8NtWSl0UFSSYnCSxKap4XhSiBgUf8putMp5/mbc0qjKSqnvn9R1gnBjfVF09dleFXPBDL2ORCjZel8AKfdNU7KJPXmqzzBtcHKdHF52mndPVaRi7Bldg4isuUBoxJxnvLPHdSr2F9yNS5C1jRyODsL/zn2qR7ooaAIP9sK+RBON5rUszzWftfu34hdzz2D96NTFVoYXW38d67SD2VsuxA== 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=e/86QTzf6jKZcK3h5e5aX71s4pRjsED1PrT285DBxQ4=; b=di8R044fD/9hp5O+8JO84beM63GjvUMsmMKJtdHFRXGI8AYMI3XcjGlipNxJrJo5j68lsZ22oRSRlLf78i43loL+B9ytncdCyENKb+LXYMLTcpQRvgmuS/UzyK49wxByzuCbx2FhoMAv9R/7mGnjpr5DS7n46jcXcAP6StZ0qMA= Received: from DU7PR01CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:10:50f::7) by AS4P190MB1782.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:4b2::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.22; Fri, 12 Jul 2024 15:47:43 +0000 Received: from DU2PEPF00028D0C.eurprd03.prod.outlook.com (2603:10a6:10:50f:cafe::ed) by DU7PR01CA0007.outlook.office365.com (2603:10a6:10:50f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.23 via Frontend Transport; Fri, 12 Jul 2024 15:47:42 +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 DU2PEPF00028D0C.mail.protection.outlook.com (10.167.242.20) with Microsoft SMTP Server id 15.20.7762.17 via Frontend Transport; Fri, 12 Jul 2024 15:47:42 +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 v8 03/21] net/ntnic: add minimal initialization for PCI device Date: Fri, 12 Jul 2024 17:47:13 +0200 Message-ID: <20240712154737.1339646-3-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240712154737.1339646-1-sil-plv@napatech.com> References: <20240530144929.4127931-1-sil-plv@napatech.com> <20240712154737.1339646-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D0C:EE_|AS4P190MB1782:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 6f798289-5c5b-4993-050f-08dca289f7b6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?SE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qrAnZ+AKiolSzLU?= =?us-ascii?Q?Vmb+w2ZBZOoCRtAZvcn+6lytYwq1m0cfMywyMiLZ9NpurDVmTJUDVsdoU5MZ?= =?us-ascii?Q?e4l5gzmsk214l7/h/iTKfo7v75SGu+f8cINF3yRT+28A7wzrypRzqwQ7S9SO?= =?us-ascii?Q?gK/UKaD5OlkcO0nc0wWMi8gz+fHg1xjoF6/JffPL/dzVqGzNs+qcmA5SKYZj?= =?us-ascii?Q?qr8ss4jJsfGFV/MBsatTu6YxbdvLQzagyC8JKFyrMqg2OnQagjqHkxzU466B?= =?us-ascii?Q?Qoe0Q+vZRVIBE0TdvEdeOZV5lCM2x+PPoA4JiuQnE1Kyb2AzD9+7LRCGV1Rt?= =?us-ascii?Q?BAypBMpisA1pLeAG3OQEYZf/gi0DGT1ACyLRDP5y6FOvoz6aEg0CQ8zHVLTf?= =?us-ascii?Q?Kc0iySTr52sJqwmFlsc759LaXbgmBiZQ8Rc/H35pG722QEheUUMXT7HCkuKz?= =?us-ascii?Q?3uIbzNjLoBC3j/Vwbtuh9CHZZjs4sS9Nep+j02+o1sqAROphk6aWIksq76xD?= =?us-ascii?Q?r5Pwr86fLfUfNLtiShQRU/z7YAyMr9o0HcGtJjFG3R+Knv6I6TdSa7cAiL9G?= =?us-ascii?Q?3hfnbobHQgpIulw1OYsl1sj5jbm/ZqPA?= 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)(36860700013)(1800799024)(82310400026)(376014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: sVg3RKHANNGh2xI/v7Iec44hV7W8mT+W9tMGar6TBWtlev6nJf5PJMH+cKNS2UB3eQOxgUNoxLLRvtqNDiQu3xb00NjVvuyQb+ayq1//S9ptRfND4QP/ihzZhLNElPLdilcU3xS/1LRYdyfnxZ1S+P7pK8mXAsHFNbWzgF6ijYcTswflf5uuTjFCc4xbsKldxvsIAfa+tkpVYbLaaHlDJ6OQkXr/PW3KQREEYo1CxD+bj9LnmaYfgo8CD8EVIpLtnee51QlqlICfric8skPO0s/RU3QzNrCBQDUI5WP3of6IyZbn87efEB85aj1w0wqKlF+R8Ak4sBQaaDM+d2fJvFFmpLrSYAGY2RT6M3K8KgmLJsOHaf7+kQtMdSqf+rzCy2L76zUFSp+dAqCGrIKyiPT79jsDMVi9Uefl1BEfG3jtOyvTqf8TdycV34pkif/6I7kh5meGg0+l03yWYT/VSfSUtRKjHEE1pLEavqgDebo9rdDxyGFOFgqRrWVTsPgk4+ajh6yPrjYuQd3v5dGuaMFBXTaV15lQcCXzkEMkc8IzoeckTVe+5TYGl+MJzZXgiuNLtCLmdR+WF9vqx60l5rpLngH2uJ4iHDr3fxDIfkXaxuB2HXkTdiXvgwz0qMwJwAmF+8kRKZw4XQZ14BjTRA== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2024 15:47:42.7075 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6f798289-5c5b-4993-050f-08dca289f7b6 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: DU2PEPF00028D0C.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4P190MB1782 X-BESS-ID: 1720799264-305890-12645-32719-2 X-BESS-VER: 2019.1_20240702.1505 X-BESS-Apparent-Source-IP: 104.47.18.104 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVqYGBgZAVgZQ0MLExMAgycLMwt QoOc3QwswoxdIyLdUyyTzJyNIixcJAqTYWAE4IN/xBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.257575 [from cloudscan13-118.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 --- 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 --- 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