Daniel Wagner [Mon, 13 Jun 2022 11:32:32 +0000 (13:32 +0200)]
doc: move update instruction into template
The documentation added in 7fecc4881a3c ("doc: add quickstart and
installation") and 6a9758bbde33 ("doc: update installation doc")
should have been added to the template.
Hannes Reinecke [Fri, 10 Jun 2022 08:19:01 +0000 (10:19 +0200)]
tree: make nvme_ctrl_scan_namespace() idempotent
When issuing a rescan the list of namespaces is not cleared, so
just blindly adding new entries might not yield the expected result.
This patch clears out old entries from the controller namespace list
before adding new ones, ensuring that we only ever have one namespace
with a given name in the list of controller namespaces.
Hannes Reinecke [Fri, 10 Jun 2022 08:19:01 +0000 (10:19 +0200)]
tree: make nvme_subsystem_scan_namespace() idempotent
When issuing a rescan the list of namespaces is not cleared, so
just blindly adding new entries might not yield the expected result.
This patch clears out old entries from the subsystem namespace list
before adding new ones, ensuring that we only ever have one namespace
with a given name in the list of subsystem namespaces.
Hannes Reinecke [Fri, 10 Jun 2022 07:48:03 +0000 (09:48 +0200)]
tree: simplifiy nvme_subsystem_lookup_namespace()
The list of namespaces needs to be considered static, and should
only be changed on a full rescan. So simplify the function to just
return the corresponding namespace entry from the topology tree.
Jeremy Kerr [Fri, 10 Jun 2022 01:41:52 +0000 (09:41 +0800)]
test/mi: Improve test OK reporting, print log data separately
Currently, we have a confusing output for tests (all of which currenly
pass):
$ ./obj/test/test-mi
crc mismatch
$ echo $?
0
This change adds reporting for each test, and separates the nvme_msg log
data from the report:
$ ./obj/test/test-mi
Running test read_mi_data... OK
Running test transport_fail... OK
Running test invalid_crc... OK
--- begin test output
crc mismatch
--- end test output
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Wed, 20 Oct 2021 03:20:39 +0000 (11:20 +0800)]
mi: Add initial Admin channel commands
This change adds Admin Channel commands, and the first admin channel
command to the MI transport: Identify. The admin functions have the
nvme_mi_admin_ prefix.
For this, we need a couple of definitions for Admin-Channel-over-MI
serialisation, and add individual admin commands using those.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Wed, 15 Sep 2021 09:27:30 +0000 (17:27 +0800)]
examples/mi-mctp: Add subcommand support
A future change will introduce further mi commands, and admin channel
commands, so we'll want a way to invoke mi-mctp to perform these
additional commands.
This change introduces an <action> argument, which currently defaults to
the existing 'info' action.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Tue, 5 Apr 2022 07:51:26 +0000 (15:51 +0800)]
mi: Add basic tests
This change adds a couple of basic tests for the mi infrastrcucture.
To do this, we define a test "transport", which just allows inserting a
custom function as the transport's ->submit callback. Each test is then
a pair of: the test itself, and a callback to implement a specific
response from the test "device".
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
This change adds support for the NVMe-MI protocol, as a secondary
library: libnvme-mi.{a,so,h}. This allows management of NVMe devices,
typically through NVMe Admin Channel commands, transmitted over a
side-band channel - typically MCTP over SMBus.
There's a fair amount of shared structure between the direct-ioctl and
MI channel implementations; for example, the Admin command set is used
mostly as-is over the MI transport. The library is built as separate
.so/.a objects as client applications would typically either use one or
the other. MI-specific functions are added with a 'nvme_mi' prefix.
This change introduces a small set of MI commands using this channel.
We'll extend this to further MI commands in subsequent changes, as well
as implement Admin Channel commands too.
We currently assume a MCTP transport for NVMe-commands, using the new
AF_MCTP socket support in Linux. However, the transport-specific code is
kept somewhat separate, through the internal struct nvme_mi_transport
interface. This allows potential alternative transports in future - for
example in-band PCIe.
Finally, we start a new example application, mi-mctp, which provides
a reference application using the new library.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
The kernel returns status information via error codes. Currently we
map all error codes to ENVME_CONNECT_WRITE if the operation
fails. Some of those error codes should be treated differently, such
as EALREADY which means the connection attempt failed because the
connection is already established.
Many of the error codes are overloaded so we have to guess if they are
actually from the nvme subsystem and not from the write
command. Though in practice it's almost certainly the nvme
subsystem. Still it's a guessing game due the very limited API
between userland and kernel.
Brandon Paupore [Fri, 18 Mar 2022 22:03:56 +0000 (17:03 -0500)]
libnvme: 64-bit Reference Tags and TP-4068 changes
Adds support for expanded reference and storage tags, automatically
placing them into the appropriate bits based on Protection Information
Format and Storage Tag Size. This includes updates to nvme_io_args
expanding the size of the tags and adding these STS and PIF values.
Also adds a new copy range format as defined by the NVMe 2.0 spec, as it
determines the reference/storage tags associated to the range being
copied.
Signed-off-by: Brandon Paupore <brandon.paupore@wdc.com> Signed-off-by: Jeff Lien <jeff.lien@wdc.com>
Anuj Gupta [Thu, 19 May 2022 11:35:21 +0000 (17:05 +0530)]
ioctl: nvme_uring_cmd add structure and opcodes
This adds definition of struct nvme_uring_cmd and
NVME_URING_CMD_IO/NVME_URING_CMD_IO_VEC opcodes. The new structure
definition and opcodes are required for using uring-nvme-passthrough
feature. This feature has been picked for 5.19 kernel.
Daniel Wagner [Thu, 19 May 2022 08:49:40 +0000 (10:49 +0200)]
fabrics: Consider config from file when adding new controller
nvme_read_config() function is attaching the configuration
to tree. But when we create a new controller via nvme_create_ctrl()
and then call nvmf_add_ctrl() we ignore this previously read
in configuration.
Hence lookup if there exist a controller/config and merge into
the fabrics config.
Note, the order of the merge is important. For example we want
the config from the command line to have higher priority
than the one from the config file.
Daniel Wagner [Thu, 19 May 2022 08:44:24 +0000 (10:44 +0200)]
tree: Factor lookup code for controller
nvme_lookup_ctrl() will create a controller if it is not
found. In the case where we really just want the lookup
if a controller is in the tree we are missing a pure
lookup function. Hence factor out the lookup into a internal
function.
Thomas Weißschuh [Fri, 29 Apr 2022 15:06:27 +0000 (17:06 +0200)]
util: Add feature length for host memory buffer
Without this the command "nvme get-feature /dev/nvme0 -H -f 0x0d"
segfaults because it retrieves no data but tries to use it in
nvme_show_host_mem_buffer()
Hannes Reinecke [Fri, 22 Apr 2022 09:42:47 +0000 (11:42 +0200)]
tree: coverity fixes
Coverity found some resource leaks and a possible out-of-bounds access
in nvme_ctrl_lookup_subsystem_name() where we could overflow the
'path' variable.
Hannes Reinecke [Fri, 22 Apr 2022 09:37:19 +0000 (11:37 +0200)]
fabrics: coverity fixes
Coverity reported a possible out-of-bounds access in inet6_pton
and we never checked the return value of nvme_ctrl_identify() in
nvme_fetch_cntrltype_dctype_from_id(), leading to a possible
NULL pointer access in nvmf_is_registration_supported().
Eli Schwartz [Fri, 15 Apr 2022 05:06:56 +0000 (01:06 -0400)]
reduce the exposed interface for libnvme_dep
It does not publicly expose openssl. It does publicly expose uuid.h and
json.h, but only in terms of header types, not symbols used... so use a
partial dependency that doesn't expose the link libraries.
Eli Schwartz [Fri, 15 Apr 2022 00:23:40 +0000 (20:23 -0400)]
fix broken includes for the uuid.h header
Per `man 3 uuid`, the correct include is `<uuid.h>`, and correspondingly
the util-linux build system installs the uuid.h file to
`$(includedir)/uuid/` and uuid.pc adds `-I${includedir}/uuid` to the
dependency Cflags.
Including it as `<uuid/uuid.h>` simply fails altogether. The exception
is if, by coincidence, the libuuid includedir happens to be the same as
one of the compiler's own internal include directories... which is
pretty common if that is `/usr/include`. In this case, `<uuid/uuid.h>`
fails to be found in the uuid dependency's export directories, but the
compiler picks up a copy in its builtin search path.
In other cases, such as when util-linux is compiled into a custom prefix
and added to the PKG_CONFIG_PATH, it either:
- fails with missing header errors, if libuuid-dev is not installed
- seems to succeed, but compiles against a different version of the
headers than the library that is linked to, resulting in potentially
various problems from bizarre linker errors, to subtly broken
incompatible symbols that crash, or corrupt the results
The problem is even worse if you try to use util-linux as a subproject
dependency fallback. In this case, `<uuid.h>` is correctly exported, but
there is no disk location for `<uuid/uuid.h>` and absolutely no way to
generate such a location in the builddir. This completely prevents the
use of subproject fallbacks.
Once the header include is renamed, it is revealed that the example and
test executables don't correctly build as they depend on the full public
interface of libnvme, which includes the public compile interface of
libuuid due to `libnvme.h` including `uuid.h`. Update all executables to
depend on the full public interface of libnvme_dep instead of simply
linking to the library name on its own.
Daniel Wagner [Thu, 14 Apr 2022 10:18:53 +0000 (12:18 +0200)]
fabrics: Remove double connection error logging
nvmf_connect_disc_entry() is calling nvmf_add_ctrl() to do the
connecting attempt. We have in nvmf_add_ctrl() all error paths logging
enabled, so another logging in nvmf_connect_disc_entry() is not
necessary and introduces a problem such as nmve-cli users interpreting
this as hard error.
For example the kernel reports via < 0 return values state information
such as the connection is already there if the user runs 'nvme
connect-all' twice:
$ .build/nvme connect-all -t tcp --traddr=10.161.8.24 --trsvcid=4421
Failed to write to /dev/nvme-fabrics: Operation already in progress
failed to connect controller, error 1006
Daniel Wagner [Thu, 14 Apr 2022 10:01:43 +0000 (12:01 +0200)]
fabrics: Lower log level in __nvmf_add_ctrl
9df8676d2db6 ("Add logging functionality to libnvme") introduced the
logging. The log level for writing to /dev/nvme-fabrics was set on
NOTICE because the kernel reports also status information such
EALREADY which is a soft error.
866c288a456f ("fabrics: update log level for write failures")
increased the log level without taking this into account.
Drop back to NOTICE level to avoid error message when doing
$ nvme connect-all ....
Failed to write to /dev/nvme-fabrics: Operation already in progress