Skip to content

Commit 2af0809

Browse files
committed
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 <[email protected]>
1 parent 97f4883 commit 2af0809

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

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: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,21 @@ 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 void *hdr, size_t hdr_len,
418+
const void *data, size_t data_len) { return NULL; }
419+
420+
__attribute__((weak)) void nvme_mi_submit_exit(__u8 type, const void *hdr, size_t hdr_len,
421+
const void *data, size_t data_len, void *user_data)
422+
{ }
423+
417424
int nvme_mi_submit(nvme_mi_ep_t ep, struct nvme_mi_req *req,
418425
struct nvme_mi_resp *resp)
419426
{
420427
int rc;
428+
void *user_data;
429+
430+
user_data = nvme_mi_submit_entry(req->hdr->type, req->hdr, req->hdr_len, req->data,
431+
req->data_len);
421432

422433
if (req->hdr_len < sizeof(struct nvme_mi_msg_hdr)) {
423434
errno = EINVAL;
@@ -502,6 +513,9 @@ int nvme_mi_submit(nvme_mi_ep_t ep, struct nvme_mi_req *req,
502513
return -1;
503514
}
504515

516+
nvme_mi_submit_exit(resp->hdr->type, resp->hdr, resp->hdr_len, resp->data, resp->data_len,
517+
user_data);
518+
505519
return 0;
506520
}
507521

0 commit comments

Comments
 (0)