]> www.infradead.org Git - users/sagi/libnvme.git/log
users/sagi/libnvme.git
2 years agoMerge pull request #513 from igaw/move-def
Daniel Wagner [Fri, 28 Oct 2022 15:06:47 +0000 (17:06 +0200)]
Merge pull request #513 from igaw/move-def

types: Move enum nvme_data_tfr to types

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

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

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

fabris: Use doublicate string when merging configs

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

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

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

build: Update min version of meson to 0.48

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

 Set log page offset for nvme_{mi}_get_log_telemetry_host

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

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

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

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

The function is not setting the passed in offset.

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

The function is not setting the passed in offset.

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

util: Add simple UUID type

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

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

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

libnvme.map: add nvme_ctrl_is_persistent()

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

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

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

util: Do not expose fallthrough defines

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

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

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

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

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

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

examples/mi-conf: Initialise sd_bus_error

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

Add encoding for MI/NVMe status values

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

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

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

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

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

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

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

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

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agomi: Distinguish MI status from NVMe (CDW3) status
Jeremy Kerr [Thu, 20 Oct 2022 07:02:10 +0000 (15:02 +0800)]
mi: Distinguish MI status from NVMe (CDW3) status

We curerently have some overloading in the status values returned from
the nvme_* API, as the NVMe CDW3 values overlap with the
recently-introduced NVMe-MI response header status.

This change introduces a new encoding for the return values of MI
functions, where we use a set of bits in the return value to encode
whether the value is either a MI status value or a NVMe status value. We
leave room for future expansion too, by defining three bits of possible
type values.

This has minimal change to the current API, as we're using 0 for the
current NVMe status codes, so they are all unchanged. Since the MI
values alised those, they will have high bits set now, but we couldn't
previously distinguish them from the NVMe values anyway.

Fixes: https://github.com/linux-nvme/libnvme/issues/456
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agomi: Add Identify helper for ns-descs and primary-ctrl-caps
Jinliang Wang [Tue, 11 Oct 2022 17:20:58 +0000 (10:20 -0700)]
mi: Add Identify helper for ns-descs and primary-ctrl-caps

This change adds two helpers for the Identify command, retrieving the
namespace identification descriptior list and primary controller capabilities
data structure.

Signed-off-by: Jinliang Wang <jinliangw@google.com>
2 years agoMerge pull request #501 from safl/mk
Daniel Wagner [Fri, 21 Oct 2022 07:50:53 +0000 (09:50 +0200)]
Merge pull request #501 from safl/mk

Makefile: add 'make uninstall'

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

libnvme: Add direction parameter to get feature length

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

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

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

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

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
[dwagner: reordered definitions and declerations]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMakefile: add 'make uninstall'
Simon A. F. Lund [Thu, 20 Oct 2022 10:09:49 +0000 (12:09 +0200)]
Makefile: add 'make uninstall'

An uninstall option, in addition to RPM install/uninstall, is arguably
quite convenient. Yet, Makefiles usually do not provide an 'uninstall'
target since that would require recording an installation manifest and
custom logic for removal.

However, meson has an internal feature doing precisely that.

This change invokes the meson uninstall feature via "make uninstall".

Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
2 years agoMerge pull request #499 from CodeConstruct/pr/log-page
Daniel Wagner [Wed, 19 Oct 2022 12:10:58 +0000 (14:10 +0200)]
Merge pull request #499 from CodeConstruct/pr/log-page

mi: fix get_log_page chunked offset check

2 years agomi: fix get_log_page chunked offset check
Jeremy Kerr [Wed, 28 Sep 2022 09:44:24 +0000 (17:44 +0800)]
mi: fix get_log_page chunked offset check

In our get_log_page helper, we're incorrectly checking the requested
chunk offset against the chunk len, rather than the overall length -
this means we can't query anything but the first chunk.

This change fixes this to check against the overall length instead, and
adds an additional check to ensure we're not requesting more than the
full data size.

We also add a testcase for the chunking code.

Reported-by: Hao Jiang <jianghao@google.com>
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agoMerge pull request #491 from igaw/harden-json-parser
Daniel Wagner [Tue, 18 Oct 2022 16:43:45 +0000 (18:43 +0200)]
Merge pull request #491 from igaw/harden-json-parser

Enforce correct JSON config format

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

libnvme: fix a memory leak in nvme_mi_open_mctp()

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

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

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

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

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

Add more details for return code of MI admin cmds

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

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

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

json-c's json_object_from_fd() doesn't set the JSON_TOKENER_STRICT
flag. This means the parser is more failure tolerant. Let's be strict
and enforce fully correctly formatted configuration.

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

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

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

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

examples: LID supported must be shifted right by 16

2 years agoexamples: LID supported must be shifted right by 16
Martin Belanger [Wed, 28 Sep 2022 12:57:33 +0000 (08:57 -0400)]
examples: LID supported must be shifted right by 16

To access the LID Specific Field (see Base specs) the values
from the Get Supported Log pages must be shifted right by 16.
The example code was missing the shift.

Also added better exception handling example.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
2 years agoMerge pull request #487 from martin-belanger/eliminate-empty-arguments
Daniel Wagner [Tue, 27 Sep 2022 15:03:25 +0000 (17:03 +0200)]
Merge pull request #487 from martin-belanger/eliminate-empty-arguments

fabrics: Filter out empty strings in add_argument()

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

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

python: Use nvmf_get_discovery_wargs()

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

fabrics: Add nvmf_get_discovery_wargs()

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

mi: Add firmware download and commit commands

2 years agoMerge pull request #484 from CodeConstruct/dev/mi-symvers
Daniel Wagner [Mon, 26 Sep 2022 13:50:36 +0000 (15:50 +0200)]
Merge pull request #484 from CodeConstruct/dev/mi-symvers

mi: Move post-1.1 symbols to 1_2 section of libnvme-mi.map

2 years agomi: Add firmware download and commit commands
Jeremy Kerr [Sat, 24 Sep 2022 06:44:36 +0000 (14:44 +0800)]
mi: Add firmware download and commit commands

This change adds MI implementations for the Firmware Download and
Firmware Commit admin commands, as well as a couple of tests.

As usual, these are designed to match the ioctl API.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agomi: Move post-1.1 symbols to 1_2 section of libnvme-mi.map
Jeremy Kerr [Mon, 26 Sep 2022 13:10:22 +0000 (21:10 +0800)]
mi: Move post-1.1 symbols to 1_2 section of libnvme-mi.map

There have been a few functions added after the v1.1 release that ended
up in the 1_1 section of the symbol map. This change moves them to a new
1_2 section instead.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agopython: Use nvmf_get_discovery_wargs()
Martin Belanger [Mon, 26 Sep 2022 12:30:39 +0000 (08:30 -0400)]
python: Use nvmf_get_discovery_wargs()

Refactor code to use nvmf_get_discovery_wargs() which allows setting
the LSP field. Needed for TP8010 support (i.e. setting PLEO bit).

Also, added supported_log_pages() which is used to determine
whether the PLEO bit is supported (PLOES).

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
2 years agofabrics: Add nvmf_get_discovery_wargs()
Martin Belanger [Mon, 26 Sep 2022 11:13:55 +0000 (07:13 -0400)]
fabrics: Add nvmf_get_discovery_wargs()

This function is similar to nvmf_get_discovery_log(), but takes
an extensible "args" parameter. The args parameter contains more
options than are available with nvmf_get_discovery_log(). For
example, it provides a way to set the LSP (Log page Specific field)
which is needed for advanced TP8010 features.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
2 years agoMerge pull request #479 from CodeConstruct/dev/ci-cross
Daniel Wagner [Mon, 26 Sep 2022 07:23:40 +0000 (09:23 +0200)]
Merge pull request #479 from CodeConstruct/dev/ci-cross

github workflows: Add armhf & powerpc64le cross builds

2 years agoMerge pull request #481 from CodeConstruct/dev/mi-status
Daniel Wagner [Mon, 26 Sep 2022 06:51:43 +0000 (08:51 +0200)]
Merge pull request #481 from CodeConstruct/dev/mi-status

mi: Introduce a helper for response status, unify values with ioctls

2 years agoMerge pull request #480 from CodeConstruct/dev/mi-id-secondary
Daniel Wagner [Mon, 26 Sep 2022 06:48:43 +0000 (08:48 +0200)]
Merge pull request #480 from CodeConstruct/dev/mi-id-secondary

mi: Add Identify function for secondary controller list

2 years agomi: Introduce a helper for response status, unify values with ioctls
Jeremy Kerr [Sat, 24 Sep 2022 09:01:08 +0000 (17:01 +0800)]
mi: Introduce a helper for response status, unify values with ioctls

Currently, every admin command function has a similar pattern for
catching an error from one of:

 - the MI transport; or
 - the admin cdw0 field, sometimes populated to a result pointer

This change adds a helper for that pattern.

Then, instead of using cdw0 for the return value, we should be using
cdw3 instead, as cdw0 is command-specific, and may not always indicate
an error. We can then return the proper status type & status, in the
same way that the ioctl commands do.

This goes part way to fixing
https://github.com/linux-nvme/libnvme/issues/456, but we still have an
issue where the MI return values may alias the cdw3 return values.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agomi: Add Identify function for secondary controller list
Jeremy Kerr [Sat, 24 Sep 2022 06:09:26 +0000 (14:09 +0800)]
mi: Add Identify function for secondary controller list

This change adds a helper for the Identify command, retrieving the
secondary controller list. We add a simple test too.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agogithub workflows: Add a powerpc64le cross build
Jeremy Kerr [Sat, 24 Sep 2022 05:54:13 +0000 (13:54 +0800)]
github workflows: Add a powerpc64le cross build

Like the armhf cross build, add one for 64-bit powerpc too.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agogithub workflows: Add an armhf cross build
Jeremy Kerr [Sat, 24 Sep 2022 02:49:16 +0000 (10:49 +0800)]
github workflows: Add an armhf cross build

This RFC change adds a github workflow for a cross-compile of libnvme on
armhf. We use a similar setup to the build-distro job, but install a
suitable cross compiler and provide a cross config to meson.

We currently setup with -Dpython=false, as the setup-python@v4 seems to
assume a native python build. We may be able to remove this later.

The suitability of this will depend on the resources available for
actions; doing some test runs on a private repo shows an execution time
of about 1 min 15 sec - a little less than the build-static job.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agoMerge pull request #476 from martin-belanger/add-tp8010-defs
Daniel Wagner [Thu, 22 Sep 2022 16:15:33 +0000 (18:15 +0200)]
Merge pull request #476 from martin-belanger/add-tp8010-defs

fabrics: Add new TP8010 definitions

2 years agofabrics: Add new TP8010 definitions
Martin Belanger [Thu, 22 Sep 2022 15:59:17 +0000 (11:59 -0400)]
fabrics: Add new TP8010 definitions

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
2 years agoMerge pull request #473 from martin-belanger/add-lsp-to-get-dlp4
Daniel Wagner [Thu, 22 Sep 2022 09:59:44 +0000 (11:59 +0200)]
Merge pull request #473 from martin-belanger/add-lsp-to-get-dlp4

examples: Add missing free()

2 years agoexamples: Add missing free()
Martin Belanger [Wed, 21 Sep 2022 18:01:26 +0000 (14:01 -0400)]
examples: Add missing free()

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
2 years agoMerge pull request #470 from linux-nvme/dependabot/github_actions/actions/checkout-3
Daniel Wagner [Mon, 12 Sep 2022 07:45:42 +0000 (09:45 +0200)]
Merge pull request #470 from linux-nvme/dependabot/github_actions/actions/checkout-3

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

2 years agomi: Fix C++ compiler errors
Hao Jiang [Wed, 7 Sep 2022 22:32:24 +0000 (15:32 -0700)]
mi: Fix C++ compiler errors

C++20 compiler reported the following errors:

  error: invalid conversion from 'int' to 'nvme_mi_config_smbus_freq'
  error: designator order for field 'nvme_ns_mgmt_args::nsid' does not match declaration order in 'nvme_ns_mgmt_args'

Signed-off-by: Hao Jiang <jianghao@google.com>
2 years agobuild(deps): bump actions/checkout from 2 to 3
dependabot[bot] [Mon, 12 Sep 2022 02:17:16 +0000 (02:17 +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>
2 years agoMerge pull request #469 from CodeConstruct/action-warn-fix
Daniel Wagner [Fri, 9 Sep 2022 11:11:16 +0000 (13:11 +0200)]
Merge pull request #469 from CodeConstruct/action-warn-fix

examples/mi-mctp: fix warning for possibly uninitialised variable

2 years agoexamples/mi-mctp: fix warning for possibly uninitialised variable
Jeremy Kerr [Fri, 9 Sep 2022 10:10:10 +0000 (18:10 +0800)]
examples/mi-mctp: fix warning for possibly uninitialised variable

gcc-12 with -Wuninitialized-var reports a warning for mi-mctp:

    examples/mi-mctp.c: In function ‘do_action_endpoint’:
    examples/mi-mctp.c:665:16: warning: ‘rc’ may be used uninitialized [-Wmaybe-uninitialized]
      665 |         return rc;
          |                ^~
    examples/mi-mctp.c:637:13: note: ‘rc’ was declared here
      637 |         int rc;
          |             ^~

We shouldn't be able to hit this path, but explicitly set rc to an error
if we miss an enum case.

Fixes: https://github.com/linux-nvme/libnvme/issues/467
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agoMerge pull request #465 from martin-gpy/update_schema
Daniel Wagner [Wed, 7 Sep 2022 10:19:47 +0000 (12:19 +0200)]
Merge pull request #465 from martin-gpy/update_schema

json-schema: add dhchap_key details to host section

2 years agojson-schema: add dhchap_key details to host section
Martin George [Wed, 7 Sep 2022 08:54:05 +0000 (14:24 +0530)]
json-schema: add dhchap_key details to host section

One can set the dhchap_key in the host section as well of
the config JSON file. So update the JSON schema to reflect
the same.

Signed-off-by: Martin George <marting@netapp.com>
2 years agodocs: Relax regex in identifier match in list-man-pages.sh
Daniel Wagner [Fri, 2 Sep 2022 06:24:35 +0000 (08:24 +0200)]
docs: Relax regex in identifier match in list-man-pages.sh

Function, struct and enum identifiers are allowed to have digits in
their name, just not as first character. Relax the regex accordingly.

Reported-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #464 from igaw/fix-man-page-dir
Daniel Wagner [Tue, 30 Aug 2022 15:24:47 +0000 (17:24 +0200)]
Merge pull request #464 from igaw/fix-man-page-dir

doc: Install pre-compiled man pages to the correct path

2 years agodoc: Install pre-compiled man pages to the correct path
Daniel Wagner [Tue, 30 Aug 2022 14:03:56 +0000 (16:03 +0200)]
doc: Install pre-compiled man pages to the correct path

The install_subdir('man', ...) command installs the man pages under
$mandir/man/ instead of $mandir. Use and external script to get the
list of man pages to avoid having to list all the man pages
explicitly.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #463 from martin-gpy/authkey_unavailable_segfault
Daniel Wagner [Tue, 30 Aug 2022 12:22:44 +0000 (14:22 +0200)]
Merge pull request #463 from martin-gpy/authkey_unavailable_segfault

nvme-tree: avoid segfault if auth keys are unavailable

2 years agonvme-tree: avoid segfault if auth keys are unavailable
Martin George [Fri, 26 Aug 2022 13:17:57 +0000 (18:47 +0530)]
nvme-tree: avoid segfault if auth keys are unavailable

Seeing multiple segfaults in nvme_configure_ctrl() when the
respective controller attributes (including auth keys) are
unavailable. For e.g. attempting a nvme connect with bidirectional
auth hits the following segfault:

nvme connect -t tcp -w 192.168.1.16 -a 192.168.1.116 -n
nqn.1992-08.com.netapp:sn.48391d66c0a611ecaaa5d039ea165514:subsystem.subsys_CLIENT116
-S DHHC-1:01:k+fO3MFyRpOwrPTUQh0ewZI58uf8bwn5H9RnHle4Q8U37aJe:
-C DHHC-1:03:KEVxLQLJxugDXw/tWm9VmZuas38ath9HWzpq+cDprHafC4yuVg+McEQgEltOJAIIziNfWWKaw8mpPrnSQqqQuHKE5zQ=:
Segmentation fault (core dumped)

In another instance, a segfault is seen if no keys are specified
in the nvme connect:

nvme connect -t tcp -w 192.168.1.16 -a 192.168.1.116
-n nqn.1992-08.com.netapp:sn.48391d66c0a611ecaaa5d039ea165514:subsystem.subsys_CLIENT116
Segmentation fault (core dumped)

Avoid these segfaults by checking if the respective controller attributes
(including auth keys) are available before dereferencing them.

Fixes: 6614a55 ("Parse dhchap_host_key at controller level")
Signed-off-by: Martin George <marting@netapp.com>
2 years agoMerge pull request #461 from hreinecke/dhchap-templating.v2
Daniel Wagner [Thu, 25 Aug 2022 15:10:22 +0000 (17:10 +0200)]
Merge pull request #461 from hreinecke/dhchap-templating.v2

Allow to get and set DHCHAP host key on controller level

2 years agoMerge pull request #460 from CodeConstruct/mpr
Daniel Wagner [Thu, 25 Aug 2022 11:44:36 +0000 (13:44 +0200)]
Merge pull request #460 from CodeConstruct/mpr

mi: Allow Admin-message sized More Processing Required responses

2 years agoUpdate json config schema for missing dhchap host key
Hannes Reinecke [Thu, 25 Aug 2022 08:35:53 +0000 (10:35 +0200)]
Update json config schema for missing dhchap host key

The dhchap key definition for the host was missing.

Signed-off-by: Hannes Reinecke <hare@suse.de>
2 years agoParse dhchap_host_key on controller level
Hannes Reinecke [Thu, 25 Aug 2022 08:27:02 +0000 (10:27 +0200)]
Parse dhchap_host_key on controller level

The json config schema declares an 'dhchap_key' element representing
the dhchap host key on the controller level, but the implementation
was missing. Add the missing parsing elements and ensure to pick the
correct one (either host or controller setting) when creating the
nvme connect string.

Signed-off-by: Hannes Reinecke <hare@suse.de>
2 years agotree: rename controller 'dhchap_key' to 'dhchap_ctrl_key'
Hannes Reinecke [Thu, 28 Jul 2022 16:19:41 +0000 (18:19 +0200)]
tree: rename controller 'dhchap_key' to 'dhchap_ctrl_key'

To differentiate between 'host' and 'controller' keys within
the controller structure.

Signed-off-by: Hannes Reinecke <hare@suse.de>
2 years agolibnvme: accessors for dhchap_key variables
Hannes Reinecke [Thu, 28 Jul 2022 16:12:07 +0000 (18:12 +0200)]
libnvme: accessors for dhchap_key variables

To insulate against changes with the dhchap key handling
in the library itself introduce accessor functions for the
SWIG wrapper.

Signed-off-by: Hannes Reinecke <hare@suse.de>
2 years agomi: Allow Admin-message sized More Processing Required responses
Jeremy Kerr [Fri, 12 Aug 2022 04:44:50 +0000 (12:44 +0800)]
mi: Allow Admin-message sized More Processing Required responses

Devices may implement their MPR response as an actual Admin response
message, rather than the simple MI-only message described in 4.1.2.3 of
NVMe-MI v1.2b.

Allow this, but with some fairly stringent header checks. Add a test for
this behaviour too.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agoMerge pull request #458 from CodeConstruct/mi-mtu-conf
Daniel Wagner [Wed, 17 Aug 2022 06:20:30 +0000 (08:20 +0200)]
Merge pull request #458 from CodeConstruct/mi-mtu-conf

example/mi-conf: Add an example for MI transport configuration

2 years agoexample/mi-conf: Add an example for MI transport configuration
Jeremy Kerr [Thu, 21 Jul 2022 08:21:30 +0000 (16:21 +0800)]
example/mi-conf: Add an example for MI transport configuration

With the Read MI Data Structure and MI Configuration Set functions
available, we can query a device for its maximum MTU, and update the
current MTU to suit.

This also requires telling the local MCTP stack about the new MTU too,
by sending a d-bus message to `mctpd`.

This change adds a little example for this functionality, where we
perform the MI query and configuration, and implements the d-bus
communication for the local stack control.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agoMerge pull request #457 from CodeConstruct/mi+admin
Daniel Wagner [Tue, 16 Aug 2022 06:59:33 +0000 (08:59 +0200)]
Merge pull request #457 from CodeConstruct/mi+admin

MI: expand admin command implementation

2 years agomi: Add Get Log Page helpers
Jeremy Kerr [Wed, 20 Jul 2022 03:54:48 +0000 (11:54 +0800)]
mi: Add Get Log Page helpers

This change adds a few helpers for the Get Log Page command, as the
usual inlines in mi.h. These mirror the ioctl-based definitions.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agomi: Implement Sanitize command
Jeremy Kerr [Wed, 20 Jul 2022 02:29:15 +0000 (10:29 +0800)]
mi: Implement Sanitize command

Add support for the Sanitize command, using the existing
struct nvme_sanitize_nvm_args argument format.

Include a test for the cdw10/cdw11 message encoding.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agomi: Implement Format NVM command
Jeremy Kerr [Tue, 19 Jul 2022 09:47:04 +0000 (17:47 +0800)]
mi: Implement Format NVM command

Add support for the Format NVM command, using the existing
struct nvme_format_nvm_args, plus a small test.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agomi: Implement NS attach command and helpers
Jeremy Kerr [Tue, 19 Jul 2022 08:55:40 +0000 (16:55 +0800)]
mi: Implement NS attach command and helpers

This change adds support for the NVMe Namespace Attach Admin command:

    nvme_mi_admin_ns_attach

plus a couple of helpers for constructing the attach and detach args:

    nvme_mi_admin_ns_attach_ctrls
    nvme_mi_admin_ns_detach_ctrls

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agomi: Implement Namespace Management command and create/delete helpers
Jeremy Kerr [Wed, 8 Jun 2022 08:40:20 +0000 (16:40 +0800)]
mi: Implement Namespace Management command and create/delete helpers

This change adds a function for the base Namespace Management command:

    nvme_mi_admin_ns_mgmt(...)

And helpers for the create and delete actions.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agomi: Add identify helper for nsid-capable Controller List
Jeremy Kerr [Tue, 19 Jul 2022 06:23:13 +0000 (14:23 +0800)]
mi: Add identify helper for nsid-capable Controller List

Add an Identify command helper, similar to the controller list, to query
a controller list for a specific namespace ID.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agomi: Add identify helpers for namespaces
Jeremy Kerr [Thu, 14 Jul 2022 07:18:51 +0000 (15:18 +0800)]
mi: Add identify helpers for namespaces

This change adds Identify command helpers for the active and allocated
namespace, allowing query of a struct nvme_id_ns for each namespace.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agomi: Add identify helpers for namespace lists
Jeremy Kerr [Wed, 8 Jun 2022 07:20:38 +0000 (15:20 +0800)]
mi: Add identify helpers for namespace lists

This change implements the Identify command helper for the active
and allocated namespace lists.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agomi: Implement Get & Set Features Admin commands
Jeremy Kerr [Wed, 8 Jun 2022 04:03:12 +0000 (12:03 +0800)]
mi: Implement Get & Set Features Admin commands

This change adds a new MI Admin functions:

 nvme_mi_admin_get_features()
 nvme_mi_admin_set_features()

And a couple of helpers:

 nvme_mi_admin_get_features_data()
 nvme_mi_admin_get_features_simple()

These using the existing _args definitions, in a similar pattern to the
direct ioctl API.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 years agobuild: Extend release script to support micro version releases
Daniel Wagner [Mon, 1 Aug 2022 15:14:49 +0000 (17:14 +0200)]
build: Extend release script to support micro version releases

In case we need to fix up a a maj.min release extend the release
script to accept x.y.z version strings.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #453 from igaw/add-line-max-define
Daniel Wagner [Thu, 11 Aug 2022 09:06:36 +0000 (11:06 +0200)]
Merge pull request #453 from igaw/add-line-max-define

util: Add LINE_MAX define

2 years agoutil: Add LINE_MAX define
Daniel Wagner [Wed, 3 Aug 2022 11:56:48 +0000 (13:56 +0200)]
util: Add LINE_MAX define

The bionic libc implementation doesn't implement the complete
POSIX API. Apperantly we just need this define to be able
to compile for Android OS. Thus, keep it as simple as possible
and just define it here.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #433 from igaw/build-support-pypi-rc-uploads
Daniel Wagner [Mon, 1 Aug 2022 12:53:51 +0000 (14:53 +0200)]
Merge pull request #433 from igaw/build-support-pypi-rc-uploads

Add support for uploading release candidates to PyPI

2 years agoRegenerate all documentation v1.1
Daniel Wagner [Mon, 1 Aug 2022 12:45:26 +0000 (14:45 +0200)]
Regenerate all documentation

Regenerate documentation for v1.1 release

Signed-off-by: Daniel Wagner <dwagner@suse.de>
2 years agoMerge pull request #450 from hreinecke/json-sync
Daniel Wagner [Mon, 1 Aug 2022 12:08:48 +0000 (14:08 +0200)]
Merge pull request #450 from hreinecke/json-sync

json: fixup dhchap_ctrl_key definitions

2 years agoMerge pull request #449 from tbzatek/errno-fixes-2
Daniel Wagner [Mon, 1 Aug 2022 11:34:05 +0000 (13:34 +0200)]
Merge pull request #449 from tbzatek/errno-fixes-2

fabrics: Fix build_options() return values

2 years agojson: fixup dhchap_ctrl_key definitions
Hannes Reinecke [Fri, 29 Jul 2022 06:14:14 +0000 (08:14 +0200)]
json: fixup dhchap_ctrl_key definitions

The config schema declared a 'dhchap_key' and a 'dhchap_ctrl_key'
value for the port structure, but the json parser implemented a
'dhchap_key' entry for the port (holding the controller key), and
a 'dhchap_key' entry for the host (holding the host key).
Fixup the config schema to declared the correct entries and the
json parser to check for 'dhchap_ctrl_key' instead of 'dhchap_key'.

Signed-off-by: Hannes Reinecke <hare@suse.de>