Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3185874pxj; Mon, 14 Jun 2021 17:02:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/t3a5uuMuKsmcA7SvrBE20GM7ZdVp3YGRujfBuEUw5cgOjvu9St1bl6J2dsLQpxXTwoks X-Received: by 2002:a05:6402:2552:: with SMTP id l18mr20067711edb.166.1623715340009; Mon, 14 Jun 2021 17:02:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623715340; cv=none; d=google.com; s=arc-20160816; b=CZ50WQ107HhtfWJffHd07GKTR2WB2Ev62P2JpAmxiTZ4fPE7zlRXXZFwygGrMvCa6i TUXThA5/8/maSve9iBlbuFkrEfSxksHCUqhiWbMVqHW9T/whoDKj84cyTMaQ6HQHZ7aj pCQ2l3e9476QyR+tgWhgUorBxYbakDC79CTboK3jy77Ht5ErnHV+cZ4ADxFMvczurQmz H9f51GDs9QmnqaibzfPzElxrqyc9jS1w75e1pR/tKRxUdLfJKXOjKsqx14/4WBew1uZ/ xljfdjyRxLjk/Pb/YHkaXtvZmnk9yrd55ZH3o+anwvp1jk+/JoTbiL1cu7Seeof3l8XK SRuQ== 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=f3IQ+9mSkSmnpTuRDvx0hrRzqNBo8P7CqUdlmjVRhNU=; b=oA9G+IghSn6v8G+VeFn01Gg8V0wvxPnR5BQ0znFJfJT5AoCSLv2M+xLvC28NkuBuVA VDyNO/B1k/WIzARXaPBsXeOzss9ibtWUFTezLwVHZ+kYazQqK6UrvHxVpe5sAnvCJw5d EMqfJYuAGh1rlhcnNL9ftyraIsyinlFv+cjLMsoPFnGLG29WLyz/F3HLfKDWNml0Z7oF bI5K9NdIfs3qzuNpGtx9rNDZZiamFLTj8VSPCxXsnnVoRtUw2ynFifWpjTJCmIApkW++ tU1hhtIVuGvtAgMOerLwl0tnDe3/Mddmq6xfkShk8rAwRDhKlo+gaHKymvoG449/ssOe DI1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=LFHtgx9E; 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 u26si13035606ejz.348.2021.06.14.17.01.46; Mon, 14 Jun 2021 17:02:19 -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=LFHtgx9E; 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 S229649AbhFOADV (ORCPT + 99 others); Mon, 14 Jun 2021 20:03:21 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:30880 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229499AbhFOADU (ORCPT ); Mon, 14 Jun 2021 20:03:20 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15ENv5AR032797; Mon, 14 Jun 2021 20:01:05 -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=f3IQ+9mSkSmnpTuRDvx0hrRzqNBo8P7CqUdlmjVRhNU=; b=LFHtgx9Ew1sGZGhCjEYujoSTnboaFgO7R1StAjb4TAtP1ckgLiUn6HdIVtvmBWxDsAkc QdUMt98thIgiA0TD3nlVbnwHupdmakS2G2yJp1I2oOE1UzizKhZako19VkwoyiyN6+sK yElNSN3yt4Eju+P4w2YlkhVmRynRLy1KRlhWjuGs0DmZd8Oqwk6yb6FLZZTEcfTwE6MU kyGtLs9EzmVVOwcYGXjFg+QXeGplUeiSHUhS06UlRad0txP7NL/XAVrDfRl+8lzlhDiE T/f3QN+ueMorwAUzzpPMmwtI2uOz8lOciqY22uE3gkw8Uz4LmFWNpoPjHWTkDFwc29ht 6g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 396h8402g2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 14 Jun 2021 20:01:05 -0400 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 15ENvnls033675; Mon, 14 Jun 2021 20:01:05 -0400 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com with ESMTP id 396h8402fg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 14 Jun 2021 20:01:05 -0400 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 15ENlXB0028332; Tue, 15 Jun 2021 00:01:04 GMT Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by ppma03dal.us.ibm.com with ESMTP id 394mj9g9ef-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Jun 2021 00:01:04 +0000 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 15F013Vb28901800 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Jun 2021 00:01:03 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8991FAC066; Tue, 15 Jun 2021 00:01:03 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A437EAC081; Tue, 15 Jun 2021 00:01:02 +0000 (GMT) Received: from localhost.localdomain (unknown [9.160.180.39]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 15 Jun 2021 00:01:02 +0000 (GMT) Message-ID: Subject: Re: [PATCH v5 16/17] crypto/nx: Get NX capabilities for GZIP coprocessor type From: Haren Myneni To: Nicholas Piggin , herbert@gondor.apana.org.au, linux-crypto@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, mpe@ellerman.id.au Cc: haren@us.ibm.com, hbabu@us.ibm.com Date: Mon, 14 Jun 2021 17:01:00 -0700 In-Reply-To: <1623641787.0rdwnv3k4u.astroid@bobo.none> References: <726de270eb20e0898f4391a0b0e7077697db66ab.camel@linux.ibm.com> <1623641787.0rdwnv3k4u.astroid@bobo.none> 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-GUID: B6PDft7hsjJoojsWfdZJ9oqmrSWb6fVI X-Proofpoint-ORIG-GUID: S3EYkFFTo41ClPGjuUt5zcPHa0Olj119 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-06-14_14:2021-06-14,2021-06-14 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 mlxlogscore=999 mlxscore=0 priorityscore=1501 suspectscore=0 spamscore=0 bulkscore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106140149 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, 2021-06-14 at 13:39 +1000, Nicholas Piggin wrote: > Excerpts from Haren Myneni's message of June 13, 2021 9:04 pm: > > 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). > > So what does this give you which you didn't have before? Should > this go before the previous patch that enables the interface for > guests, > or is there some functional-yet-degraded mode that is available > without > this patch? > > I would suggest even if this is the case to switch ordering of the > patches so as to reduce the matrix of functionality that userspace > sees > when bisecting. Unless you specifically want this kind of > bisectability, > in which case make that explicit in the changelog. Thanks for your suggestions. I will incorporate them and post next revision. The user space request buffer length should not be more than req_max_processed_len (available through sysfs). Otherwise NX will return the request with RMA_Reject. Whereasas min_compress_len and min_decompress_len are recommended values. We can add this patch and the last one (crypto/nx: Add sysfs interface to export NX capabilities) before the actual enablement ("crypto/nx: Register and unregisterVAS interface on PowerVM"" Thanks Haren > > Thanks, > Nick > > > 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 > > > > > >