diff mbox series

[iproute2,master,2/2] devlink: Add a new time-stamp format for health reporter's dump

Message ID 1566471942-28529-3-git-send-email-ayal@mellanox.com
State Changes Requested
Delegated to: stephen hemminger
Headers show
Series [net] devlink: Add method for time-stamp on reporter's dump | expand

Commit Message

Aya Levin Aug. 22, 2019, 11:05 a.m. UTC
Introduce a new attribute representing a new time-stamp format: current
time instead of jiffies. If the new attribute was received, translate
the time-stamp accordingly.

Fixes: 2f1242efe9d0 ("devlink: Add devlink health show command")
Signed-off-by: Aya Levin <ayal@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
---
 devlink/devlink.c            | 20 +++++++++++++++++++-
 include/uapi/linux/devlink.h |  2 ++
 2 files changed, 21 insertions(+), 1 deletion(-)

Comments

Stephen Hemminger Aug. 29, 2019, 11:27 p.m. UTC | #1
On Thu, 22 Aug 2019 14:05:42 +0300
Aya Levin <ayal@mellanox.com> wrote:

> diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
> index fc195cbd66f4..3f8532711315 100644
> --- a/include/uapi/linux/devlink.h
> +++ b/include/uapi/linux/devlink.h
> @@ -348,6 +348,8 @@ enum devlink_attr {
>  	DEVLINK_ATTR_PORT_PCI_PF_NUMBER,	/* u16 */
>  	DEVLINK_ATTR_PORT_PCI_VF_NUMBER,	/* u16 */
>  
> +	DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TSPEC,
> +
>  	/* add new attributes above here, update the policy in devlink.c */
>  
>  	__DEVLINK_ATTR_MAX,
> -- 

Since this is not upstream, this patch needs to go to iproute2-next.
Which means if you want the other bug fix, send it again against master.
Aya Levin Sept. 6, 2019, 7:17 a.m. UTC | #2
On 8/30/2019 2:27 AM, Stephen Hemminger wrote:
> On Thu, 22 Aug 2019 14:05:42 +0300
> Aya Levin <ayal@mellanox.com> wrote:
> 
>> diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
>> index fc195cbd66f4..3f8532711315 100644
>> --- a/include/uapi/linux/devlink.h
>> +++ b/include/uapi/linux/devlink.h
>> @@ -348,6 +348,8 @@ enum devlink_attr {
>>   	DEVLINK_ATTR_PORT_PCI_PF_NUMBER,	/* u16 */
>>   	DEVLINK_ATTR_PORT_PCI_VF_NUMBER,	/* u16 */
>>   
>> +	DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TSPEC,
>> +
>>   	/* add new attributes above here, update the policy in devlink.c */
>>   
>>   	__DEVLINK_ATTR_MAX,
>> -- 
> 
> Since this is not upstream, this patch needs to go to iproute2-next.
> Which means if you want the other bug fix, send it again against master.
Thanks,
Will do that
>
diff mbox series

Patch

diff --git a/devlink/devlink.c b/devlink/devlink.c
index f1d9de8e151d..623d1b52c4ca 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -6197,6 +6197,22 @@  out:
 	pr_out_str(dl, "last_dump_time", dump_time);
 }
 
+static void pr_out_dump_report_timestamp(struct dl *dl, const struct nlattr *attr)
+{
+	char dump_date[HEALTH_REPORTER_TIMESTAMP_FMT_LEN];
+	char dump_time[HEALTH_REPORTER_TIMESTAMP_FMT_LEN];
+	struct timespec *ts = mnl_attr_get_payload(attr);
+	struct tm *tm;
+
+	tm = localtime(&ts->tv_sec);
+
+	strftime(dump_date, HEALTH_REPORTER_TIMESTAMP_FMT_LEN, "%Y-%m-%d", tm);
+	strftime(dump_time, HEALTH_REPORTER_TIMESTAMP_FMT_LEN, "%H:%M:%S", tm);
+
+	pr_out_str(dl, "last_dump_date", dump_date);
+	pr_out_str(dl, "last_dump_time", dump_time);
+}
+
 static void pr_out_health(struct dl *dl, struct nlattr **tb_health)
 {
 	struct nlattr *tb[DEVLINK_ATTR_MAX + 1] = {};
@@ -6228,7 +6244,9 @@  static void pr_out_health(struct dl *dl, struct nlattr **tb_health)
 		   mnl_attr_get_u64(tb[DEVLINK_ATTR_HEALTH_REPORTER_ERR_COUNT]));
 	pr_out_u64(dl, "recover",
 		   mnl_attr_get_u64(tb[DEVLINK_ATTR_HEALTH_REPORTER_RECOVER_COUNT]));
-	if (tb[DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS])
+	if (tb[DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TSPEC])
+		pr_out_dump_report_timestamp(dl, tb[DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TSPEC]);
+	else if (tb[DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS])
 		pr_out_dump_reporter_format_logtime(dl, tb[DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS]);
 	if (tb[DEVLINK_ATTR_HEALTH_REPORTER_GRACEFUL_PERIOD])
 		pr_out_u64(dl, "grace_period",
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index fc195cbd66f4..3f8532711315 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -348,6 +348,8 @@  enum devlink_attr {
 	DEVLINK_ATTR_PORT_PCI_PF_NUMBER,	/* u16 */
 	DEVLINK_ATTR_PORT_PCI_VF_NUMBER,	/* u16 */
 
+	DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TSPEC,
+
 	/* add new attributes above here, update the policy in devlink.c */
 
 	__DEVLINK_ATTR_MAX,