From patchwork Wed Nov 29 08:41:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 119935 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2782895qgn; Wed, 29 Nov 2017 00:44:46 -0800 (PST) X-Google-Smtp-Source: AGs4zMYxyZAC4DDBF9Wexpw2mBfqEDWbgzfW4KlmdBe8zeEUIQmbeXGqHRbSmbV96FqFIDf4udJ+ X-Received: by 10.98.196.155 with SMTP id h27mr2188538pfk.137.1511945086190; Wed, 29 Nov 2017 00:44:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511945086; cv=none; d=google.com; s=arc-20160816; b=V5fXMFpLEpETPA4z7D1XJq4N2k/x3Vwsj+DsULminOKJ3/wmsyPnuKHFhgaXda4c0s mff0yJfLnY99S5TWHspe8J+kKpB89Woe4B5bg6fsdyNV+nKQDTnjE0D9ijvmPeQaZhRJ oHjtnJnkoZEtOSMwibUkADLQvQYuKNlh7XB+gBeLWNyjdA4OkItkdH9Z8FmxfsKk9qrt UM8gFuyKsW9xb6VGGbO9aP7bsw59HyCAh9M+HSmBf9I9vHAzMRkMRx4LjHqv9LbEnX0Y fVgAguZ1uRiLaT9REYSIHxRqGLu4ExIr8MAF79L2wB8SmdQgt4u4/uhLfi1vSa+lEpxB H2hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=WQvz8QBiIozxGVQAldcBjipGiMXUOoF5QPMJS+BXMMw=; b=tnl2Xca6or27bo1LJ7G+qG6i7O5kxtR3ZsqBYmf0IoCAp3W0GHJ6l2Qy7ICYf1y88P 5WFf2ZM/pTit09VLhvgMEavIj3GcWAePNgeepZ8c8IiKAsQ5/Q9E7FAoonHkiQ1NvaMj C48NGhKqlbbfy+/J+FfnAuJ91kZdps17OWXhe/WoKqS1WVvYujadcacswuz/iP+rTn1E uh1ROoPR1z6MnItPrdap4iAhSOG0NM+WyWRZB3WmfdGeGSmYmg0uigUDHIRxySph1LId G4daCrO3X+P6XBiz64AIGNCfKKuBzeNpuS1TX60IVHdPh67/eaI1PqIhDO+HywznbpNy ekbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NrNDNjKu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c17si902871pgu.693.2017.11.29.00.44.45; Wed, 29 Nov 2017 00:44:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NrNDNjKu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753821AbdK2Ioo (ORCPT + 28 others); Wed, 29 Nov 2017 03:44:44 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:39218 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752597AbdK2Ins (ORCPT ); Wed, 29 Nov 2017 03:43:48 -0500 Received: by mail-wr0-f194.google.com with SMTP id a41so752191wra.6; Wed, 29 Nov 2017 00:43:47 -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=WQvz8QBiIozxGVQAldcBjipGiMXUOoF5QPMJS+BXMMw=; b=NrNDNjKuoSs0inY6MPb9OPJnmhta5n1VYSb6DRlFZ+1DYWZkPUheCTWy97J5lG7Rp8 PaA8KIqPa61Btuu3Tugc+EAq1WZTTNpfaCumnEh7nSbhoYBHEpph1ga6PcQKqG5LAt5L SQ0KQ+jaMlZetv5RDBR4skvOECC6gMd6ul743jnejliT+nrRREElJuDaHIobcx7GqA/R Kol+w8iBIvEK4cuzXEYbW+QorpxmRYHkVPnev6iswFwUZWeGUHIqhSZQbMiExX5JQQYC BD3aWTAsw2vnXX7/0n1LUBomVTtOkKC1d6GZ9P5bKheL2B18hn/5LXiQ9/DeiOWakrCy wF/w== 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=WQvz8QBiIozxGVQAldcBjipGiMXUOoF5QPMJS+BXMMw=; b=EJPiG7flLaugwKgspbzzYkXe3SnnDw+lHZ3EwNu9STt7DIMlTRgIIJkRDL1Qee3DlO 1fmi7F72V293YeGSjJ8lZiN/MNGgwntfuEv5+iK5vlMc15YJLV02uLVtuCHV9vAKKJwb y/qSZwLzJwQ26nmVzbU2cwcvHd89cgSP9qPLvUJLxqPL3FbYktWbh+31umeceyFAOyg2 zuVY5asccq3fAAxCiw18aCgOFxZd8pfhcfDnYIUTgQ5j051Tl+LFoIBKhyWlKXT3At41 ntL4HrZMSA/HpPLliC+cEL8Fao/R1RU1aNNoE+0kRm0UH12jdFppsml3/44qhj+AZWj9 gRfQ== X-Gm-Message-State: AJaThX7c7tZV/ddqp+q/m8LFQNUR6oVpMnw2IvdlTd1NqFe0Tuhp3KHb VNON+1SXDdCaSiSYFlZeXXY= X-Received: by 10.223.129.135 with SMTP id 7mr1792608wra.55.1511945027179; Wed, 29 Nov 2017 00:43:47 -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.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Nov 2017 00:43:46 -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 1/4] crypto: engine - Permit to enqueue all async requests Date: Wed, 29 Nov 2017 09:41:18 +0100 Message-Id: <20171129084121.9385-2-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The crypto engine could actually only enqueue hash and ablkcipher request. This patch permit it to enqueue any type of crypto_async_request. Signed-off-by: Corentin Labbe --- crypto/crypto_engine.c | 188 +++++++++++------------------------------------- include/crypto/engine.h | 46 +++++------- 2 files changed, 60 insertions(+), 174 deletions(-) -- 2.13.6 diff --git a/crypto/crypto_engine.c b/crypto/crypto_engine.c index 61e7c4e02fd2..f7c4c4c1f41b 100644 --- a/crypto/crypto_engine.c +++ b/crypto/crypto_engine.c @@ -34,11 +34,10 @@ static void crypto_pump_requests(struct crypto_engine *engine, bool in_kthread) { struct crypto_async_request *async_req, *backlog; - struct ahash_request *hreq; - struct ablkcipher_request *breq; unsigned long flags; bool was_busy = false; - int ret, rtype; + int ret; + struct crypto_engine_reqctx *enginectx; spin_lock_irqsave(&engine->queue_lock, flags); @@ -94,7 +93,6 @@ static void crypto_pump_requests(struct crypto_engine *engine, spin_unlock_irqrestore(&engine->queue_lock, flags); - rtype = crypto_tfm_alg_type(engine->cur_req->tfm); /* Until here we get the request need to be encrypted successfully */ if (!was_busy && engine->prepare_crypt_hardware) { ret = engine->prepare_crypt_hardware(engine); @@ -104,57 +102,31 @@ static void crypto_pump_requests(struct crypto_engine *engine, } } - switch (rtype) { - case CRYPTO_ALG_TYPE_AHASH: - hreq = ahash_request_cast(engine->cur_req); - if (engine->prepare_hash_request) { - ret = engine->prepare_hash_request(engine, hreq); - if (ret) { - dev_err(engine->dev, "failed to prepare request: %d\n", - ret); - goto req_err; - } - engine->cur_req_prepared = true; - } - ret = engine->hash_one_request(engine, hreq); - if (ret) { - dev_err(engine->dev, "failed to hash one request from queue\n"); - goto req_err; - } - return; - case CRYPTO_ALG_TYPE_ABLKCIPHER: - breq = ablkcipher_request_cast(engine->cur_req); - if (engine->prepare_cipher_request) { - ret = engine->prepare_cipher_request(engine, breq); - if (ret) { - dev_err(engine->dev, "failed to prepare request: %d\n", - ret); - goto req_err; - } - engine->cur_req_prepared = true; - } - ret = engine->cipher_one_request(engine, breq); + enginectx = crypto_tfm_ctx(async_req->tfm); + + if (enginectx->op.prepare_request) { + ret = enginectx->op.prepare_request(engine, async_req); if (ret) { - dev_err(engine->dev, "failed to cipher one request from queue\n"); + dev_err(engine->dev, "failed to prepare request: %d\n", + ret); goto req_err; } - return; - default: - dev_err(engine->dev, "failed to prepare request of unknown type\n"); - return; + engine->cur_req_prepared = true; + } + if (!enginectx->op.do_one_request) { + dev_err(engine->dev, "failed to do request\n"); + ret = -EINVAL; + goto req_err; + } + ret = enginectx->op.do_one_request(engine, async_req); + if (ret) { + dev_err(engine->dev, "failed to hash one request from queue\n"); + goto req_err; } + return; req_err: - switch (rtype) { - case CRYPTO_ALG_TYPE_AHASH: - hreq = ahash_request_cast(engine->cur_req); - crypto_finalize_hash_request(engine, hreq, ret); - break; - case CRYPTO_ALG_TYPE_ABLKCIPHER: - breq = ablkcipher_request_cast(engine->cur_req); - crypto_finalize_cipher_request(engine, breq, ret); - break; - } + crypto_finalize_request(engine, async_req, ret); return; out: @@ -170,59 +142,16 @@ static void crypto_pump_work(struct kthread_work *work) } /** - * crypto_transfer_cipher_request - transfer the new request into the - * enginequeue + * crypto_transfer_request - transfer the new request into the engine queue * @engine: the hardware engine * @req: the request need to be listed into the engine queue */ -int crypto_transfer_cipher_request(struct crypto_engine *engine, - struct ablkcipher_request *req, - bool need_pump) +int crypto_transfer_request(struct crypto_engine *engine, + struct crypto_async_request *req, bool need_pump) { unsigned long flags; int ret; - spin_lock_irqsave(&engine->queue_lock, flags); - - if (!engine->running) { - spin_unlock_irqrestore(&engine->queue_lock, flags); - return -ESHUTDOWN; - } - - ret = ablkcipher_enqueue_request(&engine->queue, req); - - if (!engine->busy && need_pump) - kthread_queue_work(engine->kworker, &engine->pump_requests); - - spin_unlock_irqrestore(&engine->queue_lock, flags); - return ret; -} -EXPORT_SYMBOL_GPL(crypto_transfer_cipher_request); - -/** - * crypto_transfer_cipher_request_to_engine - transfer one request to list - * into the engine queue - * @engine: the hardware engine - * @req: the request need to be listed into the engine queue - */ -int crypto_transfer_cipher_request_to_engine(struct crypto_engine *engine, - struct ablkcipher_request *req) -{ - return crypto_transfer_cipher_request(engine, req, true); -} -EXPORT_SYMBOL_GPL(crypto_transfer_cipher_request_to_engine); - -/** - * crypto_transfer_hash_request - transfer the new request into the - * enginequeue - * @engine: the hardware engine - * @req: the request need to be listed into the engine queue - */ -int crypto_transfer_hash_request(struct crypto_engine *engine, - struct ahash_request *req, bool need_pump) -{ - unsigned long flags; - int ret; spin_lock_irqsave(&engine->queue_lock, flags); @@ -231,7 +160,7 @@ int crypto_transfer_hash_request(struct crypto_engine *engine, return -ESHUTDOWN; } - ret = ahash_enqueue_request(&engine->queue, req); + ret = crypto_enqueue_request(&engine->queue, req); if (!engine->busy && need_pump) kthread_queue_work(engine->kworker, &engine->pump_requests); @@ -239,80 +168,45 @@ int crypto_transfer_hash_request(struct crypto_engine *engine, spin_unlock_irqrestore(&engine->queue_lock, flags); return ret; } -EXPORT_SYMBOL_GPL(crypto_transfer_hash_request); +EXPORT_SYMBOL_GPL(crypto_transfer_request); /** - * crypto_transfer_hash_request_to_engine - transfer one request to list + * crypto_transfer_request_to_engine - transfer one request to list * into the engine queue * @engine: the hardware engine * @req: the request need to be listed into the engine queue */ -int crypto_transfer_hash_request_to_engine(struct crypto_engine *engine, - struct ahash_request *req) -{ - return crypto_transfer_hash_request(engine, req, true); -} -EXPORT_SYMBOL_GPL(crypto_transfer_hash_request_to_engine); - -/** - * crypto_finalize_cipher_request - finalize one request if the request is done - * @engine: the hardware engine - * @req: the request need to be finalized - * @err: error number - */ -void crypto_finalize_cipher_request(struct crypto_engine *engine, - struct ablkcipher_request *req, int err) +int crypto_transfer_request_to_engine(struct crypto_engine *engine, + struct crypto_async_request *req) { - unsigned long flags; - bool finalize_cur_req = false; - int ret; - - spin_lock_irqsave(&engine->queue_lock, flags); - if (engine->cur_req == &req->base) - finalize_cur_req = true; - spin_unlock_irqrestore(&engine->queue_lock, flags); - - if (finalize_cur_req) { - if (engine->cur_req_prepared && - engine->unprepare_cipher_request) { - ret = engine->unprepare_cipher_request(engine, req); - if (ret) - dev_err(engine->dev, "failed to unprepare request\n"); - } - spin_lock_irqsave(&engine->queue_lock, flags); - engine->cur_req = NULL; - engine->cur_req_prepared = false; - spin_unlock_irqrestore(&engine->queue_lock, flags); - } - - req->base.complete(&req->base, err); - - kthread_queue_work(engine->kworker, &engine->pump_requests); + return crypto_transfer_request(engine, req, true); } -EXPORT_SYMBOL_GPL(crypto_finalize_cipher_request); +EXPORT_SYMBOL_GPL(crypto_transfer_request_to_engine); /** - * crypto_finalize_hash_request - finalize one request if the request is done + * crypto_finalize_request - finalize one request if the request is done * @engine: the hardware engine * @req: the request need to be finalized * @err: error number */ -void crypto_finalize_hash_request(struct crypto_engine *engine, - struct ahash_request *req, int err) +void crypto_finalize_request(struct crypto_engine *engine, + struct crypto_async_request *req, int err) { unsigned long flags; bool finalize_cur_req = false; int ret; + struct crypto_engine_reqctx *enginectx; spin_lock_irqsave(&engine->queue_lock, flags); - if (engine->cur_req == &req->base) + if (engine->cur_req == req) finalize_cur_req = true; spin_unlock_irqrestore(&engine->queue_lock, flags); if (finalize_cur_req) { + enginectx = crypto_tfm_ctx(req->tfm); if (engine->cur_req_prepared && - engine->unprepare_hash_request) { - ret = engine->unprepare_hash_request(engine, req); + enginectx->op.unprepare_request) { + ret = enginectx->op.unprepare_request(engine, req); if (ret) dev_err(engine->dev, "failed to unprepare request\n"); } @@ -322,11 +216,11 @@ void crypto_finalize_hash_request(struct crypto_engine *engine, spin_unlock_irqrestore(&engine->queue_lock, flags); } - req->base.complete(&req->base, err); + req->complete(req, err); kthread_queue_work(engine->kworker, &engine->pump_requests); } -EXPORT_SYMBOL_GPL(crypto_finalize_hash_request); +EXPORT_SYMBOL_GPL(crypto_finalize_request); /** * crypto_engine_start - start the hardware engine diff --git a/include/crypto/engine.h b/include/crypto/engine.h index dd04c1699b51..2e45db45849b 100644 --- a/include/crypto/engine.h +++ b/include/crypto/engine.h @@ -17,7 +17,6 @@ #include #include #include -#include #define ENGINE_NAME_LEN 30 /* @@ -65,19 +64,6 @@ struct crypto_engine { int (*prepare_crypt_hardware)(struct crypto_engine *engine); int (*unprepare_crypt_hardware)(struct crypto_engine *engine); - int (*prepare_cipher_request)(struct crypto_engine *engine, - struct ablkcipher_request *req); - int (*unprepare_cipher_request)(struct crypto_engine *engine, - struct ablkcipher_request *req); - int (*prepare_hash_request)(struct crypto_engine *engine, - struct ahash_request *req); - int (*unprepare_hash_request)(struct crypto_engine *engine, - struct ahash_request *req); - int (*cipher_one_request)(struct crypto_engine *engine, - struct ablkcipher_request *req); - int (*hash_one_request)(struct crypto_engine *engine, - struct ahash_request *req); - struct kthread_worker *kworker; struct kthread_work pump_requests; @@ -85,19 +71,25 @@ struct crypto_engine { struct crypto_async_request *cur_req; }; -int crypto_transfer_cipher_request(struct crypto_engine *engine, - struct ablkcipher_request *req, - bool need_pump); -int crypto_transfer_cipher_request_to_engine(struct crypto_engine *engine, - struct ablkcipher_request *req); -int crypto_transfer_hash_request(struct crypto_engine *engine, - struct ahash_request *req, bool need_pump); -int crypto_transfer_hash_request_to_engine(struct crypto_engine *engine, - struct ahash_request *req); -void crypto_finalize_cipher_request(struct crypto_engine *engine, - struct ablkcipher_request *req, int err); -void crypto_finalize_hash_request(struct crypto_engine *engine, - struct ahash_request *req, int err); +struct crypto_engine_op { + int (*prepare_request)(struct crypto_engine *engine, + struct crypto_async_request *areq); + int (*unprepare_request)(struct crypto_engine *engine, + struct crypto_async_request *areq); + int (*do_one_request)(struct crypto_engine *engine, + struct crypto_async_request *areq); +}; + +struct crypto_engine_reqctx { + struct crypto_engine_op op; +}; + +int crypto_transfer_request(struct crypto_engine *engine, + struct crypto_async_request *req, bool need_pump); +int crypto_transfer_request_to_engine(struct crypto_engine *engine, + struct crypto_async_request *req); +void crypto_finalize_request(struct crypto_engine *engine, + struct crypto_async_request *req, int err); int crypto_engine_start(struct crypto_engine *engine); int crypto_engine_stop(struct crypto_engine *engine); struct crypto_engine *crypto_engine_alloc_init(struct device *dev, bool rt); From patchwork Wed Nov 29 08:41:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 119934 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2782619qgn; Wed, 29 Nov 2017 00:44:18 -0800 (PST) X-Google-Smtp-Source: AGs4zMb+JJ6+CFYEFQNGRS/GoicHkjvbFbEmo33tKuP1pj8iJDBazr1EW2kVvQcS4Wx5cjbJapgi X-Received: by 10.84.164.231 with SMTP id l36mr2072439plg.75.1511945058561; Wed, 29 Nov 2017 00:44:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511945058; cv=none; d=google.com; s=arc-20160816; b=N9ZSpsQ5WaNqd1o0syG4znX9hU8t+UOVwQpYhm21vaEWgcXALluYLBWmsNF1NkvT3N iYVrYoU5fc5VHY+FMR7/iz/Yq2gfZY3tH9Ph3ia2qdFeNQ5sSJojQsc87KE8QIYgyeMX PMVlVDosr+FWTeXe+DmRByljacZVGBW/Q6tBqQ4aYWj/OuR4Sv8CtSKJbXNp90sZUr9j pnlb3XUR5ivfLUByemOiHeBeAWFqlEL793Bh4GL/A4QJQ/1n4Ath+HIDY01YQ06kiLJb qDxXeWXhkn3Rt9OKJ1QK2E/eJgv7MWsMAohRyNbG7eExxtTBrD9Di/1F7CsHb9s4jJOX /T2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=1w4KGYQ+mdxR4Ax3LxeNopLazazXn19Zt2HfGjgZul4=; b=fUUTCeKatpbFjIm2SCM5MZSuAd9Au8J9YVIUfjIzChHXMEMy88+OPUWB5JBoLeM2Ze +8Tl4hGSxDREDqTqruxEi4R6Ns6yylBjWUduytJjs4vHpjoICo+A6piFu1lNc5gK4z/t 3LudBVR2Bnl7NE8k6OF22FZlLaXiM+N5hvSDCYsEJ6aM3xk6YGqWUHYQgPczzflTTThj N4Kx84nZDFHyzDaY/VExOskuukSQjafVB+WVGHdo2N5aUReRKkEYWDOwa5e0dPo2ZRTP YJs8l/NGDhO6ie9zpjH6Dhawh6QkrBztIpxhOt8yFkKvvYB3r+cxn34dG+3aUjrwjuzd /Irg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AEiq/Oyh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m37si942893pla.205.2017.11.29.00.44.18; Wed, 29 Nov 2017 00:44:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AEiq/Oyh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753807AbdK2IoQ (ORCPT + 28 others); Wed, 29 Nov 2017 03:44:16 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:33039 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753499AbdK2Int (ORCPT ); Wed, 29 Nov 2017 03:43:49 -0500 Received: by mail-wm0-f66.google.com with SMTP id g130so35269071wme.0; Wed, 29 Nov 2017 00:43:48 -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=1w4KGYQ+mdxR4Ax3LxeNopLazazXn19Zt2HfGjgZul4=; b=AEiq/OyhggVThlduvM/k2C6kjaZFPzUqoAauUleI8B8I1SdTWaGpajuUOqgEmyzEsw qNLdCCe9Vge7cmKi7XmnAl/i/fJYe9I2JXQ1E6tWPNyTDTPMItv3phz26Tp3EjXcMo5o UGhMRt+iIUYwt2JZ5An/hM0ju7uoUnmunYJeW02bBiMtfFM0Z7G3L8/NCk1TC/uP42vj ObMk1DSQU+MZcnv/QPhgdefh/9iIKFAwfZEzb/dvQZVx5KNF8Ad0N/qOv94cffHUZvYL j21q/nNllnHaGexpRUa7pFu71E/cUKq2i26htbZE3Qr7jIx5IOhFRoCSiJf+AporLVMR mHqA== 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=1w4KGYQ+mdxR4Ax3LxeNopLazazXn19Zt2HfGjgZul4=; b=OA+W5fSShKWMC6KUSIBunGdMFyYOvpitfzxORgbLR7q5pCHeBba8Lp2yt43f4NALDh B7Z9FEkytkSzwBysDd4CqC3lboO9NYweKX/Cpm8UyyTloK67+BLCmuBaI4W2HUgLo6+W PrOnOqSyXsNJGlCJVDmqU0iy+4vRxOUXRgTuZYNnN6UwCvE9hzJjclSJjoRZ9ZwNMIsq ao8/z+9S8aVECFwQAc8TgdbYJykIQ7BFPIQSX8hXIZpJTLOdnn0wxT6YLj6+n3XbjE3G tR88u4j9BQe1KQ3fdm8ufWmrD6EcOIOiH8dia2OvXq4GCB0z+Y+IVEW9xMIeOO3SsEER HzKg== X-Gm-Message-State: AJaThX74DM/wL2zlkVyuWmd0+N7GEVpc6FXe0qa040gjnSQ7r/kV91Oo EBNRb9rvtvTHJtt/lZsM3LA= X-Received: by 10.28.194.139 with SMTP id s133mr1686526wmf.14.1511945028269; Wed, 29 Nov 2017 00:43:48 -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.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Nov 2017 00:43:47 -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 2/4] crypto: omap: convert to new crypto engine API Date: Wed, 29 Nov 2017 09:41:19 +0100 Message-Id: <20171129084121.9385-3-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch convert the driver to the new crypto engine API. Signed-off-by: Corentin Labbe --- drivers/crypto/omap-aes.c | 21 +++++++++++++++------ drivers/crypto/omap-aes.h | 3 +++ drivers/crypto/omap-des.c | 24 ++++++++++++++++++------ 3 files changed, 36 insertions(+), 12 deletions(-) -- 2.13.6 diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c index fbec0a2e76dd..4a31bbfca9a4 100644 --- a/drivers/crypto/omap-aes.c +++ b/drivers/crypto/omap-aes.c @@ -388,7 +388,7 @@ static void omap_aes_finish_req(struct omap_aes_dev *dd, int err) pr_debug("err: %d\n", err); - crypto_finalize_cipher_request(dd->engine, req, err); + crypto_finalize_request(dd->engine, &req->base, err); pm_runtime_mark_last_busy(dd->dev); pm_runtime_put_autosuspend(dd->dev); @@ -408,14 +408,15 @@ static int omap_aes_handle_queue(struct omap_aes_dev *dd, struct ablkcipher_request *req) { if (req) - return crypto_transfer_cipher_request_to_engine(dd->engine, req); + return crypto_transfer_request_to_engine(dd->engine, &req->base); return 0; } static int omap_aes_prepare_req(struct crypto_engine *engine, - struct ablkcipher_request *req) + struct crypto_async_request *areq) { + struct ablkcipher_request *req = ablkcipher_request_cast(areq); struct omap_aes_ctx *ctx = crypto_ablkcipher_ctx( crypto_ablkcipher_reqtfm(req)); struct omap_aes_reqctx *rctx = ablkcipher_request_ctx(req); @@ -468,8 +469,9 @@ static int omap_aes_prepare_req(struct crypto_engine *engine, } static int omap_aes_crypt_req(struct crypto_engine *engine, - struct ablkcipher_request *req) + struct crypto_async_request *areq) { + struct ablkcipher_request *req = ablkcipher_request_cast(areq); struct omap_aes_reqctx *rctx = ablkcipher_request_ctx(req); struct omap_aes_dev *dd = rctx->dd; @@ -601,6 +603,11 @@ static int omap_aes_ctr_decrypt(struct ablkcipher_request *req) return omap_aes_crypt(req, FLAGS_CTR); } +static int omap_aes_prepare_req(struct crypto_engine *engine, + struct crypto_async_request *req); +static int omap_aes_crypt_req(struct crypto_engine *engine, + struct crypto_async_request *req); + static int omap_aes_cra_init(struct crypto_tfm *tfm) { const char *name = crypto_tfm_alg_name(tfm); @@ -616,6 +623,10 @@ static int omap_aes_cra_init(struct crypto_tfm *tfm) tfm->crt_ablkcipher.reqsize = sizeof(struct omap_aes_reqctx); + ctx->enginectx.op.prepare_request = omap_aes_prepare_req; + ctx->enginectx.op.unprepare_request = NULL; + ctx->enginectx.op.do_one_request = omap_aes_crypt_req; + return 0; } @@ -1119,8 +1130,6 @@ static int omap_aes_probe(struct platform_device *pdev) goto err_engine; } - dd->engine->prepare_cipher_request = omap_aes_prepare_req; - dd->engine->cipher_one_request = omap_aes_crypt_req; err = crypto_engine_start(dd->engine); if (err) goto err_engine; diff --git a/drivers/crypto/omap-aes.h b/drivers/crypto/omap-aes.h index 8906342e2b9a..f6ce94907ade 100644 --- a/drivers/crypto/omap-aes.h +++ b/drivers/crypto/omap-aes.h @@ -13,6 +13,8 @@ #ifndef __OMAP_AES_H__ #define __OMAP_AES_H__ +#include + #define DST_MAXBURST 4 #define DMA_MIN (DST_MAXBURST * sizeof(u32)) @@ -95,6 +97,7 @@ struct omap_aes_gcm_result { }; struct omap_aes_ctx { + struct crypto_engine_reqctx enginectx; int keylen; u32 key[AES_KEYSIZE_256 / sizeof(u32)]; u8 nonce[4]; diff --git a/drivers/crypto/omap-des.c b/drivers/crypto/omap-des.c index ebc5c0f11f03..94212248159e 100644 --- a/drivers/crypto/omap-des.c +++ b/drivers/crypto/omap-des.c @@ -86,6 +86,7 @@ #define FLAGS_OUT_DATA_ST_SHIFT 10 struct omap_des_ctx { + struct crypto_engine_reqctx enginectx; struct omap_des_dev *dd; int keylen; @@ -498,7 +499,7 @@ static void omap_des_finish_req(struct omap_des_dev *dd, int err) pr_debug("err: %d\n", err); - crypto_finalize_cipher_request(dd->engine, req, err); + crypto_finalize_request(dd->engine, &req->base, err); pm_runtime_mark_last_busy(dd->dev); pm_runtime_put_autosuspend(dd->dev); @@ -520,14 +521,15 @@ static int omap_des_handle_queue(struct omap_des_dev *dd, struct ablkcipher_request *req) { if (req) - return crypto_transfer_cipher_request_to_engine(dd->engine, req); + return crypto_transfer_request_to_engine(dd->engine, &req->base); return 0; } static int omap_des_prepare_req(struct crypto_engine *engine, - struct ablkcipher_request *req) + struct crypto_async_request *areq) { + struct ablkcipher_request *req = ablkcipher_request_cast(areq); struct omap_des_ctx *ctx = crypto_ablkcipher_ctx( crypto_ablkcipher_reqtfm(req)); struct omap_des_dev *dd = omap_des_find_dev(ctx); @@ -582,8 +584,9 @@ static int omap_des_prepare_req(struct crypto_engine *engine, } static int omap_des_crypt_req(struct crypto_engine *engine, - struct ablkcipher_request *req) + struct crypto_async_request *areq) { + struct ablkcipher_request *req = ablkcipher_request_cast(areq); struct omap_des_ctx *ctx = crypto_ablkcipher_ctx( crypto_ablkcipher_reqtfm(req)); struct omap_des_dev *dd = omap_des_find_dev(ctx); @@ -695,12 +698,23 @@ static int omap_des_cbc_decrypt(struct ablkcipher_request *req) return omap_des_crypt(req, FLAGS_CBC); } +static int omap_des_prepare_req(struct crypto_engine *engine, + struct crypto_async_request *areq); +static int omap_des_crypt_req(struct crypto_engine *engine, + struct crypto_async_request *areq); + static int omap_des_cra_init(struct crypto_tfm *tfm) { + struct omap_des_ctx *ctx = crypto_tfm_ctx(tfm); + pr_debug("enter\n"); tfm->crt_ablkcipher.reqsize = sizeof(struct omap_des_reqctx); + ctx->enginectx.op.prepare_request = omap_des_prepare_req; + ctx->enginectx.op.unprepare_request = NULL; + ctx->enginectx.op.do_one_request = omap_des_crypt_req; + return 0; } @@ -1046,8 +1060,6 @@ static int omap_des_probe(struct platform_device *pdev) goto err_engine; } - dd->engine->prepare_cipher_request = omap_des_prepare_req; - dd->engine->cipher_one_request = omap_des_crypt_req; err = crypto_engine_start(dd->engine); if (err) goto err_engine; 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: 119933 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2782605qgn; Wed, 29 Nov 2017 00:44:17 -0800 (PST) X-Google-Smtp-Source: AGs4zMZHnQKeiRCmZ7LrBNpy+q7ABncWgsTkIz0NSrzJtuTkNVZeH/UZ5JeDxeXKFSYuyP9c0uCQ X-Received: by 10.159.198.148 with SMTP id g20mr2111310plo.89.1511945057061; Wed, 29 Nov 2017 00:44:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511945057; cv=none; d=google.com; s=arc-20160816; b=d310p+bGD7wcgxl1vyLCHSaPiq9Jx1OIv18qKYKmGQmuogXXUCX8H0jKDmJSasOmEK WJ6kCcQUQiTIdOBI5YD0ZpFUOHVNfJmADiy3GCSMDEGjNEUJ5lyQufnhTYy7lbAwPI3e Jhk3SSWJQc9Mw1qFQ+LHIHEbJ4v+hfeOH1eSPDeofrQT+tvYECzk/MsHbWZzbsHqAOe0 MncvhgvlS+GW+L5UqV2TEGG4kimEK4NvmOWNgNa47AbNrECc1hcNzNQixIbOYG7twiGw lr9DHcYMhsfwyd4tLV8wS2Ek97rPNx963AiqnRw3AcmCnwJOWMBs8ljrVlSrGz2jz1nW XTPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=/28ctTz6j185aaKeGjLHyzf/14R/nUNi2FlRgAXIgQ0=; b=dk26x933hkx13eqKa/xrpRZ3Kzvu+TdewiP4aKNtsuClaK9u0yXqg7A5XtWxBWe3j2 cEcXcuMuhHrdCYd1F4vq9WShYWZzdtsuuD1Y3CXscRbu06LUAqpgp3zSDoC0yE0FDgeR 6vCmPzJXoXmd17lnIE/c3Y8K0Yxw7mXJ31gwi5v+FBZqq6XKXR+LYekpMdmJOfU3Yho0 4Q0EyTslN/Sp/n9SObq7LKd0Hze5hIw9JQEm0SMnR4dnn59IpS0NSbMz0LiuQNzzUsJJ ubSysRj2G7/tjU7TMDdKtjUC7zOxpelASc6kaoLHDZLhd4BnYAI8fOsAM6T1fWR4tpLf Uz3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ha3cIbG1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h13si942426pgq.28.2017.11.29.00.44.16; Wed, 29 Nov 2017 00:44:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ha3cIbG1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753797AbdK2IoP (ORCPT + 28 others); Wed, 29 Nov 2017 03:44:15 -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-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.13.6 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); From patchwork Wed Nov 29 08:41:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 119932 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2782431qgn; Wed, 29 Nov 2017 00:44:03 -0800 (PST) X-Google-Smtp-Source: AGs4zMaL2hbwcS4lMOxJRH779bAveAsMTVamDlDHp6q137I/DJOHm2Qu/n2508/TmJxl91PI1maI X-Received: by 10.101.96.1 with SMTP id m1mr2079395pgu.38.1511945042985; Wed, 29 Nov 2017 00:44:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511945042; cv=none; d=google.com; s=arc-20160816; b=gPgazbmdryh7FhLAG+vIuA44pa2k2rCsJJf5rtICdPz7PJgwfd6wFxVg+GCxvC8XWT o0m4i3TJFNNApgpvgSrPHgVoCUFrqGI0e/T/g75tROLMDHa57gAbuBSfNH+4gpb+Jh+h wqkfOF3GQL764ymgs7bXrFDYThwI08vy0V9+dcY/daTfkXCQDgUcKqeLuV21wfiC7DgO CuN+PklmY2xbTsRtHQ7cZ39Ks7lut+fqcmZSVO1pODCwbbX5LGmeSewMkKa4D9c4l4nf d+YHCYvfQ5VuqPX6jifUaoWOGJi5jePyLsl3gdsxHW728j2YYOLpIMoyPxpyQoJn9Tvc zpOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=MrdKqTiQmuOfevQVvtq82E9mHKdrHfboMevxIkOPurM=; b=EhxEF/s/77TL+w0F7XU1WG6cIr4GUFT4vQqe3bzEV+/IgqoKIk0gjROfKfvZKVSzwO 8hdf8PNP4jVsEIDNNaTAMtiYDMPz0jI1iiLJSEz/vzZGnBTF3sItdrWyqEXEAAXM/ctX T6+jtlv4F+LdG031DeC5kkE/6kHtnEIg/a8WSzBfeN+WiwyAbne/s0Bd83WpvMLGfI0R hNzn0DZaZ0u3hcEoEw0QCjinHbyv4S0/YSRE4VzgHaIOQsjF9YkCCaCQwbBed9WiXN4h NT/k9gZrwBQSvlb0UNay8pwg4eoxfgsJxlGgpcw9fwgSPXWPeK/kYas5mAJ8fpyUwTeJ soKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=t/RmWAqt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p9si928807pls.471.2017.11.29.00.44.02; Wed, 29 Nov 2017 00:44:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=t/RmWAqt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753769AbdK2IoA (ORCPT + 28 others); Wed, 29 Nov 2017 03:44:00 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:36733 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753686AbdK2Inv (ORCPT ); Wed, 29 Nov 2017 03:43:51 -0500 Received: by mail-wr0-f194.google.com with SMTP id v105so2622497wrc.3; Wed, 29 Nov 2017 00:43:51 -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=MrdKqTiQmuOfevQVvtq82E9mHKdrHfboMevxIkOPurM=; b=t/RmWAqt4SXnR+XJwOrg0m8gXDnVBz7usPT6rxYTXrx2OqsLSr8AJxiYX+cZx07H6+ gqGD59xUeG4WcbQ72x3MMqoIKV4lL2IwXjFsmOnro/bo2kb4bZ4I1Dptb9bS7I0vA/oG 3ZNBkT/q6IHHafPMC051rJJ7WMX0zArM6/WmEDUl+7RYwN7FZr6o35b48S7mSmkq1EjO VUrn8Bd95qyzQj+NNiWIMMCRMcNQFEOXzSQl+atnM0mCAYjHu+uRV5mOvwMizv+E4Vjr 6n8L3SMWKNpq8xFq3selfjOOdO1N0xn4ZW8O6ONVeLu4NwWF/MF9xCoV0nS3Ja+QDu7C dMWA== 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=MrdKqTiQmuOfevQVvtq82E9mHKdrHfboMevxIkOPurM=; b=Qvzwnj2j7l8L8i6Oq0a8vuClQHW71UmK+1gcps3wWaohglCDCCsqe2ip9Re+weMooT UiX07bO0pzihzc5JpsBXQigTj9PRFcCyE950rDoN6/FLjnVYwXv/ux75m1p19Ha2ey9z Emku1ZiENUVJxlZobbRw4UkMJfXmTN3J0mVIXgMP6ugE4u+xGcgFFaYlQwY8SWNgoJrO ywsqRm1pQCEG5udy5jGvpMfQi3WW1Ed/qe34DGfJACogh7lMI02rZfRqaqZ51kU9fAPG ItQwjzNEbpneFYKYKMSYDyJdoOe3YjlM6GY0UPit7uUYGoMxhV+wg+Jd+3YMzWUXmOyN f1Qg== X-Gm-Message-State: AJaThX7h/VNOIl+3FBEjrFCKtLEtjEKkHIzLb4tW4aKuY/OCXROmoFpM GVy7tGZairiT9WuLki6sijU= X-Received: by 10.223.172.115 with SMTP id v106mr1755174wrc.195.1511945030522; Wed, 29 Nov 2017 00:43:50 -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.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Nov 2017 00:43:49 -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 4/4] crypto: stm32: convert to the new crypto engine API Date: Wed, 29 Nov 2017 09:41:21 +0100 Message-Id: <20171129084121.9385-5-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch convert the driver to the new crypto engine API. Signed-off-by: Corentin Labbe --- drivers/crypto/stm32/stm32-hash.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) -- 2.13.6 diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c index 4ca4a264a833..e3f9f7b04ce2 100644 --- a/drivers/crypto/stm32/stm32-hash.c +++ b/drivers/crypto/stm32/stm32-hash.c @@ -122,6 +122,7 @@ enum stm32_hash_data_format { #define HASH_DMA_THRESHOLD 50 struct stm32_hash_ctx { + struct crypto_engine_reqctx enginectx; struct stm32_hash_dev *hdev; unsigned long flags; @@ -811,7 +812,7 @@ static void stm32_hash_finish_req(struct ahash_request *req, int err) rctx->flags |= HASH_FLAGS_ERRORS; } - crypto_finalize_hash_request(hdev->engine, req, err); + crypto_finalize_request(hdev->engine, &req->base, err); } static int stm32_hash_hw_init(struct stm32_hash_dev *hdev, @@ -828,15 +829,21 @@ static int stm32_hash_hw_init(struct stm32_hash_dev *hdev, return 0; } +static int stm32_hash_one_request(struct crypto_engine *engine, + struct crypto_async_request *areq); +static int stm32_hash_prepare_req(struct crypto_engine *engine, + struct crypto_async_request *areq); + static int stm32_hash_handle_queue(struct stm32_hash_dev *hdev, struct ahash_request *req) { - return crypto_transfer_hash_request_to_engine(hdev->engine, req); + return crypto_transfer_request_to_engine(hdev->engine, &req->base); } static int stm32_hash_prepare_req(struct crypto_engine *engine, - struct ahash_request *req) + struct crypto_async_request *areq) { + struct ahash_request *req = ahash_request_cast(areq); struct stm32_hash_ctx *ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(req)); struct stm32_hash_dev *hdev = stm32_hash_find_dev(ctx); struct stm32_hash_request_ctx *rctx; @@ -855,8 +862,9 @@ static int stm32_hash_prepare_req(struct crypto_engine *engine, } static int stm32_hash_one_request(struct crypto_engine *engine, - struct ahash_request *req) + struct crypto_async_request *areq) { + struct ahash_request *req = ahash_request_cast(areq); struct stm32_hash_ctx *ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(req)); struct stm32_hash_dev *hdev = stm32_hash_find_dev(ctx); struct stm32_hash_request_ctx *rctx; @@ -1033,6 +1041,9 @@ static int stm32_hash_cra_init_algs(struct crypto_tfm *tfm, if (algs_hmac_name) ctx->flags |= HASH_FLAGS_HMAC; + ctx->enginectx.op.do_one_request = stm32_hash_one_request; + ctx->enginectx.op.prepare_request = stm32_hash_prepare_req; + ctx->enginectx.op.unprepare_request = NULL; return 0; } @@ -1493,9 +1504,6 @@ static int stm32_hash_probe(struct platform_device *pdev) goto err_engine; } - hdev->engine->prepare_hash_request = stm32_hash_prepare_req; - hdev->engine->hash_one_request = stm32_hash_one_request; - ret = crypto_engine_start(hdev->engine); if (ret) goto err_engine_start;