Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp2837205rdh; Sun, 26 Nov 2023 23:09:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IFyH6veoCBXIQOlG/bnbXd0KNo0pVnXAjDMwZx11kRNWlKE4Jiefjnw9Kc5xHnUPljkZWl1 X-Received: by 2002:a17:90b:17c1:b0:27d:2dde:5979 with SMTP id me1-20020a17090b17c100b0027d2dde5979mr12028819pjb.5.1701068941481; Sun, 26 Nov 2023 23:09:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701068941; cv=none; d=google.com; s=arc-20160816; b=w91RjTaLO1hMW2YjHWtRgy8TTyNREZkCOXCM95TuGCiLrylzs8a/4WMk9/Y1nk+D+U zqhAugAA38tiFE6B9gF+7N/gfazEVECgmQ53aiUkabaN1PbP4fQq3lUZqwP7oXtN1j/a PZ9q0tw0ocGiuonHdP20Ro/RYPhnoOjiuMWb9ICJSSvc5Ra2RfHaxXq8InWpc4dAufT0 lQAV1cVUbTFySJ3HSW0O0fIdi3rSBdkRHIHoEj9um3Hu+ZmN5BStrfHYTAe17YW6Wltc u8lH+FcL2vEIyuAd7RI2wLrARbAPBCoXSO6B8iuRIhXUIKcJAVT+a69XzHStuv9Gt+CE h4Lg== 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=EdrkxR6/0cUzdeRoIO4nQ0kc+YBaYAptqDtNOny9eFo=; b=Jr8rLHQGYoZGpsAVWNOrJylqRMa7IvyVCOhmOsMeWzJWbDP7btVDw+hWxVwSbNmJhd O+XLLcmSJDKRbKIN5rvIKJk7X6TlcMS8jvYOhQeUCa9aUGlv/AaKryhqcH/CHWT5CACc j71784CW7bPSQe4r5GbiNGzLMnmhRR1KxwApkoAfSBSZNxtjJFN1u1454mExGxaRA2gv 7HZhPHOhZVSzxZ69Gth9bnckIElw3m6BTmj5Qih8kfuL5dE7X/ntA2YTuqugGbY9N4Yn j5rYGBmxEARKdUS38XeiSRfh6WipVc8iTqoMXwARtbDC/59Zw5N/pWkJtuFbB7rNwszi EjIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=kjzYockN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id d22-20020a17090ad3d600b00283a1ef6feasi9854814pjw.147.2023.11.26.23.09.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Nov 2023 23:09:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=kjzYockN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-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 morse.vger.email (Postfix) with ESMTP id A5CB3807E41C; Sun, 26 Nov 2023 23:08:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232505AbjK0HHk (ORCPT + 99 others); Mon, 27 Nov 2023 02:07:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232229AbjK0HH2 (ORCPT ); Mon, 27 Nov 2023 02:07:28 -0500 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6D8B181 for ; Sun, 26 Nov 2023 23:07:31 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1cfafe3d46bso16442325ad.0 for ; Sun, 26 Nov 2023 23:07:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1701068851; x=1701673651; 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=kjzYockN9LFJ6sx2k0sGTTv2ytJuV4elNRp7fBYMsUAQ9WMnE/5gs3P+8QSQ9lYcUu y0q54OvISdijCRal+GXbTQQM9k8P4lbgU7+Qi6cXrbec2Vy0BhNWcgObBZGenfaBM0pa WWfUkV5tBE3ALfJosouIAt6/wP/1T092eOP9/CmWzyHQUYfUK4BkAioZkNr2/Sly8FSm umWvG6sqhe0fLBciczQW2wL/PushexwwSJTU843BMvxw4DkiMzx+1G5AQJ7Ugi7Omh7L waH/IKc9Ewewq1bLR7U2nQWiX6+COnNYXo+fV/MpRKzFBgi9xpjCIy6jkqqN4dKvlNhK KIOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701068851; x=1701673651; 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=UgwRmO9MlVcS4Vv1SXXAhulinlnsmUk3n+VWxtw4f7GT54oE2wK/96dedB4KyY4AZC fqUoAl77RX2zMyno/3IqFvg3iw8dvYSUjKJ01NVzjlytV6WSJnQuS9m9VTubxyfSvF0K i3a/RsyHE6ju3GHPQ5y/42hMtADUTk1jdqj7rWrC9ImCw+KbqBVzRCgfRg85vOG4Bl+D RVVn2MRfMWge/YJIgIjVvxI4uhW4jBgwykHDOi4J0xv10Bhv6Mg8alV6ugRjqkTbDn2V hLW9Ec1yJw4ZMdpim4POqCEvQ+9Vuqx+vxiL/YJfab4iRgrRviVrSHTLJLNWgTa6tJbx AuOA== X-Gm-Message-State: AOJu0Yxqwjw4fyqmORe757pqaw6v5aNdr9/RL/FtKA5eoogCbs/HjtTy itDkLQebff+oojDlEubIyM9vsA== X-Received: by 2002:a17:902:820b:b0:1cf:cd4e:ca02 with SMTP id x11-20020a170902820b00b001cfcd4eca02mr2699019pln.24.1701068851234; Sun, 26 Nov 2023 23:07:31 -0800 (PST) Received: from localhost.localdomain ([101.10.45.230]) by smtp.gmail.com with ESMTPSA id jh15-20020a170903328f00b001cfcd3a764esm1340134plb.77.2023.11.26.23.07.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Nov 2023 23:07:31 -0800 (PST) From: Jerry Shih To: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, herbert@gondor.apana.org.au, davem@davemloft.net, conor.dooley@microchip.com, ebiggers@kernel.org, ardb@kernel.org Cc: heiko@sntech.de, 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 v2 06/13] crypto: scatterwalk - Add scatterwalk_next() to get the next scatterlist in scatter_walk Date: Mon, 27 Nov 2023 15:06:56 +0800 Message-Id: <20231127070703.1697-7-jerry.shih@sifive.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20231127070703.1697-1-jerry.shih@sifive.com> References: <20231127070703.1697-1-jerry.shih@sifive.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Sun, 26 Nov 2023 23:08:51 -0800 (PST) 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