From patchwork Wed Nov 29 08:41:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 10081605 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7590960353 for ; Wed, 29 Nov 2017 08:44:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63ADF295D6 for ; Wed, 29 Nov 2017 08:44:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 57418296E7; Wed, 29 Nov 2017 08:44:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0048E295D6 for ; Wed, 29 Nov 2017 08:44:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753462AbdK2IoO (ORCPT ); Wed, 29 Nov 2017 03:44:14 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:46651 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753673AbdK2Inu (ORCPT ); Wed, 29 Nov 2017 03:43:50 -0500 Received: by mail-wr0-f195.google.com with SMTP id x49so2593391wrb.13; Wed, 29 Nov 2017 00:43:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/28ctTz6j185aaKeGjLHyzf/14R/nUNi2FlRgAXIgQ0=; b=ha3cIbG1gxNmuXHXbaxZTvRgcmI9n7jGSU7jbKbkO8TfcxEl0M1Ed/MK48xFHSkBxT gu2wtO/jwRwCx/hhg+Ta8CVYfXGHdSDJpnhafN6virBdYlvvnFQ/MPtl2NjK6Y0H5Muj 7SrpgK+ublohG4JocSaYeKe8rGzuczWs7Hb8OazlI0N15o32508HA63NYrfvYnwZjI9P 5QhOeU3HUhh3Hoiii+C6Lwwx5eG4YCUhcAxIKSmzTW7Qkpy2JKDO8H4LqcBiKqimgjc3 zRYloUchdhWUq6v8p4JWsVs9ndkm76jDexJsHhwotu9+lOJG5AHXis8pnGCtixWWdWaz gbjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/28ctTz6j185aaKeGjLHyzf/14R/nUNi2FlRgAXIgQ0=; b=HioF2LSyxIzSS0i3SQUyEvX/XC1MMbLhR3dkVDZZkPerPuuuHjsH0bIgJpAFRopOOx l4vj42+9ci/5Rr8RXgDDkcmKRQ9CREjN/NIG2qmbi16TjUHpmwJyIK1KFtKGTsCmjTzs +l5xb6P2OZYPeQWUxCZMB5iP0TZ3kEsXpKVt2mkI9KEitXc4UEWdxqPLXRgfmVwPhySS euKpaEY8elinh9TUS7+siemQSS8+b5n7pFvafLtsEulLFho5ZQVMLd5Y1ei/yJyecppa vtSBzKhiLZzXj3R5ccvbVwyrEkRr/wgmQHbboLotx6oe6B0EVCGeFbJ+yMINM6Wl048F Dzxg== X-Gm-Message-State: AJaThX7MCh8N2ltmcim7Aq1cHjNppCErVbHBg3FrE8U2DMPspa1Kdth2 PdVhaMkpDIKf37+WlYfr0yg= X-Google-Smtp-Source: AGs4zMbOfEDRXlQAuqYO2Fomz8ZmlAGMS5dmpfmUN9YN6h5x8BahoM7nvBgZGycV5EagqhIIt002ow== X-Received: by 10.223.145.80 with SMTP id j74mr1731817wrj.250.1511945029288; Wed, 29 Nov 2017 00:43:49 -0800 (PST) Received: from Red.local (LFbn-MAR-1-580-204.w90-118.abo.wanadoo.fr. [90.118.159.204]) by smtp.googlemail.com with ESMTPSA id 19sm1947398wmv.41.2017.11.29.00.43.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Nov 2017 00:43:48 -0800 (PST) From: Corentin Labbe To: herbert@gondor.apana.org.au, alexandre.torgue@st.com, arei.gonglei@huawei.com, davem@davemloft.net, jasowang@redhat.com, mcoquelin.stm32@gmail.com, mst@redhat.com, fabien.dessenne@st.com Cc: linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Corentin Labbe Subject: [PATCH RFC 3/4] crypto: virtio: convert to new crypto engine API Date: Wed, 29 Nov 2017 09:41:20 +0100 Message-Id: <20171129084121.9385-4-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171129084121.9385-1-clabbe.montjoie@gmail.com> References: <20171129084121.9385-1-clabbe.montjoie@gmail.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch convert the driver to the new crypto engine API. Signed-off-by: Corentin Labbe --- drivers/crypto/virtio/virtio_crypto_algs.c | 15 ++++++++++----- drivers/crypto/virtio/virtio_crypto_common.h | 2 +- drivers/crypto/virtio/virtio_crypto_core.c | 3 --- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/crypto/virtio/virtio_crypto_algs.c b/drivers/crypto/virtio/virtio_crypto_algs.c index abe8c15450df..a2ac7a08247f 100644 --- a/drivers/crypto/virtio/virtio_crypto_algs.c +++ b/drivers/crypto/virtio/virtio_crypto_algs.c @@ -29,6 +29,7 @@ struct virtio_crypto_ablkcipher_ctx { + struct crypto_engine_reqctx enginectx; struct virtio_crypto *vcrypto; struct crypto_tfm *tfm; @@ -491,7 +492,7 @@ static int virtio_crypto_ablkcipher_encrypt(struct ablkcipher_request *req) vc_sym_req->ablkcipher_req = req; vc_sym_req->encrypt = true; - return crypto_transfer_cipher_request_to_engine(data_vq->engine, req); + return crypto_transfer_request_to_engine(data_vq->engine, &req->base); } static int virtio_crypto_ablkcipher_decrypt(struct ablkcipher_request *req) @@ -511,7 +512,7 @@ static int virtio_crypto_ablkcipher_decrypt(struct ablkcipher_request *req) vc_sym_req->ablkcipher_req = req; vc_sym_req->encrypt = false; - return crypto_transfer_cipher_request_to_engine(data_vq->engine, req); + return crypto_transfer_request_to_engine(data_vq->engine, &req->base); } static int virtio_crypto_ablkcipher_init(struct crypto_tfm *tfm) @@ -521,6 +522,9 @@ static int virtio_crypto_ablkcipher_init(struct crypto_tfm *tfm) tfm->crt_ablkcipher.reqsize = sizeof(struct virtio_crypto_sym_request); ctx->tfm = tfm; + ctx->enginectx.op.do_one_request = virtio_crypto_ablkcipher_crypt_req; + ctx->enginectx.op.prepare_request = NULL; + ctx->enginectx.op.unprepare_request = NULL; return 0; } @@ -539,8 +543,9 @@ static void virtio_crypto_ablkcipher_exit(struct crypto_tfm *tfm) int virtio_crypto_ablkcipher_crypt_req( struct crypto_engine *engine, - struct ablkcipher_request *req) + struct crypto_async_request *areq) { + struct ablkcipher_request *req = ablkcipher_request_cast(areq); struct virtio_crypto_sym_request *vc_sym_req = ablkcipher_request_ctx(req); struct virtio_crypto_request *vc_req = &vc_sym_req->base; @@ -561,8 +566,8 @@ static void virtio_crypto_ablkcipher_finalize_req( struct ablkcipher_request *req, int err) { - crypto_finalize_cipher_request(vc_sym_req->base.dataq->engine, - req, err); + crypto_finalize_request(vc_sym_req->base.dataq->engine, + &req->base, err); kzfree(vc_sym_req->iv); virtcrypto_clear_request(&vc_sym_req->base); } diff --git a/drivers/crypto/virtio/virtio_crypto_common.h b/drivers/crypto/virtio/virtio_crypto_common.h index e976539a05d9..0d51f6ce226d 100644 --- a/drivers/crypto/virtio/virtio_crypto_common.h +++ b/drivers/crypto/virtio/virtio_crypto_common.h @@ -108,7 +108,7 @@ int virtcrypto_dev_start(struct virtio_crypto *vcrypto); void virtcrypto_dev_stop(struct virtio_crypto *vcrypto); int virtio_crypto_ablkcipher_crypt_req( struct crypto_engine *engine, - struct ablkcipher_request *req); + struct crypto_async_request *req); void virtcrypto_clear_request(struct virtio_crypto_request *vc_req); diff --git a/drivers/crypto/virtio/virtio_crypto_core.c b/drivers/crypto/virtio/virtio_crypto_core.c index ff1410a32c2b..83326986c113 100644 --- a/drivers/crypto/virtio/virtio_crypto_core.c +++ b/drivers/crypto/virtio/virtio_crypto_core.c @@ -111,9 +111,6 @@ static int virtcrypto_find_vqs(struct virtio_crypto *vi) ret = -ENOMEM; goto err_engine; } - - vi->data_vq[i].engine->cipher_one_request = - virtio_crypto_ablkcipher_crypt_req; } kfree(names);