From 4d51afb5cdb668d8fa9737f3a3665c14b868a5d0 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Sun, 29 Nov 2015 10:46:47 -0800 Subject: [PATCH] sched: keep track of RED drops Add new statistic to keep track of drops due to RED. Signed-off-by: Stephen Hemminger --- doc/guides/rel_notes/deprecation.rst | 3 --- lib/librte_sched/rte_sched.c | 20 ++++++++++++++++---- lib/librte_sched/rte_sched.h | 8 ++++++++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index a2017f163e..252a096e6a 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -33,6 +33,3 @@ Deprecation Notices * ABI changes are planned for adding four new flow types. This impacts RTE_ETH_FLOW_MAX. The release 2.2 does not contain these ABI changes, but release 2.3 will. - -* The scheduler statistics structure will change to allow keeping track of - RED actions. diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c index 513e89335e..89007ad117 100644 --- a/lib/librte_sched/rte_sched.c +++ b/lib/librte_sched/rte_sched.c @@ -1076,7 +1076,9 @@ rte_sched_port_update_subport_stats(struct rte_sched_port *port, uint32_t qindex } static inline void -rte_sched_port_update_subport_stats_on_drop(struct rte_sched_port *port, uint32_t qindex, struct rte_mbuf *pkt) +rte_sched_port_update_subport_stats_on_drop(struct rte_sched_port *port, + uint32_t qindex, + struct rte_mbuf *pkt, uint32_t red) { struct rte_sched_subport *s = port->subport + (qindex / rte_sched_port_queues_per_subport(port)); uint32_t tc_index = (qindex >> 2) & 0x3; @@ -1084,6 +1086,9 @@ rte_sched_port_update_subport_stats_on_drop(struct rte_sched_port *port, uint32_ s->stats.n_pkts_tc_dropped[tc_index] += 1; s->stats.n_bytes_tc_dropped[tc_index] += pkt_len; +#ifdef RTE_SCHED_RED + s->stats.n_pkts_red_dropped[tc_index] += red; +#endif } static inline void @@ -1097,13 +1102,18 @@ rte_sched_port_update_queue_stats(struct rte_sched_port *port, uint32_t qindex, } static inline void -rte_sched_port_update_queue_stats_on_drop(struct rte_sched_port *port, uint32_t qindex, struct rte_mbuf *pkt) +rte_sched_port_update_queue_stats_on_drop(struct rte_sched_port *port, + uint32_t qindex, + struct rte_mbuf *pkt, uint32_t red) { struct rte_sched_queue_extra *qe = port->queue_extra + qindex; uint32_t pkt_len = pkt->pkt_len; qe->stats.n_pkts_dropped += 1; qe->stats.n_bytes_dropped += pkt_len; +#ifdef RTE_SCHED_RED + qe->stats.n_pkts_red_dropped += red; +#endif } #endif /* RTE_SCHED_COLLECT_STATS */ @@ -1234,8 +1244,10 @@ rte_sched_port_enqueue_qwa(struct rte_sched_port *port, uint32_t qindex, (qlen >= qsize))) { rte_pktmbuf_free(pkt); #ifdef RTE_SCHED_COLLECT_STATS - rte_sched_port_update_subport_stats_on_drop(port, qindex, pkt); - rte_sched_port_update_queue_stats_on_drop(port, qindex, pkt); + rte_sched_port_update_subport_stats_on_drop(port, qindex, pkt, + qlen < qsize); + rte_sched_port_update_queue_stats_on_drop(port, qindex, pkt, + qlen < qsize); #endif return 0; } diff --git a/lib/librte_sched/rte_sched.h b/lib/librte_sched/rte_sched.h index c0f4ad355e..e9c281726a 100644 --- a/lib/librte_sched/rte_sched.h +++ b/lib/librte_sched/rte_sched.h @@ -162,6 +162,11 @@ struct rte_sched_subport_stats { /**< Number of bytes successfully written for each traffic class */ uint32_t n_bytes_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; /**< Number of bytes dropped for each traffic class */ + +#ifdef RTE_SCHED_RED + uint32_t n_pkts_red_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; + /**< Number of packets dropped by red */ +#endif }; /* @@ -196,6 +201,9 @@ struct rte_sched_queue_stats { /* Packets */ uint32_t n_pkts; /**< Packets successfully written */ uint32_t n_pkts_dropped; /**< Packets dropped */ +#ifdef RTE_SCHED_RED + uint32_t n_pkts_red_dropped; /**< Packets dropped by RED */ +#endif /* Bytes */ uint32_t n_bytes; /**< Bytes successfully written */ -- 2.20.1