From patchwork Tue Jun 25 15:31:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jasvinder Singh X-Patchwork-Id: 55334 X-Patchwork-Delegate: cristian.dumitrescu@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4BB861BB20; Tue, 25 Jun 2019 17:32:27 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 727391BA90 for ; Tue, 25 Jun 2019 17:32:14 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jun 2019 08:32:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,416,1557212400"; d="scan'208";a="166711493" Received: from silpixa00381635.ir.intel.com (HELO silpixa00381635.ger.corp.intel.com) ([10.237.223.4]) by orsmga006.jf.intel.com with ESMTP; 25 Jun 2019 08:32:12 -0700 From: Jasvinder Singh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com, Abraham Tovar , Lukasz Krakowiak Date: Tue, 25 Jun 2019 16:31:59 +0100 Message-Id: <20190625153217.24301-11-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190625153217.24301-1-jasvinder.singh@intel.com> References: <20190528120553.2992-2-lukaszx.krakowiak@intel.com> <20190625153217.24301-1-jasvinder.singh@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 10/28] sched: update subport and tc queue stats 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Update subport and tc queue stats api mplementation to allow configuration flexiblity for pipe traffic classes and queues, and subport level configuration of the pipe parameters. Signed-off-by: Jasvinder Singh Signed-off-by: Abraham Tovar Signed-off-by: Lukasz Krakowiak --- lib/librte_sched/rte_sched.c | 74 +++++++++++++++++++++++------------- lib/librte_sched/rte_sched.h | 34 ++++++++++------- 2 files changed, 68 insertions(+), 40 deletions(-) diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c index cd82fd918..7a4c7cf12 100644 --- a/lib/librte_sched/rte_sched.c +++ b/lib/librte_sched/rte_sched.c @@ -1490,11 +1490,31 @@ rte_sched_subport_read_stats(struct rte_sched_port *port, struct rte_sched_subport *s; /* Check user parameters */ - if (port == NULL || subport_id >= port->n_subports_per_port || - stats == NULL || tc_ov == NULL) - return -1; + if (port == NULL) { + RTE_LOG(ERR, SCHED, + "%s: Incorrect value for parameter port \n", __func__); + return -EINVAL; + } - s = port->subport + subport_id; + if (subport_id >= port->n_subports_per_port) { + RTE_LOG(ERR, SCHED, + "%s: Incorrect value for subport id \n", __func__); + return -EINVAL; + } + + if (stats == NULL) { + RTE_LOG(ERR, SCHED, + "%s: Incorrect value for parameter stats \n", __func__); + return -EINVAL; + } + + if (tc_ov == NULL) { + RTE_LOG(ERR, SCHED, + "%s: Incorrect value for tc_ov \n", __func__); + return -EINVAL; + } + + s = port->subports[subport_id]; /* Copy subport stats and clear */ memcpy(stats, &s->stats, sizeof(struct rte_sched_subport_stats)); @@ -1550,10 +1570,10 @@ rte_sched_port_queue_is_empty(struct rte_sched_port *port, uint32_t qindex) #ifdef RTE_SCHED_COLLECT_STATS static inline void -rte_sched_port_update_subport_stats(struct rte_sched_port *port, uint32_t qindex, struct rte_mbuf *pkt) +rte_sched_port_update_subport_stats(struct rte_sched_subport *s, + struct rte_mbuf *pkt) { - struct rte_sched_subport *s = port->subport + (qindex / rte_sched_port_queues_per_subport(port)); - uint32_t tc_index = (qindex >> 2) & 0x3; + uint32_t tc_index = rte_mbuf_sched_traffic_class_get(pkt); uint32_t pkt_len = pkt->pkt_len; s->stats.n_pkts_tc[tc_index] += 1; @@ -1562,31 +1582,31 @@ rte_sched_port_update_subport_stats(struct rte_sched_port *port, uint32_t qindex #ifdef RTE_SCHED_RED static inline void -rte_sched_port_update_subport_stats_on_drop(struct rte_sched_port *port, - uint32_t qindex, - struct rte_mbuf *pkt, uint32_t red) +rte_sched_port_update_subport_stats_on_drop(struct rte_sched_subport *subport, + struct rte_mbuf *pkt, + uint32_t red) #else static inline void -rte_sched_port_update_subport_stats_on_drop(struct rte_sched_port *port, - uint32_t qindex, - struct rte_mbuf *pkt, __rte_unused uint32_t red) +rte_sched_port_update_subport_stats_on_drop(struct rte_sched_subport *subport, + struct rte_mbuf *pkt, + __rte_unused uint32_t red) #endif { - struct rte_sched_subport *s = port->subport + (qindex / rte_sched_port_queues_per_subport(port)); - uint32_t tc_index = (qindex >> 2) & 0x3; + uint32_t tc_index = rte_mbuf_sched_traffic_class_get(pkt); uint32_t pkt_len = pkt->pkt_len; - s->stats.n_pkts_tc_dropped[tc_index] += 1; - s->stats.n_bytes_tc_dropped[tc_index] += pkt_len; + subport->stats.n_pkts_tc_dropped[tc_index] += 1; + subport->stats.n_bytes_tc_dropped[tc_index] += pkt_len; #ifdef RTE_SCHED_RED - s->stats.n_pkts_red_dropped[tc_index] += red; + subport->stats.n_pkts_red_dropped[tc_index] += red; #endif } static inline void -rte_sched_port_update_queue_stats(struct rte_sched_port *port, uint32_t qindex, struct rte_mbuf *pkt) +rte_sched_port_update_queue_stats(struct rte_sched_subport *subport, + uint32_t qindex, struct rte_mbuf *pkt) { - struct rte_sched_queue_extra *qe = port->queue_extra + qindex; + struct rte_sched_queue_extra *qe = subport->queue_extra + qindex; uint32_t pkt_len = pkt->pkt_len; qe->stats.n_pkts += 1; @@ -1595,17 +1615,19 @@ rte_sched_port_update_queue_stats(struct rte_sched_port *port, uint32_t qindex, #ifdef RTE_SCHED_RED static inline void -rte_sched_port_update_queue_stats_on_drop(struct rte_sched_port *port, +rte_sched_port_update_queue_stats_on_drop(struct rte_sched_subport *subport, uint32_t qindex, - struct rte_mbuf *pkt, uint32_t red) + struct rte_mbuf *pkt, + int32_t red) #else static inline void -rte_sched_port_update_queue_stats_on_drop(struct rte_sched_port *port, +rte_sched_port_update_queue_stats_on_drop(struct rte_sched_subport *subport, uint32_t qindex, - struct rte_mbuf *pkt, __rte_unused uint32_t red) + struct rte_mbuf *pkt, + __rte_unused uint32_t red) #endif { - struct rte_sched_queue_extra *qe = port->queue_extra + qindex; + struct rte_sched_queue_extra *qe = subport->queue_extra + qindex; uint32_t pkt_len = pkt->pkt_len; qe->stats.n_pkts_dropped += 1; @@ -1626,7 +1648,7 @@ rte_sched_port_red_drop(struct rte_sched_port *port, struct rte_mbuf *pkt, uint3 struct rte_red_config *red_cfg; struct rte_red *red; uint32_t tc_index; - enum rte_color color; + enum rte_meter_color color; tc_index = (qindex >> 2) & 0x3; color = rte_sched_port_pkt_read_color(pkt); diff --git a/lib/librte_sched/rte_sched.h b/lib/librte_sched/rte_sched.h index 6a6ea84aa..05f518457 100644 --- a/lib/librte_sched/rte_sched.h +++ b/lib/librte_sched/rte_sched.h @@ -195,36 +195,42 @@ struct rte_sched_subport_params { /** Subport statistics */ struct rte_sched_subport_stats { - /* Packets */ + /** Number of packets successfully written */ uint32_t n_pkts_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; - /**< Number of packets successfully written */ + + /** Number of packets dropped */ uint32_t n_pkts_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; - /**< Number of packets dropped */ - /* Bytes */ + /** Number of bytes successfully written for each traffic class */ uint32_t n_bytes_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; - /**< Number of bytes successfully written for each traffic class */ + + /** Number of bytes dropped 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 + /** Number of packets dropped by red */ uint32_t n_pkts_red_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; - /**< Number of packets dropped by red */ #endif }; /** Queue statistics */ struct rte_sched_queue_stats { - /* Packets */ - uint32_t n_pkts; /**< Packets successfully written */ - uint32_t n_pkts_dropped; /**< Packets dropped */ + /** Packets successfully written */ + uint32_t n_pkts; + + /** Packets dropped */ + uint32_t n_pkts_dropped; + #ifdef RTE_SCHED_RED - uint32_t n_pkts_red_dropped; /**< Packets dropped by RED */ + /** Packets dropped by RED */ + uint32_t n_pkts_red_dropped; #endif - /* Bytes */ - uint32_t n_bytes; /**< Bytes successfully written */ - uint32_t n_bytes_dropped; /**< Bytes dropped */ + /** Bytes successfully written */ + uint32_t n_bytes; + + /** Bytes dropped */ + uint32_t n_bytes_dropped; }; /** Port configuration parameters. */