Skip to content

Commit 2bcbe3a

Browse files
authored
Fix health check for SSD vendors: add a parser for ATP, and add a generic health ID for other brands (#595)
Description Fix health check for SSD vendors: add a parser for ATP, and add a generic health ID for other brands. Each vendor stores health information in different SMART attributes. ATP stores it in attribute ID 248, we add a parser for it. We also have SSDs use Attribute ID 231 and it is commonly used, so add it in the generic parser. Skip obtaining vendor SSD info for ATP and Virtium NVMe SSD because they are handle by parse_generic_ssd_info and parse_vendor_ssd_info will overwrite data with N/A. Add unit test cases for ATP SATA/NVMe SSD. Motivation and Context show platform ssdhealth shows N/A health for some qualified SSDs. Back port request 202412 202505 How Has This Been Tested? We have tested the code change on DUTs with different SSDs including all the qualified SSDs that show N/A in health and also on the ones that worked fine before.
1 parent 499d775 commit 2bcbe3a

File tree

2 files changed

+365
-9
lines changed

2 files changed

+365
-9
lines changed

sonic_platform_base/sonic_storage/ssd.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
# Generic IDs
2727

28-
GENERIC_HEALTH_ID = 169
28+
GENERIC_HEALTH_ID = [169, 231]
2929
GENERIC_IO_READS_ID = 242
3030
GENERIC_IO_WRITES_ID = 241
3131
GENERIC_RESERVED_BLOCKS_ID = [170, 232]
@@ -53,6 +53,8 @@
5353

5454
INTEL_MEDIA_WEAROUT_INDICATOR_ID = 233
5555

56+
ATP_HEALTH_ID = 248
57+
5658
class SsdUtil(StorageCommon):
5759
"""
5860
Generic implementation of the SSD health API
@@ -85,6 +87,7 @@ def __init__(self, diskdev):
8587
"Micron" : { "utility" : SMARTCTL, "parser" : self.parse_micron_info },
8688
"Intel" : { "utility" : SMARTCTL, "parser" : self.parse_intel_info },
8789
"Transcend" : { "utility" : SMARTCTL, "parser" : self.parse_generic_ssd_info },
90+
"ATP" : { "utility" : SMARTCTL, "parser" : self.parse_atp_info },
8891
}
8992

9093
self.dev = diskdev
@@ -100,12 +103,12 @@ def fetch_parse_info(self, diskdev):
100103

101104
# Known vendor part
102105
if self.model:
103-
# For some Virtium SSDs, parse_generic_ssd_info should be called.
104-
# Since it was called above, no need to parse a specific vendor SSD info.
105-
if self.model in ['Virtium VTPM24CEXI080-BM110006']:
106+
vendor = self._parse_vendor()
107+
# For Virtium, ATP NVMe SSD, parse_generic_ssd_info should be called.
108+
# Skip here, otherwise data will be overwritten by N/A.
109+
if vendor in ['Virtium', 'ATP'] and "nvme" in self.dev:
106110
return
107111

108-
vendor = self._parse_vendor()
109112
if vendor:
110113
try:
111114
self.fetch_vendor_ssd_info(diskdev, vendor)
@@ -189,10 +192,11 @@ def parse_generic_ssd_info(self):
189192

190193
health_raw = self._parse_re('Remaining_Lifetime_Perc\s*(.+?)\n', self.ssd_info)
191194
if health_raw == NOT_AVAILABLE:
192-
health_raw = self.parse_id_number(GENERIC_HEALTH_ID, self.ssd_info)
193-
if health_raw == NOT_AVAILABLE:
194-
self.health = NOT_AVAILABLE
195-
else: self.health = health_raw.split()[-1]
195+
for health_id in GENERIC_HEALTH_ID:
196+
health_raw = self.parse_id_number(health_id, self.ssd_info)
197+
if health_raw != NOT_AVAILABLE:
198+
break
199+
self.health = NOT_AVAILABLE if health_raw == NOT_AVAILABLE else health_raw.split()[-1]
196200
else:
197201
self.health = health_raw.split()[-1]
198202

@@ -359,6 +363,11 @@ def parse_intel_info(self):
359363
health_raw = self.parse_id_number(INTEL_MEDIA_WEAROUT_INDICATOR_ID, self.vendor_ssd_info)
360364
self.health = NOT_AVAILABLE if health_raw == NOT_AVAILABLE else str(100 - float(health_raw.split()[-1]))
361365

366+
def parse_atp_info(self):
367+
if self.vendor_ssd_info:
368+
health_raw = self.parse_id_number(ATP_HEALTH_ID, self.vendor_ssd_info)
369+
self.health = NOT_AVAILABLE if health_raw == NOT_AVAILABLE else health_raw.split()[-1]
370+
362371
def fetch_vendor_ssd_info(self, diskdev, model):
363372
self.vendor_ssd_info = self._execute_shell(self.vendor_ssd_utility[model]["utility"].format(diskdev))
364373

0 commit comments

Comments
 (0)