Skip to content

Commit 44818d3

Browse files
committed
cxl/test: Add Get Supported Features mailbox command support
Add cxl-test emulation of Get Supported Features mailbox command. Currently only adding a test feature with feature identifier of all f's for testing. Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Acked-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Li Ming <ming.li@zohomail.com> Link: https://patch.msgid.link/20250220194438.2281088-4-dave.jiang@intel.com Signed-off-by: Dave Jiang <dave.jiang@intel.com>
1 parent f0e6a23 commit 44818d3

File tree

1 file changed

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

1 file changed

+70
-0
lines changed

tools/testing/cxl/test/mem.c

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ static struct cxl_cel_entry mock_cel[] = {
4444
.opcode = cpu_to_le16(CXL_MBOX_OP_GET_SUPPORTED_LOGS),
4545
.effect = CXL_CMD_EFFECT_NONE,
4646
},
47+
{
48+
.opcode = cpu_to_le16(CXL_MBOX_OP_GET_SUPPORTED_FEATURES),
49+
.effect = CXL_CMD_EFFECT_NONE,
50+
},
4751
{
4852
.opcode = cpu_to_le16(CXL_MBOX_OP_IDENTIFY),
4953
.effect = CXL_CMD_EFFECT_NONE,
@@ -1354,6 +1358,69 @@ static int mock_activate_fw(struct cxl_mockmem_data *mdata,
13541358
return -EINVAL;
13551359
}
13561360

1361+
#define CXL_VENDOR_FEATURE_TEST \
1362+
UUID_INIT(0xffffffff, 0xffff, 0xffff, 0xff, 0xff, 0xff, 0xff, 0xff, \
1363+
0xff, 0xff, 0xff)
1364+
1365+
static void fill_feature_vendor_test(struct cxl_feat_entry *feat)
1366+
{
1367+
feat->uuid = CXL_VENDOR_FEATURE_TEST;
1368+
feat->id = 0;
1369+
feat->get_feat_size = cpu_to_le16(0x4);
1370+
feat->set_feat_size = cpu_to_le16(0x4);
1371+
feat->flags = cpu_to_le32(CXL_FEATURE_F_CHANGEABLE |
1372+
CXL_FEATURE_F_DEFAULT_SEL |
1373+
CXL_FEATURE_F_SAVED_SEL);
1374+
feat->get_feat_ver = 1;
1375+
feat->set_feat_ver = 1;
1376+
feat->effects = cpu_to_le16(CXL_CMD_CONFIG_CHANGE_COLD_RESET |
1377+
CXL_CMD_EFFECTS_VALID);
1378+
}
1379+
1380+
#define MAX_CXL_TEST_FEATS 1
1381+
1382+
static int mock_get_supported_features(struct cxl_mockmem_data *mdata,
1383+
struct cxl_mbox_cmd *cmd)
1384+
{
1385+
struct cxl_mbox_get_sup_feats_in *in = cmd->payload_in;
1386+
struct cxl_mbox_get_sup_feats_out *out = cmd->payload_out;
1387+
struct cxl_feat_entry *feat;
1388+
u16 start_idx, count;
1389+
1390+
if (cmd->size_out < sizeof(*out)) {
1391+
cmd->return_code = CXL_MBOX_CMD_RC_PAYLOADLEN;
1392+
return -EINVAL;
1393+
}
1394+
1395+
/*
1396+
* Current emulation only supports 1 feature
1397+
*/
1398+
start_idx = le16_to_cpu(in->start_idx);
1399+
if (start_idx != 0) {
1400+
cmd->return_code = CXL_MBOX_CMD_RC_INPUT;
1401+
return -EINVAL;
1402+
}
1403+
1404+
count = le16_to_cpu(in->count);
1405+
if (count < struct_size(out, ents, 0)) {
1406+
cmd->return_code = CXL_MBOX_CMD_RC_PAYLOADLEN;
1407+
return -EINVAL;
1408+
}
1409+
1410+
out->supported_feats = cpu_to_le16(MAX_CXL_TEST_FEATS);
1411+
cmd->return_code = 0;
1412+
if (count < struct_size(out, ents, MAX_CXL_TEST_FEATS)) {
1413+
out->num_entries = 0;
1414+
return 0;
1415+
}
1416+
1417+
out->num_entries = cpu_to_le16(MAX_CXL_TEST_FEATS);
1418+
feat = out->ents;
1419+
fill_feature_vendor_test(feat);
1420+
1421+
return 0;
1422+
}
1423+
13571424
static int cxl_mock_mbox_send(struct cxl_mailbox *cxl_mbox,
13581425
struct cxl_mbox_cmd *cmd)
13591426
{
@@ -1439,6 +1506,9 @@ static int cxl_mock_mbox_send(struct cxl_mailbox *cxl_mbox,
14391506
case CXL_MBOX_OP_ACTIVATE_FW:
14401507
rc = mock_activate_fw(mdata, cmd);
14411508
break;
1509+
case CXL_MBOX_OP_GET_SUPPORTED_FEATURES:
1510+
rc = mock_get_supported_features(mdata, cmd);
1511+
break;
14421512
default:
14431513
break;
14441514
}

0 commit comments

Comments
 (0)