From 63346d6980d0b3f968a1f160ca3ae25bf3959c4f Mon Sep 17 00:00:00 2001 From: Jeff Lien Date: Fri, 22 Oct 2021 11:18:28 -0500 Subject: [PATCH] Add namespace id parm to vs-smart-add-log wdc plugin cmd [dwagner: ported from nvme-cli-monolithic] Signed-off-by: Daniel Wagner --- plugins/wdc/wdc-nvme.c | 19 +++++++++++++++---- plugins/wdc/wdc-nvme.h | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/plugins/wdc/wdc-nvme.c b/plugins/wdc/wdc-nvme.c index 7105562e..0f895257 100644 --- a/plugins/wdc/wdc-nvme.c +++ b/plugins/wdc/wdc-nvme.c @@ -4927,7 +4927,7 @@ static int wdc_print_c0_eol_log(void *data, int fmt) } static int wdc_get_c0_log_page(nvme_root_t r, int fd, char *format, - int uuid_index) + int uuid_index, __u32 namespace_id) { int ret = 0; int fmt = -1; @@ -4970,8 +4970,15 @@ static int wdc_get_c0_log_page(nvme_root_t r, int fd, char *format, return -1; } + if (namespace_id == NVME_NSID_ALL) { + ret = nvme_get_nsid(fd, &namespace_id); + if (ret < 0) { + namespace_id = NVME_NSID_ALL; + } + } + /* Get the 0xC0 log data */ - ret = nvme_get_log(fd, WDC_NVME_GET_EOL_STATUS_LOG_OPCODE, 0xFFFFFFFF, 0, + ret = nvme_get_log(fd, WDC_NVME_GET_EOL_STATUS_LOG_OPCODE, namespace_id, 0, NVME_LOG_LSP_NONE, 0, false, uuid_index, 0, WDC_NVME_SMART_CLOUD_ATTR_LEN, data); if (strcmp(format, "json")) @@ -5018,7 +5025,7 @@ static int wdc_get_c0_log_page(nvme_root_t r, int fd, char *format, } /* Get the 0xC0 log data */ - ret = nvme_get_log(fd, WDC_NVME_GET_EOL_STATUS_LOG_OPCODE, 0xFFFFFFFF, 0, + ret = nvme_get_log(fd, WDC_NVME_GET_EOL_STATUS_LOG_OPCODE, NVME_NSID_ALL, 0, NVME_LOG_LSP_NONE, 0, false, uuid_index, 0, WDC_NVME_EOL_STATUS_LOG_LEN, data); if (strcmp(format, "json")) @@ -5503,6 +5510,7 @@ static int wdc_vs_smart_add_log(int argc, char **argv, struct command *command, int fd; const char *log_page_version = "Log Page Version: 0 = vendor, 1 = WDC"; const char *log_page_mask = "Log Page Mask, comma separated list: 0xC0, 0xC1, 0xCA, 0xD0"; + const char *namespace_id = "desired namespace id"; nvme_root_t r; int ret = 0; int uuid_index = 0; @@ -5515,6 +5523,7 @@ static int wdc_vs_smart_add_log(int argc, char **argv, struct command *command, char *output_format; __u8 log_page_version; char *log_page_mask; + __u32 namespace_id; }; struct config cfg = { @@ -5522,6 +5531,7 @@ static int wdc_vs_smart_add_log(int argc, char **argv, struct command *command, .output_format = "normal", .log_page_version = 0, .log_page_mask = "", + .namespace_id = NVME_NSID_ALL, }; OPT_ARGS(opts) = { @@ -5529,6 +5539,7 @@ static int wdc_vs_smart_add_log(int argc, char **argv, struct command *command, OPT_FMT("output-format", 'o', &cfg.output_format, "Output Format: normal|json"), OPT_BYTE("log-page-version", 'l', &cfg.log_page_version, log_page_version), OPT_LIST("log-page-mask", 'p', &cfg.log_page_mask, log_page_mask), + OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), OPT_END() }; @@ -5592,7 +5603,7 @@ static int wdc_vs_smart_add_log(int argc, char **argv, struct command *command, if (((capabilities & WDC_DRIVE_CAP_C0_LOG_PAGE) == WDC_DRIVE_CAP_C0_LOG_PAGE) && (page_mask & WDC_C0_PAGE_MASK)) { /* Get 0xC0 log page if possible. */ - ret = wdc_get_c0_log_page(r, fd, cfg.output_format, uuid_index); + ret = wdc_get_c0_log_page(r, fd, cfg.output_format, uuid_index, cfg.namespace_id); if (ret) fprintf(stderr, "ERROR : WDC : Failure reading the C0 Log Page, ret = %d\n", ret); } diff --git a/plugins/wdc/wdc-nvme.h b/plugins/wdc/wdc-nvme.h index 10d506f6..e046007d 100644 --- a/plugins/wdc/wdc-nvme.h +++ b/plugins/wdc/wdc-nvme.h @@ -4,7 +4,7 @@ #if !defined(WDC_NVME) || defined(CMD_HEADER_MULTI_READ) #define WDC_NVME -#define WDC_PLUGIN_VERSION "1.14.1" +#define WDC_PLUGIN_VERSION "1.15.4" #include "cmd.h" PLUGIN(NAME("wdc", "Western Digital vendor specific extensions", WDC_PLUGIN_VERSION), -- 2.50.1