diff mbox

[ndctl,1/5] ndctl: Introduce libndctl-nfit.h

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

Commit Message

Gotou, Yasunori/五島 康文 Sept. 1, 2017, 1:16 p.m. UTC
This patch introduces libndctl-nfit.h.

Since these command can be executed via ND_CMD_CALL,
libndctl.h which is shared between ndctl command and kernel does not
have to include these defintions.

So, libndctl-nfit.h, which is defined for only ndctl, is created instead,
and move definitions from ndctl.h to it.

Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>
---
 ndctl/libndctl-nfit.h | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++
 ndctl/ndctl.h         | 37 -------------------------
 2 files changed, 76 insertions(+), 37 deletions(-)

Comments

Dan Williams Sept. 5, 2017, 6:13 p.m. UTC | #1
On Fri, Sep 1, 2017 at 6:16 AM, Yasunori Goto <y-goto@jp.fujitsu.com> wrote:
>
> This patch introduces libndctl-nfit.h.
>
> Since these command can be executed via ND_CMD_CALL,
> libndctl.h which is shared between ndctl command and kernel does not
> have to include these defintions.
>
> So, libndctl-nfit.h, which is defined for only ndctl, is created instead,
> and move definitions from ndctl.h to it.
>
> Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>
> ---
>  ndctl/libndctl-nfit.h | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  ndctl/ndctl.h         | 37 -------------------------
>  2 files changed, 76 insertions(+), 37 deletions(-)
>
> diff --git a/ndctl/libndctl-nfit.h b/ndctl/libndctl-nfit.h
> new file mode 100644
> index 0000000..1258d2e
> --- /dev/null
> +++ b/ndctl/libndctl-nfit.h
> @@ -0,0 +1,76 @@
> +/*
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU Lesser General Public License,
> + * version 2.1, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope it will be useful, but WITHOUT ANY
> + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
> + * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
> + * more details.
> + */
> +
> +#ifndef __LIBNDCTL_NFIT_H__
> +#define __LIBNDCTL_NFIT_H__
> +
> +/*
> + * libndctl-nfit.h : definitions for NFIT related commands/functions.
> + */
> +
> +/* nfit command numbers which are called via ND_CMD_CALL */
> +enum {
> +       NFIT_CMD_TRANSLATE_SPA = 5,
> +       NFIT_CMD_ARS_INJECT_SET = 7,
> +       NFIT_CMD_ARS_INJECT_CLEAR = 8,
> +       NFIT_CMD_ARS_INJECT_GET = 9,
> +};
> +
> +/* error number of Translate SPA by firmware  */
> +#define ND_TRANSLATE_SPA_STATUS_INVALID_SPA  2
> +
> +/*
> + * The following structures are command packages which are
> + * defined by ACPI 6.2 (or later).
> + */
> +
> +/* For Translate SPA */
> +struct nd_cmd_translate_spa {
> +       __u64 spa;
> +       __u32 status;
> +       __u8  flags;
> +       __u8  _reserved[3];
> +       __u64 translate_length;
> +       __u32 num_nvdimms;
> +       struct nd_nvdimm_device {
> +               __u32 nfit_device_handle;
> +               __u32 _reserved;
> +               __u64 dpa;
> +       } devices[0];
> +
> +}; /* naturally packed */
> +

Sorry, I wasn't clear. Only "nd_cmd_ars_err_inj_stat" is naturally
packed the others are not. I can fix this up when I apply it.
Dan Williams Sept. 5, 2017, 9:06 p.m. UTC | #2
On Tue, Sep 5, 2017 at 11:13 AM, Dan Williams <dan.j.williams@intel.com>
wrote:

> On Fri, Sep 1, 2017 at 6:16 AM, Yasunori Goto <y-goto@jp.fujitsu.com>
> wrote:
> >
> > This patch introduces libndctl-nfit.h.
> >
> > Since these command can be executed via ND_CMD_CALL,
> > libndctl.h which is shared between ndctl command and kernel does not
> > have to include these defintions.
> >
> > So, libndctl-nfit.h, which is defined for only ndctl, is created instead,
> > and move definitions from ndctl.h to it.
> >
> > Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>
> > ---
> >  ndctl/libndctl-nfit.h | 76 ++++++++++++++++++++++++++++++
> +++++++++++++++++++++
> >  ndctl/ndctl.h         | 37 -------------------------
> >  2 files changed, 76 insertions(+), 37 deletions(-)
> >
> > diff --git a/ndctl/libndctl-nfit.h b/ndctl/libndctl-nfit.h
> > new file mode 100644
> > index 0000000..1258d2e
> > --- /dev/null
> > +++ b/ndctl/libndctl-nfit.h
> > @@ -0,0 +1,76 @@
> > +/*
> > + * This program is free software; you can redistribute it and/or modify
> it
> > + * under the terms and conditions of the GNU Lesser General Public
> License,
> > + * version 2.1, as published by the Free Software Foundation.
> > + *
> > + * This program is distributed in the hope it will be useful, but
> WITHOUT ANY
> > + * WARRANTY; without even the implied warranty of MERCHANTABILITY or
> FITNESS
> > + * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
> for
> > + * more details.
> > + */
> > +
> > +#ifndef __LIBNDCTL_NFIT_H__
> > +#define __LIBNDCTL_NFIT_H__
> > +
> > +/*
> > + * libndctl-nfit.h : definitions for NFIT related commands/functions.
> > + */
> > +
> > +/* nfit command numbers which are called via ND_CMD_CALL */
> > +enum {
> > +       NFIT_CMD_TRANSLATE_SPA = 5,
> > +       NFIT_CMD_ARS_INJECT_SET = 7,
> > +       NFIT_CMD_ARS_INJECT_CLEAR = 8,
> > +       NFIT_CMD_ARS_INJECT_GET = 9,
> > +};
> > +
> > +/* error number of Translate SPA by firmware  */
> > +#define ND_TRANSLATE_SPA_STATUS_INVALID_SPA  2
> > +
> > +/*
> > + * The following structures are command packages which are
> > + * defined by ACPI 6.2 (or later).
> > + */
> > +
> > +/* For Translate SPA */
> > +struct nd_cmd_translate_spa {
> > +       __u64 spa;
> > +       __u32 status;
> > +       __u8  flags;
> > +       __u8  _reserved[3];
> > +       __u64 translate_length;
> > +       __u32 num_nvdimms;
> > +       struct nd_nvdimm_device {
> > +               __u32 nfit_device_handle;
> > +               __u32 _reserved;
> > +               __u64 dpa;
> > +       } devices[0];
> > +
> > +}; /* naturally packed */
> > +
>
> Sorry, I wasn't clear. Only "nd_cmd_ars_err_inj_stat" is naturally
> packed the others are not. I can fix this up when I apply it.
>

Actually, since there's some other fixups needed on this series, I'll let
you resend this with the "attribute packed" statements added back in. I'll
follow on later with kernel and ndctl patches to remove the ones that are
not needed.
Gotou, Yasunori/五島 康文 Sept. 6, 2017, 1:28 a.m. UTC | #3
> Actually, since there's some other fixups needed on this series, I'll let
> you resend this with the "attribute packed" statements added back in. I'll
> follow on later with kernel and ndctl patches to remove the ones that are
> not needed.

Hmm, since I may still misunderstand yet, let me confirm it.

In my next patch, "attribute packed" statements should be added 
to ALL of structures again.

(that is, the followings should have "attribute packed" again.
  - nd_cmd_translate_spa
  - nd_cmd_ars_err_inj
  - nd_cmd_ars_err_inj_clear
  - nd_cmd_ars_err_inj_stat
)

Is this correct?
Dan Williams Sept. 6, 2017, 1:44 a.m. UTC | #4
On Tue, Sep 5, 2017 at 6:28 PM, Yasunori Goto <y-goto@jp.fujitsu.com> wrote:

> > Actually, since there's some other fixups needed on this series, I'll let
> > you resend this with the "attribute packed" statements added back in.
> I'll
> > follow on later with kernel and ndctl patches to remove the ones that are
> > not needed.
>
> Hmm, since I may still misunderstand yet, let me confirm it.
>
> In my next patch, "attribute packed" statements should be added
> to ALL of structures again.
>
> (that is, the followings should have "attribute packed" again.
>   - nd_cmd_translate_spa
>   - nd_cmd_ars_err_inj
>   - nd_cmd_ars_err_inj_clear
>   - nd_cmd_ars_err_inj_stat
> )
>
> Is this correct?
>

Yes.

Then I can address all the places where the cleanup can happen in one patch
rather than just doing this one change in isolation. For example, some of
the existing ones in ndctl.h need conversion, as well as some of the
payloads in hpe.h.
diff mbox

Patch

diff --git a/ndctl/libndctl-nfit.h b/ndctl/libndctl-nfit.h
new file mode 100644
index 0000000..1258d2e
--- /dev/null
+++ b/ndctl/libndctl-nfit.h
@@ -0,0 +1,76 @@ 
+/*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 2.1, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
+ * more details.
+ */
+
+#ifndef __LIBNDCTL_NFIT_H__
+#define __LIBNDCTL_NFIT_H__
+
+/*
+ * libndctl-nfit.h : definitions for NFIT related commands/functions.
+ */
+
+/* nfit command numbers which are called via ND_CMD_CALL */
+enum {
+	NFIT_CMD_TRANSLATE_SPA = 5,
+	NFIT_CMD_ARS_INJECT_SET = 7,
+	NFIT_CMD_ARS_INJECT_CLEAR = 8,
+	NFIT_CMD_ARS_INJECT_GET = 9,
+};
+
+/* error number of Translate SPA by firmware  */
+#define ND_TRANSLATE_SPA_STATUS_INVALID_SPA  2
+
+/*
+ * The following structures are command packages which are
+ * defined by ACPI 6.2 (or later).
+ */
+
+/* For Translate SPA */
+struct nd_cmd_translate_spa {
+	__u64 spa;
+	__u32 status;
+	__u8  flags;
+	__u8  _reserved[3];
+	__u64 translate_length;
+	__u32 num_nvdimms;
+	struct nd_nvdimm_device {
+		__u32 nfit_device_handle;
+		__u32 _reserved;
+		__u64 dpa;
+	} devices[0];
+
+}; /* naturally packed */
+
+/* For ARS Error Inject */
+struct nd_cmd_ars_err_inj {
+	__u64 err_inj_spa_range_base;
+	__u64 err_inj_spa_range_length;
+	__u8  err_inj_options;
+	__u32 status;
+}; /* naturally packed */
+
+/* For ARS Error Inject Clear */
+struct nd_cmd_ars_err_inj_clr {
+	__u64 err_inj_clr_spa_range_base;
+	__u64 err_inj_clr_spa_range_length;
+	__u32 status;
+}; /* naturally packed */
+
+/* For ARS Error Inject Status Query */
+struct nd_cmd_ars_err_inj_stat {
+	__u32 status;
+	__u32 inj_err_rec_count;
+	struct nd_error_stat_query_record {
+		__u64 err_inj_stat_spa_range_base;
+		__u64 err_inj_stat_spa_range_length;
+	} record[0];
+}; /* naturally packed */
+
+#endif /* __LIBNDCTL_NFIT_H__ */
diff --git a/ndctl/ndctl.h b/ndctl/ndctl.h
index d70b97d..2dd461b 100644
--- a/ndctl/ndctl.h
+++ b/ndctl/ndctl.h
@@ -145,43 +145,6 @@  struct nd_cmd_clear_error {
 	__u64 cleared;
 } __attribute__((packed));
 
-struct nd_cmd_trans_spa {
-	__u64 spa;
-	__u32 status;
-	__u8  flags;
-	__u8  _reserved[3];
-	__u64 trans_length;
-	__u32 num_nvdimms;
-	struct nd_nvdimm_device {
-		__u32 nfit_device_handle;
-		__u32 _reserved;
-		__u64 dpa;
-	} __attribute__((packed)) devices[0];
-
-} __attribute__((packed));
-
-struct nd_cmd_ars_err_inj {
-	__u64 err_inj_spa_range_base;
-	__u64 err_inj_spa_range_length;
-	__u8  err_inj_options;
-	__u32 status;
-} __attribute__((packed));
-
-struct nd_cmd_ars_err_inj_clr {
-	__u64 err_inj_clr_spa_range_base;
-	__u64 err_inj_clr_spa_range_length;
-	__u32 status;
-} __attribute__((packed));
-
-struct nd_cmd_ars_err_inj_stat {
-	__u32 status;
-	__u32 inj_err_rec_count;
-	struct nd_error_stat_query_record {
-		__u64 err_inj_stat_spa_range_base;
-		__u64 err_inj_stat_spa_range_length;
-	} __attribute__((packed)) record[0];
-} __attribute__((packed));
-
 enum {
 	ND_CMD_IMPLEMENTED = 0,