From patchwork Sat Mar 23 04:26:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dexuan Cui X-Patchwork-Id: 10866763 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 03D61139A for ; Sat, 23 Mar 2019 04:26:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C83582A982 for ; Sat, 23 Mar 2019 04:26:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBD3B2A9F8; Sat, 23 Mar 2019 04:26:48 +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=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,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 5AD4D2A982 for ; Sat, 23 Mar 2019 04:26:48 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 40EB3211E9FA4; Fri, 22 Mar 2019 21:26:48 -0700 (PDT) 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=2607:f8b0:4864:20::842; helo=mail-qt1-x842.google.com; envelope-from=dexuan.cui@gmail.com; receiver=linux-nvdimm@lists.01.org Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id ADE04211E95B2 for ; Fri, 22 Mar 2019 21:26:46 -0700 (PDT) Received: by mail-qt1-x842.google.com with SMTP id h39so4910672qte.2 for ; Fri, 22 Mar 2019 21:26:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RE9NZJml4eNkAwJmDkEJCLS19gaxRsEyFTdR8rayQuY=; b=llTnYCrqpJegH3Ofuk5sAf234dQUa+oyeX3jkRgMcWCL5OvNQ5GlJ55s1MWHREUNGz sZ4WzsiQJaT4ZRafWSxWAMaS4L04EsN55B8k3bjUV7Q1P4L2RgtbN5XsehoVQvMOSe/1 o0wYOh/33TPvyPMViW+BrPJnBK4Do2WPPrGciUuJ5EMPnY2YW+UB+OgghTbuiquuI2Bo x7SDLbM6NWPXWH9mqnpuZl+ZlY81H/pm64YGQOF6+31+z/K9ddPy4smjAyeA3SXvSZ52 f/tS6RjpiFP6RGX2V7z+JdhLzIQyFYDrL6EMvi8HA5p61ehQ4SJOt5VWkc4Bw9xLsXHD lmMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RE9NZJml4eNkAwJmDkEJCLS19gaxRsEyFTdR8rayQuY=; b=LeVaz5QDZg+vvSIP2snG3OesuBokpoJIPrYSHA8arOIcF4Qkh+f2ygYqpigRXpdFtQ fIeFB7ga2KVsxvcFf5FUyFg6E8vZLHIwwNRF2nGUZ+O0S6kijhJrSrux7AJY3yAh8YPG GMBFmbDoFbZiecsGAuCaidhS65cwSMQFYpaP8ZJ1FYom8SZQsJehbJJfAyZn1D44QTW0 lr+yNEiT1Bzz5/gIfo2+IwSZsL69z7+PGEBUVGZrDBLZz8jokC1xosqK7LEDbloFQ0GT xjzPIQqFICdvJhc95XV4m3ApDx2HXOQndFlrlFcui9GPbF1KB7H1fM1SFrElpOqmOfru BCnQ== X-Gm-Message-State: APjAAAUFkOkByb6Zv6Wdfdh2emntfoEwOWuM9MwKc15uZ3F1jdLVqy2s 5iGjaC0pHEm0RrF7VNJocWc= X-Google-Smtp-Source: APXvYqw0YV+ukIJo2lay3bUAMfApd/E5XoUWBGFTsRL6Mqqz0GTyW7nTEcvR1MutYeSPAiWAq6Z89Q== X-Received: by 2002:a0c:b645:: with SMTP id q5mr11299106qvf.194.1553315205809; Fri, 22 Mar 2019 21:26:45 -0700 (PDT) Received: from linuxonhyperv2.linuxonhyperv.com (ip-107-180-71-197.ip.secureserver.net. [107.180.71.197]) by smtp.gmail.com with ESMTPSA id w9sm4913811qkf.94.2019.03.22.21.26.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 21:26:45 -0700 (PDT) From: Dexuan Cui X-Google-Original-From: Dexuan Cui To: vishal.l.verma@intel.com, dan.j.williams@intel.com, dave.jiang@intel.com, linux-nvdimm@lists.01.org, mikelley@microsoft.com Subject: [ndctl PATCH v3 5/5] libndctl: Implement the "cmd_is_supported" dimm-op for Hyper-V Date: Sat, 23 Mar 2019 04:26:37 +0000 Message-Id: <20190323042637.4544-1-decui@microsoft.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 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: , Cc: qi.fuli@fujitsu.com Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Currently "ndctl monitor" fails for Hyper-V virtual NVDIMM due to "no smart support". According to http://www.uefi.org/RFIC_LIST ("Virtual NVDIMM 0x1901"), Hyper-V doesn't really support ND_CMD_SMART, but it supports "Get Health Information (Function Index 1)" and "Get Unsafe Shutdown Count (Function Index 2)", which is basically a "weak" variant of ND_CMD_SMART. Implement the dimm-ops to allow "ndctl monitor" to work with Hyper-V NVDIMM. Now when an error happens, "ndctl monitor" can show such a line: {"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/lib/hyperv.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ndctl/lib/hyperv.c b/ndctl/lib/hyperv.c index efd8b03..9b4fe12 100644 --- a/ndctl/lib/hyperv.c +++ b/ndctl/lib/hyperv.c @@ -9,6 +9,19 @@ #include "private.h" #include "hyperv.h" +static bool hyperv_cmd_is_supported(struct ndctl_dimm *dimm, int cmd) +{ + /* + * "ndctl monitor" requires ND_CMD_SMART, which is not really supported + * by Hyper-V virtual NVDIMM. Nevertheless, ND_CMD_SMART can be emulated + * by ND_HYPERV_CMD_GET_HEALTH_INFO and ND_HYPERV_CMD_GET_SHUTDOWN_INFO. + */ + if (cmd == ND_CMD_SMART ) + return true; + + return !!(dimm->cmd_mask & (1ULL << cmd)); +} + static struct ndctl_cmd *alloc_hyperv_cmd(struct ndctl_dimm *dimm, unsigned int command) { @@ -161,6 +174,7 @@ static int hyperv_cmd_xlat_firmware_status(struct ndctl_cmd *cmd) } struct ndctl_dimm_ops * const hyperv_dimm_ops = &(struct ndctl_dimm_ops) { + .cmd_is_supported = hyperv_cmd_is_supported, .new_smart = hyperv_dimm_cmd_new_smart, .smart_get_flags = hyperv_cmd_get_flags, .smart_get_health = hyperv_cmd_get_health,