Skip to contentSkip to conversation

drivers: improve DPAA crypto fq resource handling

PATCH New Gagandeep Singh 1 participant 1 message Oct 28

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: improve DPAA crypto fq resource handling

From: Jun Yang <[email protected]>

Release resources on probe failure and on uninit, and allocate the FQID range for a queue pair with a single ioctl instead of one per FQID to cut boot and quit time.

Export qman_release_fqid_range() from the bus, which dpaa_sec_uninit() needs to return the queue FQIDs in ranges.

qman_shutdown_fq() falls back to get_affine_portal() when fq->qp is NULL, so affine a portal first in dpaa_sec_uninit() as probe does; rte_dev_remove() can run on a thread that never did. Release an FQID only once its queue actually shut down, in both uninit and the probe error paths: one that did not is still live in QMan, and handing its FQID back would let qman_alloc_fqid() give it to another user.

---
 drivers/bus/dpaa/base/qbman/qman.c       |  15 +-
 drivers/bus/dpaa/dpaa_bus_base_symbols.c |   2 +
 drivers/bus/dpaa/include/fsl_qman.h      |  13 +-
 drivers/crypto/dpaa_sec/dpaa_sec.c       | 176 ++++++++++++++++++++---
 drivers/net/dpaa/dpaa_ethdev.c           |   2 +-
 5 files changed, 184 insertions(+), 24 deletions(-)
drivers/bus/dpaa/base/qbman/qman.c +11 -4
index ff56f7b1ab..81b7ae5c37 100644
@@ -1588,6 +1588,7 @@ int qman_create_fq(u32 fqid, u32 flags, struct qman_fq *fq)
 	return -EIO;
 }
 
+RTE_EXPORT_INTERNAL_SYMBOL(qman_destroy_fq)
 void qman_destroy_fq(struct qman_fq *fq, u32 flags __maybe_unused)
 {
 	/*
@@ -2795,19 +2796,20 @@ qm_mc_result_timeout(struct qm_portal *portal,
 
 RTE_EXPORT_INTERNAL_SYMBOL(qman_shutdown_fq)
 int
-qman_shutdown_fq(u32 fqid)
+qman_shutdown_fq(struct qman_fq *fq)
 {
-	struct qman_portal *p;
+	struct qman_portal *p = fq->qp;
 	struct qm_mc_command *mcc;
 	struct qm_mc_result *mcr;
 	int orl_empty, drain = 0, ret = 0;
-	u32 res;
+	u32 res, fqid = fq->fqid;
 	u8 state;
 	u32 channel, wq;
 	u16 dest_wq;
 
 	DPAA_BUS_DEBUG("In shutdown for queue = %x", fqid);
-	p = get_affine_portal();
+	if (!p)
+		p = get_affine_portal();
 	/* Determine the state of the FQID */
 	mcc = qm_mc_start(&p->p);
 	mcc->queryfq_np.fqid = cpu_to_be32(fqid);
@@ -2986,6 +2988,11 @@ qman_shutdown_fq(u32 fqid)
 		ret = -EIO;
 	}
 
+	if (!ret) {
+		fq->state = qman_fq_state_oos;
+		qman_destroy_fq(fq, 0);
+	}
+
 out:
 	return ret;
 }
drivers/bus/dpaa/dpaa_bus_base_symbols.c +2 -0
index 522cdca27e..51c46f0f31 100644
@@ -51,6 +51,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(bman_acquire)
 RTE_EXPORT_INTERNAL_SYMBOL(bman_query_free_buffers)
 RTE_EXPORT_INTERNAL_SYMBOL(bman_thread_irq)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_fqid_range)
+RTE_EXPORT_INTERNAL_SYMBOL(qman_release_fqid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_reserve_fqid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_pool_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_cgrid_range)
@@ -77,6 +78,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(qman_dqrr_consume)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_static_dequeue_add)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_dca_index)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_create_fq)
+RTE_EXPORT_INTERNAL_SYMBOL(qman_destroy_fq)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_fq_fqid)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_fq_state)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_init_fq)
drivers/bus/dpaa/include/fsl_qman.h +12 -1
index 82269cdf99..5999a45b5f 100644
@@ -1577,6 +1577,7 @@ int qman_create_fq(u32 fqid, u32 flags, struct qman_fq *fq);
  * FQ must be in the 'out-of-service' state unless the QMAN_FQ_FREE_PARKED flag
  * is specified, in which case it may also be in the 'parked' state.
  */
+__rte_internal
 void qman_destroy_fq(struct qman_fq *fq, u32 flags);
 
 /**
@@ -1887,6 +1888,7 @@ static inline int qman_alloc_fqid(u32 *result)
  * This function can also be used to seed the allocator with ranges of FQIDs
  * that it can subsequently allocate from.
  */
+__rte_internal
 void qman_release_fqid_range(u32 fqid, unsigned int count);
 static inline void qman_release_fqid(u32 fqid)
 {
@@ -1896,7 +1898,16 @@ static inline void qman_release_fqid(u32 fqid)
 void qman_seed_fqid_range(u32 fqid, unsigned int count);
 
 __rte_internal
-int qman_shutdown_fq(u32 fqid);
+int qman_shutdown_fq(struct qman_fq *fq);
+
+static inline int qman_shutdown_fq_by_fqid(u32 fqid)
+{
+	struct qman_fq fq;
+
+	memset(&fq, 0, sizeof(struct qman_fq));
+	fq.fqid = fqid;
+	return qman_shutdown_fq(&fq);
+}
 
 /**
  * qman_reserve_fqid_range - Reserve the specified range of frame queue IDs
drivers/crypto/dpaa_sec/dpaa_sec.c +158 -18

226 lines not on this page · raw message

drivers/net/dpaa/dpaa_ethdev.c +1 -1
index 1aaf97f175..718ae6e3f7 100644
@@ -2355,7 +2355,7 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
 		/* Clean up a frame queue left behind by a previous run
 		 * before it is initialized.
 		 */
-		qman_shutdown_fq(fqid);
+		qman_shutdown_fq_by_fqid(fqid);
 
 		if (dpaa_intf->cgr_rx)
 			dpaa_intf->cgr_rx[loop].cgrid = cgrid[loop];
Signature · 1 line
2.25.1