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 E0014A0543; Tue, 25 Oct 2022 09:56:57 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 93BF340A89; Tue, 25 Oct 2022 09:56:57 +0200 (CEST) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2072.outbound.protection.outlook.com [40.107.102.72]) by mails.dpdk.org (Postfix) with ESMTP id 819BE400D6 for ; Tue, 25 Oct 2022 09:56:56 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VJ7jHM6fKhgD72uiNB2PNpPIwgcL4spEyhQdvX/tNJt6RpA2g5rWI0UUX/ilfRn6VSBtQFgFiCLEBhzRhgioGtrC6AvqRtpU6PnTFTfrfTf/wEWswIJKSGbRPZPEnvzaeQvoN++Ii3IU06fb7Rdw0Qs2JsZCAlfVIY0qrPLdbPFPZjIFvBL/XBMa7BNyPaWcxpeaFfRNQv7pOIGxBocb/gWQtnAfpt/kFmsEVKSo/GdR92ZjyFO1uGEZFBUFyfeiWwm7Gsr2l4VLZnvaBgB8at9jEsWERJHX3+k+VS3k3EN4ra2ioydQxHqHq1/3pi7pZbyGWjQ1TqVRjojy6Jsl1Q== 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=puyY6h/spzUYLOi9QKUVaeUhw+Vt0hQLrw3w4JCUSJo=; b=HwfQetAM/AIG3gi/oqIKWR9to5EjSEun2TMgJ7m9rL/0ZEPrauHFq98T/Skf5cF/22ATM847hp78agDGPcRjvz6H2pCiswHBlpbs1jtihKO18UH0oRFCxr6FyXkisgsR57Ixtzj1Nn+LBuQ8K4Tjub4GGhePWcVwVaPTNVsM8vOcp3YfgVFjzGZGa6E2tHnxUIBPeP7fPWcvTx9QwHtx7uRwk84WAqtqHk5ACPpVsR7EJvL2Dmja7HPmTeI4CDiTHmItSs1V7VJMnu/f7Mq4okB5GkQN05NmeZDPx1POYxdr4ZY3jxe1BCOeZYW7s0AOlv3gVq1CnmkmOgVUrsvlgg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=puyY6h/spzUYLOi9QKUVaeUhw+Vt0hQLrw3w4JCUSJo=; b=ckRpBb5YO+e/hL8jZoiL3coWKEX/MbRZwizQaqq5vE1+ZhV+fuoHK3uYTCl5ofj+Ak0xsUowDfVaw4+CslGDXYGh9UsYSQGMBKYfz5Zcinh1fy8CgsRxNJ3fxar0ZdJ9ftq2PRcX1vZ+5Ls0Lb+Uj87zuD2VjFZza04gZfx/2rE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from DM6PR12MB4297.namprd12.prod.outlook.com (2603:10b6:5:211::20) by DM6PR12MB4105.namprd12.prod.outlook.com (2603:10b6:5:217::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.23; Tue, 25 Oct 2022 07:56:54 +0000 Received: from DM6PR12MB4297.namprd12.prod.outlook.com ([fe80::b9fd:e732:4585:6b25]) by DM6PR12MB4297.namprd12.prod.outlook.com ([fe80::b9fd:e732:4585:6b25%7]) with mapi id 15.20.5723.033; Tue, 25 Oct 2022 07:56:54 +0000 Message-ID: <67ed7c7a-ec77-98d6-3ec6-351c1fde75d1@amd.com> Date: Tue, 25 Oct 2022 08:56:49 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH v5] pci: read amd iommu virtual address width To: Stephen Hemminger , Michael Piszczek Cc: dev@dpdk.org, Vipin.Varghese@amd.com References: <20220912160157.3642968-2-mpiszczek@ddn.com> <20221013181602.873166-1-mpiszczek@ddn.com> <20221013181602.873166-2-mpiszczek@ddn.com> <20221024110927.5ad71ed1@shemminger-XPS-13-9360> Content-Language: en-US From: Ferruh Yigit In-Reply-To: <20221024110927.5ad71ed1@shemminger-XPS-13-9360> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P265CA0171.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:312::17) To DM6PR12MB4297.namprd12.prod.outlook.com (2603:10b6:5:211::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR12MB4297:EE_|DM6PR12MB4105:EE_ X-MS-Office365-Filtering-Correlation-Id: b6772fee-2d12-4830-546f-08dab65e7b98 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0UesMYhjMPHMJICs3WvMtslwsivjWh7ECbbF6uqXYZAfDCQvY8Gm/jEIDLnIhUGjOKlz5/HLXvdirbVYv/LhCY7lR8NSgOlB1Uivdys3lcm54rlAwtK/WBxEO1vcd8Ck7Xo50xPdd5W+uXDyxz5h8LlZ8SxAR8cJcYLPmAG3tkzpKhb7LL4iZCXM3wwGaSwNh9NZ2XUg5UVMDBL7csHTrljZwgoL2vzxdtqkDSH/qCtDpTb580DZrwyByrxEfoEXcHBhTqmmiYI83GIcxCmBVuVQjLcygJjW1wGt0/2UjsMCrfYwxcXzQ0g0F5RBSxW90w1OHyFyLISGXZTx8nFwhdOOIMM9ZlqCy34AfKKG9IpV5vvgeAEdZ1NHtj+1MfQOqWj/guwOmeelBQ+8k8Dpk4BAQN0rMsLOVER1ZojjLoMHkNNWTc55Do1lB/OCki/TuvUh1Yv+1VC5/Ua2R9r83zuusPT1m4DR+urCewlgLwtaqNyqGzoRh8nTuvY2AgVuobV6KGyZKZMo8KHfjR5P6rozceBPNLShcaPmAfJCJutP5R4SXJbnsPeJD2sks8vJaAr8PbL+x7dDttJNnjTAWmrSErXaZinSAmWjfd6DDalp9DlQKt2vidNezwnlDVWbpytK9zvBY/gSZ6PXKaYwEMGbt5UZhpBGMFaSm4X5k+jpGOK1toa3mC3xbUYBoxFjRiYAvjsC4qqFEqQ642iIwS77yK6DsoMEml6y+lpiK7rJZn3cJdbives8i6Yz2kQyK0J+XZ/+5jLm9AG//moOOzoKTNQ0MSPBMhfjWaRmfy8= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR12MB4297.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(366004)(376002)(346002)(39860400002)(396003)(136003)(451199015)(44832011)(53546011)(31686004)(4326008)(86362001)(5660300002)(6486002)(8676002)(186003)(6512007)(83380400001)(478600001)(26005)(38100700002)(2906002)(36756003)(2616005)(6506007)(8936002)(41300700001)(66556008)(66476007)(316002)(31696002)(110136005)(6666004)(66946007)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?SklTRnc0SmxsN1NzUVFvcHh2L3VqNVVZWXJxQVlVYk5nSTRXRmRsWHdzbTlm?= =?utf-8?B?YmlKZ1pRc05kaFR1MSs1N2o5cWkzYjRRZGp5ZUhjeDhxYXhJYkFtYUpjSU9o?= =?utf-8?B?aTNrcXRDMmFmdkd3MHpPVGVHL2xKeGdaa2h0MElRbUd4TUdDR0UwT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HK0M2YnRtb1gyak0reWhlTkZzM1kvZUtVTHlTbVZZWXAvM2pUekV5?= =?utf-8?B?ZGlWeHZqNm5mTzY2TjF4bExIeUxsb2k2MGR2TzJSV054MGRsbTF5c0pwMDlO?= =?utf-8?B?bWhOcDZqZUI5YXZiKzVVdzF6TUpKMHlUYlEzU0I0eUJnTVQrdFNQUE9NMjBV?= =?utf-8?Q?5ZH++Wm7ChELUnxXi5XwhtuKE?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: b6772fee-2d12-4830-546f-08dab65e7b98 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4297.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2022 07:56:54.5451 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 6O1azmCPA44hRrIsn8Giz/VZd73JEwDY+eUpOIV+qNrAe7LjwAqVVZmPPlXFiENB X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4105 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 On 10/24/2022 7:09 PM, Stephen Hemminger wrote: > On Thu, 13 Oct 2022 20:16:02 +0200 > Michael Piszczek wrote: > >> Add code to read the virtual address width for AMD processors. >> Updated pci_device_iommu_support_va() to use glob to find iommu >> capability files. >> >> Signed-off-by: Michael Piszczek >> --- >> drivers/bus/pci/linux/pci.c | 58 ++++++++++++++++++++++--------------- >> 1 file changed, 35 insertions(+), 23 deletions(-) >> >> diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c >> index ebd1395502..291090ba7b 100644 >> --- a/drivers/bus/pci/linux/pci.c >> +++ b/drivers/bus/pci/linux/pci.c >> @@ -4,6 +4,7 @@ >> >> #include >> #include >> +#include >> >> #include >> #include >> @@ -480,42 +481,53 @@ rte_pci_scan(void) >> } >> >> #if defined(RTE_ARCH_X86) >> + >> bool >> pci_device_iommu_support_va(const struct rte_pci_device *dev) >> { >> -#define VTD_CAP_MGAW_SHIFT 16 >> -#define VTD_CAP_MGAW_MASK (0x3fULL << VTD_CAP_MGAW_SHIFT) >> +#define VTD_CAP_MGAW_SHIFT 16 >> +#define VTD_CAP_MGAW_MASK (0x3fULL << VTD_CAP_MGAW_SHIFT) >> +#define RD_AMD_CAP_VASIZE_SHIFT 15 >> +#define RD_AMD_CAP_VASIZE_MASK (0x7F << RD_AMD_CAP_VASIZE_SHIFT) >> + int rc; >> const struct rte_pci_addr *addr = &dev->addr; >> - char filename[PATH_MAX]; >> - FILE *fp; >> - uint64_t mgaw, vtd_cap_reg = 0; >> + char pattern[PATH_MAX]; >> + glob_t glob_results; >> + uint64_t mgaw = 0; >> >> - snprintf(filename, sizeof(filename), >> - "%s/" PCI_PRI_FMT "/iommu/intel-iommu/cap", >> + snprintf(pattern, sizeof(pattern), >> + "%s/" PCI_PRI_FMT "/iommu/*-iommu/cap", >> rte_pci_get_sysfs_path(), addr->domain, addr->bus, addr->devid, >> addr->function); >> >> - fp = fopen(filename, "r"); >> - if (fp == NULL) { >> - /* We don't have an Intel IOMMU, assume VA supported */ >> - if (errno == ENOENT) >> - return true; >> + rc = glob(pattern, 0, NULL, &glob_results); >> + if (rc != 0 && glob_results.gl_pathc == 1) { >> + const char *filename = glob_results.gl_pathv[0]; > > Why not use fnmatch() instead of glob()? > Most of the places in DPDK use that to do this kind of matching. Since glob() returns matching string, it can be useful to open the file. Is there an advantage of fnmatch() against globe()?