From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 01FA73250; Fri, 12 Jan 2018 12:10:55 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Jan 2018 03:10:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,348,1511856000"; d="scan'208";a="26597564" Received: from aburakov-mobl.ger.corp.intel.com (HELO [10.237.220.145]) ([10.237.220.145]) by orsmga002.jf.intel.com with ESMTP; 12 Jan 2018 03:10:52 -0800 To: Maxime Coquelin , dev@dpdk.org, stable@dpdk.org, jianfeng.tan@intel.com, qi.z.zhang@intel.com, stephen@networkplumber.org, santosh.shukla@caviumnetworks.com, thomas@monjalon.net Cc: peterx@redhat.com References: <20180112102220.20061-1-maxime.coquelin@redhat.com> From: "Burakov, Anatoly" Message-ID: <89c16dd0-3938-f9ae-cc9f-189388abc0a9@intel.com> Date: Fri, 12 Jan 2018 11:10:51 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20180112102220.20061-1-maxime.coquelin@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v3] bus/pci: forbid VA as IOVA mode if IOMMU address width too small X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jan 2018 11:10:56 -0000 > +#if defined(RTE_ARCH_X86) > +static bool > +pci_one_device_iommu_support_va(struct rte_pci_device *dev) > +{ > +#define VTD_CAP_MGAW_SHIFT 16 > +#define VTD_CAP_MGAW_MASK (0x3fULL << VTD_CAP_MGAW_SHIFT) > +#define X86_VA_WIDTH 47 /* From Documentation/x86/x86_64/mm.txt */ > + struct rte_pci_addr *addr = &dev->addr; > + char filename[PATH_MAX]; > + FILE *fp; > + uint64_t mgaw, vtd_cap_reg = 0; > + > + snprintf(filename, sizeof(filename), > + "%s/" PCI_PRI_FMT "/iommu/intel-iommu/cap", > + rte_pci_get_sysfs_path(), addr->domain, addr->bus, addr->devid, > + addr->function); > + if (access(filename, F_OK) == -1) { > + /* We don't have an Intel IOMMU, assume VA supported*/ > + return true; > + } > + > + /* We have an intel IOMMU */ > + fp = fopen(filename, "r"); > + if (fp == NULL) { > + RTE_LOG(ERR, EAL, "%s(): can't open %s\n", __func__, filename); > + return false; > + } > + > + if (fscanf(fp, "%lx", &vtd_cap_reg) != 1) { > + RTE_LOG(ERR, EAL, "%s(): can't read %s\n", __func__, filename); > + fclose(fp); > + return false; > + } > + > + fclose(fp); Hi Maxime, You probably want to use eal_parse_sysfs_value() for this. -- Thanks, Anatoly