DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 3/4] rte_sched: don't clear statistics when read
Date: Tue, 9 Dec 2014 08:41:37 -0800	[thread overview]
Message-ID: <20141209084137.6bbe0087@urahara> (raw)
In-Reply-To: <20141209084026.2895154e@urahara>

Make rte_sched statistics API work like the ethernet statistics API.
Don't auto-clear statistics when read.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

--- a/lib/librte_sched/rte_sched.c	2014-12-08 09:29:49.014821607 -0800
+++ b/lib/librte_sched/rte_sched.c	2014-12-08 09:35:45.568568267 -0800
@@ -924,9 +924,8 @@ rte_sched_subport_read_stats(struct rte_
 	}
 	s = port->subport + subport_id;
 
-	/* Copy subport stats and clear */
-	memcpy(stats, &s->stats, sizeof(struct rte_sched_subport_stats));
-	memset(&s->stats, 0, sizeof(struct rte_sched_subport_stats));
+	/* Copy subport stats */
+	*stats = s->stats;
 
 	/* Subport TC ovesubscription status */
 	*tc_ov = s->tc_ov;
@@ -935,6 +934,21 @@ rte_sched_subport_read_stats(struct rte_
 }
 
 int
+rte_sched_subport_stats_reset(struct rte_sched_port *port,
+			      uint32_t subport_id)
+{
+	struct rte_sched_subport *s;
+
+	/* Check user parameters */
+	if (port == NULL || subport_id >= port->n_subports_per_port)
+		return -1;
+
+	s = port->subport + subport_id;
+	memset(&s->stats, 0, sizeof(struct rte_sched_subport_stats));
+	return 0;
+}
+
+int
 rte_sched_queue_read_stats(struct rte_sched_port *port,
 	uint32_t queue_id,
 	struct rte_sched_queue_stats *stats,
@@ -953,9 +967,8 @@ rte_sched_queue_read_stats(struct rte_sc
 	q = port->queue + queue_id;
 	qe = port->queue_extra + queue_id;
 
-	/* Copy queue stats and clear */
-	memcpy(stats, &qe->stats, sizeof(struct rte_sched_queue_stats));
-	memset(&qe->stats, 0, sizeof(struct rte_sched_queue_stats));
+	/* Copy queue stats */
+	*stats = qe->stats;
 
 	/* Queue length */
 	*qlen = q->qw - q->qr;
@@ -963,6 +976,21 @@ rte_sched_queue_read_stats(struct rte_sc
 	return 0;
 }
 
+int
+rte_sched_queue_stats_reset(struct rte_sched_port *port,
+			    uint32_t queue_id)
+{
+	struct rte_sched_queue_extra *qe;
+
+	/* Check user parameters */
+	if (port == NULL || queue_id >= rte_sched_port_queues_per_port(port))
+		return -1;
+
+	qe = port->queue_extra + queue_id;
+	memset(&qe->stats, 0, sizeof(struct rte_sched_queue_stats));
+	return 0;
+}
+
 static inline uint32_t
 rte_sched_port_qindex(struct rte_sched_port *port, uint32_t subport, uint32_t pipe, uint32_t traffic_class, uint32_t queue)
 {
--- a/lib/librte_sched/rte_sched.h	2014-12-08 09:29:49.014821607 -0800
+++ b/lib/librte_sched/rte_sched.h	2014-12-08 09:30:29.426977482 -0800
@@ -312,6 +312,21 @@ rte_sched_subport_read_stats(struct rte_
 	struct rte_sched_subport_stats *stats,
 	uint32_t *tc_ov);
 
+
+/**
+ * Hierarchical scheduler subport statistics reset
+ *
+ * @param port
+ *   Handle to port scheduler instance
+ * @param subport_id
+ *   Subport ID
+ * @return
+ *   0 upon success, error code otherwise
+ */
+int
+rte_sched_subport_stats_reset(struct rte_sched_port *port,
+			      uint32_t subport_id);
+
 /**
  * Hierarchical scheduler queue statistics read
  *
@@ -333,6 +348,20 @@ rte_sched_queue_read_stats(struct rte_sc
 	struct rte_sched_queue_stats *stats,
 	uint16_t *qlen);
 
+/**
+ * Hierarchical scheduler queue statistics reset
+ *
+ * @param port
+ *   Handle to port scheduler instance
+ * @param queue_id
+ *   Queue ID within port scheduler
+ * @return
+ *   0 upon success, error code otherwise
+ */
+int
+rte_sched_queue_stats_reset(struct rte_sched_port *port,
+			    uint32_t queue_id);
+
 /*
  * Run-time
  *

  reply	other threads:[~2014-12-09 16:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-09 16:40 [dpdk-dev] [PATCH 1/4] rte_sched: make RED optional at runtime Stephen Hemminger
2014-12-09 16:41 ` Stephen Hemminger [this message]
2014-12-09 16:42 ` [dpdk-dev] [PATCH 4/4] rte_sched: don't put tabs in log messages Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141209084137.6bbe0087@urahara \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).