@@ -152,14 +152,18 @@ do_tests()
$NDCTL inject-smart -b $bus --uninject-all $dimm
# start tests
- for field in "${fields_val[@]}"; do
- test_field $field $inj_val
- done
-
for field in "${fields_bool[@]}"; do
test_field $field
done
+ if [ $NDCTL_TEST_FAMILY == "PAPR" ]; then
+ return
+ fi
+
+ for field in "${fields_val[@]}"; do
+ test_field $field $inj_val
+ done
+
for field in "${fields_thresh[@]}"; do
test_field $field $inj_val "thresh"
done
@@ -2211,6 +2211,46 @@ struct smart {
life_used, shutdown_state, shutdown_count, vendor_size;
};
+static int check_smart_ndtest(struct ndctl_bus *bus, struct ndctl_dimm *dimm,
+ struct check_cmd *check)
+{
+ static const struct smart smart_data = {
+ .flags = ND_SMART_HEALTH_VALID | ND_SMART_SHUTDOWN_VALID
+ | ND_SMART_SHUTDOWN_COUNT_VALID | ND_SMART_USED_VALID,
+ .health = ND_SMART_NON_CRITICAL_HEALTH,
+ .life_used = 5,
+ .shutdown_state = 0,
+ .shutdown_count = 42,
+ .vendor_size = 0,
+ };
+ struct ndctl_cmd *cmd = ndctl_dimm_cmd_new_smart(dimm);
+ int rc;
+
+ if (!cmd) {
+ fprintf(stderr, "%s: dimm: %#x failed to create cmd\n",
+ __func__, ndctl_dimm_get_handle(dimm));
+ return -ENXIO;
+ }
+
+ rc = ndctl_cmd_submit(cmd);
+ if (rc < 0) {
+ fprintf(stderr, "%s: dimm: %#x failed to submit cmd: %d\n",
+ __func__, ndctl_dimm_get_handle(dimm), rc);
+ ndctl_cmd_unref(cmd);
+ return rc;
+ }
+
+ __check_smart(dimm, cmd, flags, -1);
+ __check_smart(dimm, cmd, health, -1);
+ __check_smart(dimm, cmd, life_used, -1);
+ __check_smart(dimm, cmd, shutdown_state, -1);
+ __check_smart(dimm, cmd, shutdown_count, -1);
+ __check_smart(dimm, cmd, vendor_size, -1);
+
+ check->cmd = cmd;
+ return 0;
+}
+
static int check_smart(struct ndctl_bus *bus, struct ndctl_dimm *dimm,
struct check_cmd *check)
{
@@ -2434,6 +2474,12 @@ static int check_commands(struct ndctl_bus *bus, struct ndctl_dimm *dimm,
};
unsigned int i, rc = 0;
+ char *test_env = getenv("NDCTL_TEST_FAMILY");
+
+ if (test_env && strcmp(test_env, "PAPR") == 0) {
+ dimm_commands &= ~(1 << ND_CMD_SMART_THRESHOLD);
+ __check_dimm_cmds[ND_CMD_SMART].check_fn = &check_smart_ndtest;
+ }
/*
* The kernel did not start emulating v1.2 namespace spec smart data
@@ -26,6 +26,32 @@ static bool filter_region(struct ndctl_region *region,
return true;
}
+static void filter_ndtest_dimm(struct ndctl_dimm *dimm,
+ struct util_filter_ctx *ctx)
+{
+ struct list_filter_arg *lfa = ctx->list;
+ struct json_object *jdimm;
+
+ if (!ndctl_dimm_is_cmd_supported(dimm, ND_CMD_SMART))
+ return;
+
+ if (!lfa->jdimms) {
+ lfa->jdimms = json_object_new_array();
+ if (!lfa->jdimms) {
+ fail("\n");
+ return;
+ }
+ }
+
+ jdimm = util_dimm_to_json(dimm, lfa->flags);
+ if (!jdimm) {
+ fail("\n");
+ return;
+ }
+
+ json_object_array_add(lfa->jdimms, jdimm);
+}
+
static void filter_dimm(struct ndctl_dimm *dimm, struct util_filter_ctx *ctx)
{
struct list_filter_arg *lfa = ctx->list;
@@ -89,6 +115,11 @@ int main(int argc, const char *argv[])
};
struct util_filter_ctx fctx = { 0 };
struct list_filter_arg lfa = { 0 };
+ char *test_env = getenv("NDCTL_TEST_FAMILY");
+ int family = NVDIMM_FAMILY_INTEL;
+
+ if (test_env && strcmp(test_env, "PAPR") == 0)
+ family = NVDIMM_FAMILY_PAPR;
rc = ndctl_new(&ctx);
if (rc < 0)
@@ -100,7 +131,10 @@ int main(int argc, const char *argv[])
usage_with_options(u, options);
fctx.filter_bus = filter_bus;
- fctx.filter_dimm = filter_dimm;
+ if (family == NVDIMM_FAMILY_PAPR)
+ fctx.filter_dimm = filter_ndtest_dimm;
+ else
+ fctx.filter_dimm = filter_dimm;
fctx.filter_region = filter_region;
fctx.filter_namespace = NULL;
fctx.list = &lfa;