]> www.infradead.org Git - users/sagi/libnvme.git/log
users/sagi/libnvme.git
21 months agotree: Add getter for subsystem iopolicy
Daniel Wagner [Wed, 26 Jul 2023 13:33:39 +0000 (15:33 +0200)]
tree: Add getter for subsystem iopolicy

Allow to retrieve the iopolicy settings for the subsystem.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
21 months agofabrics: Consider also all hosts settings for context match
Daniel Wagner [Mon, 3 Jul 2023 09:17:48 +0000 (11:17 +0200)]
fabrics: Consider also all hosts settings for context match

It's not enough to iterate over all subsystem of one host. We need to
iterate over all hosts as well to find a match.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
21 months agotree: Scan all subsystems
Daniel Wagner [Mon, 17 Jul 2023 11:54:30 +0000 (13:54 +0200)]
tree: Scan all subsystems

We need to scan all subsystems because a subsystem might show up on
different hosts, e.g 'nvme connect' with different hostnqn and the
target reports the same namespace.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
21 months agodoc: Fixing compile instruction in README
Brando [Tue, 18 Jul 2023 16:57:56 +0000 (09:57 -0700)]
doc: Fixing compile instruction in README

Update the instruction how to build with meson.

21 months agomi: allow non-4-byte-aligned responses
Jeremy Kerr [Mon, 3 Jul 2023 08:14:47 +0000 (16:14 +0800)]
mi: allow non-4-byte-aligned responses

We currently assume that a MI response will be a multiple of four bytes
in length. However, this may not be the case: for example, a Read MI
Data (Controller List) with an even number of controllers, and with an
unpadded response, may only be aligned on a two-byte boundary.

The NVMe-MI spec states, for the MIC field:

    This field is byte aligned.

So, relax the requirement for alignment on the response sizes, and the
expected response size values. We only do this for the mi commands; the
Admin commands still require an aligned value for DLEN.

In doing so, drop the explicit alignment tests, and add a couple that
check that the Controller List example above will work.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Reported-by: Klaus Jensen <its@irrelevant.dk>
21 months agomi-mctp: use a linear response buffer
Jeremy Kerr [Mon, 3 Jul 2023 08:06:34 +0000 (16:06 +0800)]
mi-mctp: use a linear response buffer

Currently, we're passing a 3-entry iovec to the MCTP resvmsg()
interface:

 - header
 - payload
 - MIC

This is fine if the response comes back eaxctly the size we expect, but
causes complexity if we get a smaller response (for example, as an error
or a More Processing Required response), as we need to extract the MIC
from somewhere in those buffers.

At the moment, since we're enforcing 4-byte alignment, that isn't too
complex - we know the MIC will be entirely in one of the buffers. The
MPR code is a bit awkward, but still manageable.

However: we now want to allow unaligned responses from MI messages,
which is about to make that a lot more complex; in the worst case, the
MIC could be split over all three buffers!

This change uses a fixed linear buffer for the MCTP response instead. We
allocate 4k for this by default, but expand if necessary. We use this as
the sendmsg() buffer, so get a linear message back from the MCTP
endpoint. Once we have verified the format (and extracted the MIC), we
copy this into the actual response header/payload buffers as required.

This makes the response handing code simpler, at the cost of one extra
response buffer per endpoint.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
21 months agomi: implement length and offset alignment checks in admin_xfer()
Jeremy Kerr [Mon, 3 Jul 2023 07:55:04 +0000 (15:55 +0800)]
mi: implement length and offset alignment checks in admin_xfer()

We're about to relax some alignment requirements in the generic
(internal) nvme_mi_submit function. To ensure that the raw admin
interface continues to enfore the required alignment on DOFST and DLEN
fields, implement checks in the Admin command interface.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
21 months agotree: Don't open nvme devices until it's absolutely required
Martin Belanger [Mon, 3 Jul 2023 18:41:14 +0000 (14:41 -0400)]
tree: Don't open nvme devices until it's absolutely required

Don't open nvme devices while scanning the tree. Only open devices
when we actually need to write commands to them.

This patch also provides functions to close fds when a user no
longer needs them to be open.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
21 months agotree: missing closedir() causes fd leak for "/sys/bus/pci/slots"
Martin Belanger [Wed, 5 Jul 2023 14:59:25 +0000 (10:59 -0400)]
tree: missing closedir() causes fd leak for "/sys/bus/pci/slots"

In nvme_ctrl_lookup_phy_slot(), we are missing a closedir(), which
causes file descriptors to leak. Also, there was a missing free()
when the function returns with ENOMEM.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
21 months agomi: don't return from mi_mctp_submit with a tag held
Jeremy Kerr [Wed, 24 May 2023 09:29:33 +0000 (17:29 +0800)]
mi: don't return from mi_mctp_submit with a tag held

If the poll() times-out or fails, we'll exit early from
nvme_mi_mctp_submit still holding the tag reservation. When using an i2c
transport, this may mean we hold a lock on the i2c bus with no way to
release.

Instead, always drop the tag on function exit.

Fixes: 6a08780 ("mi-mctp: Add timeout support to MCTP transport")
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
21 months agodoc: Regenerate all docs for v1.5 v1.5
Daniel Wagner [Fri, 30 Jun 2023 13:17:07 +0000 (15:17 +0200)]
doc: Regenerate all docs for v1.5

Signed-off-by: Daniel Wagner <dwagner@suse.de>
21 months agobuild: Update version to v1.5
Daniel Wagner [Fri, 30 Jun 2023 13:16:30 +0000 (15:16 +0200)]
build: Update version to v1.5

Signed-off-by: Daniel Wagner <dwagner@suse.de>
21 months agobuild: Update cross instruction and drop verbose test flag
Daniel Wagner [Fri, 30 Jun 2023 13:08:52 +0000 (15:08 +0200)]
build: Update cross instruction and drop verbose test flag

Signed-off-by: Daniel Wagner <dwagner@suse.de>
21 months agobuild: Use containers with matrix build
Daniel Wagner [Mon, 26 Jun 2023 11:44:21 +0000 (13:44 +0200)]
build: Use containers with matrix build

Use a matrix build approach and a base container which already contains
all the libraries installed.

21 months agoutil: Provide empty nvme_ipaddrs_eq for static builds
Daniel Wagner [Mon, 26 Jun 2023 11:40:28 +0000 (13:40 +0200)]
util: Provide empty nvme_ipaddrs_eq for static builds

Static builds can't use netdb functions, they are only available when
linking dynamically against glibc.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
22 months agoscripts: Use spaces instead of tabs
Daniel Wagner [Fri, 23 Jun 2023 14:22:50 +0000 (16:22 +0200)]
scripts: Use spaces instead of tabs

The build.sh file contains a mix of tabs and spaces, just use spaces
consistently.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
22 months agobuild: Move CI build steps into a scripts
Daniel Wagner [Fri, 23 Jun 2023 13:29:15 +0000 (15:29 +0200)]
build: Move CI build steps into a scripts

Move the build instruction into a script. This allows to run these steps
also locally.

Also disable the fallback static library build as it is clearly not
working because in the dependencies rely to link against a dynamic
glibc. Instead just add a minimal static build without fallbacks.

While we are at it, also add a debug clang build.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
22 months agoscripts: Sync release script
Daniel Wagner [Fri, 23 Jun 2023 08:55:08 +0000 (10:55 +0200)]
scripts: Sync release script

Sync with the nvme-cli release script.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
22 months agoscripts: Call update doc script from top level dir
Daniel Wagner [Fri, 23 Jun 2023 08:52:44 +0000 (10:52 +0200)]
scripts: Call update doc script from top level dir

Make sure that the script runs from the lop level dir.

While at it also properly quote variables to make shellcheck happy.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
22 months agoscripts: Move helper scripts to a central place
Daniel Wagner [Fri, 23 Jun 2023 08:02:02 +0000 (10:02 +0200)]
scripts: Move helper scripts to a central place

The helper scripts for maintaining are distributed over several
directories. Let's move them to the scripts directory.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
22 months agofabrics: Relax match on well known disc ctrl lookup
Daniel Wagner [Thu, 22 Jun 2023 12:13:13 +0000 (14:13 +0200)]
fabrics: Relax match on well known disc ctrl lookup

In case nvmf_add_ctrl() is called to add a well known discovery
controller we also need to verify if we should ignore it (see --context
command line argument of nvme-cli). Though we have to be careful not to
overmatch on the lookup.

That means the host_traddr and host_iface might be different for the
discovery controller than the normal controllers. For example this can
happen when the discovery controller is reached via different interface
than the data controllers.

Thus only consider the transport type, target address and trsvcid only
when looking up well known discovery controllers.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
22 months agotree: Ignore NULL address pointer for phy slot lookup
Daniel Wagner [Thu, 22 Jun 2023 12:09:50 +0000 (14:09 +0200)]
tree: Ignore NULL address pointer for phy slot lookup

The PCI physical slot lookup works obviously only for physical cards.
Thus do not try to dereference the address pointer if it is a NULL
pointer.

Fixes: 42ac45359635 ("tree: Add PCI physical slot number for controller")
Signed-off-by: Daniel Wagner <dwagner@suse.de>
22 months agofabrics: Filter discovery ctrls out during application context check
Daniel Wagner [Wed, 14 Jun 2023 12:19:10 +0000 (14:19 +0200)]
fabrics: Filter discovery ctrls out during application context check

We also need to filter out the well known discovery controllers when
using the execution context filtering. Obviously, we can't use the
subsystem name, thus match on the host and target address instead.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
22 months agoutil: Add ignored error code
Daniel Wagner [Wed, 14 Jun 2023 12:17:41 +0000 (14:17 +0200)]
util: Add ignored error code

When libnvme ignores a connection attempt via the 'application' context
tracking return an unique error code to allow proper filtering on the
caller side.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
22 months agojson: Use memory block allocated by realloc() instead printbuf
Tokunori Ikegami [Sat, 17 Jun 2023 15:06:26 +0000 (00:06 +0900)]
json: Use memory block allocated by realloc() instead printbuf

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
22 months agoutil: Use HAVE_NETDB instead of HAVE_LIBNSS
Tokunori Ikegami [Thu, 15 Jun 2023 15:16:50 +0000 (00:16 +0900)]
util: Use HAVE_NETDB instead of HAVE_LIBNSS

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
22 months agotree: Add PCI physical slot number for controller
Umer Saleem [Mon, 12 Jun 2023 14:45:49 +0000 (19:45 +0500)]
tree: Add PCI physical slot number for controller

This commit introduces a physical slot field for controller, that
contains the PCI physcial slot number for controller device.

In case, there are multiple NVME drives present on the platform,
it's hard to identify which NVME drive is present in which slot.
The slot number is usually helpful in determining the location.
It is cross reference-able from lspci, but it would be nice to
have a direct option.

Signed-off-by: Umer Saleem <usaleem@ixsystems.com>
22 months agotree: Use nvme_ipaddrs_eq() to compare IP addresses
Martin Belanger [Mon, 12 Jun 2023 14:40:42 +0000 (10:40 -0400)]
tree: Use nvme_ipaddrs_eq() to compare IP addresses

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
22 months agofabrics: Add EADDRNOTAVAIL error mapping
Tokunori Ikegami [Tue, 13 Jun 2023 15:13:14 +0000 (00:13 +0900)]
fabrics: Add EADDRNOTAVAIL error mapping

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
22 months agofabrics: filter out subsystems with non-matching application string
Hannes Reinecke [Thu, 20 Apr 2023 10:38:10 +0000 (12:38 +0200)]
fabrics: filter out subsystems with non-matching application string

If the nvme root has an application string set any subsystem lookup
should ignore subsystems which either have no application string set
or which have a non-matching application string.

Signed-off-by: Hannes Reinecke <hare@suse.de>
22 months agolibnvme: add 'application' setting to nvme_root
Hannes Reinecke [Thu, 20 Apr 2023 10:10:17 +0000 (12:10 +0200)]
libnvme: add 'application' setting to nvme_root

Add an 'application' string to the tree root to indicate which
application manages this configuration.

Signed-off-by: Hannes Reinecke <hare@suse.de>
22 months agolibnvme: add 'application' setting to the subsystem
Hannes Reinecke [Thu, 20 Apr 2023 10:10:17 +0000 (12:10 +0200)]
libnvme: add 'application' setting to the subsystem

Add an 'application' string to the subsystem to indicate which
application should manage this particular subsystem.

Signed-off-by: Hannes Reinecke <hare@suse.de>
22 months agotest: Add more code coverage for nvme_ipaddrs_eq()
Martin Belanger [Fri, 2 Jun 2023 12:55:24 +0000 (08:55 -0400)]
test: Add more code coverage for nvme_ipaddrs_eq()

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
22 months agoutil: rename ipaddrs_eq() to nvme_ipaddrs_eq() and make public.
Martin Belanger [Fri, 2 Jun 2023 12:35:51 +0000 (08:35 -0400)]
util: rename ipaddrs_eq() to nvme_ipaddrs_eq() and make public.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
22 months agoutil: Add ipaddrs_eq() to check whether two IP addresses are equal
Martin Belanger [Fri, 19 May 2023 17:40:45 +0000 (13:40 -0400)]
util: Add ipaddrs_eq() to check whether two IP addresses are equal

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
23 months agoexamples: Fix wrong indentation in discover-loop.py
Benjamin Drung [Tue, 23 May 2023 10:30:16 +0000 (12:30 +0200)]
examples: Fix wrong indentation in discover-loop.py

Running `examples/discover-loop.py` fails:

```
  File "examples/discover-loop.py", line 59
    c.disconnect()
    ^
IndentationError: expected an indented block after 'try' statement on line 58
```

Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
23 months agotest: Add unit test for ctrl lookups
Daniel Wagner [Thu, 18 May 2023 13:43:01 +0000 (15:43 +0200)]
test: Add unit test for ctrl lookups

Add a simple unit test which tests the ctrl lookup logic.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
23 months agobuild: Install missing s390 library
Daniel Wagner [Thu, 18 May 2023 13:49:55 +0000 (15:49 +0200)]
build: Install missing s390 library

libjson-c-dev:s390x depends on the libgcc-s1 library.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
23 months agoioctl: fix RAE bit on last Get Log Page command
Caleb Sander [Fri, 12 May 2023 15:43:22 +0000 (09:43 -0600)]
ioctl: fix RAE bit on last Get Log Page command

If nvme_get_log_page() requires multiple Get Log Page commands
because the total log length exceeds the transfer length,
args->rae is overwritten, causing the RAE bit to be set in all commands.
Retrieve the value of args->rae before overwriting it
so the RAE bit is set as requested in the last command.

Fixes: c23dbd4 ("linux: Change nvme_get_log_page to use nvme_get_log_args parm")
Signed-off-by: Caleb Sander <csander@purestorage.com>
23 months agofabrics: check genctr after getting discovery entries
Caleb Sander [Fri, 12 May 2023 16:49:46 +0000 (10:49 -0600)]
fabrics: check genctr after getting discovery entries

From the NVMe base spec (version 2.0c, section 5.16.1.23):
If the host reads the Discovery Log Page using multiple Get Log Page
commands the host should ensure that there has not been a change in the
contents of the data. The host should read the Discovery Log Page
contents in order (i.e., with increasing Log Page Offset values) and
then re-read the Generation Counter after the entire log page is
transferred. If the Generation Counter does not match the original value
read, the host should discard the log page read as the entries may be
inconsistent.

nvme_get_log_page() will issue multiple Get Log Page commands
to fetch the discovery log page if it exceeds 4 KB.
Since GENCTR is at the start of the log page, this ordering is possible:
- GENCTR is read by a Get Log Page command for the first 4 KB
- The log page is modified, changing GENCTR
- Other Get Log Page commands read the remainder of the log page
So the check that GENCTR hasn't changed will incorrectly pass,
despite the log page having been modified.
This can lead to inconsistent, missing, or duplicate log page entries.

Ensure a GENCTR update is not missed
by fetching log page header again after all entries.

Also use NVME_LOG_PAGE_PDU_SIZE to match other nvme_get_log_page() calls
instead of hard-coding the 4 KB max transfer length.
And ensure LPO is correctly reset if the log page is read again.

Signed-off-by: Caleb Sander <csander@purestorage.com>
23 months agofabrics: handle /dev/nvme-fabrics read failure
Caleb Sander [Fri, 12 May 2023 00:40:26 +0000 (18:40 -0600)]
fabrics: handle /dev/nvme-fabrics read failure

The ability to read from /dev/nvme-fabrics to find supported options
is a newer Linux kernel feature added in f18ee3d988157 (5.17-rc1).
On earlier kernels, this read returns EINVAL,
preventing the controller from being added:
$ nvme discover --transport tcp --traddr 192.168.1.62
Failed to read from /dev/nvme-fabrics: Invalid argument
failed to add controller, error Invalid argument

So don't treat EINVAL as a fatal error, and instead fall back
to a default set of supported options.
With this change, controllers can be created successfully:
$ nvme discover --transport tcp --traddr 192.168.1.62

Discovery Log Number of Records 4, Generation counter 125
...

Fixes: d123131f2e ("fabrics: Do not pass unsupported options to kernel")
Signed-off-by: Caleb Sander <csander@purestorage.com>
23 months agofabrics: fix potential invalid memory access in __nvmf_supported_option()
Maurizio Lombardi [Mon, 8 May 2023 15:47:00 +0000 (17:47 +0200)]
fabrics: fix potential invalid memory access in __nvmf_supported_option()

In __nvmf_supported_option(), len is declared as size_t (unsigned)

"len = read()" may return a negative number;
the check "if (len < 0)" will always be false and therefore
"buf[len]" will dereference an invalid memory address.

len should be declared as a signed size_t (ssize_t)

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
23 months agoPython: Fix crash during garbage collection
Martin Belanger [Tue, 2 May 2023 18:22:46 +0000 (14:22 -0400)]
Python: Fix crash during garbage collection

Same fix as commit d2a5491d1681ead6d8983d0bf6ecae937ab9f317

Prevent Garbage Collector (GC) from deleting host and root objects
before all controller objects under that root/host have been GCed.
This time, it's the init() method that needed the fix. Previously
we had only fixed the connect() method.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
23 months agopython/swig: Check swig version to determine whether -py3 is needed
Martin Belanger [Thu, 27 Apr 2023 15:36:11 +0000 (11:36 -0400)]
python/swig: Check swig version to determine whether -py3 is needed

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
23 months agopython/swig: Wrap swig-sensitive struct inside #ifwdef SWIG
Martin Belanger [Thu, 27 Apr 2023 14:13:19 +0000 (10:13 -0400)]
python/swig: Wrap swig-sensitive struct inside #ifwdef SWIG

To suppress the warnings generated by swig when parsing anonymous
struct/union, we simply wrap the offending struct/union in a
"#ifndef SWIG" statement. This is an acceptable workaround because
we don't need to generate Python bindings for these structs. In
fact, we specifically tell swig to not generate wrappers for all
structs in types.h. Although swig does not generate wrappers for
those structs, it still warns when a struct doesn't have a name
and therefore we need to use this workaround.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
23 months agomi: Add nvme_mi_ctrl_id to retrieve controller ID
Jeremy Kerr [Thu, 27 Apr 2023 07:07:46 +0000 (15:07 +0800)]
mi: Add nvme_mi_ctrl_id to retrieve controller ID

Controllers may be scanned through nvme_mi_scan_ep, in which case the
caller will not have access to the underlying controller IDs.

Add an accessor function to retrieve the controller ID for use in
subsequent commands (like namespace attach).

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
23 months agoPython: Suppress swig warnings about unnamed struct
Martin Belanger [Tue, 25 Apr 2023 10:59:43 +0000 (06:59 -0400)]
Python: Suppress swig warnings about unnamed struct

Ref: https://github.com/linux-nvme/libnvme/issues/634

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
23 months agoexamples: fix incorrect controller status in MI info output
Lior Weintraub [Mon, 24 Apr 2023 05:26:57 +0000 (08:26 +0300)]
examples: fix incorrect controller status in MI info output

In the mi-mctp example, we're incorrectly reporting the percent drive
life used as the controller status. Fix the controller status output
to use the correct (ccs) field.

Signed-off-by: Lior Weintraub <liorw@pliops.com>
Reviewed-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agoioctl: Explicitly initialize all members of struct nvme_ns_mgmt_args
Daniel Wagner [Fri, 21 Apr 2023 12:18:59 +0000 (14:18 +0200)]
ioctl: Explicitly initialize all members of struct nvme_ns_mgmt_args

Older compilers complain with:

../src/nvme/ioctl.h:3063:2: sorry, unimplemented: non-trivial designated initializers not supported

Thus explicitly initialize all members of this data structure.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoPython: make NBFT data more pythonic
Martin Belanger [Tue, 18 Apr 2023 13:19:32 +0000 (09:19 -0400)]
Python: make NBFT data more pythonic

I made the nfollowing changes so that the data is more Pythonic.

1) For boolean values, set them to True/False instead of 1/0.

2) NBFT data contains ordered lists. In the raw NBFT data the
position of each element in the list is indicated by a 1-based
index. When converting to Python lists, make sure that each
element is inserted in the list at the right position. This is
done by converting the 1-based index to a 0-based index.

3) For objects that contain index variables that refer to items in
a list, make sure to convert the 1-based index to 0-based so that
it can be used directly to access the python lists (e.g. list[index]).

4) Since Python lists are ordered (per 2 above), there is no
need to keep an explicit 1-based index in each of the list items.
Therefore those 1-based indexes were removed.

5) No need to keep explicit variables representing the length of
a list. In Python one need only use len(list) to get the length.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
2 years agoioctl: io management send, receive args fix
Steven Seungcheol Lee [Mon, 17 Apr 2023 02:20:23 +0000 (11:20 +0900)]
ioctl: io management send, receive args fix

TP4146 Flexible Data Placement 2022.11.30 Ratified
Command Dword 10
Bits[31:16] : Management Operation Specific (MOS)
Bits[07:00] : Management Operation (MO)
Signed-off-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
2 years agopython: Update test data
Daniel Wagner [Mon, 17 Apr 2023 08:25:55 +0000 (10:25 +0200)]
python: Update test data

Since commit 1617d1a3f42a ("nbft: Parse the {HOSTID,HOSTNQN}_CONFIGURED
flags") host_id_configured and host_nqn_configured are parsed. Thus we
need to update the test case accordingly.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoNBFT: Remove documentation from nbft.c since it's also in nbft.h
Martin Belanger [Fri, 14 Apr 2023 15:19:23 +0000 (11:19 -0400)]
NBFT: Remove documentation from nbft.c since it's also in nbft.h

Also, replace nbft_free() by nvme_nbft_free() in documentation
found in nbft.h.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
2 years agoPython: Add NBFT support
Martin Belanger [Thu, 13 Apr 2023 13:29:17 +0000 (09:29 -0400)]
Python: Add NBFT support

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
2 years agonbft: Doc typo - Use nvme_nbft_free() instead of nbft_free()
Martin Belanger [Thu, 13 Apr 2023 13:27:04 +0000 (09:27 -0400)]
nbft: Doc typo - Use nvme_nbft_free() instead of nbft_free()

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
2 years agonbft: Parse the {HOSTID,HOSTNQN}_CONFIGURED flags
Tomas Bzatek [Thu, 13 Apr 2023 16:27:39 +0000 (18:27 +0200)]
nbft: Parse the {HOSTID,HOSTNQN}_CONFIGURED flags

2 years agonbft: Fix nbft_ssns_flags endianness test
Tomas Bzatek [Thu, 13 Apr 2023 15:28:42 +0000 (17:28 +0200)]
nbft: Fix nbft_ssns_flags endianness test

Missing flags endianness conversion leading to ssns_ext_info
not being parsed on s390x and armhf.

2 years agonbft: Add a simple unit test
Tomas Bzatek [Tue, 11 Apr 2023 16:04:55 +0000 (18:04 +0200)]
nbft: Add a simple unit test

A simple table dump utility, a set of real ACPI NBFT table files
and corresponding set of reference dumps, compared against each
other as part of the meson test run.

Please check the README file for details.

Signed-off-by: Tomas Bzatek <tbzatek@redhat.com>
2 years agodoc: Update README
Daniel Wagner [Mon, 17 Apr 2023 06:52:33 +0000 (08:52 +0200)]
doc: Update README

Extend the documentation on the build process.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agobuild: Simple muon build configuration
Daniel Wagner [Fri, 14 Apr 2023 07:56:23 +0000 (09:56 +0200)]
build: Simple muon build configuration

The auto detection takes care to disable all dependencies. Thus we
should actually test this by explicitly disabling this part.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agobuild: Extend summary section
Daniel Wagner [Fri, 14 Apr 2023 07:55:44 +0000 (09:55 +0200)]
build: Extend summary section

List also the dependencies in the summary.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agobuild: Make json-c dependency lookup not fail
Daniel Wagner [Fri, 14 Apr 2023 07:54:42 +0000 (09:54 +0200)]
build: Make json-c dependency lookup not fail

Let's relax the dependency on json-c, when the command list option is set
to auto. It will just ignore the dependency if not found

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agonbft: Move added symbols to LIBNVME_1_5
Tomas Bzatek [Thu, 13 Apr 2023 13:39:28 +0000 (15:39 +0200)]
nbft: Move added symbols to LIBNVME_1_5

2 years agobuild: Update wrap mode defaults
Daniel Wagner [Thu, 13 Apr 2023 10:36:35 +0000 (12:36 +0200)]
build: Update wrap mode defaults

We switched the default of the wrap mode to nofallback. Update the CI
builds accordingly.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agobuild: Disable fallback on default
Daniel Wagner [Thu, 13 Apr 2023 10:41:31 +0000 (12:41 +0200)]
build: Disable fallback on default

meson's default setting for wrap mode is to attempt to download missing
dependencies. Disable this feature as the community is unhappy with
this default behavior.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agotree: Fix offset argument check in nvme_bytes_to_lba
Daniel Wagner [Wed, 12 Apr 2023 13:43:18 +0000 (15:43 +0200)]
tree: Fix offset argument check in nvme_bytes_to_lba

Also offset modulo blocksize needs to be 0. Commit 01c6055e5602 ("tree:
Fix argument check in nvme_bytes_to_lba") missed to update this, thus do
it now.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agonbft: add NBFT v1.0 table support
Stuart Hayes [Thu, 31 Mar 2022 18:47:11 +0000 (13:47 -0500)]
nbft: add NBFT v1.0 table support

Added support for parsing and printing the contents
of the NBFT table (per NVMe-oF boot specification v1.0).

Signed-off-by: Stuart Hayes <stuart_hayes@dell.com>
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Tomas Bzatek <tbzatek@redhat.com>
Signed-off-by: John Meneghini <jmeneghi@redhat.com>
2 years agotypes: Add IO command set specific field on nsmgmt
Steven Seungcheol Lee [Wed, 5 Apr 2023 03:06:11 +0000 (12:06 +0900)]
types: Add IO command set specific field on nsmgmt

nvme_ns_mgmt_host_sw_specified_zns from TP4115 ZNS Namespace Management Enhancements 2022.03.15 Ratified

Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
2 years agofabrics: Do not pass unsupported options to kernel
Daniel Wagner [Wed, 12 Apr 2023 09:59:45 +0000 (11:59 +0200)]
fabrics: Do not pass unsupported options to kernel

The kernel API might not support all options libnvme is supporting.
Filter out all options which the kernel doesn't support.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agotypes: Add ns-mgmt host software specified fields
Steven Seungcheol Lee [Mon, 13 Feb 2023 06:53:09 +0000 (15:53 +0900)]
types: Add ns-mgmt host software specified fields

nphndls, phndl from TP4146 Flexible Data Placement 2022.11.30 Ratified

Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
2 years agotypes.h: Add FDP related Status Code
Steven Seungcheol Lee [Wed, 8 Feb 2023 04:56:11 +0000 (13:56 +0900)]
types.h: Add FDP related Status Code

Generic Command Status Values from TP4146 Flexible Data Placement 2022.11.30 Ratified

Signed-off-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
2 years agotree: Fix argument check in nvme_bytes_to_lba
Daniel Wagner [Wed, 5 Apr 2023 06:37:38 +0000 (08:37 +0200)]
tree: Fix argument check in nvme_bytes_to_lba

nvme_bytes_to_lba() argument checker is ensuring that all passed in
values are valid. That means we have at least one block to write, the
offset is aligned to a block starting address and the number of blocks
is a multiple of the block size

The last check is wrong, thus fix it.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agodoc: Regenerate all docs for v1.4 v1.4
Daniel Wagner [Fri, 31 Mar 2023 14:05:19 +0000 (16:05 +0200)]
doc: Regenerate all docs for v1.4

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agobuild: Update version to v1.4
Daniel Wagner [Fri, 31 Mar 2023 14:04:49 +0000 (16:04 +0200)]
build: Update version to v1.4

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agofabrics: Filter out invalid UUIDs from DMI
Daniel Wagner [Thu, 30 Mar 2023 14:14:19 +0000 (16:14 +0200)]
fabrics: Filter out invalid UUIDs from DMI

Qemu might not initialize the system DMI correctly and nvme-cli would
generate an invalid hostid.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agofabrics: Add define for DMI sysinfo
Daniel Wagner [Thu, 30 Mar 2023 13:55:24 +0000 (15:55 +0200)]
fabrics: Add define for DMI sysinfo

2 years agodoc: Do not hardcode default location for config files
Daniel Wagner [Wed, 29 Mar 2023 15:14:05 +0000 (17:14 +0200)]
doc: Do not hardcode default location for config files

The location of the config files is depending of the configuration.
Because we ship pre-compiled documentation the SYSCONFDIR might not be
correct.

Avoid confusion and just point out they live under SYSCONFDIR.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agodoc: Update build script to use correct meson verbs
Daniel Wagner [Wed, 29 Mar 2023 15:13:00 +0000 (17:13 +0200)]
doc: Update build script to use correct meson verbs

Use setup and compile as meson verbs.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoPrint out correct TREQ strings for discovery
Hannes Reinecke [Tue, 28 Mar 2023 10:28:21 +0000 (12:28 +0200)]
Print out correct TREQ strings for discovery

The TREQ field in the discover log page is actually a bit field,
so we need to update the string mapping to print out all possible
combinations correctly.

Signed-off-by: Hannes Reinecke <hare@suse.de>
2 years agotree: fix generic device open failure
Minwoo Im [Wed, 22 Mar 2023 22:59:03 +0000 (07:59 +0900)]
tree: fix generic device open failure

If scan_namespace is called with a generic device (e.g., /dev/ng0n1)
given, it fails to scan a namespace based on the generic device because
there's no entry point in /sys/block/ for the generic device.

This patch provides two helpers to change the given generic device name
to a block device name based on the instances:
ng0n1 -> nvme0n1

This patch fixes command failure:
root@vm:~/work/nvme-cli.git# nvme show-regs /dev/ng0n1
Unable to find ng0n1
get-property: Invalid argument

Signed-off-by: Minwoo Im <minwoo.im@samsung.com>
[dwagner: also catch blkdev allocation failures]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agofabrics: add configuration option 'tls_key'
Hannes Reinecke [Thu, 23 Mar 2023 09:44:02 +0000 (10:44 +0100)]
fabrics: add configuration option 'tls_key'

Add a fabrics configuration option to specify the TLS PSK for a
connection. The PSK is referenced by its serial number, but stored
with its description in the JSON configuration file.

Signed-off-by: Hannes Reinecke <hare@suse.de>
2 years agofabrics: add configuration option 'keyring'
Hannes Reinecke [Thu, 23 Mar 2023 09:14:03 +0000 (10:14 +0100)]
fabrics: add configuration option 'keyring'

Add a fabrics configuation option 'keyring' to set the keyring
for storing and looking up keys.
As the keyring serial number is ephemeral we cannot store it
in the JSON configuration file, so store the keyring description
instead.

Signed-off-by: Hannes Reinecke <hare@suse.de>
2 years agolinux: add key helper functions
Hannes Reinecke [Thu, 23 Mar 2023 13:46:13 +0000 (14:46 +0100)]
linux: add key helper functions

Add helper functions for key handling.

Signed-off-by: Hannes Reinecke <hare@suse.de>
[dwagner:
  - set errno on failure and updated documentation accordingly
  - fix return check of nvme_lookup_key in nvme_insert_tls_key]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agonvme: add 'nvme_insert_tls_key()' function
Hannes Reinecke [Wed, 22 Mar 2023 14:44:31 +0000 (15:44 +0100)]
nvme: add 'nvme_insert_tls_key()' function

Add a function to derive a TLS key and insert it into the given
keyring.

Signed-off-by: Hannes Reinecke <hare@suse.de>
[dwagner: updated doc to mention errno set if failure]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agolinux: add nvme_lookup_keyring()
Hannes Reinecke [Thu, 23 Mar 2023 13:18:44 +0000 (14:18 +0100)]
linux: add nvme_lookup_keyring()

Add a function to lookup a keyring by its description.

Signed-off-by: Hannes Reinecke <hare@suse.de>
[dwagner:
  - pass in command line option to dependency requirement argument
  - drop log message, find_key_by_type_and_desc sets errno]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agopython: Change python option from combo to feature
Martin Belanger [Fri, 24 Mar 2023 15:18:20 +0000 (11:18 -0400)]
python: Change python option from combo to feature

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
2 years agobuild: Update OpenSSL wrap
Daniel Wagner [Fri, 24 Mar 2023 15:50:48 +0000 (16:50 +0100)]
build: Update OpenSSL wrap

Update to OpenSSL 3.0.7.

When the fallback was using v1 we never went into the v3 testing. With
updating to v3 we are going to figure out if we have LibreSSL spin of
the API. But cc.has_header_symbol() and cc.has_header() only work on
external library and not on fallbacks.

Thus if we use the fallback (internal) we just know it is API version 3
and don't do any crazy testing.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agobuild: Update json-c wrap
Daniel Wagner [Fri, 24 Mar 2023 15:50:20 +0000 (16:50 +0100)]
build: Update json-c wrap

Update to json-c 0.16

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agobuild: Add build action back
Daniel Wagner [Fri, 24 Mar 2023 13:35:19 +0000 (14:35 +0100)]
build: Add build action back

The test meson target builds only the necessary files for passing the
test target. To build the complete library use the build target.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agotypes: add opcode field to error log page (TP4113)
Minwoo Im [Wed, 8 Mar 2023 23:48:46 +0000 (08:48 +0900)]
types: add opcode field to error log page (TP4113)

Add support for opcode field in error information log page based on TP
4113. It is easy to identify which command is associated with the error.

Signed-off-by: Minwoo Im <minwoo.im@samsung.com>
2 years agopython: Add setter property for controller DHCHAP Key
Martin Belanger [Fri, 17 Mar 2023 15:56:26 +0000 (11:56 -0400)]
python: Add setter property for controller DHCHAP Key

Similar to the way we allow setting/getting the Host DHCHAP key,
we need to allow setting/getting the Controller DHCHAP Key.
There was already a "getter" property, but the "setter" property
was missing.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
2 years agopython: Remove redundant host.set_key() method
Martin Belanger [Fri, 17 Mar 2023 12:12:07 +0000 (08:12 -0400)]
python: Remove redundant host.set_key() method

I just found out that the DHCHAP Key can be set as a property
(e.g. host.dhchap_key = "THE-KEY"). So, we can remove the set_key()
method that was added a few days ago.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
2 years agobuild, meson: Print option summary
Martin Belanger [Wed, 15 Mar 2023 19:49:43 +0000 (15:49 -0400)]
build, meson: Print option summary

At the end of the meson setup command, display the options so that
we can quickly determine that we're configured the project properly

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
2 years agoPython: Add support for setting/getting Host DHCHAP key
Martin Belanger [Wed, 15 Mar 2023 20:05:53 +0000 (16:05 -0400)]
Python: Add support for setting/getting Host DHCHAP key

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
2 years agoPython: Add hostnqn_from_file() and hostid_from_file()
Martin Belanger [Wed, 15 Mar 2023 19:56:55 +0000 (15:56 -0400)]
Python: Add hostnqn_from_file() and hostid_from_file()

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
2 years agotypes: Update position of elbatm in struct nvme_copy_range{_f1}
zerone [Wed, 1 Mar 2023 10:58:26 +0000 (18:58 +0800)]
types: Update position of elbatm in struct nvme_copy_range{_f1}

Update the Expected Logical Block Application Tag and Reference Tag in
struct nvme_copy_range and struct nvme_copy_range_f1.

 1. The elbatm is behind elbat fields, which are defined in section
    3.2.2 Copy command

 2. Storage and Reference Space is declared as an big-endian order,
    the elbt[10] fields need to reassigned

[dwagner: squashed changes and updated commit message]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agobuild: Upload all log files on failure
Daniel Wagner [Tue, 14 Mar 2023 14:00:53 +0000 (15:00 +0100)]
build: Upload all log files on failure

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agobuild: Initialize sysconfdir
Daniel Wagner [Tue, 14 Mar 2023 13:18:40 +0000 (14:18 +0100)]
build: Initialize sysconfdir

The default sysconfdir needs to be initialize so that Meson and muon
expand to the same final result using join_paths().

Fixes: f6100dd16b49 ("build: Use prefixdir directly on sysconfdir")
Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agodoc: fix kernel-doc-check warning
Steven Seungcheol Lee [Mon, 6 Mar 2023 06:37:10 +0000 (15:37 +0900)]
doc: fix kernel-doc-check warning

src/nvme/api-types.h:815: warning: Function parameter or member 'mos' not described in 'nvme_io_mgmt_recv_args'
src/nvme/api-types.h:815: warning: Function parameter or member 'mo' not described in 'nvme_io_mgmt_recv_args'
src/nvme/api-types.h:837: warning: Function parameter or member 'mos' not described in 'nvme_io_mgmt_send_args'
src/nvme/api-types.h:837: warning: Function parameter or member 'mo' not described in 'nvme_io_mgmt_send_args'

Signed-off-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
2 years agopython, meson: Assert that deps are present for -Dpython=true
Martin Belanger [Wed, 1 Mar 2023 19:21:03 +0000 (14:21 -0500)]
python, meson: Assert that deps are present for -Dpython=true

The -Dpython option takes 3 values: auto, true, or false. For
"auto", the Python bindings will be built if all the dependencies
are met and will be skipped in not. For "true", the Python bindings
MUST be built and therefore missing dependencies need to be treated
as an error. For "false", the Python bindings won't be built whether
the dependencies are met or not.

Currently, with -Dpython=true, if a dependency required to build the
Python bindings is missing, meson silently skips it (i.e. it behaves
like "-Dpython=auto").

Signed-off-by: Martin Belanger <martin.belanger@dell.com>