All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Clean up crypto documentation
@ 2019-06-25 23:43 Hook, Gary
  2019-06-25 23:43 ` [PATCH v2 1/2] crypto: doc - Add parameter documentation Hook, Gary
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Hook, Gary @ 2019-06-25 23:43 UTC (permalink / raw)
  To: herbert, corbet, linux-doc, linux-kernel, linux-crypto, davem

Tidy up the crypto documentation by filling in some variable
descriptions, make some grammatical corrections, and enhance
formatting.

Changes since v1:
 - Remove patch with superfluous change to index (patch 2)
 - Remove unnecessary markup on function names in patch 3
 - Un-add extraneous white space (patch 3)

---

Gary R Hook (2):
      crypto: doc - Add parameter documentation
      crypto: doc - Fix formatting of new crypto engine content


 Documentation/crypto/api-skcipher.rst  |    2 -
 Documentation/crypto/crypto_engine.rst |  111 +++++++++++++++++++++-----------
 include/linux/crypto.h                 |   11 +++
 3 files changed, 85 insertions(+), 39 deletions(-)

--

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/2] crypto: doc - Add parameter documentation
  2019-06-25 23:43 [PATCH v2 0/2] Clean up crypto documentation Hook, Gary
@ 2019-06-25 23:43 ` Hook, Gary
  2019-06-25 23:43 ` [PATCH v2 2/2] crypto: doc - Fix formatting of new crypto engine content Hook, Gary
  2019-07-03 14:28 ` [PATCH v2 0/2] Clean up crypto documentation Herbert Xu
  2 siblings, 0 replies; 6+ messages in thread
From: Hook, Gary @ 2019-06-25 23:43 UTC (permalink / raw)
  To: herbert, corbet, linux-doc, linux-kernel, linux-crypto, davem

Fill in missing parameter descriptions for the compression algorithm,
then pick them up to document for the compression_alg structure.

Signed-off-by: Gary R Hook <gary.hook@amd.com>
---
 Documentation/crypto/api-skcipher.rst |    2 +-
 include/linux/crypto.h                |   11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/Documentation/crypto/api-skcipher.rst b/Documentation/crypto/api-skcipher.rst
index 4eec4a93f7e3..20ba08dddf2e 100644
--- a/Documentation/crypto/api-skcipher.rst
+++ b/Documentation/crypto/api-skcipher.rst
@@ -5,7 +5,7 @@ Block Cipher Algorithm Definitions
    :doc: Block Cipher Algorithm Definitions
 
 .. kernel-doc:: include/linux/crypto.h
-   :functions: crypto_alg ablkcipher_alg blkcipher_alg cipher_alg
+   :functions: crypto_alg ablkcipher_alg blkcipher_alg cipher_alg compress_alg
 
 Symmetric Key Cipher API
 ------------------------
diff --git a/include/linux/crypto.h b/include/linux/crypto.h
index 311237b1dab0..4b4e2ffbee74 100644
--- a/include/linux/crypto.h
+++ b/include/linux/crypto.h
@@ -327,6 +327,17 @@ struct cipher_alg {
 	void (*cia_decrypt)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
 };
 
+/**
+ * struct compress_alg - compression/decompression algorithm
+ * @coa_compress: Compress a buffer of specified length, storing the resulting
+ *		  data in the specified buffer. Return the length of the
+ *		  compressed data in dlen.
+ * @coa_decompress: Decompress the source buffer, storing the uncompressed
+ *		    data in the specified buffer. The length of the data is
+ *		    returned in dlen.
+ *
+ * All fields are mandatory.
+ */
 struct compress_alg {
 	int (*coa_compress)(struct crypto_tfm *tfm, const u8 *src,
 			    unsigned int slen, u8 *dst, unsigned int *dlen);


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] crypto: doc - Fix formatting of new crypto engine content
  2019-06-25 23:43 [PATCH v2 0/2] Clean up crypto documentation Hook, Gary
  2019-06-25 23:43 ` [PATCH v2 1/2] crypto: doc - Add parameter documentation Hook, Gary
@ 2019-06-25 23:43 ` Hook, Gary
  2019-06-26  0:13   ` Joe Perches
  2019-07-03 14:28 ` [PATCH v2 0/2] Clean up crypto documentation Herbert Xu
  2 siblings, 1 reply; 6+ messages in thread
From: Hook, Gary @ 2019-06-25 23:43 UTC (permalink / raw)
  To: herbert, corbet, linux-doc, linux-kernel, linux-crypto, davem

Tidy up the formatting/grammar in crypto_engine.rst. Use bulleted lists
where appropriate.

Signed-off-by: Gary R Hook <gary.hook@amd.com>
---
 Documentation/crypto/crypto_engine.rst |  111 +++++++++++++++++++++-----------
 1 file changed, 73 insertions(+), 38 deletions(-)

diff --git a/Documentation/crypto/crypto_engine.rst b/Documentation/crypto/crypto_engine.rst
index 1d56221dfe35..236c674d6897 100644
--- a/Documentation/crypto/crypto_engine.rst
+++ b/Documentation/crypto/crypto_engine.rst
@@ -1,50 +1,85 @@
-=============
-CRYPTO ENGINE
+.. SPDX-License-Identifier: GPL-2.0
+Crypto Engine
 =============
 
 Overview
 --------
-The crypto engine API (CE), is a crypto queue manager.
+The crypto engine (CE) API is a crypto queue manager.
 
 Requirement
 -----------
-You have to put at start of your tfm_ctx the struct crypto_engine_ctx::
+You must put, at the start of your transform context your_tfm_ctx, the structure
+crypto_engine:
+
+::
 
-  struct your_tfm_ctx {
-        struct crypto_engine_ctx enginectx;
-        ...
-  };
+	struct your_tfm_ctx {
+		struct crypto_engine engine;
+		...
+	};
 
-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.
+The crypto engine only manages asynchronous requests in the form of
+crypto_async_request. It cannot know the underlying request type and thus only
+has access to the transform structure. It is not possible to access the context
+using container_of. In addition, the engine knows nothing about your
+structure "``struct your_tfm_ctx``". The engine assumes (requires) the placement
+of the known member ``struct crypto_engine`` at the beginning.
 
 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
+You are required to obtain a struct crypto_engine via ``crypto_engine_alloc_init()``.
+Start it via ``crypto_engine_start()``. When finished with your work, shut down the
+engine using ``crypto_engine_stop()`` and destroy the engine with
+``crypto_engine_exit()``.
+
+Before transferring any request, you have to fill the context enginectx by
+providing functions for the following:
+
+* ``prepare_crypt_hardware``: Called once before any prepare functions are
+  called.
+
+* ``unprepare_crypt_hardware``: Called once after all unprepare functions have
+  been called.
+
+* ``prepare_cipher_request``/``prepare_hash_request``: Called before each
+  corresponding request is performed. If some processing or other preparatory
+  work is required, do it here.
+
+* ``unprepare_cipher_request``/``unprepare_hash_request``: Called after each
+  request is handled. Clean up / undo what was done in the prepare function.
+
+* ``cipher_one_request``/``hash_one_request``: Handle the current request by
+  performing the operation.
+
+Note that these functions access the crypto_async_request structure
+associated with the received request. You are able to retrieve the original
+request by using:
+
+::
+
+	container_of(areq, struct yourrequesttype_request, base);
+
+When your driver receives a crypto_request, you must to transfer it to
+the crypto engine 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 functions is needed:
+
+* crypto_finalize_ablkcipher_request()
+
+* crypto_finalize_aead_request()
+
+* crypto_finalize_akcipher_request()
+
+* crypto_finalize_hash_request()
+
+* crypto_finalize_skcipher_request()


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/2] crypto: doc - Fix formatting of new crypto engine content
  2019-06-25 23:43 ` [PATCH v2 2/2] crypto: doc - Fix formatting of new crypto engine content Hook, Gary
@ 2019-06-26  0:13   ` Joe Perches
  2019-06-26 16:50     ` Gary R Hook
  0 siblings, 1 reply; 6+ messages in thread
From: Joe Perches @ 2019-06-26  0:13 UTC (permalink / raw)
  To: Hook, Gary, herbert, corbet, linux-doc, linux-kernel,
	linux-crypto, davem

On Tue, 2019-06-25 at 23:43 +0000, Hook, Gary wrote:
> Tidy up the formatting/grammar in crypto_engine.rst. Use bulleted lists
> where appropriate.

Hi again Gary.

> diff --git a/Documentation/crypto/crypto_engine.rst b/Documentation/crypto/crypto_engine.rst
[]
> +Before transferring any request, you have to fill the context enginectx by
> +providing functions for the following:
> +
> +* ``prepare_crypt_hardware``: Called once before any prepare functions are
> +  called.
> +
> +* ``unprepare_crypt_hardware``: Called once after all unprepare functions have
> +  been called.
> +
> +* ``prepare_cipher_request``/``prepare_hash_request``: Called before each
> +  corresponding request is performed. If some processing or other preparatory
> +  work is required, do it here.
> +
> +* ``unprepare_cipher_request``/``unprepare_hash_request``: Called after each
> +  request is handled. Clean up / undo what was done in the prepare function.
> +
> +* ``cipher_one_request``/``hash_one_request``: Handle the current request by
> +  performing the operation.

I again suggest not using ``<func>`` but instead use <func>()
and remove unnecessary blank lines.

i.e.:

* prepare_crypt_hardware(): Called once before any prepare functions are
  called.
* unprepare_crypt_hardware():  Called once after all unprepare functions
  have been called.
* prepare_cipher_request()/prepare_hash_request(): Called before each
  corresponding request is performed. If some processing or other preparatory
  work is required, do it here.
* unprepare_cipher_request()/unprepare_hash_request(): Called after each
  request is handled. Clean up / undo what was done in the prepare function.
* cipher_one_request()/hash_one_request(): Handle the current request by
  performing the operation.

[]
> +When your driver receives a crypto_request, you must to transfer it to
> +the crypto engine via one of:
> +
> +* crypto_transfer_ablkcipher_request_to_engine()

And removing the unnecessary blank lines below

> +
> +* 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 functions is needed:
> +
> +* crypto_finalize_ablkcipher_request()
> +
> +* crypto_finalize_aead_request()
> +
> +* crypto_finalize_akcipher_request()
> +
> +* crypto_finalize_hash_request()
> +
> +* crypto_finalize_skcipher_request()



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/2] crypto: doc - Fix formatting of new crypto engine content
  2019-06-26  0:13   ` Joe Perches
@ 2019-06-26 16:50     ` Gary R Hook
  0 siblings, 0 replies; 6+ messages in thread
From: Gary R Hook @ 2019-06-26 16:50 UTC (permalink / raw)
  To: Joe Perches, Hook, Gary, herbert, corbet, linux-doc,
	linux-kernel, linux-crypto, davem

On 6/25/19 7:13 PM, Joe Perches wrote:
> On Tue, 2019-06-25 at 23:43 +0000, Hook, Gary wrote:
>> Tidy up the formatting/grammar in crypto_engine.rst. Use bulleted lists
>> where appropriate.
> 
> Hi again Gary.

Howdy!

> 
>> diff --git a/Documentation/crypto/crypto_engine.rst b/Documentation/crypto/crypto_engine.rst
> []
>> +Before transferring any request, you have to fill the context enginectx by
>> +providing functions for the following:
>> +
>> +* ``prepare_crypt_hardware``: Called once before any prepare functions are
>> +  called.
>> +
>> +* ``unprepare_crypt_hardware``: Called once after all unprepare functions have
>> +  been called.
>> +
>> +* ``prepare_cipher_request``/``prepare_hash_request``: Called before each
>> +  corresponding request is performed. If some processing or other preparatory
>> +  work is required, do it here.
>> +
>> +* ``unprepare_cipher_request``/``unprepare_hash_request``: Called after each
>> +  request is handled. Clean up / undo what was done in the prepare function.
>> +
>> +* ``cipher_one_request``/``hash_one_request``: Handle the current request by
>> +  performing the operation.
> 
> I again suggest not using ``<func>`` but instead use <func>()
> and remove unnecessary blank lines.

with all due respect, those aren't functions, they're function pointers 
(as structure members). Therefore, if anything, they should be notated 
as (*func)(). But I tried that (with the new patches), and they weren't 
detected and emboldened (that's not a word, I know) in the html.

So I left them as-is.

I don't pretend to be a guru on this markup, but if there's a way to 
make symbol names fixed-width and bold, I'll gladly do it. But I 
disagree on turning these into functions, because that's not what they are.


> i.e.:
> 
> * prepare_crypt_hardware(): Called once before any prepare functions are
>    called.
> * unprepare_crypt_hardware():  Called once after all unprepare functions
>    have been called.
> * prepare_cipher_request()/prepare_hash_request(): Called before each
>    corresponding request is performed. If some processing or other preparatory
>    work is required, do it here.
> * unprepare_cipher_request()/unprepare_hash_request(): Called after each
>    request is handled. Clean up / undo what was done in the prepare function.
> * cipher_one_request()/hash_one_request(): Handle the current request by
>    performing the operation.
> 
> []
>> +When your driver receives a crypto_request, you must to transfer it to
>> +the crypto engine via one of:
>> +
>> +* crypto_transfer_ablkcipher_request_to_engine()
> 
> And removing the unnecessary blank lines below
> 
>> +
>> +* 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 functions is needed:
>> +
>> +* crypto_finalize_ablkcipher_request()
>> +
>> +* crypto_finalize_aead_request()
>> +
>> +* crypto_finalize_akcipher_request()
>> +
>> +* crypto_finalize_hash_request()
>> +
>> +* crypto_finalize_skcipher_request()
> 
> 

The lines between the bulleted items will go, yes. Not the ones around 
the leading text of each list (which are necessary to delineate the lists).

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/2] Clean up crypto documentation
  2019-06-25 23:43 [PATCH v2 0/2] Clean up crypto documentation Hook, Gary
  2019-06-25 23:43 ` [PATCH v2 1/2] crypto: doc - Add parameter documentation Hook, Gary
  2019-06-25 23:43 ` [PATCH v2 2/2] crypto: doc - Fix formatting of new crypto engine content Hook, Gary
@ 2019-07-03 14:28 ` Herbert Xu
  2 siblings, 0 replies; 6+ messages in thread
From: Herbert Xu @ 2019-07-03 14:28 UTC (permalink / raw)
  To: Hook, Gary; +Cc: corbet, linux-doc, linux-kernel, linux-crypto, davem

On Tue, Jun 25, 2019 at 11:43:36PM +0000, Hook, Gary wrote:
> Tidy up the crypto documentation by filling in some variable
> descriptions, make some grammatical corrections, and enhance
> formatting.
> 
> Changes since v1:
>  - Remove patch with superfluous change to index (patch 2)
>  - Remove unnecessary markup on function names in patch 3
>  - Un-add extraneous white space (patch 3)
> 
> ---
> 
> Gary R Hook (2):
>       crypto: doc - Add parameter documentation
>       crypto: doc - Fix formatting of new crypto engine content
> 
> 
>  Documentation/crypto/api-skcipher.rst  |    2 -
>  Documentation/crypto/crypto_engine.rst |  111 +++++++++++++++++++++-----------
>  include/linux/crypto.h                 |   11 +++
>  3 files changed, 85 insertions(+), 39 deletions(-)

All applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-07-03 14:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-25 23:43 [PATCH v2 0/2] Clean up crypto documentation Hook, Gary
2019-06-25 23:43 ` [PATCH v2 1/2] crypto: doc - Add parameter documentation Hook, Gary
2019-06-25 23:43 ` [PATCH v2 2/2] crypto: doc - Fix formatting of new crypto engine content Hook, Gary
2019-06-26  0:13   ` Joe Perches
2019-06-26 16:50     ` Gary R Hook
2019-07-03 14:28 ` [PATCH v2 0/2] Clean up crypto documentation Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.