From patchwork Wed Jul 5 09:12:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?R290b3UsIFlhc3Vub3JpL+S6lOWztiDlurfmloc=?= X-Patchwork-Id: 9826221 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8FDC1602F0 for ; Wed, 5 Jul 2017 09:13:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80C9522B26 for ; Wed, 5 Jul 2017 09:13:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 74722204BA; Wed, 5 Jul 2017 09:13:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 090ED204BA for ; Wed, 5 Jul 2017 09:13:07 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id DFF8A21A07AB5; Wed, 5 Jul 2017 02:11:27 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mgwym01.jp.fujitsu.com (mgwym01.jp.fujitsu.com [211.128.242.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A615821A00AF2 for ; Wed, 5 Jul 2017 02:11:26 -0700 (PDT) Received: from yt-mxauth.gw.nic.fujitsu.com (unknown [192.168.229.68]) by mgwym01.jp.fujitsu.com with smtp id 7387_d3e5_39a06f8a_5cea_4eb5_bd8b_0788294fc2df; Wed, 05 Jul 2017 18:13:01 +0900 Received: from m3051.s.css.fujitsu.com (m3051.s.css.fujitsu.com [10.134.21.209]) by yt-mxauth.gw.nic.fujitsu.com (Postfix) with ESMTP id 3118BAC00CB for ; Wed, 5 Jul 2017 18:13:01 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v2.3.2 X-SHieldMailCheckerPolicyVersion: FJ-ISEC-20141210 X-SHieldMailCheckerMailID: ecc13faa6d1e439d81ad3dcf41129672 Date: Wed, 05 Jul 2017 18:12:52 +0900 From: Yasunori Goto To: NVDIMM-ML Subject: [RFC/PATCH] ndctl list should show more hardware information Message-Id: <20170705181250.8D09.E1E9C6FF@jp.fujitsu.com> MIME-Version: 1.0 X-Mailer: Becky! ver. 2.73 [ja] X-TM-AS-MML: disable X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Hello, The current "id" data of dimm (ndctl list -D) shows the information of DIMM module vendor or serial number. However, I think it is not enough. If a NVDIMM becomes broken, users need to know its physical place rather than vendor or serial number to replace the NVDIMM. There are 2 candidate of such information. a) NFIT Device Handle (_ADR of the NVDIMM device) This date includes node controller id and socket id. b) NVDIMM Physical ID (Handle for the SMBIOS Memory Device (Type 17)). The dmidecode can show this handle with more information like "Locator" So, user can find the location of NVDIMM. At first, I think _ADR is enough information. However, when I talked with our firmware team about this requirement, they said it may not be good data, because the node contoller ID is not stable on our server due to "partitioning" feature. (Our server can have plural partition on one box, and may have plural node 0.) So, I make the ndctl shows not only NFIT Device Handle but also NVDIMM Physical ID. Then, user can find the location with dmidecode. This is the first trial patch. So any comments are welcome. Signed-off-by: Yasunori Goto --- --- Yasunori Goto diff --git a/util/json.c b/util/json.c index b718d74..749a358 100644 --- a/util/json.c +++ b/util/json.c @@ -68,6 +68,9 @@ struct json_object *util_dimm_to_json(struct ndctl_dimm *dimm) { struct json_object *jdimm = json_object_new_object(); const char *id = ndctl_dimm_get_unique_id(dimm); + unsigned int handle = ndctl_dimm_get_handle(dimm); + short phys_id = ndctl_dimm_get_phys_id(dimm); + char buf[11]; struct json_object *jobj; if (!jdimm) @@ -85,6 +88,18 @@ struct json_object *util_dimm_to_json(struct ndctl_dimm *dimm) json_object_object_add(jdimm, "id", jobj); } + snprintf(buf, 11, "0x%08x", handle); + jobj = json_object_new_string(buf); + if (!jobj) + goto err; + json_object_object_add(jdimm, "handle", jobj); + + snprintf(buf, 7, "0x%04x", phys_id ); + jobj = json_object_new_string(buf); + if (!jobj) + goto err; + json_object_object_add(jdimm, "phys_id", jobj); + if (!ndctl_dimm_is_enabled(dimm)) { jobj = json_object_new_string("disabled"); if (!jobj)