From 749efe961f0e1a71461a9c79e6e4584d35af6e7f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 19 Feb 2024 11:45:34 +0100 Subject: Adding upstream version 2.8. Signed-off-by: Daniel Baumann --- plugins/wdc/wdc-nvme.c | 147 +++++++++++++++++++++++++++++++++++++++--------- plugins/wdc/wdc-nvme.h | 2 +- plugins/wdc/wdc-utils.c | 12 +--- 3 files changed, 121 insertions(+), 40 deletions(-) (limited to 'plugins/wdc') diff --git a/plugins/wdc/wdc-nvme.c b/plugins/wdc/wdc-nvme.c index d663131..8cbcf2e 100644 --- a/plugins/wdc/wdc-nvme.c +++ b/plugins/wdc/wdc-nvme.c @@ -94,10 +94,40 @@ #define WDC_NVME_SN520_DEV_ID 0x5003 #define WDC_NVME_SN520_DEV_ID_1 0x5004 #define WDC_NVME_SN520_DEV_ID_2 0x5005 -#define WDC_NVME_SN530_DEV_ID 0x5009 -#define WDC_NVME_SN530_DEV_ID_1 0x501d + +#define WDC_NVME_SN530_DEV_ID_1 0x5007 +#define WDC_NVME_SN530_DEV_ID_2 0x5008 +#define WDC_NVME_SN530_DEV_ID_3 0x5009 +#define WDC_NVME_SN530_DEV_ID_4 0x500b +#define WDC_NVME_SN530_DEV_ID_5 0x501d + +#define WDC_NVME_SN350_DEV_ID 0x5019 + +#define WDC_NVME_SN570_DEV_ID 0x501A + +#define WDC_NVME_SN850X_DEV_ID 0x5030 + +#define WDC_NVME_SN5000_DEV_ID_1 0x5034 +#define WDC_NVME_SN5000_DEV_ID_2 0x5035 +#define WDC_NVME_SN5000_DEV_ID_3 0x5036 +#define WDC_NVME_SN5000_DEV_ID_4 0x504A + +#define WDC_NVME_SN7000S_DEV_ID_1 0x5039 + +#define WDC_NVME_SN7150_DEV_ID_1 0x503b +#define WDC_NVME_SN7150_DEV_ID_2 0x503c +#define WDC_NVME_SN7150_DEV_ID_3 0x503d +#define WDC_NVME_SN7150_DEV_ID_4 0x503e +#define WDC_NVME_SN7150_DEV_ID_5 0x503f + +#define WDC_NVME_SN7100_DEV_ID_1 0x5043 +#define WDC_NVME_SN7100_DEV_ID_2 0x5044 +#define WDC_NVME_SN7100_DEV_ID_3 0x5045 + +#define WDC_NVME_SN8000S_DEV_ID 0x5049 + #define WDC_NVME_SN720_DEV_ID 0x5002 -#define WDC_NVME_SN730A_DEV_ID 0x5006 +#define WDC_NVME_SN730_DEV_ID 0x5006 #define WDC_NVME_SN740_DEV_ID 0x5015 #define WDC_NVME_SN740_DEV_ID_1 0x5016 #define WDC_NVME_SN740_DEV_ID_2 0x5017 @@ -989,7 +1019,7 @@ struct wdc_e6_log_hdr { /* DUI log header */ struct wdc_dui_log_section { __le16 section_type; - __le16 data_area_id; + __le16 reserved; __le32 section_size; }; @@ -1671,6 +1701,7 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, struct nvme_dev *dev) WDC_DRIVE_CAP_DRIVE_LOG | WDC_DRIVE_CAP_CRASH_DUMP | WDC_DRIVE_CAP_PFAIL_DUMP | WDC_DRIVE_CAP_PURGE); break; + case WDC_NVME_SN200_DEV_ID: capabilities = (WDC_DRIVE_CAP_CAP_DIAG | WDC_DRIVE_CAP_INTERNAL_LOG | WDC_DRIVE_CAP_CLEAR_PCIE | WDC_DRIVE_CAP_DRIVE_LOG | WDC_DRIVE_CAP_CRASH_DUMP | WDC_DRIVE_CAP_PFAIL_DUMP | @@ -1686,10 +1717,12 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, struct nvme_dev *dev) WDC_NVME_ADD_LOG_OPCODE)) capabilities |= WDC_DRIVE_CAP_C1_LOG_PAGE; break; + default: capabilities = 0; } break; + case WDC_NVME_VID_2: switch (read_device_id) { case WDC_NVME_SN630_DEV_ID: @@ -1708,6 +1741,7 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, struct nvme_dev *dev) WDC_NVME_GET_VU_SMART_LOG_OPCODE)) capabilities |= WDC_DRIVE_CAP_D0_LOG_PAGE; break; + case WDC_NVME_SN640_DEV_ID: fallthrough; case WDC_NVME_SN640_DEV_ID_1: @@ -1780,6 +1814,7 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, struct nvme_dev *dev) capabilities |= (WDC_DRIVE_CAP_CLEAR_FW_ACT_HISTORY | WDC_DRIVE_CAP_CLEAR_PCIE); break; + case WDC_NVME_SN840_DEV_ID: fallthrough; case WDC_NVME_SN840_DEV_ID_1: @@ -1810,6 +1845,7 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, struct nvme_dev *dev) WDC_NVME_GET_VU_SMART_LOG_OPCODE)) capabilities |= WDC_DRIVE_CAP_D0_LOG_PAGE; break; + case WDC_NVME_SN650_DEV_ID: fallthrough; case WDC_NVME_SN650_DEV_ID_1: @@ -1869,6 +1905,7 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, struct nvme_dev *dev) WDC_DRIVE_CAP_CLEAR_PCIE); break; + case WDC_NVME_SN861_DEV_ID: fallthrough; case WDC_NVME_SN861_DEV_ID_1: @@ -1886,28 +1923,28 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, struct nvme_dev *dev) WDC_DRIVE_CAP_LOG_PAGE_DIR | WDC_DRIVE_CAP_SET_LATENCY_MONITOR); break; + default: capabilities = 0; } break; + case WDC_NVME_SNDK_VID: switch (read_device_id) { case WDC_NVME_SXSLCL_DEV_ID: capabilities = WDC_DRIVE_CAP_DRIVE_ESSENTIALS; 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_SN530_DEV_ID: - fallthrough; - case WDC_NVME_SN530_DEV_ID_1: - fallthrough; case WDC_NVME_SN810_DEV_ID: capabilities = WDC_DRIVE_CAP_DUI_DATA; break; + case WDC_NVME_SN820CL_DEV_ID: capabilities = WDC_DRIVE_CAP_DUI_DATA | WDC_DRIVE_CAP_CLOUD_BOOT_SSD_VERSION | @@ -1916,15 +1953,62 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, struct nvme_dev *dev) WDC_DRIVE_CAP_VU_FID_CLEAR_PCIE | WDC_DRIVE_CAP_NAND_STATS | WDC_DRIVE_CAP_DEVICE_WAF | WDC_DRIVE_CAP_TEMP_STATS; break; + case WDC_NVME_SN720_DEV_ID: capabilities = WDC_DRIVE_CAP_DUI_DATA | WDC_DRIVE_CAP_NAND_STATS | WDC_DRIVE_CAP_NS_RESIZE; break; - case WDC_NVME_SN730A_DEV_ID: + + case WDC_NVME_SN730_DEV_ID: capabilities = WDC_DRIVE_CAP_DUI | WDC_DRIVE_CAP_NAND_STATS | WDC_DRIVE_CAP_INFO | WDC_DRIVE_CAP_TEMP_STATS | WDC_DRIVE_CAP_VUC_CLEAR_PCIE | WDC_DRIVE_CAP_PCIE_STATS; break; + + case WDC_NVME_SN530_DEV_ID_1: + fallthrough; + case WDC_NVME_SN530_DEV_ID_2: + fallthrough; + case WDC_NVME_SN530_DEV_ID_3: + fallthrough; + case WDC_NVME_SN530_DEV_ID_4: + fallthrough; + case WDC_NVME_SN530_DEV_ID_5: + fallthrough; + case WDC_NVME_SN350_DEV_ID: + fallthrough; + case WDC_NVME_SN570_DEV_ID: + fallthrough; + case WDC_NVME_SN850X_DEV_ID: + fallthrough; + case WDC_NVME_SN5000_DEV_ID_1: + fallthrough; + case WDC_NVME_SN5000_DEV_ID_2: + fallthrough; + case WDC_NVME_SN5000_DEV_ID_3: + fallthrough; + case WDC_NVME_SN5000_DEV_ID_4: + fallthrough; + case WDC_NVME_SN7000S_DEV_ID_1: + fallthrough; + case WDC_NVME_SN7150_DEV_ID_1: + fallthrough; + case WDC_NVME_SN7150_DEV_ID_2: + fallthrough; + case WDC_NVME_SN7150_DEV_ID_3: + fallthrough; + case WDC_NVME_SN7150_DEV_ID_4: + fallthrough; + case WDC_NVME_SN7150_DEV_ID_5: + fallthrough; + case WDC_NVME_SN7100_DEV_ID_1: + fallthrough; + case WDC_NVME_SN7100_DEV_ID_2: + fallthrough; + case WDC_NVME_SN7100_DEV_ID_3: + fallthrough; + case WDC_NVME_SN8000S_DEV_ID: + fallthrough; case WDC_NVME_SN740_DEV_ID: fallthrough; case WDC_NVME_SN740_DEV_ID_1: @@ -1936,6 +2020,7 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, struct nvme_dev *dev) 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: @@ -1945,6 +2030,7 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, struct nvme_dev *dev) WDC_DRIVE_CAP_FW_ACTIVATE_HISTORY_C2 | WDC_DRIVE_CAP_INFO | WDC_DRIVE_CAP_CLOUD_SSD_VERSION | WDC_DRIVE_CAP_LOG_PAGE_DIR; break; + default: capabilities = 0; } @@ -2632,6 +2718,16 @@ static int wdc_do_dump_e6(int fd, __u32 opcode, __u32 data_len, int i; struct nvme_passthru_cmd admin_cmd; + /* if data_len is not 4 byte aligned */ + if (data_len & 0x00000003) { + /* Round down to the next 4 byte aligned value */ + fprintf(stderr, "%s: INFO: data_len 0x%x not 4 byte aligned.\n", + __func__, data_len); + fprintf(stderr, "%s: INFO: Round down to 0x%x.\n", + __func__, (data_len &= 0xFFFFFFFC)); + data_len &= 0xFFFFFFFC; + } + dump_data = (__u8 *)malloc(sizeof(__u8) * data_len); if (!dump_data) { @@ -2649,7 +2745,8 @@ static int wdc_do_dump_e6(int fd, __u32 opcode, __u32 data_len, admin_cmd.opcode = opcode; admin_cmd.cdw12 = cdw12; - log_size = data_len; + /* subtract off the header size since that was already copied into the buffer */ + log_size = (data_len - curr_data_offset); while (log_size > 0) { xfer_size = min(xfer_size, log_size); @@ -2890,6 +2987,8 @@ static int wdc_do_cap_dui_v1(int fd, char *file, __u32 xfer_size, int data_area, fprintf(stderr, "INFO: WDC: Capture V1 Device Unit Info log, data area = %d\n", data_area); fprintf(stderr, "INFO: WDC: DUI Header Version = 0x%x\n", log_hdr->hdr_version); + fprintf(stderr, "INFO: WDC: DUI section count = 0x%x\n", log_hdr->section_count); + fprintf(stderr, "INFO: WDC: DUI log size = 0x%x\n", log_hdr->log_size); } if (!cap_dui_length) { @@ -2899,23 +2998,15 @@ static int wdc_do_cap_dui_v1(int fd, char *file, __u32 xfer_size, int data_area, /* parse log header for all sections up to specified data area inclusively */ if (data_area != WDC_NVME_DUI_MAX_DATA_AREA) { - for (j = 0; j < WDC_NVME_DUI_MAX_SECTION; j++) { - if (log_hdr->log_section[j].data_area_id <= data_area && - log_hdr->log_section[j].data_area_id) { - log_size += log_hdr->log_section[j].section_size; - if (verbose) - fprintf(stderr, - "%s: Data area ID %d : section size 0x%x, total size = 0x%x\n", - __func__, log_hdr->log_section[j].data_area_id, - (unsigned int)log_hdr->log_section[j].section_size, - (unsigned int)log_size); + for (j = 0; j < log_hdr->section_count; j++) { + log_size += log_hdr->log_section[j].section_size; + if (verbose) + fprintf(stderr, + "%s: section size 0x%x, total size = 0x%x\n", + __func__, + (unsigned int)log_hdr->log_section[j].section_size, + (unsigned int)log_size); - } else { - if (verbose) - fprintf(stderr, "%s: break, total size = 0x%x\n", __func__, - (unsigned int)log_size); - break; - } } } else { log_size = cap_dui_length; @@ -8112,7 +8203,7 @@ static int wdc_vs_smart_add_log(int argc, char **argv, struct command *command, struct ocp_cloud_smart_log log; char buf[2 * sizeof(log.log_page_guid) + 3]; - ret = validate_output_format(output_format, &fmt); + ret = validate_output_format(cfg.output_format, &fmt); if (ret < 0) { fprintf(stderr, "Invalid output format: %s\n", cfg.output_format); goto out; @@ -11496,7 +11587,7 @@ static int wdc_vs_drive_info(int argc, char **argv, } } break; - case WDC_NVME_SN730A_DEV_ID: + case WDC_NVME_SN730_DEV_ID: memcpy(vsData, &ctrl.vs[0], 32); major_rev = ctrl.sn[12]; diff --git a/plugins/wdc/wdc-nvme.h b/plugins/wdc/wdc-nvme.h index f3f28a7..d3692bc 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.3.5" +#define WDC_PLUGIN_VERSION "2.7.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 be2ef06..414a06a 100644 --- a/plugins/wdc/wdc-utils.c +++ b/plugins/wdc/wdc-utils.c @@ -192,15 +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) { - int i; - - for (i = 0; i < 16; i++) { - if (entry1->uuid[i] != entry2->uuid[i]) - break; - } - - if (i == 16) - return true; - else - return false; + return !memcmp(entry1, entry2, NVME_UUID_LEN); } -- cgit v1.2.3