1 /*
2 * Copyright (c) 2021 Chuck Tuffli <chuck@tuffli.net>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16 #include <stddef.h>
17
18 #include "libsmart.h"
19 #include "libsmart_priv.h"
20
21 /* Strings from "SMART Attribute Descriptions" (SAD) */
22 static const char *
23 desc_ata_data[] = {
24 [1] = "Read Error Rate",
25 [2] = "Throughput Performance",
26 [3] = "Spin-Up Time",
27 [4] = "Start/Stop Count",
28 [5] = "Reallocated Sectors Count",
29 [6] = "Read Channel Margin",
30 [7] = "Seek Error Rate",
31 [8] = "Seek Time Performance",
32 [9] = "Power-On Hours",
33 [10] = "Spin Retry Count",
34 [11] = "Calibration Retry Count",
35 [12] = "Power Cycle Count",
36 [13] = "Soft Read Error Rate",
37 [22] = "Current Helium Level", /* HGST */
38 [170] = "Available Reserved Space", /* Intel */
39 [171] = "SSD Program Fail", /* Kingston? */
40 [172] = "SSD Erase Fail Count", /* Kingston? */
41 [173] = "SSD Wear Leveling Count", /* HPE SSD Endurance Limit */
42 [174] = "Unexpected Power Loss Count", /* Intel */
43 [175] = "Power Loss Protection Failure", /* Intel */
44 [176] = "Erase Fail Count (chip)",
45 [177] = "Wear Range Delta",
46 [179] = "Used Reserved Block Count Total",
47 /* [180] = HPE, Seagate, Intel differences */
48 [181] = "Non-4K Aligned Access Count", /* Micron. Conflict Kingston */
49 [182] = "Erase Fail Count",
50 [183] = "Runtime Bad Block",
51 [184] = "End-to-End Error",
52 [185] = "Head Stability", /* WD */
53 [186] = "Induced Op-Vibration Detection", /* WD */
54 [187] = "Reported Uncorrectable Errors",
55 [188] = "Command Timeout",
56 [189] = "High Fly Writes",
57 [190] = "Airflow Temperature", /* WDC, HPE conflict */
58 [191] = "G-Sense Error Rate",
59 [192] = "Power-Off Count", /* HPE, Seagate */
60 [193] = "Load/Unload Cycle Count",
61 [194] = "Temperature Celsius",
62 [195] = "Hardware ECC Recovered",
63 [196] = "Reallocation Event Count",
64 [197] = "Current Pending Sector Count",
65 [198] = "Uncorrectable Sector Count", /* Fujitsu */
66 [199] = "UltraDMA CRC Error Count",
67 [200] = "Write Error Rate",
68 [201] = "Soft Read Error Rate",
69 [202] = "Data Address Mark Errors",
70 [203] = "Run Out Cancel",
71 [204] = "Soft ECC Correction",
72 [205] = "Thermal Asperity Rate",
73 [206] = "Flying Height",
74 [207] = "Spin High Current",
75 [208] = "Spin Buzz",
76 [209] = "Offline Seek Performnce",
77 [210] = "Vibration, During Write", /* Maxtor */
78 [211] = "Vibration During Write", /* Acronis */
79 [212] = "Shock During Write", /* Acronis */
80 [220] = "Disk Shift",
81 [221] = "G-Sense Error Rate",
82 [222] = "Loaded Hours",
83 [223] = "Load/Unload Retry Count",
84 [224] = "Load Friction",
85 [225] = "Load/Unload Cycle Count",
86 [226] = "Load-in Time",
87 [227] = "Torque Amplification Count",
88 [228] = "Power-off Retract Cycle",
89 [230] = "GMR Head Amplitude Drive Life Protection Status",
90 [231] = "Temperature SSD Life Left", /* Kingston */
91 [232] = "Endurance Remaining", /* Multiple conflict */
92 [233] = "Power-On Hours", /* Multiple conflict */
93 [234] = "Average Erase Count", /* Multiple conflict */
94 [235] = "Good Block Count", /* Multiple conflict */
95 [240] = "Head Flying Hours",
96 [241] = "Total LBAs Written",
97 [242] = "Total LBAs Read",
98 [243] = "Total LBAs Written Expanded", /* Multiple conflict */
99 [244] = "Total LBAs Read Expanded", /* Multiple conflict */
100 [250] = "Read Error Rate",
101 [251] = "Minimum Spares Remaining",
102 [252] = "Newly Added Bad Flash Block",
103 [254] = "Free Fall Protection"
104 };
105
106 const char *
__smart_ata_desc(uint32_t page,uint32_t id)107 __smart_ata_desc(uint32_t page, uint32_t id)
108 {
109 const char *desc = NULL;
110
111 switch (page) {
112 case PAGE_ID_ATA_SMART_READ_DATA:
113 if (desc_ata_data[id] != NULL)
114 desc = desc_ata_data[id];
115 break;
116 case PAGE_ID_ATA_SMART_RET_STATUS:
117 desc = "SMART Status";
118 break;
119 default:
120 ;
121 }
122
123 return (desc);
124 }
125
126 const char *
__smart_scsi_err_desc(uint32_t id)127 __smart_scsi_err_desc(uint32_t id)
128 {
129 const char *param = NULL;
130
131 switch (id) {
132 case 0:
133 param = "Errors corrected without substantial delay";
134 break;
135 case 1:
136 param = "Errors corrected with possible delays";
137 break;
138 case 2:
139 param = "Total retries";
140 break;
141 case 3:
142 param = "Total errors corrected";
143 break;
144 case 4:
145 param = "Total times correction algorithm processed";
146 break;
147 case 5:
148 param = "Total bytes processed";
149 break;
150 case 6:
151 param = "Total uncorrected errors";
152 break;
153 default:
154 return (NULL);
155 }
156
157 return (param);
158 }
159