@@ -48,6 +48,10 @@ static struct cxl_cel_entry mock_cel[] = {
48
48
.opcode = cpu_to_le16 (CXL_MBOX_OP_GET_SUPPORTED_FEATURES ),
49
49
.effect = CXL_CMD_EFFECT_NONE ,
50
50
},
51
+ {
52
+ .opcode = cpu_to_le16 (CXL_MBOX_OP_GET_FEATURE ),
53
+ .effect = CXL_CMD_EFFECT_NONE ,
54
+ },
51
55
{
52
56
.opcode = cpu_to_le16 (CXL_MBOX_OP_IDENTIFY ),
53
57
.effect = CXL_CMD_EFFECT_NONE ,
@@ -149,6 +153,10 @@ struct mock_event_store {
149
153
u32 ev_status ;
150
154
};
151
155
156
+ struct vendor_test_feat {
157
+ __le32 data ;
158
+ } __packed ;
159
+
152
160
struct cxl_mockmem_data {
153
161
void * lsa ;
154
162
void * fw ;
@@ -165,6 +173,7 @@ struct cxl_mockmem_data {
165
173
u8 event_buf [SZ_4K ];
166
174
u64 timestamp ;
167
175
unsigned long sanitize_timeout ;
176
+ struct vendor_test_feat test_feat ;
168
177
};
169
178
170
179
static struct mock_event_log * event_find_log (struct device * dev , int log_type )
@@ -1379,6 +1388,44 @@ static void fill_feature_vendor_test(struct cxl_feat_entry *feat)
1379
1388
1380
1389
#define MAX_CXL_TEST_FEATS 1
1381
1390
1391
+ static int mock_get_test_feature (struct cxl_mockmem_data * mdata ,
1392
+ struct cxl_mbox_cmd * cmd )
1393
+ {
1394
+ struct vendor_test_feat * output = cmd -> payload_out ;
1395
+ struct cxl_mbox_get_feat_in * input = cmd -> payload_in ;
1396
+ u16 offset = le16_to_cpu (input -> offset );
1397
+ u16 count = le16_to_cpu (input -> count );
1398
+ u8 * ptr ;
1399
+
1400
+ if (offset > sizeof (* output )) {
1401
+ cmd -> return_code = CXL_MBOX_CMD_RC_INPUT ;
1402
+ return - EINVAL ;
1403
+ }
1404
+
1405
+ if (offset + count > sizeof (* output )) {
1406
+ cmd -> return_code = CXL_MBOX_CMD_RC_INPUT ;
1407
+ return - EINVAL ;
1408
+ }
1409
+
1410
+ ptr = (u8 * )& mdata -> test_feat + offset ;
1411
+ memcpy ((u8 * )output + offset , ptr , count );
1412
+
1413
+ return 0 ;
1414
+ }
1415
+
1416
+ static int mock_get_feature (struct cxl_mockmem_data * mdata ,
1417
+ struct cxl_mbox_cmd * cmd )
1418
+ {
1419
+ struct cxl_mbox_get_feat_in * input = cmd -> payload_in ;
1420
+
1421
+ if (uuid_equal (& input -> uuid , & CXL_VENDOR_FEATURE_TEST ))
1422
+ return mock_get_test_feature (mdata , cmd );
1423
+
1424
+ cmd -> return_code = CXL_MBOX_CMD_RC_UNSUPPORTED ;
1425
+
1426
+ return - EOPNOTSUPP ;
1427
+ }
1428
+
1382
1429
static int mock_get_supported_features (struct cxl_mockmem_data * mdata ,
1383
1430
struct cxl_mbox_cmd * cmd )
1384
1431
{
@@ -1509,6 +1556,9 @@ static int cxl_mock_mbox_send(struct cxl_mailbox *cxl_mbox,
1509
1556
case CXL_MBOX_OP_GET_SUPPORTED_FEATURES :
1510
1557
rc = mock_get_supported_features (mdata , cmd );
1511
1558
break ;
1559
+ case CXL_MBOX_OP_GET_FEATURE :
1560
+ rc = mock_get_feature (mdata , cmd );
1561
+ break ;
1512
1562
default :
1513
1563
break ;
1514
1564
}
@@ -1556,6 +1606,11 @@ static int cxl_mock_mailbox_create(struct cxl_dev_state *cxlds)
1556
1606
return 0 ;
1557
1607
}
1558
1608
1609
+ static void cxl_mock_test_feat_init (struct cxl_mockmem_data * mdata )
1610
+ {
1611
+ mdata -> test_feat .data = cpu_to_le32 (0xdeadbeef );
1612
+ }
1613
+
1559
1614
static int cxl_mock_mem_probe (struct platform_device * pdev )
1560
1615
{
1561
1616
struct device * dev = & pdev -> dev ;
@@ -1651,6 +1706,7 @@ static int cxl_mock_mem_probe(struct platform_device *pdev)
1651
1706
dev_dbg (dev , "No CXL FWCTL setup\n" );
1652
1707
1653
1708
cxl_mem_get_event_records (mds , CXLDEV_EVENT_STATUS_ALL );
1709
+ cxl_mock_test_feat_init (mdata );
1654
1710
1655
1711
return 0 ;
1656
1712
}
0 commit comments