Skip to contentSkip to conversation

ndctl: add an api for getting ars_status flags

PATCH Superseded Vishal Verma 2 participants 3 messages Jun 6, 2018 libnvdimm: non-volatile memory device

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Vishal Verma

author maintainer
#0 lore raw

PATCH 1/1 ndctl: add an api for getting ars_status flags

The ARS status command defines a 'flags' field that wasn't being exposed via an API yet. Add a new ndctl_cmd_ars_get_flags() helper to retrieve this field.

---
 ndctl/lib/ars.c        | 10 ++++++++++
 ndctl/lib/libndctl.sym |  1 +
 ndctl/libndctl.h       |  1 +
 3 files changed, 12 insertions(+)
ndctl/lib/ars.c +10 -0
index e04b51e..b0a7ae6 100644
@@ -269,6 +269,16 @@ NDCTL_EXPORT unsigned long long ndctl_cmd_ars_get_record_len(
 	return ars_stat->ars_status->records[rec_index].length;
 }
 
+NDCTL_EXPORT unsigned int ndctl_cmd_ars_get_flags(struct ndctl_cmd *ars_stat)
+{
+	struct ndctl_ctx *ctx = ndctl_bus_get_ctx(cmd_to_bus(ars_stat));
+
+	if (!validate_ars_stat(ctx, ars_stat))
+		return 0;
+
+	return ars_stat->ars_status->flags;
+}
+
 NDCTL_EXPORT struct ndctl_cmd *ndctl_bus_cmd_new_clear_error(
 		unsigned long long address, unsigned long long len,
 		struct ndctl_cmd *ars_cap)
ndctl/lib/libndctl.sym +1 -0
index c1228e5..9940c7a 100644
@@ -365,4 +365,5 @@ global:
 	ndctl_cmd_ars_cap_get_clear_unit;
 	ndctl_namespace_inject_error2;
 	ndctl_namespace_uninject_error2;
+	ndctl_cmd_ars_get_flags;
 } LIBNDCTL_15;
ndctl/libndctl.h +1 -0
index be997ac..99218e6 100644
@@ -210,6 +210,7 @@ struct ndctl_cmd *ndctl_bus_cmd_new_clear_error(unsigned long long address,
 unsigned long long ndctl_cmd_clear_error_get_cleared(
 		struct ndctl_cmd *clear_err);
 unsigned int ndctl_cmd_ars_cap_get_clear_unit(struct ndctl_cmd *ars_cap);
+unsigned int ndctl_cmd_ars_get_flags(struct ndctl_cmd *ars_stat);
 
 /*
  * Note: ndctl_cmd_smart_get_temperature is an alias for
Signature · 6 lines
2.17.0

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#1 lore raw
Quoted 7 lines · Vishal Verma

The ARS status command defines a 'flags' field that wasn't being exposed via an API yet. Add a new ndctl_cmd_ars_get_flags() helper to retrieve this field.

I'm wondering if we should add a 'get' routine for each flag value as to not expose the binary representation of the flags in case they ever change. The hope is that if some other platform added their own ARS-like facility that we would be able to reuse these routines and translate between ACPI and a theoretical Open Firmware implementation, for example.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

author maintainer
#2 lore raw
Quoted 11 lines · Dan Williams
Quoted 8 lines · Vishal Verma

The ARS status command defines a 'flags' field that wasn't being exposed
via an API yet. Add a new ndctl_cmd_ars_get_flags() helper to retrieve this field.

Quoted 6 lines

I'm wondering if we should add a 'get' routine for each flag value as to not expose the binary representation of the flags in case they ever change. The hope is that if some other platform added their own ARS-like facility that we would be able to reuse these routines and translate between ACPI and a theoretical Open Firmware implementation, for example.

Yes that makes sense, I'll routines for all the flags we have today.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm