From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by dpdk.org (Postfix) with ESMTP id 97BCA160 for ; Wed, 18 Jul 2018 16:51:48 +0200 (CEST) Received: by mail-wr1-f66.google.com with SMTP id h9-v6so5005221wro.3 for ; Wed, 18 Jul 2018 07:51:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=D2yfzZuQTqTIX4TWyRDjG/8+mrMNM9JoCil68gt6fZo=; b=sXrEoyPW5ex07xcf6Q3gCTt+VY6sjEBTVcMaIdz57UDSqyeVkFM56w4I3okIfc9Krl i4p0bBPKv2sI+AXLje4MJ5/M7GV7FFK+jROBYXGGslAGyhI7LzHL2o4QngoqRQdNSNSG QwE9pj1utnf5d966bhJPbYNhVnnOGVLKqI9y8UIg856wGg2lnGuKcuDaVYHHvZ28fO9T 1D2Uv9DuV2cx+wSzDyUvXuuBajzqCuPuXtxu203R1CKQN70YJXnPAmX6po3IHu7I972K 3wLmuO3i7TbDW0YVF+m9FjXtIqra9RYrqEK7zvpP5xnHokUxzZbGnl360M3xLNlCC88a zltQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=D2yfzZuQTqTIX4TWyRDjG/8+mrMNM9JoCil68gt6fZo=; b=ZOUx07YiCSiHqp7pmRVTXt9Ogn2DkWa8wHltTxHa/id/xnc+E/atIcZuWofq3jjxOt ynnrkJOZfKtYYQHQk39sH3uvhXWT+0zJL9IvAX/p0C5DiBqDoqMFbhG6/YoygxxNlKR6 8ZzHfoyuWXQL163DikGUbpW5FFNItT/SMyUi5cnTnmTLDSf73eXPg63J8xVHrDXYaY2k GBghLi4hD2xWx1K8uwpHzC9rMSYUccs7k2WdfiUFQczcdkGsJzzUOx/fVMiiOwpuik5r pcPxE+idjwOm8GQZbtjeiZukh7WCjWykPDqNEUWnpPcXHLlW2pMIasdLLeRFwHOmZtRY 9jhw== X-Gm-Message-State: AOUpUlGFIE9iuy1i4kIhT42qKrt8/DWkF6zsVXXgwJps/GHFZJ2E4CTl zNHIkNYNXGb1aGTOibUbkA== X-Google-Smtp-Source: AAOMgpcKMcpGpzlHlu3z3XNw4UsTo1TXH4kpXWy68UyUd+iwnnojkZQEIpyDQCK80TtUyOIzxL+AMA== X-Received: by 2002:adf:93a3:: with SMTP id 32-v6mr4592287wrp.140.1531925508248; Wed, 18 Jul 2018 07:51:48 -0700 (PDT) Received: from adewar-Precision-7520.edi.vyatta.net ([2001:1be0:110d:fcfe:38af:162c:e143:97d7]) by smtp.gmail.com with ESMTPSA id c5-v6sm5024854wrh.36.2018.07.18.07.51.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Jul 2018 07:51:47 -0700 (PDT) From: alangordondewar@gmail.com X-Google-Original-From: alan.dewar@att.com To: cristian.dumitrescu@intel.com Cc: dev@dpdk.org, Alan Dewar Date: Wed, 18 Jul 2018 15:51:39 +0100 Message-Id: <1531925499-938-1-git-send-email-alan.dewar@att.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH] sched: add 64-bit counter retrieval API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jul 2018 14:51:48 -0000 From: Alan Dewar Add new APIs to retrieve counters in 64-bit wide fields. Signed-off-by: Alan Dewar --- lib/librte_sched/rte_sched.c | 72 ++++++++++++++++++++++++++++++++ lib/librte_sched/rte_sched.h | 76 ++++++++++++++++++++++++++++++++++ lib/librte_sched/rte_sched_version.map | 2 + 3 files changed, 150 insertions(+) diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c index 9269e5c..4396366 100644 --- a/lib/librte_sched/rte_sched.c +++ b/lib/librte_sched/rte_sched.c @@ -1070,6 +1070,43 @@ rte_sched_subport_read_stats(struct rte_sched_port *port, return 0; } +int __rte_experimental +rte_sched_subport_read_stats64(struct rte_sched_port *port, + uint32_t subport_id, + struct rte_sched_subport_stats64 *stats64, + uint32_t *tc_ov) +{ + struct rte_sched_subport *s; + uint32_t tc; + + /* Check user parameters */ + if (port == NULL || subport_id >= port->n_subports_per_port || + stats64 == NULL || tc_ov == NULL) + return -1; + + s = port->subport + subport_id; + + /* Copy subport stats and clear */ + for (tc = 0; tc < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; tc++) { + stats64->n_pkts_tc[tc] = s->stats.n_pkts_tc[tc]; + stats64->n_pkts_tc_dropped[tc] = + s->stats.n_pkts_tc_dropped[tc]; + stats64->n_bytes_tc[tc] = s->stats.n_bytes_tc[tc]; + stats64->n_bytes_tc_dropped[tc] = + s->stats.n_bytes_tc_dropped[tc]; +#ifdef RTE_SCHED_RED + stats64->n_pkts_red_dropped[tc] = + s->stats.n_pkts_red_dropped[tc]; +#endif + } + memset(&s->stats, 0, sizeof(struct rte_sched_subport_stats)); + + /* Subport TC oversubscription status */ + *tc_ov = s->tc_ov; + + return 0; +} + int rte_sched_queue_read_stats(struct rte_sched_port *port, uint32_t queue_id, @@ -1099,6 +1136,41 @@ rte_sched_queue_read_stats(struct rte_sched_port *port, return 0; } +int __rte_experimental +rte_sched_queue_read_stats64(struct rte_sched_port *port, + uint32_t queue_id, + struct rte_sched_queue_stats64 *stats64, + uint16_t *qlen) +{ + struct rte_sched_queue *q; + struct rte_sched_queue_extra *qe; + + /* Check user parameters */ + if ((port == NULL) || + (queue_id >= rte_sched_port_queues_per_port(port)) || + (stats64 == NULL) || + (qlen == NULL)) { + return -1; + } + q = port->queue + queue_id; + qe = port->queue_extra + queue_id; + + /* Copy queue stats and clear */ + stats64->n_pkts = qe->stats.n_pkts; + stats64->n_pkts_dropped = qe->stats.n_pkts_dropped; + stats64->n_bytes = qe->stats.n_bytes; + stats64->n_bytes_dropped = qe->stats.n_bytes_dropped; +#ifdef RTE_SCHED_RED + stats64->n_pkts_red_dropped = qe->stats.n_pkts_red_dropped; +#endif + memset(&qe->stats, 0, sizeof(struct rte_sched_queue_stats)); + + /* Queue length */ + *qlen = q->qw - q->qr; + + 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) { diff --git a/lib/librte_sched/rte_sched.h b/lib/librte_sched/rte_sched.h index 84fa896..f37a4d6 100644 --- a/lib/librte_sched/rte_sched.h +++ b/lib/librte_sched/rte_sched.h @@ -141,6 +141,25 @@ struct rte_sched_subport_stats { #endif }; +struct rte_sched_subport_stats64 { + /* Packets */ + uint64_t n_pkts_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; + /**< Number of packets successfully written */ + uint64_t n_pkts_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; + /**< Number of packets dropped */ + + /* Bytes */ + uint64_t n_bytes_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; + /**< Number of bytes successfully written for each traffic class */ + uint64_t n_bytes_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; + /**< Number of bytes dropped for each traffic class */ + +#ifdef RTE_SCHED_RED + uint64_t n_pkts_red_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; + /**< Number of packets dropped by red */ +#endif +}; + /* * Pipe configuration parameters. The period and credits_per_period * parameters are measured in bytes, with one byte meaning the time @@ -182,6 +201,19 @@ struct rte_sched_queue_stats { uint32_t n_bytes_dropped; /**< Bytes dropped */ }; +struct rte_sched_queue_stats64 { + /* Packets */ + uint64_t n_pkts; /**< Packets successfully written */ + uint64_t n_pkts_dropped; /**< Packets dropped */ +#ifdef RTE_SCHED_RED + uint64_t n_pkts_red_dropped; /**< Packets dropped by RED */ +#endif + + /* Bytes */ + uint64_t n_bytes; /**< Bytes successfully written */ + uint64_t n_bytes_dropped; /**< Bytes dropped */ +}; + /** Port configuration parameters. */ struct rte_sched_port_params { const char *name; /**< String to be associated */ @@ -330,6 +362,28 @@ rte_sched_subport_read_stats(struct rte_sched_port *port, uint32_t *tc_ov); /** + * Hierarchical scheduler subport statistics 64-bit read + * + * @param port + * Handle to port scheduler instance + * @param subport_id + * Subport ID + * @param stats64 + * Pointer to pre-allocated subport statistics structure where the 64-bit + * statistics counters should be stored + * @param tc_ov + * Pointer to pre-allocated 4-entry array where the oversubscription status + * for each of the 4 subport traffic classes should be stored. + * @return + * 0 upon success, error code otherwise + */ +int __rte_experimental +rte_sched_subport_read_stats64(struct rte_sched_port *port, + uint32_t subport_id, + struct rte_sched_subport_stats64 *stats64, + uint32_t *tc_ov); + +/** * Hierarchical scheduler queue statistics read * * @param port @@ -352,6 +406,28 @@ rte_sched_queue_read_stats(struct rte_sched_port *port, uint16_t *qlen); /** + * Hierarchical scheduler queue statistics 64-bit read + * + * @param port + * Handle to port scheduler instance + * @param queue_id + * Queue ID within port scheduler + * @param stats + * Pointer to pre-allocated subport statistics structure where the + * 64-bit statistics counters should be stored + * @param qlen + * Pointer to pre-allocated variable where the current queue length + * should be stored. + * @return + * 0 upon success, error code otherwise + */ +int __rte_experimental +rte_sched_queue_read_stats64(struct rte_sched_port *port, + uint32_t queue_id, + struct rte_sched_queue_stats64 *stats64, + uint16_t *qlen); + +/** * Scheduler hierarchy path write to packet descriptor. Typically * called by the packet classification stage. * diff --git a/lib/librte_sched/rte_sched_version.map b/lib/librte_sched/rte_sched_version.map index 7295887..01bf71a 100644 --- a/lib/librte_sched/rte_sched_version.map +++ b/lib/librte_sched/rte_sched_version.map @@ -34,4 +34,6 @@ EXPERIMENTAL { global: rte_sched_port_pipe_profile_add; + rte_sched_subport_read_stats64; + rte_sched_queue_read_stats64; }; -- 2.7.4