From patchwork Thu Apr 18 13:38:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 162489 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp762127jan; Thu, 18 Apr 2019 06:41:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqz+ydcryK8WBNmpqAztt5z9CseY8YYXRPq0puWioq+erwsR8gL/1OISOf7+wqHdhhbKCbhO X-Received: by 2002:aa7:8a92:: with SMTP id a18mr6711309pfc.218.1555594894525; Thu, 18 Apr 2019 06:41:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555594894; cv=none; d=google.com; s=arc-20160816; b=Tf+u7bIXbMecLT2t51ZU4eSZwWF/pF5RPOIfWx4dfYVrx4oY7HReHR590pcWdiB/+L 0ZfqK7FWFOO/C1nT0ilHQ2K221ar3Fyio73/jgNAJvHlGZ96b53yaQyxPqMjRG6xNw0m lS2YKBHz4kz3xDOVADhzSuIRyOTFqchNgK/TSFBHe085XuMqIqtlllI4KkSoqjC2s7i6 pzOeZdu8Xc++OUo1x0l7r66NBCc3+IrNOjxSZVipBIrNx0pB0ixXC+cOqn2alIMQY5qA 8DsKhSFJMy543irR3vIUKR8Gz6CoP+ddGZT9BoEwj8WDTNil8LWJ1Rya2oh3fUkUb4eJ 7xNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=zhmaUxP/QDrutczUl+Tp6hZcB7wrv5cdjuk1xc2HyBs=; b=BO5QkvW7LEKgRGbDB87HCBrAGqIcmamsxOYYBVSwdvShuJR8ZqPoxo0tx49Dbom3/w tCMDAhnNIPvR1Oddjo3yd8d49SjKl8ru1wZy5sqiDZn0hUw5VHhl/vSXN6Yy6XO6GGJl ed5wUp0BBDwAXx1Vk4YJxw5CxP1JX7jnkjXr5qo72iAtcpKyadNgy0l7Ev0jUs8ZhCuQ FWux8Rskn1NcjvcY4+desBzGwfTkjOtPZFC5REWJwpnrtm8OivRoZkvB8HLlqjADiflJ m7UcTKQuUw5J0pnHb0fPqyLEfYIX0IpMx+HvL55uMElRIvoGJ8GYE2GdWd96+iZF5zYQ +KTg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r6si2114325plo.349.2019.04.18.06.41.34; Thu, 18 Apr 2019 06:41:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389200AbfDRNld (ORCPT + 3 others); Thu, 18 Apr 2019 09:41:33 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:33692 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388375AbfDRNlc (ORCPT ); Thu, 18 Apr 2019 09:41:32 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4F0891688; Thu, 18 Apr 2019 06:41:32 -0700 (PDT) Received: from e110176-lin.kfn.arm.com (e110176-lin.kfn.arm.com [10.50.4.178]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D7CBF3F5AF; Thu, 18 Apr 2019 06:41:30 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" Cc: Ofir Drang , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 23/35] crypto: ccree: simplify AEAD ICV addr calculation Date: Thu, 18 Apr 2019 16:38:58 +0300 Message-Id: <20190418133913.9122-24-gilad@benyossef.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418133913.9122-1-gilad@benyossef.com> References: <20190418133913.9122-1-gilad@benyossef.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The function cc_prepare_aead_data_dlli() which calculates ICV addresses was needlessly complicate it. This patch simplifies it without altering its functionality. Signed-off-by: Gilad Ben-Yossef --- drivers/crypto/ccree/cc_buffer_mgr.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) -- 2.21.0 diff --git a/drivers/crypto/ccree/cc_buffer_mgr.c b/drivers/crypto/ccree/cc_buffer_mgr.c index 8269474cb9fa..8554cfb2963a 100644 --- a/drivers/crypto/ccree/cc_buffer_mgr.c +++ b/drivers/crypto/ccree/cc_buffer_mgr.c @@ -749,27 +749,21 @@ static void cc_prepare_aead_data_dlli(struct aead_request *req, struct aead_req_ctx *areq_ctx = aead_request_ctx(req); enum drv_crypto_direction direct = areq_ctx->gen_ctx.op_type; unsigned int authsize = areq_ctx->req_authsize; + struct scatterlist *sg; + ssize_t offset; areq_ctx->is_icv_fragmented = false; - if (req->src == req->dst) { - /*INPLACE*/ - areq_ctx->icv_dma_addr = sg_dma_address(areq_ctx->src_sgl) + - (*src_last_bytes - authsize); - areq_ctx->icv_virt_addr = sg_virt(areq_ctx->src_sgl) + - (*src_last_bytes - authsize); - } else if (direct == DRV_CRYPTO_DIRECTION_DECRYPT) { - /*NON-INPLACE and DECRYPT*/ - areq_ctx->icv_dma_addr = sg_dma_address(areq_ctx->src_sgl) + - (*src_last_bytes - authsize); - areq_ctx->icv_virt_addr = sg_virt(areq_ctx->src_sgl) + - (*src_last_bytes - authsize); + + if ((req->src == req->dst) || direct == DRV_CRYPTO_DIRECTION_DECRYPT) { + sg = areq_ctx->src_sgl; + offset = *src_last_bytes - authsize; } else { - /*NON-INPLACE and ENCRYPT*/ - areq_ctx->icv_dma_addr = sg_dma_address(areq_ctx->dst_sgl) + - (*dst_last_bytes - authsize); - areq_ctx->icv_virt_addr = sg_virt(areq_ctx->dst_sgl) + - (*dst_last_bytes - authsize); + sg = areq_ctx->dst_sgl; + offset = *dst_last_bytes - authsize; } + + areq_ctx->icv_dma_addr = sg_dma_address(sg) + offset; + areq_ctx->icv_virt_addr = sg_virt(sg) + offset; } static void cc_prepare_aead_data_mlli(struct cc_drvdata *drvdata,