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 2576542C61; Thu, 8 Jun 2023 17:45:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E3BCF410FA; Thu, 8 Jun 2023 17:45:55 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2060.outbound.protection.outlook.com [40.107.237.60]) by mails.dpdk.org (Postfix) with ESMTP id 2107740A84 for ; Thu, 8 Jun 2023 17:45:55 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UCacdQ4wuG4uIF72m4hXEwsgYH9FZHSE5q/uu0q/8eew09nPVRQkkRDO2Ge16zxHWQ9fy2kJ6T7B2MSKhczji+Tp5LQ10Dox/eVw1KU01e9vnd1I0jtUu7YkG1iHPGjYqbZ/V7f8qATcF9VvbnrIhFz/z08X/1myEZQpbyjw2Fs74nwfkDhBZAp2pI0d/CcB+Seco1yi21/0blBhSiqqk84HYzw0XkjCDLsDt4PNQPr3EeMl9rBnUuZjQtZOAgE/OUjivJbvgSoZ3HYIzRxtKndKBZR4hiJtTuRMbIeS6IqH8WrDRGRcp4B9IuDTXc/327i9sJ1lZ1h2LHx+sTVMgg== 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=atfOekSLusCMNLezQ8gsDh2cdgLofKrMrgcT1lRiRQo=; b=U3yThKX6UGfW4y2egyxO/VRiro0J43riShptMvkxoSD5KzaYYmPzidL+b4i2mI6HFe692oyb1s76jKazOcKeXYj0Kl/TnLLBu4UHtmXX3M0O2Onpj/qMCq1y7lGuw2Sd/6lICrjvmtUgPTcxEAnq9BRRwo2DWqo9tIKlTl+KCborSs5lo+U4o8nYSGMta8iS2XrwYZ4BZqUJnlDvisZkbgT6WjZnW2jfaYSJKjBfJ/jdcnF9ZO7oQKLLDE/p4i0DFM3E2XULtjyd3VNBcVjUlzkDclitRqj0TIZHvd+3tsrCw2dTkFSLkcCxRPH7TH6a38pf3uUyEmCHOrbz0JiYyQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=atfOekSLusCMNLezQ8gsDh2cdgLofKrMrgcT1lRiRQo=; b=KP8OW/Jv3R8f+A/b7bF9KmUE0SNnmyDai+vb/vJiUhF7WbzbhpbQlZ3QX86o67xZQ25WbhFKsFU3K5CcvgwA7XKOmR55XBJEkuDSUsDb0hxOhWWOjD5IDg1szqu00r1VREg+fW+gugcnWJSGk8oXN6lz61xwwLTvogU9pJjQsPaBamLxkaaJGia6u9rZiXi+6h2b9gIaUaN5gPbZUFoi6AXzSF0r3jb23BHLqAOVIYhDIos8VeDZIQxyCCdcoJ7eUvc0oFTm2Ur0I8JSp59HlI+LaT6OzVX0e/xM3uNIR+GBN+w6BMFdnTxcSlHKof9E/5vEbAKqDLQjMpPu92nhNQ== Received: from MW4PR03CA0199.namprd03.prod.outlook.com (2603:10b6:303:b8::24) by DS0PR12MB8072.namprd12.prod.outlook.com (2603:10b6:8:dd::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Thu, 8 Jun 2023 15:45:53 +0000 Received: from CO1NAM11FT030.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b8:cafe::bb) by MW4PR03CA0199.outlook.office365.com (2603:10b6:303:b8::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.26 via Frontend Transport; Thu, 8 Jun 2023 15:45:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1NAM11FT030.mail.protection.outlook.com (10.13.174.125) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.26 via Frontend Transport; Thu, 8 Jun 2023 15:45:52 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 8 Jun 2023 08:45:42 -0700 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 8 Jun 2023 08:45:40 -0700 From: Viacheslav Ovsiienko To: CC: , Subject: [PATCH v3] eal: choose IOVA mode according to compilation flags Date: Thu, 8 Jun 2023 18:45:26 +0300 Message-ID: <20230608154526.5165-1-viacheslavo@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20230412171949.27665-1-viacheslavo@nvidia.com> References: <20230412171949.27665-1-viacheslavo@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT030:EE_|DS0PR12MB8072:EE_ X-MS-Office365-Filtering-Correlation-Id: 05b07675-6ab9-4c41-074e-08db683770ed X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pXV7wmLlvwXYpdwHND3K1I47brEFp77us/dyhyU9MyM72LMClw7DV0KWkCN/ne+gHf/EPrQM0s8Pxu0r6GQ6jJ8+mTARU8k5wYXq/nUlZcMptqyFfcDRB/H3MIz/Ohy6UwfskYT1/kKFPcHdTjlxp8H0iDRUQv30K4L7mcdv+xEAKoQoSVLuLV7lZernntnQJoXEPOSme7sK4lfAJI/VgS9KiWGPX4wVjKwGRF2sUCL2UEV4eC6vcjmup5dLZ84QCV+ItD7VlMjSlIXkrAvnZndaDlsd2HumfZb9seZCwyOkKKDW9tty3W4ugpSV1ADRuJSsq3uXVuc7nWeXiIMqMmKib+3ckh+cYH8/yuUMPhotVGlUxhnCBglPHw6HhVSBTNIWjs3wTNPc05R2GZYggtqpaX0kXp3NcvPiqU9KFSSjQ+5pyTD6Sx7wsmCPCOfPkwwSYUsOOH2uL4kH7PAwq2TAuuj69l3YSSWNmSF1R8Ijy0xVbFQrFV2S+ufvyk1p2njtuWk1VkvejgsoiNEcOEq6K+6PBOjvZ809LhaPr9OTM5wE+CwRyVYQKu4wCC+AzSzv0LGUb5dpuJMXHwhl32u7sfp5FqvRYiqIHFAU0no098Za9afQNsgRTHWF7V1FImQdoK/cmxB7jGfMfTakuMmBkTGziKMdK2zJjzABH5lFMHbp3YXmqVOA3gFbfceYMWm2IS+ckB8Jk0//n8A1g43yldPWuE4yJYbygfU4gk/IdccTov0lCt+eLRz7ouJf X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(376002)(136003)(346002)(39860400002)(396003)(451199021)(46966006)(40470700004)(36840700001)(4326008)(6916009)(70206006)(40480700001)(55016003)(5660300002)(8676002)(316002)(8936002)(70586007)(36756003)(54906003)(478600001)(41300700001)(40460700003)(2906002)(6666004)(7696005)(82310400005)(86362001)(26005)(1076003)(186003)(83380400001)(47076005)(336012)(36860700001)(426003)(66574015)(2616005)(6286002)(356005)(7636003)(82740400003)(16526019); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2023 15:45:52.8566 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 05b07675-6ab9-4c41-074e-08db683770ed X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT030.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8072 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 The DPDK can be compiled to be run in IOVA VA mode with 'enable_iova_as_pa=false' meson option. If there is no explicit EAL --iova-mode parameter specified in the command line the rte_eal_init() tried to deduce VA or PA mode without taking into account the above mentioned compile time option, resulting into initialization failure. Also, for FreeBSD and Windows EALs the IOVE mode checks were added or moved to be after the mode selection code block for final checking. Signed-off-by: Viacheslav Ovsiienko Reviewed-by: Morten Brørup --- lib/eal/freebsd/eal.c | 28 +++++++++++++++++++++------- lib/eal/linux/eal.c | 5 ++++- lib/eal/windows/eal.c | 28 +++++++++++++++++++++------- 3 files changed, 46 insertions(+), 15 deletions(-) --- v2: - minor test message update v3: - added the same change to FreeBSD and Windwos EALs - added/mode chosen IOVA mode checks in FreeBSD/Windows diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index 7daf22e314..ff7da2473a 100644 --- a/lib/eal/freebsd/eal.c +++ b/lib/eal/freebsd/eal.c @@ -694,22 +694,36 @@ rte_eal_init(int argc, char **argv) */ has_phys_addr = internal_conf->no_hugetlbfs == 0; iova_mode = internal_conf->iova_mode; - if (iova_mode == RTE_IOVA_PA && !has_phys_addr) { - rte_eal_init_alert("Cannot use IOVA as 'PA' since physical addresses are not available"); - rte_errno = EINVAL; - return -1; - } if (iova_mode == RTE_IOVA_DC) { RTE_LOG(DEBUG, EAL, "Specific IOVA mode is not requested, autodetecting\n"); if (has_phys_addr) { RTE_LOG(DEBUG, EAL, "Selecting IOVA mode according to bus requests\n"); iova_mode = rte_bus_get_iommu_class(); - if (iova_mode == RTE_IOVA_DC) - iova_mode = RTE_IOVA_PA; + if (iova_mode == RTE_IOVA_DC) { + if (!RTE_IOVA_IN_MBUF) { + iova_mode = RTE_IOVA_VA; + RTE_LOG(DEBUG, EAL, "IOVA as VA mode is forced by build option.\n"); + } else { + iova_mode = RTE_IOVA_PA; + } + } } else { iova_mode = RTE_IOVA_VA; } } + + if (iova_mode == RTE_IOVA_PA && !has_phys_addr) { + rte_eal_init_alert("Cannot use IOVA as 'PA' since physical addresses are not available"); + rte_errno = EINVAL; + return -1; + } + + if (iova_mode == RTE_IOVA_PA && !RTE_IOVA_IN_MBUF) { + rte_eal_init_alert("Cannot use IOVA as 'PA' as it is disabled during build"); + rte_errno = EINVAL; + return -1; + } + rte_eal_get_configuration()->iova_mode = iova_mode; RTE_LOG(INFO, EAL, "Selected IOVA mode '%s'\n", rte_eal_iova_mode() == RTE_IOVA_PA ? "PA" : "VA"); diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index ae323cd492..9856ec9d12 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -1081,7 +1081,10 @@ rte_eal_init(int argc, char **argv) if (iova_mode == RTE_IOVA_DC) { RTE_LOG(DEBUG, EAL, "Buses did not request a specific IOVA mode.\n"); - if (!phys_addrs) { + if (!RTE_IOVA_IN_MBUF) { + iova_mode = RTE_IOVA_VA; + RTE_LOG(DEBUG, EAL, "IOVA as VA mode is forced by build option.\n"); + } else if (!phys_addrs) { /* if we have no access to physical addresses, * pick IOVA as VA mode. */ diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c index 033825c14c..9c9a49fda0 100644 --- a/lib/eal/windows/eal.c +++ b/lib/eal/windows/eal.c @@ -362,22 +362,36 @@ rte_eal_init(int argc, char **argv) } iova_mode = internal_conf->iova_mode; - if (iova_mode == RTE_IOVA_PA && !has_phys_addr) { - rte_eal_init_alert("Cannot use IOVA as 'PA' since physical addresses are not available"); - rte_errno = EINVAL; - return -1; - } if (iova_mode == RTE_IOVA_DC) { RTE_LOG(DEBUG, EAL, "Specific IOVA mode is not requested, autodetecting\n"); if (has_phys_addr) { RTE_LOG(DEBUG, EAL, "Selecting IOVA mode according to bus requests\n"); iova_mode = rte_bus_get_iommu_class(); - if (iova_mode == RTE_IOVA_DC) - iova_mode = RTE_IOVA_PA; + if (iova_mode == RTE_IOVA_DC) { + if (!RTE_IOVA_IN_MBUF) { + iova_mode = RTE_IOVA_VA; + RTE_LOG(DEBUG, EAL, "IOVA as VA mode is forced by build option.\n"); + } else { + iova_mode = RTE_IOVA_PA; + } + } } else { iova_mode = RTE_IOVA_VA; } } + + if (iova_mode == RTE_IOVA_PA && !has_phys_addr) { + rte_eal_init_alert("Cannot use IOVA as 'PA' since physical addresses are not available"); + rte_errno = EINVAL; + return -1; + } + + if (iova_mode == RTE_IOVA_PA && !RTE_IOVA_IN_MBUF) { + rte_eal_init_alert("Cannot use IOVA as 'PA' as it is disabled during build"); + rte_errno = EINVAL; + return -1; + } + RTE_LOG(DEBUG, EAL, "Selected IOVA mode '%s'\n", iova_mode == RTE_IOVA_PA ? "PA" : "VA"); rte_eal_get_configuration()->iova_mode = iova_mode; -- 2.18.1