__DEVLINK_ATTR_MAX,
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 1509c2ffb98b..71aeda259e6a 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -501,10 +501,39 @@ devlink_reload_action_limit_level_is_supported(struct
devlink *devlink,
return test_bit(limit_level,
&devlink->ops->supported_reload_action_limit_levels);
}
+static int devlink_reload_action_stat_put(struct sk_buff *msg, enum devlink_reload_action action,
+ enum
devlink_reload_action_limit_level limit_level,
+ bool is_remote, u32 value)
+{
+ struct nlattr *reload_action_stat;
+
+ reload_action_stat = nla_nest_start(msg,
DEVLINK_ATTR_RELOAD_ACTION_STAT);
+ if (!reload_action_stat)
+ return -EMSGSIZE;
+
+ if (nla_put_u8(msg, DEVLINK_ATTR_RELOAD_ACTION, action))
+ goto nla_put_failure;
+ if (nla_put_u8(msg, DEVLINK_ATTR_RELOAD_ACTION_LIMIT_LEVEL,
limit_level))
+ goto nla_put_failure;
+ if (is_remote && nla_put_flag(msg,
DEVLINK_ATTR_RELOAD_ACTION_STAT_REMOTE))
+ goto nla_put_failure;
+ if (nla_put_u32(msg, DEVLINK_ATTR_RELOAD_ACTION_STAT_VALUE, value))
+ goto nla_put_failure;
+ nla_nest_end(msg, reload_action_stat);
+ return 0;
+
+nla_put_failure:
+ nla_nest_cancel(msg, reload_action_stat);
+ return -EMSGSIZE;
+}
+
static int devlink_nl_fill(struct sk_buff *msg, struct devlink *devlink,
enum devlink_command cmd, u32 portid,
u32 seq, int flags)
{
+ struct nlattr *dev_stats, *reload_action_stats;
+ int i, j, stat_idx;
+ u32 value;
void *hdr;
hdr = genlmsg_put(msg, portid, seq, &devlink_nl_family, flags, cmd);
@@ -516,9 +545,50 @@ static int devlink_nl_fill(struct sk_buff *msg, struct
devlink *devlink,
if (nla_put_u8(msg, DEVLINK_ATTR_RELOAD_FAILED, devlink->reload_failed))
goto nla_put_failure;
+ dev_stats = nla_nest_start(msg, DEVLINK_ATTR_DEV_STATS);
+ if (!dev_stats)
+ goto nla_put_failure;
+ reload_action_stats = nla_nest_start(msg,
DEVLINK_ATTR_RELOAD_ACTION_STATS);
+ if (!reload_action_stats)
+ goto dev_stats_nest_cancel;
+
+ for (j = 0; j <= DEVLINK_RELOAD_ACTION_LIMIT_LEVEL_MAX; j++) {
+ if (!devlink_reload_action_limit_level_is_supported(devlink, j))
+ continue;
+ for (i = 0; i <= DEVLINK_RELOAD_ACTION_MAX; i++) {
+ if (!devlink_reload_action_is_supported(devlink, i) ||
+ devlink_reload_combination_is_invalid(i, j))
+ continue;
+
+ stat_idx = j * __DEVLINK_RELOAD_ACTION_MAX + i;
+ value = devlink->reload_action_stats[stat_idx];
+ if (devlink_reload_action_stat_put(msg, i, j, false,
value))
+ goto reload_action_stats_nest_cancel;
+ }
+ }
+
+ for (j = 0; j <= DEVLINK_RELOAD_ACTION_LIMIT_LEVEL_MAX; j++) {
+ for (i = 0; i <= DEVLINK_RELOAD_ACTION_MAX; i++) {
+ if (i == DEVLINK_RELOAD_ACTION_UNSPEC ||
+ devlink_reload_combination_is_invalid(i, j))
+ continue;
+
+ stat_idx = j * __DEVLINK_RELOAD_ACTION_MAX + i;
+ value = devlink->remote_reload_action_stats[stat_idx];
+ if (devlink_reload_action_stat_put(msg, i, j, true,
value))
+ goto reload_action_stats_nest_cancel;
+ }
+ }