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 BD031A0542; Mon, 24 Oct 2022 20:09:36 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A28A441143; Mon, 24 Oct 2022 20:09:36 +0200 (CEST) Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by mails.dpdk.org (Postfix) with ESMTP id 2F73740A8B for ; Mon, 24 Oct 2022 20:09:36 +0200 (CEST) Received: by mail-pl1-f169.google.com with SMTP id n7so9147405plp.1 for ; Mon, 24 Oct 2022 11:09:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=mbY8+TxaFPw4dhcJL7Q24IgmLQKfPna06iMTi0egoD0=; b=U9dkIbiKvLq2eByqxjHL5Rz2JLVHBMh7uP+FkTBjnlFYIQQAfT8CNUJ4jw36ZkLu6z RJfsY5n4ZsdLVromwJmVR2r7WcPW1QcoJLymsc89BGsPSSvk7vUhgFsikAJLrQmNEa7H 4P4W7Mi+LAsw+0Q2n3ytYpSu1jaJEI515McvNHTxCpBmsM4hzWqdjJxlNJNzqFNLxD+i 5Ae0HoLfc4tfyuEg4Croi+Nffrdx86Qy6dVnH6DGFdugRXOs/xOoEUSH5aqZDFZWgCG7 qG0mZEKfXaZLh12HwouZV1jl3SR9sRak9wdwVIAP8TOCqReEBQ3S5+sMzZoqvj2Nfh8Q 4yiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mbY8+TxaFPw4dhcJL7Q24IgmLQKfPna06iMTi0egoD0=; b=vJPgENp4AFy52UIKLHFMahmZ8s0FQGKxR+aWlKWvxG+gp/by4YxKFUBipVkBiJU0tN xa30MbzUmpCe2sPJEKVK+mYEumHQ6sa/sWy/lZ9RDqDHJvKiPjqH3k/cDaCHYPJvz3FI gFcMs92AzlCe8FngbtQ2e8DDS+6jRhkMu8vgW4iSNI1xlkxAc5Q301Dm8w5rTwrCwxP/ B3mjMFusePBA/pFhhGg6mK64umsYsbHdUVXvXZiy8DiLRcOL9pDngsy3zCXZN5a+S81u IN3U898osTwWUx6H7SDKP2BMECc/hKMhVcB2phqMHqKMZJkEl7g2r5OZackTzEIbqkYS F56A== X-Gm-Message-State: ACrzQf27UQXLkoeJ16oxdFf/YvuPCxUicKpJ3nSN3+5TxQD5mb59o32l Hdsyb2ilSp3bJ6Aqh6fNJTcUT158mZyUiA== X-Google-Smtp-Source: AMsMyM6bzigT69Gxq2SXrBv/Df7DAedq3QnBFzHjJOLCP8Cs6ae2/Ub6knyJ/o2YWwb/PM91tl+Qyw== X-Received: by 2002:a17:90a:6984:b0:213:a95:88aa with SMTP id s4-20020a17090a698400b002130a9588aamr7900521pjj.181.1666634975230; Mon, 24 Oct 2022 11:09:35 -0700 (PDT) Received: from shemminger-XPS-13-9360 ([131.107.9.16]) by smtp.gmail.com with ESMTPSA id l7-20020a170903120700b0017bb38e4588sm47272plh.135.2022.10.24.11.09.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 11:09:34 -0700 (PDT) Date: Mon, 24 Oct 2022 11:09:27 -0700 From: Stephen Hemminger To: Michael Piszczek Cc: dev@dpdk.org, Vipin.Varghese@amd.com Subject: Re: [PATCH v5] pci: read amd iommu virtual address width Message-ID: <20221024110927.5ad71ed1@shemminger-XPS-13-9360> In-Reply-To: <20221013181602.873166-2-mpiszczek@ddn.com> References: <20220912160157.3642968-2-mpiszczek@ddn.com> <20221013181602.873166-1-mpiszczek@ddn.com> <20221013181602.873166-2-mpiszczek@ddn.com> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 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.