Skip to content

Commit 1729808

Browse files
davejiangjgunthorpe
authored andcommitted
cxl/test: Add Set Feature support to cxl_test
Add emulation to support Set Feature mailbox command to cxl_test. The only feature supported is the device patrol scrub feature. The set feature allows activation of patrol scrub for the cxl_test emulated device. The command does not support partial data transfer even though the spec allows it. This restriction is to reduce complexity of the emulation given the patrol scrub feature is very minimal. Link: https://patch.msgid.link/r/[email protected] Reviewed-by: Jonathan Cameron <[email protected]> Reviewed-by: Dan Williams <[email protected]> Reviewed-by: Li Ming <[email protected]> Signed-off-by: Dave Jiang <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent e77e9c1 commit 1729808

File tree

1 file changed

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

1 file changed

+51
-0
lines changed

tools/testing/cxl/test/mem.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ static struct cxl_cel_entry mock_cel[] = {
5252
.opcode = cpu_to_le16(CXL_MBOX_OP_GET_FEATURE),
5353
.effect = CXL_CMD_EFFECT_NONE,
5454
},
55+
{
56+
.opcode = cpu_to_le16(CXL_MBOX_OP_SET_FEATURE),
57+
.effect = cpu_to_le16(EFFECT(CONF_CHANGE_IMMEDIATE)),
58+
},
5559
{
5660
.opcode = cpu_to_le16(CXL_MBOX_OP_IDENTIFY),
5761
.effect = CXL_CMD_EFFECT_NONE,
@@ -1426,6 +1430,50 @@ static int mock_get_feature(struct cxl_mockmem_data *mdata,
14261430
return -EOPNOTSUPP;
14271431
}
14281432

1433+
static int mock_set_test_feature(struct cxl_mockmem_data *mdata,
1434+
struct cxl_mbox_cmd *cmd)
1435+
{
1436+
struct cxl_mbox_set_feat_in *input = cmd->payload_in;
1437+
struct vendor_test_feat *test =
1438+
(struct vendor_test_feat *)input->feat_data;
1439+
u32 action;
1440+
1441+
action = FIELD_GET(CXL_SET_FEAT_FLAG_DATA_TRANSFER_MASK,
1442+
le32_to_cpu(input->hdr.flags));
1443+
/*
1444+
* While it is spec compliant to support other set actions, it is not
1445+
* necessary to add the complication in the emulation currently. Reject
1446+
* anything besides full xfer.
1447+
*/
1448+
if (action != CXL_SET_FEAT_FLAG_FULL_DATA_TRANSFER) {
1449+
cmd->return_code = CXL_MBOX_CMD_RC_INPUT;
1450+
return -EINVAL;
1451+
}
1452+
1453+
/* Offset should be reserved when doing full transfer */
1454+
if (input->hdr.offset) {
1455+
cmd->return_code = CXL_MBOX_CMD_RC_INPUT;
1456+
return -EINVAL;
1457+
}
1458+
1459+
memcpy(&mdata->test_feat.data, &test->data, sizeof(u32));
1460+
1461+
return 0;
1462+
}
1463+
1464+
static int mock_set_feature(struct cxl_mockmem_data *mdata,
1465+
struct cxl_mbox_cmd *cmd)
1466+
{
1467+
struct cxl_mbox_set_feat_in *input = cmd->payload_in;
1468+
1469+
if (uuid_equal(&input->hdr.uuid, &CXL_VENDOR_FEATURE_TEST))
1470+
return mock_set_test_feature(mdata, cmd);
1471+
1472+
cmd->return_code = CXL_MBOX_CMD_RC_UNSUPPORTED;
1473+
1474+
return -EOPNOTSUPP;
1475+
}
1476+
14291477
static int mock_get_supported_features(struct cxl_mockmem_data *mdata,
14301478
struct cxl_mbox_cmd *cmd)
14311479
{
@@ -1559,6 +1607,9 @@ static int cxl_mock_mbox_send(struct cxl_mailbox *cxl_mbox,
15591607
case CXL_MBOX_OP_GET_FEATURE:
15601608
rc = mock_get_feature(mdata, cmd);
15611609
break;
1610+
case CXL_MBOX_OP_SET_FEATURE:
1611+
rc = mock_set_feature(mdata, cmd);
1612+
break;
15621613
default:
15631614
break;
15641615
}

0 commit comments

Comments
 (0)