Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1554154lqz; Mon, 1 Apr 2024 09:34:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXRIac4XqSvpNhWoa/omPWrJ/0JiaKfdSvAu7FhAauie/qF+vZwCH39C8QQxzOz6ES7sBmjz/sl2dQXhOMwEkdYVRzU4OIhb1o29M7gEQ== X-Google-Smtp-Source: AGHT+IG3fxsrXlTyMpKw+elM57EpMw0UoRoo+L9v3NkLG85mB+AKnrXNFk3C0mDGyZvceQ897NZM X-Received: by 2002:a05:6359:4594:b0:17f:88fb:4164 with SMTP id no20-20020a056359459400b0017f88fb4164mr15429313rwb.7.1711989253423; Mon, 01 Apr 2024 09:34:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711989253; cv=pass; d=google.com; s=arc-20160816; b=E+J2qUcEqSKvGcs9t+KIdkkR8OcJYwmDiU359XBkfQRZrxPGfJHKHz1BVnvACRkzaI Mn/EGYojEeO+TmtmkxyYDEU/bsU54spRAI9aiWkfMLlK9mgS3TvwVJmb7gHlJychoBW3 eE0UIbyUJrILHUVSi99UQZ6gClZowYxpekbjrpaw3vXb3+oZELp8QwNesoOCu8kamkrg 0drk1kER40koEUOGSKjngw7jqVk9cCH31nk1GNhBsDnimtnQPbzOUWOF/cTmDz0J8xRA 9EgMbpyl86/CgimQXOOyCa4mI4q+VpEWFHHxQR6Oj51/wRYH51naczP4P+6REgHydHsA GOew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature :dkim-filter; bh=39I0Y90dA9bIsxVXudHTnA9QLat04AGZ2eAVp1pKulQ=; fh=PAQB8e+XsuJXOS7EKQNJuoca0xOdPvfvVQIaYCy1Pu0=; b=RTxv2O/8B32g4lVRTI7tq4Fm3YnAMyrbdIBjd4pWYmKul+qr/qfSctwV4mQXXBB2jq G6L3felsCFUmWNydem75iAyy9KDOdY8/xfyT7j3lfGM/076ziGoQNLd6SV2G8YMqwtSk 6pC4HRrN3PMIwrCEBESMxRcGyBWSLKeoqtgH1UfY5L1QirxcDKVowIYw+uu8EUejL6rK EQeoJkoKIqKBk1HIgppwWk/d94baENGJMHNUaiO8x+EKDgyDkIWTLe0SRT95ePw2sQCH Mwt9hrB3FobXpW53TH58ncphrR9cup7LWtLx3iHX7WxgpHCm6uadbScD/kZBe+ZDZpmV qaQA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=AoAnnVei; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-crypto+bounces-3236-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3236-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h37-20020a632125000000b005cdc5c70fd5si9104669pgh.531.2024.04.01.09.34.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 09:34:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-3236-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=AoAnnVei; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-crypto+bounces-3236-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3236-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 0A16C282714 for ; Mon, 1 Apr 2024 16:34:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CEB393F8F4; Mon, 1 Apr 2024 16:34:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="AoAnnVei" X-Original-To: linux-crypto@vger.kernel.org Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 036011E525 for ; Mon, 1 Apr 2024 16:34:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711989251; cv=none; b=FPfwXZ5qj3LZk1RfWOQVOk2RxOq98QfZ2FY8tyCxC91kvybnupNCwPqSXdII4xwRV/ab3voqI5jZEeIZIibUj8MmWfsZQnOWkPvrcE6N/zs7KmsMvYiXG8fqFVctTLz4Q9haessud5+3e3pZgFELt5CBtFu4uV5JrNsOSjtYv+0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711989251; c=relaxed/simple; bh=2HR4hSPxoXiOT9ncvLIn94WohHa3F3zyMsRCFeKu9Sw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=bjZVp1zlUxnR4gh1Pm2ah2p+gMc9TkZ2JWTdCmsCJqlo7dP/RIKvt0kcAUda6iwSHD+djIVo9e+1mvWs+g3Cyc13L524xHSjz9/zP7+J9tKqp2kdAS/hQTIAaHVe2jb/dwmaXntEG/8RTqI9bM9aSvQquh0g6MV2dRMebXlzsUM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=AoAnnVei; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Received: from [100.64.200.249] (unknown [20.29.225.195]) by linux.microsoft.com (Postfix) with ESMTPSA id 21244208B324; Mon, 1 Apr 2024 09:34:03 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 21244208B324 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1711989243; bh=39I0Y90dA9bIsxVXudHTnA9QLat04AGZ2eAVp1pKulQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=AoAnnVeiCqP4xgpUdV0eY+BbG3IcSd8rX0ooGdxIiw2md1z/EmgQU05sRDeTtFzk/ UzUThpDqNS8BOmd93Qwa9x543sdriBz1MwtZPKa9Yjmz1LLylt5Yc59InT76A2rjzY y+haT8+jxab56QAzLSmbCUpyI3JygjIfMGf5gpbg= Message-ID: <0ca1f15a-f883-407f-8837-c2a9891637f4@linux.microsoft.com> Date: Mon, 1 Apr 2024 09:34:03 -0700 Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 1/4] Add SPAcc driver to Linux kernel To: Pavitrakumar Managutte Cc: herbert@gondor.apana.org.au, linux-crypto@vger.kernel.org, Ruud.Derwig@synopsys.com, manjunath.hadli@vayavyalabs.com, bhoomikak@vayavyalabs.com, shwetar References: <20240328182652.3587727-1-pavitrakumarm@vayavyalabs.com> <20240328182652.3587727-2-pavitrakumarm@vayavyalabs.com> <6e486947-54cb-4ff5-bcf3-97e6ae106412@linux.microsoft.com> Content-Language: en-CA From: Easwar Hariharan In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 4/1/2024 12:21 AM, Pavitrakumar Managutte wrote: > Hi Easwar, > My comments are embedded below. Also should I wait for more comments > from you or > should I go ahead and push v2 with the below fixes ? > > Warm regards, > PK > Please see more comments below, and go ahead and push a v2. If possible, split the series into more patches. I leave it to you to group them by file or logical functionality, so long as each individual commit compiles neatly so as to not break future git bisects. On 3/28/2024 11:26 AM, Pavitrakumar M wrote: > Signed-off-by: shwetar > Signed-off-by: Pavitrakumar M > Acked-by: Ruud Derwig > --- > drivers/crypto/dwc-spacc/spacc_aead.c | 1382 ++++++++++ > drivers/crypto/dwc-spacc/spacc_ahash.c | 1183 ++++++++ > drivers/crypto/dwc-spacc/spacc_core.c | 2917 ++++++++++++++++++++ > drivers/crypto/dwc-spacc/spacc_core.h | 839 ++++++ > drivers/crypto/dwc-spacc/spacc_device.c | 324 +++ > drivers/crypto/dwc-spacc/spacc_device.h | 236 ++ > drivers/crypto/dwc-spacc/spacc_hal.c | 365 +++ > drivers/crypto/dwc-spacc/spacc_hal.h | 113 + > drivers/crypto/dwc-spacc/spacc_interrupt.c | 204 ++ > drivers/crypto/dwc-spacc/spacc_manager.c | 670 +++++ > drivers/crypto/dwc-spacc/spacc_skcipher.c | 754 +++++ > 11 files changed, 8987 insertions(+) > create mode 100644 drivers/crypto/dwc-spacc/spacc_aead.c > create mode 100644 drivers/crypto/dwc-spacc/spacc_ahash.c > create mode 100644 drivers/crypto/dwc-spacc/spacc_core.c > create mode 100644 drivers/crypto/dwc-spacc/spacc_core.h > create mode 100644 drivers/crypto/dwc-spacc/spacc_device.c > create mode 100644 drivers/crypto/dwc-spacc/spacc_device.h > create mode 100644 drivers/crypto/dwc-spacc/spacc_hal.c > create mode 100644 drivers/crypto/dwc-spacc/spacc_hal.h > create mode 100644 drivers/crypto/dwc-spacc/spacc_interrupt.c > create mode 100644 drivers/crypto/dwc-spacc/spacc_manager.c > create mode 100644 drivers/crypto/dwc-spacc/spacc_skcipher.c > diff --git a/drivers/crypto/dwc-spacc/spacc_ahash.c b/drivers/crypto/dwc-spacc/spacc_ahash.c > new file mode 100644 > index 000000000000..53c76ee16c53 > --- /dev/null > +++ b/drivers/crypto/dwc-spacc/spacc_ahash.c > @@ -0,0 +1,1183 @@ > +// SPDX-License-Identifier: GPL-2.0 > + > + > +static int spacc_hash_init(struct ahash_request *req) > +{ > + int x = 0, rc = 0; > + struct crypto_ahash *reqtfm = crypto_ahash_reqtfm(req); > + struct spacc_crypto_ctx *tctx = crypto_ahash_ctx(reqtfm); > + struct spacc_crypto_reqctx *ctx = ahash_request_ctx(req); > + const struct spacc_alg *salg = spacc_tfm_ahash(&reqtfm->base); > + struct spacc_priv *priv = dev_get_drvdata(tctx->dev); > + > + > + ctx->digest_buf = NULL; > + > + ctx->single_shot = 0; > + ctx->total_nents = 0; > + ctx->cur_part_pck = 0; > + ctx->final_part_pck = 0; > + ctx->rem_len = 0; > + ctx->rem_nents = 0; > + ctx->first_ppp_chunk = 1; > + ctx->small_pck = 1; > + tctx->ppp_sgl = NULL; > + > + if (tctx->handle < 0 || !tctx->ctx_valid) { > + priv = NULL; > + dev_dbg(tctx->dev, "%s: open SPAcc context\n", __func__); > + > + for (x = 0; x < ELP_CAPI_MAX_DEV && salg->dev[x]; x++) { > + priv = dev_get_drvdata(salg->dev[x]); > + tctx->dev = get_device(salg->dev[x]); > + if (spacc_isenabled(&priv->spacc, salg->mode->id, 0)) { > + tctx->handle = spacc_open(&priv->spacc, > + CRYPTO_MODE_NULL, > + salg->mode->id, -1, 0, > + spacc_digest_cb, reqtfm); > + } > + > + if (tctx->handle >= 0) > + break; > + > + put_device(salg->dev[x]); > + } > + > + if (tctx->handle < 0) { > + dev_dbg(salg->dev[0], "Failed to open SPAcc context\n"); > + goto fallback; > + } > + > + rc = spacc_set_operation(&priv->spacc, tctx->handle, > + OP_ENCRYPT, ICV_HASH, IP_ICV_OFFSET, > + 0, 0, 0); > + if (rc < 0) { > + spacc_close(&priv->spacc, tctx->handle); > + dev_dbg(salg->dev[0], "Failed to open SPAcc context\n"); > + tctx->handle = -1; > + put_device(tctx->dev); > + goto fallback; > + } > + tctx->ctx_valid = true; > + } else { > + ;/* do nothing */ > + } Do we need this else? > + > + /* alloc ppp_sgl */ > + tctx->ppp_sgl = kmalloc(sizeof(*(tctx->ppp_sgl)) * 2, GFP_KERNEL); > + if (!tctx->ppp_sgl) > + return -ENOMEM; > + > + sg_init_table(tctx->ppp_sgl, 2); > + > + return 0; > +fallback: > + > + ctx->fb.hash_req.base = req->base; > + ahash_request_set_tfm(&ctx->fb.hash_req, tctx->fb.hash); > + > + return crypto_ahash_init(&ctx->fb.hash_req); > +} > + > +static int spacc_hash_final_part_pck(struct ahash_request *req) > +{ > + struct crypto_ahash *reqtfm = crypto_ahash_reqtfm(req); > + struct spacc_crypto_ctx *tctx = crypto_ahash_ctx(reqtfm); > + struct spacc_crypto_reqctx *ctx = ahash_request_ctx(req); > + struct spacc_priv *priv = dev_get_drvdata(tctx->dev); > + > + int rc; > + > + ctx->final_part_pck = 1; > + > + /* In all the final calls the data is same as prev update and > + * hence we can skip this init dma part and just enQ ddt > + * No use in calling initdata, just process remaining bytes in ppp_sgl > + * and be done with it. > + */ > + > + rc = spacc_hash_init_dma(tctx->dev, req, 1); > + > + if (rc < 0) > + return -ENOMEM; > + > + if (rc == 0) { > + ;/* small packet */ > + } Please cleanup these do-nothing comment code paths throughout. > + > + /* enqueue ddt for the remaining bytes of data, everything else > + * would have been processed already, req->nbytes need not be > + * processed > + * Since this will hit only for small pkts, hence the condition > + * ctx->rem_len-req->nbytes for the small pkt len > + */ > + if (ctx->rem_len) > + rc = spacc_packet_enqueue_ddt(&priv->spacc, > + ctx->acb.new_handle, &ctx->src, &ctx->dst, > + tctx->ppp_sgl[0].length, > + 0, tctx->ppp_sgl[0].length, 0, 0, 0); > + else { > + /* zero msg handling */ > + rc = spacc_packet_enqueue_ddt(&priv->spacc, > + ctx->acb.new_handle, > + &ctx->src, &ctx->dst, 0, 0, 0, 0, 0, 0); > + } > + > + if (rc < 0) { > + spacc_hash_cleanup_dma(tctx->dev, req); > + spacc_close(&priv->spacc, ctx->acb.new_handle); > + > + if (rc != -EBUSY) { > + dev_err(tctx->dev, "ERR: Failed to enqueue job: %d\n", rc); > + return rc; > + } > + > + if (!(req->base.flags & CRYPTO_TFM_REQ_MAY_BACKLOG)) > + return -EBUSY; > + } > + > + return -EINPROGRESS; > +} > + Thanks, Easwar