forked from linux-nvme/libnvme
-
Notifications
You must be signed in to change notification settings - Fork 2
code-generation: Put #include and forward declaration at the top #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
martin-belanger
wants to merge
80
commits into
nvme-experiments:libnvme3
from
martin-experiments:libnvme3
Closed
code-generation: Put #include and forward declaration at the top #111
martin-belanger
wants to merge
80
commits into
nvme-experiments:libnvme3
from
martin-experiments:libnvme3
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The fw download and fw commit test fail sometimes because struct args is not properly initiliazed. Signed-off-by: Daniel Wagner <wagi@kernel.org>
Merge all existing symbols into a new 2.0 section. Signed-off-by: Daniel Wagner <wagi@kernel.org>
Get rid of deprecated functions. Signed-off-by: Daniel Wagner <wagi@kernel.org>
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 global context 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. 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 transport 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_transport_handle 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>
struct nvme_transport_handle was introduced to abstract the transport, thus replace nvme_mi_ctrl_t with it. 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 struct nvme_transport_handle 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>
The sizeof_args macro is buggy returns invalid values on 32 bit arch. Remove this feature before we remove the struct args otherwise the tests start to fail during the API update. There is no piont in trying to fix this. Signed-off-by: Daniel Wagner <wagi@kernel.org>
The change fixes the following complie warings.
../test/ioctl/logs.c: In function ‘test_get_log_reachability_groups’:
../test/ioctl/logs.c:796:28: warning: enum constant in boolean context [-Wint-in-bool-context]
796 | (!!TEST_LSP << 8) | (!!TEST_RAE << 15) |
| ^
../test/ioctl/logs.c:805:54: warning: enum constant in boolean context [-Wint-in-bool-context]
805 | nvme_init_get_log_reachability_groups(&cmd, !!TEST_LSP, &log,
| ^
../test/ioctl/logs.c: In function ‘test_get_log_reachability_associations’:
../test/ioctl/logs.c:822:28: warning: enum constant in boolean context [-Wint-in-bool-context]
822 | (!!TEST_LSP << 8) | (!!TEST_RAE << 15) |
| ^
../test/ioctl/logs.c:831:60: warning: enum constant in boolean context [-Wint-in-bool-context]
831 | nvme_init_get_log_reachability_associations(&cmd, !!TEST_LSP, &log,
| ^
../test/ioctl/logs.c: In function ‘test_get_log_host_discover’:
../test/ioctl/logs.c:898:28: warning: enum constant in boolean context [-Wint-in-bool-context]
898 | (!!TEST_LSP << 8) |
| ^
../test/ioctl/logs.c:908:49: warning: enum constant in boolean context [-Wint-in-bool-context]
908 | nvme_init_get_log_host_discovery(&cmd, !!TEST_LSP, &log, sizeof(log));
| ^
Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
Replace the struct args approach by providing init function for initializing the passthru commands. This reduces the dependency between callside and library. The only stable API from the library is then nvme_submit_passthru_cmd and struct nvme_passthru_cmd. Signed-off-by: Daniel Wagner <wagi@kernel.org>
Reduce nvme_init_identify_ctrl and nvme_submit_admin_passthru calls. Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com> [wagi: added documentation] Signed-off-by: Daniel Wagner <wagi@kernel.org>
Replace the struct args approach by providing init function for initializing the passthru commands. This reduces the dependency between callside and library. Signed-off-by: Daniel Wagner <wagi@kernel.org> [ikegami.t: update Python binding] Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
Just added only functions frequently used in nvme-cli.
Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
[wagi: - addded documentation
- dropped nvme_get_csi_log and nvme_get_nsid_log
- all missing helpers]
Signed-off-by: Daniel Wagner <wagi@kernel.org>
There are many places where the LPO needs to be set. Signed-off-by: Daniel Wagner <wagi@kernel.org>
Replace the struct args approach by providing init function for initializing the passthru commands. This reduces the dependency between callside and library. Signed-off-by: Daniel Wagner <wagi@kernel.org>
Replace the struct args approach by providing init function for initializing the passthru commands. This reduces the dependency between callside and library. Signed-off-by: Daniel Wagner <wagi@kernel.org>
Replace the struct args approach by providing init function for initializing the passthru commands. This reduces the dependency between callside and library. Signed-off-by: Daniel Wagner <wagi@kernel.org>
Replace the struct args approach by providing init function for initializing the passthru commands. This reduces the dependency between callside and library. Signed-off-by: Daniel Wagner <wagi@kernel.org>
Replace the struct args approach by providing init function for initializing the passthru commands. This reduces the dependency between callside and library. Signed-off-by: Daniel Wagner <wagi@kernel.org>
Replace the struct args approach by providing init function for initializing the passthru commands. This reduces the dependency between callside and library. Signed-off-by: Daniel Wagner <wagi@kernel.org>
Replace the struct args approach by providing init function for initializing the passthru commands. This reduces the dependency between callside and library. Signed-off-by: Daniel Wagner <wagi@kernel.org>
Replace the struct args approach by providing init function for initializing the passthru commands. This reduces the dependency between callside and library. Signed-off-by: Daniel Wagner <wagi@kernel.org> [ikegmi.t: - added switch case break statement missed] Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
There is no user left of this type in ioctl.c. Remove it. Signed-off-by: Daniel Wagner <wagi@kernel.org>
Refactore so we maintain nvme_get_log_partial easier. Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.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>
The api-types.h include file provided struct args definition. These are all gone. But some basic types have been added in the meantime, which need to be present when using the types.h header. Signed-off-by: Daniel Wagner <wagi@kernel.org>
As we have renamed nvme_root to nvme_global_ctx, the Python bindings example needs to be adjusted to reflect the refactoring. Signed-off-by: Dennis Maisenbacher <dennis.maisenbacher@wdc.com>
The error handling has changed from returning -1 and errno set to just returing the error code. Negative values are internal errors, e.g. -ENOMEM. Positive values are status code from the transport. Signed-off-by: Dennis Maisenbacher <dennis.maisenbacher@wdc.com>
This is to resolve the build warnings below.
In function ‘nvme_init_app_tag’,
inlined from ‘test_verify’ at ../test/ioctl/misc.c:961:2:
../src/nvme/ioctl.h:4514:20: warning: array subscript ‘struct nvme_passthru_cmd64[0]’ is partly outside array bounds of ‘struct nvme_passthru_cmd[1]’ [-Warray-bounds=]
4514 | cmd->cdw15 = NVME_FIELD_ENCODE(lbat,
| ^
../test/ioctl/misc.c: In function ‘test_verify’:
../test/ioctl/misc.c:955:34: note: object ‘cmd’ of size 72
955 | struct nvme_passthru_cmd cmd;
| ^~~
In function ‘nvme_init_app_tag’,
inlined from ‘test_compare’ at ../test/ioctl/misc.c:865:2:
../src/nvme/ioctl.h:4514:20: warning: array subscript ‘struct nvme_passthru_cmd64[0]’ is partly outside array bounds of ‘struct nvme_passthru_cmd[1]’ [-Warray-bounds=]
4514 | cmd->cdw15 = NVME_FIELD_ENCODE(lbat,
| ^
../test/ioctl/misc.c: In function ‘test_compare’:
../test/ioctl/misc.c:857:34: note: object ‘cmd’ of size 72
857 | struct nvme_passthru_cmd cmd;
| ^~~
In function ‘nvme_init_app_tag’,
inlined from ‘test_write’ at ../test/ioctl/misc.c:830:2:
../src/nvme/ioctl.h:4514:20: warning: array subscript ‘struct nvme_passthru_cmd64[0]’ is partly outside array bounds of ‘struct nvme_passthru_cmd[1]’ [-Warray-bounds=]
4514 | cmd->cdw15 = NVME_FIELD_ENCODE(lbat,
| ^
../test/ioctl/misc.c: In function ‘test_write’:
../test/ioctl/misc.c:823:34: note: object ‘cmd’ of size 72
823 | struct nvme_passthru_cmd cmd;
| ^~~
In function ‘nvme_init_app_tag’,
inlined from ‘test_read’ at ../test/ioctl/misc.c:794:2:
../src/nvme/ioctl.h:4514:20: warning: array subscript ‘struct nvme_passthru_cmd64[0]’ is partly outside array bounds of ‘struct nvme_passthru_cmd[1]’ [-Warray-bounds=]
4514 | cmd->cdw15 = NVME_FIELD_ENCODE(lbat,
| ^
../test/ioctl/misc.c: In function ‘test_read’:
../test/ioctl/misc.c:787:34: note: object ‘cmd’ of size 72
787 | struct nvme_passthru_cmd cmd;
| ^~~
In function ‘nvme_init_app_tag’,
inlined from ‘test_write_zeros’ at ../test/ioctl/misc.c:898:2:
../src/nvme/ioctl.h:4514:20: warning: array subscript ‘struct nvme_passthru_cmd64[0]’ is partly outside array bounds of ‘struct nvme_passthru_cmd[1]’ [-Warray-bounds=]
4514 | cmd->cdw15 = NVME_FIELD_ENCODE(lbat,
| ^
../test/ioctl/misc.c: In function ‘test_write_zeros’:
../test/ioctl/misc.c:892:34: note: object ‘cmd’ of size 72
892 | struct nvme_passthru_cmd cmd;
| ^~~
Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
Since the almost nvme-cli caller functions expected the base name. Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
This adds the ability to automatically generate accessor functions (setter/getter functions) by parsing structs definitions in header files. Two files are generated: [accessors.c, accessors.h]. Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Before this fix, #includes and forward declarations were inserted in the generated outputs on a first-come-first-serve basis. In other words, #include statements and forward struct declarations would get scattered thoughout the output instead of appearing at the top of the files as they should. This patch ensures that all #includes and forward declarations appear at the top of the file where it is customary to find them. Signed-off-by: Martin Belanger <martin.belanger@dell.com>
4425c69 to
5e05cc8
Compare
b51ed8f to
4a73807
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before this fix, #includes and forward declarations were inserted in the generated outputs on a first-come-first-serve basis. In other words, #include statements and forward struct declarations would get scattered throughout the output instead of appearing at the top of the files as they should.
This patch ensures that all #includes and forward declarations appear at the top of the file where it is customary to find them.
Also did a bit of cleaning that checkpatch missed the last time.