From: Akhil Goyal Date: Thu, 30 Aug 2018 05:50:58 +0000 (+0530) Subject: crypto/dpaa_sec: add lock before Rx HW queue attach X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=3b617ee775b7383c019539e4a91e885f00432cd4;p=dpdk.git crypto/dpaa_sec: add lock before Rx HW queue attach This is to safeguard as the session config can be done from multi-threads. Signed-off-by: Akhil Goyal --- diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c index d79904b615..095e218161 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.c +++ b/drivers/crypto/dpaa_sec/dpaa_sec.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -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]; diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.h b/drivers/crypto/dpaa_sec/dpaa_sec.h index ac6c00a601..e923942fca 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.h +++ b/drivers/crypto/dpaa_sec/dpaa_sec.h @@ -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