common/cnxk: consider adjust value for TM burst calculation
[dpdk.git] / lib / cryptodev / rte_cryptodev.c
index b913c43..305e013 100644 (file)
@@ -53,6 +53,9 @@ static struct rte_cryptodev_global cryptodev_globals = {
                .nb_devs                = 0
 };
 
+/* Public fastpath APIs. */
+struct rte_crypto_fp_ops rte_crypto_fp_ops[RTE_CRYPTO_MAX_DEVS];
+
 /* spinlock for crypto device callbacks */
 static rte_spinlock_t rte_cryptodev_cb_lock = RTE_SPINLOCK_INITIALIZER;
 
@@ -917,6 +920,8 @@ rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev)
 
        dev_id = cryptodev->data->dev_id;
 
+       cryptodev_fp_ops_reset(rte_crypto_fp_ops + dev_id);
+
        /* Close device only if device operations have been set */
        if (cryptodev->dev_ops) {
                ret = rte_cryptodev_close(dev_id);
@@ -978,7 +983,8 @@ rte_cryptodev_queue_pairs_config(struct rte_cryptodev *dev, uint16_t nb_qpairs,
        if (dev->data->queue_pairs == NULL) { /* first time configuration */
                dev->data->queue_pairs = rte_zmalloc_socket(
                                "cryptodev->queue_pairs",
-                               sizeof(dev->data->queue_pairs[0]) * nb_qpairs,
+                               sizeof(dev->data->queue_pairs[0]) *
+                               dev_info.max_nb_queue_pairs,
                                RTE_CACHE_LINE_SIZE, socket_id);
 
                if (dev->data->queue_pairs == NULL) {
@@ -1001,25 +1007,9 @@ rte_cryptodev_queue_pairs_config(struct rte_cryptodev *dev, uint16_t nb_qpairs,
                        ret = (*dev->dev_ops->queue_pair_release)(dev, i);
                        if (ret < 0)
                                return ret;
+                       qp[i] = NULL;
                }
 
-               qp = rte_realloc(qp, sizeof(qp[0]) * nb_qpairs,
-                               RTE_CACHE_LINE_SIZE);
-               if (qp == NULL) {
-                       CDEV_LOG_ERR("failed to realloc qp meta data,"
-                                               " nb_queues %u", nb_qpairs);
-                       return -(ENOMEM);
-               }
-
-               if (nb_qpairs > old_nb_queues) {
-                       uint16_t new_qs = nb_qpairs - old_nb_queues;
-
-                       memset(qp + old_nb_queues, 0,
-                               sizeof(qp[0]) * new_qs);
-               }
-
-               dev->data->queue_pairs = qp;
-
        }
        dev->data->nb_queue_pairs = nb_qpairs;
        return 0;
@@ -1095,6 +1085,9 @@ rte_cryptodev_start(uint8_t dev_id)
        }
 
        diag = (*dev->dev_ops->dev_start)(dev);
+       /* expose selection of PMD fast-path functions */
+       cryptodev_fp_ops_set(rte_crypto_fp_ops + dev_id, dev);
+
        rte_cryptodev_trace_start(dev_id, diag);
        if (diag == 0)
                dev->data->dev_started = 1;
@@ -1124,6 +1117,9 @@ rte_cryptodev_stop(uint8_t dev_id)
                return;
        }
 
+       /* point fast-path functions to dummy ones */
+       cryptodev_fp_ops_reset(rte_crypto_fp_ops + dev_id);
+
        (*dev->dev_ops->dev_stop)(dev);
        rte_cryptodev_trace_stop(dev_id);
        dev->data->dev_started = 0;
@@ -2426,3 +2422,11 @@ rte_cryptodev_allocate_driver(struct cryptodev_driver *crypto_drv,
 
        return nb_drivers++;
 }
+
+RTE_INIT(cryptodev_init_fp_ops)
+{
+       uint32_t i;
+
+       for (i = 0; i != RTE_DIM(rte_crypto_fp_ops); i++)
+               cryptodev_fp_ops_reset(rte_crypto_fp_ops + i);
+}