crypto/dpaa_sec: add lock before Rx HW queue attach
authorAkhil Goyal <akhil.goyal@nxp.com>
Thu, 30 Aug 2018 05:50:58 +0000 (11:20 +0530)
committerAkhil Goyal <akhil.goyal@nxp.com>
Wed, 26 Sep 2018 11:18:38 +0000 (13:18 +0200)
This is to safeguard as the session config can be done from multi-threads.

Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
drivers/crypto/dpaa_sec/dpaa_sec.c
drivers/crypto/dpaa_sec/dpaa_sec.h

index d79904b..095e218 100644 (file)
@@ -23,6 +23,7 @@
 #include <rte_mbuf.h>
 #include <rte_memcpy.h>
 #include <rte_string_fns.h>
+#include <rte_spinlock.h>
 
 #include <fsl_usd.h>
 #include <fsl_qman.h>
@@ -1810,7 +1811,9 @@ dpaa_sec_set_session_parameters(struct rte_cryptodev *dev,
                return -EINVAL;
        }
        session->ctx_pool = internals->ctx_pool;
+       rte_spinlock_lock(&internals->lock);
        session->inq = dpaa_sec_attach_rxq(internals);
+       rte_spinlock_unlock(&internals->lock);
        if (session->inq == NULL) {
                DPAA_SEC_ERR("unable to attach sec queue");
                goto err1;
@@ -2037,7 +2040,9 @@ dpaa_sec_set_ipsec_session(__rte_unused struct rte_cryptodev *dev,
        } else
                goto out;
        session->ctx_pool = internals->ctx_pool;
+       rte_spinlock_lock(&internals->lock);
        session->inq = dpaa_sec_attach_rxq(internals);
+       rte_spinlock_unlock(&internals->lock);
        if (session->inq == NULL) {
                DPAA_SEC_ERR("unable to attach sec queue");
                goto out;
@@ -2288,6 +2293,7 @@ dpaa_sec_dev_init(struct rte_cryptodev *cryptodev)
        security_instance->sess_cnt = 0;
        cryptodev->security_ctx = security_instance;
 
+       rte_spinlock_init(&internals->lock);
        for (i = 0; i < internals->max_nb_queue_pairs; i++) {
                /* init qman fq for queue pair */
                qp = &internals->qps[i];
index ac6c00a..e923942 100644 (file)
@@ -150,6 +150,7 @@ struct dpaa_sec_dev_private {
        unsigned char inq_attach[RTE_DPAA_MAX_RX_QUEUE];
        unsigned int max_nb_queue_pairs;
        unsigned int max_nb_sessions;
+       rte_spinlock_t lock;
 };
 
 #define MAX_SG_ENTRIES         16