Skip to content

Commit 5479ae7

Browse files
sndk: Add support for the Sandisk UUID
This change will check for the Sandisk UUID first and fallback to the WDC UUID if the Sandisk UUID is not found. Signed-off-by: jeff-lien-sndk <[email protected]>
1 parent 37f0290 commit 5479ae7

3 files changed

Lines changed: 55 additions & 15 deletions

File tree

plugins/sandisk/sandisk-nvme.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#if !defined(SANDISK_NVME) || defined(CMD_HEADER_MULTI_READ)
66
#define SANDISK_NVME
77

8-
#define SANDISK_PLUGIN_VERSION "3.0.2"
8+
#define SANDISK_PLUGIN_VERSION "3.0.3"
99
#include "cmd.h"
1010

1111
PLUGIN(NAME("sndk", "Sandisk vendor specific extensions", SANDISK_PLUGIN_VERSION),

plugins/wdc/wdc-nvme.c

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -532,13 +532,18 @@ static const __u8 WDC_UUID[NVME_UUID_LEN] = {
532532
0xab, 0xe6, 0x33, 0x29, 0x9a, 0x70, 0xdf, 0xd0
533533
};
534534

535-
536535
/* WDC_UUID value for SN640_3 devices */
537536
static const __u8 WDC_UUID_SN640_3[NVME_UUID_LEN] = {
538537
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
539538
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22
540539
};
541540

541+
/* Sandisk UUID value */
542+
static const __u8 SNDK_UUID[NVME_UUID_LEN] = {
543+
0xde, 0x87, 0xd1, 0xeb, 0x72, 0xc5, 0x58, 0x0b,
544+
0xad, 0xd8, 0x3c, 0x29, 0xd1, 0x23, 0x7c, 0x70
545+
};
546+
542547
enum WDC_DRIVE_ESSENTIAL_TYPE {
543548
WDC_DE_TYPE_IDENTIFY = 0x1,
544549
WDC_DE_TYPE_SMARTATTRIBUTEDUMP = 0x2,
@@ -2693,13 +2698,23 @@ static bool get_dev_mgment_data(nvme_root_t r, struct nvme_dev *dev,
26932698

26942699
memset(&uuid_list, 0, sizeof(struct nvme_id_uuid_list));
26952700
if (wdc_CheckUuidListSupport(dev, &uuid_list)) {
2696-
uuid_index = nvme_uuid_find(&uuid_list, WDC_UUID);
2697-
if (uuid_index < 0 &&
2698-
(wdc_is_sn640_3(device_id) || wdc_is_sn655(device_id)))
2699-
uuid_index = nvme_uuid_find(&uuid_list, WDC_UUID_SN640_3);
2701+
/* check for the Sandisk UUID first */
2702+
uuid_index = nvme_uuid_find(&uuid_list, SNDK_UUID);
2703+
2704+
if (uuid_index < 0) {
2705+
/* The Sandisk UUID is not found;
2706+
* check for the WDC UUID second.
2707+
*/
2708+
uuid_index = nvme_uuid_find(&uuid_list, WDC_UUID);
2709+
if (uuid_index < 0 &&
2710+
(wdc_is_sn640_3(device_id) || wdc_is_sn655(device_id)))
2711+
uuid_index = nvme_uuid_find(&uuid_list, WDC_UUID_SN640_3);
2712+
}
27002713

27012714
if (uuid_index >= 0)
27022715
found = get_dev_mgmt_log_page_data(dev, data, uuid_index);
2716+
else
2717+
fprintf(stderr, "UUID lists are supported but a matching uuid was not found\n");
27032718
} else if (needs_c2_log_page_check(device_id)) {
27042719
/* In certain devices that don't support UUID lists, there are multiple
27052720
* definitions of the C2 logpage. In those cases, the code
@@ -2750,15 +2765,24 @@ static bool get_dev_mgment_cbs_data(nvme_root_t r, struct nvme_dev *dev,
27502765

27512766
memset(&uuid_list, 0, sizeof(struct nvme_id_uuid_list));
27522767
if (wdc_CheckUuidListSupport(dev, &uuid_list)) {
2753-
uuid_index = nvme_uuid_find(&uuid_list, WDC_UUID);
2754-
if (uuid_index < 0 &&
2755-
(wdc_is_sn640_3(device_id) || wdc_is_sn655(device_id))) {
2756-
uuid_index = nvme_uuid_find(&uuid_list, WDC_UUID_SN640_3);
2768+
/* check for the Sandisk UUID first */
2769+
uuid_index = nvme_uuid_find(&uuid_list, SNDK_UUID);
2770+
2771+
if (uuid_index < 0) {
2772+
/* The Sandisk UUID is not found;
2773+
* check for the WDC UUID second.
2774+
*/
2775+
uuid_index = nvme_uuid_find(&uuid_list, WDC_UUID);
2776+
if (uuid_index < 0 &&
2777+
(wdc_is_sn640_3(device_id) || wdc_is_sn655(device_id)))
2778+
uuid_index = nvme_uuid_find(&uuid_list, WDC_UUID_SN640_3);
27572779
}
27582780

27592781
if (uuid_index >= 0)
27602782
found = get_dev_mgmt_log_page_lid_data(dev, cbs_data, lid,
27612783
log_id, uuid_index);
2784+
else
2785+
fprintf(stderr, "UUID lists are supported but a matching uuid was not found\n");
27622786
} else if (needs_c2_log_page_check(device_id)) {
27632787
/* In certain devices that don't support UUID lists, there are multiple
27642788
* definitions of the C2 logpage. In those cases, the code
@@ -9109,8 +9133,16 @@ static int wdc_drive_status(int argc, char **argv, struct command *command,
91099133

91109134
/* Find the WDC UUID index */
91119135
memset(&uuid_list, 0, sizeof(struct nvme_id_uuid_list));
9112-
if (wdc_CheckUuidListSupport(dev, &uuid_list))
9113-
uuid_index = nvme_uuid_find(&uuid_list, WDC_UUID);
9136+
if (wdc_CheckUuidListSupport(dev, &uuid_list)) {
9137+
/* check for the Sandisk UUID first */
9138+
uuid_index = nvme_uuid_find(&uuid_list, SNDK_UUID);
9139+
9140+
if (uuid_index < 0)
9141+
/* The Sandisk UUID is not found;
9142+
* check for the WDC UUID second.
9143+
*/
9144+
uuid_index = nvme_uuid_find(&uuid_list, WDC_UUID);
9145+
}
91149146

91159147
/* WD UUID not found, use default uuid index - 0 */
91169148
if (uuid_index < 0)
@@ -10895,8 +10927,16 @@ static int wdc_log_page_directory(int argc, char **argv, struct command *command
1089510927
WDC_NVME_GET_DEV_MGMNT_LOG_PAGE_ID;
1089610928

1089710929
if (!wdc_is_sn861(device_id)) {
10898-
if (uuid_supported)
10899-
uuid_index = nvme_uuid_find(&uuid_list, WDC_UUID);
10930+
if (uuid_supported) {
10931+
/* check for the Sandisk UUID first */
10932+
uuid_index = nvme_uuid_find(&uuid_list, SNDK_UUID);
10933+
10934+
if (uuid_index < 0)
10935+
/* The Sandisk UUID is not found;
10936+
* check for the WDC UUID second.
10937+
*/
10938+
uuid_index = nvme_uuid_find(&uuid_list, WDC_UUID);
10939+
}
1090010940

1090110941
/* WD UUID not found, use default uuid index - 0 */
1090210942
if (uuid_index < 0)

plugins/wdc/wdc-nvme.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#if !defined(WDC_NVME) || defined(CMD_HEADER_MULTI_READ)
66
#define WDC_NVME
77

8-
#define WDC_PLUGIN_VERSION "2.14.4"
8+
#define WDC_PLUGIN_VERSION "2.14.5"
99
#include "cmd.h"
1010

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

0 commit comments

Comments
 (0)