cryptodev: use AES-GCM/CCM as AEAD algorithms
[dpdk.git] / drivers / crypto / openssl / rte_openssl_pmd_ops.c
index 875550c..3a58eea 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2016 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2016-2017 Intel Corporation. All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
  *   modification, are permitted provided that the following conditions
@@ -57,7 +57,8 @@ static const struct rte_cryptodev_capabilities openssl_pmd_capabilities[] = {
                                        .max = 16,
                                        .increment = 0
                                },
-                               .aad_size = { 0 }
+                               .aad_size = { 0 },
+                               .iv_size = { 0 }
                        }, }
                }, }
        },
@@ -78,7 +79,8 @@ static const struct rte_cryptodev_capabilities openssl_pmd_capabilities[] = {
                                        .max = 16,
                                        .increment = 0
                                },
-                               .aad_size = { 0 }
+                               .aad_size = { 0 },
+                               .iv_size = { 0 }
                        }, }
                }, }
        },
@@ -99,7 +101,8 @@ static const struct rte_cryptodev_capabilities openssl_pmd_capabilities[] = {
                                        .max = 20,
                                        .increment = 0
                                },
-                               .aad_size = { 0 }
+                               .aad_size = { 0 },
+                               .iv_size = { 0 }
                        }, }
                }, }
        },
@@ -120,7 +123,8 @@ static const struct rte_cryptodev_capabilities openssl_pmd_capabilities[] = {
                                        .max = 20,
                                        .increment = 0
                                },
-                               .aad_size = { 0 }
+                               .aad_size = { 0 },
+                               .iv_size = { 0 }
                        }, }
                }, }
        },
@@ -141,7 +145,8 @@ static const struct rte_cryptodev_capabilities openssl_pmd_capabilities[] = {
                                        .max = 28,
                                        .increment = 0
                                },
-                               .aad_size = { 0 }
+                               .aad_size = { 0 },
+                               .iv_size = { 0 }
                        }, }
                }, }
        },
@@ -162,7 +167,8 @@ static const struct rte_cryptodev_capabilities openssl_pmd_capabilities[] = {
                                        .max = 28,
                                        .increment = 0
                                },
-                               .aad_size = { 0 }
+                               .aad_size = { 0 },
+                               .iv_size = { 0 }
                        }, }
                }, }
        },
@@ -183,31 +189,33 @@ static const struct rte_cryptodev_capabilities openssl_pmd_capabilities[] = {
                                        .max = 32,
                                        .increment = 0
                                },
-                               .aad_size = { 0 }
+                               .aad_size = { 0 },
+                               .iv_size = { 0 }
                        }, }
                }, }
        },
        {       /* SHA256 */
-                       .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
-                       {.sym = {
-                               .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
-                               {.auth = {
-                                       .algo = RTE_CRYPTO_AUTH_SHA256,
-                                       .block_size = 64,
-                                       .key_size = {
-                                               .min = 0,
-                                               .max = 0,
-                                               .increment = 0
-                                       },
-                                       .digest_size = {
-                                               .min = 32,
-                                               .max = 32,
-                                               .increment = 0
-                                       },
-                                       .aad_size = { 0 }
-                               }, }
+               .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+               {.sym = {
+                       .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
+                       {.auth = {
+                               .algo = RTE_CRYPTO_AUTH_SHA256,
+                               .block_size = 64,
+                               .key_size = {
+                                       .min = 0,
+                                       .max = 0,
+                                       .increment = 0
+                               },
+                               .digest_size = {
+                                       .min = 32,
+                                       .max = 32,
+                                       .increment = 0
+                               },
+                               .aad_size = { 0 },
+                               .iv_size = { 0 }
                        }, }
-               },
+               }, }
+       },
        {       /* SHA384 HMAC */
                .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
                {.sym = {
@@ -225,7 +233,8 @@ static const struct rte_cryptodev_capabilities openssl_pmd_capabilities[] = {
                                        .max = 48,
                                        .increment = 0
                                },
-                               .aad_size = { 0 }
+                               .aad_size = { 0 },
+                               .iv_size = { 0 }
                        }, }
                }, }
        },
@@ -246,7 +255,8 @@ static const struct rte_cryptodev_capabilities openssl_pmd_capabilities[] = {
                                        .max = 48,
                                        .increment = 0
                                },
-                               .aad_size = { 0 }
+                               .aad_size = { 0 },
+                               .iv_size = { 0 }
                        }, }
                }, }
        },
@@ -267,7 +277,8 @@ static const struct rte_cryptodev_capabilities openssl_pmd_capabilities[] = {
                                        .max = 64,
                                        .increment = 0
                                },
-                               .aad_size = { 0 }
+                               .aad_size = { 0 },
+                               .iv_size = { 0 }
                        }, }
                }, }
        },
@@ -288,7 +299,8 @@ static const struct rte_cryptodev_capabilities openssl_pmd_capabilities[] = {
                                        .max = 64,
                                        .increment = 0
                                },
-                               .aad_size = { 0 }
+                               .aad_size = { 0 },
+                               .iv_size = { 0 }
                        }, }
                }, }
        },
@@ -332,12 +344,12 @@ static const struct rte_cryptodev_capabilities openssl_pmd_capabilities[] = {
                        }, }
                }, }
        },
-       {       /* AES GCM (AUTH) */
+       {       /* AES GCM */
                .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
                {.sym = {
-                       .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
-                       {.auth = {
-                               .algo = RTE_CRYPTO_AUTH_AES_GCM,
+                       .xform_type = RTE_CRYPTO_SYM_XFORM_AEAD,
+                       {.aead = {
+                               .algo = RTE_CRYPTO_AEAD_AES_GCM,
                                .block_size = 16,
                                .key_size = {
                                        .min = 16,
@@ -350,30 +362,15 @@ static const struct rte_cryptodev_capabilities openssl_pmd_capabilities[] = {
                                        .increment = 0
                                },
                                .aad_size = {
-                                       .min = 8,
-                                       .max = 12,
-                                       .increment = 4
-                               }
-                       }, }
-               }, }
-       },
-       {       /* AES GCM (CIPHER) */
-               .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
-               {.sym = {
-                       .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
-                       {.cipher = {
-                               .algo = RTE_CRYPTO_CIPHER_AES_GCM,
-                               .block_size = 16,
-                               .key_size = {
-                                       .min = 16,
-                                       .max = 16,
-                                       .increment = 0
+                                       .min = 0,
+                                       .max = 65535,
+                                       .increment = 1
                                },
                                .iv_size = {
                                        .min = 12,
                                        .max = 16,
                                        .increment = 4
-                               }
+                               },
                        }, }
                }, }
        },
@@ -394,9 +391,9 @@ static const struct rte_cryptodev_capabilities openssl_pmd_capabilities[] = {
                                        .max = 16,
                                        .increment = 0
                                },
-                               .aad_size = {
-                                       .min = 8,
-                                       .max = 65532,
+                               .iv_size = {
+                                       .min = 12,
+                                       .max = 16,
                                        .increment = 4
                                }
                        }, }
@@ -442,6 +439,26 @@ static const struct rte_cryptodev_capabilities openssl_pmd_capabilities[] = {
                        }, }
                }, }
        },
+       {       /* DES DOCSIS BPI */
+               .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+               {.sym = {
+                       .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
+                       {.cipher = {
+                               .algo = RTE_CRYPTO_CIPHER_DES_DOCSISBPI,
+                               .block_size = 8,
+                               .key_size = {
+                                       .min = 8,
+                                       .max = 8,
+                                       .increment = 0
+                               },
+                               .iv_size = {
+                                       .min = 8,
+                                       .max = 8,
+                                       .increment = 0
+                               }
+                       }, }
+               }, }
+       },
 
        RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
 };
@@ -449,7 +466,8 @@ static const struct rte_cryptodev_capabilities openssl_pmd_capabilities[] = {
 
 /** Configure device */
 static int
-openssl_pmd_config(__rte_unused struct rte_cryptodev *dev)
+openssl_pmd_config(__rte_unused struct rte_cryptodev *dev,
+               __rte_unused struct rte_cryptodev_config *config)
 {
        return 0;
 }
@@ -559,7 +577,7 @@ openssl_pmd_qp_create_processed_ops_ring(struct openssl_qp *qp,
 
        r = rte_ring_lookup(qp->name);
        if (r) {
-               if (r->prod.size >= ring_size) {
+               if (rte_ring_get_size(r) >= ring_size) {
                        OPENSSL_LOG_INFO(
                                "Reusing existing ring %s for processed ops",
                                 qp->name);