Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2466918pxb; Tue, 13 Apr 2021 02:36:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybEQXJ1JVJng1+S6cyn7Ft22iVVKTTsDoS6yg1znJ9hy+HO7C7eQ7Z3HzR+JS5ieCdMYH0 X-Received: by 2002:a17:902:9a84:b029:ea:e627:f7c2 with SMTP id w4-20020a1709029a84b02900eae627f7c2mr11326120plp.57.1618306563644; Tue, 13 Apr 2021 02:36:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618306563; cv=none; d=google.com; s=arc-20160816; b=Y377o40IocLuQxd6htxu8FHWiaGXChm3z9YcaobgKh3cxyen6sABEtY+ZfK5TrCEyZ ql9bYW5kQEKbvluFH309rBUGFbKzO1NP8x2/umn5QDG0MZ46Pf/Rt7cNlQggZWtPImaJ KsYSGoPk2KbJroEFddbSF/1Ip+Lhp7b7ONnQnJbrAdnC0FdJifOcDerf+pP1Xh6LXD6G I8NrUX2iXTYdcAfa0+KrmqnwTAnfTlH4qCMiohEJywz8ra9gSyDhvRwuOeiqDDQsmpfN 3/6L0Bo6OVELeUf/rG2Z5QSsRRY6eZDNQozNRXUd8et5YRCXOkkwhu8oGzukRfwkKt0X Yyxw== 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=pxeHkQP1kmn1yXzALIc5qkqciwnKnZqng2FUwOgZiXs=; b=VtyQOYvxucsf4p54XrM35sDBRT4fY7gh9gXwWG747L8qYmGm5Ks1UzMsN1UahUMxe3 vBi/KEq9r8eJTGuo6KfusA0WqtGEwNprR45jiXAr2ctEu+Sb3ij0hmIILe+oFgojFNfA oA270MmGNRWnIyWVY/L8xeH6GnjFodRqulHeOfJcoKnZufy7WH8l6QiKoU0MhkrwcN0U CUFrwzRK3qfCyrJnw/Z3+s31sIXuOXMMXLP8juEUpNdQvQzFA4F4lW+5sENC5N22oxMl 2j1aZdQA0kxxrDDvQEntLCd5rcHIVApm9aaJldS5OWDi8v8+y9VZfN8UckuaNOkiq9Ni fiIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="g2/+WCm/"; 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 s3si962027pgn.98.2021.04.13.02.35.51; Tue, 13 Apr 2021 02:36:03 -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="g2/+WCm/"; 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 S229995AbhDMIal (ORCPT + 99 others); Tue, 13 Apr 2021 04:30:41 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:13650 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229963AbhDMIaj (ORCPT ); Tue, 13 Apr 2021 04:30:39 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 13D83GIR158150; Tue, 13 Apr 2021 04:30:12 -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=g2/+WCm/dUqpUSGdxAl8vSFvm3276P/MWwdP4hvx+9qQttFhTXOdwXARVC2lPPzZtSwm v4DGkefPs5FWoy9RAj4GFoV7ehwNjd84BUUlR8Tm5AoR7VB/zPjgFa7hWjCRMkkZ0dOt EvX5Yup4ZevYbYjPHziZxGz0SR1qyCvL3Ocpr2vYmzjfV3MtxC5jUBeL+SsirXiytwK1 cL5g2UPo31egRpMLFHNJzfs3pVn06HBBWSEWRUKEG3s3pNZKmvtekF86weRqGfkRc4Nn sU/OfY3knxMMsflxPtAePRJ+rCOXIUvLvQN98NcKkudGQgpreF8ecqBUdbYhHi5owcRL gQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 37vtnt0nn5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Apr 2021 04:30:11 -0400 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 13D8N4sC034347; Tue, 13 Apr 2021 04:30:11 -0400 Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0b-001b2d01.pphosted.com with ESMTP id 37vtnt0nmj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Apr 2021 04:30:11 -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 13D8S3Bm021314; Tue, 13 Apr 2021 08:30:10 GMT Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by ppma04wdc.us.ibm.com with ESMTP id 37u3n9y4kn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Apr 2021 08:30:10 +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 13D8UAvV32309620 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Apr 2021 08:30:10 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EB16CAC05B; Tue, 13 Apr 2021 08:30:09 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2687DAC060; Tue, 13 Apr 2021 08:30:09 +0000 (GMT) Received: from localhost.localdomain (unknown [9.80.232.48]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 13 Apr 2021 08:30:09 +0000 (GMT) Message-ID: <1bb10e6566b6984448489f93b89686c0bb1fbe7f.camel@linux.ibm.com> Subject: [V2 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 Date: Tue, 13 Apr 2021 01:30:07 -0700 In-Reply-To: <68aa9f2860f9acffa41469d3858883c938634722.camel@linux.ibm.com> References: <68aa9f2860f9acffa41469d3858883c938634722.camel@linux.ibm.com> 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: IlFbmZQbgY6yoe2DirnUgsaknPzmyqEq X-Proofpoint-ORIG-GUID: hGEISsj94auK1NWnhbqUz0LWBOQCevz5 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-04-13_03:2021-04-13,2021-04-13 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 mlxscore=0 impostorscore=0 clxscore=1015 mlxlogscore=999 bulkscore=0 priorityscore=1501 spamscore=0 lowpriorityscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104130055 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 --- 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) { -- 2.18.2