On Tue, Mar 20, 2018 at 2:50 PM, Dave Jiang <dave.ji...@intel.com> wrote:
> Adding helper functions to iterate through sysfs region persistence domain
> attribute. The region will display the domain with the most persistence for 
> the
> region.  The bus will display the domain attribute with the least persistence
> amongst all the regions. ndctl_bus_get_persistence_domain() and
> ndctl_region_get_persistence_domain are exported. ndctl list will also display
> the region persistence domain as well.
>
> Signed-off-by: Dave Jiang <dave.ji...@intel.com>
> ---
>
> v3:
> - fixed up return types per Ross's comments
> - removed persistence_domain for bus and calculate on the fly per Dan's 
> comment
>
> v2:
> - Simplied scanning of persistence domain from Ross's comments.
>
>  ndctl/lib/libndctl.c   |   85 
> ++++++++++++++++++++++++++++++++++++++++++++++++
>  ndctl/lib/libndctl.sym |    2 +
>  ndctl/libndctl.h       |   11 ++++++
>  ndctl/list.c           |   16 +++++++++
>  4 files changed, 114 insertions(+)
[..]
> diff --git a/ndctl/libndctl.h b/ndctl/libndctl.h
> index f3a27411..84f441ef 100644
> --- a/ndctl/libndctl.h
> +++ b/ndctl/libndctl.h
> @@ -115,6 +115,7 @@ int ndctl_bus_is_cmd_supported(struct ndctl_bus *bus, int 
> cmd);
>  unsigned int ndctl_bus_get_revision(struct ndctl_bus *bus);
>  unsigned int ndctl_bus_get_id(struct ndctl_bus *bus);
>  const char *ndctl_bus_get_provider(struct ndctl_bus *bus);
> +enum ndctl_persistence ndctl_bus_get_persistence_domain(struct ndctl_bus 
> *bus);
>  int ndctl_bus_wait_probe(struct ndctl_bus *bus);
>  int ndctl_bus_wait_for_scrub_completion(struct ndctl_bus *bus);
>  unsigned int ndctl_bus_get_scrub_count(struct ndctl_bus *bus);
> @@ -305,6 +306,14 @@ struct badblock {
>         unsigned long long offset;
>         unsigned int len;
>  };
> +
> +enum ndctl_persistence {

Let's fully spell this out this type as "enum ndctl_persistence_domain"

> +       PERSISTENCE_NONE = 0,
> +       PERSISTENCE_MEM_CTRL,
> +       PERSISTENCE_CPU_CACHE,
> +       PERSISTENCE_UNKNOWN,
> +};

Just in case there might be additional theoretical persistence domains
in the future between cache and memory controller, or memory
controller and media lets pad some values into this definition.

I.e. something like:

       PERSISTENCE_NONE = 0,
       PERSISTENCE_MEM_CTRL = 10,
       PERSISTENCE_CPU_CACHE = 20,
       PERSISTENCE_UNKNOWN = INT_MAX,
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

Reply via email to