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 3941945635; Wed, 17 Jul 2024 15:33:23 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 09A9040289; Wed, 17 Jul 2024 15:33:23 +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 B90D140289 for ; Wed, 17 Jul 2024 15:33:20 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2113.outbound.protection.outlook.com [104.47.18.113]) by mx-outbound23-33.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 17 Jul 2024 13:33:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GfWN1LtBZzU286YJBqblGAEaBiLNouH5OKB9Rk1P8EnZsSl9nC3wgAPXaLEQC0EP1Iv+TVniUHUGxGR2oNjqfStd3kPUgQcUsvoo2giPUMm4IFmy7q1WoaTUzNLOu0+9gnQoXMqHkoQvYo6AXST1N36HEmKDdJ+oZKc7XLuGFUzjExKL6i6vXRyvTDTnVoxT4AR3sQ0Pk/nTbN+kNGwfUJ4PRkFQ7FB7gLY4EtS995Dpben/Rr8eSF4ZFXKGqi679r4nvhuVD2eoqq7M+dmLR6muEIkQzON148qWjOe406vMdDIyUGkzGlboswuc0bHpt7350V36YLI5UwHE0yf77w== 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=uR1ZF4xRkvlroFtUKK8thRFWFChpEC5a+xWf5XIy9So=; b=ViYhH5iGNxMWV37FAz6DaXZBTxEZIg6fjlV7qOUXXrwQhYSh7B+ARFU62dK2j79WrpnLzU2w2zhDxk39cBKNlz0mgANUTmU03cApLkBduTocnpoQMEhoC7y1fv7GZ0Ei51vEgnzgQuaBFkox7qsvmu28/z0jb6QNvzs8YYy/s9ZAux6XHCTbnBsrgYnmZfLh5jXY8PchfkeJIdNkRbsJYU0hBBL69cv6LwQdxGvJYn31wf+HRtWT12VDizgpTUo3nclHwAODp9tQJuAMTrak1pFRJVHhiIkXoEbnmBm0RJm2Augxl1v9EU0Dl2gbGvii6J9qbLsIZGTJDRGqP5CPnA== 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=uR1ZF4xRkvlroFtUKK8thRFWFChpEC5a+xWf5XIy9So=; b=V/mhAu9BILGjptfj2OUvR/hQiyDnn7vNTg83rJ5hVw+Mn2VfrF9gTJxxu8/PI7EvxC9ze2sJ5r1zZbo8wcwlw4mbp3kOqZeQiobTQ/N5VggfrRuHQHkf1frd1s0/12McoDJCx6CLIjfFSFlW2woCGwoY2pgCmPZx3W3o5VHl8us= Received: from AM0PR04CA0090.eurprd04.prod.outlook.com (2603:10a6:208:be::31) by DB8P190MB0700.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:123::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.14; Wed, 17 Jul 2024 13:33:18 +0000 Received: from AM3PEPF0000A799.eurprd04.prod.outlook.com (2603:10a6:208:be:cafe::1b) by AM0PR04CA0090.outlook.office365.com (2603:10a6:208:be::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29 via Frontend Transport; Wed, 17 Jul 2024 13:33:18 +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 AM3PEPF0000A799.mail.protection.outlook.com (10.167.16.104) with Microsoft SMTP Server id 15.20.7784.11 via Frontend Transport; Wed, 17 Jul 2024 13:33:18 +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 v10 03/21] net/ntnic: add minimal initialization for PCI device Date: Wed, 17 Jul 2024 15:32:50 +0200 Message-ID: <20240717133313.3104239-3-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240717133313.3104239-1-sil-plv@napatech.com> References: <20240530144929.4127931-1-sil-plv@napatech.com> <20240717133313.3104239-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM3PEPF0000A799:EE_|DB8P190MB0700:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 5cf74059-f599-4793-f5a4-08dca66504ea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii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cCMWZMyyGoSfF2AKduIqxoloQ0j5?= =?us-ascii?Q?JNnHYAGk2egEoenQqqCY2nl/GJ2fKJ27okNj8IzsXUfUY9UBXT7KmTzlWode?= =?us-ascii?Q?IDcj9ghGnII8mhIFLttQKmR8YovVgf0CBcQu3fvItA5aDV/ZIdBUkBBYstTm?= =?us-ascii?Q?Yxy7HmpQ6x8zutcVUwgQ31mE0fHKwMgz5S/iTdnCZDpuE2tQb2Fe7jDeyGyI?= =?us-ascii?Q?+T3WC6AwoF7WjjZ8DCKs30Ac6NYL3bIszj4zyHdh4yu9RA67MG+uIA+olJeZ?= =?us-ascii?Q?9Z62DKjfDdwvycWeZt/K55NdYJeR9r1TmJEsZzI+UAaIih+6x/ZVsOf2yI/O?= =?us-ascii?Q?ZLbKXc/7pio0JRA+F280L4l/cM74AV+afShmQKn2S1E+cQpiDr6SnMH4f7sy?= =?us-ascii?Q?SlH30Y2b4+PrfnbDGNjf+WEbXYqyi8+CNjRsOcblL0pQAt+l+kJZ6ARiRzuf?= =?us-ascii?Q?zZRQGwkxZkvEgaTOnydD4Qm3LtOFn2fIKoOWloksQDPzdci+yXx8MAISR6ut?= =?us-ascii?Q?9WOg7XGbdySLgR3m3uVqCHHrOnvwQ98ODApETRnTUPydCOAmMps583lyO783?= =?us-ascii?Q?5wLMNnwbTMAOkFTF54/IjV6YNdFz3dqp?= 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)(36860700013)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: AUEAxy8Jal00ZY9+qALN+pX6Q0HseSNoK9KwygtY7UPNQywNg0/ofdU621fC7DzII4LuU1yE+GiB8TV94HJEnDWxnkHboknu+ER1YrI6MR7zHc7wN9NZswWkdVHpg//y0lzDJ0kQz6cnDVkSjor9IXkKBM8r1XB5T+GrC1hZOOE7ISBWd3BZbZOFAJaVORGucnn+U3fwTkEFcTbT2gHn5uk0LNlKTjyAp1mHutv7BleO1RFH6Vluljf5tk3jl1GZgCE4DOfvFEQWOyqwX96oBpzutT1s/MKvvTzmAgUlkoQhOJsUSKLbMdWKgnxzXk9YTbobd2UzzbprsTepV4awbIcPHs2u89CtpmvcXjZ1y1lm2YaWzXyEXkFzWMjBWdDMdC4fL9JXs/g5DVXBIZehUS8eDfevhTYrsAZnUg0Veiok5nOygbJr/NvtghBhQ2yETurrkrO6uv9fOSAwNyKpo5y8Qe8pf3tESvdFKOjm8DdMz7DUtEEL1swClr6/wyu1T+2JEwww2p/yusddIUkXHw/1DSW7xxxv2zrjlTdkGJtsyu0aDMgc2+jG4etV/ozqMQ4jwkLpwa7lHU4MRuNI57fE30CKtVAX+zFiRBhyaEqe1GHXB6hflhoCJARrH0dI4uGM2jMJliLjrQbBR/JUVg== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2024 13:33:18.2776 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5cf74059-f599-4793-f5a4-08dca66504ea 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: AM3PEPF0000A799.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8P190MB0700 X-BESS-ID: 1721223199-305921-12787-14939-1 X-BESS-VER: 2019.1_20240716.1757 X-BESS-Apparent-Source-IP: 104.47.18.113 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVibGFoZAVgZQ0CQ1xdzI3NzUzC I1KcXULDnVyMQ4yczS2CwlJcnc0iBJqTYWADJd8+hBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.257687 [from cloudscan13-15.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.43.0