Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp599225rda; Sun, 22 Oct 2023 01:19:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGzEqO0XC674vH7mP7oxWyR2Vc9/1UN3/Fy6vefqxF1p6005Voa6ej5/I2XAn1ckCh1PkIw X-Received: by 2002:a05:6a00:2d9d:b0:6be:319:446b with SMTP id fb29-20020a056a002d9d00b006be0319446bmr7542594pfb.21.1697962763902; Sun, 22 Oct 2023 01:19:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697962763; cv=none; d=google.com; s=arc-20160816; b=QSa9erMwuYu8/AccMBfufBov1eyppciqZLi5ZQl/qCADGQ7tutj7W/RH5Mj0zMT/TS LplczxCQxXHmAs1epVDpfyJAyaSuBuRS1e9/MDMi2r+C+JuemFKeDGQxngsN41U5OUUO R9VD+1kGT9ytg31pd65i92S6iJR/cz+7n0hloe264RZiXN/en0DibL/5VzHEmKqSoPkB bF2CUURAOg4qpQ8K1Q/L2CzgftFCJIzudAIxfsRCNtZLtd02MH5Va1QyO9FCpwPmD1R6 gxtwdDcpsxNXKxpLPELWeiPznMU36g2+F5gntraAKBOXnAKGIm9PDSrYfCvWbAtwr9Cc 1ifQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=J/WYlUXEGyBFigZacI6p7OsdFLZBiynJpzX+kaT0Dsw=; fh=uKl1CTlin8qnxt56ErGp3UOINPCBskOXHDuKvJLDQbo=; b=OspmJ5AHF71zTQYGatry6z71Oz7vfH2nTUuKxvaT4l5F5cjcFg/3awYgVo86hyOTZh hVweVJmTlGjT+MJbHyEVMN91YiUbP9Kr8xvOr+euCHbjRnGq/7KusZh130v3ULyaHuoQ ezyXpKSlX5CXmw7PB4IUE16lw/LqN/DHb2yaXqcS1f2AX5ZG0YWRiRIuQt9n4iuQqkKa b29zaA2qlzLcR0iLiJ7W6BFKR+T+mFtZMuq0J3fg0KwfNs8VtjRK775t9kCeCRSs9nK+ 4HVfE5wPdKLlU/A/H6xMm+XREvmQQ7xsvC4hEhH4FMV0/rP5jIr/KV1GFapL4L1Dc9My 2YDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tdyNRRNL; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id k29-20020a637b5d000000b00578c8ce14edsi4757295pgn.252.2023.10.22.01.19.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Oct 2023 01:19:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tdyNRRNL; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id E7F148057475; Sun, 22 Oct 2023 01:19:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231877AbjJVITO (ORCPT + 99 others); Sun, 22 Oct 2023 04:19:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231722AbjJVISx (ORCPT ); Sun, 22 Oct 2023 04:18:53 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69E30D53 for ; Sun, 22 Oct 2023 01:18:49 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 307F8C433C7 for ; Sun, 22 Oct 2023 08:18:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697962729; bh=ji3lKzqwdzm3b5FtRsxKYlJDL+v3S0VySToriL6uwC4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=tdyNRRNLpkK4MxpRc3j3/km9Jwaty08JLzhB9aZfw7S8X+YFUT6sM6uG2ztvBOK3c GNgrSL9djBNzTYfFKCLZvdIL9/fgLqR3yhXijwlk2JpK+1ODiQUGjPtex2KAK+lk8P g1401dS87fpPrhvQzED5qr1K+Npm1iT/e+kozKeNqYDK38FaO8iNN3lJA4/rpeTbYr dlYV/RG+pm7+inWjhZZmzdnN+h9obwPsNtupVwndxJ5kqCU27DKJl8Phcwppb3YwkL c3nyVa0GVJSdM+TrRD6dTeCmmPJVcQGdPJEpynuT1bu9AMBwwjEUL9c0XAd57hBwCR QejP4ZTuer2rQ== From: Eric Biggers To: linux-crypto@vger.kernel.org Subject: [PATCH 26/30] crypto: chelsio - stop using crypto_ahash::init Date: Sun, 22 Oct 2023 01:10:56 -0700 Message-ID: <20231022081100.123613-27-ebiggers@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231022081100.123613-1-ebiggers@kernel.org> References: <20231022081100.123613-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Sun, 22 Oct 2023 01:19:21 -0700 (PDT) From: Eric Biggers The function pointer crypto_ahash::init is an internal implementation detail of the ahash API that exists to help it support both ahash and shash algorithms. With an upcoming refactoring of how the ahash API supports shash algorithms, this field will be removed. Some drivers are invoking crypto_ahash::init to call into their own code, which is unnecessary and inefficient. The chelsio driver is one of those drivers. Make it just call its own code directly. Signed-off-by: Eric Biggers --- drivers/crypto/chelsio/chcr_algo.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c index 16298ae4a00bf..177428480c7d1 100644 --- a/drivers/crypto/chelsio/chcr_algo.c +++ b/drivers/crypto/chelsio/chcr_algo.c @@ -1913,39 +1913,46 @@ static int chcr_ahash_finup(struct ahash_request *req) set_wr_txq(skb, CPL_PRIORITY_DATA, req_ctx->txqidx); chcr_send_wr(skb); return -EINPROGRESS; unmap: chcr_hash_dma_unmap(&u_ctx->lldi.pdev->dev, req); err: chcr_dec_wrcount(dev); return error; } +static int chcr_hmac_init(struct ahash_request *areq); +static int chcr_sha_init(struct ahash_request *areq); + static int chcr_ahash_digest(struct ahash_request *req) { struct chcr_ahash_req_ctx *req_ctx = ahash_request_ctx(req); struct crypto_ahash *rtfm = crypto_ahash_reqtfm(req); struct chcr_dev *dev = h_ctx(rtfm)->dev; struct uld_ctx *u_ctx = ULD_CTX(h_ctx(rtfm)); struct chcr_context *ctx = h_ctx(rtfm); struct sk_buff *skb; struct hash_wr_param params; u8 bs; int error; unsigned int cpu; cpu = get_cpu(); req_ctx->txqidx = cpu % ctx->ntxq; req_ctx->rxqidx = cpu % ctx->nrxq; put_cpu(); - rtfm->init(req); + if (is_hmac(crypto_ahash_tfm(rtfm))) + chcr_hmac_init(req); + else + chcr_sha_init(req); + bs = crypto_tfm_alg_blocksize(crypto_ahash_tfm(rtfm)); error = chcr_inc_wrcount(dev); if (error) return -ENXIO; if (unlikely(cxgb4_is_crypto_q_full(u_ctx->lldi.ports[0], req_ctx->txqidx) && (!(req->base.flags & CRYPTO_TFM_REQ_MAY_BACKLOG)))) { error = -ENOSPC; goto err; -- 2.42.0