[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190128234507.32028-5-jakub.kicinski@netronome.com>
Date: Mon, 28 Jan 2019 15:44:57 -0800
From: Jakub Kicinski <jakub.kicinski@...ronome.com>
To: davem@...emloft.net
Cc: oss-drivers@...ronome.com, netdev@...r.kernel.org,
jiri@...nulli.us, f.fainelli@...il.com, andrew@...n.ch,
mkubecek@...e.cz, dsahern@...il.com, simon.horman@...ronome.com,
jesse.brandeburg@...el.com, maciejromanfijalkowski@...il.com,
vasundhara-v.volam@...adcom.com, michael.chan@...adcom.com,
shalomt@...lanox.com, idosch@...lanox.com,
Jakub Kicinski <jakub.kicinski@...ronome.com>
Subject: [RFC 04/14] net: hstats: allow hierarchies to be built
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@...ronome.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
Powered by blists - more mailing lists