From patchwork Wed Feb 20 05:10:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dexuan Cui X-Patchwork-Id: 10821177 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3A4656C2 for ; Wed, 20 Feb 2019 05:10:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C5CF2DEBE for ; Wed, 20 Feb 2019 05:10:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0FB392DEC4; Wed, 20 Feb 2019 05:10:40 +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=-2.7 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,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 04EDB2DEBE for ; Wed, 20 Feb 2019 05:10:38 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id CB26C208F6122; Tue, 19 Feb 2019 21:10:38 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=40.107.131.124; helo=apc01-sg2-obe.outbound.protection.outlook.com; envelope-from=decui@microsoft.com; receiver=linux-nvdimm@lists.01.org Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-eopbgr1310124.outbound.protection.outlook.com [40.107.131.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 36762208AE2C4 for ; Tue, 19 Feb 2019 21:10:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Goz+XhB3GaLDTTgiqNe9v47Z061U5Mufw9G4Twzo6jA=; b=M4slW1INyDulF4dMLMIknBPkQxgBZ4Y3NO9eOYkH2N1OJIQhYTiTPQv3EiLLgT9r9V41br959L+NxA7tsQ5UvTuywW17eG7nUERL+6jfd1d/00oiJI1nM1DP+mBPLM/s1iTjP+ic9u+CQuu8u65L41gkkBubClF3Wzn1MqmOgxM= Received: from PU1P153MB0169.APCP153.PROD.OUTLOOK.COM (10.170.189.13) by PU1P153MB0105.APCP153.PROD.OUTLOOK.COM (10.170.188.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.0; Wed, 20 Feb 2019 05:10:33 +0000 Received: from PU1P153MB0169.APCP153.PROD.OUTLOOK.COM ([fe80::7822:a20:e63c:de2f]) by PU1P153MB0169.APCP153.PROD.OUTLOOK.COM ([fe80::7822:a20:e63c:de2f%9]) with mapi id 15.20.1665.002; Wed, 20 Feb 2019 05:10:33 +0000 From: Dexuan Cui To: Dave Jiang , Vishal Verma , Dan Williams , "linux-nvdimm@lists.01.org" , Michael Kelley , "qi.fuli@fujitsu.com" , Johannes Thumshirn Subject: [ndctl PATCH v2 1/4] libndctl: add support for NVDIMM_FAMILY_HYPERV's _DSM Function 1 Thread-Topic: [ndctl PATCH v2 1/4] libndctl: add support for NVDIMM_FAMILY_HYPERV's _DSM Function 1 Thread-Index: AdTI2piivcxVODcVSzuimNGde2l/Dg== Date: Wed, 20 Feb 2019 05:10:32 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=decui@microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2019-02-20T05:10:31.1305087Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=4729f78c-0441-434d-aeba-b1878f53296f; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic x-originating-ip: [2001:4898:80e8:9:e09f:1351:8c90:7b8c] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 492bed64-5f50-4c4a-5d86-08d696f1bdaf x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600126)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:PU1P153MB0105; x-ms-traffictypediagnostic: PU1P153MB0105: x-ms-exchange-purlcount: 1 x-microsoft-exchange-diagnostics: =?us-ascii?Q?1; PU1P153MB0105; 23:sx72eAHvq4Zw7GD5soF2NdKg24S4pxB6pURvTo+Yd?= +skoWAidNMUMREuop78QxGBA2Wi2NNYHwZr7hzeDBvFKc9BGw0JULkh1NBSraA1JW6mBpHurASkX6tT3wwOXCQ+dmz8ZkNrIkWRZn74XSQdljEiIsVGeHyAQwFhVg6w/sQy4Imz85nDduW+4RkT8N8MX9oDeNQ8VaEU+YtidBRo1ckY8zRxyiaWEWbCnn22SHMnyBiiZXmNOLDuWmAoOt7fpRPHh+2HBEU+99jKemhx1j1zj1i4BNRvtrs2G+9TKT5yO3k5emnM6LmWT6nzZPWp7hfEu7yqkEj0XHyi83ed/FLvJxgH61M2tY2Z+HwmpkhEw0CtssO2URSdyQdlJtx0gRIE+sS+eTTWS61lNlZwab7d7jZKqgumzKBEkVKVtgng/on1Eb2CHuCsvCRCUIaS3aYUFdVTUwGN2/sCMdRj5QHaQZWJ0YbKvyCsWG9EVbIk2yz5HgN4MGJG+g+GLEsWgklPWF+jLi9aszJL83j3Mt64DKrSpQXVEi8k7tL8oLb6ON+QAu3Czq/IAGBGt5wdiQHSgfzojZCJSYwKFa5S5C5nBh8tH0lLh7KmqGqeFNDW5Qq5+y6z3OKnoxRcwvF3tMSkKWOKzN+ZsYYhcs8yOwTm2qA7xYiqqDHVk4GxirT7FYmSrGk095Q8uZyaMFE8S5ktm6RgMuzykHDGyDzXPDKOOXg+jxUqALA0gi5agFukX8Exe0IwydIqXWIZp7sUKcw8GalI2KDf57hBzSPSRK05QOEjWPjO6vDTVzk92PAR05DsFJd9GgnlJHVmgE4Fk5gGGxTp9eDmFASjXQZtQwcn4gJI/nk1o7klxsyl5IIIZvntJBTzAQdEk5S205PjlU+238Upd8OA9P6C5gf5ANmia4xfpMCp0tAzey4fw4rfsOxMTMLrRH71GodV3LLo0undLQ+a8xnOchUBmy6SuFoTfai4HJUCYr1bXTQmyXTGRzgNrwEdJvwLJtnRe2n1ESN+AoXD8dMG0MY4WX5UvlCqyPVeP22h83pFLsYxKHsleDZ95YZvzTNoFh0gR4EjQXgOBlhEfOquK1UvnTkHZEiJeGB8h2lnXfMCg7BSHVoOEvozCAiN7Xd2fkWAfR4kqCswy7eCNgxGKs6GgUnK2C/oFIukFBv1hjtAz5trDv+LJQKIwUs3FEkyjQiz42CsRLjk+dQqMynqvbhaY4BCshiGHITJxNu93r+4e49R+z4= x-microsoft-antispam-prvs: x-forefront-prvs: 0954EE4910 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(366004)(346002)(376002)(136003)(396003)(189003)(199004)(33656002)(478600001)(110136005)(316002)(14454004)(22452003)(106356001)(2906002)(46003)(8990500004)(6506007)(476003)(486006)(71200400001)(71190400001)(256004)(186003)(6116002)(105586002)(10290500003)(68736007)(1511001)(97736004)(10090500001)(966005)(6346003)(102836004)(9686003)(6436002)(8676002)(55016002)(5660300002)(81156014)(6306002)(7736002)(305945005)(7696005)(86612001)(25786009)(53936002)(2501003)(74316002)(99286004)(86362001)(8936002)(81166006)(2004002); DIR:OUT; SFP:1102; SCL:1; SRVR:PU1P153MB0105; H:PU1P153MB0169.APCP153.PROD.OUTLOOK.COM; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=decui@microsoft.com; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: HDuqLHLr4FfyeX+Fl32jU3B+3iFtk2y8fI7GCXHMN0dlVxjM5mP2bS7APu8JHW+XbA8yH+drlo8r4v4XNIUJ7M0mdyDJmmz14BNA9onntuV1vpoVpXZl++KSkz+oWKl4rM6oirBrAGol/w99e2DwuSt0fwOwjJqTlVJ6DQhrryRv3jbFD9q9mC4vqHDumiP4IHcRl1/NU4FMlcs0JjquEG4B0UZMNfsxU53vT3byxYo9xK/hiJXg4wl/gs4NnkZo7AhzsL/B3GWCFHn46IpVpeeOUnmF1MBNgRGJsbl5sQhXYkce0J56yJLmn/X0uvUDyAtBzM5GeEF138bYGjMC7K+9jzGBdD7Hoc8GCsHqN6eHgcn9TKYXSxI9rQOrTqvvBTN/4numW4VRXNh7nCAMMCOekWVbYLea5doeOsjwbcg= MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 492bed64-5f50-4c4a-5d86-08d696f1bdaf X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Feb 2019 05:10:32.8807 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: PU1P153MB0105 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 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 This patch retrieves the health info by Hyper-V _DSM method Function 1: Get Health Information (Function Index 1) See http://www.uefi.org/RFIC_LIST ("Virtual NVDIMM 0x1901"). Now "ndctl list --dimms --health --idle" can show a line "health_state":"ok", e.g. { "dev":"nmem0", "id":"04d5-01-1701-00000000", "handle":0, "phys_id":0, "health":{ "health_state":"ok" } } If there is an error with the NVDIMM, the "ok" will be replaced with "unknown", "fatal", "critical", or "non-critical". Signed-off-by: Dexuan Cui --- ndctl/lib/Makefile.am | 1 + ndctl/lib/hyperv.c | 129 ++++++++++++++++++++++++++++++++++++++++++ ndctl/lib/hyperv.h | 51 +++++++++++++++++ ndctl/lib/libndctl.c | 2 + ndctl/lib/private.h | 3 + ndctl/ndctl.h | 1 + 6 files changed, 187 insertions(+) create mode 100644 ndctl/lib/hyperv.c create mode 100644 ndctl/lib/hyperv.h diff --git a/ndctl/lib/Makefile.am b/ndctl/lib/Makefile.am index 7797039..fb75fda 100644 --- a/ndctl/lib/Makefile.am +++ b/ndctl/lib/Makefile.am @@ -20,6 +20,7 @@ libndctl_la_SOURCES =\ intel.c \ hpe1.c \ msft.c \ + hyperv.c \ ars.c \ firmware.c \ libndctl.c diff --git a/ndctl/lib/hyperv.c b/ndctl/lib/hyperv.c new file mode 100644 index 0000000..b303d50 --- /dev/null +++ b/ndctl/lib/hyperv.c @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2019, Microsoft Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU Lesser General Public License, + * version 2.1, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for + * more details. + */ +#include +#include +#include +#include +#include +#include "private.h" +#include "hyperv.h" + +#define CMD_HYPERV(_c) ((_c)->hyperv) +#define CMD_HYPERV_STATUS(_c) (CMD_HYPERV(_c)->u.status) +#define CMD_HYPERV_SMART_DATA(_c) (CMD_HYPERV(_c)->u.smart.data) + +static struct ndctl_cmd *hyperv_dimm_cmd_new_smart(struct ndctl_dimm *dimm) +{ + struct ndctl_bus *bus = ndctl_dimm_get_bus(dimm); + struct ndctl_ctx *ctx = ndctl_bus_get_ctx(bus); + struct ndctl_cmd *cmd; + size_t size; + struct nd_pkg_hyperv *hyperv; + + if (!ndctl_dimm_is_cmd_supported(dimm, ND_CMD_CALL)) { + dbg(ctx, "unsupported cmd\n"); + return NULL; + } + + if (test_dimm_dsm(dimm, ND_HYPERV_CMD_GET_HEALTH_INFO) == + DIMM_DSM_UNSUPPORTED) { + dbg(ctx, "unsupported function\n"); + return NULL; + } + + size = sizeof(*cmd) + sizeof(struct nd_pkg_hyperv); + cmd = calloc(1, size); + if (!cmd) + return NULL; + + cmd->dimm = dimm; + ndctl_cmd_ref(cmd); + cmd->type = ND_CMD_CALL; + cmd->size = size; + cmd->status = 1; + + hyperv = CMD_HYPERV(cmd); + hyperv->gen.nd_family = NVDIMM_FAMILY_HYPERV; + hyperv->gen.nd_command = ND_HYPERV_CMD_GET_HEALTH_INFO; + hyperv->gen.nd_fw_size = 0; + hyperv->gen.nd_size_in = offsetof(struct nd_hyperv_smart, status); + hyperv->gen.nd_size_out = sizeof(hyperv->u.smart); + hyperv->u.smart.status = 0; + + cmd->firmware_status = &hyperv->u.smart.status; + + return cmd; +} + +static int hyperv_smart_valid(struct ndctl_cmd *cmd) +{ + if (cmd->type != ND_CMD_CALL || + cmd->size != sizeof(*cmd) + sizeof(struct nd_pkg_hyperv) || + CMD_HYPERV(cmd)->gen.nd_family != NVDIMM_FAMILY_HYPERV || + CMD_HYPERV(cmd)->gen.nd_command != ND_HYPERV_CMD_GET_HEALTH_INFO || + cmd->status != 0 || + CMD_HYPERV_STATUS(cmd) != 0) + return cmd->status < 0 ? cmd->status : -EINVAL; + return 0; +} + +static int hyperv_cmd_xlat_firmware_status(struct ndctl_cmd *cmd) +{ + return CMD_HYPERV_STATUS(cmd) == 0 ? 0 : -EINVAL; +} + +static unsigned int hyperv_cmd_smart_get_flags(struct ndctl_cmd *cmd) +{ + int rc; + + rc = hyperv_smart_valid(cmd); + if (rc < 0) { + errno = -rc; + return 0; + } + + return ND_SMART_HEALTH_VALID; +} + +static unsigned int hyperv_cmd_smart_get_health(struct ndctl_cmd *cmd) +{ + unsigned int health = 0; + __u32 num; + int rc; + + rc = hyperv_smart_valid(cmd); + if (rc < 0) { + errno = -rc; + return UINT_MAX; + } + + num = CMD_HYPERV_SMART_DATA(cmd)->health & 0x3F; + + if (num & (BIT(0) | BIT(1))) + health |= ND_SMART_CRITICAL_HEALTH; + + if (num & BIT(2)) + health |= ND_SMART_FATAL_HEALTH; + + if (num & (BIT(3) | BIT(4) | BIT(5))) + health |= ND_SMART_NON_CRITICAL_HEALTH; + + return health; +} + +struct ndctl_dimm_ops * const hyperv_dimm_ops = &(struct ndctl_dimm_ops) { + .new_smart = hyperv_dimm_cmd_new_smart, + .smart_get_flags = hyperv_cmd_smart_get_flags, + .smart_get_health = hyperv_cmd_smart_get_health, + .xlat_firmware_status = hyperv_cmd_xlat_firmware_status, +}; diff --git a/ndctl/lib/hyperv.h b/ndctl/lib/hyperv.h new file mode 100644 index 0000000..8e55a97 --- /dev/null +++ b/ndctl/lib/hyperv.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2019, Microsoft Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU Lesser General Public License, + * version 2.1, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for + * more details. + */ +#ifndef __NDCTL_HYPERV_H__ +#define __NDCTL_HYPERV_H__ + +/* See http://www.uefi.org/RFIC_LIST ("Virtual NVDIMM 0x1901") */ +enum { + ND_HYPERV_CMD_QUERY = 0, + + /* non-root commands */ + ND_HYPERV_CMD_GET_HEALTH_INFO = 1, +}; + +/* + * This is actually Function 1's data, + * This is the closest I can find to match the "smart". + * Hyper-V _DSM methods don't have a smart function. + */ +struct nd_hyperv_smart_data { + __u32 health; +} __attribute__((packed)); + +struct nd_hyperv_smart { + __u32 status; + union { + __u8 buf[4]; + struct nd_hyperv_smart_data data[0]; + }; +} __attribute__((packed)); + +union nd_hyperv_cmd { + __u32 status; + struct nd_hyperv_smart smart; +} __attribute__((packed)); + +struct nd_pkg_hyperv { + struct nd_cmd_pkg gen; + union nd_hyperv_cmd u; +} __attribute__((packed)); + +#endif /* __NDCTL_HYPERV_H__ */ diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index c9e2875..48bdb27 100644 --- a/ndctl/lib/libndctl.c +++ b/ndctl/lib/libndctl.c @@ -1492,6 +1492,8 @@ static void *add_dimm(void *parent, int id, const char *dimm_base) dimm->ops = hpe1_dimm_ops; if (dimm->cmd_family == NVDIMM_FAMILY_MSFT) dimm->ops = msft_dimm_ops; + if (dimm->cmd_family == NVDIMM_FAMILY_HYPERV) + dimm->ops = hyperv_dimm_ops; sprintf(path, "%s/nfit/dsm_mask", dimm_base); if (sysfs_read_attr(ctx, path, buf) == 0) diff --git a/ndctl/lib/private.h b/ndctl/lib/private.h index a387b0b..a9d35c5 100644 --- a/ndctl/lib/private.h +++ b/ndctl/lib/private.h @@ -31,6 +31,7 @@ #include "intel.h" #include "hpe1.h" #include "msft.h" +#include "hyperv.h" struct nvdimm_data { struct ndctl_cmd *cmd_read; @@ -270,6 +271,7 @@ struct ndctl_cmd { struct nd_cmd_pkg pkg[0]; struct ndn_pkg_hpe1 hpe1[0]; struct ndn_pkg_msft msft[0]; + struct nd_pkg_hyperv hyperv[0]; struct nd_pkg_intel intel[0]; struct nd_cmd_get_config_size get_size[0]; struct nd_cmd_get_config_data_hdr get_data[0]; @@ -344,6 +346,7 @@ struct ndctl_dimm_ops { struct ndctl_dimm_ops * const intel_dimm_ops; struct ndctl_dimm_ops * const hpe1_dimm_ops; struct ndctl_dimm_ops * const msft_dimm_ops; +struct ndctl_dimm_ops * const hyperv_dimm_ops; static inline struct ndctl_bus *cmd_to_bus(struct ndctl_cmd *cmd) { diff --git a/ndctl/ndctl.h b/ndctl/ndctl.h index c6aaa4c..008f81c 100644 --- a/ndctl/ndctl.h +++ b/ndctl/ndctl.h @@ -262,6 +262,7 @@ struct nd_cmd_pkg { #define NVDIMM_FAMILY_HPE1 1 #define NVDIMM_FAMILY_HPE2 2 #define NVDIMM_FAMILY_MSFT 3 +#define NVDIMM_FAMILY_HYPERV 4 #define ND_IOCTL_CALL _IOWR(ND_IOCTL, ND_CMD_CALL,\ struct nd_cmd_pkg) From patchwork Wed Feb 20 05:10:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dexuan Cui X-Patchwork-Id: 10821179 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 43BE46C2 for ; Wed, 20 Feb 2019 05:11:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25A102DEBE for ; Wed, 20 Feb 2019 05:11:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 180392DEC4; Wed, 20 Feb 2019 05:11:00 +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=-2.7 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,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 13B002DEBE for ; Wed, 20 Feb 2019 05:10:59 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id EE7A2208D613B; Tue, 19 Feb 2019 21:10:58 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=40.107.132.119; helo=apc01-pu1-obe.outbound.protection.outlook.com; envelope-from=decui@microsoft.com; receiver=linux-nvdimm@lists.01.org Received: from APC01-PU1-obe.outbound.protection.outlook.com (mail-eopbgr1320119.outbound.protection.outlook.com [40.107.132.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D6166208AE2C4 for ; Tue, 19 Feb 2019 21:10:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U0Vry1ANwK8gxXAlBPwegI47tTUEM9mEHQId4Furuqw=; b=NhKA7kD5hac/Ny1cHxF7vuKWdXnlq+BFup3r4oprZ3FM+AxSJZg9MyOlnMcmnuPryKStQU7HSzvoNzXvfENr2NxOY0JQsJoFq+IChZgSY3m1u5xdsk15DC/5O7uh8tSLzfYHPiuSbmaut9Tit5BXNEzHalmPL6Bu7a78as7QLqc= Received: from PU1P153MB0169.APCP153.PROD.OUTLOOK.COM (10.170.189.13) by PU1P153MB0105.APCP153.PROD.OUTLOOK.COM (10.170.188.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.0; Wed, 20 Feb 2019 05:10:54 +0000 Received: from PU1P153MB0169.APCP153.PROD.OUTLOOK.COM ([fe80::7822:a20:e63c:de2f]) by PU1P153MB0169.APCP153.PROD.OUTLOOK.COM ([fe80::7822:a20:e63c:de2f%9]) with mapi id 15.20.1665.002; Wed, 20 Feb 2019 05:10:54 +0000 From: Dexuan Cui To: Dave Jiang , Vishal Verma , Dan Williams , "linux-nvdimm@lists.01.org" , Michael Kelley , "qi.fuli@fujitsu.com" , Johannes Thumshirn Subject: [ndctl PATCH v2 2/4] libndctl: NVDIMM_FAMILY_HYPERV: add .smart_get_shutdown_count (Function 2) Thread-Topic: [ndctl PATCH v2 2/4] libndctl: NVDIMM_FAMILY_HYPERV: add .smart_get_shutdown_count (Function 2) Thread-Index: AdTI2qVNGDL7Aro+TdSJZnmU7IeV2Q== Date: Wed, 20 Feb 2019 05:10:54 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=decui@microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2019-02-20T05:10:52.0084362Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=4c1cf349-2158-40be-a317-b30c38bbbdf5; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic x-originating-ip: [2001:4898:80e8:9:e09f:1351:8c90:7b8c] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 31599aec-d839-4858-49a3-08d696f1ca54 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600126)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:PU1P153MB0105; x-ms-traffictypediagnostic: PU1P153MB0105: x-microsoft-exchange-diagnostics: =?us-ascii?Q?1; PU1P153MB0105; 23:eRNMM+Z3HCoVq2f7oM7e37qC63bxxI49bcQr3OseG?= updwny09yxkKlf7Rwo9QqIVYQi69M620b+Z79WWmTBP+sp6d1ezRvhJDKpmrkAPAzCNwMXWpsk3JbZizGFa/jJxZLPmc6O9X4xjkBuxCQr2gIsKGbDy0HbKIfmYBRPCK4boVohPQxoyV0bHG8NLRjy4S5joWdXZ+7gSN0cHTc9YawYcrMgOeIks+ZN0Xjwq+ngcfVcG8hofqxxVRJIpYquHIRJW45CJbHrrngeE2QVy5GK+wgbFcz+lfEYOp0LBWrBuid4Q51c5Evadb4uOYBMO1aAyQ/UY22SgbDWN5aDlgNr4qMYT/Vah61+CpJsoKnWz5bEEJl8IKDT1oB6mdiHD7PH5Ass6iYL8rqmvMXopngv7pUqCPgCnhIfgBpNVWr+npMZgLQK2wEtoHwE4J5a5YUvY8PBBmYN444paZczTF8klCxHKouafdmL2M9D4OCmwbeqv3YzrVjLwMEQdoeq+RStv66hlOpqSAQdvdZcjb9vO5PVDJvM7jpA2BL6vHpxR/GtgVoluu1ZaZwAyxTHYU2GOsNlm7oByzGkAF3/dUa0QTUi+F0jyJZB+LtClxCyCujYGYkbtsfEbeXgi1RPnB25oXAAk5lXIdYRtoboqhpKTARc3+7sqlVvUtnmNxTRrGescuSN6I9Cg+SQxGe7XcmaLE2d1UP0/C6nrMetQbCJ1H9neE/e0OFy1oCgto7Dt3MWUEHUXmzUGTxJ8D4/fuWSYk/+AuIBVTmgbcWqg89Ye6MaFNHiYgK7HetrX3Rx5N80dhj53WbpRrbNX+eoYBIdOPun7cWFc9mrpd/eK/Ngrfc5k3ZQ3WNLLQSvsHVrDWlSQkAZFAWekPh8j8z1ZEs1ezr2KsxfZ9X/5ljXAfwvdKW1mhv0ufd9ST32Gl3tRbfU4opFjdqLl1MhHzz5MngJlvz+ZsNYvpqjS4KktX/zXrczsDnAO1fepc62oFpTJCzH02w3nprkm2kwUhzFQWH9tBohEnyUB2zz66Ttkb7IKgxgzzVebKNHmID92ANeSNrRmkDbst4K5ijxh1pe1fvu5x4DWrfWE/7iL7HtjnsG6La6lukqQHV2jIOhaqf1bKqozCQfDSEaUlDU1ClUK0bAXIrMQ/n1K919+mLeZGibNQpUxX7eMaO2rOYzmjcuUDRNkgaFOojNDFH+k+lladwBbEUL/NJ1s6Q8gimrk7A== x-microsoft-antispam-prvs: x-forefront-prvs: 0954EE4910 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(366004)(346002)(376002)(136003)(396003)(189003)(199004)(33656002)(478600001)(110136005)(316002)(14454004)(22452003)(106356001)(2906002)(46003)(8990500004)(6506007)(476003)(486006)(71200400001)(71190400001)(256004)(186003)(6116002)(105586002)(10290500003)(68736007)(1511001)(97736004)(10090500001)(6346003)(102836004)(9686003)(6436002)(8676002)(55016002)(5660300002)(81156014)(7736002)(305945005)(7696005)(86612001)(25786009)(53936002)(2501003)(74316002)(99286004)(86362001)(8936002)(81166006)(142923001); DIR:OUT; SFP:1102; SCL:1; SRVR:PU1P153MB0105; H:PU1P153MB0169.APCP153.PROD.OUTLOOK.COM; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=decui@microsoft.com; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 6dlLNhBqZC6dxvrQ8PWXaA5Huukw8Kiyn0sy84WZjdKq0suFDh2IkDYVX74voJpec5fK9hhi55r5ATDczDbmELMokiGxrOgZ2lI4+HzVJZdzd4l+FCIdNf9fUETg4qpcSvRA9yibNXh6J0fyUnm7TINT4pjsIZcQoYcFPfUZtnJW1KyXmvjx8SwMcTAo76qJCIQBvwKNIHQusFDupDfTDnDlgFtc3AmQgKOmZqpfqt+Hb8wL18WKMdbB7haJnswXkvz59sNR8Z0U5uFPOxPcXGRJF1b5Zv5rUR0Dx/3zF7P+q+bDaI8IkSyqEymT6XtJSG1Pp8Zs+A/5E43mmTcEtjZ+lSKvmgknmOjo/yxRs5IFEtUKJWlBYWRL7BGuzwXU/5jYRBG1cNzFp4q6MapKBtvgypel+qNGpLV2WUjQ41g= MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 31599aec-d839-4858-49a3-08d696f1ca54 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Feb 2019 05:10:54.0652 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: PU1P153MB0105 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 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 With the patch, "ndctl list --dimms --health --idle" can show "shutdown_count" now, e.g. { "dev":"nmem0", "id":"04d5-01-1701-00000000", "handle":0, "phys_id":0, "health":{ "health_state":"ok", "shutdown_count":2 } } The patch has to directly call ndctl_cmd_submit() in hyperv_cmd_smart_get_flags() and hyperv_cmd_smart_get_shutdown_count() to get the needed info, because util_dimm_health_to_json() only submits *one* command, and unluckily for Hyper-V Virtual NVDIMM we need to call both Function 1 and 2 to get the needed info. My feeling is that it's not very good to directly call ndctl_cmd_submit(), but by doing this we don't need to make any change to the common code, and I'm unsure if it's good to change the common code just for Hyper-V. Signed-off-by: Dexuan Cui --- ndctl/lib/hyperv.c | 62 ++++++++++++++++++++++++++++++++++++++++------ ndctl/lib/hyperv.h | 7 ++++++ 2 files changed, 62 insertions(+), 7 deletions(-) diff --git a/ndctl/lib/hyperv.c b/ndctl/lib/hyperv.c index b303d50..e8ec142 100644 --- a/ndctl/lib/hyperv.c +++ b/ndctl/lib/hyperv.c @@ -22,7 +22,8 @@ #define CMD_HYPERV_STATUS(_c) (CMD_HYPERV(_c)->u.status) #define CMD_HYPERV_SMART_DATA(_c) (CMD_HYPERV(_c)->u.smart.data) -static struct ndctl_cmd *hyperv_dimm_cmd_new_smart(struct ndctl_dimm *dimm) +static struct ndctl_cmd *hyperv_dimm_cmd_new_cmd(struct ndctl_dimm *dimm, + unsigned int command) { struct ndctl_bus *bus = ndctl_dimm_get_bus(dimm); struct ndctl_ctx *ctx = ndctl_bus_get_ctx(bus); @@ -35,8 +36,7 @@ static struct ndctl_cmd *hyperv_dimm_cmd_new_smart(struct ndctl_dimm *dimm) return NULL; } - if (test_dimm_dsm(dimm, ND_HYPERV_CMD_GET_HEALTH_INFO) == - DIMM_DSM_UNSUPPORTED) { + if (test_dimm_dsm(dimm, command) == DIMM_DSM_UNSUPPORTED) { dbg(ctx, "unsupported function\n"); return NULL; } @@ -54,7 +54,7 @@ static struct ndctl_cmd *hyperv_dimm_cmd_new_smart(struct ndctl_dimm *dimm) hyperv = CMD_HYPERV(cmd); hyperv->gen.nd_family = NVDIMM_FAMILY_HYPERV; - hyperv->gen.nd_command = ND_HYPERV_CMD_GET_HEALTH_INFO; + hyperv->gen.nd_command = command; hyperv->gen.nd_fw_size = 0; hyperv->gen.nd_size_in = offsetof(struct nd_hyperv_smart, status); hyperv->gen.nd_size_out = sizeof(hyperv->u.smart); @@ -65,34 +65,74 @@ static struct ndctl_cmd *hyperv_dimm_cmd_new_smart(struct ndctl_dimm *dimm) return cmd; } -static int hyperv_smart_valid(struct ndctl_cmd *cmd) +static struct ndctl_cmd *hyperv_dimm_cmd_new_smart(struct ndctl_dimm *dimm) +{ + return hyperv_dimm_cmd_new_cmd(dimm, ND_HYPERV_CMD_GET_HEALTH_INFO); +} + +static int hyperv_cmd_valid(struct ndctl_cmd *cmd, unsigned int command) { if (cmd->type != ND_CMD_CALL || cmd->size != sizeof(*cmd) + sizeof(struct nd_pkg_hyperv) || CMD_HYPERV(cmd)->gen.nd_family != NVDIMM_FAMILY_HYPERV || - CMD_HYPERV(cmd)->gen.nd_command != ND_HYPERV_CMD_GET_HEALTH_INFO || + CMD_HYPERV(cmd)->gen.nd_command != command || cmd->status != 0 || CMD_HYPERV_STATUS(cmd) != 0) return cmd->status < 0 ? cmd->status : -EINVAL; return 0; } +static int hyperv_smart_valid(struct ndctl_cmd *cmd) +{ + return hyperv_cmd_valid(cmd, ND_HYPERV_CMD_GET_HEALTH_INFO); +} + static int hyperv_cmd_xlat_firmware_status(struct ndctl_cmd *cmd) { return CMD_HYPERV_STATUS(cmd) == 0 ? 0 : -EINVAL; } +static int hyperv_get_shutdown_count(struct ndctl_cmd *cmd, + unsigned int *count) +{ + unsigned int command = ND_HYPERV_CMD_GET_SHUTDOWN_INFO; + struct ndctl_cmd *cmd_get_shutdown_info; + int rc; + + cmd_get_shutdown_info = hyperv_dimm_cmd_new_cmd(cmd->dimm, command); + if (!cmd_get_shutdown_info) + return -EINVAL; + + if (ndctl_cmd_submit(cmd_get_shutdown_info) < 0 || + hyperv_cmd_valid(cmd_get_shutdown_info, command) < 0) { + rc = -EINVAL; + goto out; + } + + *count = CMD_HYPERV(cmd_get_shutdown_info)->u.shutdown_info.count; + rc = 0; +out: + ndctl_cmd_unref(cmd_get_shutdown_info); + return rc; +} + static unsigned int hyperv_cmd_smart_get_flags(struct ndctl_cmd *cmd) { int rc; + unsigned int count; + unsigned int flags = 0; rc = hyperv_smart_valid(cmd); if (rc < 0) { errno = -rc; return 0; } + flags |= ND_SMART_HEALTH_VALID; - return ND_SMART_HEALTH_VALID; + if (hyperv_get_shutdown_count(cmd, &count) == 0) + flags |= ND_SMART_SHUTDOWN_COUNT_VALID; + + return flags; } static unsigned int hyperv_cmd_smart_get_health(struct ndctl_cmd *cmd) @@ -121,9 +161,17 @@ static unsigned int hyperv_cmd_smart_get_health(struct ndctl_cmd *cmd) return health; } +static unsigned int hyperv_cmd_smart_get_shutdown_count(struct ndctl_cmd *cmd) +{ + unsigned int count; + + return hyperv_get_shutdown_count(cmd, &count) == 0 ? count : UINT_MAX; +} + struct ndctl_dimm_ops * const hyperv_dimm_ops = &(struct ndctl_dimm_ops) { .new_smart = hyperv_dimm_cmd_new_smart, .smart_get_flags = hyperv_cmd_smart_get_flags, .smart_get_health = hyperv_cmd_smart_get_health, + .smart_get_shutdown_count = hyperv_cmd_smart_get_shutdown_count, .xlat_firmware_status = hyperv_cmd_xlat_firmware_status, }; diff --git a/ndctl/lib/hyperv.h b/ndctl/lib/hyperv.h index 8e55a97..5232d60 100644 --- a/ndctl/lib/hyperv.h +++ b/ndctl/lib/hyperv.h @@ -19,6 +19,7 @@ enum { /* non-root commands */ ND_HYPERV_CMD_GET_HEALTH_INFO = 1, + ND_HYPERV_CMD_GET_SHUTDOWN_INFO = 2, }; /* @@ -38,9 +39,15 @@ struct nd_hyperv_smart { }; } __attribute__((packed)); +struct nd_hyperv_shutdown_info { + __u32 status; + __u32 count; +} __attribute__((packed)); + union nd_hyperv_cmd { __u32 status; struct nd_hyperv_smart smart; + struct nd_hyperv_shutdown_info shutdown_info; } __attribute__((packed)); struct nd_pkg_hyperv { From patchwork Wed Feb 20 05:11:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dexuan Cui X-Patchwork-Id: 10821181 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8CB666C2 for ; Wed, 20 Feb 2019 05:11:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 738252DEBE for ; Wed, 20 Feb 2019 05:11:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 682A92DEC4; Wed, 20 Feb 2019 05:11:17 +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=-2.7 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,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 1DDEA2DEBE for ; Wed, 20 Feb 2019 05:11:16 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 15F93209574CA; Tue, 19 Feb 2019 21:11:16 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=40.107.132.97; helo=apc01-pu1-obe.outbound.protection.outlook.com; envelope-from=decui@microsoft.com; receiver=linux-nvdimm@lists.01.org Received: from APC01-PU1-obe.outbound.protection.outlook.com (mail-eopbgr1320097.outbound.protection.outlook.com [40.107.132.97]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7F524208AE3FA for ; Tue, 19 Feb 2019 21:11:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=x5u90kJi5VnbjR2ygYwtGYoe2/sLV3Z3y9/+Qa77eA4=; b=ibYnSw1wKbabcMsHDbNf6UXnSdD+nRWMwPcDjR1tGKk6DY7ii+eV3mbbS2dg6pK+zVKX04rezm2C66221rMSBc+A3TCnCBvUKRQ99rWD6qc+jlYWcXDXcTVXvCxNP/xxp8Tb9u3HtiInyoTwRnQ7oHoJ1dId5dS33sn6NI9hpJ4= Received: from PU1P153MB0169.APCP153.PROD.OUTLOOK.COM (10.170.189.13) by PU1P153MB0105.APCP153.PROD.OUTLOOK.COM (10.170.188.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.0; Wed, 20 Feb 2019 05:11:11 +0000 Received: from PU1P153MB0169.APCP153.PROD.OUTLOOK.COM ([fe80::7822:a20:e63c:de2f]) by PU1P153MB0169.APCP153.PROD.OUTLOOK.COM ([fe80::7822:a20:e63c:de2f%9]) with mapi id 15.20.1665.002; Wed, 20 Feb 2019 05:11:11 +0000 From: Dexuan Cui To: Dave Jiang , Vishal Verma , Dan Williams , "linux-nvdimm@lists.01.org" , Michael Kelley , "qi.fuli@fujitsu.com" , Johannes Thumshirn Subject: [ndctl PATCH v2 3/4] ndctl, lib: implement ndctl_dimm_get_cmd_family() Thread-Topic: [ndctl PATCH v2 3/4] ndctl, lib: implement ndctl_dimm_get_cmd_family() Thread-Index: AdTI2q9TbSFgGnHRQvql/Od6kAUVag== Date: Wed, 20 Feb 2019 05:11:10 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=decui@microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2019-02-20T05:11:09.0273980Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=8d416a6f-11e9-4e1e-ae71-8176c93ae572; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic x-originating-ip: [2001:4898:80e8:9:e09f:1351:8c90:7b8c] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2c79d2e1-6101-4281-c02d-08d696f1d433 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600126)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:PU1P153MB0105; x-ms-traffictypediagnostic: PU1P153MB0105: x-microsoft-exchange-diagnostics: =?us-ascii?Q?1; PU1P153MB0105; 23:U7NUJl/GExA5tKLKD7uddnPhP1PtxazL8cEhmfzn7?= nyRkRDSSPj9pd+CVC7ucaN0ld4I0VFiAF/ExOy4RpFPcYM+LBLbzty6EnKbOxiCHTGVcYuop5STHfcDeQn1PAEs1dalvwJtgZfi7hZSFqnxeCNUvlat/AJakGZPLS7lKRVB36fRpftcZ980yti7pCuCLNvy62EA/gbwNkd+cxdd49Vo0EAADWXo+N+bUVcvGVSCWl/gCq3W20gpZV0enS1418n/NPzbYNTuJdFDvCHO/bLRmC68qFt0RJsD85CLGgKK7fULUDB5poPWFuZRafbQKux7X4rZgBqY+i5hGSPIOsu0aiu2+IgVanWFdHEea0LPjPn+m2UnfN0wdamy9A9iwRlrcnxPiFVFajQU6MEVIT3bix0JNPxFv22R4LbJOTquQ7q5X3duFQplncWeDj2kmQ3Kp7g+KRprHmWZreCCtTbvZ2nJkveRQmOxuCMUWLDz9VjuzKW9PpzdlxiSmPhuVj60O5f10gY3X2BCn4IGVPNxO3I4ZLNxXDt6UAgTiBI8uPDR+wqh9qgnf7OCH9E7eYa9H/xZpFmYWrzpalUNNS41tVjEQ5r8YKgYEorIr6ES+98HIQm91TixvF+wZxkNbI7mH02YV7Aq5OlXY9XSUT0GBViIKkNiWb0sdFZi1w0YimDpTuCvUbi6UO06Sxk54+1DLDiFui9cqVbdonRiY2QqXmrtA6vmkbdBBJWGXG2AHp9ecSJHwpPY9F1ryYBLb1+Geud0p1enXxRsoxs3g1yqRuXzcApoVEl4dt8ST1sVFT39tYUlAYHPdBiFqCORq0x1olCXDR7fOsYSJTVEu68Vo7HShUPZYO9q3zzbuMLhMYYkTdhV0fcRtjeYo0UrX4m8YQFAV34WWtRwtmU9yi9why8bcivHt7oWR+TY9fDHKOhR73TpFSC/a1cnrSNnWcmoldGQLOkzpDoJK4bqyLtg3JlqqX/tYQKIgWrtkBS5msYi8jKQe2M9EzBvxmy7qKW9CKE5P0HXqP98vvOu/lytHppNanGp2uhl9Lv7GA+ZZGa4jP+WOVLCGiDV9OvWWOrlcIGaunsspnJnspM+QYDCoIkfE0XZYLizihg9jpMs6npNsDYFZlWsaizUXmAX5ZeDIEnqkooPHfSlV4GhYGzq3Be7KoesxCOCaxJGVIZSEJgvhuL3LNfglH7ySxeD x-microsoft-antispam-prvs: x-forefront-prvs: 0954EE4910 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(366004)(346002)(376002)(136003)(396003)(189003)(199004)(33656002)(478600001)(110136005)(316002)(14454004)(22452003)(106356001)(2906002)(46003)(8990500004)(6506007)(476003)(486006)(71200400001)(71190400001)(256004)(186003)(6116002)(105586002)(10290500003)(68736007)(1511001)(97736004)(10090500001)(6346003)(102836004)(9686003)(6436002)(8676002)(55016002)(5660300002)(81156014)(7736002)(305945005)(7696005)(86612001)(25786009)(53936002)(2501003)(74316002)(99286004)(86362001)(8936002)(81166006); DIR:OUT; SFP:1102; SCL:1; SRVR:PU1P153MB0105; H:PU1P153MB0169.APCP153.PROD.OUTLOOK.COM; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=decui@microsoft.com; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 74V4uLFPG1IuryaQ2xH/tYWZmE0g/LxM//T8W2SDO0cv7+xOiHoxtyjsPyHXXEFHZYChFLNnTAFldiMGJ3g36iAtmtANwldBedRMioyhs46BBL5d+deBPJjEHAbuROiYD7ZuR2eADjsxIVRWE8JDBzPOACnO5akGCxIXC79kcjfJFNel6cqDAZbYV7wScIHhCcTeAyTEYpmCPTbVF9Wb6Mx27DkSAVY223vRlwahnwbJKx32kQwR4FNgUW1zoUOPcSE64T0t6DsFi4R8spReWcOS/Tw3jx9rCRgVebYQtrJzdmnYwzuBLLhMxAnZ83Xc8VQCiDkmEgb2w8x1CQ0qx20qvDwc4PVp8wbQOPsKHv2BmOgdBz4oKXIH0RHQ943Vq0KzPENIl+t4WOBdV40F8BQzcWDlgriy6F7jFhivUX8= MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2c79d2e1-6101-4281-c02d-08d696f1d433 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Feb 2019 05:11:10.6202 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: PU1P153MB0105 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 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 Let's export the family info so we can do some family-specific handling in ndctl/monitor.c for Hyper-V NVDIMM. Signed-off-by: Dexuan Cui --- ndctl/lib/libndctl.c | 5 +++++ ndctl/lib/libndctl.sym | 1 + ndctl/libndctl.h | 1 + 3 files changed, 7 insertions(+) diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index 48bdb27..1186579 100644 --- a/ndctl/lib/libndctl.c +++ b/ndctl/lib/libndctl.c @@ -1550,6 +1550,11 @@ NDCTL_EXPORT struct ndctl_dimm *ndctl_dimm_get_next(struct ndctl_dimm *dimm) return list_next(&bus->dimms, dimm, list); } +NDCTL_EXPORT unsigned long ndctl_dimm_get_cmd_family(struct ndctl_dimm *dimm) +{ + return dimm->cmd_family; +} + NDCTL_EXPORT unsigned int ndctl_dimm_get_handle(struct ndctl_dimm *dimm) { return dimm->handle; diff --git a/ndctl/lib/libndctl.sym b/ndctl/lib/libndctl.sym index cb9f769..470e895 100644 --- a/ndctl/lib/libndctl.sym +++ b/ndctl/lib/libndctl.sym @@ -38,6 +38,7 @@ global: ndctl_bus_wait_probe; ndctl_dimm_get_first; ndctl_dimm_get_next; + ndctl_dimm_get_cmd_family; ndctl_dimm_get_handle; ndctl_dimm_get_phys_id; ndctl_dimm_get_vendor; diff --git a/ndctl/libndctl.h b/ndctl/libndctl.h index 0debdb6..cb5a8fc 100644 --- a/ndctl/libndctl.h +++ b/ndctl/libndctl.h @@ -145,6 +145,7 @@ struct ndctl_dimm *ndctl_dimm_get_next(struct ndctl_dimm *dimm); for (dimm = ndctl_dimm_get_first(bus); \ dimm != NULL; \ dimm = ndctl_dimm_get_next(dimm)) +unsigned long ndctl_dimm_get_cmd_family(struct ndctl_dimm *dimm); unsigned int ndctl_dimm_get_handle(struct ndctl_dimm *dimm); unsigned short ndctl_dimm_get_phys_id(struct ndctl_dimm *dimm); unsigned short ndctl_dimm_get_vendor(struct ndctl_dimm *dimm); From patchwork Wed Feb 20 05:11:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dexuan Cui X-Patchwork-Id: 10821183 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C788F1399 for ; Wed, 20 Feb 2019 05:11:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB68D2DEBE for ; Wed, 20 Feb 2019 05:11:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E53A2DEC4; Wed, 20 Feb 2019 05:11:45 +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=-2.7 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,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 3C16C2DEBE for ; Wed, 20 Feb 2019 05:11:45 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3448D2095AE5E; Tue, 19 Feb 2019 21:11:45 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=40.107.131.130; helo=apc01-sg2-obe.outbound.protection.outlook.com; envelope-from=decui@microsoft.com; receiver=linux-nvdimm@lists.01.org Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-eopbgr1310130.outbound.protection.outlook.com [40.107.131.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2BA74208F612F for ; Tue, 19 Feb 2019 21:11:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=12KIYdP5ktHlFfiCIBMy0xTpMHsEmUY6J84hjLNFLXo=; b=RUTOXya9bK2JiA1W6CuMOEX+Jvu3UwrsIIpdkyi0SH0CXDP74lsGODntgIRmMvTfdcOm2ZoghQZReyXMjZpQ64tG3n888C5y5Ydi8Gf9Wa4dU81GBsZWlZlp2FZ6EyE4mvsgXAMqj8K39RzzTBM8JS94Lr76A51Hau1YLt2cV70= Received: from PU1P153MB0169.APCP153.PROD.OUTLOOK.COM (10.170.189.13) by PU1P153MB0105.APCP153.PROD.OUTLOOK.COM (10.170.188.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.0; Wed, 20 Feb 2019 05:11:40 +0000 Received: from PU1P153MB0169.APCP153.PROD.OUTLOOK.COM ([fe80::7822:a20:e63c:de2f]) by PU1P153MB0169.APCP153.PROD.OUTLOOK.COM ([fe80::7822:a20:e63c:de2f%9]) with mapi id 15.20.1665.002; Wed, 20 Feb 2019 05:11:40 +0000 From: Dexuan Cui To: Dave Jiang , Vishal Verma , Dan Williams , "linux-nvdimm@lists.01.org" , Michael Kelley , "qi.fuli@fujitsu.com" , Johannes Thumshirn Subject: [ndctl PATCH v2 4/4] ndctl, monitor: support NVDIMM_FAMILY_HYPERV Thread-Topic: [ndctl PATCH v2 4/4] ndctl, monitor: support NVDIMM_FAMILY_HYPERV Thread-Index: AdTI2rz1QLsetrmLRMK6s1y+OGDh+w== Date: Wed, 20 Feb 2019 05:11:40 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=decui@microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2019-02-20T05:11:38.6924733Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=efa35817-4f58-413a-b0c0-203c5da79211; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic x-originating-ip: [2001:4898:80e8:9:e09f:1351:8c90:7b8c] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1aa32363-d4ac-416a-5c00-08d696f1e5d4 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600126)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:PU1P153MB0105; x-ms-traffictypediagnostic: PU1P153MB0105: x-ms-exchange-purlcount: 1 x-microsoft-exchange-diagnostics: =?us-ascii?Q?1; PU1P153MB0105; 23:/vLFxViaBf/CZyuTqqnEK35ItejF4KKZshnxxViW8?= d0xGad9hmVcVJiYlEKNJCW42XvnKh+Va+glRtXbFYpIgIrEaMDTCkf2p+A6d4uYzJ7pJJJYFe3RwYF+j0zy/ccKQE1CrUxPjy0+w1kATeh1Vwgvb3PwiBkr/AEU4EX//6EpyPZEdDGBbaEKBdb7OBBgxIxhpM2ISm91TaOIwPOUnZqDdmQhSDzNG7J/OuVr5pdDZjuN0kIpLu8rZ31PuYTDp74G0Bxrg44PjS5kI4C0vHRDlFrr8ocnd+bVCbM477vtkOHrl25qBdO/5E+rt7DEbGkdcz7JHUrW6VQ9v4lpALviiuLt0AXXfEJw/4tAYTt07T89ANha9SA7hCDV+/Rbrz900qFyEEOiNH1PYK72Z51l4uKk2ryH2SIcx+L0EGMY8co7Y1ALqtpSW8Eh7GzfBlEODzWhIccD5VwyEgHqpsfxOHjnoNtyNOIl7OafN56cf4Fj03zqgy3Tw6KS9NRvBBTf4kqec5frB9Cu8WRhbsZ8W0tK1/ZZvchOhaBOywL+2rBZVjn+zwsnmIlCOWHsvgJR6VZE1GtlIXc3zTvfbWzLfutGuu/giDkJht/HSD9Z59PUAQE2UMORPW69EUU3txiCNLrEfsTsG6G4l7oewLXY3iVF3/5tDKfYt1wbvWePvghWR8khqEnVo28Bf/C5YqNJ6dkxhU5QcV2dnB1R0BrdLm6sDOuy7S4CgNwgCeX76lmXJVzgadbxFG2d/yl3J87tnNHCqrqZleSrVDxKUY5iqPh2YRk6uGBnu4+adI4a39ZJD525dzrutIMH9qAjfC/jmL1R99nNmLihq9l++RemstyJJAVYc4cMu499OBmS1JExAxHALBjGLrPL/n1YLz6PjoMrlIJFEz/Dd/lQfezz2TsINzmedQfpXrUhOQXUbqM95S8LIHu4kMEFRIU5djgy2OGck+lirb8ssyt7lGx2WvgckYS1yI881FEoOh4jfNgh4zgoep9NWOiy7/mngKmKI4Irt+Xu8ChM6CxwSMLqrn/fQsUvQFTC34JfgROfgwlo6/LAW2ssN4pb0G8kLRAPug9kIl6SnkuuoQgG7zRBK7XMrerJyTjd3TwbaJF79i8Yn5gDPHQnkpE2X56jiUTb6c6rB/y5oBKuINvTQrTIRiGQBHTJRE7/kyodXy5RXmhBhulsy/LJ5nuae+KP57M1JuVd0GwUlE/xvExEq7m4azF4z461q8pPa8MyxHM= x-microsoft-antispam-prvs: x-forefront-prvs: 0954EE4910 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(366004)(346002)(376002)(136003)(396003)(189003)(199004)(33656002)(478600001)(110136005)(316002)(14454004)(22452003)(106356001)(2906002)(46003)(8990500004)(6506007)(476003)(486006)(71200400001)(71190400001)(14444005)(256004)(186003)(6116002)(105586002)(10290500003)(68736007)(1511001)(97736004)(10090500001)(966005)(6346003)(102836004)(9686003)(6436002)(8676002)(55016002)(5660300002)(81156014)(6306002)(7736002)(305945005)(7696005)(86612001)(25786009)(53936002)(2501003)(74316002)(99286004)(86362001)(8936002)(81166006); DIR:OUT; SFP:1102; SCL:1; SRVR:PU1P153MB0105; H:PU1P153MB0169.APCP153.PROD.OUTLOOK.COM; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=decui@microsoft.com; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: gP2ovw2DiJlFrNojmBnNE/ZjTXFl+8F3M/j1cUjkB/EXsEYha82Sv/VkPIyxx4hIHgVyHH+2kRnetuGIHUGWAdjRc9LdNE7OUFwRMgetQvEVVsGZ+pwkL0EwnP31jrj72V6iq0Lg4GQsjCurpY837F37/M3IjxuP20qmL36BjQ9Ept7AGZLpmbO71THLdl1XF4jQsOQ2NJGCiTRlK5YjhpkOFIAipHc6MKxdKuZLfszTx7mm9GMo/Jj2PEU3bGRKL8Yh8xaN0BNjfhJaQhcYYcvWLFqDZ4JdIz4ProcPHes2eNbVJ/QnMxq5WioxBoTcwX57utzj4POOjl093qGQVkppIvJqt2lNN35Kd4kHgDy9w16wMDrvXJq0wynBpSi1oF7GFani/9zVbPaBZOl5CEWPl3HCuY7lvZXE/XXNS54= MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1aa32363-d4ac-416a-5c00-08d696f1e5d4 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Feb 2019 05:11:40.2390 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: PU1P153MB0105 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 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 Currently "ndctl monitor" fails for NVDIMM_FAMILY_HYPERV due to "no smart support". NVDIMM_FAMILY_HYPERV doesn't use ND_CMD_SMART to get the health info. Instead, it uses ND_CMD_CALL, so the checking here can't apply,and it doesn't support threshold alarms -- actually it only supports one event: ND_EVENT_HEALTH_STATE. See http://www.uefi.org/RFIC_LIST ("Virtual NVDIMM 0x1901"). Let's skip the unnecessary checking for NVDIMM_FAMILY_HYPERV, and make sure we only monitor the "dimm-health-state" event and ignore the others. With the patch, when an error happens, we log it with such a message: {"timestamp":"1550547497.431731497","pid":1571,"event": {"dimm-health-state":true},"dimm":{"dev":"nmem1", "id":"04d5-01-1701-01000000","handle":1,"phys_id":0, "health":{"health_state":"fatal","shutdown_count":8}}} Here the meaningful info is: "health":{"health_state":"fatal","shutdown_count":8} Signed-off-by: Dexuan Cui --- ndctl/monitor.c | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/ndctl/monitor.c b/ndctl/monitor.c index 43b2abe..43beb06 100644 --- a/ndctl/monitor.c +++ b/ndctl/monitor.c @@ -265,31 +265,59 @@ static bool filter_region(struct ndctl_region *region, return true; } -static void filter_dimm(struct ndctl_dimm *dimm, struct util_filter_ctx *fctx) +static bool ndctl_dimm_test_and_enable_notification(struct ndctl_dimm *dimm) { - struct monitor_dimm *mdimm; - struct monitor_filter_arg *mfa = fctx->monitor; const char *name = ndctl_dimm_get_devname(dimm); + /* + * Hyper-V Virtual NVDIMM doesn't use ND_CMD_SMART to get the health + * info. Instead, it uses ND_CMD_CALL, so the checking here can't + * apply, and it doesn't support threshold alarms -- actually it only + * supports one event: ND_EVENT_HEALTH_STATE. + */ + if (ndctl_dimm_get_cmd_family(dimm) == NVDIMM_FAMILY_HYPERV) { + if (monitor.event_flags != ND_EVENT_HEALTH_STATE) { + monitor.event_flags = ND_EVENT_HEALTH_STATE; + + notice(&monitor, + "%s: only dimm-health-state can be monitored\n", + name); + } + return true; + } + if (!ndctl_dimm_is_cmd_supported(dimm, ND_CMD_SMART)) { err(&monitor, "%s: no smart support\n", name); - return; + return false; } if (!ndctl_dimm_is_cmd_supported(dimm, ND_CMD_SMART_THRESHOLD)) { err(&monitor, "%s: no smart threshold support\n", name); - return; + return false; } if (!ndctl_dimm_is_flag_supported(dimm, ND_SMART_ALARM_VALID)) { err(&monitor, "%s: smart alarm invalid\n", name); - return; + return false; } if (enable_dimm_supported_threshold_alarms(dimm)) { err(&monitor, "%s: enable supported threshold alarms failed\n", name); - return; + return false; } + return true; +} + +static void filter_dimm(struct ndctl_dimm *dimm, struct util_filter_ctx *fctx) +{ + struct monitor_dimm *mdimm; + struct monitor_filter_arg *mfa = fctx->monitor; + const char *name = ndctl_dimm_get_devname(dimm); + + + if (!ndctl_dimm_test_and_enable_notification(dimm)) + return; + mdimm = calloc(1, sizeof(struct monitor_dimm)); if (!mdimm) { err(&monitor, "%s: calloc for monitor dimm failed\n", name);