Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
6a9055e
ioctl: add alignment and length check to nvme_fw_download
igaw Jun 11, 2025
02a6c99
mi: replace dedicated MI API with generic one
igaw May 28, 2025
2eda4ff
src: return error codes directly
igaw Jul 11, 2025
1a5d92a
ioctl: add nvme_identify_partial
igaw Jul 31, 2025
5d72c99
mi: remove nvme_mi_admin_identify{_partial}
igaw Jul 31, 2025
4746c71
fabrics: fix nvme_get_adrfam function description parameter ctrl as c
ikegami-t Aug 11, 2025
7d577d4
ioctl: nvme_identify use nvme_passthru_cmd directly
igaw Jul 31, 2025
ca46183
ioctl: reorder nvme_get_log and nvme_get_log_page
igaw Jul 30, 2025
6168c3f
ioctl: nvme_get_log use nvme_passthru_cmd directly
igaw Jul 29, 2025
b57e39d
test: fix rae and lsp handling in log page tests
igaw Aug 8, 2025
e1a11b7
ioctl: nvme_format_nvm use nvme_passthru_cmd directly
igaw Aug 1, 2025
40fd74c
ioctl: nvme_ns_mgmt use nvme_passthru_cmd directly
igaw Aug 1, 2025
aeaeb7e
ioctl: nvme_ns_attach use nvme_passthru_cmd directly
igaw Aug 1, 2025
14b9a6e
ioctl: nvme_ns_download use nvme_passthru_cmd directly
igaw Aug 1, 2025
2beb025
ioctl: nvme_fw_commit use nvme_passthru_cmd directly
igaw Aug 1, 2025
2dff827
ioctl: nvme_security_send use nvme_passthru_cmd directly
igaw Aug 1, 2025
130cb1f
ioctl: nvme_set_features use nvme_passthru_cmd directly
MaisenbacherD Jul 30, 2025
d462209
ioctl: nvme_dsm use nvme_passthru_cmd directly
ikegami-t Aug 2, 2025
6dc4423
ioctl: nvme_io use nvme_passthru_cmd directly
ikegami-t Aug 2, 2025
6f94eb7
ioctl: update nvme_io related APIs
igaw Sep 16, 2025
00a44f2
ioctl: add dsm and io commands dword fields
ikegami-t Aug 3, 2025
f565244
ioctl: nvme_copy use nvme_passthru_cmd directly
ikegami-t Aug 4, 2025
67b7d36
ioctl: nvme_copy update API
igaw Sep 16, 2025
74e10c1
ioctl: nvme_resv_acquire use nvme_passthru_cmd directly
ikegami-t Aug 10, 2025
069c154
ioctl: nvme_resv_register use nvme_passthru_cmd directly
ikegami-t Aug 10, 2025
cb16144
ioctl: nvme_resv_release use nvme_passthru_cmd directly
ikegami-t Aug 10, 2025
4714011
ioctl: nvme_resv_report use nvme_passthru_cmd directly
ikegami-t Aug 10, 2025
2a250e4
ioctl: nvme_io_mgmt_recv use nvme_passthru_cmd directly
ikegami-t Aug 11, 2025
2698fbe
ioctl: nvme_io_mgmt_send use nvme_passthru_cmd directly
ikegami-t Aug 11, 2025
fc57aef
ioctl: nvme_zns_mgmt_send use nvme_passthru_cmd directly
ikegami-t Aug 11, 2025
ef451c8
ioctl: nvme_zns_mgmt_recv use nvme_passthru_cmd directly
ikegami-t Aug 11, 2025
f68a516
ioctl: nvme_zns_append use nvme_passthru_cmd directly
ikegami-t Aug 11, 2025
8a90568
ioctl: nvme_dim_send use nvme_passthru_cmd directly
ikegami-t Aug 11, 2025
5db9aab
ioctl: nvme_lm_cdq use nvme_passthru_cmd directly
ikegami-t Aug 11, 2025
f255641
ioctl: nvme_lm_track_send use nvme_passthru_cmd directly
ikegami-t Aug 11, 2025
9dc5da6
ioctl: nvme_lm_migration_send use nvme_passthru_cmd directly
ikegami-t Aug 11, 2025
040c69a
ioctl: nvme_lm_migration_recv use nvme_passthru_cmd directly
ikegami-t Aug 11, 2025
6b75082
ioctl: nvme_security_receive use nvme_passthru_cmd directly
ikegami-t Aug 25, 2025
65e3db2
ioctl: nvme_get_lba_status use nvme_passthru_cmd directly
ikegami-t Aug 31, 2025
86d6cc8
ioctl: nvme_directive_send use nvme_passthru_cmd directly
ikegami-t Aug 31, 2025
9b45bbc
ioctl: nvme_directive_recv use nvme_passthru_cmd directly
ikegami-t Aug 31, 2025
4c4c184
ioctl: nvme_virtual_mgmt use nvme_passthru_cmd directly
ikegami-t Aug 31, 2025
ca4b955
ioctl: nvme_dev_self_test use nvme_passthru_cmd directly
ikegami-t Aug 31, 2025
c43d1a8
ioctl: nvme_sanitize_nvm use nvme_passthru_cmd directly
ikegami-t Aug 31, 2025
0ad8528
ioctl: nvme_get_property use nvme_passthru_cmd directly
ikegami-t Aug 31, 2025
5dd87e1
ioctl: nvme_set_property use nvme_passthru_cmd directly
ikegami-t Aug 31, 2025
abbd64e
ioctl: nvme_lockdown use nvme_passthru_cmd directly
ikegami-t Aug 31, 2025
27d4dae
ioctl: nvme_capacity_mgmt use nvme_passthru_cmd directly
ikegami-t Sep 5, 2025
69688b9
ioctl: nvme_get_features use nvme_passthru_cmd directly
MaisenbacherD Aug 11, 2025
1d86c10
ioctl: remove unused enum features
igaw Sep 5, 2025
e95463c
ioctl: refactor nvme_get_log_partial uring
ikegami-t Sep 3, 2025
44d4349
test/zns: fix kernel-doc-check warnings
ikegami-t Aug 19, 2025
14db866
examples: fix mi-mctp.c kernel-doc-check warning
ikegami-t Aug 25, 2025
7fbdb8b
examples: do not use "/**" opening comment mark
ikegami-t Sep 2, 2025
e8528de
test: fix mi.c kernel-doc-check warning
ikegami-t Aug 31, 2025
f8c827c
ioctl: Rename NVME_NVM_CDW* SHIFT and MASK enum members
MaisenbacherD Sep 19, 2025
2803bfb
ioctl: Fix nvme_zns_append PI tag parsing.
MaisenbacherD Sep 19, 2025
feb92bd
ioctl: introduce SHIFT MASK enum for nvme_zns_append
MaisenbacherD Sep 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions examples/discover-loop.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/**
/*
* This file is part of libnvme.
* Copyright (c) 2020 Western Digital Corporation or its affiliates.
*
* Authors: Keith Busch <[email protected]>
*/

/**
/*
* discover-loop: Use fabrics commands to discover any loop targets and print
* those records. You must have at least one configured nvme loop target on the
* system (no existing connection required). The output will look more
Expand Down Expand Up @@ -59,22 +59,24 @@ int main()

nvmf_default_config(&cfg);

r = nvme_scan(NULL);
h = nvme_default_host(r);
if (!h) {
ret = nvme_scan(NULL, &r);
if (ret)
return ret;
ret = nvme_default_host(r, &h);
if (ret) {
fprintf(stderr, "Failed to allocated memory\n");
return ENOMEM;
return ret;
}
c = nvme_create_ctrl(r, NVME_DISC_SUBSYS_NAME, "loop",
NULL, NULL, NULL, NULL);
if (!c) {
ret = nvme_create_ctrl(r, NVME_DISC_SUBSYS_NAME, "loop",
NULL, NULL, NULL, NULL, &c);
if (ret) {
fprintf(stderr, "Failed to allocate memory\n");
return ENOMEM;
}
ret = nvmf_add_ctrl(h, c, &cfg);
if (ret < 0) {
if (ret) {
fprintf(stderr, "no controller found\n");
return errno;
return ret;
}

ret = nvmf_get_discovery_log(c, &log, 4);
Expand Down
7 changes: 3 additions & 4 deletions examples/display-columnar.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/**
/*
* This file is part of libnvme.
* Copyright (c) 2020 Western Digital Corporation or its affiliates.
*
* Authors: Keith Busch <[email protected]>
*/

/**
/*
* display-columnar: Scans the nvme topology, prints each record type in a
* column format for easy visual scanning.
*/
Expand All @@ -24,8 +24,7 @@ int main()
nvme_path_t p;
nvme_ns_t n;

r = nvme_scan(NULL);
if (!r)
if (nvme_scan(NULL, &r))
return -1;


Expand Down
7 changes: 3 additions & 4 deletions examples/display-tree.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/**
/*
* This file is part of libnvme.
* Copyright (c) 2020 Western Digital Corporation or its affiliates.
*
* Authors: Keith Busch <[email protected]>
*/

/**
/*
* display-tree: Scans the nvme topology, prints as an ascii tree with some
* selected attributes for each component.
*/
Expand All @@ -23,8 +23,7 @@ int main()
nvme_path_t p, _p;
nvme_ns_t n, _n;

r = nvme_scan(NULL);
if (!r)
if (nvme_scan(NULL, &r))
return -1;

printf(".\n");
Expand Down
4 changes: 2 additions & 2 deletions examples/mi-conf.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/**
/*
* This file is part of libnvme.
* Copyright (c) 2022 Code Construct Pty Ltd.
*
* Authors: Jeremy Kerr <[email protected]>
*/

/**
/*
* mi-conf: query a device for optimal MTU and set for both the local MCTP
* route (through dbus to mctpd) and the device itself (through NVMe-MI
* configuration commands)
Expand Down
6 changes: 3 additions & 3 deletions examples/mi-mctp-ae.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/**
/*
* This file is part of libnvme.
*/

/**
/*
* mi-mctp-ae: open a MI connection over MCTP, supporting asynchronous event messages
*/

Expand Down Expand Up @@ -131,7 +131,7 @@ int main(int argc, char **argv)
}

rc = nvme_mi_aem_enable(ep, &aem_config, &data);
if (rc && errno == EOPNOTSUPP)
if (rc == EOPNOTSUPP)
errx(EXIT_FAILURE, "MCTP Peer-Bind is required for AEM");
else if (rc)
err(EXIT_FAILURE, "Can't enable aem:%d", rc);
Expand Down
24 changes: 12 additions & 12 deletions examples/mi-mctp-csi-test.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/**
/*
* This file is part of libnvme.
*/

/**
/*
* mi-mctp-csi-test: open a MI connection over MCTP, and send two commands
* in parallel with different CSI buffers
*/
Expand Down Expand Up @@ -56,7 +56,7 @@ void hexdump(const unsigned char *buf, int len)

int do_get_log_page(nvme_mi_ep_t ep, int argc, char **argv)
{
struct nvme_get_log_args args = { 0 };
enum nvme_cmd_get_log_lid lid;
struct nvme_link *link;
uint8_t buf[4096];
uint16_t ctrl_id;
Expand All @@ -75,15 +75,11 @@ int do_get_log_page(nvme_mi_ep_t ep, int argc, char **argv)

ctrl_id = tmp & 0xffff;

args.args_size = sizeof(args);
args.log = buf;
args.len = sizeof(buf);

if (argc > 2) {
tmp = atoi(argv[2]);
args.lid = tmp & 0xff;
lid = tmp & 0xff;
} else {
args.lid = 0x1;
lid = 0x1;
}

link = nvme_mi_init_link(ep, ctrl_id);
Expand All @@ -92,14 +88,18 @@ int do_get_log_page(nvme_mi_ep_t ep, int argc, char **argv)
return -1;
}

rc = nvme_mi_admin_get_log(link, &args);
rc = nvme_get_log(link, NVME_NSID_NONE, false, NVME_LOG_LSP_NONE,
lid, NVME_LOG_LSI_NONE, NVME_CSI_NVM,
false, NVME_UUID_NONE,
0, buf, sizeof(buf),
sizeof(buf), NULL);
if (rc) {
warn("can't perform Get Log page command");
return -1;
}

printf("Get log page (log id = 0x%02x) data:\n", args.lid);
hexdump(buf, args.len);
printf("Get log page (log id = 0x%02x) data:\n", lid);
hexdump(buf, sizeof(buf));

return 0;
}
Expand Down
63 changes: 27 additions & 36 deletions examples/mi-mctp.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/**
/*
* This file is part of libnvme.
* Copyright (c) 2021 Code Construct Pty Ltd.
*
* Authors: Jeremy Kerr <[email protected]>
*/

/**
/*
* mi-mctp: open a MI connection over MCTP, and query controller info
*/

Expand Down Expand Up @@ -178,7 +178,6 @@ static const char *__copy_id_str(const void *field, size_t size,

int do_identify(nvme_mi_ep_t ep, int argc, char **argv)
{
struct nvme_identify_args id_args = { 0 };
struct nvme_link *link;
struct nvme_id_ctrl id;
uint16_t ctrl_id;
Expand Down Expand Up @@ -207,23 +206,19 @@ int do_identify(nvme_mi_ep_t ep, int argc, char **argv)
return -1;
}

id_args.data = &id;
id_args.args_size = sizeof(id_args);
id_args.cns = NVME_IDENTIFY_CNS_CTRL;
id_args.nsid = NVME_NSID_NONE;
id_args.cntid = 0;
id_args.csi = NVME_CSI_NVM;

/* for this example code, we can either do a full or partial identify;
* since we're only printing the fields before the 'rab' member,
* these will be equivalent, aside from the size of the MI
* response.
*/
if (partial) {
rc = nvme_mi_admin_identify_partial(link, &id_args, 0,
offsetof(struct nvme_id_ctrl, rab));
rc = nvme_identify_partial(link, NVME_NSID_NONE, 0, NVME_IDENTIFY_CNS_CTRL,
NVME_CSI_NVM, 0, 0, &id,
offsetof(struct nvme_id_ctrl, rab),
NULL);
} else {
rc = nvme_mi_admin_identify(link, &id_args);
rc = nvme_identify(link, NVME_NSID_NONE, 0, NVME_IDENTIFY_CNS_CTRL,
NVME_CSI_NVM, 0, 0, &id, NULL);
}

if (rc) {
Expand Down Expand Up @@ -373,7 +368,7 @@ void hexdump(const unsigned char *buf, int len)

int do_get_log_page(nvme_mi_ep_t ep, int argc, char **argv)
{
struct nvme_get_log_args args = { 0 };
enum nvme_cmd_get_log_lid lid;
struct nvme_link *link;
uint8_t buf[512];
uint16_t ctrl_id;
Expand All @@ -392,15 +387,11 @@ int do_get_log_page(nvme_mi_ep_t ep, int argc, char **argv)

ctrl_id = tmp & 0xffff;

args.args_size = sizeof(args);
args.log = buf;
args.len = sizeof(buf);

if (argc > 2) {
tmp = atoi(argv[2]);
args.lid = tmp & 0xff;
lid = tmp & 0xff;
} else {
args.lid = 0x1;
lid = 0x1;
}

link = nvme_mi_init_link(ep, ctrl_id);
Expand All @@ -409,14 +400,18 @@ int do_get_log_page(nvme_mi_ep_t ep, int argc, char **argv)
return -1;
}

rc = nvme_mi_admin_get_log(link, &args);
rc = nvme_get_log(link, NVME_NSID_NONE, false, NVME_LOG_LSP_NONE,
lid, NVME_LOG_LSI_NONE, NVME_CSI_NVM,
false, NVME_UUID_NONE,
0, buf, sizeof(buf),
sizeof(buf), NULL);
if (rc) {
warn("can't perform Get Log page command");
return -1;
}

printf("Get log page (log id = 0x%02x) data:\n", args.lid);
hexdump(buf, args.len);
printf("Get log page (log id = 0x%02x) data:\n", lid);
hexdump(buf, sizeof(buf));

return 0;
}
Expand Down Expand Up @@ -542,7 +537,6 @@ static const char *sec_proto_description(uint8_t id)

int do_security_info(nvme_mi_ep_t ep, int argc, char **argv)
{
struct nvme_security_receive_args args = { 0 };
nvme_link_t link;
int i, rc, n_proto;
unsigned long tmp;
Expand All @@ -552,6 +546,9 @@ int do_security_info(nvme_mi_ep_t ep, int argc, char **argv)
uint16_t len;
uint8_t protocols[256];
} proto_info;
/* protocol 0x00, spsp 0x0000: retrieve supported protocols */
void *data = &proto_info;
__u32 data_len = sizeof(proto_info);

if (argc != 2) {
fprintf(stderr, "no controller ID specified\n");
Expand All @@ -572,27 +569,21 @@ int do_security_info(nvme_mi_ep_t ep, int argc, char **argv)
return -1;
}

/* protocol 0x00, spsp 0x0000: retrieve supported protocols */
args.args_size = sizeof(args);
args.data = &proto_info;
args.data_len = sizeof(proto_info);

rc = nvme_mi_admin_security_recv(link, &args);
rc = nvme_security_receive(link, 0, 0, 0, 0, 0, 0, data, data_len, NULL);
if (rc) {
warnx("can't perform Security Receive command: rc %d", rc);
return -1;
}

if (args.data_len < 6) {
warnx("Short response in security receive command (%d bytes)",
args.data_len);
if (data_len < 6) {
warnx("Short response in security receive command (%d bytes)", data_len);
return -1;
}

n_proto = be16_to_cpu(proto_info.len);
if (args.data_len < 6 + n_proto) {
warnx("Short response in security receive command (%d bytes), "
"for %d protocols", args.data_len, n_proto);
if (data_len < 6 + n_proto) {
warnx("Short response in security receive command (%d bytes), for %d protocols",
data_len, n_proto);
return -1;
}

Expand Down
7 changes: 3 additions & 4 deletions examples/telemetry-listen.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/**
/*
* This file is part of libnvme.
* Copyright (c) 2020 Western Digital Corporation or its affiliates.
*
* Authors: Keith Busch <[email protected]>
*/

/**
/*
* Open all nvme controller's uevent and listen for changes. If NVME_AEN event
* is observed with controller telemetry data, read the log and save it to a
* file in /var/log/ with the device's unique name and epoch timestamp.
Expand Down Expand Up @@ -134,8 +134,7 @@ int main()
nvme_host_t h;
nvme_root_t r;

r = nvme_scan(NULL);
if (!r)
if (nvme_scan(NULL, &r))
return EXIT_FAILURE;

nvme_for_each_host(r, h)
Expand Down
Loading