]> www.infradead.org Git - users/sagi/libnvme.git/log
users/sagi/libnvme.git
3 years agoFix %llx/%lx build warnings on powerpc
Jeremy Kerr [Mon, 20 Jun 2022 05:10:42 +0000 (13:10 +0800)]
Fix %llx/%lx build warnings on powerpc

powerpc64 uses the int-l64 type definitions, so we get an unsigned long
for our __u64 type. This causes several build warnings when we're
printing with %llx in tests/register.c and example/discover-loop.c, as
it's an unsigned long, not an unsigned long long.

One way to fix this would be to use the PRIx64 definitions from
inttypes.h - however, those are keyed off the __WORDSIZE definition,
essentially:

    # if __WORDSIZE == 64
    #  define PRIx64 "lx"
    # else
    #  define PRIx64 "llx"
    # endif

- and that breaks on x86_64, where our __u64 is an unsigned long long,
and would need %llx.

The powerpc types header does give us an option to use the int-l64
definitions though:

    /*
     * This is here because we used to use l64 for 64bit powerpc
     * and we don't want to impact user mode with our change to ll64
     * in the kernel.
     *
     * However, some user programs are fine with this.  They can
     * flag __SANE_USERSPACE_TYPES__ to get int-ll64.h here.
     */
    #if !defined(__SANE_USERSPACE_TYPES__) && defined(__powerpc64__) && !defined(__KERNEL__)
    # include <asm-generic/int-l64.h>
    #else
    # include <asm-generic/int-ll64.h>
    #endif

... and in our case we are in fact fine with this. So, #define
__SANE_USERSPACE_TYPES__ for the two example programs.

We refrain from doing this to the library headers though, as we have no
idea what libnvme users will need for __u64.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agoMerge pull request #387 from jeffreyalien/master
Daniel Wagner [Fri, 17 Jun 2022 16:41:22 +0000 (18:41 +0200)]
Merge pull request #387 from jeffreyalien/master

build: Add api-types.h to install headers

3 years agobuild: Add api-types.h to install headers
Jeff Lien [Fri, 17 Jun 2022 13:51:59 +0000 (08:51 -0500)]
build: Add api-types.h to install headers

Signed-off-by: Jeff Lien <jeff.lien@wdc.com>
3 years agoMerge pull request #386 from CodeConstruct/mi
Daniel Wagner [Fri, 17 Jun 2022 12:39:43 +0000 (14:39 +0200)]
Merge pull request #386 from CodeConstruct/mi

MI: Update MI Admin API to suit core

3 years agoMerge pull request #384 from CodeConstruct/api-types
Daniel Wagner [Fri, 17 Jun 2022 12:35:48 +0000 (14:35 +0200)]
Merge pull request #384 from CodeConstruct/api-types

api: move _args defintions to api-types.h

3 years agoexample: provide an example of both the full and partial identify commands
Jeremy Kerr [Tue, 14 Jun 2022 05:20:26 +0000 (13:20 +0800)]
example: provide an example of both the full and partial identify commands

This change adds a --partial argument to the mi-mctp command, so we have
an example of both the full and partial identify APIs.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agomi: change admin channel functions to use _args structs
Jeremy Kerr [Tue, 14 Jun 2022 05:12:19 +0000 (13:12 +0800)]
mi: change admin channel functions to use _args structs

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agoMerge pull request #383 from jeffreyalien/stc-control-bit-fix
Daniel Wagner [Tue, 14 Jun 2022 11:41:47 +0000 (13:41 +0200)]
Merge pull request #383 from jeffreyalien/stc-control-bit-fix

Fix/Add Bit Definitions NVMe Commands

3 years agoapi: move _args defintions to api-types.h
Jeremy Kerr [Tue, 14 Jun 2022 01:25:41 +0000 (09:25 +0800)]
api: move _args defintions to api-types.h

This change establishes a new (internal) header, api-types.h, and moves
the existing _args structs from ioctl.h.

This will allow us to share the definitions between the direct-ioctl
and MI interfaces.

The changes are purely a move of the struct definitions, and some
whitespace fixes, and some new file-level comments. None of the structs
are altered.

Fixes https://github.com/linux-nvme/libnvme/issues/373 .

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agoMerge pull request #375 from hreinecke/subsys-ns-lookup
Daniel Wagner [Mon, 13 Jun 2022 12:33:36 +0000 (14:33 +0200)]
Merge pull request #375 from hreinecke/subsys-ns-lookup

tree: simplifiy nvme_subsystem_lookup_namespace()

3 years agoMerge pull request #376 from linux-nvme/dependabot/github_actions/actions/setup-python-4
Daniel Wagner [Mon, 13 Jun 2022 12:20:56 +0000 (14:20 +0200)]
Merge pull request #376 from linux-nvme/dependabot/github_actions/actions/setup-python-4

build(deps): bump actions/setup-python from 3 to 4

3 years agobuild(deps): bump actions/setup-python from 3 to 4
dependabot[bot] [Mon, 13 Jun 2022 12:18:28 +0000 (12:18 +0000)]
build(deps): bump actions/setup-python from 3 to 4

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3 to 4.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
3 years agoMerge pull request #381 from igaw/add-version-to-setup-python
Daniel Wagner [Mon, 13 Jun 2022 12:17:59 +0000 (14:17 +0200)]
Merge pull request #381 from igaw/add-version-to-setup-python

ci: add python version to setup-python environment

3 years agoci: add python version to setup-python environment
Daniel Wagner [Mon, 13 Jun 2022 12:13:09 +0000 (14:13 +0200)]
ci: add python version to setup-python environment

v4 of the setup-python helper wants to know the python version number.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #380 from igaw/add-kernel-dep-note
Daniel Wagner [Mon, 13 Jun 2022 12:02:15 +0000 (14:02 +0200)]
Merge pull request #380 from igaw/add-kernel-dep-note

README: add note about min kernel version

3 years agoREADME: add note about min kernel version
Daniel Wagner [Mon, 13 Jun 2022 11:54:49 +0000 (13:54 +0200)]
README: add note about min kernel version

The min kernel version is v4.15 kernel because libnvme depends on the
/sys/class/nvme-subsystem interface.

Signed-off-by: Daniel Wagner dwagner@suse.de
3 years agodoc: update Python binding documentation
Daniel Wagner [Mon, 13 Jun 2022 11:53:30 +0000 (13:53 +0200)]
doc: update Python binding documentation

Move the Python documentation into a subsection so we don't mix it with
the main library.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agodoc: move update instruction into template
Daniel Wagner [Mon, 13 Jun 2022 11:32:32 +0000 (13:32 +0200)]
doc: move update instruction into template

The documentation added in 7fecc4881a3c ("doc: add quickstart and
installation") and 6a9758bbde33 ("doc: update installation doc")
should have been added to the template.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #379 from igaw/fix-libnvme-mi-build
Daniel Wagner [Mon, 13 Jun 2022 11:08:54 +0000 (13:08 +0200)]
Merge pull request #379 from igaw/fix-libnvme-mi-build

ioctl: Add inline to nvme_identify_cns_nsid and nvme_get_log_ana

3 years agoioctl: Add inline to nvme_identify_cns_nsid and nvme_get_log_ana
Daniel Wagner [Mon, 13 Jun 2022 11:05:09 +0000 (13:05 +0200)]
ioctl: Add inline to nvme_identify_cns_nsid and nvme_get_log_ana

Both function should always be inlined.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #76 from jk-ozlabs/mi
Daniel Wagner [Mon, 13 Jun 2022 07:28:17 +0000 (09:28 +0200)]
Merge pull request #76 from jk-ozlabs/mi

Initial NVMe-MI protocol support

3 years agotree: make nvme_ctrl_scan_namespace() idempotent
Hannes Reinecke [Fri, 10 Jun 2022 08:19:01 +0000 (10:19 +0200)]
tree: make nvme_ctrl_scan_namespace() idempotent

When issuing a rescan the list of namespaces is not cleared, so
just blindly adding new entries might not yield the expected result.
This patch clears out old entries from the controller namespace list
before adding new ones, ensuring that we only ever have one namespace
with a given name in the list of controller namespaces.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agotree: make nvme_subsystem_scan_namespace() idempotent
Hannes Reinecke [Fri, 10 Jun 2022 08:19:01 +0000 (10:19 +0200)]
tree: make nvme_subsystem_scan_namespace() idempotent

When issuing a rescan the list of namespaces is not cleared, so
just blindly adding new entries might not yield the expected result.
This patch clears out old entries from the subsystem namespace list
before adding new ones, ensuring that we only ever have one namespace
with a given name in the list of subsystem namespaces.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agotree: simplifiy nvme_subsystem_lookup_namespace()
Hannes Reinecke [Fri, 10 Jun 2022 07:48:03 +0000 (09:48 +0200)]
tree: simplifiy nvme_subsystem_lookup_namespace()

The list of namespaces needs to be considered static, and should
only be changed on a full rescan. So simplify the function to just
return the corresponding namespace entry from the topology tree.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agotest/mi: Improve test OK reporting, print log data separately
Jeremy Kerr [Fri, 10 Jun 2022 01:41:52 +0000 (09:41 +0800)]
test/mi: Improve test OK reporting, print log data separately

Currently, we have a confusing output for tests (all of which currenly
pass):

    $ ./obj/test/test-mi
    crc mismatch
    $ echo $?
    0

This change adds reporting for each test, and separates the nvme_msg log
data from the report:

    $ ./obj/test/test-mi
    Running test read_mi_data...  OK
    Running test transport_fail...  OK
    Running test invalid_crc...  OK
    --- begin test output
    crc mismatch
    --- end test output

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agoioctl: Fixed get log LSP and LSI mask values
Jeff Lien [Thu, 9 Jun 2022 14:44:50 +0000 (09:44 -0500)]
ioctl:  Fixed get log LSP and LSI mask values

Signed-off-by: Jeff Lien <jeff.lien@wdc.com>
3 years agoAdd pkgconfig for libnvme-mi
Hao Jiang [Thu, 24 Mar 2022 23:34:52 +0000 (16:34 -0700)]
Add pkgconfig for libnvme-mi

Signed-off-by: Hao Jiang <jianghao@google.com>
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agoexamples/mi-mctp: Add identify subcommand
Jeremy Kerr [Thu, 16 Sep 2021 02:58:11 +0000 (10:58 +0800)]
examples/mi-mctp: Add identify subcommand

Now that we have admin command support in libnvme-mi, use the new
partial identify to request basic serial/model/firmware information from
the drive.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agomi: Add initial Admin channel commands
Jeremy Kerr [Wed, 20 Oct 2021 03:20:39 +0000 (11:20 +0800)]
mi: Add initial Admin channel commands

This change adds Admin Channel commands, and the first admin channel
command to the MI transport: Identify. The admin functions have the
nvme_mi_admin_ prefix.

For this, we need a couple of definitions for Admin-Channel-over-MI
serialisation, and add individual admin commands using those.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agomi: Add NVMe-MI Read MI Data Structure commands for controller and controller list
Jeremy Kerr [Wed, 15 Sep 2021 09:13:44 +0000 (17:13 +0800)]
mi: Add NVMe-MI Read MI Data Structure commands for controller and controller list

Add MI functions perform Read MI Data Structure commands (section 5.6 of
the NVMe-MI v1.1), to retrieve the controller list, and the controller
data.

Use these new functions to extend the mi-mctp example to show controller
info, as a 'controllers' subcommand.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agoexamples/mi-mctp: Add subcommand support
Jeremy Kerr [Wed, 15 Sep 2021 09:27:30 +0000 (17:27 +0800)]
examples/mi-mctp: Add subcommand support

A future change will introduce further mi commands, and admin channel
commands, so we'll want a way to invoke mi-mctp to perform these
additional commands.

This change introduces an <action> argument, which currently defaults to
the existing 'info' action.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agomi: Add basic tests
Jeremy Kerr [Tue, 5 Apr 2022 07:51:26 +0000 (15:51 +0800)]
mi: Add basic tests

This change adds a couple of basic tests for the mi infrastrcucture.

To do this, we define a test "transport", which just allows inserting a
custom function as the transport's ->submit callback. Each test is then
a pair of: the test itself, and a callback to implement a specific
response from the test "device".

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agolibnvme-mi: Introduce NVMe Managament Interface library
Jeremy Kerr [Thu, 29 Jul 2021 05:32:51 +0000 (13:32 +0800)]
libnvme-mi: Introduce NVMe Managament Interface library

This change adds support for the NVMe-MI protocol, as a secondary
library: libnvme-mi.{a,so,h}. This allows management of NVMe devices,
typically through NVMe Admin Channel commands, transmitted over a
side-band channel - typically MCTP over SMBus.

There's a fair amount of shared structure between the direct-ioctl and
MI channel implementations; for example, the Admin command set is used
mostly as-is over the MI transport. The library is built as separate
.so/.a objects as client applications would typically either use one or
the other. MI-specific functions are added with a 'nvme_mi' prefix.

This change introduces a small set of MI commands using this channel.
We'll extend this to further MI commands in subsequent changes, as well
as implement Admin Channel commands too.

We currently assume a MCTP transport for NVMe-commands, using the new
AF_MCTP socket support in Linux. However, the transport-specific code is
kept somewhat separate, through the internal struct nvme_mi_transport
interface. This allows potential alternative transports in future - for
example in-band PCIe.

Finally, we start a new example application, mi-mctp, which provides
a reference application using the new library.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agoMerge pull request #372 from CodeConstruct/32-bit
Daniel Wagner [Thu, 9 Jun 2022 09:05:31 +0000 (11:05 +0200)]
Merge pull request #372 from CodeConstruct/32-bit

examples: Fix printf format warnings on 32-bit

3 years agoMerge pull request #370 from ankit-sam/master
Daniel Wagner [Thu, 9 Jun 2022 09:04:49 +0000 (11:04 +0200)]
Merge pull request #370 from ankit-sam/master

types.h: add missing fields for identify controller DS

3 years agoMerge pull request #371 from CodeConstruct/optional-cxx
Daniel Wagner [Thu, 9 Jun 2022 08:54:52 +0000 (10:54 +0200)]
Merge pull request #371 from CodeConstruct/optional-cxx

meson: only build test/cpp if a c++ compiler is available

3 years agotypes.h: add missing enum for format nvm attributes
Ankit Kumar [Wed, 8 Jun 2022 17:34:52 +0000 (23:04 +0530)]
types.h: add missing enum for format nvm attributes

Add bit3, format NVM command support nsid value set to
FFFFFFFFh enum and its description.

Signed-off-by: Ankit Kumar <ankit.kumar@samsung.com>
3 years agotypes.h: add missing enum for optional nvm command
Ankit Kumar [Wed, 8 Jun 2022 17:30:41 +0000 (23:00 +0530)]
types.h: add missing enum for optional nvm command

Add bit 8, NVM command set copy command support enum and
its description.

Signed-off-by: Ankit Kumar <ankit.kumar@samsung.com>
3 years agotypes.h: add missing description and enum for log page att
Ankit Kumar [Wed, 8 Jun 2022 17:16:35 +0000 (22:46 +0530)]
types.h: add missing description and enum for log page att

1. Add missing description for existing log page attributes.
2. Add bit 5, 6 enum and their respective descriptions.

Signed-off-by: Ankit Kumar <ankit.kumar@samsung.com>
3 years agotypes.h: add missing enum for firmware updates
Ankit Kumar [Wed, 8 Jun 2022 17:06:04 +0000 (22:36 +0530)]
types.h: add missing enum for firmware updates

Add bit 5, support multiple update detection enum and
its description.

Signed-off-by: Ankit Kumar <ankit.kumar@samsung.com>
3 years agotypes.h: add missing enum for optional admin command support
Ankit Kumar [Wed, 8 Jun 2022 16:59:16 +0000 (22:29 +0530)]
types.h: add missing enum for optional admin command support

Add bit 10, command and feature lockdown capability enum and
its description.

Signed-off-by: Ankit Kumar <ankit.kumar@samsung.com>
3 years agotypes.h: Add missing enum for power state descriptor
Ankit Kumar [Wed, 8 Jun 2022 16:49:47 +0000 (22:19 +0530)]
types.h: Add missing enum for power state descriptor

1. Add enum and description for not reported power scale.
2. Add enum and description for power workload.

Signed-off-by: Ankit Kumar <ankit.kumar@samsung.com>
3 years agoexamples: Fix printf format warnings on 32-bit
Jeremy Kerr [Wed, 8 Jun 2022 05:18:55 +0000 (13:18 +0800)]
examples: Fix printf format warnings on 32-bit

We have a few warnings from mismatched printf format specifiers on
32-bit builds. Use PRIu64 for uint64_t, and %z for size_t.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agomeson: only build test/cpp if a c++ compiler is available
Jeremy Kerr [Tue, 7 Jun 2022 06:59:02 +0000 (14:59 +0800)]
meson: only build test/cpp if a c++ compiler is available

Currently, the meson project configuration specifies both 'c' and 'ccp'
languages. We use the latter to build a single test binary.

This change makes the cpp language optional, so we can compile the rest
of libnvme without a C++ environment.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agotypes: Add Storage Tag Check IO Control flag
Jeff Lien [Tue, 7 Jun 2022 19:58:13 +0000 (14:58 -0500)]
types: Add Storage Tag Check IO Control flag

Signed-off-by: Jeff Lien <jeff.lien@wdc.com>
3 years agoMerge pull request #353 from igaw/introduce-connection-error-mapping
Daniel Wagner [Fri, 3 Jun 2022 09:42:36 +0000 (11:42 +0200)]
Merge pull request #353 from igaw/introduce-connection-error-mapping

fabrics: Introduce connection connect error mapping

3 years agoMerge pull request #365 from jeffreyalien/master
Daniel Wagner [Fri, 3 Jun 2022 07:24:23 +0000 (09:24 +0200)]
Merge pull request #365 from jeffreyalien/master

ioctl: Fix STC mask for device-self-test command

3 years agoMerge pull request #366 from sc108-lee/export-symbol
Daniel Wagner [Fri, 3 Jun 2022 07:06:40 +0000 (09:06 +0200)]
Merge pull request #366 from sc108-lee/export-symbol

libnvme: export 'nvme_scan_ctrls'

3 years agolibnvme: export 'nvme_scan_ctrls'
Steven Seungcheol Lee [Fri, 3 Jun 2022 06:54:37 +0000 (15:54 +0900)]
libnvme: export 'nvme_scan_ctrls'

For some reason it has been missing from the map file.

Signed-off-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
3 years agoioctl: Fix STC mask for device-self-test command
Jeff Lien [Thu, 2 Jun 2022 19:50:05 +0000 (14:50 -0500)]
ioctl: Fix STC mask for device-self-test command

Signed-off-by: Jeff Lien <jeff.lien@wdc.com>
3 years agofabrics: Introduce connection connect error mapping
Daniel Wagner [Thu, 14 Apr 2022 11:38:25 +0000 (13:38 +0200)]
fabrics: Introduce connection connect error mapping

The kernel returns status information via error codes. Currently we
map all error codes to ENVME_CONNECT_WRITE if the operation
fails. Some of those error codes should be treated differently, such
as EALREADY which means the connection attempt failed because the
connection is already established.

Many of the error codes are overloaded so we have to guess if they are
actually from the nvme subsystem and not from the write
command. Though in practice it's almost certainly the nvme
subsystem. Still it's a guessing game due the very limited API
between userland and kernel.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #362 from ankit-sam/master
Daniel Wagner [Tue, 24 May 2022 13:26:03 +0000 (15:26 +0200)]
Merge pull request #362 from ankit-sam/master

ioctl: nvme_uring_cmd add structure and opcodes

3 years agoMerge pull request #363 from igaw/apply-file-config
Daniel Wagner [Tue, 24 May 2022 13:11:06 +0000 (15:11 +0200)]
Merge pull request #363 from igaw/apply-file-config

Consider file config when adding controller

3 years agoMerge pull request #358 from jeffreyalien/tp-4068-4084
Daniel Wagner [Fri, 20 May 2022 08:21:21 +0000 (10:21 +0200)]
Merge pull request #358 from jeffreyalien/tp-4068-4084

Changes to support TP 4068 and TP 4084

3 years agodoc: Add function nvme_init_copy_range_f1 doc
Jeff Lien [Mon, 16 May 2022 21:25:33 +0000 (16:25 -0500)]
doc: Add function nvme_init_copy_range_f1 doc

Signed-off-by: Jeff Lien <jeff.lien@wdc.com>
3 years agolibnvme: 64-bit Reference Tags and TP-4068 changes
Brandon Paupore [Fri, 18 Mar 2022 22:03:56 +0000 (17:03 -0500)]
libnvme: 64-bit Reference Tags and TP-4068 changes

Adds support for expanded reference and storage tags, automatically
placing them into the appropriate bits based on Protection Information
Format and Storage Tag Size. This includes updates to nvme_io_args
expanding the size of the tags and adding these STS and PIF values.

Also adds a new copy range format as defined by the NVMe 2.0 spec, as it
determines the reference/storage tags associated to the range being
copied.

Signed-off-by: Brandon Paupore <brandon.paupore@wdc.com>
Signed-off-by: Jeff Lien <jeff.lien@wdc.com>
3 years agoioctl: nvme_uring_cmd add structure and opcodes
Anuj Gupta [Thu, 19 May 2022 11:35:21 +0000 (17:05 +0530)]
ioctl: nvme_uring_cmd add structure and opcodes

This adds definition of struct nvme_uring_cmd and
NVME_URING_CMD_IO/NVME_URING_CMD_IO_VEC opcodes. The new structure
definition and opcodes are required for using uring-nvme-passthrough
feature. This feature has been picked for 5.19 kernel.

Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
Signed-off-by: Ankit Kumar <ankit.kumar@samsung.com>
3 years agofabrics: Consider config from file when adding new controller
Daniel Wagner [Thu, 19 May 2022 08:49:40 +0000 (10:49 +0200)]
fabrics: Consider config from file when adding new controller

nvme_read_config() function is attaching the configuration
to tree. But when we create a new controller via nvme_create_ctrl()
and then call nvmf_add_ctrl() we ignore this previously read
in configuration.

Hence lookup if there exist a controller/config and merge into
the fabrics config.

Note, the order of the merge is important. For example we want
the config from the command line to have higher priority
than the one from the config file.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agotree: Factor lookup code for controller
Daniel Wagner [Thu, 19 May 2022 08:44:24 +0000 (10:44 +0200)]
tree: Factor lookup code for controller

nvme_lookup_ctrl() will create a controller if it is not
found. In the case where we really just want the lookup
if a controller is in the tree we are missing a pure
lookup function. Hence factor out the lookup into a internal
function.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agolibnvme: Export nvme_ctrl_get_config
Daniel Wagner [Thu, 19 May 2022 08:41:27 +0000 (10:41 +0200)]
libnvme: Export nvme_ctrl_get_config

We missed to export the nvme_ctrl_get_config() function in
version 1.0.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #361 from igaw/clarify-license
Hannes Reinecke [Tue, 17 May 2022 15:02:24 +0000 (17:02 +0200)]
Merge pull request #361 from igaw/clarify-license

Clarify license and add missing SPDX identifiers

3 years agomeson: Use SPDX identifier as license text
Daniel Wagner [Tue, 17 May 2022 14:01:23 +0000 (16:01 +0200)]
meson: Use SPDX identifier as license text

First it is recommended to use SPDX identifiers for the version field
and second it clarifies which LGPL version this project is using.

While at it, also use the SPDX identifier in the README.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agotreewide: Add SPDX identifier
Daniel Wagner [Tue, 17 May 2022 13:49:24 +0000 (15:49 +0200)]
treewide: Add SPDX identifier

Add the SPDX identifer with the projects default license choice.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agolog: Change license to LGPL-2.1-or-later
Daniel Wagner [Tue, 17 May 2022 13:48:14 +0000 (15:48 +0200)]
log: Change license to LGPL-2.1-or-later

Change the license to LGPL-2.1-or-later to match with the projects
license.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agolicenses: Remove old dir from initial ccan import
Daniel Wagner [Tue, 17 May 2022 13:34:00 +0000 (15:34 +0200)]
licenses: Remove old dir from initial ccan import

The ccan directory has been moved to nvme-cli/ccan including the
initial location of licenses. Remove stale directory.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agotypes: Add new enums and defines for TP-4084
Jeff Lien [Wed, 13 Apr 2022 14:38:14 +0000 (09:38 -0500)]
types: Add new enums and defines for TP-4084

Signed-off-by: Jeff Lien <jeff.lien@wdc.com>
3 years agoMerge pull request #360 from martin-gpy/nvme_config_segfault
Daniel Wagner [Fri, 13 May 2022 13:53:26 +0000 (15:53 +0200)]
Merge pull request #360 from martin-gpy/nvme_config_segfault

tree: avoid segfault if subsysnqn is not available

3 years agoMerge pull request #359 from glimchb/master
Daniel Wagner [Fri, 13 May 2022 13:48:48 +0000 (15:48 +0200)]
Merge pull request #359 from glimchb/master

ci: add static library compilation

3 years agoMerge pull request #357 from t-8ch/host_mem_buf-feature-length
Daniel Wagner [Fri, 13 May 2022 13:47:00 +0000 (15:47 +0200)]
Merge pull request #357 from t-8ch/host_mem_buf-feature-length

util: Add feature length for host memory buffer

3 years agotree: avoid segfault if subsysnqn is not available
Martin George [Fri, 13 May 2022 07:43:10 +0000 (13:13 +0530)]
tree: avoid segfault if subsysnqn is not available

A nvme config command specifying the -M & -J options would end
up in a segfault if subsysnqn is NULL, as shown below:

nvme config -M -J /etc/nvme/config.json
Segmentation fault (core dumped)

Avoid this segfault by proceeding with the subsysnqn strcmp in
nvme_lookup_subsystem() only if subsysnqn is available.

Signed-off-by: Martin George <marting@netapp.com>
3 years agoci: add static library compilation
Boris Glimcher [Mon, 2 May 2022 10:09:07 +0000 (13:09 +0300)]
ci: add static library compilation

Now possible since we can use uuid for fallback

Signed-off-by: Boris Glimcher <Boris.Glimcher@emc.com>
3 years agoMerge pull request #349 from glimchb/master
Daniel Wagner [Fri, 29 Apr 2022 17:06:05 +0000 (19:06 +0200)]
Merge pull request #349 from glimchb/master

build: use uuid wrap for fallback build

3 years agoutil: Add feature length for host memory buffer
Thomas Weißschuh [Fri, 29 Apr 2022 15:06:27 +0000 (17:06 +0200)]
util: Add feature length for host memory buffer

Without this the command "nvme get-feature /dev/nvme0 -H -f 0x0d"
segfaults because it retrieves no data but tries to use it in
nvme_show_host_mem_buffer()

3 years agobuild: use uuid wrap for fallback build
Boris Glimcher [Wed, 13 Apr 2022 13:11:34 +0000 (16:11 +0300)]
build: use uuid wrap for fallback build

see https://github.com/util-linux/util-linux/pull/1657

Signed-off-by: Boris Glimcher <Boris.Glimcher@emc.com>
3 years agoMerge pull request #356 from hreinecke/coverity
Hannes Reinecke [Fri, 22 Apr 2022 10:12:17 +0000 (12:12 +0200)]
Merge pull request #356 from hreinecke/coverity

Coverity fixes

3 years agotest/zns: coverity fixes
Hannes Reinecke [Fri, 22 Apr 2022 09:44:05 +0000 (11:44 +0200)]
test/zns: coverity fixes

Coverity found some resource leaks.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agotree: coverity fixes
Hannes Reinecke [Fri, 22 Apr 2022 09:42:47 +0000 (11:42 +0200)]
tree: coverity fixes

Coverity found some resource leaks and a possible out-of-bounds access
in nvme_ctrl_lookup_subsystem_name() where we could overflow the
'path' variable.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agofabrics: coverity fixes
Hannes Reinecke [Fri, 22 Apr 2022 09:37:19 +0000 (11:37 +0200)]
fabrics: coverity fixes

Coverity reported a possible out-of-bounds access in inet6_pton
and we never checked the return value of nvme_ctrl_identify() in
nvme_fetch_cntrltype_dctype_from_id(), leading to a possible
NULL pointer access in nvmf_is_registration_supported().

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agoexamples/telemetry-listen: coverity fixes
Hannes Reinecke [Fri, 22 Apr 2022 09:37:19 +0000 (11:37 +0200)]
examples/telemetry-listen: coverity fixes

Coverity reported several issues.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agoMerge pull request #354 from eli-schwartz/uuid_h-name
Daniel Wagner [Thu, 21 Apr 2022 15:32:09 +0000 (17:32 +0200)]
Merge pull request #354 from eli-schwartz/uuid_h-name

fix broken includes for the uuid.h header

3 years agoreduce the exposed interface for libnvme_dep
Eli Schwartz [Fri, 15 Apr 2022 05:06:56 +0000 (01:06 -0400)]
reduce the exposed interface for libnvme_dep

It does not publicly expose openssl. It does publicly expose uuid.h and
json.h, but only in terms of header types, not symbols used... so use a
partial dependency that doesn't expose the link libraries.

3 years agofix broken includes for the uuid.h header
Eli Schwartz [Fri, 15 Apr 2022 00:23:40 +0000 (20:23 -0400)]
fix broken includes for the uuid.h header

Per `man 3 uuid`, the correct include is `<uuid.h>`, and correspondingly
the util-linux build system installs the uuid.h file to
`$(includedir)/uuid/` and uuid.pc adds `-I${includedir}/uuid` to the
dependency Cflags.

Including it as `<uuid/uuid.h>` simply fails altogether. The exception
is if, by coincidence, the libuuid includedir happens to be the same as
one of the compiler's own internal include directories... which is
pretty common if that is `/usr/include`. In this case, `<uuid/uuid.h>`
fails to be found in the uuid dependency's export directories, but the
compiler picks up a copy in its builtin search path.

In other cases, such as when util-linux is compiled into a custom prefix
and added to the PKG_CONFIG_PATH, it either:

- fails with missing header errors, if libuuid-dev is not installed

- seems to succeed, but compiles against a different version of the
  headers than the library that is linked to, resulting in potentially
  various problems from bizarre linker errors, to subtly broken
  incompatible symbols that crash, or corrupt the results

The problem is even worse if you try to use util-linux as a subproject
dependency fallback. In this case, `<uuid.h>` is correctly exported, but
there is no disk location for `<uuid/uuid.h>` and absolutely no way to
generate such a location in the builddir. This completely prevents the
use of subproject fallbacks.

Once the header include is renamed, it is revealed that the example and
test executables don't correctly build as they depend on the full public
interface of libnvme, which includes the public compile interface of
libuuid due to `libnvme.h` including `uuid.h`. Update all executables to
depend on the full public interface of libnvme_dep instead of simply
linking to the library name on its own.

3 years agoMerge pull request #340 from igaw/add-git-version
Daniel Wagner [Thu, 14 Apr 2022 12:11:30 +0000 (14:11 +0200)]
Merge pull request #340 from igaw/add-git-version

build: Add git ref to the binary

3 years agoMerge pull request #350 from glimchb/doc
Daniel Wagner [Thu, 14 Apr 2022 12:02:45 +0000 (14:02 +0200)]
Merge pull request #350 from glimchb/doc

doc: update installation doc

3 years agoMerge pull request #352 from igaw/fix-log-level
Daniel Wagner [Thu, 14 Apr 2022 10:33:41 +0000 (12:33 +0200)]
Merge pull request #352 from igaw/fix-log-level

fabrics: Remove double connection error logging

3 years agofabrics: Remove double connection error logging
Daniel Wagner [Thu, 14 Apr 2022 10:18:53 +0000 (12:18 +0200)]
fabrics: Remove double connection error logging

nvmf_connect_disc_entry() is calling nvmf_add_ctrl() to do the
connecting attempt. We have in nvmf_add_ctrl() all error paths logging
enabled, so another logging in nvmf_connect_disc_entry() is not
necessary and introduces a problem such as nmve-cli users interpreting
this as hard error.

For example the kernel reports via < 0 return values state information
such as the connection is already there if the user runs 'nvme
connect-all' twice:

  $ .build/nvme connect-all -t tcp --traddr=10.161.8.24  --trsvcid=4421
  Failed to write to /dev/nvme-fabrics: Operation already in progress
  failed to connect controller, error 1006

Let's remove this error message.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #351 from igaw/fix-log-level
Daniel Wagner [Thu, 14 Apr 2022 10:13:00 +0000 (12:13 +0200)]
Merge pull request #351 from igaw/fix-log-level

fabrics: Lower log level in __nvmf_add_ctrl

3 years agofabrics: Lower log level in __nvmf_add_ctrl
Daniel Wagner [Thu, 14 Apr 2022 10:01:43 +0000 (12:01 +0200)]
fabrics: Lower log level in __nvmf_add_ctrl

9df8676d2db6 ("Add logging functionality to libnvme") introduced the
logging. The log level for writing to /dev/nvme-fabrics was set on
NOTICE because the kernel reports also status information such
EALREADY which is a soft error.

866c288a456f ("fabrics: update log level for write failures")
increased the log level without taking this into account.

Drop back to NOTICE level to avoid error message when doing

  $ nvme connect-all ....
  Failed to write to /dev/nvme-fabrics: Operation already in progress

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoutil: add function to retrieve version information
Daniel Wagner [Wed, 13 Apr 2022 19:15:52 +0000 (21:15 +0200)]
util: add function to retrieve version information

Allow to query the version of the library via a function.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agodoc: update installation doc
Boris Glimcher [Wed, 13 Apr 2022 13:53:51 +0000 (16:53 +0300)]
doc: update installation doc

Signed-off-by: Boris Glimcher <Boris.Glimcher@emc.com>
3 years agoMerge pull request #344 from glimchb/doc
Daniel Wagner [Wed, 13 Apr 2022 12:34:37 +0000 (14:34 +0200)]
Merge pull request #344 from glimchb/doc

doc: add quickstart and installation

3 years agoMerge pull request #342 from cions/fix-cxx11-narrowing
Daniel Wagner [Wed, 13 Apr 2022 09:59:53 +0000 (11:59 +0200)]
Merge pull request #342 from cions/fix-cxx11-narrowing

ioctl.h: Fix clang -Wc++11-narrowing error

3 years agoMerge pull request #345 from linux-nvme/dependabot/github_actions/actions/checkout-3
Daniel Wagner [Wed, 13 Apr 2022 09:55:42 +0000 (11:55 +0200)]
Merge pull request #345 from linux-nvme/dependabot/github_actions/actions/checkout-3

build(deps): bump actions/checkout from 2 to 3

3 years agobuild(deps): bump actions/checkout from 2 to 3
dependabot[bot] [Wed, 13 Apr 2022 09:54:18 +0000 (09:54 +0000)]
build(deps): bump actions/checkout from 2 to 3

Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
3 years agoMerge pull request #346 from linux-nvme/dependabot/github_actions/codecov/codecov...
Daniel Wagner [Wed, 13 Apr 2022 09:53:58 +0000 (11:53 +0200)]
Merge pull request #346 from linux-nvme/dependabot/github_actions/codecov/codecov-action-3

build(deps): bump codecov/codecov-action from 1 to 3

3 years agoMerge pull request #347 from linux-nvme/dependabot/github_actions/actions/setup-python-3
Daniel Wagner [Wed, 13 Apr 2022 09:53:20 +0000 (11:53 +0200)]
Merge pull request #347 from linux-nvme/dependabot/github_actions/actions/setup-python-3

build(deps): bump actions/setup-python from 1 to 3

3 years agoMerge pull request #348 from linux-nvme/dependabot/github_actions/actions/upload...
Daniel Wagner [Wed, 13 Apr 2022 09:52:45 +0000 (11:52 +0200)]
Merge pull request #348 from linux-nvme/dependabot/github_actions/actions/upload-artifact-3

build(deps): bump actions/upload-artifact from 1 to 3

3 years agoMerge pull request #338 from TotalCaesar659/patch-1
Daniel Wagner [Wed, 13 Apr 2022 09:49:05 +0000 (11:49 +0200)]
Merge pull request #338 from TotalCaesar659/patch-1

Update URLs to HTTPS

3 years agobuild(deps): bump actions/upload-artifact from 1 to 3
dependabot[bot] [Wed, 13 Apr 2022 09:47:17 +0000 (09:47 +0000)]
build(deps): bump actions/upload-artifact from 1 to 3

Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 1 to 3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v1...v3)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
3 years agobuild(deps): bump actions/setup-python from 1 to 3
dependabot[bot] [Wed, 13 Apr 2022 09:47:14 +0000 (09:47 +0000)]
build(deps): bump actions/setup-python from 1 to 3

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 1 to 3.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v1...v3)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>