Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1251371imm; Fri, 29 Jun 2018 14:23:48 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLRdHp+vBHD//M9UxfDh+ChEwARkCyWOmq7ixE62d+Lt5veuVwHxFUCSvWSNTpjj8xBTSLZ X-Received: by 2002:a65:61d1:: with SMTP id j17-v6mr14294451pgv.447.1530307428775; Fri, 29 Jun 2018 14:23:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530307428; cv=none; d=google.com; s=arc-20160816; b=S/XWE+xvebv2kbr6sdzxpN1VRwUdcQL8Og9ipclDDYJIOCWxfdS1HO98PTuUWFDTa/ ss5ly8zS9wb59rl0J+N9wR8zQTAbSH3uR27cw+4ZcOccLZnObdUAcHHR8gizqJczBwZK 1fcXxOp9vqCSh8N8uIcDAWASHLJ356SME/TVNfDn3boWlHdD444zyPlmetHUqEc/s3O1 5ZDw7G5MUdICNP5ad5jtBuUnIRzmNnAvTiOVkFMWQo3Gtkre5uYv0O+1GKBp7R6Yqh1Y 3KjP05Fv2MVK0t+0fFZwcHA1j/tWeANcy7HpozCV9Vj8ugRLpIZaG6XqQxT0hLvJHOab RvKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=sqcksZoMykTuHhb2bm8xjNpQR1R5Acr38cK4NWmRhuY=; b=d4nja/ZKryXRHNFG+VW+jQG4CFdDV0M2gJDsjYO+mvFQwU55zygXO/TY47p1Fh2xLs WMlq8Aa/FlkX/l37hb522MNsGwx8rp9UhfLBYadsYg7s9ZnhidCUjgAhS3qQDd65Ai1L VU/m9NBlfg5zzyGissSJlj0G29iBXf/EM7n+GurGvv8iU5Ni58A2yGU04KM+YedAsr5v d0gQMygJVp9EDPVFwpeFaygnOhUy1KrD0H10kwbnj5UwRNViGHTNnsbkWZ8zrMXkTm0F +YpKYg9Lwx7akznD0usijnkbCU9zu9O9jmNzqhI0jVSgVEdIPpJIXAvx7inxSnvyJgvC oefQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j6-v6si9885603pll.54.2018.06.29.14.23.34; Fri, 29 Jun 2018 14:23:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936827AbeF2VQS (ORCPT + 99 others); Fri, 29 Jun 2018 17:16:18 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:55180 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1030452AbeF2VLz (ORCPT ); Fri, 29 Jun 2018 17:11:55 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5TL9K3W114376 for ; Fri, 29 Jun 2018 17:11:54 -0400 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0b-001b2d01.pphosted.com with ESMTP id 2jwrx7yjtb-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 29 Jun 2018 17:11:54 -0400 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 29 Jun 2018 17:11:53 -0400 Received: from b01cxnp22035.gho.pok.ibm.com (9.57.198.25) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 29 Jun 2018 17:11:49 -0400 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5TLBlvQ61472936 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 29 Jun 2018 21:11:47 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6A62312405C; Fri, 29 Jun 2018 18:13:16 -0400 (EDT) Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6445C124052; Fri, 29 Jun 2018 18:13:15 -0400 (EDT) Received: from localhost.localdomain (unknown [9.85.157.42]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTPS; Fri, 29 Jun 2018 18:13:15 -0400 (EDT) From: Tony Krowiak To: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: freude@de.ibm.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, borntraeger@de.ibm.com, cohuck@redhat.com, kwankhede@nvidia.com, bjsdjshi@linux.vnet.ibm.com, pbonzini@redhat.com, alex.williamson@redhat.com, pmorel@linux.vnet.ibm.com, alifm@linux.vnet.ibm.com, mjrosato@linux.vnet.ibm.com, jjherne@linux.vnet.ibm.com, thuth@redhat.com, pasic@linux.vnet.ibm.com, berrange@redhat.com, fiuczy@linux.vnet.ibm.com, buendgen@de.ibm.com, akrowiak@linux.vnet.ibm.com, Tony Krowiak Subject: [PATCH v6 09/21] s390: vfio-ap: structure for storing mdev matrix Date: Fri, 29 Jun 2018 17:11:11 -0400 X-Mailer: git-send-email 1.7.1 In-Reply-To: <1530306683-7270-1-git-send-email-akrowiak@linux.vnet.ibm.com> References: <1530306683-7270-1-git-send-email-akrowiak@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18062921-0052-0000-0000-000003063F85 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009278; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01054189; UDB=6.00540581; IPR=6.00832112; MB=3.00021933; MTD=3.00000008; XFM=3.00000015; UTC=2018-06-29 21:11:52 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18062921-0053-0000-0000-00005D2FC043 Message-Id: <1530306683-7270-10-git-send-email-akrowiak@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-06-29_10:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1806290224 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tony Krowiak Introduces a new structure for storing the AP matrix configured for the mediated matrix device via its sysfs attributes files. Signed-off-by: Tony Krowiak --- drivers/s390/crypto/vfio_ap_ops.c | 12 ++++++++++++ drivers/s390/crypto/vfio_ap_private.h | 24 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 0 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index 4e61e33..bf7ed9f 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -20,6 +20,17 @@ DEFINE_SPINLOCK(mdev_list_lock); LIST_HEAD(mdev_list); +static void vfio_ap_matrix_init(struct ap_matrix *matrix) +{ + /* Test if PQAP(QCI) instruction is available */ + if (test_facility(12)) + ap_qci(&matrix->info); + + matrix->apm_max = matrix->info.apxa ? matrix->info.Na : 63; + matrix->aqm_max = matrix->info.apxa ? matrix->info.Nd : 15; + matrix->adm_max = matrix->info.apxa ? matrix->info.Nd : 15; +} + static int vfio_ap_mdev_create(struct kobject *kobj, struct mdev_device *mdev) { struct ap_matrix_dev *matrix_dev = @@ -31,6 +42,7 @@ static int vfio_ap_mdev_create(struct kobject *kobj, struct mdev_device *mdev) return -ENOMEM; matrix_mdev->name = dev_name(mdev_dev(mdev)); + vfio_ap_matrix_init(&matrix_mdev->matrix); mdev_set_drvdata(mdev, matrix_mdev); if (atomic_dec_if_positive(&matrix_dev->available_instances) < 0) { diff --git a/drivers/s390/crypto/vfio_ap_private.h b/drivers/s390/crypto/vfio_ap_private.h index 3de1275..ae771f5 100644 --- a/drivers/s390/crypto/vfio_ap_private.h +++ b/drivers/s390/crypto/vfio_ap_private.h @@ -29,9 +29,33 @@ struct ap_matrix_dev { atomic_t available_instances; }; +/** + * The AP matrix is comprised of three bit masks identifying the adapters, + * queues (domains) and control domains that belong to an AP matrix. The bits i + * each mask, from least significant to most significant bit, correspond to IDs + * 0 to 255. When a bit is set, the corresponding ID belongs to the matrix. + * + * @apm identifies the AP adapters in the matrix + * @apm_max: max adapter number in @apm + * @aqm identifies the AP queues (domains) in the matrix + * @aqm_max: max domain number in @aqm + * @adm identifies the AP control domains in the matrix + * @adm_max: max domain number in @adm + */ +struct ap_matrix { + unsigned long apm_max; + DECLARE_BITMAP(apm, 256); + unsigned long aqm_max; + DECLARE_BITMAP(aqm, 256); + unsigned long adm_max; + DECLARE_BITMAP(adm, 256); + struct ap_config_info info; +}; + struct ap_matrix_mdev { const char *name; struct list_head list; + struct ap_matrix matrix; }; static struct ap_matrix_dev *to_ap_matrix_dev(struct device *dev) -- 1.7.1