From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f169.google.com (mail-pd0-f169.google.com [209.85.192.169]) by dpdk.org (Postfix) with ESMTP id 86BE0DE0 for ; Tue, 9 Dec 2014 17:43:20 +0100 (CET) Received: by mail-pd0-f169.google.com with SMTP id z10so867780pdj.28 for ; Tue, 09 Dec 2014 08:43:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=PLPfg66oZYp7pnwnlRS3Fu012CrLCUcykX5P1mw/JGo=; b=IMuFVpTvuGDS3u6czbUDQotkUdk/6P/2XrVrggpQOkSnx4cuoikRlAFVwkS5bZKtK7 nxKaSMI9QKjJs1JxU5YOWcjqrEi2P9i/rtbfuOJFSZxwgr9mU6Ie/F10Je5f59NfPHnc VxyL8vpb++K78RJk1c0F2m7GagcbJhz2FeYD4lokML64fxgmE7JRk67liFqKVe7Th6lh fFhw6cwG5lfVMiodF3pNMsFx6FnaErFfXB9TEL/JsZ2fUIRKCoUYokSubcbU4lju7Zcf tfgyTnYHH7y634O1JJ7+PX0xvusE+SuYC+Xvc3UDpalq17jUnF/fji15ob1jeFjh+lFt jgQw== X-Gm-Message-State: ALoCoQktsZ4bGfNk9S6UlAuKaHvMwD/zVxEy0gIVCDF2+67P8C5Cgrd3mrv0K+xJjTDt4+XVOMPJ X-Received: by 10.70.31.35 with SMTP id x3mr32297593pdh.34.1418143399487; Tue, 09 Dec 2014 08:43:19 -0800 (PST) Received: from urahara (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by mx.google.com with ESMTPSA id 1sm1895305pdw.87.2014.12.09.08.43.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Dec 2014 08:43:18 -0800 (PST) Date: Tue, 9 Dec 2014 08:41:37 -0800 From: Stephen Hemminger To: dev@dpdk.org Message-ID: <20141209084137.6bbe0087@urahara> In-Reply-To: <20141209084026.2895154e@urahara> References: <20141209084026.2895154e@urahara> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: [dpdk-dev] [PATCH 3/4] rte_sched: don't clear statistics when read X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Dec 2014 16:43:22 -0000 Make rte_sched statistics API work like the ethernet statistics API. Don't auto-clear statistics when read. Signed-off-by: Stephen Hemminger --- 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 *