nvme/compliance: add a test case for get log page

Change-Id: I31252b016ad64ba259807dee468adc69dd545138
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10094
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Changpeng Liu 2021-11-03 21:17:15 +08:00 committed by Jim Harris
parent 7a2a588c62
commit d83b2ee4f4

View File

@ -999,6 +999,80 @@ identify_ns(void)
spdk_nvme_detach(ctrlr);
}
/* Mandatory Log Page Identidfiers
* 01h Error Information
* 02h SMART / Health Information
* 03h Firmware Slot Information
*/
static void
mandatory_get_log_page(void)
{
struct spdk_nvme_ctrlr *ctrlr;
struct spdk_nvme_cmd cmd;
void *buf;
struct status s;
int rc;
SPDK_CU_ASSERT_FATAL(spdk_nvme_transport_id_parse(&g_trid, g_trid_str) == 0);
ctrlr = spdk_nvme_connect(&g_trid, NULL, 0);
SPDK_CU_ASSERT_FATAL(ctrlr);
buf = spdk_dma_zmalloc(0x1000, 0x1000, NULL);
SPDK_CU_ASSERT_FATAL(buf != NULL);
/* 01h Error Information, valid */
memset(&cmd, 0, sizeof(cmd));
cmd.opc = SPDK_NVME_OPC_GET_LOG_PAGE;
cmd.cdw10_bits.get_log_page.numdl = sizeof(struct spdk_nvme_error_information_entry) / 4 - 1;
cmd.cdw10_bits.get_log_page.lid = SPDK_NVME_LOG_ERROR;
s.done = false;
rc = spdk_nvme_ctrlr_cmd_admin_raw(ctrlr, &cmd, buf,
sizeof(struct spdk_nvme_error_information_entry), test_cb, &s);
CU_ASSERT(rc == 0);
wait_for_admin_completion(&s, ctrlr);
CU_ASSERT(!spdk_nvme_cpl_is_error(&s.cpl));
/* Log Page Offset Lower is greater than spdk_nvme_error_information_entry, invalid */
cmd.cdw12 = sizeof(struct spdk_nvme_error_information_entry) + 4;
s.done = false;
rc = spdk_nvme_ctrlr_cmd_admin_raw(ctrlr, &cmd, buf,
sizeof(struct spdk_nvme_error_information_entry), test_cb, &s);
CU_ASSERT(rc == 0);
wait_for_admin_completion(&s, ctrlr);
CU_ASSERT(s.cpl.status.sc == SPDK_NVME_SC_INVALID_FIELD);
/* 02h SMART / Health Information, valid */
cmd.cdw10_bits.get_log_page.numdl = sizeof(struct spdk_nvme_health_information_page) / 4 - 1;
cmd.cdw10_bits.get_log_page.lid = SPDK_NVME_LOG_HEALTH_INFORMATION;
cmd.cdw12 = 0;
s.done = false;
rc = spdk_nvme_ctrlr_cmd_admin_raw(ctrlr, &cmd, buf,
sizeof(struct spdk_nvme_health_information_page), test_cb, &s);
CU_ASSERT(rc == 0);
wait_for_admin_completion(&s, ctrlr);
CU_ASSERT(!spdk_nvme_cpl_is_error(&s.cpl));
/* 03h Firmware Slot Information, valid */
cmd.cdw10_bits.get_log_page.numdl = sizeof(struct spdk_nvme_firmware_page) / 4 - 1;
cmd.cdw10_bits.get_log_page.lid = SPDK_NVME_LOG_FIRMWARE_SLOT;
s.done = false;
rc = spdk_nvme_ctrlr_cmd_admin_raw(ctrlr, &cmd, buf,
sizeof(struct spdk_nvme_firmware_page), test_cb, &s);
CU_ASSERT(rc == 0);
wait_for_admin_completion(&s, ctrlr);
CU_ASSERT(!spdk_nvme_cpl_is_error(&s.cpl));
spdk_dma_free(buf);
spdk_nvme_detach(ctrlr);
}
int main(int argc, char **argv)
{
struct spdk_env_opts opts;
@ -1039,6 +1113,7 @@ int main(int argc, char **argv)
CU_ADD_TEST(suite, property_get);
CU_ADD_TEST(suite, create_max_io_qpairs);
CU_ADD_TEST(suite, identify_ns);
CU_ADD_TEST(suite, mandatory_get_log_page);
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();