[dpdk-dev] [PATCH 05/27] sched: update port free api

Lukasz Krakowiak lukaszx.krakowiak at intel.com
Tue May 28 14:05:31 CEST 2019


From: Jasvinder Singh <jasvinder.singh at intel.com>

Update the scheduler port free api implementation to allow configuration
flexiblity for pipe traffic classes and queues, and subport level
configuration of the pipe parameters.

Signed-off-by: Jasvinder Singh <jasvinder.singh at intel.com>
Signed-off-by: Abraham Tovar <abrahamx.tovar at intel.com>
Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak at intel.com>
---
 lib/librte_sched/rte_sched.c | 61 ++++++++++++++++++++++++++++--------
 1 file changed, 48 insertions(+), 13 deletions(-)

diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c
index 8f11b4597..39a6165e3 100644
--- a/lib/librte_sched/rte_sched.c
+++ b/lib/librte_sched/rte_sched.c
@@ -316,6 +316,29 @@ rte_sched_port_queues_per_subport(struct rte_sched_port *port)
 
 #endif
 
+static inline uint32_t
+rte_sched_subport_queues(struct rte_sched_subport *subport)
+{
+	return RTE_SCHED_QUEUES_PER_PIPE * subport->n_subport_pipes;
+}
+
+static inline struct rte_mbuf **
+rte_sched_subport_qbase(struct rte_sched_subport *subport, uint32_t qindex)
+{
+	uint32_t pindex = qindex >> 4;
+	uint32_t qpos = qindex & 0xF;
+
+	return (subport->queue_array + pindex *
+		subport->qsize_sum + subport->qsize_add[qpos]);
+}
+
+static inline uint16_t
+rte_sched_subport_qsize(struct rte_sched_subport *subport, uint32_t qindex)
+{
+	uint32_t qpos = qindex & 0xF;
+	return subport->qsize[qpos];
+}
+
 static inline uint32_t
 rte_sched_port_queues_per_port(struct rte_sched_port *port)
 {
@@ -647,28 +670,40 @@ rte_sched_port_config(struct rte_sched_port_params *params)
 void
 rte_sched_port_free(struct rte_sched_port *port)
 {
-	uint32_t qindex;
-	uint32_t n_queues_per_port;
+	uint32_t n_subport_queues;
+	uint32_t qindex, i;
 
 	/* Check user parameters */
 	if (port == NULL)
 		return;
 
-	n_queues_per_port = rte_sched_port_queues_per_port(port);
+	for (i = 0; i < port->n_subports_per_port; i++) {
+		struct rte_sched_subport *s = port->subports[i];
 
-	/* Free enqueued mbufs */
-	for (qindex = 0; qindex < n_queues_per_port; qindex++) {
-		struct rte_mbuf **mbufs = rte_sched_port_qbase(port, qindex);
-		uint16_t qsize = rte_sched_port_qsize(port, qindex);
-		struct rte_sched_queue *queue = port->queue + qindex;
-		uint16_t qr = queue->qr & (qsize - 1);
-		uint16_t qw = queue->qw & (qsize - 1);
+		if (s == NULL)
+			continue;
+
+		n_subport_queues = rte_sched_subport_queues(s);
+
+		/* Free enqueued mbufs */
+		for (qindex = 0; qindex < n_subport_queues; qindex++) {
+			struct rte_mbuf **mbufs =
+				rte_sched_subport_qbase(s, qindex);
+			uint16_t qsize = rte_sched_subport_qsize(s, qindex);
+			if (qsize != 0) {
+				struct rte_sched_queue *queue =
+					s->queue + qindex;
+				uint16_t qr = queue->qr & (qsize - 1);
+				uint16_t qw = queue->qw & (qsize - 1);
+
+				for (; qr != qw; qr = (qr + 1) & (qsize - 1))
+					rte_pktmbuf_free(mbufs[qr]);
+			}
+		}
 
-		for (; qr != qw; qr = (qr + 1) & (qsize - 1))
-			rte_pktmbuf_free(mbufs[qr]);
+		rte_bitmap_free(s->bmp);
 	}
 
-	rte_bitmap_free(port->bmp);
 	rte_free(port);
 }
 
-- 
2.20.1



More information about the dev mailing list