summaryrefslogtreecommitdiffstats
path: root/plugins/wdc/wdc-nvme.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 11:08:54 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 11:08:54 +0000
commita45fb29c9f34bc175ac7b69723de175d62e838eb (patch)
tree364371981040c3dc6e97bb289bda0d33933ebfac /plugins/wdc/wdc-nvme.c
parentAdding upstream version 2.8. (diff)
downloadnvme-cli-a45fb29c9f34bc175ac7b69723de175d62e838eb.tar.xz
nvme-cli-a45fb29c9f34bc175ac7b69723de175d62e838eb.zip
Adding upstream version 2.9.1.upstream/2.9.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'plugins/wdc/wdc-nvme.c')
-rw-r--r--plugins/wdc/wdc-nvme.c327
1 files changed, 122 insertions, 205 deletions
diff --git a/plugins/wdc/wdc-nvme.c b/plugins/wdc/wdc-nvme.c
index 8cbcf2e..7525055 100644
--- a/plugins/wdc/wdc-nvme.c
+++ b/plugins/wdc/wdc-nvme.c
@@ -1383,6 +1383,11 @@ struct __packed wdc_fw_act_history_log_format_c2 {
__u8 log_page_guid[WDC_C2_GUID_LENGTH];
};
+static __u8 ocp_C2_guid[WDC_C2_GUID_LENGTH] = {
+ 0x6D, 0x79, 0x9A, 0x76, 0xB4, 0xDA, 0xF6, 0xA3,
+ 0xE2, 0x4D, 0xB2, 0x8A, 0xAC, 0xF3, 0x1C, 0xD1
+};
+
#define WDC_OCP_C4_GUID_LENGTH 16
#define WDC_DEV_CAP_LOG_BUF_LEN 4096
#define WDC_DEV_CAP_LOG_ID 0xC4
@@ -1726,7 +1731,6 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, struct nvme_dev *dev)
case WDC_NVME_VID_2:
switch (read_device_id) {
case WDC_NVME_SN630_DEV_ID:
- fallthrough;
case WDC_NVME_SN630_DEV_ID_1:
capabilities = (WDC_DRIVE_CAP_CAP_DIAG | WDC_DRIVE_CAP_INTERNAL_LOG |
WDC_DRIVE_CAP_DRIVE_STATUS | WDC_DRIVE_CAP_CLEAR_ASSERT |
@@ -1743,19 +1747,12 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, struct nvme_dev *dev)
break;
case WDC_NVME_SN640_DEV_ID:
- fallthrough;
case WDC_NVME_SN640_DEV_ID_1:
- fallthrough;
case WDC_NVME_SN640_DEV_ID_2:
- fallthrough;
case WDC_NVME_SN640_DEV_ID_3:
- 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_SN660_DEV_ID:
/* verify the 0xC0 log page is supported */
if (wdc_nvme_check_supported_log_page(r, dev,
@@ -1816,9 +1813,7 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, struct nvme_dev *dev)
break;
case WDC_NVME_SN840_DEV_ID:
- fallthrough;
case WDC_NVME_SN840_DEV_ID_1:
- fallthrough;
case WDC_NVME_SN860_DEV_ID:
/* verify the 0xC0 log page is supported */
if (wdc_nvme_check_supported_log_page(r, dev,
@@ -1826,7 +1821,6 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, struct nvme_dev *dev)
capabilities |= WDC_DRIVE_CAP_C0_LOG_PAGE;
fallthrough;
case WDC_NVME_ZN540_DEV_ID:
- fallthrough;
case WDC_NVME_SN540_DEV_ID:
capabilities |= (WDC_DRIVE_CAP_CAP_DIAG | WDC_DRIVE_CAP_INTERNAL_LOG |
WDC_DRIVE_CAP_DRIVE_STATUS | WDC_DRIVE_CAP_CLEAR_ASSERT |
@@ -1847,17 +1841,11 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, struct nvme_dev *dev)
break;
case WDC_NVME_SN650_DEV_ID:
- fallthrough;
case WDC_NVME_SN650_DEV_ID_1:
- fallthrough;
case WDC_NVME_SN650_DEV_ID_2:
- fallthrough;
case WDC_NVME_SN650_DEV_ID_3:
- fallthrough;
case WDC_NVME_SN650_DEV_ID_4:
- fallthrough;
case WDC_NVME_SN655_DEV_ID:
- fallthrough;
case WDC_NVME_SN550_DEV_ID:
/* verify the 0xC0 log page is supported */
if (wdc_nvme_check_supported_log_page(r, dev,
@@ -1907,7 +1895,6 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, struct nvme_dev *dev)
break;
case WDC_NVME_SN861_DEV_ID:
- fallthrough;
case WDC_NVME_SN861_DEV_ID_1:
capabilities |= (WDC_DRIVE_CAP_C0_LOG_PAGE |
WDC_DRIVE_CAP_C3_LOG_PAGE |
@@ -1921,6 +1908,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;
@@ -1936,11 +1924,8 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, struct nvme_dev *dev)
break;
case WDC_NVME_SN520_DEV_ID:
- fallthrough;
case WDC_NVME_SN520_DEV_ID_1:
- fallthrough;
case WDC_NVME_SN520_DEV_ID_2:
- fallthrough;
case WDC_NVME_SN810_DEV_ID:
capabilities = WDC_DRIVE_CAP_DUI_DATA;
break;
@@ -2010,19 +1995,14 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, struct nvme_dev *dev)
case WDC_NVME_SN8000S_DEV_ID:
fallthrough;
case WDC_NVME_SN740_DEV_ID:
- fallthrough;
case WDC_NVME_SN740_DEV_ID_1:
- fallthrough;
case WDC_NVME_SN740_DEV_ID_2:
- fallthrough;
case WDC_NVME_SN740_DEV_ID_3:
- fallthrough;
case WDC_NVME_SN340_DEV_ID:
capabilities = WDC_DRIVE_CAP_DUI;
break;
case WDC_NVME_ZN350_DEV_ID:
- fallthrough;
case WDC_NVME_ZN350_DEV_ID_1:
capabilities = WDC_DRIVE_CAP_DUI_DATA | WDC_DRIVE_CAP_VU_FID_CLEAR_PCIE |
WDC_DRIVE_CAP_C0_LOG_PAGE |
@@ -2450,23 +2430,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;
@@ -5538,17 +5527,18 @@ static void wdc_print_fw_act_history_log_normal(__u8 *data, int num_entries,
char previous_fw[9];
char new_fw[9];
char commit_action_bin[8];
- char time_str[11];
+ char time_str[100];
__u16 oldestEntryIdx = 0, entryIdx = 0;
+ uint64_t timestamp;
+ __u64 timestamp_sec;
char *null_fw = "--------";
- memset((void *)time_str, 0, 11);
+ memset((void *)time_str, '\0', 100);
if (data[0] == WDC_NVME_GET_FW_ACT_HISTORY_C2_LOG_ID) {
printf(" Firmware Activate History Log\n");
if (cust_id == WDC_CUSTOMER_ID_0x1005 ||
- vendor_id == WDC_NVME_SNDK_VID ||
- wdc_is_sn861(device_id)) {
+ vendor_id == WDC_NVME_SNDK_VID) {
printf(" Power on Hour Power Cycle Previous New\n");
printf(" Entry hh:mm:ss Count Firmware Firmware Slot Action Result\n");
printf(" ----- ----------------- ----------------- --------- --------- ----- ------ -------\n");
@@ -5589,48 +5579,33 @@ static void wdc_print_fw_act_history_log_normal(__u8 *data, int num_entries,
memcpy(new_fw, null_fw, 8);
printf("%5"PRIu16"", (uint16_t)le16_to_cpu(fw_act_history_entry->entry[entryIdx].fw_act_hist_entries));
+
+ timestamp = (0x0000FFFFFFFFFFFF &
+ le64_to_cpu(
+ fw_act_history_entry->entry[entryIdx].timestamp));
+ timestamp_sec = timestamp / 1000;
if (cust_id == WDC_CUSTOMER_ID_0x1005) {
printf(" ");
memset((void *)time_str, 0, 9);
- sprintf((char *)time_str, "%04d:%02d:%02d", (int)(le64_to_cpu(fw_act_history_entry->entry[entryIdx].timestamp)/3600),
- (int)((le64_to_cpu(fw_act_history_entry->entry[entryIdx].timestamp%3600)/60)),
- (int)(le64_to_cpu(fw_act_history_entry->entry[entryIdx].timestamp%60)));
+ sprintf((char *)time_str, "%"PRIu32":%u:%u",
+ (__u32)(timestamp_sec/3600),
+ (__u8)(timestamp_sec%3600/60),
+ (__u8)(timestamp_sec%60));
printf("%s", time_str);
printf(" ");
} else if (vendor_id == WDC_NVME_SNDK_VID) {
printf(" ");
- uint64_t timestamp = (0x0000FFFFFFFFFFFF & le64_to_cpu(fw_act_history_entry->entry[entryIdx].timestamp));
memset((void *)time_str, 0, 9);
- sprintf((char *)time_str, "%04d:%02d:%02d", (int)((timestamp/(3600*1000))%24), (int)((timestamp/(1000*60))%60),
- (int)((timestamp/1000)%60));
+ sprintf((char *)time_str, "%"PRIu32":%u:%u",
+ (__u32)((timestamp_sec/3600)%24),
+ (__u8)((timestamp_sec/60)%60),
+ (__u8)(timestamp_sec%60));
printf("%s", time_str);
printf(" ");
- } else if (wdc_is_sn861(device_id)) {
- printf(" ");
- char timestamp[20];
- __u64 hour;
- __u8 min;
- __u8 sec;
- __u64 timestamp_sec;
-
- timestamp_sec =
- le64_to_cpu(fw_act_history_entry->entry[entryIdx].timestamp)
- / 1000;
- hour = timestamp_sec / 3600;
- min = (timestamp_sec % 3600) / 60;
- sec = timestamp_sec % 60;
-
- sprintf(timestamp,
- "%"PRIu64":%02"PRIu8":%02"PRIu8,
- (uint64_t)hour, min, sec);
- printf("%-11s", timestamp);
- printf(" ");
} else {
printf(" ");
- uint64_t timestamp = (0x0000FFFFFFFFFFFF & le64_to_cpu(fw_act_history_entry->entry[entryIdx].timestamp));
-
printf("%16"PRIu64"", timestamp);
printf(" ");
}
@@ -5735,13 +5710,15 @@ static void wdc_print_fw_act_history_log_json(__u8 *data, int num_entries,
char new_fw[9];
char commit_action_bin[8];
char fail_str[32];
- char time_str[11];
+ char time_str[100];
char ext_time_str[20];
+ uint64_t timestamp;
+ __u64 timestamp_sec;
memset((void *)previous_fw, 0, 9);
memset((void *)new_fw, 0, 9);
memset((void *)commit_action_bin, 0, 8);
- memset((void *)time_str, 0, 11);
+ memset((void *)time_str, '\0', 100);
memset((void *)ext_time_str, 0, 20);
memset((void *)fail_str, 0, 11);
char *null_fw = "--------";
@@ -5781,33 +5758,25 @@ static void wdc_print_fw_act_history_log_json(__u8 *data, int num_entries,
json_object_add_value_int(root, "Entry",
le16_to_cpu(fw_act_history_entry->entry[entryIdx].fw_act_hist_entries));
+ timestamp = (0x0000FFFFFFFFFFFF &
+ le64_to_cpu(
+ fw_act_history_entry->entry[entryIdx].timestamp));
+ timestamp_sec = timestamp / 1000;
if (cust_id == WDC_CUSTOMER_ID_0x1005) {
- sprintf((char *)time_str, "%04d:%02d:%02d", (int)(le64_to_cpu(fw_act_history_entry->entry[entryIdx].timestamp)/3600),
- (int)((le64_to_cpu(fw_act_history_entry->entry[entryIdx].timestamp%3600)/60)),
- (int)(le64_to_cpu(fw_act_history_entry->entry[entryIdx].timestamp%60)));
+ sprintf((char *)time_str, "%"PRIu32":%u:%u",
+ (__u32)(timestamp_sec/3600),
+ (__u8)(timestamp_sec%3600/60),
+ (__u8)(timestamp_sec%60));
json_object_add_value_string(root, "Power on Hour", time_str);
} else if (vendor_id == WDC_NVME_SNDK_VID) {
- uint64_t timestamp = (0x0000FFFFFFFFFFFF & le64_to_cpu(fw_act_history_entry->entry[entryIdx].timestamp));
-
- sprintf((char *)time_str, "%04d:%02d:%02d", (int)((timestamp/(3600*1000))%24), (int)((timestamp/(1000*60))%60),
- (int)((timestamp/1000)%60));
+ sprintf((char *)time_str, "%"PRIu32":%u:%u",
+ (__u32)((timestamp_sec/3600)%24),
+ (__u8)((timestamp_sec/60)%60),
+ (__u8)(timestamp_sec%60));
json_object_add_value_string(root, "Power on Hour", time_str);
- } else if (wdc_is_sn861(device_id)) {
- __u64 timestamp_sec =
- le64_to_cpu(fw_act_history_entry->entry[entryIdx].timestamp)
- / 1000;
-
- sprintf((char *)ext_time_str,
- "%"PRIu64":%02"PRIu8":%02"PRIu8,
- (uint64_t)(__u64)(timestamp_sec/3600),
- (__u8)((timestamp_sec%3600)/60),
- (__u8)(timestamp_sec%60));
- json_object_add_value_string(root, "Power on Hour", ext_time_str);
} else {
- uint64_t timestamp = (0x0000FFFFFFFFFFFF & le64_to_cpu(fw_act_history_entry->entry[entryIdx].timestamp));
-
json_object_add_value_uint64(root, "Timestamp", timestamp);
}
@@ -7047,39 +7016,23 @@ static int wdc_get_c0_log_page(nvme_root_t r, struct nvme_dev *dev, char *format
switch (device_id) {
case WDC_NVME_SN640_DEV_ID:
- fallthrough;
case WDC_NVME_SN640_DEV_ID_1:
- fallthrough;
case WDC_NVME_SN640_DEV_ID_2:
- fallthrough;
case WDC_NVME_SN640_DEV_ID_3:
- fallthrough;
case WDC_NVME_SN840_DEV_ID:
- fallthrough;
case WDC_NVME_SN840_DEV_ID_1:
- 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:
- fallthrough;
case WDC_NVME_SN650_DEV_ID_2:
- fallthrough;
case WDC_NVME_SN650_DEV_ID_3:
- fallthrough;
case WDC_NVME_SN650_DEV_ID_4:
- fallthrough;
case WDC_NVME_SN655_DEV_ID:
if (uuid_index == 0) {
log_id = WDC_NVME_GET_SMART_CLOUD_ATTR_LOG_ID;
@@ -7137,9 +7090,7 @@ static int wdc_get_c0_log_page(nvme_root_t r, struct nvme_dev *dev, char *format
}
free(data);
break;
-
case WDC_NVME_ZN350_DEV_ID:
- fallthrough;
case WDC_NVME_ZN350_DEV_ID_1:
data = (__u8 *)malloc(sizeof(__u8) * WDC_NVME_SMART_CLOUD_ATTR_LEN);
if (!data) {
@@ -7405,17 +7356,11 @@ static int wdc_get_ca_log_page(nvme_root_t r, struct nvme_dev *dev, char *format
}
break;
case WDC_NVME_SN640_DEV_ID:
- fallthrough;
case WDC_NVME_SN640_DEV_ID_1:
- fallthrough;
case WDC_NVME_SN640_DEV_ID_2:
- fallthrough;
case WDC_NVME_SN640_DEV_ID_3:
- fallthrough;
case WDC_NVME_SN840_DEV_ID:
- fallthrough;
case WDC_NVME_SN840_DEV_ID_1:
- fallthrough;
case WDC_NVME_SN860_DEV_ID:
if (cust_id == WDC_CUSTOMER_ID_0x1005) {
data = (__u8 *)malloc(sizeof(__u8) * WDC_FB_CA_LOG_BUF_LEN);
@@ -9074,6 +9019,7 @@ static int wdc_get_fw_act_history_C2(nvme_root_t r, struct nvme_dev *dev,
enum nvme_print_flags fmt;
__u8 *data;
int ret;
+ bool c2GuidMatch = false;
if (!wdc_check_device(r, dev))
return -1;
@@ -9102,29 +9048,40 @@ static int wdc_get_fw_act_history_C2(nvme_root_t r, struct nvme_dev *dev,
nvme_show_status(ret);
if (!ret) {
- /* parse the data */
+ /* Get the log page data and verify the GUID */
fw_act_history_log = (struct wdc_fw_act_history_log_format_c2 *)(data);
- tot_entries = le32_to_cpu(fw_act_history_log->num_entries);
- if (tot_entries > 0) {
- /* get the FW customer id */
- if (!wdc_is_sn861(device_id)) {
- cust_id = wdc_get_fw_cust_id(r, dev);
- if (cust_id == WDC_INVALID_CUSTOMER_ID) {
- fprintf(stderr,
- "%s: ERROR: WDC: invalid customer id\n",
- __func__);
- ret = -1;
- goto freeData;
+ c2GuidMatch = !memcmp(ocp_C2_guid,
+ fw_act_history_log->log_page_guid,
+ WDC_C2_GUID_LENGTH);
+
+ if (c2GuidMatch) {
+ /* parse the data */
+ tot_entries = le32_to_cpu(fw_act_history_log->num_entries);
+
+ if (tot_entries > 0) {
+ /* get the FW customer id */
+ if (!wdc_is_sn861(device_id)) {
+ cust_id = wdc_get_fw_cust_id(r, dev);
+ if (cust_id == WDC_INVALID_CUSTOMER_ID) {
+ fprintf(stderr,
+ "%s: ERROR: WDC: invalid customer id\n",
+ __func__);
+ ret = -1;
+ goto freeData;
+ }
}
+ num_entries = (tot_entries < WDC_MAX_NUM_ACT_HIST_ENTRIES) ?
+ tot_entries : WDC_MAX_NUM_ACT_HIST_ENTRIES;
+ ret = wdc_print_fw_act_history_log(data, num_entries,
+ fmt, cust_id, vendor_id, device_id);
+ } else {
+ fprintf(stderr, "INFO: WDC: No entries found.\n");
+ ret = 0;
}
- num_entries = (tot_entries < WDC_MAX_NUM_ACT_HIST_ENTRIES) ? tot_entries :
- WDC_MAX_NUM_ACT_HIST_ENTRIES;
- ret = wdc_print_fw_act_history_log(data, num_entries,
- fmt, cust_id, vendor_id, device_id);
- } else {
- fprintf(stderr, "INFO: WDC: No FW Activate History entries found.\n");
- ret = 0;
+ } else {
+ fprintf(stderr, "ERROR: WDC: Invalid C2 log page GUID\n");
+ ret = -1;
}
} else {
fprintf(stderr, "ERROR: WDC: Unable to read FW Activate History Log Page data\n");
@@ -9143,7 +9100,7 @@ static int wdc_vs_fw_activate_history(int argc, char **argv, struct command *com
__u64 capabilities = 0;
struct nvme_dev *dev;
nvme_root_t r;
- int ret;
+ int ret = -1;
struct config {
char *output_format;
@@ -9171,61 +9128,23 @@ static int wdc_vs_fw_activate_history(int argc, char **argv, struct command *com
}
if (capabilities & WDC_DRIVE_CAP_FW_ACTIVATE_HISTORY) {
- int uuid_index = 0;
- bool c0GuidMatch = false;
- __u8 *data;
- int i;
-
- /*
- * check for the GUID in the 0xC0 log page to determine which log page to use to
- * retrieve fw activate history data
- */
- data = (__u8 *)malloc(sizeof(__u8) * WDC_NVME_SMART_CLOUD_ATTR_LEN);
- if (!data) {
- fprintf(stderr, "ERROR: WDC: malloc: %s\n", strerror(errno));
+ __u32 cust_fw_id = 0;
+ /* get the FW customer id */
+ cust_fw_id = wdc_get_fw_cust_id(r, dev);
+ if (cust_fw_id == WDC_INVALID_CUSTOMER_ID) {
+ fprintf(stderr, "%s: ERROR: WDC: invalid customer id\n", __func__);
ret = -1;
goto out;
}
- /* Get the 0xC0 log data */
- struct nvme_get_log_args args = {
- .args_size = sizeof(args),
- .fd = dev_fd(dev),
- .lid = WDC_NVME_GET_SMART_CLOUD_ATTR_LOG_ID,
- .nsid = 0xFFFFFFFF,
- .lpo = 0,
- .lsp = NVME_LOG_LSP_NONE,
- .lsi = 0,
- .rae = false,
- .uuidx = uuid_index,
- .csi = NVME_CSI_NVM,
- .ot = false,
- .len = WDC_NVME_SMART_CLOUD_ATTR_LEN,
- .log = data,
- .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
- .result = NULL,
- };
- ret = nvme_get_log(&args);
-
- if (!ret) {
- /* Verify GUID matches */
- for (i = 0; i < 16; i++) {
- if (scao_guid[i] != data[SCAO_LPG + i]) {
- c0GuidMatch = false;
- break;
- }
- }
-
- if (i == 16)
- c0GuidMatch = true;
- }
-
- free(data);
- if (c0GuidMatch)
+ if ((cust_fw_id == WDC_CUSTOMER_ID_0x1004) ||
+ (cust_fw_id == WDC_CUSTOMER_ID_0x1008) ||
+ (cust_fw_id == WDC_CUSTOMER_ID_0x1005) ||
+ (cust_fw_id == WDC_CUSTOMER_ID_0x1304))
ret = wdc_get_fw_act_history_C2(r, dev, cfg.output_format);
else
ret = wdc_get_fw_act_history(r, dev, cfg.output_format);
- } else {
+ } else if (capabilities & WDC_DRIVE_CAP_FW_ACTIVATE_HISTORY_C2) {
ret = wdc_get_fw_act_history_C2(r, dev, cfg.output_format);
}
@@ -9648,10 +9567,10 @@ static int wdc_fetch_log_file_from_device(struct nvme_dev *dev, __u32 fileId,
__u16 spiDestn, __u64 fileSize, __u8 *dataBuffer)
{
int ret = WDC_STATUS_FAILURE;
- __u32 chunckSize = WDC_DE_VU_READ_BUFFER_STANDARD_OFFSET;
- __u32 maximumTransferLength = 0;
- __u32 buffSize = 0;
- __u64 offsetIdx = 0;
+ __u32 chunckSize = WDC_DE_VU_READ_BUFFER_STANDARD_OFFSET;
+ __u32 maximumTransferLength = 0;
+ __u32 buffSize = 0;
+ __u64 offsetIdx = 0;
if (!dev || !dataBuffer || !fileSize) {
ret = WDC_STATUS_INVALID_PARAMETER;
@@ -9699,18 +9618,17 @@ end:
static int wdc_de_get_dump_trace(struct nvme_dev *dev, char *filePath, __u16 binFileNameLen, char *binFileName)
{
- int ret = WDC_STATUS_FAILURE;
- __u8 *readBuffer = NULL;
- __u32 readBufferLen = 0;
- __u32 lastPktReadBufferLen = 0;
- __u32 maxTransferLen = 0;
- __u32 dumptraceSize = 0;
- __u32 chunkSize = 0;
- __u32 chunks = 0;
- __u32 offset = 0;
- __u8 loop = 0;
- __u16 i = 0;
- __u32 maximumTransferLength = 0;
+ int ret = WDC_STATUS_FAILURE;
+ __u8 *readBuffer = NULL;
+ __u32 readBufferLen = 0;
+ __u32 lastPktReadBufferLen = 0;
+ __u32 maxTransferLen = 0;
+ __u32 dumptraceSize = 0;
+ __u32 chunkSize;
+ __u32 chunks;
+ __u32 offset;
+ __u32 i;
+ __u32 maximumTransferLength = 0;
if (!dev || !binFileName || !filePath) {
ret = WDC_STATUS_INVALID_PARAMETER;
@@ -9759,7 +9677,7 @@ static int wdc_de_get_dump_trace(struct nvme_dev *dev, char *filePath, __u16 bin
}
for (i = 0; i < chunks; i++) {
- offset = ((i*chunkSize) / 4);
+ offset = (i * chunkSize) / 4;
/* Last loop call, Assign readBufferLen to read only left over bytes */
if (i == (chunks - 1))
@@ -9774,7 +9692,7 @@ static int wdc_de_get_dump_trace(struct nvme_dev *dev, char *filePath, __u16 bin
break;
}
}
- } while (loop);
+ } while (0);
if (ret == WDC_STATUS_SUCCESS) {
ret = wdc_WriteToFile(binFileName, (char *)readBuffer, dumptraceSize);
@@ -11678,7 +11596,6 @@ static int wdc_vs_drive_info(int argc, char **argv,
break;
case WDC_NVME_SN861_DEV_ID:
- fallthrough;
case WDC_NVME_SN861_DEV_ID_1:
data_len = sizeof(info);
num_dwords = data_len / 4;