@@ -44,6 +44,10 @@ static struct cxl_cel_entry mock_cel[] = {
44
44
.opcode = cpu_to_le16 (CXL_MBOX_OP_GET_SUPPORTED_LOGS ),
45
45
.effect = CXL_CMD_EFFECT_NONE ,
46
46
},
47
+ {
48
+ .opcode = cpu_to_le16 (CXL_MBOX_OP_GET_SUPPORTED_FEATURES ),
49
+ .effect = CXL_CMD_EFFECT_NONE ,
50
+ },
47
51
{
48
52
.opcode = cpu_to_le16 (CXL_MBOX_OP_IDENTIFY ),
49
53
.effect = CXL_CMD_EFFECT_NONE ,
@@ -1354,6 +1358,69 @@ static int mock_activate_fw(struct cxl_mockmem_data *mdata,
1354
1358
return - EINVAL ;
1355
1359
}
1356
1360
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
+
1357
1424
static int cxl_mock_mbox_send (struct cxl_mailbox * cxl_mbox ,
1358
1425
struct cxl_mbox_cmd * cmd )
1359
1426
{
@@ -1439,6 +1506,9 @@ static int cxl_mock_mbox_send(struct cxl_mailbox *cxl_mbox,
1439
1506
case CXL_MBOX_OP_ACTIVATE_FW :
1440
1507
rc = mock_activate_fw (mdata , cmd );
1441
1508
break ;
1509
+ case CXL_MBOX_OP_GET_SUPPORTED_FEATURES :
1510
+ rc = mock_get_supported_features (mdata , cmd );
1511
+ break ;
1442
1512
default :
1443
1513
break ;
1444
1514
}
0 commit comments