Skip to content

Commit ab70e66

Browse files
Add new SSD type support (sonic-net#390)
* Add new SSD type support * Fix review comment --------- Co-authored-by: Prince George <[email protected]>
1 parent 537095c commit ab70e66

File tree

2 files changed

+135
-1
lines changed

2 files changed

+135
-1
lines changed

sonic_platform_base/sonic_ssd/ssd_generic.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
# Set Vendor Specific IDs
2424
INNODISK_HEALTH_ID = 169
2525
INNODISK_TEMPERATURE_ID = 194
26+
SWISSBIT_HEALTH_ID = 248
27+
SWISSBIT_TEMPERATURE_ID = 194
2628

2729
class SsdUtil(SsdBase):
2830
"""
@@ -42,7 +44,8 @@ def __init__(self, diskdev):
4244
"InnoDisk" : { "utility" : INNODISK, "parser" : self.parse_innodisk_info },
4345
"M.2" : { "utility" : INNODISK, "parser" : self.parse_innodisk_info },
4446
"StorFly" : { "utility" : VIRTIUM, "parser" : self.parse_virtium_info },
45-
"Virtium" : { "utility" : VIRTIUM, "parser" : self.parse_virtium_info }
47+
"Virtium" : { "utility" : VIRTIUM, "parser" : self.parse_virtium_info },
48+
"Swissbit" : { "utility" : SMARTCTL, "parser" : self.parse_swissbit_info },
4649
}
4750

4851
self.dev = diskdev
@@ -78,6 +81,8 @@ def _parse_vendor(self):
7881
return model_short
7982
elif self.model.startswith('VSF'):
8083
return 'Virtium'
84+
elif self.model.startswith('SFS'):
85+
return 'Swissbit'
8186
else:
8287
return None
8388

@@ -154,6 +159,19 @@ def parse_virtium_info(self):
154159
except ValueError:
155160
pass
156161

162+
def parse_swissbit_info(self):
163+
if self.ssd_info:
164+
health_raw = self.parse_id_number(SWISSBIT_HEALTH_ID)
165+
if health_raw == NOT_AVAILABLE:
166+
self.health = NOT_AVAILABLE
167+
else:
168+
self.health = health_raw.split()[-1]
169+
temp_raw = self.parse_id_number(SWISSBIT_TEMPERATURE_ID)
170+
if temp_raw == NOT_AVAILABLE:
171+
self.temperature = NOT_AVAILABLE
172+
else:
173+
self.temperature = temp_raw.split()[-3]
174+
157175
def fetch_vendor_ssd_info(self, diskdev, model):
158176
self.vendor_ssd_info = self._execute_shell(self.vendor_ssd_utility[model]["utility"].format(diskdev))
159177

tests/ssd_generic_test.py

+116
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,112 @@
532532
ID Attribute High Raw Low Raw Value Worst Threshold
533533
"""
534534

535+
output_swissbit_vendor = """
536+
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.10.0-23-2-amd64] (local build)
537+
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org
538+
539+
=== START OF INFORMATION SECTION ===
540+
Device Model: SFSA160GM2AK2TO-I-8C-22K-STD
541+
Serial Number: 00006022750795000010
542+
Firmware Version: SBR15004
543+
User Capacity: 160,041,885,696 bytes [160 GB]
544+
Sector Size: 512 bytes logical/physical
545+
Rotation Rate: Solid State Device
546+
Form Factor: 2.5 inches
547+
TRIM Command: Available, deterministic, zeroed
548+
Device is: Not in smartctl database [for details use: -P showall]
549+
ATA Version is: ACS-3 (minor revision not indicated)
550+
SATA Version is: SATA 3.2, 6.0 Gb/s (current: 6.0 Gb/s)
551+
Local Time is: Wed Aug 2 08:24:31 2023 UTC
552+
SMART support is: Available - device has SMART capability.
553+
SMART support is: Enabled
554+
555+
=== START OF READ SMART DATA SECTION ===
556+
SMART overall-health self-assessment test result: PASSED
557+
558+
General SMART Values:
559+
Offline data collection status: (0x00) Offline data collection activity
560+
was never started.
561+
Auto Offline Data Collection: Disabled.
562+
Self-test execution status: ( 0) The previous self-test routine completed
563+
without error or no self-test has ever
564+
been run.
565+
Total time to complete Offline
566+
data collection: ( 0) seconds.
567+
Offline data collection
568+
capabilities: (0x53) SMART execute Offline immediate.
569+
Auto Offline data collection on/off support.
570+
Suspend Offline collection upon new
571+
command.
572+
No Offline surface scan supported.
573+
Self-test supported.
574+
No Conveyance Self-test supported.
575+
Selective Self-test supported.
576+
SMART capabilities: (0x0003) Saves SMART data before entering
577+
power-saving mode.
578+
Supports SMART auto save timer.
579+
Error logging capability: (0x01) Error logging supported.
580+
General Purpose Logging supported.
581+
Short self-test routine
582+
recommended polling time: ( 2) minutes.
583+
Extended self-test routine
584+
recommended polling time: ( 15) minutes.
585+
SCT capabilities: (0x0031) SCT Status supported.
586+
SCT Feature Control supported.
587+
SCT Data Table supported.
588+
589+
SMART Attributes Data Structure revision number: 1
590+
Vendor Specific SMART Attributes with Thresholds:
591+
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
592+
1 Raw_Read_Error_Rate 0x000b 100 100 000 Pre-fail Always - 0
593+
5 Reallocated_Sector_Ct 0x0013 100 100 000 Pre-fail Always - 0
594+
9 Power_On_Hours 0x0012 100 100 000 Old_age Always - 825
595+
12 Power_Cycle_Count 0x0012 100 100 000 Old_age Always - 447
596+
16 Unknown_Attribute 0x0112 100 100 001 Old_age Always - 4
597+
17 Unknown_Attribute 0x0012 100 100 000 Old_age Always - 30000
598+
160 Unknown_Attribute 0x0002 100 100 000 Old_age Always - 0
599+
161 Unknown_Attribute 0x0012 100 100 000 Old_age Always - 15401195
600+
163 Unknown_Attribute 0x0003 100 100 000 Pre-fail Always - 33
601+
164 Unknown_Attribute 0x0012 100 100 000 Old_age Always - 6506
602+
165 Unknown_Attribute 0x0002 100 100 000 Old_age Always - 38
603+
166 Unknown_Attribute 0x0012 100 100 000 Old_age Always - 1
604+
167 Unknown_Attribute 0x0012 100 100 000 Old_age Always - 4
605+
168 Unknown_Attribute 0x0012 100 100 000 Old_age Always - 30000
606+
169 Unknown_Attribute 0x0003 100 100 000 Pre-fail Always - 421
607+
193 Unknown_SSD_Attribute 0x0012 100 100 000 Old_age Always - 0
608+
194 Temperature_Celsius 0x0023 100 100 000 Pre-fail Always - 25 (Min/Max 22/45)
609+
195 Hardware_ECC_Recovered 0x0012 100 100 000 Old_age Always - 0
610+
196 Reallocated_Event_Count 0x0012 000 000 000 Old_age Always - 0
611+
198 Offline_Uncorrectable 0x0012 100 100 000 Old_age Always - 0
612+
199 UDMA_CRC_Error_Count 0x000b 100 100 000 Pre-fail Always - 0
613+
215 Unknown_Attribute 0x0012 100 100 000 Old_age Always - 4275
614+
231 Unknown_SSD_Attribute 0x1913 100 100 025 Pre-fail Always - 100
615+
235 Unknown_Attribute 0x0012 100 100 000 Old_age Always - 1302467136
616+
237 Unknown_Attribute 0x0012 100 100 000 Old_age Always - 0
617+
241 Total_LBAs_Written 0x0012 100 100 000 Old_age Always - 1186450104
618+
242 Total_LBAs_Read 0x0012 100 100 000 Old_age Always - 2257141451
619+
243 Unknown_Attribute 0x0012 100 100 000 Old_age Always - 0
620+
244 Unknown_Attribute 0x0012 100 100 000 Old_age Always - 0
621+
248 Unknown_Attribute 0x0112 100 100 001 Old_age Always - 100
622+
623+
SMART Error Log Version: 1
624+
No Errors Logged
625+
626+
SMART Self-test log structure revision number 1
627+
No self-tests have been logged. [To run self-tests, use: smartctl -t]
628+
629+
SMART Selective self-test log data structure revision number 1
630+
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
631+
1 0 0 Not_testing
632+
2 0 0 Not_testing
633+
3 0 0 Not_testing
634+
4 0 0 Not_testing
635+
5 0 0 Not_testing
636+
Selective self-test flags (0x0):
637+
After scanning selected spans, do NOT read-scan remainder of disk.
638+
If Selective self-test is pending on power-up, resume after 0 minute delay.
639+
"""
640+
535641
class TestSsdGeneric:
536642
@mock.patch('sonic_platform_base.sonic_ssd.ssd_generic.SsdUtil._execute_shell', mock.MagicMock(return_value=output_nvme_ssd))
537643
def test_nvme_ssd(self):
@@ -631,3 +737,13 @@ def test_virtium_ssd(self, mock_exec):
631737
mock_exec.side_effect = [output_virtium_generic, output_virtium_invalid_remain_life]
632738
virtium_ssd = SsdUtil('/dev/sda')
633739
assert virtium_ssd.get_health() == "N/A"
740+
741+
@mock.patch('sonic_platform_base.sonic_ssd.ssd_generic.SsdUtil._execute_shell')
742+
def test_swissbit_ssd(self, mock_exec):
743+
mock_exec.return_value = output_swissbit_vendor
744+
swissbit_ssd = SsdUtil('/dev/sda')
745+
assert swissbit_ssd.get_health() == '100'
746+
assert swissbit_ssd.get_model() == 'SFSA160GM2AK2TO-I-8C-22K-STD'
747+
assert swissbit_ssd.get_firmware() == "SBR15004"
748+
assert swissbit_ssd.get_temperature() == '25'
749+
assert swissbit_ssd.get_serial() == "00006022750795000010"

0 commit comments

Comments
 (0)