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: 10081637 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 12111602BC for ; Wed, 29 Nov 2017 08:58:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03382295E9 for ; Wed, 29 Nov 2017 08:58:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EBFF529656; Wed, 29 Nov 2017 08:58: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=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 889A3295E9 for ; Wed, 29 Nov 2017 08:58:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=aAloEa7g6xiJ3RxNMZ8DLaahPaGOXZHhD6P6eHbMkB4=; b=ESHqQQoYddon3DeBPX8ohTgccJ 7uhgYiIWIltlYhz0QioIeNfrdQzuSgsSTeDVcXboMlAGRDq7pIKHTobZDMTOdUQzFaA4V6mj8HY+r +OP0d3C49lUVwUYHbM37AeVsUzIDYaH5rhibW0yWnkvHyPlwSZPNgeEfIEfY31ND/RfoN1GeL9DuJ aXI6fAD80ECPWhIsv1OaLQrHaYvpI/NN60FMmu9YK7q4gZzC7Wf/dCm8y/fL4hLrzJE7HJQ9VpfpJ mARA2jlqZygt2KzTaC4QNm68OSeYosb2epxdD5rMeFPU9gwVvJ+8GX1X/B1bEf6uFECtAYY6B1XJf AfRE2vvw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eJyCX-0005YJ-E8; Wed, 29 Nov 2017 08:58:41 +0000 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eJxyV-0005ev-4k for linux-arm-kernel@lists.infradead.org; Wed, 29 Nov 2017 08:44:13 +0000 Received: by mail-wr0-x244.google.com with SMTP id y21so2626004wrc.1 for ; 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=DZgdpkY6UwbgfB3S0MFKCV+XNCCX6YDqKmVSNC5JnkZE9YZVUBssydjTe1vxbxc88g pEsYOdZw+TETNYk6g6Ugv1rr60kbVYbkyNxYrK36T7hpu6rK+BakwUYaA/if4R9ayA69 iEC5g47uD69nQBCJvcJLeTVyHuG1pkrBhW8t92Tj4D5YPFbMNhv5rTt/Do0SG6Th7nbH JUMjx/S/AC+9OPksF4ItwLDwp6hTNIJiUY5bXNQwRIMwRwpaXEKa2++tA5qVObuqmDAm yXWyhv9nL0q1hqof8gweNUdBlNPi+95flT4N+k3cN0G8bGTNab8Ys6Ap77b1lURsX8AS NeFw== X-Gm-Message-State: AJaThX5cP210Z6VoRmPC7zxqbW1sciAx+DE6pRJSnIDhfQlr6DPT/Xwv 6Src5LSS4eh/SkM08kMOQ2w= 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171129_004411_340197_EA226E88 X-CRM114-Status: GOOD ( 14.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: virtualization@lists.linux-foundation.org, Corentin Labbe , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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);