Skip to content

Commit

Permalink
crypto/octeontx2: fix multi-process
Browse files Browse the repository at this point in the history
[ upstream commit 9fd11c1 ]

During crypto device probe few functions should be called only
for the primary process. This patch fixes this issue.

Fixes: 818d138 ("crypto/octeontx2: add init sequence in probe")

Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>
Reviewed-by: Anoob Joseph <anoobj@marvell.com>
  • Loading branch information
adwivedi7 authored and bluca committed Nov 9, 2020
1 parent a973d06 commit 3415ca5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 28 deletions.
57 changes: 32 additions & 25 deletions drivers/crypto/octeontx2/otx2_cryptodev.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,32 +70,35 @@ otx2_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,

otx2_dev = &vf->otx2_dev;

/* Initialize the base otx2_dev object */
ret = otx2_dev_init(pci_dev, otx2_dev);
if (ret) {
CPT_LOG_ERR("Could not initialize otx2_dev");
goto pmd_destroy;
if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
/* Initialize the base otx2_dev object */
ret = otx2_dev_init(pci_dev, otx2_dev);
if (ret) {
CPT_LOG_ERR("Could not initialize otx2_dev");
goto pmd_destroy;
}

/* Get number of queues available on the device */
ret = otx2_cpt_available_queues_get(dev, &nb_queues);
if (ret) {
CPT_LOG_ERR("Could not determine the number of queues available");
goto otx2_dev_fini;
}

/* Don't exceed the limits set per VF */
nb_queues = RTE_MIN(nb_queues, OTX2_CPT_MAX_QUEUES_PER_VF);

if (nb_queues == 0) {
CPT_LOG_ERR("No free queues available on the device");
goto otx2_dev_fini;
}

vf->max_queues = nb_queues;

CPT_LOG_INFO("Max queues supported by device: %d",
vf->max_queues);
}

/* Get number of queues available on the device */
ret = otx2_cpt_available_queues_get(dev, &nb_queues);
if (ret) {
CPT_LOG_ERR("Could not determine the number of queues available");
goto otx2_dev_fini;
}

/* Don't exceed the limits set per VF */
nb_queues = RTE_MIN(nb_queues, OTX2_CPT_MAX_QUEUES_PER_VF);

if (nb_queues == 0) {
CPT_LOG_ERR("No free queues available on the device");
goto otx2_dev_fini;
}

vf->max_queues = nb_queues;

CPT_LOG_INFO("Max queues supported by device: %d", vf->max_queues);

dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
RTE_CRYPTODEV_FF_HW_ACCELERATED |
RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
Expand All @@ -105,10 +108,14 @@ otx2_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO |
RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT;

if (rte_eal_process_type() == RTE_PROC_SECONDARY)
otx2_cpt_set_enqdeq_fns(dev);

return 0;

otx2_dev_fini:
otx2_dev_fini(pci_dev, otx2_dev);
if (rte_eal_process_type() == RTE_PROC_PRIMARY)
otx2_dev_fini(pci_dev, otx2_dev);
pmd_destroy:
rte_cryptodev_pmd_destroy(dev);
exit:
Expand Down
2 changes: 2 additions & 0 deletions drivers/crypto/octeontx2/otx2_cryptodev.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ extern int otx2_cpt_logtype;
*/
extern uint8_t otx2_cryptodev_driver_id;

void otx2_cpt_set_enqdeq_fns(struct rte_cryptodev *dev);

#endif /* _OTX2_CRYPTODEV_H_ */
13 changes: 10 additions & 3 deletions drivers/crypto/octeontx2/otx2_cryptodev_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,15 @@ otx2_cpt_dequeue_burst(void *qptr, struct rte_crypto_op **ops, uint16_t nb_ops)
return nb_completed;
}

void
otx2_cpt_set_enqdeq_fns(struct rte_cryptodev *dev)
{
dev->enqueue_burst = otx2_cpt_enqueue_burst;
dev->dequeue_burst = otx2_cpt_dequeue_burst;

rte_mb();
}

/* PMD ops */

static int
Expand Down Expand Up @@ -862,10 +871,8 @@ otx2_cpt_dev_config(struct rte_cryptodev *dev,
goto queues_detach;
}

dev->enqueue_burst = otx2_cpt_enqueue_burst;
dev->dequeue_burst = otx2_cpt_dequeue_burst;
otx2_cpt_set_enqdeq_fns(dev);

rte_mb();
return 0;

queues_detach:
Expand Down

0 comments on commit 3415ca5

Please sign in to comment.