Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

cxl/test: Add Get Feature support to cxl_test

Add emulation of Get Feature command to cxl_test. The feature for
device patrol scrub is returned by the emulation code. This is
the only feature currently supported by cxl_test. It returns
the information for the device patrol scrub feature.

Link: https://patch.msgid.link/r/20250307205648.1021626-7-dave.jiang@intel.com
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Li Ming <ming.li@zohomail.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

authored by

Dave Jiang and committed by
Jason Gunthorpe
e77e9c10 eb5dfcb9

+56
+56
tools/testing/cxl/test/mem.c
··· 49 49 .effect = CXL_CMD_EFFECT_NONE, 50 50 }, 51 51 { 52 + .opcode = cpu_to_le16(CXL_MBOX_OP_GET_FEATURE), 53 + .effect = CXL_CMD_EFFECT_NONE, 54 + }, 55 + { 52 56 .opcode = cpu_to_le16(CXL_MBOX_OP_IDENTIFY), 53 57 .effect = CXL_CMD_EFFECT_NONE, 54 58 }, ··· 153 149 u32 ev_status; 154 150 }; 155 151 152 + struct vendor_test_feat { 153 + __le32 data; 154 + } __packed; 155 + 156 156 struct cxl_mockmem_data { 157 157 void *lsa; 158 158 void *fw; ··· 173 165 u8 event_buf[SZ_4K]; 174 166 u64 timestamp; 175 167 unsigned long sanitize_timeout; 168 + struct vendor_test_feat test_feat; 176 169 }; 177 170 178 171 static struct mock_event_log *event_find_log(struct device *dev, int log_type) ··· 1388 1379 1389 1380 #define MAX_CXL_TEST_FEATS 1 1390 1381 1382 + static int mock_get_test_feature(struct cxl_mockmem_data *mdata, 1383 + struct cxl_mbox_cmd *cmd) 1384 + { 1385 + struct vendor_test_feat *output = cmd->payload_out; 1386 + struct cxl_mbox_get_feat_in *input = cmd->payload_in; 1387 + u16 offset = le16_to_cpu(input->offset); 1388 + u16 count = le16_to_cpu(input->count); 1389 + u8 *ptr; 1390 + 1391 + if (offset > sizeof(*output)) { 1392 + cmd->return_code = CXL_MBOX_CMD_RC_INPUT; 1393 + return -EINVAL; 1394 + } 1395 + 1396 + if (offset + count > sizeof(*output)) { 1397 + cmd->return_code = CXL_MBOX_CMD_RC_INPUT; 1398 + return -EINVAL; 1399 + } 1400 + 1401 + ptr = (u8 *)&mdata->test_feat + offset; 1402 + memcpy((u8 *)output + offset, ptr, count); 1403 + 1404 + return 0; 1405 + } 1406 + 1407 + static int mock_get_feature(struct cxl_mockmem_data *mdata, 1408 + struct cxl_mbox_cmd *cmd) 1409 + { 1410 + struct cxl_mbox_get_feat_in *input = cmd->payload_in; 1411 + 1412 + if (uuid_equal(&input->uuid, &CXL_VENDOR_FEATURE_TEST)) 1413 + return mock_get_test_feature(mdata, cmd); 1414 + 1415 + cmd->return_code = CXL_MBOX_CMD_RC_UNSUPPORTED; 1416 + 1417 + return -EOPNOTSUPP; 1418 + } 1419 + 1391 1420 static int mock_get_supported_features(struct cxl_mockmem_data *mdata, 1392 1421 struct cxl_mbox_cmd *cmd) 1393 1422 { ··· 1556 1509 case CXL_MBOX_OP_GET_SUPPORTED_FEATURES: 1557 1510 rc = mock_get_supported_features(mdata, cmd); 1558 1511 break; 1512 + case CXL_MBOX_OP_GET_FEATURE: 1513 + rc = mock_get_feature(mdata, cmd); 1514 + break; 1559 1515 default: 1560 1516 break; 1561 1517 } ··· 1604 1554 return rc; 1605 1555 1606 1556 return 0; 1557 + } 1558 + 1559 + static void cxl_mock_test_feat_init(struct cxl_mockmem_data *mdata) 1560 + { 1561 + mdata->test_feat.data = cpu_to_le32(0xdeadbeef); 1607 1562 } 1608 1563 1609 1564 static int cxl_mock_mem_probe(struct platform_device *pdev) ··· 1706 1651 dev_dbg(dev, "No CXL FWCTL setup\n"); 1707 1652 1708 1653 cxl_mem_get_event_records(mds, CXLDEV_EVENT_STATUS_ALL); 1654 + cxl_mock_test_feat_init(mdata); 1709 1655 1710 1656 return 0; 1711 1657 }