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 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/20250307205648.1021626-8-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
1729808c e77e9c10

+51
+51
tools/testing/cxl/test/mem.c
··· 53 53 .effect = CXL_CMD_EFFECT_NONE, 54 54 }, 55 55 { 56 + .opcode = cpu_to_le16(CXL_MBOX_OP_SET_FEATURE), 57 + .effect = cpu_to_le16(EFFECT(CONF_CHANGE_IMMEDIATE)), 58 + }, 59 + { 56 60 .opcode = cpu_to_le16(CXL_MBOX_OP_IDENTIFY), 57 61 .effect = CXL_CMD_EFFECT_NONE, 58 62 }, ··· 1430 1426 return -EOPNOTSUPP; 1431 1427 } 1432 1428 1429 + static int mock_set_test_feature(struct cxl_mockmem_data *mdata, 1430 + struct cxl_mbox_cmd *cmd) 1431 + { 1432 + struct cxl_mbox_set_feat_in *input = cmd->payload_in; 1433 + struct vendor_test_feat *test = 1434 + (struct vendor_test_feat *)input->feat_data; 1435 + u32 action; 1436 + 1437 + action = FIELD_GET(CXL_SET_FEAT_FLAG_DATA_TRANSFER_MASK, 1438 + le32_to_cpu(input->hdr.flags)); 1439 + /* 1440 + * While it is spec compliant to support other set actions, it is not 1441 + * necessary to add the complication in the emulation currently. Reject 1442 + * anything besides full xfer. 1443 + */ 1444 + if (action != CXL_SET_FEAT_FLAG_FULL_DATA_TRANSFER) { 1445 + cmd->return_code = CXL_MBOX_CMD_RC_INPUT; 1446 + return -EINVAL; 1447 + } 1448 + 1449 + /* Offset should be reserved when doing full transfer */ 1450 + if (input->hdr.offset) { 1451 + cmd->return_code = CXL_MBOX_CMD_RC_INPUT; 1452 + return -EINVAL; 1453 + } 1454 + 1455 + memcpy(&mdata->test_feat.data, &test->data, sizeof(u32)); 1456 + 1457 + return 0; 1458 + } 1459 + 1460 + static int mock_set_feature(struct cxl_mockmem_data *mdata, 1461 + struct cxl_mbox_cmd *cmd) 1462 + { 1463 + struct cxl_mbox_set_feat_in *input = cmd->payload_in; 1464 + 1465 + if (uuid_equal(&input->hdr.uuid, &CXL_VENDOR_FEATURE_TEST)) 1466 + return mock_set_test_feature(mdata, cmd); 1467 + 1468 + cmd->return_code = CXL_MBOX_CMD_RC_UNSUPPORTED; 1469 + 1470 + return -EOPNOTSUPP; 1471 + } 1472 + 1433 1473 static int mock_get_supported_features(struct cxl_mockmem_data *mdata, 1434 1474 struct cxl_mbox_cmd *cmd) 1435 1475 { ··· 1606 1558 break; 1607 1559 case CXL_MBOX_OP_GET_FEATURE: 1608 1560 rc = mock_get_feature(mdata, cmd); 1561 + break; 1562 + case CXL_MBOX_OP_SET_FEATURE: 1563 + rc = mock_set_feature(mdata, cmd); 1609 1564 break; 1610 1565 default: 1611 1566 break;