|
15 | 15 | #define TEST_CDW12 0x12121212 |
16 | 16 | #define TEST_CDW13 0x13131313 |
17 | 17 | #define TEST_CDW15 0x15151515 |
| 18 | +#define TEST_CDQID 0x8765 |
18 | 19 | #define TEST_UUIDX 0b1001110 |
19 | 20 | #define TEST_FID 0xFE |
20 | 21 | #define TEST_RESULT 0x12345678 |
@@ -1519,6 +1520,57 @@ static void test_get_kernel_error(void) |
1519 | 1520 | check(!result, "result unexpectedly set to %" PRIu32, result); |
1520 | 1521 | } |
1521 | 1522 |
|
| 1523 | +static void test_lm_set_features_ctrl_data_queue(void) |
| 1524 | +{ |
| 1525 | + __u32 hp = 0x12, tpt = 0x34; |
| 1526 | + bool etpt = true; |
| 1527 | + struct mock_cmd mock_admin_cmd = { |
| 1528 | + .opcode = nvme_admin_set_features, |
| 1529 | + .nsid = NVME_NSID_NONE, |
| 1530 | + .cdw10 = NVME_FEAT_FID_CTRL_DATA_QUEUE, |
| 1531 | + .cdw11 = TEST_CDQID | etpt << 31, |
| 1532 | + .cdw12 = hp, |
| 1533 | + .cdw13 = tpt, |
| 1534 | + .result = TEST_RESULT, |
| 1535 | + }; |
| 1536 | + uint32_t result = 0; |
| 1537 | + int err; |
| 1538 | + |
| 1539 | + set_mock_admin_cmds(&mock_admin_cmd, 1); |
| 1540 | + err = nvme_lm_set_features_ctrl_data_queue(TEST_FD, TEST_CDQID, hp, tpt, |
| 1541 | + etpt, &result); |
| 1542 | + end_mock_cmds(); |
| 1543 | + check(err == 0, "set features returned error %d, errno %m", err); |
| 1544 | + check(result == TEST_RESULT, |
| 1545 | + "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); |
| 1546 | +} |
| 1547 | + |
| 1548 | +static void test_lm_get_features_ctrl_data_queue(void) |
| 1549 | +{ |
| 1550 | + struct nvme_lm_ctrl_data_queue_fid_data expected_data, data = {}; |
| 1551 | + struct mock_cmd mock_admin_cmd = { |
| 1552 | + .opcode = nvme_admin_get_features, |
| 1553 | + .nsid = NVME_NSID_NONE, |
| 1554 | + .cdw10 = NVME_FEAT_FID_CTRL_DATA_QUEUE, |
| 1555 | + .cdw11 = TEST_CDQID, |
| 1556 | + .data_len = sizeof(expected_data), |
| 1557 | + .out_data = &expected_data, |
| 1558 | + .result = TEST_RESULT, |
| 1559 | + }; |
| 1560 | + uint32_t result = 0; |
| 1561 | + int err; |
| 1562 | + |
| 1563 | + arbitrary(&expected_data, sizeof(expected_data)); |
| 1564 | + set_mock_admin_cmds(&mock_admin_cmd, 1); |
| 1565 | + err = nvme_lm_get_features_ctrl_data_queue(TEST_FD, TEST_CDQID, &data, |
| 1566 | + &result); |
| 1567 | + end_mock_cmds(); |
| 1568 | + check(err == 0, "get features returned error %d, errno %m", err); |
| 1569 | + check(result == TEST_RESULT, |
| 1570 | + "got result %" PRIu32 ", expected %" PRIu32, result, TEST_RESULT); |
| 1571 | + cmp(&data, &expected_data, sizeof(data), "incorrect data"); |
| 1572 | +} |
| 1573 | + |
1522 | 1574 | static void run_test(const char *test_name, void (*test_fn)(void)) |
1523 | 1575 | { |
1524 | 1576 | printf("Running test %s...", test_name); |
@@ -1601,4 +1653,6 @@ int main(void) |
1601 | 1653 | RUN_TEST(set_kernel_error); |
1602 | 1654 | RUN_TEST(get_status_code_error); |
1603 | 1655 | RUN_TEST(get_kernel_error); |
| 1656 | + RUN_TEST(lm_set_features_ctrl_data_queue); |
| 1657 | + RUN_TEST(lm_get_features_ctrl_data_queue); |
1604 | 1658 | } |
0 commit comments