]> www.infradead.org Git - users/sagi/libnvme.git/log
users/sagi/libnvme.git
2 years agofabrics: Fix uuid_from_dmi_entries() read buffer initialization
Tomas Bzatek [Fri, 25 Nov 2022 15:37:32 +0000 (16:37 +0100)]
fabrics: Fix uuid_from_dmi_entries() read buffer initialization

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)

2 years agomi: rename tmp variable inside nvme_mi_admin_get_log
Jinliang Wang [Fri, 25 Nov 2022 07:44:19 +0000 (23:44 -0800)]
mi: rename tmp variable inside nvme_mi_admin_get_log

rename the `tmp` variable into `xfered_size`.
It is hard to figure out a name which can imply that this variable
is used as both input and output parameter, so I choose `xfered_size`
to emphasize the output functionality.

Signed-off-by: Jinliang Wang <jinliangw@google.com>
2 years agoMerge pull request #542 from CodeConstruct/dev/mi-libdbus
Daniel Wagner [Wed, 23 Nov 2022 08:31:54 +0000 (09:31 +0100)]
Merge pull request #542 from CodeConstruct/dev/mi-libdbus

MI: switch from libsdbus to libdbus

2 years agoMI: switch from libsdbus to libdbus
Jeremy Kerr [Mon, 21 Nov 2022 08:35:38 +0000 (16:35 +0800)]
MI: switch from libsdbus to libdbus

libsystemd is not generally available as a static library, and we would
like to produce a static nvme-cli. This change switches to libdbus
instead.

This requires slightly more boilerplate code for the dbus
marshalling/unmarshalling as part of the MCTP endpoint scan, but means
we have a simpler upstream lib dependency.

Fixes: https://github.com/linux-nvme/nvme-cli/issues/1734
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agoMerge pull request #540 from CodeConstruct/pr/mi-endpoint-close
Daniel Wagner [Tue, 22 Nov 2022 09:57:49 +0000 (10:57 +0100)]
Merge pull request #540 from CodeConstruct/pr/mi-endpoint-close

mi: call nvme_mi_close on endpoint error path

2 years agomi: call nvme_mi_close on endpoint error path
Jeremy Kerr [Mon, 21 Nov 2022 08:36:25 +0000 (16:36 +0800)]
mi: call nvme_mi_close on endpoint error path

We need to do more than free() on endpoint close, so call nvme_mi_close
on endpoint creation failure.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agoMerge pull request #538 from martin-belanger/fix-uuid-size
Daniel Wagner [Mon, 21 Nov 2022 08:39:34 +0000 (09:39 +0100)]
Merge pull request #538 from martin-belanger/fix-uuid-size

fabrics: Fix bad UUID size introduced in recent UUID changes

2 years agofabrics: Fix bad UUID size introduced in recent UUID changes
Martin Belanger [Fri, 18 Nov 2022 15:41:32 +0000 (10:41 -0500)]
fabrics: Fix bad UUID size introduced in recent UUID changes

71c25d1cf741 ("util: Add simple UUID type") introduced a regression in
nvmf_get_tel(). nvmf_get_tel() returns the lenght of the binary
representation. Hence use NVME_UUID_LEN instead.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
[dwagner: massaged commit message]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agobuild: Drop --werror for fallback builds
Daniel Wagner [Mon, 21 Nov 2022 08:19:57 +0000 (09:19 +0100)]
build: Drop --werror for fallback builds

The fallback builds will build also the OpenSSL library which triggers a
few compiler warnings. As we already build with the project with
--werror in other configuration there is no loss in coverage dropping
it here.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #536 from igaw/run-cross-tests
Daniel Wagner [Wed, 16 Nov 2022 18:13:51 +0000 (19:13 +0100)]
Merge pull request #536 from igaw/run-cross-tests

Add s390x cross build

2 years agobuild: Add s390x cross build target
Daniel Wagner [Wed, 16 Nov 2022 17:24:05 +0000 (18:24 +0100)]
build: Add s390x cross build target

Add s390x arch to the cross builds so that we have a big endian
target.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agobuild: Do not install libuuid in cross builds
Daniel Wagner [Wed, 16 Nov 2022 17:18:47 +0000 (18:18 +0100)]
build: Do not install libuuid in cross builds

The libray doesn't depend on libuuid anymore.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #535 from igaw/run-cross-tests
Daniel Wagner [Wed, 16 Nov 2022 16:31:26 +0000 (17:31 +0100)]
Merge pull request #535 from igaw/run-cross-tests

build: Run cross build test under qemu

2 years agobuild: Run cross build test under qemu
Daniel Wagner [Wed, 16 Nov 2022 16:05:00 +0000 (17:05 +0100)]
build: Run cross build test under qemu

Use qemu-user-static wrapper to run cross compiled tests.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #534 from igaw/cleanup-static-build
Daniel Wagner [Wed, 16 Nov 2022 16:08:35 +0000 (17:08 +0100)]
Merge pull request #534 from igaw/cleanup-static-build

build: Always set CONFIG_LIBSYSTEMD variable

2 years agobuild: Always set CONFIG_LIBSYSTEMD variable
Daniel Wagner [Wed, 16 Nov 2022 14:02:23 +0000 (15:02 +0100)]
build: Always set CONFIG_LIBSYSTEMD variable

We should always set the CONFIG_LIBSYSTEMD independend if the library
has been found.

Use also the more clear declare_depdency() to express library not
found.

While at it also use more streamlined names for the checks.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #533 from igaw/static-build
Daniel Wagner [Wed, 16 Nov 2022 13:42:21 +0000 (14:42 +0100)]
Merge pull request #533 from igaw/static-build

Support static builds

2 years agobuild: Allow static linking
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.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agobuild: Drop meson version test for 0.48
Daniel Wagner [Wed, 16 Nov 2022 11:06:03 +0000 (12:06 +0100)]
build: Drop meson version test for 0.48

With db8024d88198 ("build: require meson 0.50.0+") we don't need to
test the meson version for the fall through compiler feature.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #532 from igaw/generate-rst-readthedocs
Daniel Wagner [Wed, 16 Nov 2022 10:36:15 +0000 (11:36 +0100)]
Merge pull request #532 from igaw/generate-rst-readthedocs

doc: Generate rst documentation on the fly for readthedocs

2 years agodoc: Generate rst documentation on the fly for readthedocs
Daniel Wagner [Wed, 16 Nov 2022 10:26:48 +0000 (11:26 +0100)]
doc: Generate rst documentation on the fly for readthedocs

Generate the rst files from the source files directly and avoid
storing pre generated ones in the source tree.

Signed-of-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #531 from dankamongmen/dankamongmen/meson-0.50.0
Daniel Wagner [Wed, 16 Nov 2022 08:55:01 +0000 (09:55 +0100)]
Merge pull request #531 from dankamongmen/dankamongmen/meson-0.50.0

build: require meson 0.50.0+

2 years agobuild: require meson 0.50.0+
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>
2 years agodoc: Fix spelling mistakes found by lintian
Benjamin Drung [Thu, 10 Nov 2022 15:43:52 +0000 (16:43 +0100)]
doc: Fix spelling mistakes found by lintian

lintian complains about following spelling mistakes in libnvme 1.2:

```
I: libnvme1: spelling-error-in-binary commmand command [usr/lib/x86_64-linux-gnu/libnvme.so.1.2.0]
I: libnvme1: spelling-error-in-binary connnected connected [usr/lib/x86_64-linux-gnu/libnvme.so.1.2.0]
I: libnvme-dev: typo-in-manual-page Lenght Length [usr/share/man/man2/nvmf_exat_len.2.gz:15]
I: libnvme-dev: typo-in-manual-page Retreive Retrieve [usr/share/man/man2/nvme_get_feature_length.2.gz:3]
I: libnvme-dev: typo-in-manual-page Retreive Retrieve [usr/share/man/man2/nvme_get_feature_length2.2.gz:3]
I: libnvme-dev: typo-in-manual-page identifers identifiers [usr/share/man/man2/nvme_set_features_host_id.2.gz:3]
I: libnvme-dev: typo-in-manual-page lenght length [usr/share/man/man2/nvmf_exat_len.2.gz:9]
I: libnvme-dev: typo-in-manual-page namepsaces namespaces [usr/share/man/man2/nvme_dev_self_test.2.gz:18]
```

Fix all occurrences of those spelling mistakes.

Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
2 years agoMerge pull request #529 from CodeConstruct/pr/be
Daniel Wagner [Thu, 10 Nov 2022 07:45:45 +0000 (08:45 +0100)]
Merge pull request #529 from CodeConstruct/pr/be

mi: endian fixes

2 years agomi: endian fixes
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>
2 years agofabrics: fix a check-after-dereference error in nvmf_discovery_log()
Maurizio Lombardi [Tue, 8 Nov 2022 10:00:06 +0000 (11:00 +0100)]
fabrics: fix a check-after-dereference error in nvmf_discovery_log()

logp pointer can't be NULL, because it has already been dereferenced,
the function should check *logp instead.

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
2 years agoutil: fix a file handle leak in nvme_uuid_random()
Maurizio Lombardi [Tue, 8 Nov 2022 10:35:27 +0000 (11:35 +0100)]
util: fix a file handle leak in nvme_uuid_random()

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
2 years agomi: fix a static checker warning in examples/mi-mctp
Maurizio Lombardi [Tue, 8 Nov 2022 09:54:32 +0000 (10:54 +0100)]
mi: fix a static checker warning in examples/mi-mctp

tmp is an "unsigned long" variable so it can't be less than zero.

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
2 years agoMerge pull request #528 from jinliangw/master
Daniel Wagner [Wed, 9 Nov 2022 09:23:04 +0000 (10:23 +0100)]
Merge pull request #528 from jinliangw/master

mi: fix rc checking

2 years agomi: fix rc checking
Jinliang Wang [Tue, 8 Nov 2022 21:39:43 +0000 (13:39 -0800)]
mi: fix rc checking

nvme_mi_admin_admin_passthru forgets to check the rc after
nvme_mi_admin_parse_status.

Signed-off-by: Jinliang Wang <jinliangw@google.com>
2 years agoMerge pull request #522 from igaw/use-nvme_get_log_page
Keith Busch [Mon, 7 Nov 2022 16:11:34 +0000 (09:11 -0700)]
Merge pull request #522 from igaw/use-nvme_get_log_page

Use nvme_get_log_page

2 years agomi: add nvme_mi_admin_admin_passthru
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>
2 years agoMerge pull request #521 from martin-belanger/release-python-gil
Daniel Wagner [Mon, 7 Nov 2022 10:18:47 +0000 (11:18 +0100)]
Merge pull request #521 from martin-belanger/release-python-gil

python: Release GIL on blocking calls

2 years agopython: Release GIL on blocking calls
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>
2 years agoMerge pull request #520 from CodeConstruct/pr/mi-status
Daniel Wagner [Mon, 7 Nov 2022 10:13:32 +0000 (11:13 +0100)]
Merge pull request #520 from CodeConstruct/pr/mi-status

mi: Fix status extraction from cdw3 field

2 years agoMerge pull request #514 from CodeConstruct/dev/mi-quirks
Daniel Wagner [Mon, 7 Nov 2022 10:12:14 +0000 (11:12 +0100)]
Merge pull request #514 from CodeConstruct/dev/mi-quirks

MI quirk implementation

2 years agoMerge pull request #517 from drakedog2008/pr/bug-fix
Daniel Wagner [Mon, 7 Nov 2022 09:41:17 +0000 (10:41 +0100)]
Merge pull request #517 from drakedog2008/pr/bug-fix

mi: Allow zero as a controller ID in nvme_mi_scan_ep

2 years agoMerge pull request #515 from CodeConstruct/dev/mi-ctrl-list-nsid
Daniel Wagner [Mon, 7 Nov 2022 09:40:15 +0000 (10:40 +0100)]
Merge pull request #515 from CodeConstruct/dev/mi-ctrl-list-nsid

mi: Issue a NSID-specific Controller List Identify in nsid_ctrl_list()

2 years agoioctl: Use nvme_get_log_page() in helpers
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.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoioctl: Move nvme_get_log_page() to ioctl.h
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.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agomi: Fix status extraction from cdw3 field
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>
2 years agomi: Add inter-command-delay quirk for Samsung MZUL2512 devices
Jeremy Kerr [Wed, 21 Sep 2022 12:57:01 +0000 (20:57 +0800)]
mi: Add inter-command-delay quirk for Samsung MZUL2512 devices

This change is our first application of a quirk: Samsung MZUL2512
devices need the inter-command-delay of around 1ms. Make it 1.2ms just
to be safe.

This makes these devices work in my environment. Otherwise, commands
will get dropped, and subsequently time out.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agodoc: Add documentation for MI probe behaviour
Jeremy Kerr [Mon, 31 Oct 2022 05:40:20 +0000 (13:40 +0800)]
doc: Add documentation for MI probe behaviour

This change adds a small description of the probe behaviour, and the
control using the LIBNVME_MI_PROBE_ENABLED env var.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agomi: Print applied quirks
Jeremy Kerr [Fri, 28 Oct 2022 02:38:24 +0000 (10:38 +0800)]
mi: Print applied quirks

This change adds a LOG_DEBUG message if we are applying any quirks after
a successful device probe.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agomi: Add model detection via identify in nvme_mi_ep_probe()
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>
2 years agomi: Add inter-command-delay quirk
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>
2 years agomi: Allow probe suppression via an environment variable
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>
2 years agomi: Introduce quirks and endpoint probing
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:

    nvme_mi_set_probe_enabled(nvme_root_t root, bool enabled);

Which will prevent sending any probe commands, and leave the quirks
field unset.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agoMerge pull request #519 from igaw/pkg-config
Daniel Wagner [Wed, 2 Nov 2022 15:14:03 +0000 (16:14 +0100)]
Merge pull request #519 from igaw/pkg-config

build: Remove usused pkg-config template

2 years agobuild: Remove usused pkg-config template
Daniel Wagner [Wed, 2 Nov 2022 14:42:35 +0000 (15:42 +0100)]
build: Remove usused pkg-config template

Meson's pkgconfig module is used to generated the pkg-config file. The
template is a left over when the project was still using Makefiles.

While at is also drop the unused command line option 'pkgconfiglibdir'

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agomi: Allow zero as a controller ID in nvme_mi_scan_ep
Hao Jiang [Wed, 2 Nov 2022 00:03:07 +0000 (17:03 -0700)]
mi: Allow zero as a controller ID in nvme_mi_scan_ep

ctrl_id of 0 should be still considered as valid. Remove the condition
check correspondingly.

Signed-off-by: Hao Jiang <jianghao@google.com>
2 years agomi: Issue a NSID-specific Controller List Identify in nsid_ctrl_list()
Jeremy Kerr [Tue, 1 Nov 2022 06:30:35 +0000 (14:30 +0800)]
mi: Issue a NSID-specific Controller List Identify in nsid_ctrl_list()

We need a NSIS Controller List CNS value when requesting a NSID-specific
list; we're currently using a non-NSID-specific Identify here.

Reported-by: Willy Tu <wltu@google.com>
Tested-by: Willy Tu <wltu@google.com>
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agodoc: Regenerate all docs for v1.2 v1.2
Daniel Wagner [Fri, 28 Oct 2022 17:23:49 +0000 (19:23 +0200)]
doc: Regenerate all docs for v1.2

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agobuild: Update version to v1.2
Daniel Wagner [Fri, 28 Oct 2022 17:23:01 +0000 (19:23 +0200)]
build: Update version to v1.2

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #513 from igaw/move-def
Daniel Wagner [Fri, 28 Oct 2022 15:06:47 +0000 (17:06 +0200)]
Merge pull request #513 from igaw/move-def

types: Move enum nvme_data_tfr to types

2 years agotypes: Move enum nvme_data_tfr to types
Daniel Wagner [Fri, 28 Oct 2022 15:01:46 +0000 (17:01 +0200)]
types: Move enum nvme_data_tfr to types

As this is part of the spec, let's move this to the types.h header
file.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #512 from igaw/fix-merge-config
Daniel Wagner [Fri, 28 Oct 2022 14:51:23 +0000 (16:51 +0200)]
Merge pull request #512 from igaw/fix-merge-config

fabris: Use doublicate string when merging configs

2 years agofabrics: Duplicate strings when merging configs
Daniel Wagner [Fri, 28 Oct 2022 14:42:21 +0000 (16:42 +0200)]
fabrics: Duplicate strings when merging configs

We have to use strdup here, because the merged config will be freeing
these pointers eventually. Without it, we are going to double free it.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #511 from igaw/build-min-verison-fix
Daniel Wagner [Fri, 28 Oct 2022 09:24:28 +0000 (11:24 +0200)]
Merge pull request #511 from igaw/build-min-verison-fix

build: Update min version of meson to 0.48

2 years agoMerge pull request #510 from igaw/pass-lpo-arg
Daniel Wagner [Fri, 28 Oct 2022 07:16:25 +0000 (09:16 +0200)]
Merge pull request #510 from igaw/pass-lpo-arg

 Set log page offset for nvme_{mi}_get_log_telemetry_host

2 years agobuild: Update min version of meson to 0.48
Daniel Wagner [Thu, 27 Oct 2022 16:13:48 +0000 (18:13 +0200)]
build: Update min version of meson to 0.48

python3.extension_module() is depending on gnu_symbol_visibility. So
arguably, this has been from day 0.

Version 0.47 was released on Jul 02, 2018 and 0.48 on Sep 22,
2018. Even Debian oldstable ships 0.49.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agomi: Set log page offset for nvme_get_log_telemetry_host
Daniel Wagner [Thu, 27 Oct 2022 15:45:11 +0000 (17:45 +0200)]
mi: Set log page offset for nvme_get_log_telemetry_host

The function is not setting the passed in offset.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoioctl: Set log page offset for nvme_get_log_telemetry_host
Daniel Wagner [Thu, 27 Oct 2022 15:44:14 +0000 (17:44 +0200)]
ioctl: Set log page offset for nvme_get_log_telemetry_host

The function is not setting the passed in offset.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #497 from igaw/drop-libuuid
Daniel Wagner [Thu, 27 Oct 2022 14:16:36 +0000 (16:16 +0200)]
Merge pull request #497 from igaw/drop-libuuid

util: Add simple UUID type

2 years agoutil: Add simple UUID type
Daniel Wagner [Thu, 13 Oct 2022 15:05:50 +0000 (17:05 +0200)]
util: Add simple UUID type

Provide our own UUID type as there is no point to have a dependency on
libuuid just for a couple function we use.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #508 from martin-gpy/add_is_persistent
Daniel Wagner [Thu, 27 Oct 2022 13:28:57 +0000 (15:28 +0200)]
Merge pull request #508 from martin-gpy/add_is_persistent

libnvme.map: add nvme_ctrl_is_persistent()

2 years agolibnvme.map: add nvme_ctrl_is_persistent()
Martin George [Thu, 27 Oct 2022 11:10:35 +0000 (16:40 +0530)]
libnvme.map: add nvme_ctrl_is_persistent()

Add nvme_ctrl_is_persistent() to the global list for use in nvme-cli.

Signed-off-by: Martin George <marting@netapp.com>
2 years agoMerge pull request #507 from igaw/private-fallhtrough-define
Daniel Wagner [Tue, 25 Oct 2022 08:40:26 +0000 (10:40 +0200)]
Merge pull request #507 from igaw/private-fallhtrough-define

util: Do not expose fallthrough defines

2 years agoutil: Do not expose fallthrough defines
Daniel Wagner [Tue, 25 Oct 2022 08:35:08 +0000 (10:35 +0200)]
util: Do not expose fallthrough defines

Use meson to detect if the compiler supports the fallthrough attribute
and if so just add corresponding define to the private config.h.

This avoid leaking the fallthrough define outside of the projects
which can cause consuming projects to fail to compile.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #504 from CodeConstruct/pr/mi-conf-mtu
Daniel Wagner [Mon, 24 Oct 2022 13:05:18 +0000 (15:05 +0200)]
Merge pull request #504 from CodeConstruct/pr/mi-conf-mtu

examples/mi-conf: account for MCTP header in route MTU

2 years agoMerge pull request #503 from CodeConstruct/pr/mi-conf-err
Daniel Wagner [Mon, 24 Oct 2022 13:04:38 +0000 (15:04 +0200)]
Merge pull request #503 from CodeConstruct/pr/mi-conf-err

examples/mi-conf: Initialise sd_bus_error

2 years agoMerge pull request #502 from CodeConstruct/pr/mi-status
Daniel Wagner [Mon, 24 Oct 2022 12:56:09 +0000 (14:56 +0200)]
Merge pull request #502 from CodeConstruct/pr/mi-status

Add encoding for MI/NVMe status values

2 years agoexamples/mi-conf: account for MCTP header in route MTU
Jeremy Kerr [Mon, 24 Oct 2022 10:26:41 +0000 (18:26 +0800)]
examples/mi-conf: account for MCTP header in route MTU

The NVMe specs don't include the MCTP header when referring to the MCTP
MTUs; we need to do so when setting the Linux route MTU.

This change uses the header-included value when setting the route MTU
via mctpd over dbus.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agoexamples/mi-conf: Initialise sd_bus_error
Jeremy Kerr [Mon, 24 Oct 2022 09:58:42 +0000 (17:58 +0800)]
examples/mi-conf: Initialise sd_bus_error

The sd_bus methods may return EINVAL if err is not initialised to NULL.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agomi: add nvme_mi_status_to_string()
Jeremy Kerr [Sun, 23 Oct 2022 08:01:48 +0000 (16:01 +0800)]
mi: add nvme_mi_status_to_string()

Add a function, similar to nvme_status_to_string(), that returns a
string value of the spec-defined wording for each status value.

We keep this in the mi object for now, to keep the existing division of
libnvme.so/libnvme-mi.so

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agomi: Distinguish MI status from NVMe (CDW3) status
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>
2 years agomi: Add Identify helper for ns-descs and primary-ctrl-caps
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>
2 years agoMerge pull request #501 from safl/mk
Daniel Wagner [Fri, 21 Oct 2022 07:50:53 +0000 (09:50 +0200)]
Merge pull request #501 from safl/mk

Makefile: add 'make uninstall'

2 years agoMerge pull request #494 from ikegami-t/set-feature-0dh
Daniel Wagner [Fri, 21 Oct 2022 07:49:39 +0000 (09:49 +0200)]
Merge pull request #494 from ikegami-t/set-feature-0dh

libnvme: Add direction parameter to get feature length

2 years agofabrics: Use fallthrough statement
Daniel Wagner [Fri, 21 Oct 2022 07:17:15 +0000 (09:17 +0200)]
fabrics: Use fallthrough statement

Use consistently the fallthrough statement as we have a fallback in
util.h in case the compiler doesn't support it.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoutil: Add get feature length 2 API to support direction parameter
Tokunori Ikegami [Thu, 13 Oct 2022 16:07:24 +0000 (01:07 +0900)]
util: Add get feature length 2 API to support direction parameter

Since feature identifier 0Dh: host memory buffer length is affected by the
direction as mentioned by the issue #1681.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
[dwagner: reordered definitions and declerations]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMakefile: add 'make uninstall'
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>
2 years agoMerge pull request #499 from CodeConstruct/pr/log-page
Daniel Wagner [Wed, 19 Oct 2022 12:10:58 +0000 (14:10 +0200)]
Merge pull request #499 from CodeConstruct/pr/log-page

mi: fix get_log_page chunked offset check

2 years agomi: fix get_log_page chunked offset check
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>
2 years agoMerge pull request #491 from igaw/harden-json-parser
Daniel Wagner [Tue, 18 Oct 2022 16:43:45 +0000 (18:43 +0200)]
Merge pull request #491 from igaw/harden-json-parser

Enforce correct JSON config format

2 years agoMerge pull request #493 from maurizio-lombardi/memleak
Daniel Wagner [Tue, 18 Oct 2022 08:24:20 +0000 (10:24 +0200)]
Merge pull request #493 from maurizio-lombardi/memleak

libnvme: fix a memory leak in nvme_mi_open_mctp()

2 years agomi: fix a memory leak in nvme_mi_open_mctp()
Maurizio Lombardi [Tue, 11 Oct 2022 08:29:59 +0000 (10:29 +0200)]
mi: fix a memory leak in nvme_mi_open_mctp()

If the call to ops.socket() fails, the mctp pointer will be leaked.

2 years agomi: Init ctrl_id within xfer
Hao Jiang [Thu, 29 Sep 2022 01:00:58 +0000 (18:00 -0700)]
mi: Init ctrl_id within xfer

The xfer() requires a `nvme_mi_ctrl_t ctrl` as input so the ctrl_id
should be included in `ctrl` instead of from
`nvme_mi_admin_req_hdr.ctrl_id`.

Signed-off-by: Hao Jiang <jianghao@google.com>
2 years agoMerge pull request #489 from drakedog2008/description
Daniel Wagner [Mon, 3 Oct 2022 08:49:48 +0000 (10:49 +0200)]
Merge pull request #489 from drakedog2008/description

Add more details for return code of MI admin cmds

2 years agojson: Verify JSON config file starts with an array
Daniel Wagner [Fri, 30 Sep 2022 10:30:03 +0000 (12:30 +0200)]
json: Verify JSON config file starts with an array

Do not blindly assume the file starts with an array. This avoids a
crash in json-c.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agojson: Enforce correctly formatted JSON config files
Daniel Wagner [Fri, 30 Sep 2022 10:10:04 +0000 (12:10 +0200)]
json: Enforce correctly formatted JSON config files

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.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoAdd more details for return code of MI admin cmds
Hao Jiang [Wed, 28 Sep 2022 18:36:20 +0000 (11:36 -0700)]
Add more details for return code of MI admin cmds

The admin cmd of libnvme-mi returns negitive number(-1) with errno.
Otherwise it returns nvme-mi status byte (byte 4). And status = 0 means
`Success`.

It is the same behavior as the none-mi version. Align the description
of libnvme-mi to libnvme.

Signed-off-by: Hao Jiang <jianghao@google.com>
2 years agoMerge pull request #488 from martin-belanger/fix-examples
Daniel Wagner [Wed, 28 Sep 2022 13:56:06 +0000 (15:56 +0200)]
Merge pull request #488 from martin-belanger/fix-examples

examples: LID supported must be shifted right by 16

2 years agoexamples: LID supported must be shifted right by 16
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>
2 years agoMerge pull request #487 from martin-belanger/eliminate-empty-arguments
Daniel Wagner [Tue, 27 Sep 2022 15:03:25 +0000 (17:03 +0200)]
Merge pull request #487 from martin-belanger/eliminate-empty-arguments

fabrics: Filter out empty strings in add_argument()

2 years agofabrics: Filter out empty strings in add_argument()
Martin Belanger [Tue, 27 Sep 2022 14:09:33 +0000 (10:09 -0400)]
fabrics: Filter out empty strings in add_argument()

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
2 years agoMerge pull request #486 from martin-belanger/add-pleo-support-py
Daniel Wagner [Tue, 27 Sep 2022 11:26:45 +0000 (13:26 +0200)]
Merge pull request #486 from martin-belanger/add-pleo-support-py

python: Use nvmf_get_discovery_wargs()

2 years agoMerge pull request #483 from martin-belanger/add-pleo-support
Daniel Wagner [Tue, 27 Sep 2022 07:31:15 +0000 (09:31 +0200)]
Merge pull request #483 from martin-belanger/add-pleo-support

fabrics: Add nvmf_get_discovery_wargs()

2 years agoMerge pull request #482 from CodeConstruct/dev/mi-firmware
Daniel Wagner [Mon, 26 Sep 2022 13:52:12 +0000 (15:52 +0200)]
Merge pull request #482 from CodeConstruct/dev/mi-firmware

mi: Add firmware download and commit commands