From patchwork Fri Jan 26 19:15:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 10186891 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B6978601D5 for ; Fri, 26 Jan 2018 19:20:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7D9C1FF13 for ; Fri, 26 Jan 2018 19:20:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9BF8228AF0; Fri, 26 Jan 2018 19:20:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 36E2F1FF13 for ; Fri, 26 Jan 2018 19:20:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=LTwn+42bETc3zbrJvsA7HGqD7MdxXjX60UJU88tf7Kg=; b=SKpVtF+rdbVyPS3HnNcrkYA4LY alDnsFDUjJGnsYt5YknsZIIaqIeV9Garnz/Dp9Npf6E+B44MWHDaZpjxVwtAeWLE8w21v3h6GTyMA nC1QqJDJlyg2VLUhD2Eu5DJGXejLtshuSblF2HBifSgFnUqtuiCKPs/AGW2rW6AVkUu3IZMeA9VmE 1DZP2sa43c+IhBQHKOSkhE1+3wCY2XoVo78E+mDlaJqOrQ3w3YbPEhnxzNAT96qppaZz7En36JRh0 vMcFm/duZwyDPBKxr87YdYfq5zbF16AmBoBF5kZZuoIInGmYIgOFhUpnfNuyrQTE5DabvUkufdEFk 0HGTsCWA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ef9YJ-0005rA-LQ; Fri, 26 Jan 2018 19:20:43 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ef9Vw-0002uM-9d for linux-arm-kernel@lists.infradead.org; Fri, 26 Jan 2018 19:18:17 +0000 Received: by mail-wm0-x241.google.com with SMTP id f71so3275794wmf.0 for ; Fri, 26 Jan 2018 11:18:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZnAgI50T1OQp461MDiTH2WDx81c5Uz3+RL5E47VXitk=; b=fnMdNNMULQ34daCkEddo9a6WrZ9sSlH7QT2sGCFRE13bhM/3dYE6D0wWMEnGG1xkwj f5m+icjwRlFUrQ1Z7sCiR5i88On2jY9lDbLUI9Jo9f/tmZzEb5ITHr1m0B/nUoTSgMQN MpGVJT692Tw24Ow2OuZEm/WgvMAmQgOGadA+ESRKoWClxQBWXVqk1TcCitxVGU/AcWRG 8tOz/bpTdJje5FSlDShvNoKWXkegXpua6YIx824wtd2lyNO8DJqNw+M7zrJlVzHS9ezA H3/uW9NLV547Rlk92TOdkBjN0aSONxsxfEf35akCgkX1hvFlIWmZuXPsuo1MPLve2G2x iQkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZnAgI50T1OQp461MDiTH2WDx81c5Uz3+RL5E47VXitk=; b=QzyHJ4L8jgERd9pP4kSJrFjPVg/ZLHJDiWNZepVyGdWWV4/VewPTeltJLsaz6S92Kp 2a1KA+dPUkIN7DZL6z0hAllyiG5WIqP8MSN4qK44WuG9X6jk+kQfZS+gU1KHTGx7wcqy HU4kcQ5a/xkLjGltx34xCpubV8uFMYD9j7J3QqIdfiEDWNlvIBpHkOFhonTgIEIF487L esdUhrmyRaWo3WX4EWjU1vSFwyGzeYIFPKEaq+0ZYewsfkAGrHJ3Y/uzTR+KJUPDcyyE +4mksZhkQtoV5DvKLPN4A5Grn5arBWVuCVklAKysu9Z0Z8rDuxoJ3V+xFGRBkCq8FTM/ 0jnA== X-Gm-Message-State: AKwxytfSqX/Reabx4evTerU81LIDuKdeav9H/HjOHBQDUsiKUXD3ucdK aPWwXySHwUX1MCuXL0dAVpo= X-Google-Smtp-Source: AH8x224BQ0US3aDeoSnfrcz7gUwR98Z0qmpw+0xBjxz9b1Zz6YqoXgjGlD3q7TzAuEmx50aiHlqwvw== X-Received: by 10.28.86.132 with SMTP id k126mr10609545wmb.98.1516994282888; Fri, 26 Jan 2018 11:18:02 -0800 (PST) Received: from Red.local (LFbn-MAR-1-494-174.w2-15.abo.wanadoo.fr. [2.15.82.174]) by smtp.googlemail.com with ESMTPSA id k125sm7587510wmd.48.2018.01.26.11.18.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jan 2018 11:18:02 -0800 (PST) From: Corentin Labbe To: alexandre.torgue@st.com, arei.gonglei@huawei.com, corbet@lwn.net, davem@davemloft.net, herbert@gondor.apana.org.au, jasowang@redhat.com, mcoquelin.stm32@gmail.com, mst@redhat.com, fabien.dessenne@st.com Subject: [PATCH v2 1/6] Documentation: crypto: document crypto engine API Date: Fri, 26 Jan 2018 20:15:29 +0100 Message-Id: <20180126191534.17569-2-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180126191534.17569-1-clabbe.montjoie@gmail.com> References: <20180126191534.17569-1-clabbe.montjoie@gmail.com> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-sunxi@googlegroups.com, Corentin Labbe , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Corentin Labbe --- Documentation/crypto/crypto_engine.rst | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Documentation/crypto/crypto_engine.rst diff --git a/Documentation/crypto/crypto_engine.rst b/Documentation/crypto/crypto_engine.rst new file mode 100644 index 000000000000..8272ac92a14f --- /dev/null +++ b/Documentation/crypto/crypto_engine.rst @@ -0,0 +1,48 @@ +============= +CRYPTO ENGINE +============= + +Overview +-------- +The crypto engine API (CE), is a crypto queue manager. + +Requirement +----------- +You have to put at start of your tfm_ctx the struct crypto_engine_ctx +struct your_tfm_ctx { + struct crypto_engine_ctx enginectx; + ... +}; +Why: Since CE manage only crypto_async_request, it cannot know the underlying +request_type and so have access only on the TFM. +So using container_of for accessing __ctx is impossible. +Furthermore, the crypto engine cannot know the "struct your_tfm_ctx", +so it must assume that crypto_engine_ctx is at start of it. + +Order of operations +------------------- +You have to obtain a struct crypto_engine via crypto_engine_alloc_init(). +And start it via crypto_engine_start(). + +Before transferring any request, you have to fill the enginectx. +- prepare_request: (taking a function pointer) If you need to do some processing before doing the request +- unprepare_request: (taking a function pointer) Undoing what's done in prepare_request +- do_one_request: (taking a function pointer) Do encryption for current request + +Note: that those three functions get the crypto_async_request associated with the received request. +So your need to get the original request via container_of(areq, struct yourrequesttype_request, base); + +When your driver receive a crypto_request, you have to transfer it to +the cryptoengine via one of: +- crypto_transfer_ablkcipher_request_to_engine() +- crypto_transfer_aead_request_to_engine() +- crypto_transfer_akcipher_request_to_engine() +- crypto_transfer_hash_request_to_engine() +- crypto_transfer_skcipher_request_to_engine() + +At the end of the request process, a call to one of the following function is needed: +- crypto_finalize_ablkcipher_request +- crypto_finalize_aead_request +- crypto_finalize_akcipher_request +- crypto_finalize_hash_request +- crypto_finalize_skcipher_request