Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp35004rwb; Wed, 18 Jan 2023 13:42:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXseRpK5ZsnVM/nEuGT5Z0uLkUzMflMrM1uHCAa7UsPauUoKWzjQGRw3qZBVBwxI3wYZqcTB X-Received: by 2002:a05:6402:2405:b0:49d:1a59:176b with SMTP id t5-20020a056402240500b0049d1a59176bmr10329371eda.30.1674078176533; Wed, 18 Jan 2023 13:42:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674078176; cv=none; d=google.com; s=arc-20160816; b=cYVFHiOWLuYp2vS7qMC0n5oYveiEaWJO+WcQBClYI9BF5b6Dv+JEvJXkignu8ersw4 VsY2x/aEKIYaJ4xzGkpWbH57JXopfH2GZZrho+RQoeTfokq7lWhhm7/TSzEgYef8ekn6 i3co5zEFACoKXKXjh0Jk7YkLlWf9rHV341d7fNOIERtWAEDtng6+sPmUBAi86afWFGNG +uvji2XaC1lF0pshyMYu82k9URi4g9Om83y8sQe/cKVszvlVA4oCv4hxQTP2E8LcVPEp bCPwpXHq8k2nW9a2YMdqowUdK02mq1ZPYiJxbiSy6iugLrOop56leRB7gY+LQi8j9o4D nS1g== 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=FMLRObJikupEwzTrRnh2PGmgjZ9Cqtc3WwiwTSH8KzM=; b=LLni3/ItmHD5FOd7ERmAZPIuKvr5rUT7KAIo9xvFRQJOp+nE/kMeNRfkP9L7xSmnCq 1ffyi02ulS6VFqscoWQkDDML7SpU77CCk/6HrsHzGxGvDw3IxX2NWcL5zy1s8wjsj1Jz 4WJ42lMT+3x203ZP9Juhr/piHHU+GA7RI7N6e39hPTaFfSAYqw4kl5rq6qD+EErPYH3D 0csC4coOWu6UMxjqxhW/5Yo9CJskUHv0HJvBEcBm8cLGb7cllZPo4CYEMogCrOh2TSHF UzcO+HluO66PhjXKTnQp1LoqQwJnaFEUM6t6lfWXCL2yzIsNqt+xN8f/YggQEzVIp3tJ y3ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=eCtXeYsP; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=arista.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e9-20020a056402190900b0049e0d2dd9f4si15457163edz.497.2023.01.18.13.42.29; Wed, 18 Jan 2023 13:42:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=eCtXeYsP; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=arista.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231193AbjARVl6 (ORCPT + 99 others); Wed, 18 Jan 2023 16:41:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231203AbjARVlt (ORCPT ); Wed, 18 Jan 2023 16:41:49 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC74A62D10 for ; Wed, 18 Jan 2023 13:41:25 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id r9so10798wrw.4 for ; Wed, 18 Jan 2023 13:41:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=google; 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=FMLRObJikupEwzTrRnh2PGmgjZ9Cqtc3WwiwTSH8KzM=; b=eCtXeYsP+ADhvJqyR5obWxJN2h47MVmxSPM3WN/yFWVLL7Bofz6ALMqkQ5FmPFSW8x UWaka0KuTIy7rIQGm6zFjHry+P1eL6Sk8lHn9fP+GlFKwmKfj/Q6EGvopu1kINYq/tef zm8zNYOALlS2vhNm+EkXcXVPzdDc/TXwTPpHmjgDI6AlVHBF2UVGGn5IwZJjA1mkQrTd W7/8pHqfbBiiPSMO3n8KjIvPtsQCwLJhGfGrg9lAgqPV+bv5lqOuwfh93c0xePh+Wkpp 2YLAsoMIKNpdfYZLV7cFr9MhZ4e3JlmJFQlcJhphihQuV+4yzmbAlgwjxUanzoyThCaw x8Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=FMLRObJikupEwzTrRnh2PGmgjZ9Cqtc3WwiwTSH8KzM=; b=gRJTdHzzVhsVCvW02wG/Q0P/gaiSSjNRNV3lHaojoxKABt6diYTQ/rIffq8gseCinL zkzGKYjY3hC4w8MDqlGxNBJgqdRa++LhA/qgTlOEzoBCA/ppmif+I5Q1DGBo4JUQInAi UYmelOupxowxqEOfO42OhZ6GaJYhEzXGnXjr3n9DnzobMOT306TeUina3KtnewjA5fXw 0j/uR+lY5RV9E1SJfwMTNHFmVt8iv4fT1D56yTvzFQXWpQfU6D6LIy9qHzKz4tydDxzd IaRICfVDSSNiaTUyBlOczgDDXwyAxQnSJ5JYr/wLB/gSQ7Kl2Sc7b2mnS3q0a1+hXV/s oAzQ== X-Gm-Message-State: AFqh2kpVi3pyU0bdBH4/q2tHpcvpAV+lZFr1B53frlAA6TrvBB4lheZ7 wyg/Y5Ly07YgrlnFbh3DTDV5aQ== X-Received: by 2002:a5d:5b0e:0:b0:250:22e4:b89e with SMTP id bx14-20020a5d5b0e000000b0025022e4b89emr8426197wrb.65.1674078084270; Wed, 18 Jan 2023 13:41:24 -0800 (PST) Received: from Mindolluin.ire.aristanetworks.com ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id m5-20020a056000024500b00267bcb1bbe5sm33186349wrz.56.2023.01.18.13.41.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 13:41:23 -0800 (PST) From: Dmitry Safonov To: linux-kernel@vger.kernel.org, David Ahern , Eric Dumazet , Herbert Xu , Jakub Kicinski , "David S. Miller" Cc: Dmitry Safonov , Andy Lutomirski , Bob Gilligan , Dmitry Safonov <0x7f454c46@gmail.com>, Hideaki YOSHIFUJI , Leonard Crestez , Paolo Abeni , Salam Noureddine , netdev@vger.kernel.org, linux-crypto@vger.kernel.org Subject: [PATCH v4 4/4] crypto/Documentation: Add crypto_pool kernel API Date: Wed, 18 Jan 2023 21:41:11 +0000 Message-Id: <20230118214111.394416-5-dima@arista.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230118214111.394416-1-dima@arista.com> References: <20230118214111.394416-1-dima@arista.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Signed-off-by: Dmitry Safonov --- Documentation/crypto/crypto_pool.rst | 36 ++++++++++++++++++++++++++++ Documentation/crypto/index.rst | 1 + 2 files changed, 37 insertions(+) create mode 100644 Documentation/crypto/crypto_pool.rst diff --git a/Documentation/crypto/crypto_pool.rst b/Documentation/crypto/crypto_pool.rst new file mode 100644 index 000000000000..84abd1f2ee80 --- /dev/null +++ b/Documentation/crypto/crypto_pool.rst @@ -0,0 +1,36 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Per-CPU pool of crypto requests +=============================== + +Overview +-------- +The crypto pool API manages pre-allocated per-CPU pool of crypto requests, +providing ability to use crypto requests on fast paths, potentially in atomic +contexts. The allocation and initialization of the requests should be done +before their usage as it's slow-path and may sleep. + +Order of operations +------------------- +You are required to allocate a new pool prior using it and manage its lifetime. +You can allocate a per-CPU pool of ahash requests by crypto_pool_alloc_ahash(). +It will give you a pool id that you can use further on fast-path for hashing. +You can increase the reference counter for an allocated pool via +crypto_pool_get(). Decrease the reference counter by crypto_pool_release(). +When the refcounter hits zero, the pool is scheduled for destruction and you +can't use the corresponding crypto pool id anymore. +Note that crypto_pool_get() and crypto_pool_release() must be called +only for an already existing pool and can be called in atomic contexts. + +crypto_pool_start() disables bh and returns you back ``struct crypto_pool *``, +which is a generic type for different crypto requests and has ``scratch`` area +that can be used as a temporary buffer for your operation. + +crypto_pool_end() enables bh back once you've done with your crypto +operation. + +.. kernel-doc:: include/crypto/pool.h + :identifiers: + +.. kernel-doc:: crypto/crypto_pool.c + :identifiers: diff --git a/Documentation/crypto/index.rst b/Documentation/crypto/index.rst index 21338fa92642..3eaf4e964e5b 100644 --- a/Documentation/crypto/index.rst +++ b/Documentation/crypto/index.rst @@ -25,6 +25,7 @@ for cryptographic use cases, as well as programming examples. devel-algos userspace-if crypto_engine + crypto_pool api api-samples descore-readme -- 2.39.0