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(-)
@@ -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));