Skip to content

Commit fd35fdc

Browse files
Davidlohr Buesodjbw
authored andcommitted
cxl/test: Add mock test for set_timestamp
Support the command testing in a unit-test fashion. Reviewed-by: Ira Weiny <[email protected]> Signed-off-by: Davidlohr Bueso <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dan Williams <[email protected]>
1 parent bfe5845 commit fd35fdc

File tree

1 file changed

+24
-0
lines changed
  • tools/testing/cxl/test

1 file changed

+24
-0
lines changed

tools/testing/cxl/test/mem.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ struct cxl_mockmem_data {
116116
int master_limit;
117117
struct mock_event_store mes;
118118
u8 event_buf[SZ_4K];
119+
u64 timestamp;
119120
};
120121

121122
static struct mock_event_log *event_find_log(struct device *dev, int log_type)
@@ -379,6 +380,22 @@ struct cxl_event_mem_module mem_module = {
379380
}
380381
};
381382

383+
static int mock_set_timestamp(struct cxl_dev_state *cxlds,
384+
struct cxl_mbox_cmd *cmd)
385+
{
386+
struct cxl_mockmem_data *mdata = dev_get_drvdata(cxlds->dev);
387+
struct cxl_mbox_set_timestamp_in *ts = cmd->payload_in;
388+
389+
if (cmd->size_in != sizeof(*ts))
390+
return -EINVAL;
391+
392+
if (cmd->size_out != 0)
393+
return -EINVAL;
394+
395+
mdata->timestamp = le64_to_cpu(ts->timestamp);
396+
return 0;
397+
}
398+
382399
static void cxl_mock_add_event_logs(struct mock_event_store *mes)
383400
{
384401
put_unaligned_le16(CXL_GMER_VALID_CHANNEL | CXL_GMER_VALID_RANK,
@@ -1103,6 +1120,9 @@ static int cxl_mock_mbox_send(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *
11031120
int rc = -EIO;
11041121

11051122
switch (cmd->opcode) {
1123+
case CXL_MBOX_OP_SET_TIMESTAMP:
1124+
rc = mock_set_timestamp(cxlds, cmd);
1125+
break;
11061126
case CXL_MBOX_OP_GET_SUPPORTED_LOGS:
11071127
rc = mock_gsl(cmd);
11081128
break;
@@ -1232,6 +1252,10 @@ static int cxl_mock_mem_probe(struct platform_device *pdev)
12321252
if (rc)
12331253
return rc;
12341254

1255+
rc = cxl_set_timestamp(cxlds);
1256+
if (rc)
1257+
return rc;
1258+
12351259
rc = cxl_dev_state_identify(cxlds);
12361260
if (rc)
12371261
return rc;

0 commit comments

Comments
 (0)