Skip to content

Commit cfc2a93

Browse files
jeff-lien-sndkigaw
authored andcommitted
wdc: Fix SN861 capabilities in NVME-OF cases
In NVMe over Fabric cases, the pci device id is not available to use for identifying a drive. Therefore, other fields from the Wd C2 log page are used instead. Signed-off-by: jeff-lien-sndk <[email protected]> Reviewed-by: brandon-paupore-sndk <[email protected]>
1 parent 494cb3a commit cfc2a93

2 files changed

Lines changed: 115 additions & 23 deletions

File tree

plugins/wdc/wdc-nvme.c

Lines changed: 114 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,9 @@
227227
#define WDC_CUSTOMER_ID_GD 0x0101
228228
#define WDC_CUSTOMER_ID_BD 0x1009
229229

230-
#define WDC_CUSTOMER_ID_0x1005 0x1005
231-
230+
#define WDC_CUSTOMER_ID_0x00F0 0x00F0
232231
#define WDC_CUSTOMER_ID_0x1004 0x1004
232+
#define WDC_CUSTOMER_ID_0x1005 0x1005
233233
#define WDC_CUSTOMER_ID_0x1008 0x1008
234234
#define WDC_CUSTOMER_ID_0x1304 0x1304
235235
#define WDC_INVALID_CUSTOMER_ID -1
@@ -351,13 +351,14 @@
351351
#define WDC_NVME_GET_DEV_MGMNT_LOG_PAGE_ID 0xC2
352352
#define WDC_NVME_GET_DEV_MGMNT_LOG_PAGE_ID_C8 0xC8
353353
#define WDC_C2_LOG_BUF_LEN 0x1000
354+
#define WDC_C2_MARKETING_NAME_ID 0x07
354355
#define WDC_C2_LOG_PAGES_SUPPORTED_ID 0x08
355-
#define WDC_C2_CUSTOMER_ID_ID 0x15
356+
#define WDC_C2_CUSTOMER_ID_ID 0x15
356357
#define WDC_C2_THERMAL_THROTTLE_STATUS_ID 0x18
357358
#define WDC_C2_ASSERT_DUMP_PRESENT_ID 0x19
358-
#define WDC_C2_USER_EOL_STATUS_ID 0x1A
359-
#define WDC_C2_USER_EOL_STATE_ID 0x1C
360-
#define WDC_C2_SYSTEM_EOL_STATE_ID 0x1D
359+
#define WDC_C2_USER_EOL_STATUS_ID 0x1A
360+
#define WDC_C2_USER_EOL_STATE_ID 0x1C
361+
#define WDC_C2_SYSTEM_EOL_STATE_ID 0x1D
361362
#define WDC_C2_FORMAT_CORRUPT_REASON_ID 0x1E
362363
#define WDC_EOL_STATUS_NORMAL cpu_to_le32(0x00000000)
363364
#define WDC_EOL_STATUS_END_OF_LIFE cpu_to_le32(0x00000001)
@@ -370,6 +371,8 @@
370371
#define WDC_FORMAT_NOT_CORRUPT cpu_to_le32(0x00000000)
371372
#define WDC_FORMAT_CORRUPT_FW_ASSERT cpu_to_le32(0x00000001)
372373
#define WDC_FORMAT_CORRUPT_UNKNOWN cpu_to_le32(0x000000FF)
374+
#define WDC_SN861_MARKETING_NAME_1 "Ultrastar DC SN861"
375+
#define WDC_SN861_MARKETING_NAME_2 "ULTRASTAR DC SN861"
373376

374377
/* CA Log Page */
375378
#define WDC_NVME_GET_DEVICE_INFO_LOG_OPCODE 0xCA
@@ -987,6 +990,16 @@ static int wdc_print_c0_eol_log(void *data, int fmt);
987990
static void wdc_show_cloud_smart_log_normal(struct ocp_cloud_smart_log *log,
988991
struct nvme_dev *dev);
989992
static void wdc_show_cloud_smart_log_json(struct ocp_cloud_smart_log *log);
993+
static bool get_dev_mgment_data(nvme_root_t r,
994+
struct nvme_dev *dev,
995+
void **data);
996+
static bool wdc_nvme_parse_dev_status_log_entry(void *log_data,
997+
__u32 *ret_data,
998+
__u32 entry_id);
999+
static bool wdc_nvme_parse_dev_status_log_str(void *log_data,
1000+
__u32 entry_id,
1001+
char *ret_data,
1002+
__u32 *ret_data_len);
9901003

9911004
/* Drive log data size */
9921005
struct wdc_log_size {
@@ -2059,7 +2072,13 @@ static __u64 wdc_get_enc_drive_capabilities(nvme_root_t r,
20592072
int ret;
20602073
uint32_t read_vendor_id;
20612074
__u64 capabilities = 0;
2062-
__u32 cust_id;
2075+
__u32 cust_id, market_name_len;
2076+
char marketing_name[64];
2077+
void *dev_mng_log = NULL;
2078+
int uuid_index = 0;
2079+
struct nvme_id_uuid_list uuid_list;
2080+
2081+
memset(marketing_name, 0, 64);
20632082

20642083
ret = wdc_get_vendor_id(dev, &read_vendor_id);
20652084
if (ret < 0)
@@ -2085,16 +2104,56 @@ static __u64 wdc_get_enc_drive_capabilities(nvme_root_t r,
20852104
WDC_DRIVE_CAP_DRIVE_STATUS | WDC_DRIVE_CAP_CLEAR_ASSERT |
20862105
WDC_DRIVE_CAP_RESIZE);
20872106

2107+
/* Find the WDC UUID index */
2108+
memset(&uuid_list, 0, sizeof(struct nvme_id_uuid_list));
2109+
if (wdc_CheckUuidListSupport(dev, &uuid_list)) {
2110+
/* check for the Sandisk UUID first */
2111+
uuid_index = nvme_uuid_find(&uuid_list, SNDK_UUID);
2112+
2113+
if (uuid_index < 0)
2114+
/* The Sandisk UUID is not found;
2115+
* check for the WDC UUID second.
2116+
*/
2117+
uuid_index = nvme_uuid_find(&uuid_list, WDC_UUID);
2118+
}
2119+
2120+
/* WD UUID not found, use default uuid index - 0 */
2121+
if (uuid_index < 0)
2122+
uuid_index = 0;
2123+
2124+
/* verify the 0xC2 Device Manageability log page is supported */
2125+
if (wdc_nvme_check_supported_log_page(r, dev,
2126+
WDC_NVME_GET_DEV_MGMNT_LOG_PAGE_ID,
2127+
uuid_index) == false) {
2128+
fprintf(stderr, "ERROR: SNDK: 0xC2 Log Page not supported, index: %d\n",
2129+
uuid_index);
2130+
ret = -1;
2131+
goto out;
2132+
}
2133+
2134+
if (!get_dev_mgment_data(r, dev, &dev_mng_log)) {
2135+
fprintf(stderr, "ERROR: SNDK: 0xC2 Log Page not found\n");
2136+
ret = -1;
2137+
goto out;
2138+
}
2139+
2140+
/* Get the customer ID and marketing name from WD C2 log page */
2141+
if (!wdc_nvme_parse_dev_status_log_entry(dev_mng_log,
2142+
&cust_id,
2143+
WDC_C2_CUSTOMER_ID_ID))
2144+
fprintf(stderr, "ERROR: SNDK: Get Customer FW ID Failed\n");
2145+
2146+
if (!wdc_nvme_parse_dev_status_log_str(dev_mng_log,
2147+
WDC_C2_MARKETING_NAME_ID,
2148+
(char *)marketing_name,
2149+
&market_name_len))
2150+
fprintf(stderr, "ERROR: SNDK: Get Marketing Name Failed\n");
2151+
20882152
/* verify the 0xC3 log page is supported */
20892153
if (wdc_nvme_check_supported_log_page(r, dev,
20902154
WDC_LATENCY_MON_LOG_ID, 0) == true)
20912155
capabilities |= WDC_DRIVE_CAP_C3_LOG_PAGE;
20922156

2093-
/* verify the 0xCB log page is supported */
2094-
if (wdc_nvme_check_supported_log_page(r, dev,
2095-
WDC_NVME_GET_FW_ACT_HISTORY_LOG_ID, 0) == true)
2096-
capabilities |= WDC_DRIVE_CAP_FW_ACTIVATE_HISTORY;
2097-
20982157
/* verify the 0xCA log page is supported */
20992158
if (wdc_nvme_check_supported_log_page(r, dev,
21002159
WDC_NVME_GET_DEVICE_INFO_LOG_OPCODE, 0) == true)
@@ -2105,17 +2164,25 @@ static __u64 wdc_get_enc_drive_capabilities(nvme_root_t r,
21052164
WDC_NVME_GET_VU_SMART_LOG_OPCODE, 0) == true)
21062165
capabilities |= WDC_DRIVE_CAP_D0_LOG_PAGE;
21072166

2108-
cust_id = wdc_get_fw_cust_id(r, dev);
2109-
if (cust_id == WDC_INVALID_CUSTOMER_ID) {
2110-
fprintf(stderr, "%s: ERROR: WDC: invalid customer id\n", __func__);
2111-
return -1;
2112-
}
2167+
if ((cust_id == WDC_CUSTOMER_ID_0x1004) ||
2168+
(cust_id == WDC_CUSTOMER_ID_0x1008) ||
2169+
(cust_id == WDC_CUSTOMER_ID_0x1005) ||
2170+
(cust_id == WDC_CUSTOMER_ID_0x1304) ||
2171+
(!strncmp(marketing_name, WDC_SN861_MARKETING_NAME_1, market_name_len)) ||
2172+
(!strncmp(marketing_name, WDC_SN861_MARKETING_NAME_2, market_name_len)))
2173+
/* Set capabilities for OCP compliant drives */
2174+
capabilities |= (WDC_DRIVE_CAP_FW_ACTIVATE_HISTORY_C2 |
2175+
WDC_DRIVE_CAP_VU_FID_CLEAR_FW_ACT_HISTORY |
2176+
WDC_DRIVE_CAP_VU_FID_CLEAR_PCIE);
2177+
else {
2178+
capabilities |= (WDC_DRIVE_CAP_CLEAR_FW_ACT_HISTORY |
2179+
WDC_DRIVE_CAP_CLEAR_PCIE);
21132180

2114-
if ((cust_id == WDC_CUSTOMER_ID_0x1004) || (cust_id == WDC_CUSTOMER_ID_0x1008) ||
2115-
(cust_id == WDC_CUSTOMER_ID_0x1005) || (cust_id == WDC_CUSTOMER_ID_0x1304))
2116-
capabilities |= (WDC_DRIVE_CAP_VU_FID_CLEAR_FW_ACT_HISTORY | WDC_DRIVE_CAP_VU_FID_CLEAR_PCIE);
2117-
else
2118-
capabilities |= (WDC_DRIVE_CAP_CLEAR_FW_ACT_HISTORY | WDC_DRIVE_CAP_CLEAR_PCIE);
2181+
/* if the 0xCB log page is supported */
2182+
if (wdc_nvme_check_supported_log_page(r, dev,
2183+
WDC_NVME_GET_FW_ACT_HISTORY_LOG_ID, 0) == true)
2184+
capabilities |= WDC_DRIVE_CAP_FW_ACTIVATE_HISTORY;
2185+
}
21192186

21202187
break;
21212188
case WDC_NVME_SNDK_VID:
@@ -2125,6 +2192,7 @@ static __u64 wdc_get_enc_drive_capabilities(nvme_root_t r,
21252192
capabilities = 0;
21262193
}
21272194

2195+
out:
21282196
return capabilities;
21292197
}
21302198

@@ -2924,6 +2992,30 @@ static bool wdc_nvme_parse_dev_status_log_entry(void *log_data, __u32 *ret_data,
29242992
return false;
29252993
}
29262994

2995+
static bool wdc_nvme_parse_dev_status_log_str(void *log_data,
2996+
__u32 entry_id,
2997+
char *ret_data,
2998+
__u32 *ret_data_len)
2999+
{
3000+
struct wdc_c2_log_subpage_header *entry_data = NULL;
3001+
struct wdc_c2_cbs_data *entry_str_data = NULL;
3002+
3003+
if (wdc_parse_dev_mng_log_entry(log_data, entry_id, &entry_data)) {
3004+
if (entry_data) {
3005+
entry_str_data = (struct wdc_c2_cbs_data *)&entry_data->data;
3006+
memcpy(ret_data,
3007+
(void *)&entry_str_data->data,
3008+
le32_to_cpu(entry_str_data->length));
3009+
*ret_data_len = le32_to_cpu(entry_str_data->length);
3010+
return true;
3011+
}
3012+
}
3013+
3014+
*ret_data = 0;
3015+
*ret_data_len = 0;
3016+
return false;
3017+
}
3018+
29273019
static bool wdc_nvme_get_dev_status_log_data(nvme_root_t r, struct nvme_dev *dev, __le32 *ret_data,
29283020
__u8 log_id)
29293021
{

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.5"
8+
#define WDC_PLUGIN_VERSION "2.14.6"
99
#include "cmd.h"
1010

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

0 commit comments

Comments
 (0)