[dpdk-dev] [PATCH 10/27] sched: update subport and tc queue stats

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


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

Update subport and tc queue stats implementation of 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 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 | 46 +++++++++++++++++++-----------------
 1 file changed, 24 insertions(+), 22 deletions(-)

diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c
index d28d2d203..86f2bdf51 100644
--- a/lib/librte_sched/rte_sched.c
+++ b/lib/librte_sched/rte_sched.c
@@ -1412,7 +1412,7 @@ rte_sched_subport_read_stats(struct rte_sched_port *port,
 	    stats == NULL || tc_ov == NULL)
 		return -1;
 
-	s = port->subport + subport_id;
+	s = port->subports[subport_id];
 
 	/* Copy subport stats and clear */
 	memcpy(stats, &s->stats, sizeof(struct rte_sched_subport_stats));
@@ -1468,10 +1468,10 @@ rte_sched_port_queue_is_empty(struct rte_sched_port *port, uint32_t qindex)
 #ifdef RTE_SCHED_COLLECT_STATS
 
 static inline void
-rte_sched_port_update_subport_stats(struct rte_sched_port *port, uint32_t qindex, struct rte_mbuf *pkt)
+rte_sched_port_update_subport_stats(struct rte_sched_subport *s,
+	struct rte_mbuf *pkt)
 {
-	struct rte_sched_subport *s = port->subport + (qindex / rte_sched_port_queues_per_subport(port));
-	uint32_t tc_index = (qindex >> 2) & 0x3;
+	uint32_t tc_index = rte_mbuf_sched_traffic_class_get(pkt);
 	uint32_t pkt_len = pkt->pkt_len;
 
 	s->stats.n_pkts_tc[tc_index] += 1;
@@ -1480,31 +1480,31 @@ rte_sched_port_update_subport_stats(struct rte_sched_port *port, uint32_t qindex
 
 #ifdef RTE_SCHED_RED
 static inline void
-rte_sched_port_update_subport_stats_on_drop(struct rte_sched_port *port,
-						uint32_t qindex,
-						struct rte_mbuf *pkt, uint32_t red)
+rte_sched_port_update_subport_stats_on_drop(struct rte_sched_subport *subport,
+						struct rte_mbuf *pkt,
+						uint32_t red)
 #else
 static inline void
-rte_sched_port_update_subport_stats_on_drop(struct rte_sched_port *port,
-						uint32_t qindex,
-						struct rte_mbuf *pkt, __rte_unused uint32_t red)
+rte_sched_port_update_subport_stats_on_drop(struct rte_sched_subport *subport,
+						struct rte_mbuf *pkt,
+						__rte_unused uint32_t red)
 #endif
 {
-	struct rte_sched_subport *s = port->subport + (qindex / rte_sched_port_queues_per_subport(port));
-	uint32_t tc_index = (qindex >> 2) & 0x3;
+	uint32_t tc_index = rte_mbuf_sched_traffic_class_get(pkt);
 	uint32_t pkt_len = pkt->pkt_len;
 
-	s->stats.n_pkts_tc_dropped[tc_index] += 1;
-	s->stats.n_bytes_tc_dropped[tc_index] += pkt_len;
+	subport->stats.n_pkts_tc_dropped[tc_index] += 1;
+	subport->stats.n_bytes_tc_dropped[tc_index] += pkt_len;
 #ifdef RTE_SCHED_RED
-	s->stats.n_pkts_red_dropped[tc_index] += red;
+	subport->stats.n_pkts_red_dropped[tc_index] += red;
 #endif
 }
 
 static inline void
-rte_sched_port_update_queue_stats(struct rte_sched_port *port, uint32_t qindex, struct rte_mbuf *pkt)
+rte_sched_port_update_queue_stats(struct rte_sched_subport *subport,
+	uint32_t qindex, struct rte_mbuf *pkt)
 {
-	struct rte_sched_queue_extra *qe = port->queue_extra + qindex;
+	struct rte_sched_queue_extra *qe = subport->queue_extra + qindex;
 	uint32_t pkt_len = pkt->pkt_len;
 
 	qe->stats.n_pkts += 1;
@@ -1513,17 +1513,19 @@ rte_sched_port_update_queue_stats(struct rte_sched_port *port, uint32_t qindex,
 
 #ifdef RTE_SCHED_RED
 static inline void
-rte_sched_port_update_queue_stats_on_drop(struct rte_sched_port *port,
+rte_sched_port_update_queue_stats_on_drop(struct rte_sched_subport *subport,
 						uint32_t qindex,
-						struct rte_mbuf *pkt, uint32_t red)
+						struct rte_mbuf *pkt,
+						int32_t red)
 #else
 static inline void
-rte_sched_port_update_queue_stats_on_drop(struct rte_sched_port *port,
+rte_sched_port_update_queue_stats_on_drop(struct rte_sched_subport *subport,
 						uint32_t qindex,
-						struct rte_mbuf *pkt, __rte_unused uint32_t red)
+						struct rte_mbuf *pkt,
+						__rte_unused uint32_t red)
 #endif
 {
-	struct rte_sched_queue_extra *qe = port->queue_extra + qindex;
+	struct rte_sched_queue_extra *qe = subport->queue_extra + qindex;
 	uint32_t pkt_len = pkt->pkt_len;
 
 	qe->stats.n_pkts_dropped += 1;
-- 
2.20.1



More information about the dev mailing list