cryptodev: fix pmd allocation on multi-process

Message ID 20190807083924.39191-1-julien.meunier@nokia.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series cryptodev: fix pmd allocation on multi-process |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues
ci/iol-Compile-Testing success Compile Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS
ci/mellanox-Performance-Testing success Performance Testing PASS

Commit Message

Julien Meunier Aug. 7, 2019, 8:39 a.m. UTC
  Primary process is responsible to initialize the data struct of each
crypto devices.

Secondary process should not override this data during the
initialization.

Fixes: d11b0f30df88 ("cryptodev: introduce API and framework for crypto devices")
Cc: stable@dpdk.org

Signed-off-by: Julien Meunier <julien.meunier@nokia.com>
---
 lib/librte_cryptodev/rte_cryptodev.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
  

Comments

Akhil Goyal Sept. 19, 2019, 2:54 p.m. UTC | #1
> Primary process is responsible to initialize the data struct of each
> crypto devices.
> 
> Secondary process should not override this data during the
> initialization.
> 
> Fixes: d11b0f30df88 ("cryptodev: introduce API and framework for crypto
> devices")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Julien Meunier <julien.meunier@nokia.com>
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
  
Akhil Goyal Oct. 3, 2019, 2:19 p.m. UTC | #2
> 
> 
> > Primary process is responsible to initialize the data struct of each
> > crypto devices.
> >
> > Secondary process should not override this data during the
> > initialization.
> >
> > Fixes: d11b0f30df88 ("cryptodev: introduce API and framework for crypto
> > devices")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Julien Meunier <julien.meunier@nokia.com>
> Acked-by: Akhil Goyal <akhil.goyal@nxp.com>

Applied to dpdk-next-crypto

Thanks.
  

Patch

diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 43bc335..b16ef7b 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -725,12 +725,14 @@  rte_cryptodev_pmd_allocate(const char *name, int socket_id)
 
 		cryptodev->data = *cryptodev_data;
 
-		strlcpy(cryptodev->data->name, name,
-			RTE_CRYPTODEV_NAME_MAX_LEN);
+		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+			strlcpy(cryptodev->data->name, name,
+				RTE_CRYPTODEV_NAME_MAX_LEN);
 
-		cryptodev->data->dev_id = dev_id;
-		cryptodev->data->socket_id = socket_id;
-		cryptodev->data->dev_started = 0;
+			cryptodev->data->dev_id = dev_id;
+			cryptodev->data->socket_id = socket_id;
+			cryptodev->data->dev_started = 0;
+		}
 
 		/* init user callbacks */
 		TAILQ_INIT(&(cryptodev->link_intr_cbs));