Skip to content

Commit 28b0e03

Browse files
ikegami-tigaw
authored andcommitted
mi: add nvme_mi_submit entry and exit weak functions
These are for the user to implement their own logging. Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
1 parent 04061b4 commit 28b0e03

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/libnvme-mi.map

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# SPDX-License-Identifier: LGPL-2.1-or-later
22
LIBNVME_MI_UNRELEASED {
3+
global:
4+
nvme_mi_submit_entry;
5+
nvme_mi_submit_exit;
36
};
47

58
LIBNVME_MI_1_12 {

src/nvme/mi.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,24 @@ static int nvme_mi_verify_resp_mic(struct nvme_mi_resp *resp)
414414
return resp->mic != ~crc;
415415
}
416416

417+
__attribute__((weak)) void *nvme_mi_submit_entry(__u8 type, const struct nvme_mi_msg_hdr *hdr,
418+
size_t hdr_len, const void *data, size_t data_len)
419+
{
420+
return NULL;
421+
}
422+
423+
__attribute__((weak)) void nvme_mi_submit_exit(__u8 type, const struct nvme_mi_msg_hdr *hdr,
424+
size_t hdr_len, const void *data, size_t data_len,
425+
void *user_data) { }
426+
417427
int nvme_mi_submit(nvme_mi_ep_t ep, struct nvme_mi_req *req,
418428
struct nvme_mi_resp *resp)
419429
{
420430
int rc;
431+
void *user_data;
432+
433+
user_data = nvme_mi_submit_entry(req->hdr->type, req->hdr, req->hdr_len, req->data,
434+
req->data_len);
421435

422436
if (req->hdr_len < sizeof(struct nvme_mi_msg_hdr)) {
423437
errno = EINVAL;
@@ -502,6 +516,9 @@ int nvme_mi_submit(nvme_mi_ep_t ep, struct nvme_mi_req *req,
502516
return -1;
503517
}
504518

519+
nvme_mi_submit_exit(resp->hdr->type, resp->hdr, resp->hdr_len, resp->data, resp->data_len,
520+
user_data);
521+
505522
return 0;
506523
}
507524

0 commit comments

Comments
 (0)