All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: Brian Boylston <brian.boylston@hpe.com>
Cc: "linux-nvdimm@lists.01.org" <linux-nvdimm@lists.01.org>
Subject: Re: [ndctl PATCH v2 1/4] libndctl: introduce ndctl_smart_ops
Date: Wed, 14 Sep 2016 19:22:23 -0700	[thread overview]
Message-ID: <CAPcyv4hDEgz9Y4KX3sQVNVw9K7ckuOeJVd4pUeFCagiTbpaZpw@mail.gmail.com> (raw)
In-Reply-To: <20160913174140.10810-2-brian.boylston@hpe.com>

On Tue, Sep 13, 2016 at 10:41 AM, Brian Boylston <brian.boylston@hpe.com> wrote:
> Add a layer of indirection for the ndctl_cmd_smart*() family of
> interfaces.  This will allow the underlying implementation to be
> switched based on the DSM family supported by the DIMM.
>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Brian Boylston <brian.boylston@hpe.com>
> ---
>  ndctl/lib/libndctl-private.h |  21 ++++++++
>  ndctl/lib/libndctl-smart.c   | 111 ++++++++++++++++++++++++++++++++++---------
>  ndctl/lib/libndctl.c         |   8 ++++
>  ndctl/libndctl.h.in          |   1 +
>  4 files changed, 118 insertions(+), 23 deletions(-)

Looks good to me and passes my regression tests.

Just one minor comment below:

>
> diff --git a/ndctl/lib/libndctl-private.h b/ndctl/lib/libndctl-private.h
> index 65ef86d..8d2ebfc 100644
> --- a/ndctl/lib/libndctl-private.h
> +++ b/ndctl/lib/libndctl-private.h
> @@ -201,6 +201,27 @@ struct ndctl_cmd {
>         };
>  };
>
> +struct ndctl_smart_ops {
> +       struct ndctl_cmd *(*new_smart)(struct ndctl_dimm *);
> +       unsigned int (*smart_get_flags)(struct ndctl_cmd *);
> +       unsigned int (*smart_get_health)(struct ndctl_cmd *);
> +       unsigned int (*smart_get_temperature)(struct ndctl_cmd *);
> +       unsigned int (*smart_get_spares)(struct ndctl_cmd *);
> +       unsigned int (*smart_get_alarm_flags)(struct ndctl_cmd *);
> +       unsigned int (*smart_get_life_used)(struct ndctl_cmd *);
> +       unsigned int (*smart_get_shutdown_state)(struct ndctl_cmd *);
> +       unsigned int (*smart_get_vendor_size)(struct ndctl_cmd *);
> +       unsigned char *(*smart_get_vendor_data)(struct ndctl_cmd *);
> +       struct ndctl_cmd *(*new_smart_threshold)(struct ndctl_dimm *);
> +       unsigned int (*smart_threshold_get_alarm_control)(struct ndctl_cmd *);
> +       unsigned int (*smart_threshold_get_temperature)(struct ndctl_cmd *);
> +       unsigned int (*smart_threshold_get_spares)(struct ndctl_cmd *);
> +};
> +
> +#if HAS_SMART == 1
> +struct ndctl_smart_ops intel_smart_ops;
> +#endif
> +
>  /* internal library helpers for conditionally defined command numbers */
>  #ifdef HAVE_NDCTL_ARS
>  static const int nd_cmd_ars_status = ND_CMD_ARS_STATUS;
> diff --git a/ndctl/lib/libndctl-smart.c b/ndctl/lib/libndctl-smart.c
> index cba1e9d..a172541 100644
> --- a/ndctl/lib/libndctl-smart.c
> +++ b/ndctl/lib/libndctl-smart.c
> @@ -16,7 +16,55 @@
>  #include <ndctl/libndctl.h>
>  #include "libndctl-private.h"
>
> -NDCTL_EXPORT struct ndctl_cmd *ndctl_dimm_cmd_new_smart(struct ndctl_dimm *dimm)
> +/*
> + * The smart_dimm_op() and smart_cmd_op() macros are used here to
> + * define the wrappers around the ndctl_smart_ops:
> + */
> +
> +#define smart_dimm_op(name, op) \
> +NDCTL_EXPORT struct ndctl_cmd *name( \
> +               struct ndctl_dimm *dimm) \
> +{ \
> +       struct ndctl_smart_ops *ops = ndctl_dimm_get_smart_ops(dimm); \
> +       if (ops && ops->op) \
> +               return ops->op(dimm); \
> +       else \
> +               return NULL; \
> +}
> +
> +smart_dimm_op(ndctl_dimm_cmd_new_smart, new_smart)
> +smart_dimm_op(ndctl_dimm_cmd_new_smart_threshold, new_smart_threshold)

There's only two of these routines and I don't suppose there will need
to have many more variants in the future.  Let's just open code them
and not use a macro.  The rest looks good.
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

  reply	other threads:[~2016-09-15  2:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-13 17:41 [ndctl PATCH v2 0/4] ndctl: add support for HPE type N SMART health data Brian Boylston
2016-09-13 17:41 ` [ndctl PATCH v2 1/4] libndctl: introduce ndctl_smart_ops Brian Boylston
2016-09-15  2:22   ` Dan Williams [this message]
2016-09-13 17:41 ` [ndctl PATCH v2 2/4] libndctl: record dsm family in add_dimm() Brian Boylston
2016-09-15  0:44   ` Dan Williams
2016-09-15 18:17     ` Boylston, Brian
2016-09-15 19:27       ` Dan Williams
2016-09-13 17:41 ` [ndctl PATCH v2 3/4] libndctl: enable ND_CMD_CALL Brian Boylston
2016-09-13 17:41 ` [ndctl PATCH v2 4/4] libndctl: add support for the HPE1 family of DSM SMART functions Brian Boylston

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPcyv4hDEgz9Y4KX3sQVNVw9K7ckuOeJVd4pUeFCagiTbpaZpw@mail.gmail.com \
    --to=dan.j.williams@intel.com \
    --cc=brian.boylston@hpe.com \
    --cc=linux-nvdimm@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.