linux-nvdimm.lists.01.org archive mirror
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: linux-nvdimm@lists.01.org
Cc: vishal.l.verma@intel.com
Subject: [ndctl PATCH 07/16] ndctl/dimm: Emit dimm firmware details after update
Date: Mon, 06 Jul 2020 19:40:55 -0700	[thread overview]
Message-ID: <159408965572.2386154.3054569261046251497.stgit@dwillia2-desk3.amr.corp.intel.com> (raw)
In-Reply-To: <159408961822.2386154.888266173771881937.stgit@dwillia2-desk3.amr.corp.intel.com>

Replace the status messages at the end of 'ndctl update-firmware' with a
json representation of the dimm-firmware state.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 ndctl/dimm.c            |   23 ++++++++++++++++-------
 ndctl/firmware-update.h |    1 +
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/ndctl/dimm.c b/ndctl/dimm.c
index 5ecee033cd63..e02f5dfdb889 100644
--- a/ndctl/dimm.c
+++ b/ndctl/dimm.c
@@ -701,8 +701,10 @@ static int query_fw_finish_status(struct ndctl_dimm *dimm,
 	struct update_context *uctx = &actx->update;
 	struct fw_info *fw = &uctx->dimm_fw;
 	struct timespec now, before, after;
+	struct json_object *jobj;
 	enum ND_FW_STATUS status;
 	struct ndctl_cmd *cmd;
+	unsigned long flags;
 	uint64_t ver;
 	int rc;
 
@@ -763,10 +765,12 @@ again:
 			goto unref;
 		}
 
-		fprintf(stderr, "Image updated successfully to DIMM %s.\n",
-			ndctl_dimm_get_devname(dimm));
-		fprintf(stderr, "Firmware version %#lx.\n", ver);
-		fprintf(stderr, "Cold reboot to activate.\n");
+		flags = UTIL_JSON_FIRMWARE;
+		if (isatty(1))
+			flags |= UTIL_JSON_HUMAN;
+		jobj = util_dimm_to_json(dimm, flags);
+		if (jobj)
+			json_object_array_add(actx->jdimms, jobj);
 		rc = 0;
 		break;
 	case FW_EBADFW:
@@ -1202,7 +1206,7 @@ static int dimm_action(int argc, const char **argv, struct ndctl_ctx *ctx,
 		return -EINVAL;
 	}
 
-	json = param.json || param.human;
+	json = param.json || param.human || action == action_update;
 	if (action == action_read && json && (param.len || param.offset)) {
 		fprintf(stderr, "--size and --offset are incompatible with --json\n");
 		usage_with_options(u, options);
@@ -1308,8 +1312,13 @@ static int dimm_action(int argc, const char **argv, struct ndctl_ctx *ctx,
 			rc = action(single, &actx);
 	}
 
-	if (actx.jdimms)
-		util_display_json_array(actx.f_out, actx.jdimms, 0);
+	if (actx.jdimms && json_object_array_length(actx.jdimms) > 0) {
+		unsigned long flags = 0;
+
+		if (actx.f_out == stdout && isatty(1))
+			flags |= UTIL_JSON_HUMAN;
+		util_display_json_array(actx.f_out, actx.jdimms, flags);
+	}
 
 	if (actx.f_out != stdout)
 		fclose(actx.f_out);
diff --git a/ndctl/firmware-update.h b/ndctl/firmware-update.h
index a7576889f739..a4386d6089d2 100644
--- a/ndctl/firmware-update.h
+++ b/ndctl/firmware-update.h
@@ -40,6 +40,7 @@ struct update_context {
 	size_t fw_size;
 	struct fw_info dimm_fw;
 	struct ndctl_cmd *start;
+	struct json_object *jdimms;
 };
 
 #endif
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

  parent reply	other threads:[~2020-07-07  2:57 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-07  2:40 [ndctl PATCH 00/16] Firmware Activation and Test Updates Dan Williams
2020-07-07  2:40 ` [ndctl PATCH 01/16] ndctl/build: Fix zero-length array warnings Dan Williams
2020-07-07  2:40 ` [ndctl PATCH 02/16] ndctl/dimm: Fix chatty status messages Dan Williams
2020-07-07  2:40 ` [ndctl PATCH 03/16] ndctl/list: Indicate firmware update capability Dan Williams
2020-07-07  2:40 ` [ndctl PATCH 04/16] ndctl/dimm: Detect firmware-update vs ARS conflict Dan Williams
2020-07-07  2:40 ` [ndctl PATCH 05/16] ndctl/dimm: Improve firmware-update failure message Dan Williams
2020-07-07  2:40 ` [ndctl PATCH 06/16] ndctl/dimm: Prepare to emit dimm json object after firmware update Dan Williams
2020-07-07  2:40 ` Dan Williams [this message]
2020-07-07  2:41 ` [ndctl PATCH 08/16] ndctl/list: Add firmware activation enumeration Dan Williams
2020-07-07  2:41 ` [ndctl PATCH 09/16] ndctl/dimm: Auto-arm firmware activation Dan Williams
2020-07-07  2:41 ` [ndctl PATCH 10/16] ndctl/bus: Add 'activate-firmware' command Dan Williams
2020-07-07  2:41 ` [ndctl PATCH 11/16] ndctl/docs: Update copyright date Dan Williams
2020-07-07  2:41 ` [ndctl PATCH 12/16] ndctl/test: Test firmware-activation interface Dan Williams
2020-07-07  2:41 ` [ndctl PATCH 13/16] test: Validate strict iomem protections of pmem Dan Williams
2020-07-07  2:41 ` [ndctl PATCH 14/16] ndctl: Refactor nfit.h to acpi.h Dan Williams
2020-07-07  2:41 ` [ndctl PATCH 15/16] daxctl: Add 'split-acpi' command to generate custom ACPI tables Dan Williams
2020-07-07  2:41 ` [ndctl PATCH 16/16] test/ndctl: mremap pmd confusion Dan Williams

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=159408965572.2386154.3054569261046251497.stgit@dwillia2-desk3.amr.corp.intel.com \
    --to=dan.j.williams@intel.com \
    --cc=linux-nvdimm@lists.01.org \
    --cc=vishal.l.verma@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).