cryptodev: store device pointer in virtual devices
authorPablo de Lara <pablo.de.lara.guarch@intel.com>
Wed, 21 Jun 2017 06:28:18 +0000 (07:28 +0100)
committerPablo de Lara <pablo.de.lara.guarch@intel.com>
Wed, 28 Jun 2017 17:59:22 +0000 (19:59 +0200)
Only non virtual devices were storing the pointer to
rte_device structure in rte_cryptodev, which will be needed
to retrieve the driver name for any device.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Declan Doherty <declan.doherty@intel.com>
12 files changed:
drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
drivers/crypto/armv8/rte_armv8_pmd.c
drivers/crypto/kasumi/rte_kasumi_pmd.c
drivers/crypto/null/null_crypto_pmd.c
drivers/crypto/openssl/rte_openssl_pmd.c
drivers/crypto/scheduler/scheduler_pmd.c
drivers/crypto/snow3g/rte_snow3g_pmd.c
drivers/crypto/zuc/rte_zuc_pmd.c
lib/librte_cryptodev/rte_cryptodev.c
lib/librte_cryptodev/rte_cryptodev.h
lib/librte_cryptodev/rte_cryptodev_pmd.h

index 101ef98..246f71e 100644 (file)
@@ -450,7 +450,8 @@ aesni_gcm_create(const char *name,
        }
 
        dev = rte_cryptodev_pmd_virtual_dev_init(init_params->name,
-                       sizeof(struct aesni_gcm_private), init_params->socket_id);
+                       sizeof(struct aesni_gcm_private), init_params->socket_id,
+                       vdev);
        if (dev == NULL) {
                GCM_LOG_ERR("failed to create cryptodev vdev");
                goto init_error;
index 45b25c9..be38c31 100644 (file)
@@ -699,7 +699,8 @@ cryptodev_aesni_mb_create(const char *name,
        }
 
        dev = rte_cryptodev_pmd_virtual_dev_init(init_params->name,
-                       sizeof(struct aesni_mb_private), init_params->socket_id);
+                       sizeof(struct aesni_mb_private), init_params->socket_id,
+                       vdev);
        if (dev == NULL) {
                MB_LOG_ERR("failed to create cryptodev vdev");
                goto init_error;
index 3d603a5..29905d6 100644 (file)
@@ -808,7 +808,8 @@ cryptodev_armv8_crypto_create(const char *name,
 
        dev = rte_cryptodev_pmd_virtual_dev_init(init_params->name,
                                sizeof(struct armv8_crypto_private),
-                               init_params->socket_id);
+                               init_params->socket_id,
+                               vdev);
        if (dev == NULL) {
                ARMV8_CRYPTO_LOG_ERR("failed to create cryptodev vdev");
                goto init_error;
index 9da9e89..a95f503 100644 (file)
@@ -574,7 +574,8 @@ cryptodev_kasumi_create(const char *name,
        }
 
        dev = rte_cryptodev_pmd_virtual_dev_init(init_params->name,
-                       sizeof(struct kasumi_private), init_params->socket_id);
+                       sizeof(struct kasumi_private), init_params->socket_id,
+                       vdev);
        if (dev == NULL) {
                KASUMI_LOG_ERR("failed to create cryptodev vdev");
                goto init_error;
index 023450a..49da8d4 100644 (file)
@@ -166,6 +166,7 @@ static int cryptodev_null_remove(const char *name);
 /** Create crypto device */
 static int
 cryptodev_null_create(const char *name,
+               struct rte_vdev_device *vdev,
                struct rte_crypto_vdev_init_params *init_params)
 {
        struct rte_cryptodev *dev;
@@ -177,7 +178,8 @@ cryptodev_null_create(const char *name,
 
        dev = rte_cryptodev_pmd_virtual_dev_init(init_params->name,
                        sizeof(struct null_crypto_private),
-                       init_params->socket_id);
+                       init_params->socket_id,
+                       vdev);
        if (dev == NULL) {
                NULL_CRYPTO_LOG_ERR("failed to create cryptodev vdev");
                goto init_error;
@@ -235,7 +237,7 @@ cryptodev_null_probe(struct rte_vdev_device *dev)
        RTE_LOG(INFO, PMD, "  Max number of sessions = %d\n",
                        init_params.max_nb_sessions);
 
-       return cryptodev_null_create(name, &init_params);
+       return cryptodev_null_create(name, dev, &init_params);
 }
 
 /** Uninitialise null crypto device */
index f0c5ca3..13a5129 100644 (file)
@@ -1277,7 +1277,8 @@ cryptodev_openssl_create(const char *name,
 
        dev = rte_cryptodev_pmd_virtual_dev_init(init_params->name,
                        sizeof(struct openssl_private),
-                       init_params->socket_id);
+                       init_params->socket_id,
+                       vdev);
        if (dev == NULL) {
                OPENSSL_LOG_ERR("failed to create cryptodev vdev");
                goto init_error;
index 29b16c9..50a196c 100644 (file)
@@ -89,7 +89,8 @@ const struct scheduler_parse_map scheduler_ordering_map[] = {
 
 static int
 cryptodev_scheduler_create(const char *name,
-       struct scheduler_init_params *init_params)
+               struct rte_vdev_device *vdev,
+               struct scheduler_init_params *init_params)
 {
        struct rte_cryptodev *dev;
        struct scheduler_ctx *sched_ctx;
@@ -103,7 +104,8 @@ cryptodev_scheduler_create(const char *name,
 
        dev = rte_cryptodev_pmd_virtual_dev_init(init_params->def_p.name,
                        sizeof(struct scheduler_ctx),
-                       init_params->def_p.socket_id);
+                       init_params->def_p.socket_id,
+                       vdev);
        if (dev == NULL) {
                CS_LOG_ERR("driver %s: failed to create cryptodev vdev",
                        name);
@@ -417,6 +419,7 @@ cryptodev_scheduler_probe(struct rte_vdev_device *vdev)
                        init_params.def_p.name);
 
        return cryptodev_scheduler_create(name,
+                                       vdev,
                                        &init_params);
 }
 
index 960956c..f17c541 100644 (file)
@@ -563,7 +563,8 @@ cryptodev_snow3g_create(const char *name,
        }
 
        dev = rte_cryptodev_pmd_virtual_dev_init(init_params->name,
-                       sizeof(struct snow3g_private), init_params->socket_id);
+                       sizeof(struct snow3g_private), init_params->socket_id,
+                       vdev);
        if (dev == NULL) {
                SNOW3G_LOG_ERR("failed to create cryptodev vdev");
                goto init_error;
index 1020544..ab42d06 100644 (file)
@@ -463,7 +463,8 @@ cryptodev_zuc_create(const char *name,
        }
 
        dev = rte_cryptodev_pmd_virtual_dev_init(init_params->name,
-                       sizeof(struct zuc_private), init_params->socket_id);
+                       sizeof(struct zuc_private), init_params->socket_id,
+                       vdev);
        if (dev == NULL) {
                ZUC_LOG_ERR("failed to create cryptodev vdev");
                goto init_error;
index 81fd2bf..2b2f0fe 100644 (file)
@@ -651,7 +651,7 @@ rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev)
 
 struct rte_cryptodev *
 rte_cryptodev_pmd_virtual_dev_init(const char *name, size_t dev_private_size,
-               int socket_id)
+               int socket_id, struct rte_vdev_device *vdev)
 {
        struct rte_cryptodev *cryptodev;
 
@@ -673,6 +673,8 @@ rte_cryptodev_pmd_virtual_dev_init(const char *name, size_t dev_private_size,
                                        " data");
        }
 
+       cryptodev->device = &vdev->device;
+
        /* initialise user call-back tail queue */
        TAILQ_INIT(&(cryptodev->link_intr_cbs));
 
index 88aeb87..f307b3b 100644 (file)
@@ -49,6 +49,7 @@ extern "C" {
 #include "rte_crypto.h"
 #include "rte_dev.h"
 #include <rte_common.h>
+#include <rte_vdev.h>
 
 #define CRYPTODEV_NAME_NULL_PMD                crypto_null
 /**< Null crypto PMD device name */
index 17ef37c..ec4ca97 100644 (file)
@@ -462,6 +462,7 @@ rte_cryptodev_pmd_allocate(const char *name, int socket_id);
  * @param      name                    PMD type name
  * @param      dev_private_size        Size of crypto PMDs private data
  * @param      socket_id               Socket to allocate resources on.
+ * @param      vdev                    Pointer to virtual device structure.
  *
  * @return
  *   - Cryptodev pointer if device is successfully created.
@@ -469,7 +470,7 @@ rte_cryptodev_pmd_allocate(const char *name, int socket_id);
  */
 struct rte_cryptodev *
 rte_cryptodev_pmd_virtual_dev_init(const char *name, size_t dev_private_size,
-               int socket_id);
+               int socket_id, struct rte_vdev_device *vdev);
 
 
 /**