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 88A84A0C41; Wed, 23 Jun 2021 22:44:04 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0FDB440141; Wed, 23 Jun 2021 22:44:04 +0200 (CEST) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by mails.dpdk.org (Postfix) with ESMTP id 45AF34003C for ; Wed, 23 Jun 2021 22:44:03 +0200 (CEST) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15NKf6Wu121662 for ; Wed, 23 Jun 2021 16:44:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-type : content-transfer-encoding; s=pp1; bh=VvLImkN7XGYTH0YvKlmeynwXEQYu8NL10GbkfyHJ744=; b=Y+LpA2dguxdcIbQtmsiuHupvnFmcXOxfxwXbSnaX9I2eImo0C0M4s9+2XtSlbLv80QI+ 0/UNCcPNHqJsqYgg+wFsjvFSj1ESSVGMUUBX4ixIzZHTAdq+P6LLH5V2yw6X1QdvLNzC XUT+fmMPkpJoeu0CBF3LnoUuuQ7MFH+moljfBV4nd7l+DnQRDZzsPJ1NawEGebI7ylGK 0A6zx76eEQLJppw1xzbwhgEn/0G7mCXZ7PaFSWd095opRRS4yefrWXjBKIgv4BzdyO5K MK0H2clcjg+gWPuaUTvw3lSbgMUYwg6PG4lUKvKKQQZRJ9iUXbc1o2UkFwhZZPjHRyrg Bw== Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0a-001b2d01.pphosted.com with ESMTP id 39c7wg081q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 23 Jun 2021 16:44:02 -0400 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 15NKgalV012269 for ; Wed, 23 Jun 2021 20:44:01 GMT Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by ppma03wdc.us.ibm.com with ESMTP id 399879kcu8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 23 Jun 2021 20:44:01 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 15NKi1pp30802222 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Jun 2021 20:44:01 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6CC9B112064; Wed, 23 Jun 2021 20:44:01 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 546B9112063; Wed, 23 Jun 2021 20:44:01 +0000 (GMT) Received: from localhost.localdomain (unknown [9.114.224.51]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 23 Jun 2021 20:44:01 +0000 (GMT) From: David Christensen To: dev@dpdk.org Cc: thinhtr@linux.vnet.ibm.com, David Christensen Date: Wed, 23 Jun 2021 13:43:55 -0700 Message-Id: <20210623204355.74362-1-drc@linux.vnet.ibm.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: CTE-phpNdb6kAXkjIay-g5iZZprHg61p X-Proofpoint-ORIG-GUID: CTE-phpNdb6kAXkjIay-g5iZZprHg61p X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-06-23_12:2021-06-23, 2021-06-23 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 impostorscore=0 clxscore=1015 mlxscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106230119 Subject: [dpdk-dev] [PATCH] bus/pci: Add VA support for PowerVM system LPARs 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 Sender: "dev" Add IOMMU detection logic for PowerVM LPARs. PowerNV $ cat /proc/cpuinfo ... timebase     : 512000000 platform     : PowerNV model        : 8335-GTW PowerVM LPAR $ cat /proc/cpuinfo ... timebase     : 512000000 platform     : pSeries model        : IBM,9009-22A machine      : CHRP IBM,9009-22A MMU         : Hash PowerNV KVM Guest $ cat /proc/cpuinfo ... timebase     : 512000000 platform     : pSeries model        : IBM pSeries (emulated by qemu) machine      : CHRP IBM pSeries (emulated by qemu) MMU         : Radix Signed-off-by: David Christensen Reviewed-by: Thinh Tran --- drivers/bus/pci/linux/pci.c | 41 ++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c index 0dc99e9cb2..4a0904a53a 100644 --- a/drivers/bus/pci/linux/pci.c +++ b/drivers/bus/pci/linux/pci.c @@ -549,16 +549,22 @@ bool pci_device_iommu_support_va(__rte_unused const struct rte_pci_device *dev) { /* - * IOMMU is always present on a PowerNV host (IOMMUv2). - * IOMMU is also present in a KVM/QEMU VM (IOMMUv1) but is not - * currently supported by DPDK. Test for our current environment - * and report VA support as appropriate. + * All POWER systems support an IOMMU, but only IOMMUv2 supports + * IOVA = VA in DPDK. Check contents of /proc/cpuinfo to find the + * system. + * + * Platform | Model | IOMMU | VA? | Comment + * ---------+-------+---------+-----+--------------------------------- + * PowerNV | N/A | IOMMUv2 | Yes | OpenPOWER (Bare Metal) + * pSeries | ~qemu | IOMMUv2 | Yes | PowerVM Logical Partition (LPAR) + * pSeries | qemu | IOMMUv1 | No | QEMU Virtual Machine */ char *line = NULL; size_t len = 0; char filename[PATH_MAX] = "/proc/cpuinfo"; FILE *fp = fopen(filename, "r"); + bool pseries = false, powernv = false, qemu = false; bool ret = false; if (fp == NULL) { @@ -567,20 +573,31 @@ pci_device_iommu_support_va(__rte_unused const struct rte_pci_device *dev) return ret; } - /* Check for a PowerNV platform */ + /* Check the "platform" and "model" fields */ while (getline(&line, &len, fp) != -1) { - if (strstr(line, "platform") != NULL) - continue; - - if (strstr(line, "PowerNV") != NULL) { - RTE_LOG(DEBUG, EAL, "Running on a PowerNV system\n"); - ret = true; - break; + if (strstr(line, "platform") != NULL) { + if (strstr(line, "PowerNV") != NULL) { + RTE_LOG(DEBUG, EAL, "Running on a PowerNV " + "platform\n"); + powernv = true; + } else if (strstr(line, "pSeries") != NULL) { + RTE_LOG(DEBUG, EAL, "Running on a pSeries " + "platform\n"); + pseries = true; + } + } else if (strstr(line, "model") != NULL) { + if (strstr(line, "qemu") != NULL) { + RTE_LOG(DEBUG, EAL, "Found qemu emulation\n"); + qemu = true; + } } } free(line); fclose(fp); + + if (powernv || (pseries && !qemu)) + ret = true; return ret; } #else -- 2.27.0