Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2766454rda; Wed, 25 Oct 2023 11:37:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF85pF2MLAVfhDJ83Om71cQFBcsU7+Vx1+qDImLLG4ocZ9w4DfKw+4yzcd4NCKrOigK/Fr2 X-Received: by 2002:a05:6870:f60e:b0:1ea:989c:3c9f with SMTP id ek14-20020a056870f60e00b001ea989c3c9fmr17936022oab.31.1698259077551; Wed, 25 Oct 2023 11:37:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698259077; cv=none; d=google.com; s=arc-20160816; b=AUEidDrWmxt0VomSGpUF9cygcbJzQ35r56EcxIU7K+b4jgmPVejeSt4X2P2WmYryI3 Dv8UlD3ZUS0OT1wCXNfolwvhjcLeqY9zIacgJ34dVuQQAF/TU21uR4/i1wyLjEdcIu+a WA4lDpTRJeDamUxcBoYtVmJfp737FYwN9kqGX8fS0TfjFzr1turlszx5R/zORbx9jKsH +BwZhwS4d1aiHhAz1xe/FJzH4UmROvSN6lC0OBjc6Xn8hhI7JS8mQyZ3nGv4ZjmGIC0l jom6JGOWL43cjkrXgXolnf6+tkCAh59jYXT4ECvkdzJLkL8FQyPQe8B37h0TVfIS8Sf1 Z/MQ== 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:cc:to:from :dkim-signature; bh=KWDZyqBJhOVpYqYhwbudR4lRinTiZ1fIB/oQ8fHi3tg=; fh=mW5aUsjoOotHlwNYMx8xbHsUCWUVMMbs4tDVgGIL6Ds=; b=ORi6dBHeJu+1cmO9+TN2WqPADovw0nDLWd3dOuxQKENFW40lZJZd8KFzYbBtZ8qnDZ unw+Ka4o4q6ZbbH2hNH7MVuA3QU9NANZoO/cvGCbygAJcY2ADFjD/duXtDzU/VRAR+E5 m/0yKUy2ap0HiOY6fgSIwIfNb6MK1JGcrRGi5IuSyaaJi5QfyfFmb6oQjbEweUanbLTH YSv2xTlxHzYDydIot+NUFtlPuFzq02YmXD5GEfYnIQVr49A+wec8VHzFNCZovuKVxZbM BmWOKQkXiUvJHkvSRL02PyG1c5kC8F2xLy5Bko7yYVS1MqzVkZm1LhNkO/eplJ4HOnpl kGgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=mRDDTlxD; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id e11-20020a25d30b000000b00d7e34de1692si12263656ybf.250.2023.10.25.11.37.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 11:37:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=mRDDTlxD; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 7BF6580E9E18; Wed, 25 Oct 2023 11:37:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234062AbjJYShi (ORCPT + 99 others); Wed, 25 Oct 2023 14:37:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234952AbjJYShV (ORCPT ); Wed, 25 Oct 2023 14:37:21 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 637A31BE for ; Wed, 25 Oct 2023 11:37:16 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-27e0c1222d1so17454a91.0 for ; Wed, 25 Oct 2023 11:37:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1698259036; x=1698863836; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KWDZyqBJhOVpYqYhwbudR4lRinTiZ1fIB/oQ8fHi3tg=; b=mRDDTlxDfVZ4q4JsFyDbCTEDG/QLsx/GfO41ZwHBPW87ceShqpqIoBk8el3SDT0c7b Z70hpl8okKOoMgyTscvmy8Q2WsMEW9ovIwGyJjUFn6ag3nIqnu/o6tFYmP6v8vJCWdj1 nyXYOBcGgGXk5i4qXzrjEdYxAee8jRMTwG0Lvx1BYPeEIEgk9gD4iTHYCdvGQhHqQR9A KrLLnbQbbMQ0XV8fY0jUFh7qHRF+kW4DkwfoIB7zHlxUxlWuK51Y1eRpyo6M04CjLvLA Fr5VjXUd3tfBiwZOzMW1RS58SCfnCi75cmlZi21VvipOEDTppJLGTklc34sFsGZhg5ME wAgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698259036; x=1698863836; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KWDZyqBJhOVpYqYhwbudR4lRinTiZ1fIB/oQ8fHi3tg=; b=hU0rLvDRVaqeeSylsxS8Laz0b77D0AqdLhU/52ndgSUmRPKNGhE/Yo8yzhgFT7AzIR T5hpNNM72a8Fg437Ve0sNcGrBt8uOj2nRcoCgTj7ndT3ktK1A+0RLJdc1nOQuZVpA27P rOF6+M2n46WUXO8fXpAWX/VNP2fZc3f2AeByb9vU7mJbVhfrcDKDc8zxwkFi1YVKOid8 QEjd59PxaQ83alAn/D9THsgJ4ZajVK59V7Li64he9XNPYvjCMgwRE/57auJYSSepeT99 PIBRMSm2Jd4+M8uChxwbzk4D7q0n9vREuo/1UaaIcGFtl9ZY/p8VrAbiGUKMJpUNt2uR JBxA== X-Gm-Message-State: AOJu0YyFeSEnypdRV5y2vi7z/4XNPhiJLtwAZjnKCVO0PjZD1M+KS4DI VdH/xhGgyPMObUqoOXBgL4/FQA== X-Received: by 2002:a17:90b:4a8f:b0:27d:b885:17f2 with SMTP id lp15-20020a17090b4a8f00b0027db88517f2mr12749747pjb.30.1698259035682; Wed, 25 Oct 2023 11:37:15 -0700 (PDT) Received: from localhost.localdomain ([49.216.222.119]) by smtp.gmail.com with ESMTPSA id g3-20020a17090adb0300b00278f1512dd9sm212367pjv.32.2023.10.25.11.37.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Oct 2023 11:37:15 -0700 (PDT) From: Jerry Shih To: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, herbert@gondor.apana.org.au, davem@davemloft.net Cc: andy.chiu@sifive.com, greentime.hu@sifive.com, conor.dooley@microchip.com, guoren@kernel.org, bjorn@rivosinc.com, heiko@sntech.de, ebiggers@kernel.org, ardb@kernel.org, phoebe.chen@sifive.com, hongrong.hsu@sifive.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org Subject: [PATCH 05/12] crypto: scatterwalk - Add scatterwalk_next() to get the next scatterlist in scatter_walk Date: Thu, 26 Oct 2023 02:36:37 +0800 Message-Id: <20231025183644.8735-6-jerry.shih@sifive.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20231025183644.8735-1-jerry.shih@sifive.com> References: <20231025183644.8735-1-jerry.shih@sifive.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Wed, 25 Oct 2023 11:37:54 -0700 (PDT) In some situations, we might split the `skcipher_request` into several segments. When we try to move to next segment, we might use `scatterwalk_ffwd()` to get the corresponding `scatterlist` iterating from the head of `scatterlist`. This helper function could just gather the information in `skcipher_walk` and move to next `scatterlist` directly. Signed-off-by: Jerry Shih --- include/crypto/scatterwalk.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/crypto/scatterwalk.h b/include/crypto/scatterwalk.h index 32fc4473175b..b1a90afe695d 100644 --- a/include/crypto/scatterwalk.h +++ b/include/crypto/scatterwalk.h @@ -98,7 +98,12 @@ void scatterwalk_map_and_copy(void *buf, struct scatterlist *sg, unsigned int start, unsigned int nbytes, int out); struct scatterlist *scatterwalk_ffwd(struct scatterlist dst[2], - struct scatterlist *src, - unsigned int len); + struct scatterlist *src, unsigned int len); + +static inline struct scatterlist *scatterwalk_next(struct scatterlist dst[2], + struct scatter_walk *src) +{ + return scatterwalk_ffwd(dst, src->sg, src->offset - src->sg->offset); +} #endif /* _CRYPTO_SCATTERWALK_H */ -- 2.28.0