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 63E4145501; Wed, 26 Jun 2024 21:56:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C37C440657; Wed, 26 Jun 2024 21:56:07 +0200 (CEST) Received: from egress-ip11a.ess.de.barracuda.com (egress-ip11a.ess.de.barracuda.com [18.184.203.234]) by mails.dpdk.org (Postfix) with ESMTP id EB730402EC for ; Wed, 26 Jun 2024 21:56:03 +0200 (CEST) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03lp2232.outbound.protection.outlook.com [104.47.51.232]) by mx-outbound42-4.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 26 Jun 2024 19:56:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dtdvdIt/vIrGzdx16M75C04hF0JKNPgnNLpYcwChSZPIlw/G/5X+AQkcgNTQ4rJwLNpv00BSEJbiLDCGN2Cjfg44qx5Nx9FVlD4wezYQanXLlSCfPJwJklIIU9mFIJ9GXNEG7G/I3PiPwQuSRhGcRni3zSAD9lkX7brOlv0/fSVRBtgVO1syaH7mPrF0RkMLrVKtDvf14itXHomvxAUT2cEVcrVZS0ZcdRLCKZuEBQiSGgOoVy1uobupRAd8nyiBoa4pNkH2Enh94+FSEklYP8ldtyIxyoWc1UWv5zZsGxUQtGK2PfZKUBiQG50WlZyvUvkXLDLyIf+ACiuvLhPYjQ== 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=ap3dN6y2m8dqLb9tE+WLyXUExLWkL1RGhf0sGhv+fTYYVVApV3IiH8vG+zKHHFre6akUbNivjovXyVX6LMJ3e34NNsaTVl0z6a5BUZx8maepozYxSewvF8nnNNGf54uYP4QjL3K/RIIUGSTb/vQD/CvCd1CAuDmdpHMaWCB+nDwr4QS/7GQnIDEscZUymXCu1pQaMP+vSnB+UCFmXA/sCRvZxeHS8+EAG3aKCR3lPLzjuhzzUXzEcM9h4uXoZz5cgZfWDP7ixPQS8PB43k5+kZAbPKtqierl6Mu9RUpG0NzC+KoSzmnJaRa7j4fQfZ5UmAzRGbQiChE3QlUXr1r+pQ== 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=OkM8iMGqN3HASNZsUYVJ30Paf3dMsl+P4vMmR9ZSlpvmA6pXL7SDpxWHvKQrMKoMpeTx9Hrvj9TUkilrKVP7GpAqBT8jw+tj6JYAm8bSMOTHIFPnD6d4YWWKDOJpEtrzgB/wdog4QXkh47LZp+EcMMUz5q/tEWIjyRBiH6IN9m4= Received: from AS4P250CA0026.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:5e3::14) by PR3P190MB0921.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:8b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.32; Wed, 26 Jun 2024 19:55:59 +0000 Received: from AMS0EPF000001AC.eurprd05.prod.outlook.com (2603:10a6:20b:5e3:cafe::d2) by AS4P250CA0026.outlook.office365.com (2603:10a6:20b:5e3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.22 via Frontend Transport; Wed, 26 Jun 2024 19:55:59 +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 AMS0EPF000001AC.mail.protection.outlook.com (10.167.16.152) with Microsoft SMTP Server id 15.20.7677.15 via Frontend Transport; Wed, 26 Jun 2024 19:55:59 +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 v4 03/23] net/ntnic: add minimal initialization for PCI device Date: Wed, 26 Jun 2024 21:55:13 +0200 Message-ID: <20240626195545.1793419-3-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240626195545.1793419-1-sil-plv@napatech.com> References: <20240530144929.4127931-1-sil-plv@napatech.com> <20240626195545.1793419-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF000001AC:EE_|PR3P190MB0921:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: d4c87a43-ca73-44ea-3645-08dc9619fffa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230038|36860700011|1800799022|376012|82310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as7Nm9QckbJDRYjPvI6FpwJlvUmHiVgvv6wZPG9fDXPb1S0fInQdjTUIZ2?= =?us-ascii?Q?jl2rDa6kfQ9UVxqr7Q1GIO+q2KjHqeoeELQrcdU1wa90k1pt769zI7OdAmoX?= =?us-ascii?Q?qGzdPVI5W4ZVQ0nyPsesQVBZJVNoKImgVsKQzcUK7FboZX0CbXx1yAcw6ZIw?= =?us-ascii?Q?FWISO1ah+2d0JGBo4iKJIspRBFOizwQ2FeqfKtMVgCoYFllHRBWVHAH5oYfz?= =?us-ascii?Q?EOoy1hhqKwXGGHv03FrIHrBsqziSMsdawL/L3QOd93AFffUNOHiTCtKu8ybQ?= =?us-ascii?Q?TSALJ3pzNTbpR1nLW6exy+67CXsT3Li3lmn8jHq/T2ij0/T3ix/z9zxExWAz?= =?us-ascii?Q?YL+MrcSlb0siABwmBvFW/E8JmxrNBWQ8B43jbtLNjSzY/WlJroL/K7v6DqZi?= =?us-ascii?Q?PYamMiHWvia56hjDadXgIUxv5ubwrWOuuMd9w4OcjGtZ7YLXJrRw/Wa66djg?= =?us-ascii?Q?BGMDdXdXjbhMx133NVEeIgcdYa/3xpLtDjotTmrVV+Nd9FxeGAZWscR4fRvV?= =?us-ascii?Q?SCgShlMeorEiiLQPBgvnQkM6x+tR2vZxV8zMxAzcB6U2gHojdpLTkk5Fn4kE?= =?us-ascii?Q?y3q0w77upzQEiFwcaZCXJgcCuMmFbgzs?= 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:(13230038)(36860700011)(1800799022)(376012)(82310400024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: UY8OqWzEBKy6Qy4m7s/rxbpepf4lQmfxUPBm9Ebvbm24eqb6ol427jE6sfMEqcLobxNaxxuSebUXTEtzlD9o3O0XtNVTBpbRTlqi6QAXlr/BmuXvaT0a+tZoSnKatsfTrO1hxBnXN84z9DzPiUW6Q+HU8R4zDO3jGxgsGQd1eA6nCS0h19+e1gjbqTYQb1/ttC3eMXCx2XOUEgBsabUW+bbA3OXIvtsuOYeNa18aBx2THheYHizdvqvk8fbKo15+pYhJPNKXu5AelnpUgF9QL9muOZaAnUEiO2QqL8zG+Xqchu5dA9X5sWA6qHHm7kCmAAOa2wL44ofHuiYzf7YmBtIO36342TR6bfj/e1CgOcWeA61SobJ8zTtzx18BZClVuEyNVpkkWqe4pvTe+DmM94Twq7NaRehbcNfT8Jt5bCr4X0fwjkd141I72qojRzypQluPRRP6lxUOJF4JCBcmTeKbOieP20/cwUpvLqv7Kx9G0RQt/YfUNkvz+GwISr2/yC014e2GrlXT/YtjrU7LdCobHqdqvv3I35ymzxbuKJExVDHNr+Jxc1UJlc5Uu6Dq+kA5plum5IzjtWgYyWLe+HXfzDy1+VMhXV2twb6a+fhpl+9OiLHpKmLobT9LjfTXUe4CvrnS+UiUw7ZaKWpigQ== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2024 19:55:59.0673 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d4c87a43-ca73-44ea-3645-08dc9619fffa 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: AMS0EPF000001AC.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P190MB0921 X-BESS-ID: 1719431760-310756-12660-57149-2 X-BESS-VER: 2019.1_20240620.2317 X-BESS-Apparent-Source-IP: 104.47.51.232 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.257218 [from cloudscan11-42.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