Skip to content

Commit 8556da5

Browse files
authored
Merge pull request #400 from CodeConstruct/mi-test-ep-init
MI: reinstate nvme_mi_init_ep for endpoint initialisation in test
2 parents 8982344 + ce4a044 commit 8556da5

2 files changed

Lines changed: 12 additions & 17 deletions

File tree

src/libnvme-mi.map

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ LIBNVME_MI_1_1 {
1919
local:
2020
*;
2121
};
22+
# API exported only for libnvme-mi internal test functions. These should
23+
# not be used other than through the in-tree tests, and cannot be considered
24+
# at all stable.
25+
LIBNVME_MI_TEST {
26+
global:
27+
nvme_mi_init_ep;
28+
nvme_mi_crc32_update;
29+
};

test/mi.c

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,6 @@ struct test_transport_data {
3030

3131
static const int test_transport_magic = 0x74657374;
3232

33-
static __u32 crc32_update(__u32 crc, void *data, size_t len)
34-
{
35-
int i;
36-
37-
while (len--) {
38-
crc ^= *(unsigned char *)(data++);
39-
for (i = 0; i < 8; i++)
40-
crc = (crc >> 1) ^ ((crc & 1) ? 0x82F63B78 : 0);
41-
}
42-
return crc;
43-
}
44-
4533
static int test_transport_submit(struct nvme_mi_ep *ep,
4634
struct nvme_mi_req *req,
4735
struct nvme_mi_resp *resp)
@@ -70,11 +58,11 @@ static void test_transport_close(struct nvme_mi_ep *ep)
7058
/* internal test helper to generate correct response crc */
7159
static void test_transport_resp_calc_mic(struct nvme_mi_resp *resp)
7260
{
73-
extern __u32 crc32_update(__u32 crc, void *data, size_t len);
61+
extern __u32 nvme_mi_crc32_update(__u32 crc, void *data, size_t len);
7462
__u32 crc = 0xffffffff;
7563

76-
crc = crc32_update(crc, resp->hdr, resp->hdr_len);
77-
crc = crc32_update(crc, resp->data, resp->data_len);
64+
crc = nvme_mi_crc32_update(crc, resp->hdr, resp->hdr_len);
65+
crc = nvme_mi_crc32_update(crc, resp->data, resp->data_len);
7866

7967
resp->mic = ~crc;
8068
}
@@ -101,9 +89,8 @@ nvme_mi_ep_t nvme_mi_open_test(nvme_root_t root)
10189
struct test_transport_data *tpd;
10290
struct nvme_mi_ep *ep;
10391

104-
ep = malloc(sizeof(*ep));
92+
ep = nvme_mi_init_ep(root);
10593
assert(ep);
106-
ep->root = root;
10794

10895
tpd = malloc(sizeof(*tpd));
10996
assert(tpd);

0 commit comments

Comments
 (0)