Daniel Wagner [Mon, 6 Feb 2023 10:22:49 +0000 (11:22 +0100)]
util: Add crc32 implementation
a05d4213f0f9 ("Add 'gen-dhchap-key' command") introduced the zlib
dependency in order to use the crc32 function. This simple function
alone is a not worth the additional dependency, so let's ship our own
crc32 function.
The implementation is from teh elfutils project which is licensed under
LGPL 3 or later of GPL 2 or later. For this project we choose the GPL 2
or later license.
Daniel Wagner [Fri, 3 Feb 2023 10:16:11 +0000 (11:16 +0100)]
nvme: Support effects-log for fabrics ctrl
nvme-cli v1.16 supported effects-log for fabric devices only, nvme-cli
2.x supported only memory based transports (aka PCI). Obviously, we
should support effects-log independent of the transport type.
Do this by first trying to map the PCI registers and read the CAP
property if this fails fall back using the get-properties approach.
Caleb Sander [Thu, 26 Jan 2023 17:53:07 +0000 (10:53 -0700)]
json_discovery_log: avoid buffer overrun
nvme_strip_spaces() has an off-by-one error and starts stripping spaces
at the byte AFTER the end of the buffer. Use space_strip_len() instead,
which doesn't have this bug and is already used in print_discovery_log().
Daniel Wagner [Thu, 26 Jan 2023 13:40:08 +0000 (14:40 +0100)]
fabrics: Fix already connected test
The lookup will also return controllers created from discovery.conf
and config.json. These might not yet connected. When the controller has
a device name we assume that we are connected.
Fixes: 07d6b911e081 ("fabrics: Do not attempt to reconnect to already connected ctrls") Signed-off-by: Daniel Wagner <dwagner@suse.de>
Daniel Wagner [Thu, 26 Jan 2023 13:36:56 +0000 (14:36 +0100)]
fabrics: Fix discovery controller filter function
disc_ctrl_config_match() should also test if the controller is actually
a discovery controller. Because of that ctrl_config_match() can't call
disc_ctrl_config_match() anymore.
Fixes: 07d6b911e081 ("fabrics: Do not attempt to reconnect to already connected ctrls") Signed-off-by: Daniel Wagner <dwagner@suse.de>
Klaus Jensen [Thu, 26 Jan 2023 08:38:40 +0000 (09:38 +0100)]
nvme-print: prettify the fdp event printing
The default human readable printing of FDP events does not have to print
the event flags since they are only used to indicate the validity of
some of the fields.
Remove the flags from printing and use it to conditionally print valid
fields.
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Daniel Wagner [Wed, 25 Jan 2023 08:16:53 +0000 (09:16 +0100)]
fabrics: Make PDC behavior configurable
The persistent discovery controller is a behavior change which might
break existing installation. Instead enabling it per default, introduce
a compile time and a global configuration option to define the default
settings.
Daniel Wagner [Mon, 23 Jan 2023 16:01:53 +0000 (17:01 +0100)]
build: The release workflow can't tag
The releaser action is not able to auto tag the tree (permission).
Anyway, we don't want to have a 'tip' or 'latest' tag just because the
build process expects this. So we have to find a different way to have
latest AppImage.
Keith Busch [Tue, 10 Jan 2023 20:43:17 +0000 (12:43 -0800)]
nvme: Add wait for device self test
Add a wait command line option to device-self-test which makes nvme-cli
staying in forground and reports progress. This make it possible to wait
for the end of the test.
Signed-off-by: Keith Busch <kbusch@kernel.org>
[dwagner: make termination condition handling the end of self test] Signed-off-by: Daniel Wagner <dwagner@suse.de>
Daniel Wagner [Fri, 20 Jan 2023 09:39:19 +0000 (10:39 +0100)]
gitignore: Ignore clang build artifacts
When using language server support from clang, the .cache directory is
added. Also for getting lsp working properly the compile_commands.json
file has to present (which is just a link to Meson generared json file).
Daniel Wagner [Thu, 19 Jan 2023 08:21:45 +0000 (09:21 +0100)]
fabrics: Handle DUPRETINFO and EPCSD when doing discovery
The TP8014 adds two new flags for providing information to the host
which discovery controller is returning the same information we already
know or if the discovery controller doesn't support explicit
persistency.
Daniel Wagner [Tue, 17 Jan 2023 08:32:19 +0000 (09:32 +0100)]
fabrics: Prefer unique disc ctrl over well known
Currently, the well known discovery controller is used per default even
though the target might support unique discovery controller as defined
in TP8013.
Change the default behavior to use the unique discovery controller
whenever the target supports it.
Daniel Wagner [Wed, 18 Jan 2023 17:20:09 +0000 (18:20 +0100)]
fabrics: Do not attempt to reconnect to already connected ctrls
Currently, connect-all and connect will blindly try to reconnect to
already connected controllers. Try to lookup the controller in the local
hierarchy. If found just ignore the attempt and fail.
Note, we have to distinguish between normal controllers and discovery
controller when comparing them. The main difference is that we have
ignore the discovery nqn and assume if we find a discovery controller
it's the correct one (persistent). This basically means the well known
discovery nqn matches any found controller.
Daniel Wagner [Wed, 18 Jan 2023 17:16:36 +0000 (18:16 +0100)]
nvme: Ingore LOG_NOTICE level
We don't use the LOG_NOTICE level at all. That means a single '-v' has
no impact. So just ingore it and we get some useful information starting
with LOG_INFO.
Daniel Wagner [Wed, 18 Jan 2023 09:36:45 +0000 (10:36 +0100)]
fabrics: Use endian helper when reading discovery log entries
We should use the correct CPU endian helper when reading the discovery
log. While at it, also sync the JSON output with the console output and
stringify the EFLAGS.
Daniel Wagner [Mon, 16 Jan 2023 13:44:40 +0000 (14:44 +0100)]
fabrics: Do not overwrite errno with return code
__create_discover_ctrl() is calling nvmf_add_ctrl() which sets errno
when something doesn't work. Hence we should not overwrite the errno
with the return code in __ctrl_discover_ctrl().
This prevents to propagate the errno code to the callside and the
nvme_strerror(errno) call is just return 'unknown error -1'.
Daniel Wagner [Mon, 16 Jan 2023 13:51:07 +0000 (14:51 +0100)]
build: Set projects default to debug and prefix /usr/local
Do not install to /usr per default and accidently overwrite the
distributions version of the package. And also debugging symbols per
default to make development setup as we don't install it anyway to /usr
anyway.
Tokunori Ikegami [Wed, 28 Dec 2022 06:18:25 +0000 (15:18 +0900)]
nvme-print: Display smart log data units read and written SI value
This resolves for the issue #1745. Also change smart log uint128_t values as
group the output with thousands' grouping characters and add test-iunt128-si
unit tests.
Daniel Wagner [Tue, 3 Jan 2023 17:46:57 +0000 (18:46 +0100)]
unit: Move unit tests to a new directory
The tests directory contains a test framework for testing
real hardware and are thus no real unit tests. As these
tests are reading and writing data to /dev/nvme0 we should
disable them per default.
To distinguish between the real unit tests and the nvme test
framework move all unit test to a new directory.
Tokunori Ikegami [Wed, 28 Dec 2022 10:18:30 +0000 (19:18 +0900)]
nvme: create-ns: Add nsze-si and ncap-si arguments to set in standard SI units
This is proposed by the issue #1747. The value suffixed SI is divided by the
namespace LBA size to set as NSZE and NCAP. If the value not suffixed it is set
as same with the nsze and ncap options.
Note: The existing nsze/ncap arguments follow the specification defined units.
Qiang Wei [Fri, 30 Dec 2022 14:52:38 +0000 (22:52 +0800)]
Bash completion: move global declare into function
* To fix completion issue by moving global vairables into
function _nvme_subcmds. It is not only suite for bash
completion system but also support manually source bash script.
* Fix pluginx_sfx_opts spell error to plugin_sfx_opts.
* Correct variable NO_OPTS used in bash assginment.
Tokunori Ikegami [Fri, 16 Dec 2022 17:34:15 +0000 (02:34 +0900)]
nvme-print: Serialize uint32_t types correctly
le32_to_cpu returns an unsigned type which gets extended to a signed
type when using %d format specifier or json_object_add_value_int. Use
%u in this case or json_object_add_value_uint accordingly.