All of lore.kernel.org
 help / color / mirror / Atom feed
From: Remy Horton <remy.horton@intel.com>
To: dev@dpdk.org, Wenzhuo Lu <wenzhuo.lu@intel.com>,
	Thomas Monjalon <thomas.monjalon@6wind.com>
Subject: [PATCH v4 3/8] drivers/net/e1000: change xstats to use integer ids
Date: Mon, 13 Jun 2016 16:51:56 +0100	[thread overview]
Message-ID: <1465833121-26953-4-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 e1000 driver
to use the new API that seperates name string and value queries.

Signed-off-by: Remy Horton <remy.horton@intel.com>
---
 drivers/net/e1000/igb_ethdev.c | 52 ++++++++++++++++++++++++++++++++++++++----
 1 file changed, 48 insertions(+), 4 deletions(-)

diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index f0921ee..dffa04f 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -100,6 +100,9 @@ static void eth_igb_stats_get(struct rte_eth_dev *dev,
 				struct rte_eth_stats *rte_stats);
 static int eth_igb_xstats_get(struct rte_eth_dev *dev,
 			      struct rte_eth_xstats *xstats, unsigned n);
+static int eth_igb_xstats_get_names(struct rte_eth_dev *dev,
+				    struct rte_eth_xstat_name *xstats_names,
+				    unsigned limit);
 static void eth_igb_stats_reset(struct rte_eth_dev *dev);
 static void eth_igb_xstats_reset(struct rte_eth_dev *dev);
 static void eth_igb_infos_get(struct rte_eth_dev *dev,
@@ -165,6 +168,9 @@ static void eth_igbvf_stats_get(struct rte_eth_dev *dev,
 				struct rte_eth_stats *rte_stats);
 static int eth_igbvf_xstats_get(struct rte_eth_dev *dev,
 				struct rte_eth_xstats *xstats, unsigned n);
+static int eth_igbvf_xstats_get_names(struct rte_eth_dev *dev,
+				      struct rte_eth_xstat_name *xstats_names,
+				      unsigned limit);
 static void eth_igbvf_stats_reset(struct rte_eth_dev *dev);
 static int igbvf_vlan_filter_set(struct rte_eth_dev *dev,
 		uint16_t vlan_id, int on);
@@ -324,6 +330,7 @@ static const struct eth_dev_ops eth_igb_ops = {
 	.link_update          = eth_igb_link_update,
 	.stats_get            = eth_igb_stats_get,
 	.xstats_get           = eth_igb_xstats_get,
+	.xstats_get_names     = eth_igb_xstats_get_names,
 	.stats_reset          = eth_igb_stats_reset,
 	.xstats_reset         = eth_igb_xstats_reset,
 	.dev_infos_get        = eth_igb_infos_get,
@@ -385,6 +392,7 @@ static const struct eth_dev_ops igbvf_eth_dev_ops = {
 	.link_update          = eth_igb_link_update,
 	.stats_get            = eth_igbvf_stats_get,
 	.xstats_get           = eth_igbvf_xstats_get,
+	.xstats_get_names     = eth_igbvf_xstats_get_names,
 	.stats_reset          = eth_igbvf_stats_reset,
 	.xstats_reset         = eth_igbvf_stats_reset,
 	.vlan_filter_set      = igbvf_vlan_filter_set,
@@ -1691,6 +1699,26 @@ eth_igb_xstats_reset(struct rte_eth_dev *dev)
 	memset(stats, 0, sizeof(*stats));
 }
 
+static int eth_igb_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)
+		return IGB_NB_XSTATS;
+
+	/* Note: limit checked in rte_eth_xstats_names() */
+
+	for (i = 0; i < IGB_NB_XSTATS; i++) {
+		snprintf(xstats_names[i].name, sizeof(xstats_names[i].name),
+			 "%s", rte_igb_stats_strings[i].name);
+		xstats_names[i].id = i;
+	}
+
+	return IGB_NB_XSTATS;
+}
+
 static int
 eth_igb_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
 		   unsigned n)
@@ -1713,8 +1741,8 @@ eth_igb_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
 
 	/* Extended stats */
 	for (i = 0; i < IGB_NB_XSTATS; i++) {
-		snprintf(xstats[i].name, sizeof(xstats[i].name),
-			 "%s", rte_igb_stats_strings[i].name);
+		xstats[i].name[0] = '\0';
+		xstats[i].id = i;
 		xstats[i].value = *(uint64_t *)(((char *)hw_stats) +
 			rte_igb_stats_strings[i].offset);
 	}
@@ -1762,6 +1790,22 @@ igbvf_read_stats_registers(struct e1000_hw *hw, struct e1000_vf_stats *hw_stats)
 	    hw_stats->last_gotlbc, hw_stats->gotlbc);
 }
 
+static int eth_igbvf_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 < IGBVF_NB_XSTATS; i++) {
+			snprintf(xstats_names[i].name,
+				sizeof(xstats_names[i].name), "%s",
+				rte_igbvf_stats_strings[i].name);
+			xstats_names[i].id = i;
+		}
+	return IGBVF_NB_XSTATS;
+}
+
 static int
 eth_igbvf_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
 		     unsigned n)
@@ -1780,8 +1824,8 @@ eth_igbvf_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
 		return 0;
 
 	for (i = 0; i < IGBVF_NB_XSTATS; i++) {
-		snprintf(xstats[i].name, sizeof(xstats[i].name), "%s",
-			 rte_igbvf_stats_strings[i].name);
+		xstats[i].name[0] = '\0';
+		xstats[i].id = i;
 		xstats[i].value = *(uint64_t *)(((char *)hw_stats) +
 			rte_igbvf_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 [RFC PATCH v1 0/3] Remove string operations from xstats Remy Horton
2016-04-15 14:44 ` [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 ` [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 ` [RFC PATCH v1 3/3] examples/ethtool: add xstats display command Remy Horton
2016-04-20 16:03 ` [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 ` [RFC PATCH v2 " Remy Horton
2016-05-06 11:11   ` [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   ` [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   ` [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   ` [RFC PATCH v2 0/3] Remove string operations from xstats Tahhan, Maryam
2016-05-18 10:12     ` Remy Horton
2016-05-30 10:48   ` [PATCH v3 00/10] " Remy Horton
2016-05-30 10:48     ` [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     ` [PATCH v3 02/10] drivers/net/ixgbe: " Remy Horton
2016-05-30 10:48     ` [PATCH v3 03/10] drivers/net/e1000: " Remy Horton
2016-05-30 10:48     ` [PATCH v3 04/10] drivers/net/fm10k: " Remy Horton
2016-05-30 10:48     ` [PATCH v3 05/10] drivers/net/i40e: " Remy Horton
2016-05-30 10:48     ` [PATCH v3 06/10] drivers/net/virtio: " Remy Horton
2016-05-30 10:48     ` [PATCH v3 07/10] app/test-pmd: " Remy Horton
2016-05-30 10:48     ` [PATCH v3 08/10] app/proc_info: " Remy Horton
2016-05-30 10:48     ` [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     ` [PATCH v3 10/10] doc: update xstats documentation Remy Horton
2016-06-09  8:48       ` Mcnamara, John
2016-06-06 12:45     ` [PATCH v3 00/10] Remove string operations from xstats David Harton (dharton)
2016-06-13 15:51     ` [PATCH v4 0/8] " Remy Horton
2016-06-13 15:51       ` [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       ` [PATCH v4 2/8] drivers/net/ixgbe: " Remy Horton
2016-06-13 15:51       ` Remy Horton [this message]
2016-06-13 15:51       ` [PATCH v4 4/8] drivers/net/fm10k: " Remy Horton
2016-06-13 15:51       ` [PATCH v4 5/8] drivers/net/i40e: " Remy Horton
2016-06-13 15:51       ` [PATCH v4 6/8] drivers/net/virtio: " Remy Horton
2016-06-13 15:52       ` [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       ` [PATCH v4 8/8] doc: update xstats documentation Remy Horton
2016-06-14 14:06         ` Mcnamara, John
2016-06-15 15:25       ` [PATCH v5 0/7] Remove string operations from xstats Remy Horton
2016-06-15 15:25         ` [PATCH v5 1/7] rte: change xstats to use integer ids Remy Horton
2016-06-15 15:25         ` [PATCH v5 2/7] drivers/net/ixgbe: " Remy Horton
2016-06-15 15:25         ` [PATCH v5 3/7] drivers/net/e1000: " Remy Horton
2016-06-15 15:25         ` [PATCH v5 4/7] drivers/net/fm10k: " Remy Horton
2016-06-15 15:25         ` [PATCH v5 5/7] drivers/net/i40e: " Remy Horton
2016-06-15 15:25         ` [PATCH v5 6/7] drivers/net/virtio: " Remy Horton
2016-06-20 10:43           ` Yuanhan Liu
2016-06-15 15:25         ` [PATCH v5 7/7] rte: change xstats usage to new API Remy Horton
2016-06-16 16:02         ` [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-4-git-send-email-remy.horton@intel.com \
    --to=remy.horton@intel.com \
    --cc=dev@dpdk.org \
    --cc=thomas.monjalon@6wind.com \
    --cc=wenzhuo.lu@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.