Skip to content

Commit

Permalink
wdc: Fix vs-smart-add-log Command for SN650 and SN655
Browse files Browse the repository at this point in the history
	The incorrect log page was being displayed because
	the wrong uuid index was being used.  This patch
	determines the correct uuid index needed for
	SN650 and SN655.

Signed-off-by: jeff-lien-wdc <jeff.lien@wdc.com>
  • Loading branch information
jeff-lien-wdc committed Dec 14, 2023
1 parent 5c1b231 commit 956f69d
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 12 deletions.
81 changes: 70 additions & 11 deletions plugins/wdc/wdc-nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -2377,8 +2377,8 @@ static bool get_dev_mgment_cbs_data(nvme_root_t r, struct nvme_dev *dev,

if (!found) {
/* not found with uuid = 1 try with uuid = 0 */
fprintf(stderr, "Requesting Log page with uuid_index %d", uuid_index);
uuid_ix = 0;
fprintf(stderr, "Not found, requesting log page with uuid_index %d\n", uuid_index);

found = get_dev_mgmt_log_page_lid_data(dev, cbs_data, lid, log_id, uuid_ix);
}
Expand Down Expand Up @@ -6941,6 +6941,8 @@ static int wdc_get_c0_log_page(nvme_root_t r, struct nvme_dev *dev, char *format
enum nvme_print_flags fmt;
int ret;
__u8 *data;
__u8 log_id;
__u32 length;

if (!wdc_check_device(r, dev))
return -1;
Expand All @@ -6967,6 +6969,16 @@ static int wdc_get_c0_log_page(nvme_root_t r, struct nvme_dev *dev, char *format
fallthrough;
case WDC_NVME_SN860_DEV_ID:
fallthrough;
case WDC_NVME_SN560_DEV_ID_1:
fallthrough;
case WDC_NVME_SN560_DEV_ID_2:
fallthrough;
case WDC_NVME_SN560_DEV_ID_3:
fallthrough;
case WDC_NVME_SN550_DEV_ID:
ret = wdc_get_c0_log_page_sn(r, dev, uuid_index, format, namespace_id, fmt);
break;

case WDC_NVME_SN650_DEV_ID:
fallthrough;
case WDC_NVME_SN650_DEV_ID_1:
Expand All @@ -6977,17 +6989,64 @@ static int wdc_get_c0_log_page(nvme_root_t r, struct nvme_dev *dev, char *format
fallthrough;
case WDC_NVME_SN650_DEV_ID_4:
fallthrough;
case WDC_NVME_SN560_DEV_ID_1:
fallthrough;
case WDC_NVME_SN560_DEV_ID_2:
fallthrough;
case WDC_NVME_SN560_DEV_ID_3:
fallthrough;
case WDC_NVME_SN550_DEV_ID:
ret = wdc_get_c0_log_page_sn(r, dev, uuid_index, format, namespace_id, fmt);
break;
case WDC_NVME_SN655_DEV_ID:
fallthrough;
if (uuid_index == 0) {
log_id = WDC_NVME_GET_SMART_CLOUD_ATTR_LOG_ID;
length = WDC_NVME_SMART_CLOUD_ATTR_LEN;
} else {
log_id = WDC_NVME_GET_EOL_STATUS_LOG_OPCODE;
length = WDC_NVME_EOL_STATUS_LOG_LEN;
}

data = (__u8 *)malloc(sizeof(__u8) * length);
if (!data) {
fprintf(stderr, "ERROR: WDC: malloc: %s\n", strerror(errno));
return -1;
}

if (namespace_id == NVME_NSID_ALL) {
ret = nvme_get_nsid(dev_fd(dev), &namespace_id);
if (ret < 0)
namespace_id = NVME_NSID_ALL;
}

/* Get the 0xC0 log data */
struct nvme_get_log_args args = {
.args_size = sizeof(args),
.fd = dev_fd(dev),
.lid = log_id,
.nsid = namespace_id,
.lpo = 0,
.lsp = NVME_LOG_LSP_NONE,
.lsi = 0,
.rae = false,
.uuidx = uuid_index,
.csi = NVME_CSI_NVM,
.ot = false,
.len = length,
.log = data,
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
.result = NULL,
};
ret = nvme_get_log(&args);

if (strcmp(format, "json"))
nvme_show_status(ret);

if (!ret) {
/* parse the data */
if (uuid_index == 0)
wdc_print_c0_cloud_attr_log(data, fmt);
else
wdc_print_c0_eol_log(data, fmt);
} else {
fprintf(stderr, "ERROR: WDC: Unable to read C0 Log Page data, uuid index %d\n",

Check failure on line 7043 in plugins/wdc/wdc-nvme.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: line length of 103 exceeds 100 columns
uuid_index);
ret = -1;
}
free(data);
break;

case WDC_NVME_ZN350_DEV_ID:
fallthrough;
case WDC_NVME_ZN350_DEV_ID_1:
Expand Down
2 changes: 1 addition & 1 deletion plugins/wdc/wdc-nvme.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#if !defined(WDC_NVME) || defined(CMD_HEADER_MULTI_READ)
#define WDC_NVME

#define WDC_PLUGIN_VERSION "2.3.4"
#define WDC_PLUGIN_VERSION "2.3.5"
#include "cmd.h"

PLUGIN(NAME("wdc", "Western Digital vendor specific extensions", WDC_PLUGIN_VERSION),
Expand Down

0 comments on commit 956f69d

Please sign in to comment.