From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <stephen@networkplumber.org>
Received: from mail-pa0-f42.google.com (mail-pa0-f42.google.com
 [209.85.220.42]) by dpdk.org (Postfix) with ESMTP id 470DC7E6A
 for <dev@dpdk.org>; Sun, 29 Nov 2015 19:46:44 +0100 (CET)
Received: by pacej9 with SMTP id ej9so160649333pac.2
 for <dev@dpdk.org>; Sun, 29 Nov 2015 10:46:43 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=networkplumber-org.20150623.gappssmtp.com; s=20150623;
 h=from:to:cc:subject:date:message-id:in-reply-to:references;
 bh=9cFMOljXf9MK6ZFMte+2ei1eBnn7s1NpDwTkukPnu7o=;
 b=Yq/5imDGAMfl6CZcuuvylgxOnDi7A3ZyF04TR+dddofM+Ydf6o3ZgCAL2kxYz7ULcU
 jXPxT2Fb1BpL4QXssrv8M4TSo4Sg5XcqFPQmpOV/HUNZ4QcFSqBnzkjAGbmvCzGn6+o8
 /yUePchqFHpQdLd7qmFwnfzfC/AlxG7v7kH1Tz9ti+5Qf1z9g8E2ckyn7942h8Yo3byO
 XmEGQ+uUCjijqX2l0qw3PeOSsJsFD/onqhT2Yel3g4UzRIwZzrAmgTClRSN7dCLIes1J
 c8WmAVN7MhGWGlpD5WV/ItlV77uQHXd8HZeS3Vn266cRvZkX9osm8mc3FYoMOBymK+2Z
 4LeQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20130820;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
 :references;
 bh=9cFMOljXf9MK6ZFMte+2ei1eBnn7s1NpDwTkukPnu7o=;
 b=JUG/nsotUJ0AokVVF3pSq4CwY0iJk9YyW+zv4jR1Ox+OkP0rxnCVMCm7RIHSCGeu9s
 EtOV0OKAAeQwdr9XG61ZrE/ea/nbWW2CTXDfFmRB9HPC4NEIl9ZOGCCwCMwWBsDe1oC2
 +rpZ1IpNKY3BLOVuXogKvonK5e1pVfUM3NOc+0PsR4+EAuchr9lM5skNkN+btCTHl+Wa
 Hq1n0ICCTWiGTkMk+Diy+rat6NTecfeJ3YyLIHU3+cnMkl2xW+heOY6sDtXwRUbm3MlY
 nDSFaH6HrDaKVFev9+t4Vt920hTRioqCd7ET7/6l0BvDWKEqONqkieTxPbt0jtfUnVXf
 9JuA==
X-Gm-Message-State: ALoCoQnnq/NhBGRFHbzvL/uFyffBwzbpJqA8UrKd/zvpdbaHq8WLpvFJfWuHa4Nisq9+h8K7T8dp
X-Received: by 10.66.65.234 with SMTP id a10mr39047598pat.129.1448822803592;
 Sun, 29 Nov 2015 10:46:43 -0800 (PST)
Received: from xeon-e3.home.lan (static-50-53-82-155.bvtn.or.frontiernet.net.
 [50.53.82.155])
 by smtp.gmail.com with ESMTPSA id qn5sm46905832pac.41.2015.11.29.10.46.42
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);
 Sun, 29 Nov 2015 10:46:42 -0800 (PST)
From: Stephen Hemminger <stephen@networkplumber.org>
To: cristian.dumitrescu@intel.com
Date: Sun, 29 Nov 2015 10:46:47 -0800
Message-Id: <1448822809-8350-2-git-send-email-stephen@networkplumber.org>
X-Mailer: git-send-email 2.1.4
In-Reply-To: <1448822809-8350-1-git-send-email-stephen@networkplumber.org>
References: <1448822809-8350-1-git-send-email-stephen@networkplumber.org>
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 1/3] rte_sched: keep track of RED drops
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Sun, 29 Nov 2015 18:46:44 -0000

Add new statistic to keep track of drops due to RED.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_sched/rte_sched.c | 20 ++++++++++++++++----
 lib/librte_sched/rte_sched.h |  8 ++++++++
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c
index d47cfc2..16acd6b 100644
--- a/lib/librte_sched/rte_sched.c
+++ b/lib/librte_sched/rte_sched.c
@@ -1071,7 +1071,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;
@@ -1079,6 +1081,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
@@ -1092,13 +1097,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 */
@@ -1229,8 +1239,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 c0f4ad3..e9c2817 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.1.4