Daniel Wagner [Thu, 23 Dec 2021 13:59:01 +0000 (14:59 +0100)]
linux: Add support to generate DH-HMAC-CHAP keys
Initially the DH-HMAC-CHAP key generation code was part of the
nvme-cli repository and depended on OpenSSL 1. Move the key generation
code into the library. While at it also add support for OpenSSL 3.
Daniel Wagner [Mon, 27 Dec 2021 15:09:04 +0000 (16:09 +0100)]
build: Set C dialect and warning level
Currently, the Makefile is not setting the C dialect but the code was
carved out from the nvme-cli code base which relies on gnu99.
Let's define the C dialect to avoid any confusion and make the build
more consistent.
Without defining the default warning level the build system will use
the default level, which is implementation depended. For example muon
sets it to 3 which includes '-Wpendantic'. This results in a lot of
ISO-C non compliant warnings.
Let's define the warning level so that all build systems are using the
same values.
Daniel Wagner [Thu, 23 Dec 2021 15:38:04 +0000 (16:38 +0100)]
build: Avoid including wrong config.h as subpackage
In case the consuming project also uses a config.h we need to hide our
config.h file. By using the path to our config.h we avoid this
confusion. Obviously, 'src' is a bit too generic, thus move the
generated config.h under libnvme.
Introduce also a private include path because ccan has '#include
"config.h"' in its sources. So we need to present a config.h in the
lookup path but it needs to be the one from this project and not the
one from the consuming project.
Daniel Wagner [Wed, 22 Dec 2021 07:34:03 +0000 (08:34 +0100)]
util: Define inline function as static inline
The gcc in Centos 6.10 complains with
src/nvme/util.h:120: multiple definition of `nvme_feature_decode_arbitration'
'inline' alone does not guarantee that the function gets inlined. The
compiler is still free to decide, thus in this case it doesn't inline
and that's why we having multiple implementation with the same
name (in different compile units). 'static inline' forces the inline
which was the indent of this code.
Martin Belanger [Tue, 21 Dec 2021 20:36:38 +0000 (15:36 -0500)]
Replacing make by meson.
This involves replacing all Makefiles by meson.build files.
Also the top-level configure script now simply invokes meson.
The top-level Makefile is just a wrapper for meson. It supports
the following operations:
make
make test
make install
make clean # Remove build artifacts but keep configuration
make purge # Remove build artifacts and configuration
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Daniel Wagner [Tue, 21 Dec 2021 14:56:14 +0000 (15:56 +0100)]
fabrics: Declare loop index at the beginning of the block
The gcc in Centos 6.10 complains with
nvme/fabrics.c:909: error: ‘for’ loop initial declarations are only allowed in C99 mode
nvme/fabrics.c:909: note: use option -std=c99 or -std=gnu99 to compileyour code
Let's declare the index at the beginning of the basic block.
Daniel Wagner [Mon, 13 Dec 2021 17:37:21 +0000 (02:37 +0900)]
types: Add Controller Metadata and Namespace Metadata
Port and extent the libnvme part from the commit "Add NVMe MI
Features: Controller Metadata (0x7E) and Namespace Metadata (0x7F)."
from the nvme-cli monolithic branch.
While at it add the missing definitions and add some documentation.
This is based on Tokunori Ikegami first port attempt.
Tomas Bzatek [Wed, 1 Dec 2021 15:41:53 +0000 (16:41 +0100)]
types: Fabrics doc strings updates
Includes a typo correction, prefix changes, transition away from anonymous
enums and added some more enum members according to the standard.
All subtle API breaks.
Martin Belanger [Tue, 30 Nov 2021 19:50:29 +0000 (14:50 -0500)]
Fix memory leak.
The API PyDict_SetItemString() does not steal references
when adding objects to a dictionary. Therefore, the caller
must decrement the reference count after adding objects to
the dictionary if those objects are no longer needed.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Sagi Grimberg [Sun, 28 Nov 2021 13:03:03 +0000 (15:03 +0200)]
fabrics: fix endless loop in connect-all for NVME_NQN_CURR
For a discovery log page entry that indicates the discovery controller
that returned it (i.e. itself), we need to set the controller as
discovered (because we got the discovery log page by connecting to it).
Without this connect-all goes in an endless loop keep connecting and
retrieving the log page from the same discovery subsystem port.
Daniel Wagner [Fri, 19 Nov 2021 10:25:37 +0000 (11:25 +0100)]
build: Do not use the configurator for meson
meson does the feature detection itself and we don't have to rely on
the configurator. So don't use it.
To avoid touching the ccan files, we have to rethink our config.h to
libnvme-config.h rename change. Since the ccan files include
'config.h' we have to use the second option to avoid including it into
external include paths. This is moving the config.h file into a
private folder and drop the include path '.'.
Hannes Reinecke [Thu, 18 Nov 2021 16:35:53 +0000 (17:35 +0100)]
Sanitize zns command arguments
With the recent up the calling convention has been sanitzed to always
have the 'timeout' argument as second-to-last, and the 'result' as the
laster argument.
Modify the zns commands accordingly.
Hannes Reinecke [Wed, 11 Aug 2021 06:04:38 +0000 (08:04 +0200)]
Implement 'dhchap_key' host and controller attributes
Implement a 'dhchap_key' attribute for the nvme_host structure to
support the 'dhchap_secret' connection argument, and a
'dhchap_key' attribute for the nvme_controller structure to support
the 'dhchap_ctrl_secret' connection argument.
Hannes Reinecke [Thu, 18 Nov 2021 09:29:10 +0000 (10:29 +0100)]
Add 'result' argument to ioctl wrapper functions
The ioctl wrapper function are pretty inconsistent as to whether
the NVME cqe result is returned or not.
We'd better add it to every function to have a consistent interface.
Daniel Wagner [Thu, 18 Nov 2021 09:04:13 +0000 (10:04 +0100)]
build: Rename config.h to libnvme-config.h
The meson documentation recommends not to put a config.h file in the
external search path. This will clash with any project consuming this
library. There are two ways to workaround, either renaming the config
header file or put it under a different path which isn't added into
the default include path.
Minwoo Im [Mon, 15 Nov 2021 14:46:00 +0000 (23:46 +0900)]
tree: add namespace chrdev name to nvme_ns
Namespace device node is initialized into two different nodes: block
device and character device which is a generic device used when block
device is not available due to initialization failure in the kernel.
This can be directly retrieved from the `struct nvme_ns` to print out
the generic node in somewhere like `nvme list` command in nvme-cli.
Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
Hannes Reinecke [Wed, 17 Nov 2021 13:01:02 +0000 (14:01 +0100)]
fabrics: add nvmf_default_config()
'struct nvme_fabrics_config' has some default values, and the output
functions key off these values to filter the values being printed.
So to avoid applications having to know these default values this
patch introduces a function nvmf_default_config() to ensure that
every application is using the same defaults.
Daniel Wagner [Wed, 17 Nov 2021 12:38:30 +0000 (13:38 +0100)]
build: Lower json-c dependencies
libnvme has no hard requirement on json-c 0.14. It was updated to
match to min version for nvme-cli. But nvme-cli has added a
workaround, to avoid requiring a newer version of json-c. Let's drop
the requirement here too.
Hannes Reinecke [Tue, 16 Nov 2021 08:59:42 +0000 (09:59 +0100)]
fabrics: set 'discovery' argument for unique discovery controllers
Discovery controllers providing a unique NQN cannot be distinguished
by the NQN from 'normal' I/O controllers, so we need to add the keyword
'discovery' when creating the connection to indicate that this is a
disocvery connection.
Hannes Reinecke [Mon, 15 Nov 2021 14:27:27 +0000 (15:27 +0100)]
Distinguish between 'nvm' and 'discovery' subsystems
Add a 'subsystype' value to the subsystem to determine if a given
subsystem is a 'discovery' or a 'nvm' subsystem.
And also add a flags 'discovery_ctrl' to specify if a given controller
is a discovery controller; this allows connection to discovery controllers
with unique subsystem NQNs, as these cannot distinguished by the NQN
anymore.