DPDK patches and discussions
 help / color / mirror / Atom feed
From: Remy Horton <remy.horton@intel.com>
To: dev@dpdk.org, Helin Zhang <helin.zhang@intel.com>,
	Thomas Monjalon <thomas.monjalon@6wind.com>
Subject: [dpdk-dev] [PATCH v4 5/8] drivers/net/i40e: change xstats to use integer ids
Date: Mon, 13 Jun 2016 16:51:58 +0100	[thread overview]
Message-ID: <1465833121-26953-6-git-send-email-remy.horton@intel.com> (raw)
In-Reply-To: <1465833121-26953-1-git-send-email-remy.horton@intel.com>

The current extended ethernet statistics fetching involve doing several
string operations, which causes performance issues if there are lots of
statistics and/or network interfaces. This patch changes the i40e driver
to use the new API that seperates name string and value queries.

Signed-off-by: Remy Horton <remy.horton@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c    | 82 ++++++++++++++++++++++++++++++++-------
 drivers/net/i40e/i40e_ethdev_vf.c | 26 +++++++++++--
 2 files changed, 91 insertions(+), 17 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 24777d5..d712bbe 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -306,6 +306,9 @@ static void i40e_dev_stats_get(struct rte_eth_dev *dev,
 			       struct rte_eth_stats *stats);
 static int i40e_dev_xstats_get(struct rte_eth_dev *dev,
 			       struct rte_eth_xstats *xstats, unsigned n);
+static int i40e_dev_xstats_get_names(struct rte_eth_dev *dev,
+				     struct rte_eth_xstat_name *xstats_names,
+				     unsigned limit);
 static void i40e_dev_stats_reset(struct rte_eth_dev *dev);
 static int i40e_dev_queue_stats_mapping_set(struct rte_eth_dev *dev,
 					    uint16_t queue_id,
@@ -467,6 +470,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
 	.link_update                  = i40e_dev_link_update,
 	.stats_get                    = i40e_dev_stats_get,
 	.xstats_get                   = i40e_dev_xstats_get,
+	.xstats_get_names             = i40e_dev_xstats_get_names,
 	.stats_reset                  = i40e_dev_stats_reset,
 	.xstats_reset                 = i40e_dev_stats_reset,
 	.queue_stats_mapping_set      = i40e_dev_queue_stats_mapping_set,
@@ -2205,6 +2209,60 @@ i40e_xstats_calc_num(void)
 		(I40E_NB_TXQ_PRIO_XSTATS * 8);
 }
 
+static int i40e_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+				     struct rte_eth_xstat_name *xstats_names,
+				     __rte_unused unsigned limit)
+{
+	unsigned count = 0;
+	unsigned i, prio;
+
+	if (xstats_names == NULL)
+		return i40e_xstats_calc_num();
+
+	/* Note: limit checked in rte_eth_xstats_names() */
+
+	/* Get stats from i40e_eth_stats struct */
+	for (i = 0; i < I40E_NB_ETH_XSTATS; i++) {
+		snprintf(xstats_names[count].name,
+			 sizeof(xstats_names[count].name),
+			 "%s", rte_i40e_stats_strings[i].name);
+		xstats_names[count].id = count;
+		count++;
+	}
+
+	/* Get individiual stats from i40e_hw_port struct */
+	for (i = 0; i < I40E_NB_HW_PORT_XSTATS; i++) {
+		snprintf(xstats_names[count].name,
+			sizeof(xstats_names[count].name),
+			 "%s", rte_i40e_hw_port_strings[i].name);
+		xstats_names[count].id = count;
+		count++;
+	}
+
+	for (i = 0; i < I40E_NB_RXQ_PRIO_XSTATS; i++) {
+		for (prio = 0; prio < 8; prio++) {
+			snprintf(xstats_names[count].name,
+				 sizeof(xstats_names[count].name),
+				 "rx_priority%u_%s", prio,
+				 rte_i40e_rxq_prio_strings[i].name);
+			xstats_names[count].id = count;
+			count++;
+		}
+	}
+
+	for (i = 0; i < I40E_NB_TXQ_PRIO_XSTATS; i++) {
+		for (prio = 0; prio < 8; prio++) {
+			snprintf(xstats_names[count].name,
+				 sizeof(xstats_names[count].name),
+				 "tx_priority%u_%s", prio,
+				 rte_i40e_txq_prio_strings[i].name);
+			xstats_names[count].id = count;
+			count++;
+		}
+	}
+	return count;
+}
+
 static int
 i40e_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
 		    unsigned n)
@@ -2227,8 +2285,8 @@ i40e_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
 
 	/* Get stats from i40e_eth_stats struct */
 	for (i = 0; i < I40E_NB_ETH_XSTATS; i++) {
-		snprintf(xstats[count].name, sizeof(xstats[count].name),
-			 "%s", rte_i40e_stats_strings[i].name);
+		xstats[count].name[0] = '\0';
+		xstats[count].id = count;
 		xstats[count].value = *(uint64_t *)(((char *)&hw_stats->eth) +
 			rte_i40e_stats_strings[i].offset);
 		count++;
@@ -2236,19 +2294,17 @@ i40e_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
 
 	/* Get individiual stats from i40e_hw_port struct */
 	for (i = 0; i < I40E_NB_HW_PORT_XSTATS; i++) {
-		snprintf(xstats[count].name, sizeof(xstats[count].name),
-			 "%s", rte_i40e_hw_port_strings[i].name);
+		xstats[count].name[0] = '\0';
+		xstats[count].id = count;
 		xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
-				rte_i40e_hw_port_strings[i].offset);
+			rte_i40e_hw_port_strings[i].offset);
 		count++;
 	}
 
 	for (i = 0; i < I40E_NB_RXQ_PRIO_XSTATS; i++) {
 		for (prio = 0; prio < 8; prio++) {
-			snprintf(xstats[count].name,
-				 sizeof(xstats[count].name),
-				 "rx_priority%u_%s", prio,
-				 rte_i40e_rxq_prio_strings[i].name);
+			xstats[count].name[0] = '\0';
+			xstats[count].id = count;
 			xstats[count].value =
 				*(uint64_t *)(((char *)hw_stats) +
 				rte_i40e_rxq_prio_strings[i].offset +
@@ -2259,10 +2315,8 @@ i40e_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
 
 	for (i = 0; i < I40E_NB_TXQ_PRIO_XSTATS; i++) {
 		for (prio = 0; prio < 8; prio++) {
-			snprintf(xstats[count].name,
-				 sizeof(xstats[count].name),
-				 "tx_priority%u_%s", prio,
-				 rte_i40e_txq_prio_strings[i].name);
+			xstats[count].name[0] = '\0';
+			xstats[count].id = count;
 			xstats[count].value =
 				*(uint64_t *)(((char *)hw_stats) +
 				rte_i40e_txq_prio_strings[i].offset +
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 90682ac..4c5e45e 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -112,6 +112,9 @@ static void i40evf_dev_stats_get(struct rte_eth_dev *dev,
 				struct rte_eth_stats *stats);
 static int i40evf_dev_xstats_get(struct rte_eth_dev *dev,
 				 struct rte_eth_xstats *xstats, unsigned n);
+static int i40evf_dev_xstats_get_names(struct rte_eth_dev *dev,
+				       struct rte_eth_xstat_name *xstats_names,
+				       unsigned limit);
 static void i40evf_dev_xstats_reset(struct rte_eth_dev *dev);
 static int i40evf_vlan_filter_set(struct rte_eth_dev *dev,
 				  uint16_t vlan_id, int on);
@@ -196,6 +199,7 @@ static const struct eth_dev_ops i40evf_eth_dev_ops = {
 	.link_update          = i40evf_dev_link_update,
 	.stats_get            = i40evf_dev_stats_get,
 	.xstats_get           = i40evf_dev_xstats_get,
+	.xstats_get_names     = i40evf_dev_xstats_get_names,
 	.xstats_reset         = i40evf_dev_xstats_reset,
 	.dev_close            = i40evf_dev_close,
 	.dev_infos_get        = i40evf_dev_info_get,
@@ -984,6 +988,22 @@ i40evf_dev_xstats_reset(struct rte_eth_dev *dev)
 	vf->vsi.eth_stats_offset = vf->vsi.eth_stats;
 }
 
+static int i40evf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+				      struct rte_eth_xstat_name *xstats_names,
+				      __rte_unused unsigned limit)
+{
+	unsigned i;
+
+	if (xstats_names != NULL)
+		for (i = 0; i < I40EVF_NB_XSTATS; i++) {
+			snprintf(xstats_names[i].name,
+				sizeof(xstats_names[i].name),
+				"%s", rte_i40evf_stats_strings[i].name);
+			xstats_names[i].id = i;
+		}
+	return I40EVF_NB_XSTATS;
+}
+
 static int i40evf_dev_xstats_get(struct rte_eth_dev *dev,
 				 struct rte_eth_xstats *xstats, unsigned n)
 {
@@ -1003,8 +1023,8 @@ static int i40evf_dev_xstats_get(struct rte_eth_dev *dev,
 
 	/* loop over xstats array and values from pstats */
 	for (i = 0; i < I40EVF_NB_XSTATS; i++) {
-		snprintf(xstats[i].name, sizeof(xstats[i].name),
-			 "%s", rte_i40evf_stats_strings[i].name);
+		xstats[i].name[0] = '\0';
+		xstats[i].id = i;
 		xstats[i].value = *(uint64_t *)(((char *)pstats) +
 			rte_i40evf_stats_strings[i].offset);
 	}
-- 
2.5.5

  parent reply	other threads:[~2016-06-13 15:52 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-15 14:44 [dpdk-dev] [RFC PATCH v1 0/3] Remove string operations from xstats Remy Horton
2016-04-15 14:44 ` [dpdk-dev] [RFC PATCH v1 1/3] rte: change xstats to use integer keys Remy Horton
2016-04-29 13:17   ` David Harton (dharton)
2016-04-15 14:44 ` [dpdk-dev] [RFC PATCH v1 2/3] drivers/net/ixgbe: change xstats to use integers Remy Horton
2016-04-29 13:43   ` David Harton (dharton)
2016-05-03 12:22     ` Remy Horton
2016-05-03 13:40       ` David Harton (dharton)
2016-04-15 14:44 ` [dpdk-dev] [RFC PATCH v1 3/3] examples/ethtool: add xstats display command Remy Horton
2016-04-20 16:03 ` [dpdk-dev] [RFC PATCH v1 0/3] Remove string operations from xstats David Harton (dharton)
2016-04-20 16:49   ` Mcnamara, John
2016-04-22 15:04     ` David Harton (dharton)
2016-04-28 14:56   ` Tahhan, Maryam
2016-04-28 15:58     ` David Harton (dharton)
2016-04-29 10:21       ` Remy Horton
2016-04-29 12:15         ` David Harton (dharton)
2016-04-29 12:52 ` David Harton (dharton)
2016-05-06 11:11 ` [dpdk-dev] [RFC PATCH v2 " Remy Horton
2016-05-06 11:11   ` [dpdk-dev] [RFC PATCH v2 1/3] rte: change xstats to use integer keys Remy Horton
2016-05-09 13:59     ` David Harton (dharton)
2016-05-10  8:58       ` Remy Horton
2016-05-12 16:17       ` Thomas Monjalon
2016-05-16 10:47     ` Tahhan, Maryam
2016-05-18  8:31     ` Tahhan, Maryam
2016-05-18  8:45       ` Remy Horton
2016-05-06 11:11   ` [dpdk-dev] [RFC PATCH v2 2/3] drivers/net/ixgbe: change xstats to use integer id Remy Horton
2016-05-09 14:06     ` David Harton (dharton)
2016-05-18  8:41     ` Tahhan, Maryam
2016-05-06 11:11   ` [dpdk-dev] [RFC PATCH v2 3/3] examples/ethtool: add xstats display command Remy Horton
2016-05-09 14:08     ` David Harton (dharton)
2016-05-18  8:42     ` Tahhan, Maryam
2016-05-16 10:42   ` [dpdk-dev] [RFC PATCH v2 0/3] Remove string operations from xstats Tahhan, Maryam
2016-05-18 10:12     ` Remy Horton
2016-05-30 10:48   ` [dpdk-dev] [PATCH v3 00/10] " Remy Horton
2016-05-30 10:48     ` [dpdk-dev] [PATCH v3 01/10] rte: change xstats to use integer ids Remy Horton
2016-06-08  9:37       ` Thomas Monjalon
2016-06-08 11:16         ` Remy Horton
2016-06-08 12:22           ` Thomas Monjalon
2016-05-30 10:48     ` [dpdk-dev] [PATCH v3 02/10] drivers/net/ixgbe: " Remy Horton
2016-05-30 10:48     ` [dpdk-dev] [PATCH v3 03/10] drivers/net/e1000: " Remy Horton
2016-05-30 10:48     ` [dpdk-dev] [PATCH v3 04/10] drivers/net/fm10k: " Remy Horton
2016-05-30 10:48     ` [dpdk-dev] [PATCH v3 05/10] drivers/net/i40e: " Remy Horton
2016-05-30 10:48     ` [dpdk-dev] [PATCH v3 06/10] drivers/net/virtio: " Remy Horton
2016-05-30 10:48     ` [dpdk-dev] [PATCH v3 07/10] app/test-pmd: " Remy Horton
2016-05-30 10:48     ` [dpdk-dev] [PATCH v3 08/10] app/proc_info: " Remy Horton
2016-05-30 10:48     ` [dpdk-dev] [PATCH v3 09/10] remove name field from struct rte_eth_xstats Remy Horton
2016-06-08 12:23       ` Thomas Monjalon
2016-05-30 10:48     ` [dpdk-dev] [PATCH v3 10/10] doc: update xstats documentation Remy Horton
2016-06-09  8:48       ` Mcnamara, John
2016-06-06 12:45     ` [dpdk-dev] [PATCH v3 00/10] Remove string operations from xstats David Harton (dharton)
2016-06-13 15:51     ` [dpdk-dev] [PATCH v4 0/8] " Remy Horton
2016-06-13 15:51       ` [dpdk-dev] [PATCH v4 1/8] rte: change xstats to use integer ids Remy Horton
2016-06-15  9:19         ` Thomas Monjalon
2016-06-13 15:51       ` [dpdk-dev] [PATCH v4 2/8] drivers/net/ixgbe: " Remy Horton
2016-06-13 15:51       ` [dpdk-dev] [PATCH v4 3/8] drivers/net/e1000: " Remy Horton
2016-06-13 15:51       ` [dpdk-dev] [PATCH v4 4/8] drivers/net/fm10k: " Remy Horton
2016-06-13 15:51       ` Remy Horton [this message]
2016-06-13 15:51       ` [dpdk-dev] [PATCH v4 6/8] drivers/net/virtio: " Remy Horton
2016-06-13 15:52       ` [dpdk-dev] [PATCH v4 7/8] rte: change xstats usage to new API Remy Horton
2016-06-15  9:13         ` Thomas Monjalon
2016-06-13 15:52       ` [dpdk-dev] [PATCH v4 8/8] doc: update xstats documentation Remy Horton
2016-06-14 14:06         ` Mcnamara, John
2016-06-15 15:25       ` [dpdk-dev] [PATCH v5 0/7] Remove string operations from xstats Remy Horton
2016-06-15 15:25         ` [dpdk-dev] [PATCH v5 1/7] rte: change xstats to use integer ids Remy Horton
2016-06-15 15:25         ` [dpdk-dev] [PATCH v5 2/7] drivers/net/ixgbe: " Remy Horton
2016-06-15 15:25         ` [dpdk-dev] [PATCH v5 3/7] drivers/net/e1000: " Remy Horton
2016-06-15 15:25         ` [dpdk-dev] [PATCH v5 4/7] drivers/net/fm10k: " Remy Horton
2016-06-15 15:25         ` [dpdk-dev] [PATCH v5 5/7] drivers/net/i40e: " Remy Horton
2016-06-15 15:25         ` [dpdk-dev] [PATCH v5 6/7] drivers/net/virtio: " Remy Horton
2016-06-20 10:43           ` Yuanhan Liu
2016-06-15 15:25         ` [dpdk-dev] [PATCH v5 7/7] rte: change xstats usage to new API Remy Horton
2016-06-16 16:02         ` [dpdk-dev] [PATCH v5 0/7] Remove string operations from xstats Thomas Monjalon

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=1465833121-26953-6-git-send-email-remy.horton@intel.com \
    --to=remy.horton@intel.com \
    --cc=dev@dpdk.org \
    --cc=helin.zhang@intel.com \
    --cc=thomas.monjalon@6wind.com \
    /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).