Skip to content

Conversation

@MaisenbacherD
Copy link

This function was dropped with the ioctl changes. However, it is part of src/nvme/util.h and needs to stay.

Fixes Issue #40

igaw and others added 30 commits July 28, 2025 16:44
libnvme-mi was added after the initial 1.x release and it was decided to
ship it independ of libnvme. With the upcoming 2.x work, merge the two
libraries so it's possible to use common code, that is unify the APIs.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
The root object will not only be used by the tree API, instead it will
be used as default context for the complete API. This addresses the
shortcoming that 'global' variables such as the logging infrastructure
should not be library global variables.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
Abstract the file descriptor handle to a more abstract type so it's
possible to use different 'backends' to send/receive commands, e.g.
via MI instead direct.

The name 'link' was chosen because this name is not in use and thus we
avoid overloading existing names, such ctrl. The specification is using
'link' to describe the connection on a PCI bus which is kind of matching
how the handle is used in the library. It is the means to talk to a
controller.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
Since uring not supported for link type mi.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
There is no user left for the file descriptor in the args structs,
thus remove it.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
When the user provides their own implementation of the passtrhu
function, it is necessary to use the file descriptor for the ioctl call.
Thus allow to retrieve the file descriptor from the link handle.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
nvme-cli wants to retrieve the name of the device, add a getter for
this.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
The nvme_link_t type is used for block device and char device. User
application sometimes need to figure out which type of device is used.
Because libnvme already knows the type of device expose this. This
avoids tracking of the device type in the user application.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
nvme_link_t in place, it's possible to replace nvme_mi_ctrl_t with the
generic transport abstraction type.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
Extend nvme_open and nvme_close to handle MI devices.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
The nvme_link_t type is used to abstract the transport type. User
application sometimes need to figure out which type of device is used.
Because libnvme already knows the type of device expose this. This
avoids tracking of the device type in the user application.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
Hook up the MI backend to the generic commands API.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
The MI code has an alignment and length check which the direct APIs are
missing. Without these checks the download tests for MI will fail after
using the generic APIs.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
With the introduction of the link handle, it's possible to use the
generic nvme API. The transport selection happens on lower levels
depending on the link object type.

Note, the tests rely on using the ioctl interface and not the io_uring.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
The v1 design used the POSIX way to return errors, return -1 with errno
set.

Replace this design by returning directly the error code. That means non
trivial function have to return any data via a pointer so the function
is able to return proper error codes.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
MI doesn't access the complete identify data struct and thus
only transfers a port of it. Add a generic version of this
function.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
Use the generic nvme_identify{_partial} interface and drop
the MI specific version.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
Since the warning message output by kernel-doc-check.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
[dennis: fix example]
Signed-off-by: Dennis Maisenbacher <dennis.maisenbacher@wdc.com>
Signed-off-by: Daniel Wagner <wagi@kernel.org>
The next change will add a static inline implementation of nvme_get_log
which uses nvme_get_log_page. Thus move the nvme_get_log_page function
up so it can be used directly.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
Refactor nvme_get_log and nvme_get_log_page to use struct
nvme_passthru_cmd directly and drop the struct nvme_get_log_args.

The struct args have are ABI thus it's hard to change it after a
release. The nvme_passthru_cmd buffer is a generic buffer and it's
possible to use the setters directly on the buffer in an inline
function. Besides a reduced API to maintain it also generates better
code and avoids one call less when issue a command.

[ikegami.t: update nvme_uring_cmd_amdin_passthru_async]
Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
Signed-off-by: Daniel Wagner <wagi@kernel.org>
The compiler warns with

../test/ioctl/logs.c: In function ‘test_get_log_reachability_groups’:
../test/ioctl/logs.c:725:28: warning: enum constant in boolean context [-Wint-in-bool-context]
  725 |                          (!!TEST_LSP << 8) | (!!TEST_RAE << 15) |
      |                            ^
../test/ioctl/logs.c:733:70: warning: enum constant in boolean context [-Wint-in-bool-context]
  733 |         err = nvme_get_log_reachability_groups(test_link, TEST_RAE, !!TEST_LSP,
      |                                                                      ^

Update the tests so the types are correctly handled. It also addresses
the problem with the wrong lsp value testing.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
Drop struct nvme_format_nvm_args.

[dennis: merge lbafl and lbafu into one argument]
Signed-off-by: Dennis Maisenbacher <dennis.maisenbacher@wdc.com>
Signed-off-by: Daniel Wagner <wagi@kernel.org>
Drop struct nvme_ns_mgmt_args.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
Drop struct nvme_ns_attach_args.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
Drop struct nvme_fw_download_args.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
Drop struct nvme_fw_commit_args.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
Drop struct nvme_security_send_args.

[dennis: merge spsp0 and spsp1 into one argument]
Signed-off-by: Dennis Maisenbacher <dennis.maisenbacher@wdc.com>
Signed-off-by: Daniel Wagner <wagi@kernel.org>
Drop struct nvme_set_features_args.

Signed-off-by: Dennis Maisenbacher <dennis.maisenbacher@wdc.com>
[wagi: remove libnvme.map entries
       reorder fid and sv argument]
Signed-off-by: Daniel Wagner <wagi@kernel.org>
Drop struct nvme_dsm_args.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
[wagi: reorder arguments]
Signed-off-by: Daniel Wagner <wagi@kernel.org>
ikegami-t and others added 22 commits September 23, 2025 09:19
Drop struct nvme_directive_recv_args.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
[wagi: removed libnvme.map entry
       reordered arguments]
Signed-off-by: Daniel Wagner <wagi@kernel.org>
Drop struct nvme_virtual_mgmt_args.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
[wagi: remove libnvme.map entry]
Signed-off-by: Daniel Wagner <wagi@kernel.org>
Drop struct nvme_dev_self_test_args.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
[wagi: removed libnvme.map entry]
Signed-off-by: Daniel Wagner <wagi@kernel.org>
Drop struct nvme_sanitize_nvm_args.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
[wagi: remove libnvme.map entry
       reorder and rename arguments]
Signed-off-by: Daniel Wagner <wagi@kernel.org>
Drop struct nvme_get_property_args.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
[wagi: remove libnvme.map entry]
Signed-off-by: Daniel Wagner <wagi@kernel.org>
Drop struct nvme_set_property_args.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
[wagi: remove libnvme.map entry]
Signed-off-by: Daniel Wagner <wagi@kernel.org>
Drop struct nvme_lockdown_args.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
[wagi: remove libnvme.map entry]
Signed-off-by: Daniel Wagner <wagi@kernel.org>
Drop struct nvme_capacity_mgmt_args.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
[wagi: remove libnvme.map entry
       reordered/renamed arguments]
Signed-off-by: Daniel Wagner <wagi@kernel.org>
Drop struct nvme_get_features_args.

Signed-off-by: Dennis Maisenbacher <dennis.maisenbacher@wdc.com>
[wagi: reordered/renamed arguments]
Signed-off-by: Daniel Wagner <wagi@kernel.org>
There is no user left of this type in ioctl.c. Remove it.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
This is to maintain nvme_get_log_partial easily.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
Renaming NVME_NVM_CDW* SHIFT and MASK enum members to
NVME_IOCS_COMMON_CDW*.
The ZNS IO command set (IOCS) has the same fields and offsets for the CDWs
in question.
Replacing STCR with two enum entries for CDW12 bit 25 as this bit can only
be Reserved, DEAC or PIREMAP. STCR is part of the copy command which has
its own enum members for CDW12.

The NVME_IOCS_COMMON_CDW* entries cover now
nvme_read
nvme_write
nvme_compare
nvme_write_zeros
nvme_write_uncorrectable
nvme_zns_append

This is in preparation for the following commit which introduces the
shift masks for the zone append command.

Signed-off-by: Dennis Maisenbacher <dennis.maisenbacher@wdc.com>
Replace hardcoded MASK and SHIFT values with enum entries for
nvme_zns_append.

Signed-off-by: Dennis Maisenbacher <dennis.maisenbacher@wdc.com>
Replace hardcoded MASK and SHIFT values with enum entries for
nvme_capacity_mgmt.

Signed-off-by: Dennis Maisenbacher <dennis.maisenbacher@wdc.com>
Replace hardcoded MASK and SHIFT values with enum entries for
nvme_lockdown.

Signed-off-by: Dennis Maisenbacher <dennis.maisenbacher@wdc.com>
Replace hardcoded MASK and SHIFT values with enum entries for
nvme_io_mgmt_recv.

Signed-off-by: Dennis Maisenbacher <dennis.maisenbacher@wdc.com>
Replace hardcoded MASK and SHIFT values with enum entries for
nvme_resv_*.

Signed-off-by: Dennis Maisenbacher <dennis.maisenbacher@wdc.com>
The spec specifies that this command returns the currently selected
IOCSCI upon successful completion.

Signed-off-by: Dennis Maisenbacher <dennis.maisenbacher@wdc.com>
Since the following warnings output.

$ ./scripts/kernel-doc-check test/zns.c
test/zns.c:3: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst
test/zns.c:10: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
examples/mi-mctp.c:3: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
Since checked by kernel-doc-check then the warning message output.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
To fix the warning message below.
  test/mi.c:3: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
This function was dropped with the ioctl changes. However, it is part of
`src/nvme/util.h` and needs to stay.

Signed-off-by: Dennis Maisenbacher <dennis.maisenbacher@wdc.com>
@MaisenbacherD MaisenbacherD force-pushed the libnvme2-dennis-get-feature-length branch from d445289 to 7a7ee66 Compare September 23, 2025 12:57
@igaw igaw force-pushed the libnvme2 branch 2 times, most recently from a5c7768 to 4281a5d Compare September 23, 2025 14:15
@igaw
Copy link

igaw commented Oct 22, 2025

Ah thanks, I've updated the patch accordingly.

@igaw igaw closed this Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants