From 73cc2ca39ec023ee18d20056b64f76fb494612c6 Mon Sep 17 00:00:00 2001 From: jeff-lien-wdc Date: Fri, 1 Mar 2024 16:01:40 -0600 Subject: [PATCH] wdc: Add support for the get-drive-status command to SN861 This change will use UUID lists to access the WD C2 log page and retrieve the correct info needed to display the drive status. Signed-off-by: jeff-lien-wdc --- plugins/wdc/wdc-nvme.c | 38 ++++++++++++++++++++++++-------------- plugins/wdc/wdc-nvme.h | 2 +- plugins/wdc/wdc-utils.c | 2 +- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/plugins/wdc/wdc-nvme.c b/plugins/wdc/wdc-nvme.c index 8cbcf2eab0..f90ecce65a 100644 --- a/plugins/wdc/wdc-nvme.c +++ b/plugins/wdc/wdc-nvme.c @@ -1921,6 +1921,7 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, struct nvme_dev *dev) WDC_DRIVE_CAP_INFO | WDC_DRIVE_CAP_CLOUD_SSD_VERSION | WDC_DRIVE_CAP_LOG_PAGE_DIR | + WDC_DRIVE_CAP_DRIVE_STATUS | WDC_DRIVE_CAP_SET_LATENCY_MONITOR); break; @@ -2450,23 +2451,32 @@ static bool get_dev_mgment_cbs_data(nvme_root_t r, struct nvme_dev *dev, uuid_index = index + 1; } - if (!uuid_index && needs_c2_log_page_check(device_id)) { - /* In certain devices that don't support UUID lists, there are multiple - * definitions of the C2 logpage. In those cases, the code - * needs to try two UUID indexes and use an identification algorithm - * to determine which is returning the correct log page data. - */ - uuid_ix = 1; - } + if (uuid_present) { + /* use the uuid index found above */ + found = get_dev_mgmt_log_page_lid_data(dev, cbs_data, lid, log_id, uuid_index); + } else if (device_id == WDC_NVME_ZN350_DEV_ID || device_id == WDC_NVME_ZN350_DEV_ID_1) { + uuid_index = 0; + found = get_dev_mgmt_log_page_lid_data(dev, cbs_data, lid, log_id, uuid_index); + } else { + if (!uuid_index && needs_c2_log_page_check(device_id)) { + /* In certain devices that don't support UUID lists, there are multiple + * definitions of the C2 logpage. In those cases, the code + * needs to try two UUID indexes and use an identification algorithm + * to determine which is returning the correct log page data. + */ + uuid_ix = 1; + } - found = get_dev_mgmt_log_page_lid_data(dev, cbs_data, lid, log_id, uuid_ix); + found = get_dev_mgmt_log_page_lid_data(dev, cbs_data, lid, log_id, uuid_ix); - if (!found) { - /* not found with uuid = 1 try with uuid = 0 */ - uuid_ix = 0; - fprintf(stderr, "Not found, requesting log page with uuid_index %d\n", uuid_index); + if (!found) { + /* not found with uuid = 1 try with uuid = 0 */ + 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); + found = get_dev_mgmt_log_page_lid_data(dev, cbs_data, lid, log_id, uuid_ix); + } } return found; diff --git a/plugins/wdc/wdc-nvme.h b/plugins/wdc/wdc-nvme.h index d3692bcc58..d1f87406bd 100644 --- a/plugins/wdc/wdc-nvme.h +++ b/plugins/wdc/wdc-nvme.h @@ -5,7 +5,7 @@ #if !defined(WDC_NVME) || defined(CMD_HEADER_MULTI_READ) #define WDC_NVME -#define WDC_PLUGIN_VERSION "2.7.0" +#define WDC_PLUGIN_VERSION "2.8.0" #include "cmd.h" PLUGIN(NAME("wdc", "Western Digital vendor specific extensions", WDC_PLUGIN_VERSION), diff --git a/plugins/wdc/wdc-utils.c b/plugins/wdc/wdc-utils.c index 414a06a64f..1b52e7c04a 100644 --- a/plugins/wdc/wdc-utils.c +++ b/plugins/wdc/wdc-utils.c @@ -192,5 +192,5 @@ bool wdc_CheckUuidListSupport(struct nvme_dev *dev, struct nvme_id_uuid_list *uu bool wdc_UuidEqual(struct nvme_id_uuid_list_entry *entry1, struct nvme_id_uuid_list_entry *entry2) { - return !memcmp(entry1, entry2, NVME_UUID_LEN); + return !memcmp(entry1->uuid, entry2->uuid, NVME_UUID_LEN); }