[10/15] sched: update queue stats read for config flexibility
diff mbox series

Message ID 20190823144602.58213-11-jasvinder.singh@intel.com
State Superseded, archived
Delegated to: Cristian Dumitrescu
Headers show
Series
  • sched: subport level configuration of pipe nodes
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Jasvinder Singh Aug. 23, 2019, 2:45 p.m. UTC
Modify pipe queue stats read function to allow different subports
of the same port to have different configuration in terms of number
of pipes, pipe queue sizes, etc.

Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
---
 lib/librte_sched/rte_sched.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

Patch
diff mbox series

diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c
index e0ef86f40..8a7727286 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_pipe_queues(struct rte_sched_subport *subport)
 {
@@ -322,7 +312,12 @@  struct rte_sched_subport *subport, uint32_t qindex)
 static inline uint32_t
 rte_sched_port_queues_per_port(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_pipe_queues(port->subports[i]);
+
+	return n_queues;
 }
 
 static inline uint16_t
@@ -1487,8 +1482,10 @@  rte_sched_queue_read_stats(struct rte_sched_port *port,
 	struct rte_sched_queue_stats *stats,
 	uint16_t *qlen)
 {
+	struct rte_sched_subport *s;
 	struct rte_sched_queue *q;
 	struct rte_sched_queue_extra *qe;
+	uint32_t subport_id, subport_qmask, subport_qindex;
 
 	/* Check user parameters */
 	if (port == NULL) {
@@ -1514,8 +1511,13 @@  rte_sched_queue_read_stats(struct rte_sched_port *port,
 			"%s: Incorrect value for parameter qlen\n", __func__);
 		return -EINVAL;
 	}
-	q = port->queue + queue_id;
-	qe = port->queue_extra + queue_id;
+	subport_qmask = port->n_max_pipes_per_subport_log2 + 4;
+	subport_id = (queue_id >> subport_qmask) & (port->n_subports_per_port - 1);
+
+	s = port->subports[subport_id];
+	subport_qindex = ((1 << subport_qmask) - 1) & queue_id;
+	q = s->queue + subport_qindex;
+	qe = s->queue_extra + subport_qindex;
 
 	/* Copy queue stats and clear */
 	memcpy(stats, &qe->stats, sizeof(struct rte_sched_queue_stats));