[v2,22/28] sched: update sched queue stats API

Message ID 20190625153217.24301-23-jasvinder.singh@intel.com (mailing list archive)
State Changes Requested, archived
Delegated to: Cristian Dumitrescu
Headers
Series sched: feature enhancements |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation fail Compilation issues

Commit Message

Jasvinder Singh June 25, 2019, 3:32 p.m. UTC
  Update queue stats read api implementation of the scheduler 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@intel.com>
Signed-off-by: Abraham Tovar <abrahamx.tovar@intel.com>
Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
---
 lib/librte_sched/rte_sched.c | 59 ++++++++++++++++++++++++------------
 1 file changed, 39 insertions(+), 20 deletions(-)
  

Patch

diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c
index 63073aad0..cc1dcf7ab 100644
--- a/lib/librte_sched/rte_sched.c
+++ b/lib/librte_sched/rte_sched.c
@@ -284,16 +284,6 @@  enum rte_sched_subport_array {
 	e_RTE_SCHED_SUBPORT_ARRAY_TOTAL,
 };
 
-#ifdef RTE_SCHED_COLLECT_STATS
-
-static inline uint32_t
-rte_sched_port_queues_per_subport(struct rte_sched_port *port)
-{
-	return RTE_SCHED_QUEUES_PER_PIPE * port->n_pipes_per_subport;
-}
-
-#endif
-
 static inline uint32_t
 rte_sched_subport_queues(struct rte_sched_subport *subport)
 {
@@ -318,9 +308,14 @@  rte_sched_subport_qsize(struct rte_sched_subport *subport, uint32_t qindex)
 }
 
 static inline uint32_t
-rte_sched_port_queues_per_port(struct rte_sched_port *port)
+rte_sched_port_queues(struct rte_sched_port *port)
 {
-	return RTE_SCHED_QUEUES_PER_PIPE * port->n_pipes_per_subport * port->n_subports_per_port;
+	uint32_t n_queues = 0, i;
+
+	for (i = 0; i < port->n_subports_per_port; i++)
+		n_queues += rte_sched_subport_queues(port->subports[i]);
+
+	return n_queues;
 }
 
 static int
@@ -1470,18 +1465,42 @@  rte_sched_queue_read_stats(struct rte_sched_port *port,
 	struct rte_sched_queue_stats *stats,
 	uint16_t *qlen)
 {
+	uint32_t subport_id, qindex;
+	struct rte_sched_subport *s;
 	struct rte_sched_queue *q;
 	struct rte_sched_queue_extra *qe;
 
 	/* Check user parameters */
-	if ((port == NULL) ||
-	    (queue_id >= rte_sched_port_queues_per_port(port)) ||
-		(stats == NULL) ||
-		(qlen == NULL)) {
-		return -1;
-	}
-	q = port->queue + queue_id;
-	qe = port->queue_extra + queue_id;
+	if (port == NULL) {
+		RTE_LOG(ERR, SCHED,
+			"%s: Incorrect value for parameter port \n", __func__);
+		return -EINVAL;
+	}
+
+	if (queue_id >= rte_sched_port_queues(port)) {
+		RTE_LOG(ERR, SCHED,
+			"%s: Incorrect value for queue id \n", __func__);
+		return -EINVAL;
+	}
+
+	if (stats == NULL) {
+		RTE_LOG(ERR, SCHED,
+			"%s: Incorrect value for parameter stats \n", __func__);
+		return -EINVAL;
+	}
+
+	if (qlen == NULL) {
+		RTE_LOG(ERR, SCHED,
+			"%s: Incorrect value for parameter qlen \n", __func__);
+		return -EINVAL;
+	}
+
+	subport_id = (queue_id >> (port->max_subport_pipes_log2 + 4)) &
+					(port->n_subports_per_port - 1);
+	s = port->subports[subport_id];
+	qindex = ((1 << (port->max_subport_pipes_log2 + 4)) - 1) & queue_id;
+	q = s->queue + qindex;
+	qe = s->queue_extra + qindex;
 
 	/* Copy queue stats and clear */
 	memcpy(stats, &qe->stats, sizeof(struct rte_sched_queue_stats));