crypto/cnxk: fix update of number of descriptors
authorAnoob Joseph <anoobj@marvell.com>
Mon, 31 Jan 2022 12:30:29 +0000 (18:00 +0530)
committerAkhil Goyal <gakhil@marvell.com>
Sat, 12 Feb 2022 09:26:38 +0000 (10:26 +0100)
Pending queue also need to be adjusted while updating the number of
descriptors.

Fixes: a455fd869cd7 ("common/cnxk: align CPT queue depth to power of 2")
Cc: stable@dpdk.org
Signed-off-by: Anoob Joseph <anoobj@marvell.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
drivers/common/cnxk/roc_cpt.c
drivers/crypto/cnxk/cnxk_cryptodev_ops.c

index 89877d1..b3a3649 100644 (file)
@@ -571,9 +571,6 @@ cpt_lf_init(struct roc_cpt_lf *lf)
        if (lf->nb_desc == 0 || lf->nb_desc > CPT_LF_MAX_NB_DESC)
                lf->nb_desc = CPT_LF_DEFAULT_NB_DESC;
 
-       /* Update nb_desc to next power of 2 to aid in pending queue checks */
-       lf->nb_desc = plt_align32pow2(lf->nb_desc);
-
        /* Allocate memory for instruction queue for CPT LF. */
        iq_mem = plt_zmalloc(cpt_lf_iq_mem_calc(lf->nb_desc), ROC_ALIGN);
        if (iq_mem == NULL)
index 67a2d9b..a5fb68d 100644 (file)
@@ -361,6 +361,7 @@ cnxk_cpt_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id,
        struct roc_cpt *roc_cpt = &vf->cpt;
        struct rte_pci_device *pci_dev;
        struct cnxk_cpt_qp *qp;
+       uint32_t nb_desc;
        int ret;
 
        if (dev->data->queue_pairs[qp_id] != NULL)
@@ -373,14 +374,17 @@ cnxk_cpt_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id,
                return -EIO;
        }
 
-       qp = cnxk_cpt_qp_create(dev, qp_id, conf->nb_descriptors);
+       /* Update nb_desc to next power of 2 to aid in pending queue checks */
+       nb_desc = plt_align32pow2(conf->nb_descriptors);
+
+       qp = cnxk_cpt_qp_create(dev, qp_id, nb_desc);
        if (qp == NULL) {
                plt_err("Could not create queue pair %d", qp_id);
                return -ENOMEM;
        }
 
        qp->lf.lf_id = qp_id;
-       qp->lf.nb_desc = conf->nb_descriptors;
+       qp->lf.nb_desc = nb_desc;
 
        ret = roc_cpt_lf_init(roc_cpt, &qp->lf);
        if (ret < 0) {