@@ -395,18 +395,26 @@ out:
} \
}
-static int smart_inject(struct ndctl_dimm *dimm)
+static int smart_inject(struct ndctl_dimm *dimm, unsigned int inject_types)
{
const char *name = ndctl_dimm_get_devname(dimm);
struct ndctl_cmd *si_cmd = NULL;
int rc = -EOPNOTSUPP;
- send_inject_val(media_temperature)
- send_inject_val(ctrl_temperature)
- send_inject_val(spares)
- send_inject_bool(fatal)
- send_inject_bool(unsafe_shutdown)
+ if (inject_types & ND_SMART_INJECT_MEDIA_TEMPERATURE)
+ send_inject_val(media_temperature);
+ if (inject_types & ND_SMART_INJECT_CTRL_TEMPERATURE)
+ send_inject_val(ctrl_temperature);
+
+ if (inject_types & ND_SMART_INJECT_SPARES_REMAINING)
+ send_inject_val(spares);
+
+ if (inject_types & ND_SMART_INJECT_HEALTH_STATE)
+ send_inject_bool(fatal);
+
+ if (inject_types & ND_SMART_INJECT_UNCLEAN_SHUTDOWN)
+ send_inject_bool(unsafe_shutdown);
out:
ndctl_cmd_unref(si_cmd);
return rc;
@@ -417,6 +425,7 @@ static int dimm_inject_smart(struct ndctl_dimm *dimm)
struct json_object *jhealth;
struct json_object *jdimms;
struct json_object *jdimm;
+ unsigned int supported_types;
int rc;
rc = ndctl_dimm_smart_inject_supported(dimm);
@@ -433,6 +442,14 @@ static int dimm_inject_smart(struct ndctl_dimm *dimm)
error("%s: smart injection not supported by either platform firmware or the kernel.",
ndctl_dimm_get_devname(dimm));
return rc;
+ default:
+ if (rc < 0) {
+ error("%s: Unknown error %d while checking for smart injection support",
+ ndctl_dimm_get_devname(dimm), rc);
+ return rc;
+ }
+ supported_types = rc;
+ break;
}
if (sctx.op_mask & (1 << OP_SET)) {
@@ -441,7 +458,7 @@ static int dimm_inject_smart(struct ndctl_dimm *dimm)
goto out;
}
if (sctx.op_mask & (1 << OP_INJECT)) {
- rc = smart_inject(dimm);
+ rc = smart_inject(dimm, supported_types);
if (rc)
goto out;
}
@@ -455,7 +455,12 @@ static int intel_dimm_smart_inject_supported(struct ndctl_dimm *dimm)
return -EIO;
}
- return 0;
+ /* Indicate all smart injection types are supported */
+ return ND_SMART_INJECT_SPARES_REMAINING |
+ ND_SMART_INJECT_MEDIA_TEMPERATURE |
+ ND_SMART_INJECT_CTRL_TEMPERATURE |
+ ND_SMART_INJECT_HEALTH_STATE |
+ ND_SMART_INJECT_UNCLEAN_SHUTDOWN;
}
static const char *intel_cmd_desc(int fn)
@@ -69,6 +69,13 @@ extern "C" {
#define ND_EVENT_HEALTH_STATE (1 << 3)
#define ND_EVENT_UNCLEAN_SHUTDOWN (1 << 4)
+/* Flags indicating support for various smart injection types */
+#define ND_SMART_INJECT_SPARES_REMAINING (1 << 0)
+#define ND_SMART_INJECT_MEDIA_TEMPERATURE (1 << 1)
+#define ND_SMART_INJECT_CTRL_TEMPERATURE (1 << 2)
+#define ND_SMART_INJECT_HEALTH_STATE (1 << 3)
+#define ND_SMART_INJECT_UNCLEAN_SHUTDOWN (1 << 4)
+
size_t ndctl_min_namespace_size(void);
size_t ndctl_sizeof_namespace_index(void);
size_t ndctl_sizeof_namespace_label(void);
@@ -311,6 +318,7 @@ int ndctl_cmd_smart_inject_spares(struct ndctl_cmd *cmd, bool enable,
unsigned int spares);
int ndctl_cmd_smart_inject_fatal(struct ndctl_cmd *cmd, bool enable);
int ndctl_cmd_smart_inject_unsafe_shutdown(struct ndctl_cmd *cmd, bool enable);
+/* Returns a bitmap of ND_SMART_INJECT_* supported */
int ndctl_dimm_smart_inject_supported(struct ndctl_dimm *dimm);
struct ndctl_cmd *ndctl_dimm_cmd_new_vendor_specific(struct ndctl_dimm *dimm,