Commit 746c19a5 authored by Ido Schimmel's avatar Ido Schimmel Committed by David S. Miller

net: nexthop: Add ability to enable / disable hardware statistics

Add netlink support for enabling collection of HW statistics on nexthop
groups.
Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5877786f
...@@ -47,6 +47,8 @@ struct nh_config { ...@@ -47,6 +47,8 @@ struct nh_config {
bool nh_grp_res_has_idle_timer; bool nh_grp_res_has_idle_timer;
bool nh_grp_res_has_unbalanced_timer; bool nh_grp_res_has_unbalanced_timer;
bool nh_hw_stats;
struct nlattr *nh_encap; struct nlattr *nh_encap;
u16 nh_encap_type; u16 nh_encap_type;
......
...@@ -68,6 +68,9 @@ enum { ...@@ -68,6 +68,9 @@ enum {
/* nested; nexthop group stats */ /* nested; nexthop group stats */
NHA_GROUP_STATS, NHA_GROUP_STATS,
/* u32; nexthop hardware stats enable */
NHA_HW_STATS_ENABLE,
__NHA_MAX, __NHA_MAX,
}; };
......
...@@ -39,6 +39,7 @@ static const struct nla_policy rtm_nh_policy_new[] = { ...@@ -39,6 +39,7 @@ static const struct nla_policy rtm_nh_policy_new[] = {
[NHA_ENCAP] = { .type = NLA_NESTED }, [NHA_ENCAP] = { .type = NLA_NESTED },
[NHA_FDB] = { .type = NLA_FLAG }, [NHA_FDB] = { .type = NLA_FLAG },
[NHA_RES_GROUP] = { .type = NLA_NESTED }, [NHA_RES_GROUP] = { .type = NLA_NESTED },
[NHA_HW_STATS_ENABLE] = NLA_POLICY_MAX(NLA_U32, true),
}; };
static const struct nla_policy rtm_nh_policy_get[] = { static const struct nla_policy rtm_nh_policy_get[] = {
...@@ -778,7 +779,8 @@ static int nla_put_nh_group(struct sk_buff *skb, struct nexthop *nh, ...@@ -778,7 +779,8 @@ static int nla_put_nh_group(struct sk_buff *skb, struct nexthop *nh,
goto nla_put_failure; goto nla_put_failure;
if (op_flags & NHA_OP_FLAG_DUMP_STATS && if (op_flags & NHA_OP_FLAG_DUMP_STATS &&
nla_put_nh_group_stats(skb, nh)) (nla_put_u32(skb, NHA_HW_STATS_ENABLE, nhg->hw_stats) ||
nla_put_nh_group_stats(skb, nh)))
goto nla_put_failure; goto nla_put_failure;
return 0; return 0;
...@@ -1202,6 +1204,7 @@ static int nh_check_attr_group(struct net *net, ...@@ -1202,6 +1204,7 @@ static int nh_check_attr_group(struct net *net,
if (!tb[i]) if (!tb[i])
continue; continue;
switch (i) { switch (i) {
case NHA_HW_STATS_ENABLE:
case NHA_FDB: case NHA_FDB:
continue; continue;
case NHA_RES_GROUP: case NHA_RES_GROUP:
...@@ -2622,6 +2625,9 @@ static struct nexthop *nexthop_create_group(struct net *net, ...@@ -2622,6 +2625,9 @@ static struct nexthop *nexthop_create_group(struct net *net,
if (cfg->nh_fdb) if (cfg->nh_fdb)
nhg->fdb_nh = 1; nhg->fdb_nh = 1;
if (cfg->nh_hw_stats)
nhg->hw_stats = true;
rcu_assign_pointer(nh->nh_grp, nhg); rcu_assign_pointer(nh->nh_grp, nhg);
return nh; return nh;
...@@ -2964,6 +2970,9 @@ static int rtm_to_nh_config(struct net *net, struct sk_buff *skb, ...@@ -2964,6 +2970,9 @@ static int rtm_to_nh_config(struct net *net, struct sk_buff *skb,
err = rtm_to_nh_config_grp_res(tb[NHA_RES_GROUP], err = rtm_to_nh_config_grp_res(tb[NHA_RES_GROUP],
cfg, extack); cfg, extack);
if (tb[NHA_HW_STATS_ENABLE])
cfg->nh_hw_stats = nla_get_u32(tb[NHA_HW_STATS_ENABLE]);
/* no other attributes should be set */ /* no other attributes should be set */
goto out; goto out;
} }
...@@ -3055,6 +3064,10 @@ static int rtm_to_nh_config(struct net *net, struct sk_buff *skb, ...@@ -3055,6 +3064,10 @@ static int rtm_to_nh_config(struct net *net, struct sk_buff *skb,
goto out; goto out;
} }
if (tb[NHA_HW_STATS_ENABLE]) {
NL_SET_ERR_MSG(extack, "Cannot enable nexthop hardware statistics for non-group nexthops");
goto out;
}
err = 0; err = 0;
out: out:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment