]> www.infradead.org Git - users/sagi/libnvme.git/log
users/sagi/libnvme.git
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>
3 years agofabrics: Fix build_options() return values
Tomas Bzatek [Thu, 28 Jul 2022 16:41:15 +0000 (18:41 +0200)]
fabrics: Fix build_options() return values

Make the returned error values consistent with the rest of the code.

3 years agoMerge pull request #442 from ismaell/posix
Daniel Wagner [Mon, 25 Jul 2022 17:01:39 +0000 (19:01 +0200)]
Merge pull request #442 from ismaell/posix

Fix poll.h includes

3 years agoMerge pull request #440 from igaw/fix-rae-users
Daniel Wagner [Mon, 25 Jul 2022 16:57:25 +0000 (18:57 +0200)]
Merge pull request #440 from igaw/fix-rae-users

ioctl: Honor rae in nvme_get_nsid_log

3 years agoMerge pull request #443 from martin-gpy/dump_output
Daniel Wagner [Sat, 23 Jul 2022 11:24:50 +0000 (13:24 +0200)]
Merge pull request #443 from martin-gpy/dump_output

fabrics: sanitize dump-config output

3 years agofabrics: sanitize dump-config output
Martin George [Fri, 22 Jul 2022 16:47:43 +0000 (22:17 +0530)]
fabrics: sanitize dump-config output

Trivial fix to sanitize the dump-config output by appending a
new line at the end.

Signed-off-by: Martin George <marting@netapp.com>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoFix poll.h includes
Ismael Luceno [Mon, 18 Jul 2022 16:43:20 +0000 (18:43 +0200)]
Fix poll.h includes

According to POSIX it's <poll.h> since before the Linux era.

Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>
3 years agoMerge pull request #441 from igaw/drop-nostdinc-libressl
Daniel Wagner [Fri, 22 Jul 2022 13:39:50 +0000 (15:39 +0200)]
Merge pull request #441 from igaw/drop-nostdinc-libressl

build: Drop -nostdinc for LibreSSL header checks

3 years agobuild: Drop -nostdinc for LibreSSL header checks
Daniel Wagner [Fri, 22 Jul 2022 13:30:31 +0000 (15:30 +0200)]
build: Drop -nostdinc for LibreSSL header checks

-nostdinc is only necessary when the LibreSSL is not the default SSL
library on the system and OpenSSL header files are present in the
default include paths.

Though if LibreSSL found in standard paths 'pkg-config --cflags' will
include the standard include paths and hence the header files are not
found.

So -nostdinc is only useful for mixed installations which is very
unlikely a very common setup. So let's just drop the -nostdinc and if
the need is to support such setups, we can still try to figure out
how to support this.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoioctl: Honor rae in nvme_get_nsid_log
Daniel Wagner [Fri, 22 Jul 2022 12:29:48 +0000 (14:29 +0200)]
ioctl: Honor rae in nvme_get_nsid_log

The nvme_get_nsid_log() helper has a rae (Retain Asynchronous Events)
parameter, but we currently ignore this when constructing the Get Log
Page command arguments.

This is a behavior change and not an API change. But the good thing is
only for newly build binaries because all helpers are static inline
fuctions.

Reported-by: Reported-by: Jeremy Kerr <jk@codeconstruct.com.au>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #439 from igaw/add-libressl-support
Daniel Wagner [Fri, 22 Jul 2022 12:02:17 +0000 (14:02 +0200)]
Merge pull request #439 from igaw/add-libressl-support

build: Add support to build against LibreSSL

3 years agobuild: Add support to build against LibreSSL
Daniel Wagner [Fri, 22 Jul 2022 11:43:10 +0000 (13:43 +0200)]
build: Add support to build against LibreSSL

LibreSSL ships with the same API but has a different version number
scheme. That is LibreSSL 3.x is not providing the OpenSSL 3.x
APIs. Hence we need to test if the OpenSSL 3 APIs are available if
LibreSSL is present.

Reported-by: Ismael Luceno <ismael@linux.com>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #414 from sc108-lee/rpm
Daniel Wagner [Wed, 20 Jul 2022 12:52:57 +0000 (14:52 +0200)]
Merge pull request #414 from sc108-lee/rpm

rpmbuild: Enable 'make rpm' to build rpm pkgs #408

3 years agoMerge pull request #436 from CodeConstruct/mi-glp
Daniel Wagner [Wed, 20 Jul 2022 12:21:36 +0000 (14:21 +0200)]
Merge pull request #436 from CodeConstruct/mi-glp

mi: unify MI Get Log Page function with ioctl API

3 years agoMerge pull request #435 from martin-belanger/add-missing-attrs-to-python
Daniel Wagner [Wed, 20 Jul 2022 12:12:56 +0000 (14:12 +0200)]
Merge pull request #435 from martin-belanger/add-missing-attrs-to-python

python: add missing ctrl attrs to Python bindings

3 years agorpmbuild: Enable 'make rpm' to build rpm pkgs #408
Steven Seungcheol Lee [Mon, 4 Jul 2022 05:31:46 +0000 (14:31 +0900)]
rpmbuild: Enable 'make rpm' to build rpm pkgs #408

- meson is needed higher version then what rpm repo offering (use pip install)
- Enable building static library (default: shared)
- Add gitignore since make rpm generates tar.gz (when it is failed)
- libuuid-devel dose not needed as rpm pkgs
    it could be installed as some files
    if it's not installed, will be downloaded from subprojects of meson
- gcc does not needed as rpm pkgs
    meson detect compiler with meson.get_compiler('c')

error: Failed build dependencies:
gcc is needed by libnvme-1.0-0.x86_64
libuuid-devel is needed by libnvme-1.0-0.x86_64
Makefile:43: recipe for target 'rpm' failed
make: *** [rpm] Error 1

Signed-off-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
3 years agomi: unify MI Get Log Page function with ioctl API
Jeremy Kerr [Wed, 20 Jul 2022 02:32:18 +0000 (10:32 +0800)]
mi: unify MI Get Log Page function with ioctl API

In the MI interface, we currently have:

  nvme_mi_admin_get_log_page(...)

However, the ioctl-backed API equivalent doesn't use the _page:

  nvme_get_log(...)

This change makes the MI version consistent, where we have the
equivalent names, just with the mi_<type> prefix:

   nvme_mi_admin_get_log(...)

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agopython: add missing ctrl attrs to Python bindings
Martin Belanger [Tue, 19 Jul 2022 17:15:34 +0000 (13:15 -0400)]
python: add missing ctrl attrs to Python bindings

Some controller attributes were missing from the Python bindings.
For example: dctype, cntrltype, etc.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
3 years agobuild: Update version before regenerating docs
Daniel Wagner [Mon, 18 Jul 2022 14:37:29 +0000 (16:37 +0200)]
build: Update version before regenerating docs

The docs contain the version string. Let's set new version before
regenerating the documentation to keep it consistent.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agobuild: Update release version rules
Daniel Wagner [Mon, 18 Jul 2022 14:08:38 +0000 (16:08 +0200)]
build: Update release version rules

Include the release candidate version string into the project
version. This allows to upload every release candidate to PyPI instead
just the final release.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agobuild: Support release candidate version strings
Daniel Wagner [Mon, 18 Jul 2022 14:06:29 +0000 (16:06 +0200)]
build: Support release candidate version strings

The library_version is constructed from the project_version() which
might be a release candidate version. Let's strip away the release
candidate for the library versioning.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoworkflow: Only publish proper releases to PyPI
Daniel Wagner [Mon, 18 Jul 2022 13:26:32 +0000 (15:26 +0200)]
workflow: Only publish proper releases to PyPI

Match the tag name against the release only sematic versioning regex
for the PyPI upload build step.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #432 from CodeConstruct/mi-timeout
Daniel Wagner [Mon, 18 Jul 2022 11:33:32 +0000 (13:33 +0200)]
Merge pull request #432 from CodeConstruct/mi-timeout

MI: add command timeouts

3 years agomi-mctp: Add timeout support to MCTP transport
Jeremy Kerr [Mon, 18 Jul 2022 06:37:21 +0000 (14:37 +0800)]
mi-mctp: Add timeout support to MCTP transport

Now that we have timeout values in the endpoint, implement a per-command
timeout using poll(), and clamp the maximum MPR time.

Add tests to suit.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agomi: Add maximum More Processing Required limit API
Jeremy Kerr [Mon, 18 Jul 2022 06:33:58 +0000 (14:33 +0800)]
mi: Add maximum More Processing Required limit API

This change adds a function to set the maximum time we're prepared to
wait for a response after a More Processing Required message.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agomi: Add endpoint get/set timeout API
Jeremy Kerr [Mon, 18 Jul 2022 05:10:57 +0000 (13:10 +0800)]
mi: Add endpoint get/set timeout API

This change introduces an API for querying and modifying the endpoint
timeout. Transports may provide a function for valiating a new timeout
value before setting.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agoRelease v1.1-rc0 v1.1-rc0
Daniel Wagner [Thu, 14 Jul 2022 12:47:51 +0000 (14:47 +0200)]
Release v1.1-rc0

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoRegenerate all documentation
Daniel Wagner [Thu, 14 Jul 2022 12:47:51 +0000 (14:47 +0200)]
Regenerate all documentation

Regenerate documentation for v1.1-rc0 release

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #428 from igaw/fix-doc-build
Daniel Wagner [Thu, 14 Jul 2022 11:53:39 +0000 (13:53 +0200)]
Merge pull request #428 from igaw/fix-doc-build

Fix doc build

3 years agoMerge pull request #427 from CodeConstruct/docs
Daniel Wagner [Thu, 14 Jul 2022 11:50:26 +0000 (13:50 +0200)]
Merge pull request #427 from CodeConstruct/docs

doc: Use correct variable in configure_file input

3 years agodoc: Use correct variable in configure_file input
Jeremy Kerr [Thu, 14 Jul 2022 10:18:54 +0000 (18:18 +0800)]
doc: Use correct variable in configure_file input

In e33cc17 we removed an inner loop on the result of files(), but didn't
update the local variable to suit.

This change uses the correct iterator variable for the configure_file()
invocation.

Reported-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agobuild: Explicitly check return values when using run_command
Daniel Wagner [Thu, 14 Jul 2022 10:05:00 +0000 (12:05 +0200)]
build: Explicitly check return values when using run_command

meson warns about not providing explicitly the check argument.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #423 from martin-belanger/eflag-3
Daniel Wagner [Tue, 12 Jul 2022 09:40:35 +0000 (11:40 +0200)]
Merge pull request #423 from martin-belanger/eflag-3

python: add __version__ to libnvme python package

3 years agopython: add __version__ to libnvme python package
Martin Belanger [Mon, 11 Jul 2022 12:28:27 +0000 (08:28 -0400)]
python: add __version__ to libnvme python package

It is customary for Python packages to provide a __version__ attribute.

It's not enough just to copy the files to the build directory, we need
also to run the configure step.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
[dwagner: Added information why meson.build has to be changed]
Singed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #424 from igaw/add-release-script
Daniel Wagner [Tue, 12 Jul 2022 09:19:42 +0000 (11:19 +0200)]
Merge pull request #424 from igaw/add-release-script

Add release script

3 years agobuild: Add release automation script
Daniel Wagner [Fri, 8 Jul 2022 14:49:05 +0000 (16:49 +0200)]
build: Add release automation script

Add a script for generating a release.

Note, meson's project version is updated only once, either at the
begin of a RC phase or directly when there was no RC.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #416 from CodeConstruct/kdoc-test
Daniel Wagner [Tue, 12 Jul 2022 07:50:41 +0000 (09:50 +0200)]
Merge pull request #416 from CodeConstruct/kdoc-test

doc: Add a kdoc test for API docs

3 years agobuild: Add workflow to create release from tags
Daniel Wagner [Mon, 11 Jul 2022 12:36:06 +0000 (14:36 +0200)]
build: Add workflow to create release from tags

Let's automate the release process. The trigger to build a release is
the release tag.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #422 from martin-belanger/eflag-2
Daniel Wagner [Mon, 11 Jul 2022 12:43:24 +0000 (14:43 +0200)]
Merge pull request #422 from martin-belanger/eflag-2

python: add eflags to discovery log page

3 years agoMerge pull request #421 from martin-belanger/eflag-1
Daniel Wagner [Mon, 11 Jul 2022 12:41:55 +0000 (14:41 +0200)]
Merge pull request #421 from martin-belanger/eflag-1

fabrics: add NCC to nvmf_disc_eflags

3 years agopython: add eflags to discovery log page
Martin Belanger [Mon, 11 Jul 2022 12:26:27 +0000 (08:26 -0400)]
python: add eflags to discovery log page

Python bindings are extended to report the EFLAGS when a discovery
command is issued. This was previously missing.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
3 years agofabrics: add NCC to nvmf_disc_eflags
Martin Belanger [Mon, 11 Jul 2022 12:19:39 +0000 (08:19 -0400)]
fabrics: add NCC to nvmf_disc_eflags

TP8010 defines an additional EFLAG: No CDC Connectivity (NCC)

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
3 years agodoc: remove github workflow for doc check
Jeremy Kerr [Mon, 11 Jul 2022 10:12:42 +0000 (18:12 +0800)]
doc: remove github workflow for doc check

We now do the doc check as part of the docs test target, no need to
repeat it as a separate workflow.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agodoc: Add a kdoc test for API docs
Jeremy Kerr [Wed, 6 Jul 2022 06:31:41 +0000 (14:31 +0800)]
doc: Add a kdoc test for API docs

Even when we're not building docs, it would be handy to have an easy
check that the kernel-doc comments do not produce warnings or errors.

This change adds a test() defintion to docs/, which calls a simple
script, kernel-doc-check. This script invokes kernel-doc, looking for
error and/or warning output.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agodoc/meson: provide a full-path version of api_files
Jeremy Kerr [Mon, 11 Jul 2022 10:08:47 +0000 (18:08 +0800)]
doc/meson: provide a full-path version of api_files

We currently expand api_files into their full paths when constructing
the manpage build rules. However, we'll want to use this same set of
paths for a future change, so provide an expanded version of the array
globally.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agoMerge pull request #419 from igaw/spell-checking
Daniel Wagner [Fri, 8 Jul 2022 12:12:23 +0000 (14:12 +0200)]
Merge pull request #419 from igaw/spell-checking

Fixing typos and whitespace damage in header files

3 years agonvme: More whitespace cleanup reported by checkpatch
Daniel Wagner [Thu, 7 Jul 2022 16:21:32 +0000 (18:21 +0200)]
nvme: More whitespace cleanup reported by checkpatch

While checkpatch can be very noise, it finds a lot of style
inconsistency. Let's cleanup most of them in the public headers.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agonvme: Whitespace cleanups in header files
Daniel Wagner [Thu, 7 Jul 2022 16:05:47 +0000 (18:05 +0200)]
nvme: Whitespace cleanups in header files

Cleanup whitespace damages with emacs whitespace cleanup tool.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agonvme: Fix typos in header files
Daniel Wagner [Thu, 7 Jul 2022 15:30:39 +0000 (17:30 +0200)]
nvme: Fix typos in header files

A quick run with ispell to fix the obvious typos.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #378 from igaw/fix-nvmf_get_discovery_log
Daniel Wagner [Thu, 7 Jul 2022 09:36:31 +0000 (11:36 +0200)]
Merge pull request #378 from igaw/fix-nvmf_get_discovery_log

fabrics: restructrure nvmf_get_discovery_log

3 years agoMerge pull request #418 from CodeConstruct/mi-retvals
Daniel Wagner [Thu, 7 Jul 2022 09:16:18 +0000 (11:16 +0200)]
Merge pull request #418 from CodeConstruct/mi-retvals

MI:  return value + errno unification

3 years agomi: make return values + errno consistent across error paths
Jeremy Kerr [Thu, 7 Jul 2022 07:06:19 +0000 (15:06 +0800)]
mi: make return values + errno consistent across error paths

This change unifies and documents the error return values for the MI
implementation. This gives us the following semantics:

 - zero on success

 - -1 for errors in the MI communication with an endpoint, with errno
   set accordingly

 - positive values where the MI communication succeeded, but we received
   an error response from the endpoint. The return value will be that
   from the MI response status field, and should correspond to one of
   the nvme_mi_resp_status values.

We add these semantics to the file-level kdoc comments in mi.h.

Most of the changes here are replacing the negative-errno returns:

    return -EIO;

with:

    errno = EIO;
    return -1;

but there are a few slightly-more-involved changes where we need to
preserve errno across a cleanup/log that might clobber it.

For the dbus code in mi-mctp.c, we need to convert the sd_bus convention of
negative-errno values into errno; we can do most of these through the
dbus_err() helper.

Fixes: https://github.com/linux-nvme/libnvme/issues/417
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agomi-mctp: suppress error on scanning endpoints we already have
Jeremy Kerr [Thu, 7 Jul 2022 08:14:38 +0000 (16:14 +0800)]
mi-mctp: suppress error on scanning endpoints we already have

It's not an error to have an endpoint in our list prior to scanning;
just suppress the duplicate and keep going.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agomi: Add extended MI response status values
Jeremy Kerr [Thu, 7 Jul 2022 05:55:34 +0000 (13:55 +0800)]
mi: Add extended MI response status values

We'll want to make further use of the MI status values in an upcoming
change, so add the full set of values from NVMe-MI v1.2b.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agoMerge pull request #415 from CodeConstruct/mi-config
Daniel Wagner [Wed, 6 Jul 2022 10:09:48 +0000 (12:09 +0200)]
Merge pull request #415 from CodeConstruct/mi-config

mi: Add MI configuration commands

3 years agomi: Add examples for MI configuration commands
Jeremy Kerr [Wed, 6 Jul 2022 05:35:22 +0000 (13:35 +0800)]
mi: Add examples for MI configuration commands

Now that we have the MI Get/Set Configuration commands implemented, add
support in examples/mi-mctp to illustrate some basic configuration
interactions.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agomi: Add MI configuration commands
Jeremy Kerr [Tue, 12 Oct 2021 03:13:58 +0000 (11:13 +0800)]
mi: Add MI configuration commands

This change adds an API to send MI Get / Set Configuration commands to
an endpoint, allowing control of endpoint SMBus frequenct, MCTP MTU and
clearing the subsystem health status bits.

We do this with a new couple of functions:

    int nvme_mi_mi_config_get(nvme_mi_ep_t ep, __u32 dw0, __u32 dw1,
                              __u32 *nmresp)

    int nvme_mi_mi_config_set(nvme_mi_ep_t ep, __u32 dw0, __u32 dw1)

The dw0, dw1 and nmresp formats depend on the type of configuration
accessed, which can be a little opaque. Se we add a bunch of helpers
too, to get/set the three configuration params:

    nvme_mi_mi_config_get_smbus_freq(...);
    nvme_mi_mi_config_set_smbus_freq(...);
    nvme_mi_mi_config_get_mctp_mtu(...);
    nvme_mi_mi_config_set_mctp_mtu(...);
    nvme_mi_mi_config_set_health_status_change(...);

[there's no getter for the latter, as this just clears polled bits]

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agomi: Add types for MI Get/Set Configuration data
Jeremy Kerr [Tue, 12 Oct 2021 03:13:58 +0000 (11:13 +0800)]
mi: Add types for MI Get/Set Configuration data

This change adds the mi-specific types for Get/Set configuration
commands: enum nvme_mi_config_id for the currently-defined IDs, and enum
nvme_mi_config_smbus_freq for the possible SMBus frequency configuration
values.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agoMerge pull request #413 from CodeConstruct/not-cascading-style-sheets
Daniel Wagner [Mon, 4 Jul 2022 17:08:21 +0000 (19:08 +0200)]
Merge pull request #413 from CodeConstruct/not-cascading-style-sheets

types: fix typo on nvme_mi_ccs definitions in public API

3 years agotypes: fix typo on nvme_mi_ccs definitions in public API
Jeremy Kerr [Sat, 2 Jul 2022 06:22:16 +0000 (14:22 +0800)]
types: fix typo on nvme_mi_ccs definitions in public API

The NVMe-MI spec defines the Composite Controller Status definitions
using the abbreviation CCS. However, the libnvme code (since initial
commit) has used CSS, not CCS (except for CCS_RDY...).

This change fixes the definitions to use the _CCS_ names, and adds a set
of #defines to allow the old names to be used, including for the enum
itself.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agoMerge pull request #410 from CodeConstruct/mi+mpr
Daniel Wagner [Fri, 1 Jul 2022 09:02:06 +0000 (11:02 +0200)]
Merge pull request #410 from CodeConstruct/mi+mpr

MI: Strict response checking, add support for More Processing Required responses

3 years agomi-mctp: Add support for More Processing Required responses
Jeremy Kerr [Mon, 30 May 2022 07:01:18 +0000 (15:01 +0800)]
mi-mctp: Add support for More Processing Required responses

This change allows the mi-mctp transport to receive "more processing
required" responses from MI commands. When we detect a MPR response, we
keep listening for a subsequent message containing the actual response.

The NVMe-MI spec allows for only one MPR response per request.

To do this, we need to perform explicit tag control for MCTP messaging;
we cannot use the kernel's default tag handling, which would expire the
tag value once we've received the first (MPR) response. Instead, we use
the tag control ioctl()s to allocate tags, and expire once we receive
the final response.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agotest: move test_peer->rx_fn function to transmit path
Jeremy Kerr [Thu, 30 Jun 2022 07:49:12 +0000 (15:49 +0800)]
test: move test_peer->rx_fn function to transmit path

We currently have the peer->rx_fn called after libnvme has sent data to
the NVMe device, as a way for the test to check the sent data and modify
a response accordingly.

However, for testing More Processing Required responses, we will have
two TXes for a single RX. So, move the rx_fn callback to the TX side
(ie, when libnvme calls recvmsg). This allows the test to provide
TX-specific data for each call.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agomi-mctp: better handling for error/unexpected responses
Jeremy Kerr [Wed, 29 Jun 2022 10:14:51 +0000 (18:14 +0800)]
mi-mctp: better handling for error/unexpected responses

Currently, the mi-mctp transport expects there to be at least a complete
header-sized reply - matching the caller's resp->hdr_size value,
otherwise we consider this a transport failure.

However, Admin command responses have a header that's larger than the
generic error response message, so we should be able to handle response
messages that are just the small header and no payload.

This change reworks the response-buffer handling in the MCTP transport.
Rather than storing the payload and MIC into an extra allocated buffer,
we just lay out the response iovec directly into the header, payload and
MIC buffers, and then handle the short-response cases as needed. This
means we can properly extract the error response, rather than just
having the transport report a generic "header too small" failure itself.

This is at high risk for off-by-one errors, so add tests to cover each
of the possible buffer-arrangement cases.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agomi: check response status after each submit()
Jeremy Kerr [Wed, 29 Jun 2022 08:45:38 +0000 (16:45 +0800)]
mi: check response status after each submit()

Add a few checks to the callers of nvme_mi_submit(), to ensure that the
response status is zero before considering the data valid.

In the existing cases, we'd currently fail for response length
mismatches, but we want to be explicit about the check.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agomi: be pedantic with response message format
Jeremy Kerr [Wed, 29 Jun 2022 07:11:24 +0000 (15:11 +0800)]
mi: be pedantic with response message format

This change adds a few tests to check against invalid response data
received by the NVMe-MI device, and some tests to simulate these
conditions.

Because we're checking more of the response fields, we need a bit more
support for constructing default responses in the mi and mi-mctp tests,
so add that too.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agomi: be pedantic with message sizes and offsets
Jeremy Kerr [Wed, 29 Jun 2022 03:11:26 +0000 (11:11 +0800)]
mi: be pedantic with message sizes and offsets

Check that we have enough data for a base header, and that the lengths
are properly aligned, for both request and response messages.

For the raw admin API, ensure we have correct data lengths and offsets.

Add some tests to suit, using the raw admin API

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agoMerge branch 'mi-mctp-test' of https://github.com/CodeConstruct/libnvme
Daniel Wagner [Thu, 30 Jun 2022 11:38:10 +0000 (13:38 +0200)]
Merge branch 'mi-mctp-test' of https://github.com/CodeConstruct/libnvme

Conflicts:
src/nvme/mi-mctp.c

3 years agoMerge pull request #409 from sc108-lee/libsystemd
Daniel Wagner [Thu, 30 Jun 2022 11:03:16 +0000 (13:03 +0200)]
Merge pull request #409 from sc108-lee/libsystemd

meson: libsystemd <= 219 does not support sd-bus, sd-event

3 years agomeson: libsystemd <= 219 does not support sd-bus, sd-event
Steven Seungcheol Lee [Thu, 30 Jun 2022 10:06:46 +0000 (19:06 +0900)]
meson: libsystemd <= 219 does not support sd-bus, sd-event

build error below
./dist-unpack/libnvme-1.0/src/nvme/mi-mctp.c
../dist-unpack/libnvme-1.0/src/nvme/mi-mctp.c:25:10: fatal error: systemd/sd-event.h: No such file or directory
   25 | #include <systemd/sd-event.h>
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
[740/769] Compiling C object src/libnvme.so.1.0.0.p/nvme_tree.c.o

MCTP defined values are used when CONFIG_LIBSYSTEMD is defined

3 years agotest: Add initial tests for mi-mctp layer
Jeremy Kerr [Thu, 16 Jun 2022 06:55:40 +0000 (14:55 +0800)]
test: Add initial tests for mi-mctp layer

This change adds a new test module, for the MCTP transport of the MI
layer.

To do this, we hook into the socket, sendmsg and recvmsg calls from the
core mi-mctp code, allowing the test to provide a mock communication
with the kernel MCTP layer.

On top of this, we write a few simple test cases for the socket error
resonses, which we'll extend in future changes.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agotest: move some common test tools to test/utils.c
Jeremy Kerr [Tue, 28 Jun 2022 06:19:55 +0000 (14:19 +0800)]
test: move some common test tools to test/utils.c

We have a bit of test infrastructure in mi.c that may be helpful for
other tests, so move into a separate file.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agofabrics: don't treat host_traddr 'none' as a valid hostname
Sagi Grimberg [Mon, 27 Jun 2022 08:06:39 +0000 (11:06 +0300)]
fabrics: don't treat host_traddr 'none' as a valid hostname

We treat 'none' as an escape value for optional arguments, do the same
for host_traddr.

This makes prints like the below go away when passing --host-traddr=none:
sh[3244]: failed to resolve host none info

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Link: https://lore.kernel.org/r/20220627080639.108828-1-sagi@grimberg.me