]> www.infradead.org Git - users/sagi/libnvme.git/log
users/sagi/libnvme.git
2 years agoMerge pull request #576 from igaw/fix-strchomp-callers
Daniel Wagner [Tue, 7 Feb 2023 08:41:47 +0000 (09:41 +0100)]
Merge pull request #576 from igaw/fix-strchomp-callers

fabrics: Do not ignore one char whitespace when string sanitizing

2 years agofabrics: Do not ignore one char whitespace when string sanitizing
Daniel Wagner [Tue, 7 Feb 2023 08:30:42 +0000 (09:30 +0100)]
fabrics: Do not ignore one char whitespace when string sanitizing

strchomp() is handling the max length of a string correctly.

Reported-by: calebsander
Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #575 from igaw/update-dbus-wrap
Daniel Wagner [Tue, 7 Feb 2023 08:25:08 +0000 (09:25 +0100)]
Merge pull request #575 from igaw/update-dbus-wrap

build: Update dbus.wrap

2 years agobuild: Update dbus.wrap
Daniel Wagner [Tue, 7 Feb 2023 06:56:32 +0000 (07:56 +0100)]
build: Update dbus.wrap

The 'use list for dbus_static_flags' fix has been merged which adds
support older version Meson.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #570 from tbzatek/nss
Daniel Wagner [Wed, 1 Feb 2023 07:29:58 +0000 (08:29 +0100)]
Merge pull request #570 from tbzatek/nss

build: Fix nss code snippet includes

2 years agobuild: Fix nss code snippet includes
Tomas Bzatek [Tue, 31 Jan 2023 22:27:53 +0000 (23:27 +0100)]
build: Fix nss code snippet includes

With hardened distribution CFLAGS the meson code snippet wouldn't compile:

Compiler stderr:
  .build/meson-private/tmpy2z1t5q4/testfile.c: In function 'main':
  .build/meson-private/tmpy2z1t5q4/testfile.c:2:30: error: storage size of 'hints' isn't known
      2 |              struct addrinfo hints, *result;
        |                              ^~~~~
  .build/meson-private/tmpy2z1t5q4/testfile.c:3:21: warning: implicit declaration of function 'getaddrinfo' [-Wimplicit-function-declaration]
      3 |              return getaddrinfo(argv[1], argv[2], &hints, &result);
        |                     ^~~~~~~~~~~

2 years agodoc: Regenerate all docs for v1.3 v1.3
Daniel Wagner [Mon, 30 Jan 2023 13:09:52 +0000 (14:09 +0100)]
doc: Regenerate all docs for v1.3

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agobuild: Update version to v1.3
Daniel Wagner [Mon, 30 Jan 2023 13:09:26 +0000 (14:09 +0100)]
build: Update version to v1.3

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #569 from ikegami-t/dst
Daniel Wagner [Sun, 29 Jan 2023 19:06:59 +0000 (20:06 +0100)]
Merge pull request #569 from ikegami-t/dst

types: Add abort self-test code value definition

2 years agotypes: Add abort self-test code value definition
Tokunori Ikegami [Fri, 27 Jan 2023 15:42:12 +0000 (00:42 +0900)]
types: Add abort self-test code value definition

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
2 years agoMerge pull request #567 from igaw/fix-strchomp
Daniel Wagner [Fri, 27 Jan 2023 09:42:51 +0000 (10:42 +0100)]
Merge pull request #567 from igaw/fix-strchomp

fabrics: Avoid buffer overrun in strchomp

2 years agofabrics: Avoid buffer overrun in strchomp
Daniel Wagner [Fri, 27 Jan 2023 09:28:49 +0000 (10:28 +0100)]
fabrics: Avoid buffer overrun in strchomp

strchomp() has an off-by-one error and starts stripping spaces at the
byte AFTER the end of the buffer.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #566 from birkelund/fix-event-timestamp
Daniel Wagner [Thu, 26 Jan 2023 08:32:42 +0000 (09:32 +0100)]
Merge pull request #566 from birkelund/fix-event-timestamp

types: use nvme_timestamp for fdp events

2 years agoMerge pull request #565 from CodeConstruct/pr/563
Daniel Wagner [Thu, 26 Jan 2023 08:28:31 +0000 (09:28 +0100)]
Merge pull request #565 from CodeConstruct/pr/563

test: mi: ensure we're providing full initialised buffers to the libnvme-mi API

2 years agotypes: use nvme_timestamp for fdp events
Klaus Jensen [Thu, 26 Jan 2023 08:18:06 +0000 (09:18 +0100)]
types: use nvme_timestamp for fdp events

The timestamp member of nvme_fdp_event is a proper NVMe Timestamp, so
use the actual data structure for it.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
2 years agotest: mi: Provide a full request buffer for invalid admin req tests
Jeremy Kerr [Thu, 26 Jan 2023 02:28:49 +0000 (10:28 +0800)]
test: mi: Provide a full request buffer for invalid admin req tests

We're issuing an admin command with up to four bytes of data in the
request. Although these will all fail due to invalid args, we still want
to provide enough data to simulate the full request.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agotest: mi: Explicitly zero args for test API invocations
Jeremy Kerr [Thu, 26 Jan 2023 02:24:54 +0000 (10:24 +0800)]
test: mi: Explicitly zero args for test API invocations

We have a few places where we're passing an uninitialised pointer
argument to the libnvme API in the MI tests. Add an explicit zero init
for these.

Fixes: https://github.com/linux-nvme/libnvme/issues/563
Reported-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agoMerge pull request #562 from igaw/sanitize-disc-log
Daniel Wagner [Wed, 25 Jan 2023 11:18:43 +0000 (12:18 +0100)]
Merge pull request #562 from igaw/sanitize-disc-log

fabrics: Always sanitize discovery log entries

2 years agoMerge pull request #564 from igaw/make-pdc-optional
Daniel Wagner [Wed, 25 Jan 2023 11:18:06 +0000 (12:18 +0100)]
Merge pull request #564 from igaw/make-pdc-optional

tree: Add persistent_discovery_ctrl config flag

2 years agotree: Add persistent_discovery_ctrl config flag
Daniel Wagner [Wed, 25 Jan 2023 09:37:13 +0000 (10:37 +0100)]
tree: Add persistent_discovery_ctrl config flag

Allow to overwrite the system default Persistent Discovery Controller
behavior via the config.json file.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agofabrics: Always sanitize discovery log entries
Daniel Wagner [Tue, 24 Jan 2023 10:50:01 +0000 (11:50 +0100)]
fabrics: Always sanitize discovery log entries

Do not just sanitize the traddr and trsvcid when unsing the auto
discovery/connect path, instead also do it for all users of
nvmf_get_discovery_log{_args}() per default.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agogitignore: Ignore clang build artifacts
Daniel Wagner [Fri, 20 Jan 2023 09:39:19 +0000 (10:39 +0100)]
gitignore: Ignore clang build artifacts

When using language server support from clang, the .cache directory is
added. Also for getting lsp working properly the compile_commands.json
file has to present (which is just a link to Meson generared json file).

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #560 from igaw/fix-non-trivial-designeded-initializers
Daniel Wagner [Fri, 20 Jan 2023 08:45:56 +0000 (09:45 +0100)]
Merge pull request #560 from igaw/fix-non-trivial-designeded-initializers

ioctl: Initialize non-trivial designated initializers

2 years agoioctl: Initialize non-trivial designated initializers
Daniel Wagner [Fri, 20 Jan 2023 08:42:31 +0000 (09:42 +0100)]
ioctl: Initialize non-trivial designated initializers

Older compilers are not able to do this on their one.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #556 from igaw/add-unique-disc-ctrl
Daniel Wagner [Fri, 20 Jan 2023 07:43:39 +0000 (08:43 +0100)]
Merge pull request #556 from igaw/add-unique-disc-ctrl

Add setter and getter to track unique discovery controller

2 years agotree: Add unique discovery controller flag
Daniel Wagner [Tue, 17 Jan 2023 08:12:38 +0000 (09:12 +0100)]
tree: Add unique discovery controller flag

Introduce a setter an getter to track if a discovery controller is
unique (unique NQN as defined in TP8013).

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #557 from igaw/misc-fabric-fixes
Daniel Wagner [Fri, 20 Jan 2023 07:35:55 +0000 (08:35 +0100)]
Merge pull request #557 from igaw/misc-fabric-fixes

Miscellaneous fabric fixes/improvements

2 years agofabrics: Add nqn to connect/disconnect log entry
Daniel Wagner [Wed, 18 Jan 2023 17:14:44 +0000 (18:14 +0100)]
fabrics: Add nqn to connect/disconnect log entry

This helps to figure out which nqn we are connecting to:

  nvme0: nqn.2014-08.org.nvmexpress.discovery connected
  nvme0: nqn.2014-08.org.nvmexpress.discovery disconnected
  nvme0: nqn.discovery connected
  nvme0: nqn.discovery disconnected

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agofabrics: Change string for NVMF_DISC_EFLAGS_NONE
Daniel Wagner [Wed, 18 Jan 2023 08:38:52 +0000 (09:38 +0100)]
fabrics: Change string for NVMF_DISC_EFLAGS_NONE

'nvme discovery' returns for NFMF_DISC_EFLAGS_NONE 'not specified' which
seems to be a copy past error.

Fixes: 43aa825464e5 ("fabrics: Change string for NVMF_DISC_EFLAGS_NONE")
Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoutil: Add ECONNECTREFUSED to enum nvme_connect_err
Daniel Wagner [Mon, 16 Jan 2023 13:55:17 +0000 (14:55 +0100)]
util: Add ECONNECTREFUSED to enum nvme_connect_err

The kernel might return ECONNECTREFUSED when opening of a socket fails.
Add this missing errno to enum nvme_connect_err.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoioctl: Initialize all members in nvme_fdp_reclaim_unit-handle_status
Daniel Wagner [Tue, 17 Jan 2023 16:49:41 +0000 (17:49 +0100)]
ioctl: Initialize all members in nvme_fdp_reclaim_unit-handle_status

Some compiler complain about the initializers:

 "sorry, unimplemented: non-trivial designated initializers
  not supported"

Address by initializing explicitly all members.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agobuild: Set projects default to debug and prefix /usr/local
Daniel Wagner [Mon, 16 Jan 2023 13:54:34 +0000 (14:54 +0100)]
build: Set projects default to debug and prefix /usr/local

Do not install to /usr per default and accidently overwrite the
distributions version of the package. And also debugging symbols per
default to make development setup as we don't install it anyway to /usr
anyway.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #558 from birkelund/tp4146
Daniel Wagner [Thu, 19 Jan 2023 15:26:46 +0000 (16:26 +0100)]
Merge pull request #558 from birkelund/tp4146

TP4146 updates

2 years agotypes: nsid is unused in reclaim unit handle usage
Klaus Jensen [Thu, 19 Jan 2023 12:35:08 +0000 (13:35 +0100)]
types: nsid is unused in reclaim unit handle usage

The Reclaim Unit Handle Usage command does not use a namespace
identifier.

Remove the function parameter.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
2 years agoMerge pull request #555 from igaw/build-libdbus-wrap
Daniel Wagner [Fri, 13 Jan 2023 14:43:26 +0000 (15:43 +0100)]
Merge pull request #555 from igaw/build-libdbus-wrap

build: Add support to build libdbus as fallback

2 years agobuild: Add libdbus to build default build environment
Daniel Wagner [Fri, 13 Jan 2023 14:22:32 +0000 (15:22 +0100)]
build: Add libdbus to build default build environment

In order to build all the libnvme-mi we need a libdbus-dev
installed.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agobuild: Add D-Bus fallback
Daniel Wagner [Wed, 23 Nov 2022 13:01:53 +0000 (14:01 +0100)]
build: Add D-Bus fallback

Add a wrap for D-Bus so we can use it as fallback for static builds.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agobuild: Remove unused uuid.wrap
Daniel Wagner [Wed, 23 Nov 2022 09:36:35 +0000 (10:36 +0100)]
build: Remove unused uuid.wrap

The depenency on libuuid has been removed but we forgot to remove the
uuid.wrap file. Remove it now.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #554 from drakedog2008/pr/timeout
Daniel Wagner [Wed, 11 Jan 2023 09:33:37 +0000 (10:33 +0100)]
Merge pull request #554 from drakedog2008/pr/timeout

mi: add timeout functions to .map

2 years agomi: add timeout functions to .map
Hao Jiang [Tue, 10 Jan 2023 19:04:41 +0000 (11:04 -0800)]
mi: add timeout functions to .map

Need to export nvme_mi_ep_set_timeout and nvme_mi_ep_get_timeout. These
two functions were defined but left over in .map file.

Signed-off-by: Hao Jiang <jianghao@google.com>
[dwagner: moved the function to the LIBNVME_MI_1_3 section]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #552 from birkelund/tp4146
Daniel Wagner [Thu, 5 Jan 2023 14:23:46 +0000 (15:23 +0100)]
Merge pull request #552 from birkelund/tp4146

types: add fdp data structures and helpers

2 years agotypes: add fdp data structures and helpers
Klaus Jensen [Thu, 15 Sep 2022 20:54:37 +0000 (22:54 +0200)]
types: add fdp data structures and helpers

Add required data structures and helper functions for TP4146 ("Flexible
Data Placement").

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
[dwagner: - drop packed attribute
          - reorder struct args members
          - move new functions to next version linker section]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #551 from jinliangw/spsp_fix
Daniel Wagner [Thu, 22 Dec 2022 08:55:37 +0000 (09:55 +0100)]
Merge pull request #551 from jinliangw/spsp_fix

mi: fix location of spsp1 and spsp0

2 years agomi: fix location of spsp1 and spsp0
Jinliang Wang [Mon, 19 Dec 2022 22:06:03 +0000 (14:06 -0800)]
mi: fix location of spsp1 and spsp0

Command Dword 10 [23:16] : SPSP1
Command Dword 10 [15:08] : SPSP0

Signed-off-by: Jinliang Wang <jinliangw@google.com>
2 years agoMerge pull request #547 from jinliangw/in_band_get_log_fix
Daniel Wagner [Fri, 2 Dec 2022 09:08:21 +0000 (10:08 +0100)]
Merge pull request #547 from jinliangw/in_band_get_log_fix

ioctl: fix log page offset

2 years agoioctl: fix log page offset
Jinliang Wang [Tue, 29 Nov 2022 23:15:28 +0000 (15:15 -0800)]
ioctl: fix log page offset

The original `lpo` info is lost in `nvme_get_log_page`.
Save it into a local variable and append `offset` after it.

Signed-off-by: Jinliang Wang <jinliangw@google.com>
2 years agoMerge pull request #539 from jinliangw/master
Daniel Wagner [Fri, 2 Dec 2022 08:56:06 +0000 (09:56 +0100)]
Merge pull request #539 from jinliangw/master

mi: use correct log page offset

2 years agomi: use lpo and numd to chunk big get log page command
Jinliang Wang [Thu, 1 Dec 2022 07:25:05 +0000 (23:25 -0800)]
mi: use lpo and numd to chunk big get log page command

1) Change log page offset inside `__nvme_mi_admin_get_log`
   We use LPO and NUMD to chunk get log page request whose length
   is greater than 4KB. This method works better for some of current
   devices.
2) Update `test_admin_get_log_split_cb`.

Signed-off-by: Jinliang Wang <jinliangw@google.com>
2 years agoMerge pull request #548 from tbzatek/valgrind-fixes-2
Daniel Wagner [Wed, 30 Nov 2022 18:15:38 +0000 (19:15 +0100)]
Merge pull request #548 from tbzatek/valgrind-fixes-2

tree: Fix leaking struct nvme_ns.generic_name

2 years agotree: Fix leaking struct nvme_ns.generic_name
Tomas Bzatek [Wed, 30 Nov 2022 13:51:09 +0000 (14:51 +0100)]
tree: Fix leaking struct nvme_ns.generic_name

==306445== 96 bytes in 16 blocks are definitely lost in loss record 3,171 of 3,553
==306445==    at 0x484386F: malloc (vg_replace_malloc.c:393)
==306445==    by 0x4FA2F6D: strdup (strdup.c:42)
==306445==    by 0x7B9C477: nvme_ns_set_generic_name (tree.c:1802)
==306445==    by 0x7B9C51B: nvme_ns_open (tree.c:1820)
==306445==    by 0x7B9C606: __nvme_scan_namespace (tree.c:1853)
==306445==    by 0x7B9CA0C: nvme_subsystem_scan_namespace (tree.c:1931)
==306445==    by 0x7B98C81: nvme_subsystem_scan_namespaces (tree.c:496)
==306445==    by 0x7B991BC: nvme_scan_subsystem (tree.c:597)
==306445==    by 0x7B97DA1: nvme_scan_topology (tree.c:118)
==306445==    by 0x7B97FA9: nvme_scan (tree.c:177)

2 years agoMerge pull request #545 from jinliangw/rename_tmp
Daniel Wagner [Mon, 28 Nov 2022 08:52:56 +0000 (09:52 +0100)]
Merge pull request #545 from jinliangw/rename_tmp

mi: rename tmp variable inside nvme_mi_admin_get_log

2 years agoMerge pull request #546 from tbzatek/valgrind-fixes-1
Daniel Wagner [Mon, 28 Nov 2022 08:52:16 +0000 (09:52 +0100)]
Merge pull request #546 from tbzatek/valgrind-fixes-1

fabrics: Fix uuid_from_dmi_entries() read buffer initialization

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>