Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3688fe9
map: merge all symbols into 2.0 section
igaw May 22, 2025
58a208c
ioctl: remove deprecated functions
igaw May 22, 2025
10f5612
src: merge libnvme-mi into libnvme
igaw May 28, 2025
5ee9fc9
api-types: replace nvme_root_t with struct nvme_global_ctx
igaw Jul 7, 2025
c1e294d
src: introduce transport handle abstraction
igaw May 26, 2025
d09b656
ioctl: fix get_log_partial to use uring for link type direct
ikegami-t Sep 2, 2025
66ada8d
api-types: remove unused fd members
igaw May 27, 2025
ce38166
linux: add nvme_transport_handle_get_fd
igaw May 28, 2025
25e6023
linux: add nvme_transport_handle_get_name
igaw Jun 4, 2025
e688581
linux: add nvme_transport_handle_is_{blk|char}dev
igaw Jun 5, 2025
a5eb5dd
mi: replace nvme_mi_ctrl_t with struct nvme_transport_handle
igaw Jul 7, 2025
a824d56
linux: add MI support to nvme_{open|close}
igaw Jul 8, 2025
ac306aa
linux: add nvme_transport_handle_is_{direct|mi}
igaw Jul 9, 2025
598def9
ioctl: add support for MI passthru
igaw Jul 8, 2025
e513d05
ioctl: add alignment and length check to nvme_fw_download
igaw Jun 11, 2025
73083ed
mi: replace dedicated MI API with generic one
igaw May 28, 2025
8539f0b
src: return error codes directly
igaw Jul 11, 2025
06333fd
ioctl: add nvme_identify_partial
igaw Jul 31, 2025
18cfbff
mi: remove nvme_mi_admin_identify{_partial}
igaw Jul 31, 2025
a5b5527
fabrics: fix nvme_get_adrfam function description parameter ctrl as c
ikegami-t Aug 11, 2025
184da6a
ioctl: rework nvme_identify commands
igaw Jul 31, 2025
089d4e1
test/mi: initialize struct args
igaw Oct 14, 2025
ae7c790
build: enable verbose testing
igaw Oct 14, 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
Expand Up @@ -51,30 +51,32 @@ static void print_discover_log(struct nvmf_discovery_log *log)
int main()
{
struct nvmf_discovery_log *log = NULL;
nvme_root_t r;
struct nvme_global_ctx *ctx;
nvme_host_t h;
nvme_ctrl_t c;
int ret;
struct nvme_fabrics_config cfg;

nvmf_default_config(&cfg);

r = nvme_scan(NULL);
h = nvme_default_host(r);
if (!h) {
ret = nvme_scan(NULL, &ctx);
if (ret)
return ret;
ret = nvme_default_host(ctx, &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(ctx, 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 All @@ -86,7 +88,7 @@ int main()
else
print_discover_log(log);

nvme_free_tree(r);
nvme_free_global_ctx(ctx);
free(log);
return 0;
}
12 changes: 5 additions & 7 deletions examples/display-columnar.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,20 @@
static const char dash[101] = {[0 ... 99] = '-'};
int main()
{
nvme_root_t r;
struct nvme_global_ctx *ctx;
nvme_host_t h;
nvme_subsystem_t s;
nvme_ctrl_t c;
nvme_path_t p;
nvme_ns_t n;

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


printf("%-16s %-96s %-.16s\n", "Subsystem", "Subsystem-NQN", "Controllers");
printf("%-.16s %-.96s %-.16s\n", dash, dash, dash);

nvme_for_each_host(r, h) {
nvme_for_each_host(ctx, h) {
nvme_for_each_subsystem(h, s) {
bool first = true;
printf("%-16s %-96s ", nvme_subsystem_get_name(s),
Expand All @@ -53,7 +51,7 @@ int main()
printf("%-.8s %-.20s %-.40s %-.8s %-.6s %-.14s %-.12s %-.16s\n", dash, dash,
dash, dash, dash, dash, dash, dash);

nvme_for_each_host(r, h) {
nvme_for_each_host(ctx, h) {
nvme_for_each_subsystem(h, s) {
nvme_subsystem_for_each_ctrl(s, c) {
bool first = true;
Expand Down Expand Up @@ -87,7 +85,7 @@ int main()
printf("%-12s %-8s %-16s %-8s %-16s\n", "Device", "NSID", "Sectors", "Format", "Controllers");
printf("%-.12s %-.8s %-.16s %-.8s %-.16s\n", dash, dash, dash, dash, dash);

nvme_for_each_host(r, h) {
nvme_for_each_host(ctx, h) {
nvme_for_each_subsystem(h, s) {
nvme_subsystem_for_each_ctrl(s, c) {
nvme_ctrl_for_each_ns(c, n)
Expand Down
9 changes: 4 additions & 5 deletions examples/display-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,18 @@

int main()
{
nvme_root_t r;
struct nvme_global_ctx *ctx;
nvme_host_t h;
nvme_subsystem_t s, _s;
nvme_ctrl_t c, _c;
nvme_path_t p, _p;
nvme_ns_t n, _n;

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

printf(".\n");
nvme_for_each_host(r, h) {
nvme_for_each_host(ctx, h) {
nvme_for_each_subsystem_safe(h, s, _s) {
printf("%c-- %s - NQN=%s\n", _s ? '|' : '`',
nvme_subsystem_get_name(s),
Expand Down Expand Up @@ -67,6 +66,6 @@ int main()
}
}
}
nvme_free_tree(r);
nvme_free_global_ctx(ctx);
return 0;
}
8 changes: 4 additions & 4 deletions examples/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,29 @@ executable(
executable(
'mi-mctp',
['mi-mctp.c'],
dependencies: libnvme_mi_dep,
dependencies: libnvme_dep,
include_directories: [incdir, internal_incdir]
)

executable(
'mi-mctp-csi-test',
['mi-mctp-csi-test.c'],
dependencies: [libnvme_mi_dep, threads_dep],
dependencies: [libnvme_dep, threads_dep],
include_directories: [incdir, internal_incdir]
)

executable(
'mi-mctp-ae',
['mi-mctp-ae.c'],
dependencies: libnvme_mi_dep,
dependencies: libnvme_dep,
include_directories: [incdir, internal_incdir]
)

if libdbus_dep.found()
executable(
'mi-conf',
['mi-conf.c'],
dependencies: [libnvme_mi_dep, libdbus_dep],
dependencies: [libnvme_dep, libdbus_dep],
include_directories: [incdir, internal_incdir]
)
endif
16 changes: 8 additions & 8 deletions examples/mi-conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ int set_local_mtu(DBusConnection *bus, unsigned int net, uint8_t eid,

int main(int argc, char **argv)
{
struct nvme_global_ctx *ctx;
uint16_t cur_mtu, mtu;
DBusConnection *bus;
const char *devstr;
uint8_t eid, port;
nvme_root_t root;
unsigned int net;
nvme_mi_ep_t ep;
DBusError berr;
Expand All @@ -157,14 +157,14 @@ int main(int argc, char **argv)
if (rc)
errx(EXIT_FAILURE, "can't parse MI device string '%s'", devstr);

root = nvme_mi_create_root(stderr, DEFAULT_LOGLEVEL);
if (!root)
err(EXIT_FAILURE, "can't create NVMe root");
ctx = nvme_mi_create_global_ctx(stderr, DEFAULT_LOGLEVEL);
if (!ctx)
err(EXIT_FAILURE, "can't create global context");

ep = nvme_mi_open_mctp(root, net, eid);
ep = nvme_mi_open_mctp(ctx, net, eid);
if (!ep) {
warnx("can't open MCTP endpoint %d:%d", net, eid);
goto out_free_root;
goto out_free_ctx;
}

dbus_error_init(&berr);
Expand Down Expand Up @@ -218,8 +218,8 @@ int main(int argc, char **argv)
out_close_ep:
dbus_error_free(&berr);
nvme_mi_close(ep);
out_free_root:
nvme_mi_free_root(root);
out_free_ctx:
nvme_mi_free_global_ctx(ctx);

return rc ? EXIT_FAILURE : EXIT_SUCCESS;
}
Expand Down
12 changes: 6 additions & 6 deletions examples/mi-mctp-ae.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ enum nvme_mi_aem_handler_next_action aem_handler(nvme_mi_ep_t ep, size_t num_eve

int main(int argc, char **argv)
{
nvme_root_t root;
struct nvme_global_ctx *ctx;
nvme_mi_ep_t ep;
uint8_t eid = 0;
int rc = 0, net = 0;
Expand Down Expand Up @@ -109,11 +109,11 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}

root = nvme_mi_create_root(stderr, DEFAULT_LOGLEVEL);
if (!root)
ctx = nvme_mi_create_global_ctx(stderr, DEFAULT_LOGLEVEL);
if (!ctx)
err(EXIT_FAILURE, "can't create NVMe root");

ep = nvme_mi_open_mctp(root, net, eid);
ep = nvme_mi_open_mctp(ctx, net, eid);
if (!ep)
err(EXIT_FAILURE, "can't open MCTP endpoint %d:%d", net, eid);

Expand All @@ -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 Expand Up @@ -173,7 +173,7 @@ int main(int argc, char **argv)
//Cleanup
nvme_mi_aem_disable(ep);
nvme_mi_close(ep);
nvme_mi_free_root(root);
nvme_mi_free_global_ctx(ctx);

return rc ? EXIT_FAILURE : EXIT_SUCCESS;
}
Expand Down
28 changes: 14 additions & 14 deletions examples/mi-mctp-csi-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,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 };
struct nvme_mi_ctrl *ctrl;
struct nvme_transport_handle *hdl;
uint8_t buf[4096];
uint16_t ctrl_id;
int rc, tmp;
Expand Down Expand Up @@ -86,13 +86,13 @@ int do_get_log_page(nvme_mi_ep_t ep, int argc, char **argv)
args.lid = 0x1;
}

ctrl = nvme_mi_init_ctrl(ep, ctrl_id);
if (!ctrl) {
hdl = nvme_mi_init_transport_handle(ep, ctrl_id);
if (!hdl) {
warn("can't create controller");
return -1;
}

rc = nvme_mi_admin_get_log(ctrl, &args);
rc = nvme_get_log(hdl, &args);
if (rc) {
warn("can't perform Get Log page command");
return -1;
Expand Down Expand Up @@ -123,16 +123,16 @@ enum action {
ACTION_CSI_TEST,
};

int do_csi_test(nvme_root_t root, int net, __u8 eid,
int do_csi_test(struct nvme_global_ctx *ctx, int net, __u8 eid,
int argc, char **argv)
{
int rc = 0;
nvme_mi_ep_t ep1, ep2;

ep1 = nvme_mi_open_mctp(root, net, eid);
ep1 = nvme_mi_open_mctp(ctx, net, eid);
if (!ep1)
errx(EXIT_FAILURE, "can't open MCTP endpoint %d:%d", net, eid);
ep2 = nvme_mi_open_mctp(root, net, eid);
ep2 = nvme_mi_open_mctp(ctx, net, eid);
if (!ep2)
errx(EXIT_FAILURE, "can't open MCTP endpoint %d:%d", net, eid);

Expand Down Expand Up @@ -176,7 +176,7 @@ int do_csi_test(nvme_root_t root, int net, __u8 eid,
}

static int do_action_endpoint(enum action action,
nvme_root_t root,
struct nvme_global_ctx *ctx,
int net,
uint8_t eid,
int argc,
Expand All @@ -186,7 +186,7 @@ static int do_action_endpoint(enum action action,

switch (action) {
case ACTION_CSI_TEST:
rc = do_csi_test(root, net, eid, argc, argv);
rc = do_csi_test(ctx, net, eid, argc, argv);
break;
default:
/* This shouldn't be possible, as we should be covering all
Expand All @@ -201,8 +201,8 @@ static int do_action_endpoint(enum action action,

int main(int argc, char **argv)
{
struct nvme_global_ctx *ctx;
enum action action;
nvme_root_t root;
bool usage = true;
uint8_t eid = 0;
int rc = 0, net = 0;
Expand Down Expand Up @@ -238,12 +238,12 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}

root = nvme_mi_create_root(stderr, DEFAULT_LOGLEVEL);
if (!root)
ctx = nvme_mi_create_global_ctx(stderr, DEFAULT_LOGLEVEL);
if (!ctx)
err(EXIT_FAILURE, "can't create NVMe root");

rc = do_action_endpoint(action, root, net, eid, argc, argv);
nvme_mi_free_root(root);
rc = do_action_endpoint(action, ctx, net, eid, argc, argv);
nvme_mi_free_global_ctx(ctx);

return rc ? EXIT_FAILURE : EXIT_SUCCESS;
}
Expand Down
Loading
Loading