diff mbox

[ndctl,1/4] make interface to check device/nfit/dsm_mask flags

Message ID 20170818133348.8EAE.E1E9C6FF@jp.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Gotou, Yasunori/五島 康文 Aug. 18, 2017, 4:33 a.m. UTC
To check what feature can be called via ND_CMD_CALL, ndctl need to read
device/nfit/dsm_mask. This patch make an interface to check it in libndctl.c


Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>
---
 ndctl/lib/libndctl.c | 13 +++++++++++++
 ndctl/libndctl.h.in  |  1 +
 2 files changed, 14 insertions(+)

Comments

Dan Williams Aug. 25, 2017, 11:45 p.m. UTC | #1
On Thu, Aug 17, 2017 at 9:33 PM, Yasunori Goto <y-goto@jp.fujitsu.com> wrote:
>
> To check what feature can be called via ND_CMD_CALL, ndctl need to read
> device/nfit/dsm_mask. This patch make an interface to check it in libndctl.c
>
>
> Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>
> ---
>  ndctl/lib/libndctl.c | 13 +++++++++++++
>  ndctl/libndctl.h.in  |  1 +
>  2 files changed, 14 insertions(+)
>
> diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
> index c2e0efb..93692e5 100644
> --- a/ndctl/lib/libndctl.c
> +++ b/ndctl/lib/libndctl.c
> @@ -102,6 +102,7 @@ struct ndctl_bus {
>         size_t buf_len;
>         char *wait_probe_path;
>         unsigned long dsm_mask;
> +       unsigned long bus_dsm_mask;
>  };
>
>  /**
> @@ -846,6 +847,12 @@ static void *add_bus(void *parent, int id, const char *ctl_base)
>                 bus->revision = strtoul(buf, NULL, 0);
>         }
>
> +       sprintf(path, "%s/device/nfit/dsm_mask", ctl_base);
> +       if (sysfs_read_attr(ctx, path, buf) < 0)
> +               bus->bus_dsm_mask = 0;
> +       else
> +               bus->bus_dsm_mask = strtoul(buf, NULL, 16);
> +
>         sprintf(path, "%s/device/provider", ctl_base);
>         if (sysfs_read_attr(ctx, path, buf) < 0)
>                 goto err_read;
> @@ -1101,6 +1108,12 @@ NDCTL_EXPORT int ndctl_bus_is_cmd_supported(struct ndctl_bus *bus,
>         return !!(bus->dsm_mask & (1ULL << cmd));
>  }
>
> +NDCTL_EXPORT int ndctl_bus_is_sub_cmd_supported(struct ndctl_bus *bus,

Looks good, let's call this ndctl_bus_is_passthru_cmd_supported()
since ndctl_bus_is_cmd_supported() is telling you about native bus
commands that Linux supports generically and "passthru" is for command
payloads that Linux is just blindly passing through to the firmware
implementation. As far as the libndctl user is concerned they should
not be able to easily tell the difference between an ACPI defined
NVDIMM bus or Open Firmware / some other platform.
Gotou, Yasunori/五島 康文 Aug. 28, 2017, 1:01 a.m. UTC | #2
> On Thu, Aug 17, 2017 at 9:33 PM, Yasunori Goto <y-goto@jp.fujitsu.com> wrote:
> >
> > To check what feature can be called via ND_CMD_CALL, ndctl need to read
> > device/nfit/dsm_mask. This patch make an interface to check it in libndctl.c
> >
> >
> > Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>
> > ---
> >  ndctl/lib/libndctl.c | 13 +++++++++++++
> >  ndctl/libndctl.h.in  |  1 +
> >  2 files changed, 14 insertions(+)
> >
> > diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
> > index c2e0efb..93692e5 100644
> > --- a/ndctl/lib/libndctl.c
> > +++ b/ndctl/lib/libndctl.c
> > @@ -102,6 +102,7 @@ struct ndctl_bus {
> >         size_t buf_len;
> >         char *wait_probe_path;
> >         unsigned long dsm_mask;
> > +       unsigned long bus_dsm_mask;
> >  };
> >
> >  /**
> > @@ -846,6 +847,12 @@ static void *add_bus(void *parent, int id, const char *ctl_base)
> >                 bus->revision = strtoul(buf, NULL, 0);
> >         }
> >
> > +       sprintf(path, "%s/device/nfit/dsm_mask", ctl_base);
> > +       if (sysfs_read_attr(ctx, path, buf) < 0)
> > +               bus->bus_dsm_mask = 0;
> > +       else
> > +               bus->bus_dsm_mask = strtoul(buf, NULL, 16);
> > +
> >         sprintf(path, "%s/device/provider", ctl_base);
> >         if (sysfs_read_attr(ctx, path, buf) < 0)
> >                 goto err_read;
> > @@ -1101,6 +1108,12 @@ NDCTL_EXPORT int ndctl_bus_is_cmd_supported(struct ndctl_bus *bus,
> >         return !!(bus->dsm_mask & (1ULL << cmd));
> >  }
> >
> > +NDCTL_EXPORT int ndctl_bus_is_sub_cmd_supported(struct ndctl_bus *bus,
> 
> Looks good, let's call this ndctl_bus_is_passthru_cmd_supported()
> since ndctl_bus_is_cmd_supported() is telling you about native bus
> commands that Linux supports generically and "passthru" is for command
> payloads that Linux is just blindly passing through to the firmware
> implementation. As far as the libndctl user is concerned they should
> not be able to easily tell the difference between an ACPI defined
> NVDIMM bus or Open Firmware / some other platform.
> 

I see. I'll change it.
diff mbox

Patch

diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index c2e0efb..93692e5 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -102,6 +102,7 @@  struct ndctl_bus {
 	size_t buf_len;
 	char *wait_probe_path;
 	unsigned long dsm_mask;
+	unsigned long bus_dsm_mask;
 };
 
 /**
@@ -846,6 +847,12 @@  static void *add_bus(void *parent, int id, const char *ctl_base)
 		bus->revision = strtoul(buf, NULL, 0);
 	}
 
+	sprintf(path, "%s/device/nfit/dsm_mask", ctl_base);
+	if (sysfs_read_attr(ctx, path, buf) < 0)
+		bus->bus_dsm_mask = 0;
+	else
+		bus->bus_dsm_mask = strtoul(buf, NULL, 16);
+
 	sprintf(path, "%s/device/provider", ctl_base);
 	if (sysfs_read_attr(ctx, path, buf) < 0)
 		goto err_read;
@@ -1101,6 +1108,12 @@  NDCTL_EXPORT int ndctl_bus_is_cmd_supported(struct ndctl_bus *bus,
 	return !!(bus->dsm_mask & (1ULL << cmd));
 }
 
+NDCTL_EXPORT int ndctl_bus_is_sub_cmd_supported(struct ndctl_bus *bus,
+		int cmd)
+{
+	return !!(bus->bus_dsm_mask & (1ULL << cmd));
+}
+
 NDCTL_EXPORT unsigned int ndctl_bus_get_revision(struct ndctl_bus *bus)
 {
 	return bus->revision;
diff --git a/ndctl/libndctl.h.in b/ndctl/libndctl.h.in
index 855d883..206c441 100644
--- a/ndctl/libndctl.h.in
+++ b/ndctl/libndctl.h.in
@@ -109,6 +109,7 @@  struct ndctl_bus *ndctl_bus_get_by_provider(struct ndctl_ctx *ctx,
 		const char *provider);
 const char *ndctl_bus_get_cmd_name(struct ndctl_bus *bus, int cmd);
 int ndctl_bus_is_cmd_supported(struct ndctl_bus *bus, int cmd);
+int ndctl_bus_is_sub_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);