Skip to content

Commit

Permalink
wdc: Add support for the get-drive-status command to SN861
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jeff-lien-sndk authored and igaw committed Mar 5, 2024
1 parent 450d897 commit cd4c95a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
38 changes: 24 additions & 14 deletions plugins/wdc/wdc-nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
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.7.0"
#define WDC_PLUGIN_VERSION "2.8.0"
#include "cmd.h"

PLUGIN(NAME("wdc", "Western Digital vendor specific extensions", WDC_PLUGIN_VERSION),
Expand Down
2 changes: 1 addition & 1 deletion plugins/wdc/wdc-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit cd4c95a

Please sign in to comment.