From: Vaibhav Jain <vaibhav@linux.ibm.com>
To: linux-nvdimm@lists.01.org
Cc: Vaibhav Jain <vaibhav@linux.ibm.com>,
"Aneesh Kumar K . V" <aneesh.kumar@linux.ibm.com>
Subject: [ndctl PATCH v7 5/5] libndctl,papr_scm: Implement support for PAPR_PDSM_HEALTH
Date: Thu, 18 Jun 2020 12:31:04 +0530 [thread overview]
Message-ID: <20200618070104.239446-6-vaibhav@linux.ibm.com> (raw)
In-Reply-To: <20200618070104.239446-1-vaibhav@linux.ibm.com>
Add support for reporting DIMM health and shutdown state by issuing
PAPR_PDSM_HEALTH request to papr_scm module. It returns an
instance of 'struct nd_papr_pdsm_health' as defined in
'papr_pdsm.h'. The patch provides support for dimm-ops
'new_smart', 'smart_get_health' & 'smart_get_shutdown_state' as newly
introduced functions papr_new_smart_health(), papr_smart_get_health()
& papr_smart_get_shutdown_state() respectively. These callbacks should
enable ndctl to report DIMM health.
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
---
Changelog:
v6..v7:
* None
v5..v6:
* Updated patch description to reflect removal of
update_dimm_health().
* Update papr_smart_get_flags() to parse the 'struct ndctl_cmd'
instance and return appropriate ND_SMART_XXX flags.
* Callbacks papr_smart_get_health() , papr_smart_get_shutdown_state()
callbacks to use 'struct ndctl_cmd' instead of 'dimm_priv'.
* Added update_dimm_flags() to update 'struct ndctl_dimm' with the
flags returned in 'struct nd_papr_psdm_health'.
v4..v5:
* Updated patch description to reflect updated names of struct and
defines that have the term 'scm' removed.
v3..v4:
* None
v2..v3:
* None
v1..v2:
* Squashed patch to report nvdimm bad shutdown state with this patch.
* Switched to new structs/enums as defined in papr_scm_pdsm.h
---
ndctl/lib/papr.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 72 insertions(+), 1 deletion(-)
diff --git a/ndctl/lib/papr.c b/ndctl/lib/papr.c
index ebf31bac9a23..d9ce253369b3 100644
--- a/ndctl/lib/papr.c
+++ b/ndctl/lib/papr.c
@@ -124,10 +124,23 @@ static struct ndctl_cmd *allocate_cmd(struct ndctl_dimm *dimm,
return cmd;
}
+/* Parse the nd_papr_pdsm_health and update dimm flags */
+static int update_dimm_flags(struct ndctl_dimm *dimm, struct nd_papr_pdsm_health *health)
+{
+ /* Update the dimm flags */
+ dimm->flags.f_arm = health->dimm_unarmed;
+ dimm->flags.f_flush = health->dimm_bad_shutdown;
+ dimm->flags.f_restore = health->dimm_bad_restore;
+ dimm->flags.f_smart = (health->dimm_health != 0);
+
+ return 0;
+}
+
/* Validate the ndctl_cmd and return applicable flags */
static unsigned int papr_smart_get_flags(struct ndctl_cmd *cmd)
{
struct nd_pkg_pdsm *pcmd;
+ struct nd_papr_pdsm_health health;
if (!cmd_is_valid(cmd))
return 0;
@@ -140,14 +153,72 @@ static unsigned int papr_smart_get_flags(struct ndctl_cmd *cmd)
return 0;
}
- /* return empty flags for now */
+ /*
+ * In case of nvdimm health PDSM, update dimm flags
+ * and return possible flags.
+ */
+ if (to_pdsm_cmd(cmd) == PAPR_PDSM_HEALTH) {
+ health = pcmd->payload.health;
+ update_dimm_flags(cmd->dimm, &health);
+ return ND_SMART_HEALTH_VALID | ND_SMART_SHUTDOWN_VALID;
+ }
+
+ /* Else return empty flags */
return 0;
}
+static struct ndctl_cmd *papr_new_smart_health(struct ndctl_dimm *dimm)
+{
+ struct ndctl_cmd *cmd;
+
+ cmd = allocate_cmd(dimm, PAPR_PDSM_HEALTH,
+ sizeof(struct nd_papr_pdsm_health));
+ if (!cmd)
+ papr_err(dimm, "Unable to allocate smart_health command\n");
+
+ return cmd;
+}
+
+static unsigned int papr_smart_get_health(struct ndctl_cmd *cmd)
+{
+ struct nd_papr_pdsm_health health;
+
+ /* Ignore in case of error or invalid pdsm */
+ if (!cmd_is_valid(cmd) ||
+ to_pdsm(cmd)->cmd_status != 0 ||
+ to_pdsm_cmd(cmd) != PAPR_PDSM_HEALTH)
+ return 0;
+
+ /* get the payload from command */
+ health = to_payload(cmd)->health;
+
+ /* Use some math to return one of defined ND_SMART_*_HEALTH values */
+ return !health.dimm_health ? 0 : 1 << (health.dimm_health - 1);
+}
+
+static unsigned int papr_smart_get_shutdown_state(struct ndctl_cmd *cmd)
+{
+ struct nd_papr_pdsm_health health;
+
+ /* Ignore in case of error or invalid pdsm */
+ if (!cmd_is_valid(cmd) ||
+ to_pdsm(cmd)->cmd_status != 0 ||
+ to_pdsm_cmd(cmd) != PAPR_PDSM_HEALTH)
+ return 0;
+
+ /* get the payload from command */
+ health = to_payload(cmd)->health;
+
+ /* return the bad shutdown flag returned from papr_scm */
+ return health.dimm_bad_shutdown;
+}
struct ndctl_dimm_ops * const papr_dimm_ops = &(struct ndctl_dimm_ops) {
.cmd_is_supported = papr_cmd_is_supported,
.smart_get_flags = papr_smart_get_flags,
.get_firmware_status = papr_get_firmware_status,
.xlat_firmware_status = papr_xlat_firmware_status,
+ .new_smart = papr_new_smart_health,
+ .smart_get_health = papr_smart_get_health,
+ .smart_get_shutdown_state = papr_smart_get_shutdown_state,
};
--
2.26.2
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org
prev parent reply other threads:[~2020-06-18 7:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-18 7:00 [ndctl PATCH v7 0/5] Add support for reporting papr nvdimm health Vaibhav Jain
2020-06-18 7:01 ` [ndctl PATCH v7 1/5] libndctl: Refactor out add_dimm() to handle NFIT specific init Vaibhav Jain
2020-06-18 7:01 ` [ndctl PATCH v7 2/5] libncdtl: Add initial support for NVDIMM_FAMILY_PAPR nvdimm family Vaibhav Jain
2020-06-18 7:01 ` [ndctl PATCH v7 3/5] libndctl,papr_scm: Add definitions for PAPR nvdimm specific methods Vaibhav Jain
2020-06-18 7:01 ` [ndctl PATCH v7 4/5] papr: Add scaffolding to issue and handle PDSM requests Vaibhav Jain
2020-06-18 7:01 ` Vaibhav Jain [this message]
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=20200618070104.239446-6-vaibhav@linux.ibm.com \
--to=vaibhav@linux.ibm.com \
--cc=aneesh.kumar@linux.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox