From patchwork Wed Feb 15 16:49:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Motin X-Patchwork-Id: 13141947 Received: from mail-qt1-f180.google.com (mail-qt1-f180.google.com [209.85.160.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3ADF17B for ; Wed, 15 Feb 2023 16:51:06 +0000 (UTC) Received: by mail-qt1-f180.google.com with SMTP id cr22so22429086qtb.10 for ; Wed, 15 Feb 2023 08:51:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ixsystems.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=fbBnZ1g82/FRYV3IwBX90wHGlDsg+VX071r9sNu9jyY=; b=X/iWk+pGxMAPZo/p8jyuMjzB5qHl5qdNe65BhJJpWUosrUDSXyDIw/Rc03tji5EI+J wEhuFvgFTDV28X27HXF8cBuLygcTGQbhyWUAmAd72G9hkF9FoJ0OB9tdT/9g2O5jmnia md+aFtDa6JU5VwvK/ToO+vS496U3e8BkuuDh09oxwr22oEz9Ayn9ikvQJvQhGzy9aheH TpAxo6+oSzGeF7skOuwnNsPcoC1wEpPmOowcas0HfZ/NcjaEJtHnnK/GWXsxXpTN5WA2 tcIgZhJF0xTYKhcPCOCjEX9nFIQ0IhcEb7k7fBPv7Q0Wu6slIgfBI1a+wlfz/WRRydZz BXjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=fbBnZ1g82/FRYV3IwBX90wHGlDsg+VX071r9sNu9jyY=; b=fEn7tK+YbZd3ot1dVfPz4AbSY4WupqpDJG8vsH/4rxW9EDXF8BR+hDHJvvmxn0Fyk2 2jNfuj1DBxJaqvoAvQVnLYLdzTKZwzzqHW1lHLs+4s3Y5VwlirQoBz90imG0weTBv3bW Ek0q57qTlW8KhggYXEMG6gfJPRW3wnfpOUvx08WVIXi36RUbTWc5cecQi29c7QB+QUU4 akSbxXtDRdKya0tVrjK5c68c7GYRzMgqSm00r30rKxxCSMlFrng8jHRh/F21tkOrEcqN 1QhU1Ib5NaF/TI56J544nrme7EsH/xnnz5flB5yMgMrAJkYrFBaC0c3ajXH5mdzv9FYO HVqA== X-Gm-Message-State: AO0yUKUjnz/Wl8BQ5exoN+xqzD6P1vzF6qjJzf2o8HCrzvgE+kN5K4Xd bnimJqWMsa+biz8mxaumHsYOyl0iC+Fk4MIUUkUhx26LwobLTkAjmUPqAP+mqDw8TBQH1gaOHFK zGwI9ClfS88G2q83LzAwgJlTs9fowDW94DERfF71w28lsRMxc6g8l6GGAM+rtpRjCVC8m X-Google-Smtp-Source: AK7set+j8UUvfLNhOnhfQ5/4bKKL+67r+nrDZWjSuYAeJtIMmVOmqDR/EG6AvDw3ITXdGzOsI+C12g== X-Received: by 2002:a05:622a:190b:b0:3b8:67c4:b11d with SMTP id w11-20020a05622a190b00b003b867c4b11dmr3451702qtc.49.1676479864650; Wed, 15 Feb 2023 08:51:04 -0800 (PST) Received: from testm50.mav.ixsystems.net ([38.32.73.2]) by smtp.gmail.com with ESMTPSA id y10-20020ac8128a000000b003b68ea3d5c8sm13353529qti.41.2023.02.15.08.50.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 08:50:41 -0800 (PST) From: Alexander Motin To: nvdimm@lists.linux.dev Cc: Vishal Verma , Dan Williams , Alexander Motin Subject: [ndctl PATCH 1/4 v3] libndctl/msft: Remove NDN_MSFT_SMART_*_VALID defines. Date: Wed, 15 Feb 2023 11:49:28 -0500 Message-Id: <20230215164930.707170-1-mav@ixsystems.com> X-Mailer: git-send-email 2.30.2 Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 smart_get_flags method returns set of globaly defined flags, that don't need to be redefined for the specific NVDIMM type. Signed-off-by: Alexander Motin --- ndctl/lib/msft.c | 5 ++--- ndctl/lib/msft.h | 5 ----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/ndctl/lib/msft.c b/ndctl/lib/msft.c index 3112799..22f72dd 100644 --- a/ndctl/lib/msft.c +++ b/ndctl/lib/msft.c @@ -80,9 +80,8 @@ static unsigned int msft_cmd_smart_get_flags(struct ndctl_cmd *cmd) } /* below health data can be retrieved via MSFT _DSM function 11 */ - return NDN_MSFT_SMART_HEALTH_VALID | - NDN_MSFT_SMART_TEMP_VALID | - NDN_MSFT_SMART_USED_VALID; + return ND_SMART_HEALTH_VALID | ND_SMART_TEMP_VALID | + ND_SMART_USED_VALID; } static unsigned int num_set_bit_health(__u16 num) diff --git a/ndctl/lib/msft.h b/ndctl/lib/msft.h index 978cc11..c462612 100644 --- a/ndctl/lib/msft.h +++ b/ndctl/lib/msft.h @@ -12,11 +12,6 @@ enum { NDN_MSFT_CMD_SMART = 11, }; -/* NDN_MSFT_CMD_SMART */ -#define NDN_MSFT_SMART_HEALTH_VALID ND_SMART_HEALTH_VALID -#define NDN_MSFT_SMART_TEMP_VALID ND_SMART_TEMP_VALID -#define NDN_MSFT_SMART_USED_VALID ND_SMART_USED_VALID - /* * This is actually function 11 data, * This is the closest I can find to match smart From patchwork Wed Feb 15 16:49:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Motin X-Patchwork-Id: 13141948 Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A749E7B for ; Wed, 15 Feb 2023 16:51:27 +0000 (UTC) Received: by mail-qv1-f45.google.com with SMTP id l4so6426923qvh.11 for ; Wed, 15 Feb 2023 08:51:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ixsystems.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=STW69iuKspho13um/rsdKY6jzS6j0PjXfQUTKtGfNHQ=; b=emuFqyWs2SEwZVrgtb7jFOEvpHNiEWlYhvz1f8/SRrCajbnqQJUIgjrJIuaqhBOtXQ IDTEwA8C9caxee9Zw3+hH6BqDZ2JGQYgoWdjJza+bFcTD63qgQvcfOcLqN+7jhuKA1FU UpFMlNujASMxU3k+IXs9WIclt5bUv4DNhQqP+gGj/3MSGmfX56v9dENgETnmlMwtR92D JNbtYKavrNH2mWGBntAFIsfgZYNN0Gd9iwWmauISlzfsWXwJWUC4WI0UY1PVYjr9EU2s 50BxdSQtbtTzH8IgYoxX6+zxMFWZTzW9oe0TBgJq2AJC+u5/13LYQ4bpLZhuevepyEim 6AtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=STW69iuKspho13um/rsdKY6jzS6j0PjXfQUTKtGfNHQ=; b=VaomhWOKqg1tRq6+3m0YyQ2sXlkpcHC0484huNh1VHxaEaoW6gs2gVxR9H4bDUEi5J 1jxbY0WWyCKOKXk7G1jVoshXBGSns1LQ/cOJxNdCVONtoqjPNBC+jAc5wiyNJyOtEQ/N SrFlw/KwAQm3eQ8XH4jMJilp+Ofog8xzZUks2v8wKEP+vOcWOuL9gs9Z6fmi9kfh9fTV 4KWpzHt52E57jIy8SziyLkxAQ6LadiTV/GxTUQ1djilpsZKQPUz0OTxStWTWiqHQn2Lm 4xnVckgrnES3q/+aXQHQC7jdPp2blGf6RC/DzxkIneG1OJ7VS3ocE07Ea3R+tTfvaRAa vV+w== X-Gm-Message-State: AO0yUKWvH17hUh6+FOqZzhs0N1zUixl99h9YN2mWkRs9NP+fqVydBDXI norin01Waz/YrnKs/ovGqzdQOJ2FFnzwo8wY3elotYdmYUUeSCxOZCn39WJIO45rV1Nase7WGvD 9xl3AyE2So92BHP+hBNRjH7mPuYwR/bCPS8LYmbYA9vXq0WzbHo5T8lIV1Ckbtlh+Vebp X-Google-Smtp-Source: AK7set9zA6V7/ryZfapEPUsBszDII0WZ8vQ3IGhAwKXmyAjd2UiKRRbhQTI99dW/hzqM6xYXv1Td2g== X-Received: by 2002:a05:6214:ac6:b0:56e:b6de:e782 with SMTP id g6-20020a0562140ac600b0056eb6dee782mr5436818qvi.29.1676479886164; Wed, 15 Feb 2023 08:51:26 -0800 (PST) Received: from testm50.mav.ixsystems.net ([38.32.73.2]) by smtp.gmail.com with ESMTPSA id y10-20020ac8128a000000b003b68ea3d5c8sm13353529qti.41.2023.02.15.08.51.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 08:51:25 -0800 (PST) From: Alexander Motin To: nvdimm@lists.linux.dev Cc: Vishal Verma , Dan Williams , Alexander Motin Subject: [ndctl PATCH 2/4 v3] libndctl/msft: Replace nonsense NDN_MSFT_CMD_SMART command Date: Wed, 15 Feb 2023 11:49:30 -0500 Message-Id: <20230215164930.707170-2-mav@ixsystems.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230215164930.707170-1-mav@ixsystems.com> References: <20230215164930.707170-1-mav@ixsystems.com> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There is no NDN_MSFT_CMD_SMART command. There are 3 relevant ones, reporting different aspects of the module health. Define those and use NDN_MSFT_CMD_NHEALTH, while making the code more universal to allow use of others later. Signed-off-by: Alexander Motin --- ndctl/lib/msft.c | 41 +++++++++++++++++++++++++++++++++-------- ndctl/lib/msft.h | 8 ++++---- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/ndctl/lib/msft.c b/ndctl/lib/msft.c index 22f72dd..b5278c5 100644 --- a/ndctl/lib/msft.c +++ b/ndctl/lib/msft.c @@ -2,6 +2,7 @@ // Copyright (C) 2016-2017 Dell, Inc. // Copyright (C) 2016 Hewlett Packard Enterprise Development LP // Copyright (C) 2016-2020, Intel Corporation. +/* Copyright (C) 2022 iXsystems, Inc. */ #include #include #include @@ -12,12 +13,30 @@ #define CMD_MSFT(_c) ((_c)->msft) #define CMD_MSFT_SMART(_c) (CMD_MSFT(_c)->u.smart.data) +static const char *msft_cmd_desc(int fn) +{ + static const char * const descs[] = { + [NDN_MSFT_CMD_CHEALTH] = "critical_health", + [NDN_MSFT_CMD_NHEALTH] = "nvdimm_health", + [NDN_MSFT_CMD_EHEALTH] = "es_health", + }; + const char *desc; + + if (fn >= (int) ARRAY_SIZE(descs)) + return "unknown"; + desc = descs[fn]; + if (!desc) + return "unknown"; + return desc; +} + static u32 msft_get_firmware_status(struct ndctl_cmd *cmd) { return cmd->msft->u.smart.status; } -static struct ndctl_cmd *msft_dimm_cmd_new_smart(struct ndctl_dimm *dimm) +static struct ndctl_cmd *alloc_msft_cmd(struct ndctl_dimm *dimm, + unsigned int func, size_t in_size, size_t out_size) { struct ndctl_bus *bus = ndctl_dimm_get_bus(dimm); struct ndctl_ctx *ctx = ndctl_bus_get_ctx(bus); @@ -30,12 +49,12 @@ static struct ndctl_cmd *msft_dimm_cmd_new_smart(struct ndctl_dimm *dimm) return NULL; } - if (test_dimm_dsm(dimm, NDN_MSFT_CMD_SMART) == DIMM_DSM_UNSUPPORTED) { + if (test_dimm_dsm(dimm, func) == DIMM_DSM_UNSUPPORTED) { dbg(ctx, "unsupported function\n"); return NULL; } - size = sizeof(*cmd) + sizeof(struct ndn_pkg_msft); + size = sizeof(*cmd) + sizeof(struct nd_cmd_pkg) + in_size + out_size; cmd = calloc(1, size); if (!cmd) return NULL; @@ -48,22 +67,27 @@ static struct ndctl_cmd *msft_dimm_cmd_new_smart(struct ndctl_dimm *dimm) msft = CMD_MSFT(cmd); msft->gen.nd_family = NVDIMM_FAMILY_MSFT; - msft->gen.nd_command = NDN_MSFT_CMD_SMART; + msft->gen.nd_command = func; msft->gen.nd_fw_size = 0; - msft->gen.nd_size_in = offsetof(struct ndn_msft_smart, status); - msft->gen.nd_size_out = sizeof(msft->u.smart); + msft->gen.nd_size_in = in_size; + msft->gen.nd_size_out = out_size; msft->u.smart.status = 0; cmd->get_firmware_status = msft_get_firmware_status; return cmd; } +static struct ndctl_cmd *msft_dimm_cmd_new_smart(struct ndctl_dimm *dimm) +{ + return alloc_msft_cmd(dimm, NDN_MSFT_CMD_NHEALTH, 0, + sizeof(struct ndn_msft_smart)); +} + static int msft_smart_valid(struct ndctl_cmd *cmd) { if (cmd->type != ND_CMD_CALL || - cmd->size != sizeof(*cmd) + sizeof(struct ndn_pkg_msft) || CMD_MSFT(cmd)->gen.nd_family != NVDIMM_FAMILY_MSFT || - CMD_MSFT(cmd)->gen.nd_command != NDN_MSFT_CMD_SMART || + CMD_MSFT(cmd)->gen.nd_command != NDN_MSFT_CMD_NHEALTH || cmd->status != 0) return cmd->status < 0 ? cmd->status : -EINVAL; return 0; @@ -170,6 +194,7 @@ static int msft_cmd_xlat_firmware_status(struct ndctl_cmd *cmd) } struct ndctl_dimm_ops * const msft_dimm_ops = &(struct ndctl_dimm_ops) { + .cmd_desc = msft_cmd_desc, .new_smart = msft_dimm_cmd_new_smart, .smart_get_flags = msft_cmd_smart_get_flags, .smart_get_health = msft_cmd_smart_get_health, diff --git a/ndctl/lib/msft.h b/ndctl/lib/msft.h index c462612..8d246a5 100644 --- a/ndctl/lib/msft.h +++ b/ndctl/lib/msft.h @@ -2,14 +2,14 @@ /* Copyright (C) 2016-2017 Dell, Inc. */ /* Copyright (C) 2016 Hewlett Packard Enterprise Development LP */ /* Copyright (C) 2014-2020, Intel Corporation. */ +/* Copyright (C) 2022 iXsystems, Inc. */ #ifndef __NDCTL_MSFT_H__ #define __NDCTL_MSFT_H__ enum { - NDN_MSFT_CMD_QUERY = 0, - - /* non-root commands */ - NDN_MSFT_CMD_SMART = 11, + NDN_MSFT_CMD_CHEALTH = 10, + NDN_MSFT_CMD_NHEALTH = 11, + NDN_MSFT_CMD_EHEALTH = 12, }; /* From patchwork Wed Feb 15 16:49:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Motin X-Patchwork-Id: 13141949 Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE5D37B for ; Wed, 15 Feb 2023 16:51:42 +0000 (UTC) Received: by mail-qt1-f175.google.com with SMTP id v17so22482808qto.3 for ; Wed, 15 Feb 2023 08:51:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ixsystems.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VkbCFn8Ee7nglxRTQaR3XeU/VL9CocntID81FAU1nqk=; b=H17CS+lQCeoyLFJlqYrrTp3KxYr23M+hndnYdXp7llPgioLluRk+RgXDnL/b5M8yL4 6aL0TEk/5MsPJrEEK1upnAIHahuv+2PwaeL/MW+1+G53UvYTg/j+fSj/ntBHE1f91TLX t4jOz4rhaHIhyZM0T6ZVRSkVvaSCrT5uHtHLiVh7UorIZQv88wh9nCX3yn+8H1FrYRIB Bva8mla1HbTGF4/+fQ/EYlt7uK4JT6LsOIckY8LeFi080Psr/utIXVhicj2r4EDN78WP QDvpLy9ftLF5QA/w40I+c2yjf4fctBvMhusnfKyHwKVsNA4/kU8CkO7JKTXy6DGrApMm C0Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VkbCFn8Ee7nglxRTQaR3XeU/VL9CocntID81FAU1nqk=; b=ENuaBa801G+EdzP7G9pAkyX5AEmY+O8eM7ewzVNcKReLQ85UsPXTisDJAY7bAJlRov 1QYTml6PDsZsBJunHI045EAbP6vsdKnBonRtluN5rEXuyoKbsD2EAsWCltlVchRJMJT+ RNd0jpCqfMR77JLSKJzAf2qPv/XwCsgiG6VTaDXZuAWD4QC6bfa6lTxwhlUy55yY62vY LD8wH0TlSnLNVtHVUBukUUTPZSNS3UgH5ENEsrbF8HxgJam8+xTXTJp9nClYfD9BJS2y 2+JlUiQCeeOMLdc1ywu1AcXfpfdK6awFSELQWk8GxwdlljAdAuhnkaS7zsX8APDEl7iR 8DHg== X-Gm-Message-State: AO0yUKWR3moHl/Lfh591ltsqFG1YPedKIa/dQwUayKfIUBdoctkeUXa0 R6BbwddGkK61dweB1A5XBWxKgT+QoOQf3JOdxJLEPr7zQReZAqLl8Jm/9EuP5pkmFQLvskXZXf1 5QVbsclhXksGBNzCjFKUqGP7LhGbcryhh4iCpT7ko06JfBhpSXvUV7f8wCa+KbK0TxzIB X-Google-Smtp-Source: AK7set8xzrg1aF02mVS1jVCEynsI0NZg626OTYs9dQA4tknf8LKJ8kTw+4YAIoXGLTNsmJd2uY8Y3g== X-Received: by 2002:ac8:598f:0:b0:3bd:48:7097 with SMTP id e15-20020ac8598f000000b003bd00487097mr3521534qte.49.1676479901197; Wed, 15 Feb 2023 08:51:41 -0800 (PST) Received: from testm50.mav.ixsystems.net ([38.32.73.2]) by smtp.gmail.com with ESMTPSA id y10-20020ac8128a000000b003b68ea3d5c8sm13353529qti.41.2023.02.15.08.51.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 08:51:40 -0800 (PST) From: Alexander Motin To: nvdimm@lists.linux.dev Cc: Vishal Verma , Dan Williams , Alexander Motin Subject: [ndctl PATCH 3/4 v3] libndctl/msft: Add custom cmd_is_supported method Date: Wed, 15 Feb 2023 11:49:32 -0500 Message-Id: <20230215164930.707170-3-mav@ixsystems.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230215164930.707170-1-mav@ixsystems.com> References: <20230215164930.707170-1-mav@ixsystems.com> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 It allows monitor mode to be used for this type of NVDIMMs. Signed-off-by: Alexander Motin --- ndctl/lib/msft.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ndctl/lib/msft.c b/ndctl/lib/msft.c index b5278c5..b8ef00f 100644 --- a/ndctl/lib/msft.c +++ b/ndctl/lib/msft.c @@ -30,6 +30,15 @@ static const char *msft_cmd_desc(int fn) return desc; } +static bool msft_cmd_is_supported(struct ndctl_dimm *dimm, int cmd) +{ + /* Handle this separately to support monitor mode */ + if (cmd == ND_CMD_SMART) + return true; + + return !!(dimm->cmd_mask & (1ULL << cmd)); +} + static u32 msft_get_firmware_status(struct ndctl_cmd *cmd) { return cmd->msft->u.smart.status; @@ -195,6 +204,7 @@ static int msft_cmd_xlat_firmware_status(struct ndctl_cmd *cmd) struct ndctl_dimm_ops * const msft_dimm_ops = &(struct ndctl_dimm_ops) { .cmd_desc = msft_cmd_desc, + .cmd_is_supported = msft_cmd_is_supported, .new_smart = msft_dimm_cmd_new_smart, .smart_get_flags = msft_cmd_smart_get_flags, .smart_get_health = msft_cmd_smart_get_health, From patchwork Wed Feb 15 16:49:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Motin X-Patchwork-Id: 13141950 Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CAECB7B for ; Wed, 15 Feb 2023 16:52:01 +0000 (UTC) Received: by mail-qt1-f177.google.com with SMTP id b21so2987086qtr.13 for ; Wed, 15 Feb 2023 08:52:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ixsystems.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6rEa4B27p8KJ9J93PuZ29qcEuS5+ftu87mGHg/UW+S0=; b=G4car/K1Ch/HPm/DcGjgzlDjPUXs6aQurOpxJuZbZZBQLWhLtHjtYYp1HL1u8r4/E9 rbHStqnfiNQ/7uLCXDsUf8bykaIBdEgRM36xzbl72FtCAdC4pMrIPl/YhwEKUVZViYQj evHhLUgckgcy34x4eDq/3cRBJqyt2g8T7tY5k1czlCTRbHnnjKTO43Lgni8prg2PT7sq SdXwf/lbJxUYWAq7O0AePPhnon1mYPZ0L9Jz/u9MOecqRIuSAHpfLmdom7T/S8ws1R0H xxAJcAGOZT063HtO1ov1YQA1BsYre4vxQ7FjX03r5rvgqzfyK2wGguIq/dPgGojvKuQW kK+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6rEa4B27p8KJ9J93PuZ29qcEuS5+ftu87mGHg/UW+S0=; b=qDGosKql0xUDsTCv8Tea1HQhD4umCK+KWGjOhapenKx/9B/9cVAv23hvFx0FkxZrqO 4cFyliWd1csrvbGii3OJeWMGrx2LvLPiMsZShpkEquaUKdM4mmw65WXvw8VJTabX1v19 p6hpx5ekKLAyX16u4RIBYm+SO+M6bo6Ope9SzvvfCsQKdT/a7eLpoRP0xEfb2UsUxxA4 5dHIXBYtoKEysJJ42jMAk5dQXc7jxktlqWvXF1yNe4i1BhkN+oVMzfpvJ4bvjgem9+HX 9FAsVHn73uL/8mSlFbfG8+WXk2H+yB1gn6cDg8R+AOdVDzZWaRbtBzN1p3WJrVyg3y5+ 4aiQ== X-Gm-Message-State: AO0yUKWo1QPKVdaBcnrbZ+ryHXJVYQuO3pdHD+t6QEJ/z7JPdlKamZYZ di7R5MvWw60y5GoEGWvSoQTxz1WccC+slCCtuTq4U1ycRZu/pofIA/X0teWAqGDHV1C19ip1JKH omcO4b9reNugUhGgyDFFCetlkou1v01GYTK9rR1HbzvSDo8CEyYiIIitFTn93bBrp7Yuu X-Google-Smtp-Source: AK7set9lX2WX+Ht6kBZYIGFhWgD6waKf+8s8Fh13FEFORcPDJWS2OJsTdEdHVyrS0G0+iTFkisdSnw== X-Received: by 2002:a05:622a:551:b0:3a9:81f0:d8e9 with SMTP id m17-20020a05622a055100b003a981f0d8e9mr4301314qtx.68.1676479920281; Wed, 15 Feb 2023 08:52:00 -0800 (PST) Received: from testm50.mav.ixsystems.net ([38.32.73.2]) by smtp.gmail.com with ESMTPSA id y10-20020ac8128a000000b003b68ea3d5c8sm13353529qti.41.2023.02.15.08.51.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 08:51:59 -0800 (PST) From: Alexander Motin To: nvdimm@lists.linux.dev Cc: Vishal Verma , Dan Williams , Alexander Motin Subject: [ndctl PATCH 4/4 v3] libndctl/msft: Improve "smart" state reporting Date: Wed, 15 Feb 2023 11:49:34 -0500 Message-Id: <20230215164930.707170-4-mav@ixsystems.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230215164930.707170-1-mav@ixsystems.com> References: <20230215164930.707170-1-mav@ixsystems.com> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Previous code reported "smart" state based on number of bits set in the module health field. But actually any single bit set there already means critical failure. Rework the logic according to the specifications, properly reporting non-critical state in case of warning threshold reached, critical in case of any module health bit set or error threshold reached and fatal if NVDIMM exhausted its life time. In attempt to report the cause of failure in absence of better methods, report reached thresholds as more or less matching alarms. Signed-off-by: Alexander Motin --- ndctl/lib/msft.c | 55 ++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/ndctl/lib/msft.c b/ndctl/lib/msft.c index b8ef00f..a66ca9c 100644 --- a/ndctl/lib/msft.c +++ b/ndctl/lib/msft.c @@ -114,26 +114,32 @@ static unsigned int msft_cmd_smart_get_flags(struct ndctl_cmd *cmd) /* below health data can be retrieved via MSFT _DSM function 11 */ return ND_SMART_HEALTH_VALID | ND_SMART_TEMP_VALID | - ND_SMART_USED_VALID; + ND_SMART_USED_VALID | ND_SMART_ALARM_VALID; } -static unsigned int num_set_bit_health(__u16 num) +static unsigned int msft_cmd_smart_get_health(struct ndctl_cmd *cmd) { - int i; - __u16 n = num & 0x7FFF; - unsigned int count = 0; + unsigned int health = 0; + int rc; - for (i = 0; i < 15; i++) - if (!!(n & (1 << i))) - count++; + rc = msft_smart_valid(cmd); + if (rc < 0) { + errno = -rc; + return UINT_MAX; + } - return count; + if (CMD_MSFT_SMART(cmd)->nvm_lifetime == 0) + health |= ND_SMART_FATAL_HEALTH; + if (CMD_MSFT_SMART(cmd)->health != 0 || + CMD_MSFT_SMART(cmd)->err_thresh_stat != 0) + health |= ND_SMART_CRITICAL_HEALTH; + if (CMD_MSFT_SMART(cmd)->warn_thresh_stat != 0) + health |= ND_SMART_NON_CRITICAL_HEALTH; + return health; } -static unsigned int msft_cmd_smart_get_health(struct ndctl_cmd *cmd) +static unsigned int msft_cmd_smart_get_media_temperature(struct ndctl_cmd *cmd) { - unsigned int health; - unsigned int num; int rc; rc = msft_smart_valid(cmd); @@ -142,21 +148,13 @@ static unsigned int msft_cmd_smart_get_health(struct ndctl_cmd *cmd) return UINT_MAX; } - num = num_set_bit_health(CMD_MSFT_SMART(cmd)->health); - if (num == 0) - health = 0; - else if (num < 2) - health = ND_SMART_NON_CRITICAL_HEALTH; - else if (num < 3) - health = ND_SMART_CRITICAL_HEALTH; - else - health = ND_SMART_FATAL_HEALTH; - - return health; + return CMD_MSFT_SMART(cmd)->temp * 16; } -static unsigned int msft_cmd_smart_get_media_temperature(struct ndctl_cmd *cmd) +static unsigned int msft_cmd_smart_get_alarm_flags(struct ndctl_cmd *cmd) { + __u8 stat; + unsigned int flags = 0; int rc; rc = msft_smart_valid(cmd); @@ -165,7 +163,13 @@ static unsigned int msft_cmd_smart_get_media_temperature(struct ndctl_cmd *cmd) return UINT_MAX; } - return CMD_MSFT_SMART(cmd)->temp * 16; + stat = CMD_MSFT_SMART(cmd)->err_thresh_stat | + CMD_MSFT_SMART(cmd)->warn_thresh_stat; + if (stat & 3) /* NVM_LIFETIME/ES_LIFETIME */ + flags |= ND_SMART_SPARE_TRIP; + if (stat & 4) /* ES_TEMP */ + flags |= ND_SMART_CTEMP_TRIP; + return flags; } static unsigned int msft_cmd_smart_get_life_used(struct ndctl_cmd *cmd) @@ -209,6 +213,7 @@ struct ndctl_dimm_ops * const msft_dimm_ops = &(struct ndctl_dimm_ops) { .smart_get_flags = msft_cmd_smart_get_flags, .smart_get_health = msft_cmd_smart_get_health, .smart_get_media_temperature = msft_cmd_smart_get_media_temperature, + .smart_get_alarm_flags = msft_cmd_smart_get_alarm_flags, .smart_get_life_used = msft_cmd_smart_get_life_used, .xlat_firmware_status = msft_cmd_xlat_firmware_status, };