|
Jeff Moyer |
2c91dc |
From 11357d68b77392e4360ae2824e75bf8397a84885 Mon Sep 17 00:00:00 2001
|
|
Jeff Moyer |
2c91dc |
From: Redhairer Li <redhairer.li@intel.com>
|
|
Jeff Moyer |
2c91dc |
Date: Sat, 9 Jan 2021 23:36:33 +0800
|
|
Jeff Moyer |
2c91dc |
Subject: [PATCH 007/217] msft: Add xlat_firmware_status for JEDEC Byte
|
|
Jeff Moyer |
2c91dc |
Addressable Energy Backed DSM
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
Translate the status codes of the result of JEDEC Byte Addressable Energy Backed
|
|
Jeff Moyer |
2c91dc |
DSM to generic errno style error codes.
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
Signed-off-by: Li Redhairer <redhairer.li@intel.com>
|
|
Jeff Moyer |
2c91dc |
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
|
|
Jeff Moyer |
2c91dc |
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
|
|
Jeff Moyer |
2c91dc |
Link: https://lore.kernel.org/r/20210109153633.8493-1-redhairer.li@intel.com
|
|
Jeff Moyer |
2c91dc |
---
|
|
Jeff Moyer |
2c91dc |
ndctl/lib/msft.c | 22 ++++++++++++++++++++++
|
|
Jeff Moyer |
2c91dc |
ndctl/lib/msft.h | 6 ++++++
|
|
Jeff Moyer |
2c91dc |
2 files changed, 28 insertions(+)
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
diff --git a/ndctl/lib/msft.c b/ndctl/lib/msft.c
|
|
Jeff Moyer |
2c91dc |
index 145872c..3112799 100644
|
|
Jeff Moyer |
2c91dc |
--- a/ndctl/lib/msft.c
|
|
Jeff Moyer |
2c91dc |
+++ b/ndctl/lib/msft.c
|
|
Jeff Moyer |
2c91dc |
@@ -149,10 +149,32 @@ static unsigned int msft_cmd_smart_get_life_used(struct ndctl_cmd *cmd)
|
|
Jeff Moyer |
2c91dc |
return 100 - CMD_MSFT_SMART(cmd)->nvm_lifetime;
|
|
Jeff Moyer |
2c91dc |
}
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
+static int msft_cmd_xlat_firmware_status(struct ndctl_cmd *cmd)
|
|
Jeff Moyer |
2c91dc |
+{
|
|
Jeff Moyer |
2c91dc |
+ unsigned int status;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ status = cmd->get_firmware_status(cmd) & NDN_MSFT_STATUS_MASK;
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ /* Common statuses */
|
|
Jeff Moyer |
2c91dc |
+ switch (status) {
|
|
Jeff Moyer |
2c91dc |
+ case NDN_MSFT_STATUS_SUCCESS:
|
|
Jeff Moyer |
2c91dc |
+ return 0;
|
|
Jeff Moyer |
2c91dc |
+ case NDN_MSFT_STATUS_NOTSUPP:
|
|
Jeff Moyer |
2c91dc |
+ return -EOPNOTSUPP;
|
|
Jeff Moyer |
2c91dc |
+ case NDN_MSFT_STATUS_INVALPARM:
|
|
Jeff Moyer |
2c91dc |
+ return -EINVAL;
|
|
Jeff Moyer |
2c91dc |
+ case NDN_MSFT_STATUS_I2CERR:
|
|
Jeff Moyer |
2c91dc |
+ return -EIO;
|
|
Jeff Moyer |
2c91dc |
+ }
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
+ return -ENOMSG;
|
|
Jeff Moyer |
2c91dc |
+}
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
struct ndctl_dimm_ops * const msft_dimm_ops = &(struct ndctl_dimm_ops) {
|
|
Jeff Moyer |
2c91dc |
.new_smart = msft_dimm_cmd_new_smart,
|
|
Jeff Moyer |
2c91dc |
.smart_get_flags = msft_cmd_smart_get_flags,
|
|
Jeff Moyer |
2c91dc |
.smart_get_health = msft_cmd_smart_get_health,
|
|
Jeff Moyer |
2c91dc |
.smart_get_media_temperature = msft_cmd_smart_get_media_temperature,
|
|
Jeff Moyer |
2c91dc |
.smart_get_life_used = msft_cmd_smart_get_life_used,
|
|
Jeff Moyer |
2c91dc |
+ .xlat_firmware_status = msft_cmd_xlat_firmware_status,
|
|
Jeff Moyer |
2c91dc |
};
|
|
Jeff Moyer |
2c91dc |
diff --git a/ndctl/lib/msft.h b/ndctl/lib/msft.h
|
|
Jeff Moyer |
2c91dc |
index 7cfd26f..978cc11 100644
|
|
Jeff Moyer |
2c91dc |
--- a/ndctl/lib/msft.h
|
|
Jeff Moyer |
2c91dc |
+++ b/ndctl/lib/msft.h
|
|
Jeff Moyer |
2c91dc |
@@ -50,4 +50,10 @@ struct ndn_pkg_msft {
|
|
Jeff Moyer |
2c91dc |
union ndn_msft_cmd u;
|
|
Jeff Moyer |
2c91dc |
} __attribute__((packed));
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
+#define NDN_MSFT_STATUS_MASK 0xffff
|
|
Jeff Moyer |
2c91dc |
+#define NDN_MSFT_STATUS_SUCCESS 0
|
|
Jeff Moyer |
2c91dc |
+#define NDN_MSFT_STATUS_NOTSUPP 1
|
|
Jeff Moyer |
2c91dc |
+#define NDN_MSFT_STATUS_INVALPARM 2
|
|
Jeff Moyer |
2c91dc |
+#define NDN_MSFT_STATUS_I2CERR 3
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
#endif /* __NDCTL_MSFT_H__ */
|
|
Jeff Moyer |
2c91dc |
--
|
|
Jeff Moyer |
2c91dc |
2.27.0
|
|
Jeff Moyer |
2c91dc |
|