From patchwork Fri Jan 26 19:15:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 10186893 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 BF622601D5 for ; Fri, 26 Jan 2018 19:21:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB0C01FF13 for ; Fri, 26 Jan 2018 19:21:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9CE7D28AF0; Fri, 26 Jan 2018 19:21:00 +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 2942D1FF13 for ; Fri, 26 Jan 2018 19:21:00 +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=F+HUokj0FjusD73I38g3NVdVf49uETy/tnDtGXZ9OEc=; b=JWIIe/KAcSIgV1NCi4FD/6xxMH QgKmgljbzxx81s8mB38iYsbk4BtJzu8rslwb+Znjpewm+YxgGRGATJ+a7lKO4D0V7i5EoeD5XmrLO fHgHc3rqjGVK0gIt6hbetyvayxYnOTkGNVFmfhOrb+SqmV1eYRvXJmx8H6Z7iRsbRlp1yjzILbWKC wmaAIbatxp/7OtYWgOUxw3HJsQPpYI8SHTIO2D24XWecrBOooenk5ZGYGzF7U6ong8EjKInkNJoP+ +Awd5lEUs04U52u5GJXXX/7zljtubYbeSSaUjgj4oEaYtltb4gxy0XYJsFAR2NdEBHC244PII0UaX CTeIlOFA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ef9YV-00063U-4Q; Fri, 26 Jan 2018 19:20:55 +0000 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ef9W2-0002ud-B0 for linux-arm-kernel@lists.infradead.org; Fri, 26 Jan 2018 19:18:26 +0000 Received: by mail-wr0-x242.google.com with SMTP id a1so1409036wri.5 for ; Fri, 26 Jan 2018 11:18:11 -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=52lE6G9FOb5vAshbK08DnSQT44vi95s6IvjigHuUZKs=; b=HOYYtD1SNw0t7sgORubTdXBfosyw4c35aPMrDmC9cyuNsmEkVLBNEuMD/KpEuNT3E8 +Cexk4nQRnxL7agtbIRDtA1TkRe3XMVzZzMJYxu//E8otJlL2MC6Voa60f673JSaSswv MuVlMA/It0gKg51od01N/oFcG1KdLvNswSf3VpJ25nK0Ey1QS533AxrAQKnOwF89UsrF ZuYtdldNAFgdduS44PFvg2BbXmgiWaTLT35lMAtw7ykAn8snJnD6Wt11vHne4YZ4yI7c FI7WaI6kyPsakL/gmAqordl53L+fQVTjcc9CbcyXYmUFdZfMt++iMWTR0hdJtmpcrjZX RkBw== 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=52lE6G9FOb5vAshbK08DnSQT44vi95s6IvjigHuUZKs=; b=X2Igy8YW5/9SX0hOtjC8VnzGi1uLLnItE3TfO2lLGoUsCiCfl8gce3jVI8piQlrH3G BSTkzSbwHTxff3ymRx65ggOf9/GXbZk3VNiI3Y7uKpdh8T4CBy2Gz4b47uCuITDTz3Rp Iqvr89gJgAsz0lAUqdNWM/fzFziKxpv97ya5w5m9lHndISrn4CLOyfAyeMa10bWImKcn VKFC1fRbnZekaXOgraAEpyIM/AW0CE+CGKFYd9eT4aOin80p81/BOiozbt7mk/s2SmwF CTyuYNtgJGB8DMdkvrqWXHdOMw/6w+W9L2KSNJBZ6nBXbXL0WD2IS9DxjSm8G8xEx6oa 5obQ== X-Gm-Message-State: AKwxytcMd/9BMCW5WH4OpQU8WF4gKmkZKw6JMuSZo5DZ44aixTBk44+e uB1laE9tdyuBvBTc6nk2DPA= X-Google-Smtp-Source: AH8x225mwhIOvDtJ7Vog/AOEXhXvCCeLHLkypeZ0+IgX4rLthvTFye2PPMzQKmn8W2D6pfWLcYJzmw== X-Received: by 10.223.174.236 with SMTP id y99mr11548192wrc.117.1516994290608; Fri, 26 Jan 2018 11:18:10 -0800 (PST) Received: from Red.local (LFbn-MAR-1-494-174.w2-15.abo.wanadoo.fr. [2.15.82.174]) by smtp.googlemail.com with ESMTPSA id k125sm7587510wmd.48.2018.01.26.11.18.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jan 2018 11:18:10 -0800 (PST) From: Corentin Labbe To: alexandre.torgue@st.com, arei.gonglei@huawei.com, corbet@lwn.net, davem@davemloft.net, herbert@gondor.apana.org.au, jasowang@redhat.com, mcoquelin.stm32@gmail.com, mst@redhat.com, fabien.dessenne@st.com Subject: [PATCH v2 4/6] crypto: virtio: convert to new crypto engine API Date: Fri, 26 Jan 2018 20:15:32 +0100 Message-Id: <20180126191534.17569-5-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180126191534.17569-1-clabbe.montjoie@gmail.com> References: <20180126191534.17569-1-clabbe.montjoie@gmail.com> 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: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-sunxi@googlegroups.com, Corentin Labbe , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.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 Acked-by: Michael S. Tsirkin --- drivers/crypto/virtio/virtio_crypto_algs.c | 16 ++++++++++------ drivers/crypto/virtio/virtio_crypto_common.h | 3 +-- drivers/crypto/virtio/virtio_crypto_core.c | 3 --- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/crypto/virtio/virtio_crypto_algs.c b/drivers/crypto/virtio/virtio_crypto_algs.c index abe8c15450df..ba190cfa7aa1 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_ctx 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_ablkcipher_request_to_engine(data_vq->engine, req); } 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_ablkcipher_request_to_engine(data_vq->engine, req); } 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; } @@ -538,9 +542,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_engine *engine, void *vreq) { + struct ablkcipher_request *req = container_of(vreq, struct ablkcipher_request, base); struct virtio_crypto_sym_request *vc_sym_req = ablkcipher_request_ctx(req); struct virtio_crypto_request *vc_req = &vc_sym_req->base; @@ -561,8 +565,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_ablkcipher_request(vc_sym_req->base.dataq->engine, + req, 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..72621bd67211 100644 --- a/drivers/crypto/virtio/virtio_crypto_common.h +++ b/drivers/crypto/virtio/virtio_crypto_common.h @@ -107,8 +107,7 @@ struct virtio_crypto *virtcrypto_get_dev_node(int node); 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_engine *engine, void *vreq); 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);