From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id C981D8DA2 for ; Mon, 2 Nov 2015 11:19:19 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 02 Nov 2015 02:19:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,234,1444719600"; d="scan'208";a="840505386" Received: from sie-lab-212-222.ir.intel.com (HELO silpixa00366884.ir.intel.com) ([10.237.212.222]) by orsmga002.jf.intel.com with ESMTP; 02 Nov 2015 02:19:18 -0800 From: Harry van Haaren To: dev@dpdk.org Date: Mon, 2 Nov 2015 10:18:59 +0000 Message-Id: <1446459547-1754-3-git-send-email-harry.van.haaren@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1446459547-1754-1-git-send-email-harry.van.haaren@intel.com> References: <1446204998-17151-2-git-send-email-harry.van.haaren@intel.com> <1446459547-1754-1-git-send-email-harry.van.haaren@intel.com> Subject: [dpdk-dev] [PATCH v5 02/10] ethdev: update xstats_get() strings and Q handling 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: Mon, 02 Nov 2015 10:19:20 -0000 Update the strings used for presenting stats to adhere to the scheme previously presented. Updated xstats_get() function to handle Q information only if xstats() is not implemented in the PMD, providing the PMD with the needed flexibility to expose its extended Q stats. Signed-off-by: Harry van Haaren --- lib/librte_ether/rte_ethdev.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index f593f6e..07f0c26 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -137,27 +137,30 @@ struct rte_eth_xstats_name_off { }; static const struct rte_eth_xstats_name_off rte_stats_strings[] = { - {"rx_packets", offsetof(struct rte_eth_stats, ipackets)}, - {"tx_packets", offsetof(struct rte_eth_stats, opackets)}, - {"rx_bytes", offsetof(struct rte_eth_stats, ibytes)}, - {"tx_bytes", offsetof(struct rte_eth_stats, obytes)}, - {"tx_errors", offsetof(struct rte_eth_stats, oerrors)}, + {"rx_good_packets", offsetof(struct rte_eth_stats, ipackets)}, + {"tx_good_packets", offsetof(struct rte_eth_stats, opackets)}, + {"rx_good_bytes", offsetof(struct rte_eth_stats, ibytes)}, + {"tx_good_bytes", offsetof(struct rte_eth_stats, obytes)}, {"rx_errors", offsetof(struct rte_eth_stats, ierrors)}, - {"alloc_rx_buff_failed", offsetof(struct rte_eth_stats, rx_nombuf)}, + {"tx_errors", offsetof(struct rte_eth_stats, oerrors)}, + {"rx_mbuf_allocation_errors", offsetof(struct rte_eth_stats, + rx_nombuf)}, }; + #define RTE_NB_STATS (sizeof(rte_stats_strings) / sizeof(rte_stats_strings[0])) static const struct rte_eth_xstats_name_off rte_rxq_stats_strings[] = { - {"rx_packets", offsetof(struct rte_eth_stats, q_ipackets)}, - {"rx_bytes", offsetof(struct rte_eth_stats, q_ibytes)}, + {"packets", offsetof(struct rte_eth_stats, q_ipackets)}, + {"bytes", offsetof(struct rte_eth_stats, q_ibytes)}, + {"errors", offsetof(struct rte_eth_stats, q_errors)}, }; + #define RTE_NB_RXQ_STATS (sizeof(rte_rxq_stats_strings) / \ sizeof(rte_rxq_stats_strings[0])) static const struct rte_eth_xstats_name_off rte_txq_stats_strings[] = { - {"tx_packets", offsetof(struct rte_eth_stats, q_opackets)}, - {"tx_bytes", offsetof(struct rte_eth_stats, q_obytes)}, - {"tx_errors", offsetof(struct rte_eth_stats, q_errors)}, + {"packets", offsetof(struct rte_eth_stats, q_opackets)}, + {"bytes", offsetof(struct rte_eth_stats, q_obytes)}, }; #define RTE_NB_TXQ_STATS (sizeof(rte_txq_stats_strings) / \ sizeof(rte_txq_stats_strings[0])) @@ -1666,8 +1669,6 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats, /* Return generic statistics */ count = RTE_NB_STATS; - count += dev->data->nb_rx_queues * RTE_NB_RXQ_STATS; - count += dev->data->nb_tx_queues * RTE_NB_TXQ_STATS; /* implemented by the driver */ if (dev->dev_ops->xstats_get != NULL) { @@ -1679,6 +1680,9 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats, if (xcount < 0) return xcount; + } else { + count += dev->data->nb_rx_queues * RTE_NB_RXQ_STATS; + count += dev->data->nb_tx_queues * RTE_NB_TXQ_STATS; } if (n < count + xcount) @@ -1698,6 +1702,10 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats, xstats[count++].value = val; } + /* if xstats_get() is implemented by the PMD, the Q stats are done */ + if (dev->dev_ops->xstats_get != NULL) + return count + xcount; + /* per-rxq stats */ for (q = 0; q < dev->data->nb_rx_queues; q++) { for (i = 0; i < RTE_NB_RXQ_STATS; i++) { @@ -1706,7 +1714,7 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats, q * sizeof(uint64_t)); val = *stats_ptr; snprintf(xstats[count].name, sizeof(xstats[count].name), - "rx_queue_%u_%s", q, + "rx_q%u_%s", q, rte_rxq_stats_strings[i].name); xstats[count++].value = val; } @@ -1720,7 +1728,7 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats, q * sizeof(uint64_t)); val = *stats_ptr; snprintf(xstats[count].name, sizeof(xstats[count].name), - "tx_queue_%u_%s", q, + "tx_q%u_%s", q, rte_txq_stats_strings[i].name); xstats[count++].value = val; } -- 1.9.1