crypto/ccp: support AES
[dpdk.git] / drivers / crypto / ccp / ccp_pmd_ops.c
index bd0aea4..a6e777a 100644 (file)
 #include "ccp_crypto.h"
 
 static const struct rte_cryptodev_capabilities ccp_pmd_capabilities[] = {
+       {       /* AES ECB */
+               .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+               {.sym = {
+                       .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
+                       {.cipher = {
+                               .algo = RTE_CRYPTO_CIPHER_AES_ECB,
+                               .block_size = 16,
+                               .key_size = {
+                                  .min = 16,
+                                  .max = 32,
+                                  .increment = 8
+                               },
+                               .iv_size = {
+                                  .min = 0,
+                                  .max = 0,
+                                  .increment = 0
+                               }
+                       }, }
+               }, }
+       },
+       {       /* AES CBC */
+               .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+               {.sym = {
+                       .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
+                       {.cipher = {
+                               .algo = RTE_CRYPTO_CIPHER_AES_CBC,
+                               .block_size = 16,
+                               .key_size = {
+                                       .min = 16,
+                                       .max = 32,
+                                       .increment = 8
+                               },
+                               .iv_size = {
+                                       .min = 16,
+                                       .max = 16,
+                                       .increment = 0
+                               }
+                       }, }
+               }, }
+       },
+       {       /* AES CTR */
+               .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+               {.sym = {
+                       .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
+                       {.cipher = {
+                               .algo = RTE_CRYPTO_CIPHER_AES_CTR,
+                               .block_size = 16,
+                               .key_size = {
+                                       .min = 16,
+                                       .max = 32,
+                                       .increment = 8
+                               },
+                               .iv_size = {
+                                       .min = 16,
+                                       .max = 16,
+                                       .increment = 0
+                               }
+                       }, }
+               }, }
+       },
        RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
 };
 
@@ -41,6 +101,36 @@ ccp_pmd_close(struct rte_cryptodev *dev __rte_unused)
        return 0;
 }
 
+static void
+ccp_pmd_stats_get(struct rte_cryptodev *dev,
+                 struct rte_cryptodev_stats *stats)
+{
+       int qp_id;
+
+       for (qp_id = 0; qp_id < dev->data->nb_queue_pairs; qp_id++) {
+               struct ccp_qp *qp = dev->data->queue_pairs[qp_id];
+
+               stats->enqueued_count += qp->qp_stats.enqueued_count;
+               stats->dequeued_count += qp->qp_stats.dequeued_count;
+
+               stats->enqueue_err_count += qp->qp_stats.enqueue_err_count;
+               stats->dequeue_err_count += qp->qp_stats.dequeue_err_count;
+       }
+
+}
+
+static void
+ccp_pmd_stats_reset(struct rte_cryptodev *dev)
+{
+       int qp_id;
+
+       for (qp_id = 0; qp_id < dev->data->nb_queue_pairs; qp_id++) {
+               struct ccp_qp *qp = dev->data->queue_pairs[qp_id];
+
+               memset(&qp->qp_stats, 0, sizeof(qp->qp_stats));
+       }
+}
+
 static void
 ccp_pmd_info_get(struct rte_cryptodev *dev,
                 struct rte_cryptodev_info *dev_info)
@@ -255,8 +345,8 @@ struct rte_cryptodev_ops ccp_ops = {
                .dev_stop               = ccp_pmd_stop,
                .dev_close              = ccp_pmd_close,
 
-               .stats_get              = NULL,
-               .stats_reset            = NULL,
+               .stats_get              = ccp_pmd_stats_get,
+               .stats_reset            = ccp_pmd_stats_reset,
 
                .dev_infos_get          = ccp_pmd_info_get,