From patchwork Sun Apr 11 00:44:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haren Myneni X-Patchwork-Id: 419326 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF230C433B4 for ; Sun, 11 Apr 2021 00:44:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF07F610E5 for ; Sun, 11 Apr 2021 00:44:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234926AbhDKAog (ORCPT ); Sat, 10 Apr 2021 20:44:36 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:39652 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234751AbhDKAof (ORCPT ); Sat, 10 Apr 2021 20:44:35 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 13B0XiNP075040; Sat, 10 Apr 2021 20:44:15 -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=pxeHkQP1kmn1yXzALIc5qkqciwnKnZqng2FUwOgZiXs=; b=CaO67Q6IM9Zq7XnbgDJjkR8/a19JkWMYLtLTiHFcjmm8mibQ/HtY7JOyBedDfColD6pY ksOfSXVB6Sw87UrFRnddE2G0EklaaqQNXZq2aXSfPXuxXSpz/Q9KU6rCudiU42DeeMxD wu7Ve5F8cbSA6txxc9Oc+In7Nfsbu88SZBUFsLSRjtPAwsudblJgRmP2qLl6adr9X+Fb Pj9Q1l68BLU7ff3EzSOIX6Al4raarM8u2oMAw5POpauGgPmmOKryE2ciWEruzveSfQg7 iMIn1io6mAb6lbxLny4F3obEhLNdwDUz8lRPGOBdCYtSpWlrj999ZKas3ZNCEl7cZEyU zA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 37u6b9p3ae-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 10 Apr 2021 20:44:14 -0400 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 13B0hYjM096849; Sat, 10 Apr 2021 20:44:14 -0400 Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 37u6b9p3a5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 10 Apr 2021 20:44:14 -0400 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 13B0RmPP018044; Sun, 11 Apr 2021 00:44:13 GMT Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by ppma04wdc.us.ibm.com with ESMTP id 37u3n9d5ru-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 11 Apr 2021 00:44:13 +0000 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 13B0iC2A15204620 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 11 Apr 2021 00:44:13 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E6D37AE05F; Sun, 11 Apr 2021 00:44:12 +0000 (GMT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E3E4EAE05C; Sun, 11 Apr 2021 00:44:11 +0000 (GMT) Received: from localhost.localdomain (unknown [9.80.232.48]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP; Sun, 11 Apr 2021 00:44:11 +0000 (GMT) Message-ID: <27f6fef4852a3fdbb36c3a35a357a0082c581be5.camel@linux.ibm.com> Subject: [PATCH 15/16] 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@linux.ibm.com Date: Sat, 10 Apr 2021 17:44:10 -0700 In-Reply-To: References: User-Agent: Evolution 3.36.2 (3.36.2-1.fc32) MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: VTB9xOkpTjFLMZ_Le3L4BtVqR0JfYe9h X-Proofpoint-GUID: 1w1b0fIZiSNcSEkOO3j3J635KZQNbsE2 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-04-10_07:2021-04-09,2021-04-10 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 bulkscore=0 mlxscore=0 adultscore=0 spamscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 suspectscore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104110000 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org phyp provides NX capabilities which gives recommended minimum compression / decompression length and maximum request buffer size in bytes. Changes to get NX overall capabilities which points to the specific features phyp supports. Then retrieve NXGZIP specific capabilities. Signed-off-by: Haren Myneni Reported-by: kernel test robot --- drivers/crypto/nx/nx-common-pseries.c | 83 +++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/drivers/crypto/nx/nx-common-pseries.c b/drivers/crypto/nx/nx-common-pseries.c index 9a40fca8a9e6..49224870d05e 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,24 @@ MODULE_DESCRIPTION("842 H/W Compression driver for IBM Power processors"); MODULE_ALIAS_CRYPTO("842"); MODULE_ALIAS_CRYPTO("842-nx"); +struct nx_ct_capabs_be { + __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); + +struct nx_ct_capabs { + char name[VAS_DESCR_LEN + 1]; + 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 */ +}; + +u64 capab_feat = 0; +struct nx_ct_capabs nx_ct_capab; + static struct nx842_constraints nx842_pseries_constraints = { .alignment = DDE_BUFFER_ALIGN, .multiple = DDE_BUFFER_LAST_MULT, @@ -1066,6 +1085,66 @@ static void nx842_remove(struct vio_dev *viodev) kfree(old_devdata); } +/* + * Get NX capabilities from pHyp. + * Only NXGZIP capabilities are available right now and these values + * are available through sysfs. + */ +static void __init nxct_get_capabilities(void) +{ + struct vas_all_capabs_be *capabs_be; + struct nx_ct_capabs_be *nxc_be; + int rc; + + capabs_be = kmalloc(sizeof(*capabs_be), GFP_KERNEL); + if (!capabs_be) + return; + /* + * Get NX overall capabilities with feature type=0 + */ + rc = plpar_vas_query_capabilities(H_QUERY_NX_CAPABILITIES, 0, + (u64)virt_to_phys(capabs_be)); + if (rc) + goto out; + + capab_feat = be64_to_cpu(capabs_be->feat_type); + /* + * NX-GZIP feature available + */ + if (capab_feat & VAS_NX_GZIP_FEAT_BIT) { + nxc_be = kmalloc(sizeof(*nxc_be), GFP_KERNEL); + if (!nxc_be) + goto out; + /* + * Get capabilities for NX-GZIP feature + */ + rc = plpar_vas_query_capabilities(H_QUERY_NX_CAPABILITIES, + VAS_NX_GZIP_FEAT, + (u64)virt_to_phys(nxc_be)); + } else { + pr_err("NX-GZIP feature is not available\n"); + rc = -EINVAL; + } + + if (!rc) { + snprintf(nx_ct_capab.name, VAS_DESCR_LEN + 1, "%.8s", + (char *)&nxc_be->descriptor); + nx_ct_capab.descriptor = be64_to_cpu(nxc_be->descriptor); + nx_ct_capab.req_max_processed_len = + be64_to_cpu(nxc_be->req_max_processed_len); + nx_ct_capab.min_compress_len = + be64_to_cpu(nxc_be->min_compress_len); + nx_ct_capab.min_decompress_len = + be64_to_cpu(nxc_be->min_decompress_len); + } else { + capab_feat = 0; + } + + kfree(nxc_be); +out: + kfree(capabs_be); +} + static const struct vio_device_id nx842_vio_driver_ids[] = { {"ibm,compression-v1", "ibm,compression"}, {"", ""}, @@ -1093,6 +1172,10 @@ static int __init nx842_pseries_init(void) return -ENOMEM; RCU_INIT_POINTER(devdata, new_devdata); + /* + * Get NX capabilities from pHyp which is used for NX-GZIP. + */ + nxct_get_capabilities(); ret = vio_register_driver(&nx842_vio_driver); if (ret) {