crypto: chcr - Increase priority of AEAD algos.
authorHarsh Jain <harsh@chelsio.com>
Mon, 10 Apr 2017 12:53:58 +0000 (18:23 +0530)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 21 Apr 2017 12:30:31 +0000 (20:30 +0800)
templates(gcm,ccm etc) inherit priority value of driver to
calculate its priority. In some cases template priority becomes
 more than driver priority for same algo.
Without this patch we will not be able to use driver authenc algos. It will
be good if it pushed in stable kernel.

Signed-off-by: Harsh Jain <harsh@chelsio.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/chelsio/chcr_algo.c
drivers/crypto/chelsio/chcr_crypto.h

index 41bc7f4f58cd3700ae251d6046b3cf8c69ffca63..7d595912909cb32b04e881570744e2aa4d53dfc0 100644 (file)
@@ -2673,6 +2673,7 @@ static struct chcr_alg_template driver_algs[] = {
                                .cra_name = "gcm(aes)",
                                .cra_driver_name = "gcm-aes-chcr",
                                .cra_blocksize  = 1,
+                               .cra_priority = CHCR_AEAD_PRIORITY,
                                .cra_ctxsize =  sizeof(struct chcr_context) +
                                                sizeof(struct chcr_aead_ctx) +
                                                sizeof(struct chcr_gcm_ctx),
@@ -2691,6 +2692,7 @@ static struct chcr_alg_template driver_algs[] = {
                                .cra_name = "rfc4106(gcm(aes))",
                                .cra_driver_name = "rfc4106-gcm-aes-chcr",
                                .cra_blocksize   = 1,
+                               .cra_priority = CHCR_AEAD_PRIORITY + 1,
                                .cra_ctxsize =  sizeof(struct chcr_context) +
                                                sizeof(struct chcr_aead_ctx) +
                                                sizeof(struct chcr_gcm_ctx),
@@ -2710,6 +2712,7 @@ static struct chcr_alg_template driver_algs[] = {
                                .cra_name = "ccm(aes)",
                                .cra_driver_name = "ccm-aes-chcr",
                                .cra_blocksize   = 1,
+                               .cra_priority = CHCR_AEAD_PRIORITY,
                                .cra_ctxsize =  sizeof(struct chcr_context) +
                                                sizeof(struct chcr_aead_ctx),
 
@@ -2728,6 +2731,7 @@ static struct chcr_alg_template driver_algs[] = {
                                .cra_name = "rfc4309(ccm(aes))",
                                .cra_driver_name = "rfc4309-ccm-aes-chcr",
                                .cra_blocksize   = 1,
+                               .cra_priority = CHCR_AEAD_PRIORITY + 1,
                                .cra_ctxsize =  sizeof(struct chcr_context) +
                                                sizeof(struct chcr_aead_ctx),
 
@@ -2747,6 +2751,7 @@ static struct chcr_alg_template driver_algs[] = {
                                .cra_driver_name =
                                        "authenc-hmac-sha1-cbc-aes-chcr",
                                .cra_blocksize   = AES_BLOCK_SIZE,
+                               .cra_priority = CHCR_AEAD_PRIORITY,
                                .cra_ctxsize =  sizeof(struct chcr_context) +
                                                sizeof(struct chcr_aead_ctx) +
                                                sizeof(struct chcr_authenc_ctx),
@@ -2768,6 +2773,7 @@ static struct chcr_alg_template driver_algs[] = {
                                .cra_driver_name =
                                        "authenc-hmac-sha256-cbc-aes-chcr",
                                .cra_blocksize   = AES_BLOCK_SIZE,
+                               .cra_priority = CHCR_AEAD_PRIORITY,
                                .cra_ctxsize =  sizeof(struct chcr_context) +
                                                sizeof(struct chcr_aead_ctx) +
                                                sizeof(struct chcr_authenc_ctx),
@@ -2788,6 +2794,7 @@ static struct chcr_alg_template driver_algs[] = {
                                .cra_driver_name =
                                        "authenc-hmac-sha224-cbc-aes-chcr",
                                .cra_blocksize   = AES_BLOCK_SIZE,
+                               .cra_priority = CHCR_AEAD_PRIORITY,
                                .cra_ctxsize =  sizeof(struct chcr_context) +
                                                sizeof(struct chcr_aead_ctx) +
                                                sizeof(struct chcr_authenc_ctx),
@@ -2807,6 +2814,7 @@ static struct chcr_alg_template driver_algs[] = {
                                .cra_driver_name =
                                        "authenc-hmac-sha384-cbc-aes-chcr",
                                .cra_blocksize   = AES_BLOCK_SIZE,
+                               .cra_priority = CHCR_AEAD_PRIORITY,
                                .cra_ctxsize =  sizeof(struct chcr_context) +
                                                sizeof(struct chcr_aead_ctx) +
                                                sizeof(struct chcr_authenc_ctx),
@@ -2827,6 +2835,7 @@ static struct chcr_alg_template driver_algs[] = {
                                .cra_driver_name =
                                        "authenc-hmac-sha512-cbc-aes-chcr",
                                .cra_blocksize   = AES_BLOCK_SIZE,
+                               .cra_priority = CHCR_AEAD_PRIORITY,
                                .cra_ctxsize =  sizeof(struct chcr_context) +
                                                sizeof(struct chcr_aead_ctx) +
                                                sizeof(struct chcr_authenc_ctx),
@@ -2847,6 +2856,7 @@ static struct chcr_alg_template driver_algs[] = {
                                .cra_driver_name =
                                        "authenc-digest_null-cbc-aes-chcr",
                                .cra_blocksize   = AES_BLOCK_SIZE,
+                               .cra_priority = CHCR_AEAD_PRIORITY,
                                .cra_ctxsize =  sizeof(struct chcr_context) +
                                                sizeof(struct chcr_aead_ctx) +
                                                sizeof(struct chcr_authenc_ctx),
@@ -2915,8 +2925,6 @@ static int chcr_register_alg(void)
                        name = driver_algs[i].alg.crypto.cra_driver_name;
                        break;
                case CRYPTO_ALG_TYPE_AEAD:
-                       driver_algs[i].alg.aead.base.cra_priority =
-                               CHCR_CRA_PRIORITY;
                        driver_algs[i].alg.aead.base.cra_flags =
                                CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC;
                        driver_algs[i].alg.aead.encrypt = chcr_aead_encrypt;
index 81cfd0ba132ee0a9351075dba0091c4d9c35b373..4469feae84a213e5c83ba276c2a97b9f7c87aa52 100644 (file)
@@ -48,8 +48,8 @@
  * giving the processed data
  */
 
-#define CHCR_CRA_PRIORITY 3000
-
+#define CHCR_CRA_PRIORITY 500
+#define CHCR_AEAD_PRIORITY 6000
 #define CHCR_AES_MAX_KEY_LEN  (2 * (AES_MAX_KEY_SIZE)) /* consider xts */
 #define CHCR_MAX_CRYPTO_IV_LEN 16 /* AES IV len */