Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1955791pxj; Sun, 13 Jun 2021 04:08:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuRetGUK3TTkqOxh+Agq/hxtxAiD65vl76v5Pix/pj1l1dMqHgRg03/ht/9h3mKGgrXIm2 X-Received: by 2002:a17:907:2be5:: with SMTP id gv37mr11583491ejc.237.1623582529341; Sun, 13 Jun 2021 04:08:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623582529; cv=none; d=google.com; s=arc-20160816; b=sE62wBBDDUV0IoLkRrqZG3o1eGm7lrXeBVzxEl7otpD2MwawQdbAKahmqZIw5vGmSu PvMSLI8yCKYbTi+ftkjicAUPrVozUVrY1n4Rq6o3ddj4mo2kvNy9JLaOX3AYPn9K3tTG J8hJg7TLH5HTey6+RpGcHreQv+XcgirE90iamMSPqp60RiS4yGoshMJeSfTToxWKaVIs WTZJTT5s2wQylFvc2pcstUiIJcgrcn/wED5mLnRjy/+fbE163t3stf2j5FNEeQtep5ce sTj7/ibD3RSLm+lQtj8tyWoE8PwdNhkUBNcIVSuujsTB0Czw/5kr2/oE4nOJnDOMnUj3 I5ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=ZsVkRoq3Y8R1FcsqXdZppD5pi9hTEyOqGBQKxlYaLig=; b=TAS78rOmnsG/ZQo9jVuw/eSlyJhhPEkx2OcFaGFgVbIpjuGSUdhGDrICsVOukl+Ab/ QbGNPtNjOr4JtNNabXYlh6tzbALXNdrS9Z8cxiDsGNE9xjYov+h3xdJGDHURh0vOYOIY YqICoRGf9eva49Gt+SRxllVYeqkC6H2PUdPF4qN3S22mokuoHYx51VlpM46F1Fu+IMNs GNEza8D670LTVZa7wQjBcywa9UZKyGuSUZCRhRjMC7PVU0DLgx8MNFl4dLwNFOuc4Wu8 cctBPZaN8KsD04/DhZptdH4G/5WWCRt2SvBMFagCuPSAV0L+hxKfrT4pbY9ojikP+hCP G1zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=jqB2FSqe; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u23si9785171edi.175.2021.06.13.04.08.26; Sun, 13 Jun 2021 04:08:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=jqB2FSqe; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231703AbhFMLHA (ORCPT + 99 others); Sun, 13 Jun 2021 07:07:00 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:61996 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231176AbhFMLG7 (ORCPT ); Sun, 13 Jun 2021 07:06:59 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15DB3dKT075551; Sun, 13 Jun 2021 07:04:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : subject : from : to : cc : date : in-reply-to : references : content-type : mime-version : content-transfer-encoding; s=pp1; bh=ZsVkRoq3Y8R1FcsqXdZppD5pi9hTEyOqGBQKxlYaLig=; b=jqB2FSqeI8XGnOcr8Iz6I60OBnXdW1afzBDT5ozZNm5ZWIyjiQNZsqJ8G5lQIRJvKvZE XVzgGH7e2l+UN7FXCXlGzNQprMK8nOQJzxOJ0BpCoNLn51bPnn8SgJ25wqETIAj6q6NH xNES29Ih7IFYKKXL1+kwXVh/j2Fef8zvDobbmXWMz9oawR9KBJENELg/Wci/Kc5vWjH7 DvyAoUZKx722yrfLOBIZ9v4v5dlDcSz01iQCBBL4r7tJajBwecxysOSkfeYmPGhyjJ2H qS8AfdWuiV8vEK4vIvI2adF7Sot0j7bUcnSlgE2JE6Mvdp+KXV3OmzRp4QH6WD8QvdXZ eg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 395gasgeyb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 13 Jun 2021 07:04:53 -0400 Received: from m0098394.ppops.net (m0098394.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 15DB3cJl075500; Sun, 13 Jun 2021 07:04:52 -0400 Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com with ESMTP id 395gasgey2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 13 Jun 2021 07:04:52 -0400 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 15DAw96P002263; Sun, 13 Jun 2021 11:04:51 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma02wdc.us.ibm.com with ESMTP id 394mj988yy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 13 Jun 2021 11:04:51 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 15DB4oZa29229430 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 13 Jun 2021 11:04:50 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 83A7DBE056; Sun, 13 Jun 2021 11:04:50 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D77B3BE053; Sun, 13 Jun 2021 11:04:48 +0000 (GMT) Received: from localhost.localdomain (unknown [9.160.180.39]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Sun, 13 Jun 2021 11:04:48 +0000 (GMT) Message-ID: <726de270eb20e0898f4391a0b0e7077697db66ab.camel@linux.ibm.com> Subject: [PATCH v5 16/17] crypto/nx: Get NX capabilities for GZIP coprocessor type From: Haren Myneni To: linuxppc-dev@lists.ozlabs.org, linux-crypto@vger.kernel.org, mpe@ellerman.id.au, herbert@gondor.apana.org.au, npiggin@gmail.com Cc: hbabu@us.ibm.com, haren@us.ibm.com Date: Sun, 13 Jun 2021 04:04:46 -0700 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.2 (3.36.2-1.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: tMGVU2PZU15kKJh7u2hqNPLuR8kr8APn X-Proofpoint-GUID: evLQDmeY2lRKXqoe4R6dtIt1LcislpE7 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-06-13_04:2021-06-11,2021-06-13 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 adultscore=0 lowpriorityscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 bulkscore=0 mlxscore=0 priorityscore=1501 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106130082 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The hypervisor provides different capabilities that it supports to define the user space NX request. These capabilities are recommended minimum compression / decompression lengths and the maximum request buffer size in bytes. Changes to get NX overall capabilities which points to the specific features that the hypervisor supports. Then retrieve the capabilities for the specific feature (available only for NXGZIP). Signed-off-by: Haren Myneni Acked-by: Herbert Xu --- drivers/crypto/nx/nx-common-pseries.c | 86 +++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/drivers/crypto/nx/nx-common-pseries.c b/drivers/crypto/nx/nx-common-pseries.c index 9a40fca8a9e6..60b5049ec9f7 100644 --- a/drivers/crypto/nx/nx-common-pseries.c +++ b/drivers/crypto/nx/nx-common-pseries.c @@ -9,6 +9,7 @@ */ #include +#include #include #include "nx-842.h" @@ -20,6 +21,29 @@ MODULE_DESCRIPTION("842 H/W Compression driver for IBM Power processors"); MODULE_ALIAS_CRYPTO("842"); MODULE_ALIAS_CRYPTO("842-nx"); +/* + * Coprocessor type specific capabilities from the hypervisor. + */ +struct hv_nx_ct_caps { + __be64 descriptor; + __be64 req_max_processed_len; /* Max bytes in one GZIP request */ + __be64 min_compress_len; /* Min compression size in bytes */ + __be64 min_decompress_len; /* Min decompression size in bytes */ +} __packed __aligned(0x1000); + +/* + * Coprocessor type specific capabilities. + */ +struct nx_ct_caps { + u64 descriptor; + u64 req_max_processed_len; /* Max bytes in one GZIP request */ + u64 min_compress_len; /* Min compression in bytes */ + u64 min_decompress_len; /* Min decompression in bytes */ +}; + +static u64 caps_feat; +static struct nx_ct_caps nx_ct_caps; + static struct nx842_constraints nx842_pseries_constraints = { .alignment = DDE_BUFFER_ALIGN, .multiple = DDE_BUFFER_LAST_MULT, @@ -1066,6 +1090,64 @@ static void nx842_remove(struct vio_dev *viodev) kfree(old_devdata); } +/* + * Get NX capabilities from the hypervisor. + * Only NXGZIP capabilities are provided by the hypersvisor right + * now and these values are available to user space with sysfs. + */ +static void __init nxct_get_capabilities(void) +{ + struct hv_vas_all_caps *hv_caps; + struct hv_nx_ct_caps *hv_nxc; + int rc; + + hv_caps = kmalloc(sizeof(*hv_caps), GFP_KERNEL); + if (!hv_caps) + return; + /* + * Get NX overall capabilities with feature type=0 + */ + rc = h_query_vas_capabilities(H_QUERY_NX_CAPABILITIES, 0, + (u64)virt_to_phys(hv_caps)); + if (rc) + goto out; + + caps_feat = be64_to_cpu(hv_caps->feat_type); + /* + * NX-GZIP feature available + */ + if (caps_feat & VAS_NX_GZIP_FEAT_BIT) { + hv_nxc = kmalloc(sizeof(*hv_nxc), GFP_KERNEL); + if (!hv_nxc) + goto out; + /* + * Get capabilities for NX-GZIP feature + */ + rc = h_query_vas_capabilities(H_QUERY_NX_CAPABILITIES, + VAS_NX_GZIP_FEAT, + (u64)virt_to_phys(hv_nxc)); + } else { + pr_err("NX-GZIP feature is not available\n"); + rc = -EINVAL; + } + + if (!rc) { + nx_ct_caps.descriptor = be64_to_cpu(hv_nxc->descriptor); + nx_ct_caps.req_max_processed_len = + be64_to_cpu(hv_nxc->req_max_processed_len); + nx_ct_caps.min_compress_len = + be64_to_cpu(hv_nxc->min_compress_len); + nx_ct_caps.min_decompress_len = + be64_to_cpu(hv_nxc->min_decompress_len); + } else { + caps_feat = 0; + } + + kfree(hv_nxc); +out: + kfree(hv_caps); +} + static const struct vio_device_id nx842_vio_driver_ids[] = { {"ibm,compression-v1", "ibm,compression"}, {"", ""}, @@ -1093,6 +1175,10 @@ static int __init nx842_pseries_init(void) return -ENOMEM; RCU_INIT_POINTER(devdata, new_devdata); + /* + * Get NX capabilities from the hypervisor. + */ + nxct_get_capabilities(); ret = vio_register_driver(&nx842_vio_driver); if (ret) { -- 2.18.2