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);