@@ -28,8 +28,24 @@ static struct cxl_cel_entry mock_cel[] = {
28
28
.opcode = cpu_to_le16 (CXL_MBOX_OP_SET_LSA ),
29
29
.effect = cpu_to_le16 (EFFECT (1 ) | EFFECT (2 )),
30
30
},
31
+ {
32
+ .opcode = cpu_to_le16 (CXL_MBOX_OP_GET_HEALTH_INFO ),
33
+ .effect = cpu_to_le16 (0 ),
34
+ },
31
35
};
32
36
37
+ /* See CXL 2.0 Table 181 Get Health Info Output Payload */
38
+ struct cxl_mbox_health_info {
39
+ u8 health_status ;
40
+ u8 media_status ;
41
+ u8 ext_status ;
42
+ u8 life_used ;
43
+ __le16 temperature ;
44
+ __le32 dirty_shutdowns ;
45
+ __le32 volatile_errors ;
46
+ __le32 pmem_errors ;
47
+ } __packed ;
48
+
33
49
static struct {
34
50
struct cxl_mbox_get_supported_logs gsl ;
35
51
struct cxl_gsl_entry entry ;
@@ -156,6 +172,36 @@ static int mock_set_lsa(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd)
156
172
return 0 ;
157
173
}
158
174
175
+ static int mock_health_info (struct cxl_dev_state * cxlds ,
176
+ struct cxl_mbox_cmd * cmd )
177
+ {
178
+ struct cxl_mbox_health_info health_info = {
179
+ /* set flags for maint needed, perf degraded, hw replacement */
180
+ .health_status = 0x7 ,
181
+ /* set media status to "All Data Lost" */
182
+ .media_status = 0x3 ,
183
+ /*
184
+ * set ext_status flags for:
185
+ * ext_life_used: normal,
186
+ * ext_temperature: critical,
187
+ * ext_corrected_volatile: warning,
188
+ * ext_corrected_persistent: normal,
189
+ */
190
+ .ext_status = 0x18 ,
191
+ .life_used = 15 ,
192
+ .temperature = cpu_to_le16 (25 ),
193
+ .dirty_shutdowns = cpu_to_le32 (10 ),
194
+ .volatile_errors = cpu_to_le32 (20 ),
195
+ .pmem_errors = cpu_to_le32 (30 ),
196
+ };
197
+
198
+ if (cmd -> size_out < sizeof (health_info ))
199
+ return - EINVAL ;
200
+
201
+ memcpy (cmd -> payload_out , & health_info , sizeof (health_info ));
202
+ return 0 ;
203
+ }
204
+
159
205
static int cxl_mock_mbox_send (struct cxl_dev_state * cxlds , struct cxl_mbox_cmd * cmd )
160
206
{
161
207
struct device * dev = cxlds -> dev ;
@@ -177,6 +223,9 @@ static int cxl_mock_mbox_send(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *
177
223
case CXL_MBOX_OP_SET_LSA :
178
224
rc = mock_set_lsa (cxlds , cmd );
179
225
break ;
226
+ case CXL_MBOX_OP_GET_HEALTH_INFO :
227
+ rc = mock_health_info (cxlds , cmd );
228
+ break ;
180
229
default :
181
230
break ;
182
231
}
0 commit comments