crypto/mvsam: use common initialization
authorDmitri Epshtein <dima@marvell.com>
Mon, 27 Aug 2018 12:22:53 +0000 (14:22 +0200)
committerAkhil Goyal <akhil.goyal@nxp.com>
Wed, 17 Oct 2018 10:16:54 +0000 (12:16 +0200)
Use common initialization to reduce boilerplate code.

Signed-off-by: Dmitri Epshtein <dima@marvell.com>
Signed-off-by: Tomasz Duszynski <tdu@semihalf.com>
Reviewed-by: Natalie Samsonov <nsamsono@marvell.com>
drivers/common/Makefile
drivers/crypto/mvsam/Makefile
drivers/crypto/mvsam/meson.build
drivers/crypto/mvsam/rte_mrvl_pmd.c
mk/rte.app.mk

index 6392a34..cd465cf 100644 (file)
@@ -10,6 +10,7 @@ endif
 
 MVEP-y := $(CONFIG_RTE_LIBRTE_MVPP2_PMD)
 MVEP-y += $(CONFIG_RTE_LIBRTE_MVNETA_PMD)
+MVEP-y += $(CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO)
 ifneq (,$(findstring y,$(MVEP-y)))
 DIRS-y += mvep
 endif
index 3290147..2b4d036 100644 (file)
@@ -19,6 +19,7 @@ LIB = librte_pmd_mvsam_crypto.a
 # build flags
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -I$(RTE_SDK)/drivers/common/mvep
 CFLAGS += -I$(LIBMUSDK_PATH)/include
 CFLAGS += -DMVCONF_TYPES_PUBLIC
 CFLAGS += -DMVCONF_DMA_PHYS_ADDR_T_PUBLIC
@@ -33,7 +34,7 @@ EXPORT_MAP := rte_pmd_mvsam_version.map
 LDLIBS += -L$(LIBMUSDK_PATH)/lib -lmusdk
 LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_kvargs
 LDLIBS += -lrte_cryptodev
-LDLIBS += -lrte_bus_vdev
+LDLIBS += -lrte_bus_vdev -lrte_common_mvep
 
 # library source files
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO) += rte_mrvl_pmd.c
index 3c8ea3c..f1c8796 100644 (file)
@@ -18,4 +18,4 @@ endif
 
 sources = files('rte_mrvl_pmd.c', 'rte_mrvl_pmd_ops.c')
 
-deps += ['bus_vdev']
+deps += ['bus_vdev', 'common_mvep']
index a09f55b..69d7892 100644 (file)
 #include <rte_malloc.h>
 #include <rte_cpuflags.h>
 #include <rte_kvargs.h>
+#include <rte_mvep_common.h>
 
 #include "rte_mrvl_pmd_private.h"
 
-#define MRVL_MUSDK_DMA_MEMSIZE 41943040
-
 #define MRVL_PMD_MAX_NB_SESS_ARG               ("max_nb_sessions")
 #define MRVL_PMD_DEFAULT_MAX_NB_SESSIONS       2048
 
@@ -767,7 +766,7 @@ cryptodev_mrvl_crypto_create(const char *name,
        struct rte_cryptodev *dev;
        struct mrvl_crypto_private *internals;
        struct sam_init_params  sam_params;
-       int ret;
+       int ret = -EINVAL;
 
        dev = rte_cryptodev_pmd_create(name, &vdev->device,
                        &init_params->common);
@@ -795,30 +794,26 @@ cryptodev_mrvl_crypto_create(const char *name,
        internals->max_nb_qpairs = init_params->common.max_nb_queue_pairs;
        internals->max_nb_sessions = init_params->max_nb_sessions;
 
-       /*
-        * ret == -EEXIST is correct, it means DMA
-        * has been already initialized.
-        */
-       ret = mv_sys_dma_mem_init(MRVL_MUSDK_DMA_MEMSIZE);
-       if (ret < 0) {
-               if (ret != -EEXIST)
-                       return ret;
-
-               MRVL_CRYPTO_LOG_INFO(
-                       "DMA memory has been already initialized by a different driver.");
-       }
+       ret = rte_mvep_init(MVEP_MOD_T_SAM, NULL);
+       if (ret)
+               goto init_error;
 
        sam_params.max_num_sessions = internals->max_nb_sessions;
 
        /* sam_set_debug_flags(3); */
-       return sam_init(&sam_params);
+
+       ret = sam_init(&sam_params);
+       if (ret)
+               goto init_error;
+
+       return 0;
 
 init_error:
        MRVL_CRYPTO_LOG_ERR(
                "driver %s: %s failed", init_params->common.name, __func__);
 
        cryptodev_mrvl_crypto_uninit(vdev);
-       return -EFAULT;
+       return ret;
 }
 
 /** Parse integer from integer argument */
@@ -968,6 +963,7 @@ cryptodev_mrvl_crypto_uninit(struct rte_vdev_device *vdev)
                name, rte_socket_id());
 
        sam_deinit();
+       rte_mvep_deinit(MVEP_MOD_T_SAM);
 
        cryptodev = rte_cryptodev_pmd_get_named_dev(name);
        if (cryptodev == NULL)
index 06a457d..502292c 100644 (file)
@@ -100,6 +100,7 @@ endif
 
 MVEP-y := $(CONFIG_RTE_LIBRTE_MVPP2_PMD)
 MVEP-y += $(CONFIG_RTE_LIBRTE_MVNETA_PMD)
+MVEP-y += $(CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO)
 ifneq (,$(findstring y,$(MVEP-y)))
 _LDLIBS-y += -lrte_common_mvep -L$(LIBMUSDK_PATH)/lib -lmusdk
 endif