summaryrefslogtreecommitdiffstats
path: root/test/mi-mctp.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-05 18:17:21 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-05 18:17:32 +0000
commitb0dc2feab3271dbcb42df6e6d8a37138a90c44a1 (patch)
treeae02f159c125f183b2adae47fdf0e64357bf76a8 /test/mi-mctp.c
parentReleasing debian version 1.1-2. (diff)
downloadlibnvme-b0dc2feab3271dbcb42df6e6d8a37138a90c44a1.tar.xz
libnvme-b0dc2feab3271dbcb42df6e6d8a37138a90c44a1.zip
Merging upstream version 1.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/mi-mctp.c')
-rw-r--r--test/mi-mctp.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/test/mi-mctp.c b/test/mi-mctp.c
index 5b1a154..6d83d42 100644
--- a/test/mi-mctp.c
+++ b/test/mi-mctp.c
@@ -308,7 +308,8 @@ static void test_admin_resp_err(nvme_mi_ep_t ep, struct test_peer *peer)
peer->tx_buf_len = 8;
rc = nvme_mi_admin_identify_ctrl(ctrl, &id);
- assert(rc == 0x2);
+ assert(nvme_status_get_type(rc) == NVME_STATUS_TYPE_MI);
+ assert(nvme_status_get_value(rc) == NVME_MI_RESP_INTERNAL_ERR);
}
/* test: all 4-byte aligned response sizes - should be decoded into the
@@ -332,7 +333,8 @@ static void test_admin_resp_sizes(nvme_mi_ep_t ep, struct test_peer *peer)
for (i = 8; i <= 4096 + 8; i+=4) {
peer->tx_buf_len = i;
rc = nvme_mi_admin_identify_ctrl(ctrl, &id);
- assert(rc == 2);
+ assert(nvme_status_get_type(rc) == NVME_STATUS_TYPE_MI);
+ assert(nvme_status_get_value(rc) == NVME_MI_RESP_INTERNAL_ERR);
}
nvme_mi_close_ctrl(ctrl);
@@ -407,6 +409,7 @@ static void test_poll_timeout(nvme_mi_ep_t ep, struct test_peer *peer)
/* test: send a More Processing Required response, then the actual response */
struct mpr_tx_info {
int msg_no;
+ bool admin_quirk;
size_t final_len;
};
@@ -422,6 +425,9 @@ static int tx_mpr(struct test_peer *peer, void *buf, size_t len)
case 1:
peer->tx_buf[4] = NVME_MI_RESP_MPR;
peer->tx_buf_len = 8;
+ if (tx_info->admin_quirk) {
+ peer->tx_buf_len = 20;
+ }
break;
case 2:
peer->tx_buf[4] = NVME_MI_RESP_SUCCESS;
@@ -446,6 +452,7 @@ static void test_mpr_mi(nvme_mi_ep_t ep, struct test_peer *peer)
tx_info.msg_no = 1;
tx_info.final_len = sizeof(struct nvme_mi_mi_resp_hdr) + sizeof(ss_info);
+ tx_info.admin_quirk = false;
peer->tx_fn = tx_mpr;
peer->tx_data = &tx_info;
@@ -463,6 +470,32 @@ static void test_mpr_admin(nvme_mi_ep_t ep, struct test_peer *peer)
tx_info.msg_no = 1;
tx_info.final_len = sizeof(struct nvme_mi_admin_resp_hdr) + sizeof(id);
+ tx_info.admin_quirk = false;
+
+ peer->tx_fn = tx_mpr;
+ peer->tx_data = &tx_info;
+
+ ctrl = nvme_mi_init_ctrl(ep, 1);
+
+ rc = nvme_mi_admin_identify_ctrl(ctrl, &id);
+ assert(rc == 0);
+
+ nvme_mi_close_ctrl(ctrl);
+}
+
+/* We have seen drives that send a MPR response as a full Admin message,
+ * rather than a MI message; these have a larger message body
+ */
+static void test_mpr_admin_quirked(nvme_mi_ep_t ep, struct test_peer *peer)
+{
+ struct mpr_tx_info tx_info;
+ struct nvme_id_ctrl id;
+ nvme_mi_ctrl_t ctrl;
+ int rc;
+
+ tx_info.msg_no = 1;
+ tx_info.final_len = sizeof(struct nvme_mi_admin_resp_hdr) + sizeof(id);
+ tx_info.admin_quirk = true;
peer->tx_fn = tx_mpr;
peer->tx_data = &tx_info;
@@ -638,6 +671,7 @@ struct test {
DEFINE_TEST(poll_timeout),
DEFINE_TEST(mpr_mi),
DEFINE_TEST(mpr_admin),
+ DEFINE_TEST(mpr_admin_quirked),
DEFINE_TEST(mpr_timeouts),
DEFINE_TEST(mpr_timeout_clamp),
DEFINE_TEST(mpr_mprt_zero),