net/i40e: fix multiple DDP packages conflict
[dpdk.git] / lib / librte_cryptodev / rte_cryptodev.c
index 8ee5d47..8745b6b 100644 (file)
@@ -1,33 +1,5 @@
-/*-
- *   BSD LICENSE
- *
- *   Copyright(c) 2015-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
- *   are met:
- *
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in
- *       the documentation and/or other materials provided with the
- *       distribution.
- *     * Neither the name of Intel Corporation nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2015-2017 Intel Corporation
  */
 
 #include <sys/types.h>
@@ -311,8 +283,7 @@ rte_cryptodev_sym_capability_check_cipher(
 int
 rte_cryptodev_sym_capability_check_auth(
                const struct rte_cryptodev_symmetric_capability *capability,
-               uint16_t key_size, uint16_t digest_size, uint16_t aad_size,
-               uint16_t iv_size)
+               uint16_t key_size, uint16_t digest_size, uint16_t iv_size)
 {
        if (param_range_check(key_size, capability->auth.key_size))
                return -1;
@@ -320,9 +291,6 @@ rte_cryptodev_sym_capability_check_auth(
        if (param_range_check(digest_size, capability->auth.digest_size))
                return -1;
 
-       if (param_range_check(aad_size, capability->auth.aad_size))
-               return -1;
-
        if (param_range_check(iv_size, capability->auth.iv_size))
                return -1;
 
@@ -366,6 +334,8 @@ rte_cryptodev_get_feature_name(uint64_t flag)
                return "CPU_AVX";
        case RTE_CRYPTODEV_FF_CPU_AVX2:
                return "CPU_AVX2";
+       case RTE_CRYPTODEV_FF_CPU_AVX512:
+               return "CPU_AVX512";
        case RTE_CRYPTODEV_FF_CPU_AESNI:
                return "CPU_AESNI";
        case RTE_CRYPTODEV_FF_HW_ACCELERATED:
@@ -381,12 +351,6 @@ rte_cryptodev_get_feature_name(uint64_t flag)
        }
 }
 
-int
-rte_cryptodev_create_vdev(const char *name, const char *args)
-{
-       return rte_vdev_init(name, args);
-}
-
 struct rte_cryptodev *
 rte_cryptodev_pmd_get_dev(uint8_t dev_id)
 {
@@ -492,6 +456,16 @@ rte_cryptodev_devices_get(const char *driver_name, uint8_t *devices,
        return count;
 }
 
+void *
+rte_cryptodev_get_sec_ctx(uint8_t dev_id)
+{
+       if (rte_crypto_devices[dev_id].feature_flags &
+                       RTE_CRYPTODEV_FF_SECURITY)
+               return rte_crypto_devices[dev_id].security_ctx;
+
+       return NULL;
+}
+
 int
 rte_cryptodev_socket_id(uint8_t dev_id)
 {
@@ -587,6 +561,9 @@ rte_cryptodev_pmd_allocate(const char *name, int socket_id)
                cryptodev->data->socket_id = socket_id;
                cryptodev->data->dev_started = 0;
 
+               /* init user callbacks */
+               TAILQ_INIT(&(cryptodev->link_intr_cbs));
+
                cryptodev->attached = RTE_CRYPTODEV_ATTACHED;
 
                cryptodev_globals.nb_devs++;
@@ -1089,20 +1066,22 @@ rte_cryptodev_sym_session_init(uint8_t dev_id,
 {
        struct rte_cryptodev *dev;
        uint8_t index;
+       int ret;
 
        dev = rte_cryptodev_pmd_get_dev(dev_id);
 
        if (sess == NULL || xforms == NULL || dev == NULL)
-               return -1;
+               return -EINVAL;
 
        index = dev->driver_id;
 
        if (sess->sess_private_data[index] == NULL) {
-               if (dev->dev_ops->session_configure(dev, xforms, sess, mp) < 0) {
+               ret = dev->dev_ops->session_configure(dev, xforms, sess, mp);
+               if (ret < 0) {
                        CDEV_LOG_ERR(
                                "dev_id %d failed to configure session details",
                                dev_id);
-                       return -1;
+                       return ret;
                }
        }
 
@@ -1115,7 +1094,7 @@ rte_cryptodev_sym_session_create(struct rte_mempool *mp)
        struct rte_cryptodev_sym_session *sess;
 
        /* Allocate a session structure from the session pool */
-       if (rte_mempool_get(mp, (void *)&sess)) {
+       if (rte_mempool_get(mp, (void **)&sess)) {
                CDEV_LOG_ERR("couldn't get object from session mempool");
                return NULL;
        }
@@ -1273,7 +1252,7 @@ rte_crypto_op_init(struct rte_mempool *mempool,
 
        __rte_crypto_op_reset(op, type);
 
-       op->phys_addr = rte_mem_virt2phy(_op_data);
+       op->phys_addr = rte_mem_virt2iova(_op_data);
        op->mempool = mempool;
 }
 
@@ -1364,12 +1343,6 @@ TAILQ_HEAD(cryptodev_driver_list, cryptodev_driver);
 static struct cryptodev_driver_list cryptodev_driver_list =
        TAILQ_HEAD_INITIALIZER(cryptodev_driver_list);
 
-struct cryptodev_driver {
-       TAILQ_ENTRY(cryptodev_driver) next; /**< Next in list. */
-       const struct rte_driver *driver;
-       uint8_t id;
-};
-
 int
 rte_cryptodev_driver_id_get(const char *name)
 {
@@ -1389,6 +1362,17 @@ rte_cryptodev_driver_id_get(const char *name)
        return -1;
 }
 
+const char *
+rte_cryptodev_name_get(uint8_t dev_id)
+{
+       struct rte_cryptodev *dev = rte_cryptodev_pmd_get_dev(dev_id);
+
+       if (dev == NULL)
+               return NULL;
+
+       return dev->data->name;
+}
+
 const char *
 rte_cryptodev_driver_name_get(uint8_t driver_id)
 {
@@ -1401,15 +1385,13 @@ rte_cryptodev_driver_name_get(uint8_t driver_id)
 }
 
 uint8_t
-rte_cryptodev_allocate_driver(const struct rte_driver *drv)
+rte_cryptodev_allocate_driver(struct cryptodev_driver *crypto_drv,
+               const struct rte_driver *drv)
 {
-       struct cryptodev_driver *driver;
-
-       driver = malloc(sizeof(*driver));
-       driver->driver = drv;
-       driver->id = nb_drivers;
+       crypto_drv->driver = drv;
+       crypto_drv->id = nb_drivers;
 
-       TAILQ_INSERT_TAIL(&cryptodev_driver_list, driver, next);
+       TAILQ_INSERT_TAIL(&cryptodev_driver_list, crypto_drv, next);
 
        return nb_drivers++;
 }