All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: davem@davemloft.net
Cc: oss-drivers@netronome.com, netdev@vger.kernel.org,
	jiri@resnulli.us, f.fainelli@gmail.com, andrew@lunn.ch,
	mkubecek@suse.cz, dsahern@gmail.com, simon.horman@netronome.com,
	jesse.brandeburg@intel.com, maciejromanfijalkowski@gmail.com,
	vasundhara-v.volam@broadcom.com, michael.chan@broadcom.com,
	shalomt@mellanox.com, idosch@mellanox.com,
	Jakub Kicinski <jakub.kicinski@netronome.com>
Subject: [RFC 04/14] net: hstats: allow hierarchies to be built
Date: Mon, 28 Jan 2019 15:44:57 -0800	[thread overview]
Message-ID: <20190128234507.32028-5-jakub.kicinski@netronome.com> (raw)
In-Reply-To: <20190128234507.32028-1-jakub.kicinski@netronome.com>

Allow groups to have other groups attached as children.  Child
groups allow embedding different groups in the same root group
and simplify definition of dependent stats (as qualifiers don't
have to be repeated).

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 include/net/hstats.h |  6 ++++++
 net/core/hstats.c    | 14 ++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/include/net/hstats.h b/include/net/hstats.h
index c2e8b379237a..cbbdaf93d408 100644
--- a/include/net/hstats.h
+++ b/include/net/hstats.h
@@ -37,18 +37,24 @@ struct rtnl_hstat_qualifier {
 /**
  * struct rtnl_hstat_group - node in the hstat hierarchy
  * @qualifiers:	attributes describing this group
+ * @has_children: @children array is present and NULL-terminated
  * @stats_cnt:	number of stats in the bitmask
  * @stats:	bitmask of stats present
  * @get_stats:	driver callback for dumping the stats
+ * @children:	NULL-terminated array of groups inheriting the qualifiers
+ *		@has_children has to be set for core to parse the array
  */
 struct rtnl_hstat_group {
 	/* Note: this is *not* indexed with IFLA_* attributes! */
 	struct rtnl_hstat_qualifier qualifiers[RTNL_HSTATS_QUAL_CNT];
+	bool has_children;
 	/* Can't use bitmaps - words are variable length */
 	unsigned int stats_cnt;
 	u64 stats[DIV_ROUND_UP(IFLA_HSTATS_STAT_MAX + 1, 64)];
 	int (*get_stats)(struct net_device *dev, struct rtnl_hstat_req *req,
 			 const struct rtnl_hstat_group *grp);
+
+	const struct rtnl_hstat_group *children[];
 };
 
 void rtnl_hstat_add_grp(struct rtnl_hstat_req *req,
diff --git a/net/core/hstats.c b/net/core/hstats.c
index 183a1c5dd93a..b409dd40e0c9 100644
--- a/net/core/hstats.c
+++ b/net/core/hstats.c
@@ -31,6 +31,10 @@ enum hstat_dumper_cmd {
 	 */
 	HSTAT_DCMD_GRP_LOAD,
 	/* dump all statitics
+	 *   ---------------
+	 *  |  LOAD child0  |
+	 *  |  LOAD child1  |
+	 *   ===============
 	 */
 	HSTAT_DCMD_GRP_DUMP,
 	/* close grp */
@@ -353,6 +357,16 @@ static int hstat_dumper_grp_dump(struct hstat_dumper *dumper)
 	if (err)
 		return err;
 
+	if (cmd.grp->has_children) {
+		const struct rtnl_hstat_group *const *grp;
+
+		for (grp = cmd.grp->children; *grp; grp++) {
+			err = hstat_dumper_push_grp_load(dumper, *grp);
+			if (err)
+				return err;
+		}
+	}
+
 	return 0;
 }
 
-- 
2.19.2


  parent reply	other threads:[~2019-01-28 23:46 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-28 23:44 [RFC 00/14] netlink/hierarchical stats Jakub Kicinski
2019-01-28 23:44 ` [RFC 01/14] nfp: remove unused structure Jakub Kicinski
2019-01-28 23:44 ` [RFC 02/14] nfp: constify parameter to nfp_port_from_netdev() Jakub Kicinski
2019-01-28 23:44 ` [RFC 03/14] net: hstats: add basic/core functionality Jakub Kicinski
2019-01-30  4:18   ` David Ahern
2019-01-30 17:44     ` Jakub Kicinski
2019-01-30 22:33       ` David Ahern
2019-01-28 23:44 ` Jakub Kicinski [this message]
2019-01-28 23:44 ` [RFC 05/14] nfp: very basic hstat support Jakub Kicinski
2019-01-28 23:44 ` [RFC 06/14] net: hstats: allow iterators Jakub Kicinski
2019-01-28 23:45 ` [RFC 07/14] net: hstats: help in iteration over directions Jakub Kicinski
2019-01-28 23:45 ` [RFC 08/14] nfp: hstats: make use of iteration for direction Jakub Kicinski
2019-01-28 23:45 ` [RFC 09/14] nfp: hstats: add driver and device per queue statistics Jakub Kicinski
2019-01-28 23:45 ` [RFC 10/14] net: hstats: add IEEE 802.3 and common IETF MIB/RMON stats Jakub Kicinski
2019-01-28 23:45 ` [RFC 11/14] nfp: hstats: add IEEE/RMON ethernet port/MAC stats Jakub Kicinski
2019-01-28 23:45 ` [RFC 12/14] net: hstats: add markers for partial groups Jakub Kicinski
2019-01-28 23:45 ` [RFC 13/14] nfp: hstats: add a partial group of per-8021Q prio stats Jakub Kicinski
2019-01-28 23:45 ` [RFC 14/14] Documentation: networking: describe new hstat API Jakub Kicinski
2019-01-30 22:14 ` [RFC 00/14] netlink/hierarchical stats Roopa Prabhu
2019-01-31  0:24   ` Jakub Kicinski
2019-01-31 16:16     ` Roopa Prabhu
2019-01-31 16:31       ` Roopa Prabhu
2019-01-31 19:30         ` Jakub Kicinski
2019-02-02 23:14           ` Roopa Prabhu
2019-02-06  4:45             ` Jakub Kicinski
2019-02-06 20:12 ` Florian Fainelli
2019-02-07 16:23   ` Jakub Kicinski

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=20190128234507.32028-5-jakub.kicinski@netronome.com \
    --to=jakub.kicinski@netronome.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dsahern@gmail.com \
    --cc=f.fainelli@gmail.com \
    --cc=idosch@mellanox.com \
    --cc=jesse.brandeburg@intel.com \
    --cc=jiri@resnulli.us \
    --cc=maciejromanfijalkowski@gmail.com \
    --cc=michael.chan@broadcom.com \
    --cc=mkubecek@suse.cz \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@netronome.com \
    --cc=shalomt@mellanox.com \
    --cc=simon.horman@netronome.com \
    --cc=vasundhara-v.volam@broadcom.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.