diff mbox series

[ndctl,3/4,v3] libndctl/msft: Add custom cmd_is_supported method

Message ID 20230215164930.707170-3-mav@ixsystems.com (mailing list archive)
State Accepted
Commit cf85848aa67cc8d222a6566186c1b2af786c2ef1
Headers show
Series [ndctl,1/4,v3] libndctl/msft: Remove NDN_MSFT_SMART_*_VALID defines. | expand

Commit Message

Alexander Motin Feb. 15, 2023, 4:49 p.m. UTC
It allows monitor mode to be used for this type of NVDIMMs.

Signed-off-by:	Alexander Motin <mav@ixsystems.com>
---
 ndctl/lib/msft.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series

Patch

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,