From patchwork Mon Jan 16 20:14:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Safonov X-Patchwork-Id: 44307 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1382708wrn; Mon, 16 Jan 2023 12:18:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXsC9l/HaxJN9un3W7jWdVYKa8TTcJtKIrLg31hV5BnJBFk9b2NAQsv+yjH2SSpANcyD/BND X-Received: by 2002:a17:90a:ba09:b0:229:306b:6111 with SMTP id s9-20020a17090aba0900b00229306b6111mr509754pjr.20.1673900314982; Mon, 16 Jan 2023 12:18:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673900314; cv=none; d=google.com; s=arc-20160816; b=RwlFeknpUiBmBggSijWsKoQP+rveN1AF8EUhOqmYQ2BcWnxtJ29k+MSmdyyRlz4FW6 ytrLcPkfnR7kXif10K810FaGLEcfOKsYzn1bdm/a8VQTspq/lFLmIUO693XxQoeLQEAs mLUq88yz770LbQTkY6oSVFX8/cz+5VVHIwgf1CGQ3PfpfPvtVMlJNIOqpoxTENDOILzI XfQvcZVoJVKNOaSRsbZ3YKzv2wdAzO8XPm+Abg2Oz3cZ3n617W57crD/5uXSxT1TlpKi aBAXi16qeY//hMPM6OO0r/afk9bXt+gDMJeqmRZSw8aWXG4XKcurFaY4CLoAQQR+FHJ2 w04g== 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=hQCTMYgJLvIOJNpT7JMOnye/Fo2B1NyzJSdbVXfFssabcyHfEOsSszXnO8WHwXdQTm JH70Nt1PWc3CKtQtMB303kus+MsJvnbYkU8CLFKzxh2yUPvXvxXbBH/KxGJHuyOHSbIp n0vAIXf+2Sq18zw8e9NLDEkoKH8a61oGrvfIcxIqMmwBPyzQSqYkzrjvaDtQY+T87QPY 7AdZgnnM/q/+WnD4wXC7Y4dSu7m63MtGQtbQ/Ij3nZ0pGwSa0KyNs06og2Wmzx3CC8/t Jw57c2KqWKAvAq/8VO6VTM2eNYQrzj6oQWf0chgmf+7wto3meQYOzcW/oEkKZeCmoAnh uGDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=XmCdZzRt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=arista.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mw12-20020a17090b4d0c00b002270c47059asi26209717pjb.114.2023.01.16.12.18.22; Mon, 16 Jan 2023 12:18:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=XmCdZzRt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S232403AbjAPUPg (ORCPT + 99 others); Mon, 16 Jan 2023 15:15:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229934AbjAPUPO (ORCPT ); Mon, 16 Jan 2023 15:15:14 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 382FA244AC for ; Mon, 16 Jan 2023 12:15:13 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id j34-20020a05600c1c2200b003da1b054057so8670894wms.5 for ; Mon, 16 Jan 2023 12:15:13 -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=XmCdZzRtTuZuHhp81pkE69P4loy4VR6MnN9p5Ug0b9VeBBJyFAJNXMMCCPXI2Xww4+ +WmiN3JAbNz9M0cQ2HbFFj86PlJHgnfX3V6lXt1sgEDdZNmnFPeDjSwKbJNvBY++u8WY tdBzDidtFDPRiHUykbwhSWvFSRYwmt5pon5+6DRZWcD526dyXxLcUW239Ttv5O67N6Fc cLdz5fdlYzw74C1vGu/ANNxqRb1YmE4B2jUnANSP5aRhHLum8XP0XS+AsugX2ORfUlg1 KfwnBp6EI/3oYPR0eLQU2Nndym4TVpl856OKzZww7FcENqKPQxmU/O1C2fKPcezVGXGS EACQ== 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=qzgxGKejgdIuVb7D+AJmAGMZK7AnygeDJZ4HEkxsHV5unqMOBa1NJak1SZguCdZK7G Fd+DGDnN5zPkr9U3Mu64zrfbNjbg+M6L9pSCF5iCZzmmOKacKacgR96PT7okcQo0wul6 15JkmTlZLKKjaXaCQ4OOE4hZHQk2TFzunA82y7whQyt4582k1fTuX/3SuZ2dFusZtIXZ FbRq7Lqpiqpgg3Lq5q87Tu9hdpSUFN4pSRtPLsG8fLZZ28m+4F4UvDPdlz06G7CqFaH8 g5L4NHFCxPb7ucCTbG97mUpxixurBf3oyBiLQjluswXDmBzsE+QBGSqvyQiAXn9j7h5+ grnA== X-Gm-Message-State: AFqh2kqjEGHTqVenrPQzT4QzH/Bj5dLARW6kZYJYFIlIdk5uzxxfvvzP kuQSE25PDtejIYYnq6qiFZYcfI3Uj0pVPv1v X-Received: by 2002:a05:600c:b8d:b0:3cf:7c8b:a7c7 with SMTP id fl13-20020a05600c0b8d00b003cf7c8ba7c7mr622696wmb.39.1673900111548; Mon, 16 Jan 2023 12:15:11 -0800 (PST) Received: from Mindolluin.ire.aristanetworks.com ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id bh13-20020a05600c3d0d00b003d358beab9dsm34549829wmb.47.2023.01.16.12.15.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Jan 2023 12:15:11 -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 v3 4/4] crypto/Documentation: Add crypto_pool kernel API Date: Mon, 16 Jan 2023 20:14:58 +0000 Message-Id: <20230116201458.104260-5-dima@arista.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230116201458.104260-1-dima@arista.com> References: <20230116201458.104260-1-dima@arista.com> MIME-Version: 1.0 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=unavailable 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755211696432771988?= X-GMAIL-MSGID: =?utf-8?q?1755211696432771988?= 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