Martin George [Fri, 26 Aug 2022 13:17:57 +0000 (18:47 +0530)]
nvme-tree: avoid segfault if auth keys are unavailable
Seeing multiple segfaults in nvme_configure_ctrl() when the
respective controller attributes (including auth keys) are
unavailable. For e.g. attempting a nvme connect with bidirectional
auth hits the following segfault:
Hannes Reinecke [Thu, 25 Aug 2022 08:27:02 +0000 (10:27 +0200)]
Parse dhchap_host_key on controller level
The json config schema declares an 'dhchap_key' element representing
the dhchap host key on the controller level, but the implementation
was missing. Add the missing parsing elements and ensure to pick the
correct one (either host or controller setting) when creating the
nvme connect string.
Jeremy Kerr [Fri, 12 Aug 2022 04:44:50 +0000 (12:44 +0800)]
mi: Allow Admin-message sized More Processing Required responses
Devices may implement their MPR response as an actual Admin response
message, rather than the simple MI-only message described in 4.1.2.3 of
NVMe-MI v1.2b.
Allow this, but with some fairly stringent header checks. Add a test for
this behaviour too.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Thu, 21 Jul 2022 08:21:30 +0000 (16:21 +0800)]
example/mi-conf: Add an example for MI transport configuration
With the Read MI Data Structure and MI Configuration Set functions
available, we can query a device for its maximum MTU, and update the
current MTU to suit.
This also requires telling the local MCTP stack about the new MTU too,
by sending a d-bus message to `mctpd`.
This change adds a little example for this functionality, where we
perform the MI query and configuration, and implements the d-bus
communication for the local stack control.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Daniel Wagner [Wed, 3 Aug 2022 11:56:48 +0000 (13:56 +0200)]
util: Add LINE_MAX define
The bionic libc implementation doesn't implement the complete
POSIX API. Apperantly we just need this define to be able
to compile for Android OS. Thus, keep it as simple as possible
and just define it here.
Hannes Reinecke [Fri, 29 Jul 2022 06:14:14 +0000 (08:14 +0200)]
json: fixup dhchap_ctrl_key definitions
The config schema declared a 'dhchap_key' and a 'dhchap_ctrl_key'
value for the port structure, but the json parser implemented a
'dhchap_key' entry for the port (holding the controller key), and
a 'dhchap_key' entry for the host (holding the host key).
Fixup the config schema to declared the correct entries and the
json parser to check for 'dhchap_ctrl_key' instead of 'dhchap_key'.
Daniel Wagner [Fri, 22 Jul 2022 13:30:31 +0000 (15:30 +0200)]
build: Drop -nostdinc for LibreSSL header checks
-nostdinc is only necessary when the LibreSSL is not the default SSL
library on the system and OpenSSL header files are present in the
default include paths.
Though if LibreSSL found in standard paths 'pkg-config --cflags' will
include the standard include paths and hence the header files are not
found.
So -nostdinc is only useful for mixed installations which is very
unlikely a very common setup. So let's just drop the -nostdinc and if
the need is to support such setups, we can still try to figure out
how to support this.
Daniel Wagner [Fri, 22 Jul 2022 12:29:48 +0000 (14:29 +0200)]
ioctl: Honor rae in nvme_get_nsid_log
The nvme_get_nsid_log() helper has a rae (Retain Asynchronous Events)
parameter, but we currently ignore this when constructing the Get Log
Page command arguments.
This is a behavior change and not an API change. But the good thing is
only for newly build binaries because all helpers are static inline
fuctions.
Reported-by: Reported-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by: Daniel Wagner <dwagner@suse.de>
Daniel Wagner [Fri, 22 Jul 2022 11:43:10 +0000 (13:43 +0200)]
build: Add support to build against LibreSSL
LibreSSL ships with the same API but has a different version number
scheme. That is LibreSSL 3.x is not providing the OpenSSL 3.x
APIs. Hence we need to test if the OpenSSL 3 APIs are available if
LibreSSL is present.
Reported-by: Ismael Luceno <ismael@linux.com> Signed-off-by: Daniel Wagner <dwagner@suse.de>
Steven Seungcheol Lee [Mon, 4 Jul 2022 05:31:46 +0000 (14:31 +0900)]
rpmbuild: Enable 'make rpm' to build rpm pkgs #408
- meson is needed higher version then what rpm repo offering (use pip install)
- Enable building static library (default: shared)
- Add gitignore since make rpm generates tar.gz (when it is failed)
- libuuid-devel dose not needed as rpm pkgs
it could be installed as some files
if it's not installed, will be downloaded from subprojects of meson
- gcc does not needed as rpm pkgs
meson detect compiler with meson.get_compiler('c')
error: Failed build dependencies:
gcc is needed by libnvme-1.0-0.x86_64
libuuid-devel is needed by libnvme-1.0-0.x86_64
Makefile:43: recipe for target 'rpm' failed
make: *** [rpm] Error 1
Signed-off-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
Daniel Wagner [Mon, 18 Jul 2022 14:08:38 +0000 (16:08 +0200)]
build: Update release version rules
Include the release candidate version string into the project
version. This allows to upload every release candidate to PyPI instead
just the final release.
Daniel Wagner [Mon, 18 Jul 2022 14:06:29 +0000 (16:06 +0200)]
build: Support release candidate version strings
The library_version is constructed from the project_version() which
might be a release candidate version. Let's strip away the release
candidate for the library versioning.
Jeremy Kerr [Mon, 18 Jul 2022 05:10:57 +0000 (13:10 +0800)]
mi: Add endpoint get/set timeout API
This change introduces an API for querying and modifying the endpoint
timeout. Transports may provide a function for valiating a new timeout
value before setting.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Martin Belanger [Mon, 11 Jul 2022 12:28:27 +0000 (08:28 -0400)]
python: add __version__ to libnvme python package
It is customary for Python packages to provide a __version__ attribute.
It's not enough just to copy the files to the build directory, we need
also to run the configure step.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
[dwagner: Added information why meson.build has to be changed] Singed-off-by: Daniel Wagner <dwagner@suse.de>
Jeremy Kerr [Wed, 6 Jul 2022 06:31:41 +0000 (14:31 +0800)]
doc: Add a kdoc test for API docs
Even when we're not building docs, it would be handy to have an easy
check that the kernel-doc comments do not produce warnings or errors.
This change adds a test() defintion to docs/, which calls a simple
script, kernel-doc-check. This script invokes kernel-doc, looking for
error and/or warning output.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Mon, 11 Jul 2022 10:08:47 +0000 (18:08 +0800)]
doc/meson: provide a full-path version of api_files
We currently expand api_files into their full paths when constructing
the manpage build rules. However, we'll want to use this same set of
paths for a future change, so provide an expanded version of the array
globally.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Thu, 7 Jul 2022 07:06:19 +0000 (15:06 +0800)]
mi: make return values + errno consistent across error paths
This change unifies and documents the error return values for the MI
implementation. This gives us the following semantics:
- zero on success
- -1 for errors in the MI communication with an endpoint, with errno
set accordingly
- positive values where the MI communication succeeded, but we received
an error response from the endpoint. The return value will be that
from the MI response status field, and should correspond to one of
the nvme_mi_resp_status values.
We add these semantics to the file-level kdoc comments in mi.h.
Most of the changes here are replacing the negative-errno returns:
return -EIO;
with:
errno = EIO;
return -1;
but there are a few slightly-more-involved changes where we need to
preserve errno across a cleanup/log that might clobber it.
For the dbus code in mi-mctp.c, we need to convert the sd_bus convention of
negative-errno values into errno; we can do most of these through the
dbus_err() helper.
Fixes: https://github.com/linux-nvme/libnvme/issues/417 Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Wed, 6 Jul 2022 05:35:22 +0000 (13:35 +0800)]
mi: Add examples for MI configuration commands
Now that we have the MI Get/Set Configuration commands implemented, add
support in examples/mi-mctp to illustrate some basic configuration
interactions.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Tue, 12 Oct 2021 03:13:58 +0000 (11:13 +0800)]
mi: Add MI configuration commands
This change adds an API to send MI Get / Set Configuration commands to
an endpoint, allowing control of endpoint SMBus frequenct, MCTP MTU and
clearing the subsystem health status bits.
We do this with a new couple of functions:
int nvme_mi_mi_config_get(nvme_mi_ep_t ep, __u32 dw0, __u32 dw1,
__u32 *nmresp)
int nvme_mi_mi_config_set(nvme_mi_ep_t ep, __u32 dw0, __u32 dw1)
The dw0, dw1 and nmresp formats depend on the type of configuration
accessed, which can be a little opaque. Se we add a bunch of helpers
too, to get/set the three configuration params:
Jeremy Kerr [Tue, 12 Oct 2021 03:13:58 +0000 (11:13 +0800)]
mi: Add types for MI Get/Set Configuration data
This change adds the mi-specific types for Get/Set configuration
commands: enum nvme_mi_config_id for the currently-defined IDs, and enum
nvme_mi_config_smbus_freq for the possible SMBus frequency configuration
values.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Sat, 2 Jul 2022 06:22:16 +0000 (14:22 +0800)]
types: fix typo on nvme_mi_ccs definitions in public API
The NVMe-MI spec defines the Composite Controller Status definitions
using the abbreviation CCS. However, the libnvme code (since initial
commit) has used CSS, not CCS (except for CCS_RDY...).
This change fixes the definitions to use the _CCS_ names, and adds a set
of #defines to allow the old names to be used, including for the enum
itself.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Mon, 30 May 2022 07:01:18 +0000 (15:01 +0800)]
mi-mctp: Add support for More Processing Required responses
This change allows the mi-mctp transport to receive "more processing
required" responses from MI commands. When we detect a MPR response, we
keep listening for a subsequent message containing the actual response.
The NVMe-MI spec allows for only one MPR response per request.
To do this, we need to perform explicit tag control for MCTP messaging;
we cannot use the kernel's default tag handling, which would expire the
tag value once we've received the first (MPR) response. Instead, we use
the tag control ioctl()s to allocate tags, and expire once we receive
the final response.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Thu, 30 Jun 2022 07:49:12 +0000 (15:49 +0800)]
test: move test_peer->rx_fn function to transmit path
We currently have the peer->rx_fn called after libnvme has sent data to
the NVMe device, as a way for the test to check the sent data and modify
a response accordingly.
However, for testing More Processing Required responses, we will have
two TXes for a single RX. So, move the rx_fn callback to the TX side
(ie, when libnvme calls recvmsg). This allows the test to provide
TX-specific data for each call.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Wed, 29 Jun 2022 10:14:51 +0000 (18:14 +0800)]
mi-mctp: better handling for error/unexpected responses
Currently, the mi-mctp transport expects there to be at least a complete
header-sized reply - matching the caller's resp->hdr_size value,
otherwise we consider this a transport failure.
However, Admin command responses have a header that's larger than the
generic error response message, so we should be able to handle response
messages that are just the small header and no payload.
This change reworks the response-buffer handling in the MCTP transport.
Rather than storing the payload and MIC into an extra allocated buffer,
we just lay out the response iovec directly into the header, payload and
MIC buffers, and then handle the short-response cases as needed. This
means we can properly extract the error response, rather than just
having the transport report a generic "header too small" failure itself.
This is at high risk for off-by-one errors, so add tests to cover each
of the possible buffer-arrangement cases.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Wed, 29 Jun 2022 07:11:24 +0000 (15:11 +0800)]
mi: be pedantic with response message format
This change adds a few tests to check against invalid response data
received by the NVMe-MI device, and some tests to simulate these
conditions.
Because we're checking more of the response fields, we need a bit more
support for constructing default responses in the mi and mi-mctp tests,
so add that too.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Thu, 16 Jun 2022 06:55:40 +0000 (14:55 +0800)]
test: Add initial tests for mi-mctp layer
This change adds a new test module, for the MCTP transport of the MI
layer.
To do this, we hook into the socket, sendmsg and recvmsg calls from the
core mi-mctp code, allowing the test to provide a mock communication
with the kernel MCTP layer.
On top of this, we write a few simple test cases for the socket error
resonses, which we'll extend in future changes.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>