Valgrind complaining about accessing uninitialized memory:
==159962== Conditional jump or move depends on uninitialised value(s)
==159962== at 0x484BCF6: rawmemchr (vg_replace_strmem.c:1564)
==159962== by 0x4F52B15: _IO_str_init_static_internal (strops.c:41)
==159962== by 0x4F1DAB1: UnknownInlinedFun (strfile.h:95)
==159962== by 0x4F1DAB1: __isoc99_sscanf (isoc99_sscanf.c:28)
==159962== by 0x7B77C97: uuid_from_dmi_entries (fabrics.c:969)
==159962== by 0x7B84192: UnknownInlinedFun (fabrics.c:1059)
==159962== by 0x7B84192: nvmf_hostnqn_generate (fabrics.c:1070)
Daniel Wagner [Wed, 16 Nov 2022 13:17:15 +0000 (14:17 +0100)]
build: Allow static linking
To allow static linking, we have to make the libnss dependency
optional. This means the hostname IP resolution feature is not
available in this configuration.
Also the libystemd dependency check doesn't take into account that we
want to link statically. Lukily we just need this for an example.
Currently, the OpenSSL library build will fail in the example
(dependency on libnss) but the library is available to link.
nick black [Sun, 13 Nov 2022 21:27:28 +0000 (16:27 -0500)]
build: require meson 0.50.0+
The Meson buildspec uses features ('plain strings for
include_directories') introduced in Meson 0.50.0, but only specifies
0.48.0. Eliminates a Meson warning.
Signed-off-by: nick black <dankamongmen@gmail.com>
Jeremy Kerr [Thu, 10 Nov 2022 04:20:37 +0000 (12:20 +0800)]
mi: endian fixes
We have a couple of endian issues in the mi code: one where we're not
converting cdw0 for MI commands, and one where we're using the wrong
byte length for an existing conversion. There is also an error in the
test suite, where we should be converting the nsze field of a
nvme_id_ns.
This change fixes those, so that the test suite passes on a BE platform
(ppc64 in my case).
Fixes: https://github.com/linux-nvme/libnvme/issues/524 Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jinliang Wang [Fri, 28 Oct 2022 15:42:10 +0000 (08:42 -0700)]
mi: add nvme_mi_admin_admin_passthru
Similar to nvme_admin_passthru, send a customized NVMe Admin command
request message and get the corresponding response message.
Currently, it only supports data xfer size <= 4096.
Signed-off-by: Jinliang Wang <jinliangw@google.com>
[dwagner: refactored has_*_data checks] Signed-off-by: Daniel Wagner <dwagner@suse.de>
Martin Belanger [Fri, 4 Nov 2022 18:53:44 +0000 (14:53 -0400)]
python: Release GIL on blocking calls
Release Python's GIL (global interpreter lock) when invoking blocking
functions from multithreaded Python applications. This is to prevent
long running threads to block all other threads.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Daniel Wagner [Mon, 7 Nov 2022 09:31:20 +0000 (10:31 +0100)]
ioctl: Use nvme_get_log_page() in helpers
We use directly nvme_get_log() calls for many of the defined
helpers (e.g. nvme_get_log_persistent_event()). Though when the size
of the data is really large, nvme_get_log() is not able to transfer
the data (size exceeds what the kernel driver fit in a request).
Thus limit the transfer sizes in all helpers to 4k.
Daniel Wagner [Mon, 7 Nov 2022 09:19:38 +0000 (10:19 +0100)]
ioctl: Move nvme_get_log_page() to ioctl.h
Currently we use directly nvme_get_log() calls for many of the defined
helpers (e.g. nvme_get_log_persistent_event()). Though when the size
of the data is really large, nvme_get_log() is not able to transfer
the data (size exceeds what the kernel driver fit in a request).
In order to be able to use nvme_get_log_page() we have to move to
ioctl.h to avoid circular include dependency.
Jeremy Kerr [Fri, 4 Nov 2022 06:17:00 +0000 (14:17 +0800)]
mi: Fix status extraction from cdw3 field
Currently, we extract the NVMe status value from the top two bytes of
cdw3 of the response.
However, the Status Code (SC) field actually starts at bit 17 (where the
lsbit is bit 0), so we need to be shifting down by 17 instead. This
makes the status align with the enum nvme_status_field values.
Add an explicit test for this, and clarify that the existing admin_err
test is for the MI header status field.
Fixes: 108d696 ("mi: Introduce a helper for response status, unify values with ioctls") Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Wed, 21 Sep 2022 12:57:01 +0000 (20:57 +0800)]
mi: Add model detection via identify in nvme_mi_ep_probe()
In order to allow model-based probing, this change introduces
infrastructure to nvme_mi_ep_probe() to perform an Identify Controller
command, the results of which we can use in future quirk detection.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Wed, 21 Sep 2022 12:39:34 +0000 (20:39 +0800)]
mi: Add inter-command-delay quirk
Some NVMe-MI controllers will not respond to a command that is sent too
soon after the previous response. This change our first quirk, which
inserts a suitable delay if necessary (ie, the quirk is set, and a
command is sent before the minimum delay time).
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Mon, 31 Oct 2022 05:39:09 +0000 (13:39 +0800)]
mi: Allow probe suppression via an environment variable
This change introduces a new environment variable to disable quirk
probing: LIBNVME_MI_PROBE_ENABLED. Values of 0, "off" or "disable{d}"
will prevent the probe.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Tue, 20 Sep 2022 12:44:09 +0000 (20:44 +0800)]
mi: Introduce quirks and endpoint probing
This change introduces a little framework for adding device-specific
quirk flags. This allows the MI core to perform any queries on the
device, and set any quirk flags on specific devices.
This gives us a new (mi-internal) function:
bool nvme_mi_ep_has_quirk(struct nvme_mi_ep *tp, unsigned long quirk)
which returns true if `quirk` is enabled on this endpoint.
Callers can disable probing through a new external API:
Jeremy Kerr [Thu, 20 Oct 2022 07:02:10 +0000 (15:02 +0800)]
mi: Distinguish MI status from NVMe (CDW3) status
We curerently have some overloading in the status values returned from
the nvme_* API, as the NVMe CDW3 values overlap with the
recently-introduced NVMe-MI response header status.
This change introduces a new encoding for the return values of MI
functions, where we use a set of bits in the return value to encode
whether the value is either a MI status value or a NVMe status value. We
leave room for future expansion too, by defining three bits of possible
type values.
This has minimal change to the current API, as we're using 0 for the
current NVMe status codes, so they are all unchanged. Since the MI
values alised those, they will have high bits set now, but we couldn't
previously distinguish them from the NVMe values anyway.
Fixes: https://github.com/linux-nvme/libnvme/issues/456 Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jinliang Wang [Tue, 11 Oct 2022 17:20:58 +0000 (10:20 -0700)]
mi: Add Identify helper for ns-descs and primary-ctrl-caps
This change adds two helpers for the Identify command, retrieving the
namespace identification descriptior list and primary controller capabilities
data structure.
Signed-off-by: Jinliang Wang <jinliangw@google.com>
Simon A. F. Lund [Thu, 20 Oct 2022 10:09:49 +0000 (12:09 +0200)]
Makefile: add 'make uninstall'
An uninstall option, in addition to RPM install/uninstall, is arguably
quite convenient. Yet, Makefiles usually do not provide an 'uninstall'
target since that would require recording an installation manifest and
custom logic for removal.
However, meson has an internal feature doing precisely that.
This change invokes the meson uninstall feature via "make uninstall".
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Jeremy Kerr [Wed, 28 Sep 2022 09:44:24 +0000 (17:44 +0800)]
mi: fix get_log_page chunked offset check
In our get_log_page helper, we're incorrectly checking the requested
chunk offset against the chunk len, rather than the overall length -
this means we can't query anything but the first chunk.
This change fixes this to check against the overall length instead, and
adds an additional check to ensure we're not requesting more than the
full data size.
We also add a testcase for the chunking code.
Reported-by: Hao Jiang <jianghao@google.com> Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
json-c's json_object_from_fd() doesn't set the JSON_TOKENER_STRICT
flag. This means the parser is more failure tolerant. Let's be strict
and enforce fully correctly formatted configuration.
Martin Belanger [Wed, 28 Sep 2022 12:57:33 +0000 (08:57 -0400)]
examples: LID supported must be shifted right by 16
To access the LID Specific Field (see Base specs) the values
from the Get Supported Log pages must be shifted right by 16.
The example code was missing the shift.
Also added better exception handling example.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Jeremy Kerr [Mon, 26 Sep 2022 13:10:22 +0000 (21:10 +0800)]
mi: Move post-1.1 symbols to 1_2 section of libnvme-mi.map
There have been a few functions added after the v1.1 release that ended
up in the 1_1 section of the symbol map. This change moves them to a new
1_2 section instead.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Martin Belanger [Mon, 26 Sep 2022 11:13:55 +0000 (07:13 -0400)]
fabrics: Add nvmf_get_discovery_wargs()
This function is similar to nvmf_get_discovery_log(), but takes
an extensible "args" parameter. The args parameter contains more
options than are available with nvmf_get_discovery_log(). For
example, it provides a way to set the LSP (Log page Specific field)
which is needed for advanced TP8010 features.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>