]> www.infradead.org Git - users/sagi/libnvme.git/log
users/sagi/libnvme.git
3 years agofabrics: decode new discovery log entry type '3'
Hannes Reinecke [Thu, 12 Aug 2021 11:23:13 +0000 (13:23 +0200)]
fabrics: decode new discovery log entry type '3'

TP8014 adds a new discovery log entry type '3' to describe the
current discovery controller.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agoMerge pull request #107 from igaw/update-json-c-dep
Daniel Wagner [Tue, 16 Nov 2021 22:02:09 +0000 (23:02 +0100)]
Merge pull request #107 from igaw/update-json-c-dep

Update json-c dependency

3 years agoworkflows: Don't install libjson-c-dev
Daniel Wagner [Tue, 16 Nov 2021 21:48:41 +0000 (22:48 +0100)]
workflows: Don't install libjson-c-dev

ubuntu-latest ships an old version of json-c (0.13). Let's use the
version from meson's wrapdb which is bit newer (0.15).

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agobuild: Update json-c dependencies
Daniel Wagner [Tue, 16 Nov 2021 21:47:18 +0000 (22:47 +0100)]
build: Update json-c dependencies

nvme-cli has a minimum dependency to json-c 0.14. Let's update libnvme
accordingly to avoid any confusions.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #94 from igaw/merge-nvme-cli-monolithic
Daniel Wagner [Tue, 16 Nov 2021 15:31:42 +0000 (16:31 +0100)]
Merge pull request #94 from igaw/merge-nvme-cli-monolithic

Merge nvme cli monolithic

3 years agobuild: Adopt libsystemd versioning scheme
Daniel Wagner [Thu, 11 Nov 2021 10:57:16 +0000 (11:57 +0100)]
build: Adopt libsystemd versioning scheme

systemd increases the micro version for every release which is
compatible to what libtool expects. This means we just have to add the
patch level to the version string which happens to be always 0.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agobuild: Remove meson help text from meson.build
Daniel Wagner [Wed, 10 Nov 2021 17:22:21 +0000 (18:22 +0100)]
build: Remove meson help text from meson.build

The generic meson documentation is cluttering the meson.build
file. This is already in README.md file, so let's just remove it
completely.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agotypes: Add missing Zone Attributes Information on zone descriptor
Steven Seungcheol Lee [Fri, 5 Nov 2021 17:42:56 +0000 (18:42 +0100)]
types: Add missing Zone Attributes Information on zone descriptor

NVMe-Zoned-Namespace-Command-Set-Specification-1.1a-2021.07.26-Ratified
Figure 37: Zone Descriptor Data Structure - Zone Attributes Information

Signed-off-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
[dwagner: ported from nvme-cli-monolithic]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agotypes: nvme_id_ns rsvd area modified as lbaf fields
Daniel Wagner [Fri, 5 Nov 2021 17:36:38 +0000 (18:36 +0100)]
types: nvme_id_ns rsvd area modified as lbaf fields

Based spec : NVMe-NVM-Command-Set-Specification-1.0a-2021.07.26-Ratified

[dwagner: ported from nvme-cli-monolithic]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agotypes: add identify endurance group list (cns 0x19) support
Gollu Appalanaidu [Fri, 5 Nov 2021 16:35:24 +0000 (17:35 +0100)]
types: add identify endurance group list (cns 0x19) support

Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
[dwagner: ported from nvme-cli-monolithic]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agotypes: fix(Add missing fields rrl, frl, lbafe)
Steven Seungcheol Lee [Fri, 5 Nov 2021 16:24:18 +0000 (17:24 +0100)]
types: fix(Add missing fields rrl, frl, lbafe)

Based on NVMe-Zoned-Namespace-Command-Set-Specification-1.1a-2021.07.26-Ratified

Signed-off-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
[dwagner: ported from nvme-cli-monolithic]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoioctl: add lockdown command support
Gollu Appalanaidu [Fri, 5 Nov 2021 16:16:59 +0000 (17:16 +0100)]
ioctl: add lockdown command support

Signed-off-by: Karthik Balan karthik.b82@samsung.com
Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
[dwagner: ported from nvme-cli-monolithic]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agotypes: Enable telemetry data area 4 in base
Brandon Paupore [Fri, 5 Nov 2021 13:22:16 +0000 (14:22 +0100)]
types: Enable telemetry data area 4 in base

Signed-off-by: Brandon Paupore <brandon.paupore@wdc.com>
[dwagner: ported from nvme-cli-monolithic]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agotypes: add supported log pages log page (lid = 0x00)
Gollu Appalanaidu [Fri, 5 Nov 2021 13:05:37 +0000 (14:05 +0100)]
types: add supported log pages log page (lid = 0x00)

Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
[dwagner: - ported from nvme-cli-monolithic
          - changed naming scheme to nvme_get_log_supported_log_pages]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoioctl: Add Timeout Parameter for Zone Management Commands
Brandon Paupore [Fri, 5 Nov 2021 09:24:13 +0000 (10:24 +0100)]
ioctl: Add Timeout Parameter for Zone Management Commands

Signed-off-by: Brandon Paupore <brandon.paupore@wdc.com>
[dwagner: ported from nvme-cli-monolithic]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agotypes: add support for fid supported and effects log(lid = 0x12)
Gollu Appalanaidu [Fri, 5 Nov 2021 08:47:11 +0000 (09:47 +0100)]
types: add support for fid supported and effects log(lid = 0x12)

Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
[dwagner: - ported from nvme-cli-monolithic
          - changed naming scheme to nvme_get_log_fid_supported_effects]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoioctl: Fix rae parameter order in __nvme_get_log
Daniel Wagner [Thu, 4 Nov 2021 17:36:32 +0000 (18:36 +0100)]
ioctl: Fix rae parameter order in __nvme_get_log

__nvme_get_log() is a wrapper for nvme_get_log(). Though it got the
position for the rae arguemtn wrong.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agotypes: add boot partition log support
Gollu Appalanaidu [Thu, 4 Nov 2021 17:35:48 +0000 (18:35 +0100)]
types: add boot partition log support

Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
[dwagner: ported from nvme-cli-monolithic]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agotypes: Add Identify for CNS 08h NVMe spec 2.0a based
Steven Seungcheol Lee [Thu, 4 Nov 2021 14:19:38 +0000 (15:19 +0100)]
types: Add Identify for CNS 08h NVMe spec 2.0a based

I/O Command Set Independent Identify Namespace data structure (CNS
08h) Most of data comes from existing data of id-ns which is common
from All I/O command set

Signed-off-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
[dwagner: ported from nvme-cli-monolithic]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agotypes: add spinup control feature (fid=0x1A)
Gollu Appalanaidu [Thu, 4 Nov 2021 13:26:45 +0000 (14:26 +0100)]
types: add spinup control feature (fid=0x1A)

Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
[dwagner: ported from nvme-cli-monolithic]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agotypes: Add New fields on PEL based on NVMe 2.0a
Steven Seungcheol Lee [Thu, 4 Nov 2021 10:16:03 +0000 (11:16 +0100)]
types: Add New fields on PEL based on NVMe 2.0a

Persistent Event Log header got new fields below
[373:372] Generation Number
[377:374] Reporting Context Information (RCI)

Signed-off-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
[dwagner: ported from nvme-cli-monolithic]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agotypes: Add Identify CNS 0x18 Domain List Support
Daniel Wagner [Thu, 4 Nov 2021 09:32:46 +0000 (10:32 +0100)]
types: Add Identify CNS 0x18 Domain List Support

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agotypes: add capacity management command support
Gollu Appalanaidu [Wed, 3 Nov 2021 16:32:37 +0000 (17:32 +0100)]
types: add capacity management command support

Host software issues this Capacity Management command to
configure/Create/Delete Endurance Groups and NVM Sets in an
NVM subsystem.

Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
Signed-off-by: Karthik Balan <karthik.b82@samsung.com>
[dwagner: - ported from nvme-cli-monolithic
          - renamed nvme_cap_mgmt to nmve_capacity_mgmt]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoioctl: add multiple update detected result value in fw commit
Gollu Appalanaidu [Wed, 3 Nov 2021 16:05:19 +0000 (17:05 +0100)]
ioctl: add multiple update detected result value in fw commit

Add Multiple Update Detected (MUD) field in FW Commit command
CQE CDW0 as per NVMe 2.0 Spec.

Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
[dwagner: ported from nvme-cli-monolithic]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoioctl: Change IOCTL for read, write and compare commands
Gollu Appalanaidu [Wed, 3 Nov 2021 14:31:45 +0000 (15:31 +0100)]
ioctl: Change IOCTL for read, write and compare commands

Change the IOCTL and depricate SQE structure for NVM commands
Read, Write and Compare Commands to add support for the Storage
Tag field (CDW2 and CDW3).

Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
[dwagner: ported from nvme-cli-monolithic]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoioctl: add CDW2 and CDW3 support for Write Zeroes and Verify Command
Gollu Appalanaidu [Wed, 3 Nov 2021 13:13:46 +0000 (14:13 +0100)]
ioctl: add CDW2 and CDW3 support for Write Zeroes and Verify Command

Added support for the Variable Sized Expected Logical Block Storage Tag(ELBST)
and Expected Logical Block Reference Tag (ELBRT), CDW2 and CDW3 (00:47) bits
for NVM commands Write Zeroes and Verify commands.

Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
[dwagner: ported from nvme-cli-monolithic]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agonvme: add identify controller structure 2.0 spec. fields
Gollu Appalanaidu [Fri, 11 Jun 2021 21:24:56 +0000 (02:54 +0530)]
nvme: add identify controller structure 2.0 spec. fields

Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
[dwagner: ported from nvme-cli-monolithic]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agotree: fix memory leak in nvme_ctrl_lookup_subsystem_name
Jonathan Teh [Mon, 15 Nov 2021 18:02:00 +0000 (18:02 +0000)]
tree: fix memory leak in nvme_ctrl_lookup_subsystem_name

Ensure all dirents are freed when a successful stat(2) causes an early
break out of the loop.

Reproduced with valgrind running "nvme discover" against an NVMe-oF
target:

==34612== 32 bytes in 1 blocks are definitely lost in loss record 2 of 2
==34612==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==34612==    by 0x4963A4C: __scandir64_tail (scandir-tail-common.c:69)
==34612==    by 0x16E77D: nvme_ctrl_lookup_subsystem_name.isra.0 (tree.c:1024)
==34612==    by 0x170081: nvme_init_ctrl (tree.c:1100)
==34612==    by 0x16DA1F: nvmf_add_ctrl (fabrics.c:558)
==34612==    by 0x136B03: nvmf_discover (fabrics.c:516)
==34612==    by 0x139999: handle_plugin (plugin.c:155)
==34612==    by 0x1131E9: main (nvme.c:5967)

Signed-off-by: Jonathan Teh <jonathan.teh@mayadata.io>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #106 from hreinecke/fixes
Daniel Wagner [Tue, 16 Nov 2021 12:52:59 +0000 (13:52 +0100)]
Merge pull request #106 from hreinecke/fixes

Remove references to nvme_ctrl_get_nqn()

3 years agoMerge pull request #101 from sc108-lee/fix/id_psd
Daniel Wagner [Tue, 16 Nov 2021 12:36:19 +0000 (13:36 +0100)]
Merge pull request #101 from sc108-lee/fix/id_psd

types: fix wrong bits nvme_id_psd apw[178:176], aps[183:182]

3 years agofabrics: use nvme_msg() instead of fprintf()
Hannes Reinecke [Tue, 16 Nov 2021 09:25:49 +0000 (10:25 +0100)]
fabrics: use nvme_msg() instead of fprintf()

Commit d569afca ("fabrics: restore hostname traddr support")
used fprintf() instead of nvme_msg(). Fix it up.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agoRemove references to nvme_ctrl_get_nqn()
Hannes Reinecke [Tue, 16 Nov 2021 09:21:18 +0000 (10:21 +0100)]
Remove references to nvme_ctrl_get_nqn()

Stale reference, function is not implemented.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agoMerge pull request #102 from hreinecke/config
Hannes Reinecke [Tue, 16 Nov 2021 08:22:43 +0000 (09:22 +0100)]
Merge pull request #102 from hreinecke/config

Add json config schema

3 years agoAdd json config schema
Hannes Reinecke [Mon, 15 Nov 2021 14:29:46 +0000 (15:29 +0100)]
Add json config schema

Add a schema file to describe the JSON configuration file format.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Keith Busch <kbusch@kernel.org>
3 years agotypes: fix wrong bits nvme_id_psd apw[178:176], aps[183:182]
Steven Seungcheol Lee [Thu, 28 Oct 2021 03:39:30 +0000 (12:39 +0900)]
types: fix wrong bits nvme_id_psd apw[178:176], aps[183:182]

Signed-off-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
3 years agoMerge pull request #98 from martin-belanger/fix-iface-offset
Daniel Wagner [Thu, 11 Nov 2021 15:22:31 +0000 (16:22 +0100)]
Merge pull request #98 from martin-belanger/fix-iface-offset

Fix host_iface offset.

3 years agoFix host_iface offset.
Martin Belanger [Thu, 11 Nov 2021 15:07:00 +0000 (10:07 -0500)]
Fix host_iface offset.

This was a copy-paste typo.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
3 years agoMerge pull request #93 from tbzatek/docs-updates-4
Daniel Wagner [Mon, 8 Nov 2021 08:32:20 +0000 (09:32 +0100)]
Merge pull request #93 from tbzatek/docs-updates-4

Docs updates + minor fixes

3 years agobuild: Change library version to be a valid number
Tomas Bzatek [Thu, 4 Nov 2021 16:43:02 +0000 (17:43 +0100)]
build: Change library version to be a valid number

pkg-config file version number should be a valid number
to make version comparison actually work.

3 years agotypes: Doc strings update for Sanitize and Format operations
Tomas Bzatek [Thu, 4 Nov 2021 16:34:29 +0000 (17:34 +0100)]
types: Doc strings update for Sanitize and Format operations

3 years agotypes: Fix a typo in the NVME_FORMAT_MSET_EXTENEDED constant
Tomas Bzatek [Thu, 4 Nov 2021 12:01:30 +0000 (13:01 +0100)]
types: Fix a typo in the NVME_FORMAT_MSET_EXTENEDED constant

3 years agoMerge pull request #89 from martin-belanger/rm-duplicate-line
Daniel Wagner [Wed, 3 Nov 2021 12:40:15 +0000 (13:40 +0100)]
Merge pull request #89 from martin-belanger/rm-duplicate-line

Remove a duplicate read() statement

3 years agoFix reading of system UUID on Debian
Martin Belanger [Tue, 2 Nov 2021 19:21:50 +0000 (15:21 -0400)]
Fix reading of system UUID on Debian

The system UUID can be read from the sysfs in two different locations:

1) /sys/class/dmi/id/product_uuid
2) /sys/firmware/dmi/entries

Location 1) is present on all the systems I've tested: SUSE, Red Hat,
Fedora, and Ubuntu. Unfortunately, location 2) does not exist on
Debian-based systems.

Currently, uuid_from_dmi() only reads from location 2), which fails
on Debian.

This patch adds code that reads from location 1) first, and will
only try location 2) if reading from 1) fails.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
[dwagner: Updated return value from -1 to -ENXIO]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoFix python unit tests when run as a subproject of another project (#91)
Martin Belanger [Wed, 3 Nov 2021 09:03:24 +0000 (05:03 -0400)]
Fix python unit tests when run as a subproject of another project (#91)

* Fix python unit tests when run as a subproject of another
project, i.e. nvme-cli.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
3 years agoRemoved a duplicate line (read from file). I checked with
Martin Belanger [Tue, 2 Nov 2021 12:19:52 +0000 (08:19 -0400)]
Removed a duplicate line (read from file). I checked with
Hannes and he confirmed that the line was added by mistake.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
3 years agoMerge pull request #83 from igaw/ccan-build-c-files
Daniel Wagner [Tue, 2 Nov 2021 11:38:03 +0000 (12:38 +0100)]
Merge pull request #83 from igaw/ccan-build-c-files

ccan: Add *.c files to the build

3 years agoMerge pull request #87 from martin-belanger/add-python-testsv2
Daniel Wagner [Thu, 28 Oct 2021 12:30:01 +0000 (14:30 +0200)]
Merge pull request #87 from martin-belanger/add-python-testsv2

Add Python tests to meson framework.

3 years agoAdd Python tests to meson framework.
Martin Belanger [Wed, 27 Oct 2021 12:20:10 +0000 (08:20 -0400)]
Add Python tests to meson framework.

Python has this strict directory layout requirement. A Python package is a
directory that must contain a __init__.py file in addition to containing
modules.

To be able to run Python tests and load modules directly from the build
directory, the Python package (libnvme) and module (nvme.py) must be organized
in the build directory the same way they would be in the install directory. And
the PYTHONPATH must be set to point to the build directory. In other words,
like this:

  .build                <- PYTHONPATH points to here.
   \_ libnvme           <- Package
       \_ nvme.py       <- Module
       \_ __init__.py
       \_ _nvme.cpython-38-x86_64-linux-gnu.so

This patch changes the directory layout so that meson will organize the Python
package and module as shown above. The patch also defines Python tests and sets
the PYTHONPATH to allow importing directly from the build directory.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
3 years agoMerge pull request #86 from birkelund/fix-virt-mgmt
Daniel Wagner [Wed, 27 Oct 2021 09:31:25 +0000 (11:31 +0200)]
Merge pull request #86 from birkelund/fix-virt-mgmt

ioctl: fix mask values for virt mgmt

3 years agoioctl: fix mask values for virt mgmt
Klaus Jensen [Tue, 26 Oct 2021 18:12:36 +0000 (20:12 +0200)]
ioctl: fix mask values for virt mgmt

Fix the the Virtualization Managemtn CDW10 masks for ACT, RT and CNTLID.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
3 years agoMerge pull request #60 from martin-belanger/add-init-method
Daniel Wagner [Mon, 25 Oct 2021 07:46:09 +0000 (09:46 +0200)]
Merge pull request #60 from martin-belanger/add-init-method

[Python]: Add init() method to class nvme_ctrl.

3 years agoAdd Python init() method. Move nvme_init_ctrl() from private.h to tree.h
Martin Belanger [Thu, 21 Oct 2021 12:42:24 +0000 (08:42 -0400)]
Add Python init() method. Move nvme_init_ctrl() from private.h to tree.h
Addess review comments.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
3 years agoccan: Add *.c files to the build
Daniel Wagner [Fri, 22 Oct 2021 07:15:39 +0000 (09:15 +0200)]
ccan: Add *.c files to the build

We are missing the *.c files from the ccan code base in the build.
As we currently don't use any function implemented in the *.c files
all just works.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #81 from igaw/fix-python-lib
Daniel Wagner [Fri, 22 Oct 2021 06:42:50 +0000 (08:42 +0200)]
Merge pull request #81 from igaw/fix-python-lib

libnvme.map: Expose symbols for Python binding

3 years agoMerge pull request #75 from jk-ozlabs/fixes
Daniel Wagner [Fri, 22 Oct 2021 06:42:25 +0000 (08:42 +0200)]
Merge pull request #75 from jk-ozlabs/fixes

Minor header definition fixes

3 years agolibnvme.map: Expose symbols for Python binding
Daniel Wagner [Fri, 22 Oct 2021 06:13:52 +0000 (08:13 +0200)]
libnvme.map: Expose symbols for Python binding

There a few missing symbols for the Python binding. Add them to the
libnvme.map.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #79 from birkelund/meson-install-missing-header
Daniel Wagner [Thu, 21 Oct 2021 10:47:46 +0000 (12:47 +0200)]
Merge pull request #79 from birkelund/meson-install-missing-header

src/meson.build: install missing linux.h

3 years agosrc/meson.build: install missing linux.h
Klaus Jensen [Thu, 21 Oct 2021 10:43:46 +0000 (12:43 +0200)]
src/meson.build: install missing linux.h

src/nvme/linux.h is missing from install_headers.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
3 years agoMerge pull request #77 from jk-ozlabs/ccan-fix
Daniel Wagner [Thu, 21 Oct 2021 08:41:50 +0000 (10:41 +0200)]
Merge pull request #77 from jk-ozlabs/ccan-fix

meson + ccan configuration fixes

3 years agomeson: use correct byteswap macro name
Jeremy Kerr [Thu, 21 Oct 2021 01:44:18 +0000 (09:44 +0800)]
meson: use correct byteswap macro name

We're declaring HAVE_BSWAP64, but ccan expects HAVE_BSWAP_64.

Fixes: bb84156 ("meson.build: Add ccan-required configuration macros")
Reported-by: Klaus Jensen <k.jensen@samsung.com>
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agoconfigure: include ccan config from top-level config.h
Jeremy Kerr [Wed, 20 Oct 2021 13:14:25 +0000 (21:14 +0800)]
configure: include ccan config from top-level config.h

In 3a84d900, we moved the ccan config.h to ccan-config.h, but didn't end
up including it in the top-level config.h.

To complete the simplification, config.h should include the
(configurator-generated) ccan-config.h.

Fixes: 3a84d90084b5 ("configure: simplify config-host.h & config-host.mak generation")
Reported-by: Klaus Jensen <k.jensen@samsung.com>
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agomakefiles: use config.h in examples/ & tests/
Jeremy Kerr [Thu, 21 Oct 2021 08:20:42 +0000 (16:20 +0800)]
makefiles: use config.h in examples/ & tests/

After the recent reverts, we now need to use the proper config.h in
examples/ and tests/ too.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agoRevert "meson: revert to using the ccan configurator"
Jeremy Kerr [Thu, 21 Oct 2021 08:08:01 +0000 (16:08 +0800)]
Revert "meson: revert to using the ccan configurator"

We have a fix queued for the issue that the original revert is
working-around.

This also includes adjustments to the examples/ & tests/ meson
definitions to suit.

This reverts commit b66a139f12357757c54adf7f38031f0f9105c501.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agoRevert "src/Makefile: fix ccan config.h"
Jeremy Kerr [Thu, 21 Oct 2021 08:07:08 +0000 (16:07 +0800)]
Revert "src/Makefile: fix ccan config.h"

This reverts commit 859bd459dee308639eedb490d348d311dc08f859.

We have the proper fixes in progress, no need for the revert-workaround.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agoMerge pull request #78 from igaw/json-c.wrap
Daniel Wagner [Thu, 21 Oct 2021 07:30:11 +0000 (09:30 +0200)]
Merge pull request #78 from igaw/json-c.wrap

build: Add missing json-c.wrap

3 years agoMerge pull request #8 from birkelund/types
Daniel Wagner [Thu, 21 Oct 2021 07:19:38 +0000 (09:19 +0200)]
Merge pull request #8 from birkelund/types

Header cleanup (make nvme/types.h independent of Linux and usable without linking)

3 years agobuild: Add missing json-c.wrap
Daniel Wagner [Thu, 21 Oct 2021 07:16:58 +0000 (09:16 +0200)]
build: Add missing json-c.wrap

Commit 6af90f95fd1b ("build: Add fallback dependency for json-c") is
missing the wrap file.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #73 from martin-belanger/fix-python-dependency
Daniel Wagner [Thu, 21 Oct 2021 07:11:12 +0000 (09:11 +0200)]
Merge pull request #73 from martin-belanger/fix-python-dependency

Make Python Bindings optional

3 years agoMerge pull request #71 from martin-belanger/update-python-examples
Daniel Wagner [Thu, 21 Oct 2021 07:08:05 +0000 (09:08 +0200)]
Merge pull request #71 from martin-belanger/update-python-examples

[Python]: Fix inaccurate Python examples

3 years agoprivate.h: Add required includes
Jeremy Kerr [Wed, 20 Oct 2021 04:21:13 +0000 (12:21 +0800)]
private.h: Add required includes

In private.h, we use the list, nvme_fabrics_config and (optional) UUID
types, so add their appropriate #includes.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agotypes.h: heal -> health
Jeremy Kerr [Wed, 20 Oct 2021 03:59:03 +0000 (11:59 +0800)]
types.h: heal -> health

We currently have an abbreviation 'heal' in nvme_mi_ctrl_heal_status;
while the subsystem health status uses the full 'health'. This change
unifies these by using the full term instead of the abbreviation.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agotypes: remove endian/mmio helpers
Klaus Jensen [Wed, 29 Sep 2021 19:07:41 +0000 (21:07 +0200)]
types: remove endian/mmio helpers

The endian/mmio helpers do not belong in types.h.

Since we are already using ccan and have ccan/endian available, just
include that where needed. The implementation is 100% equivalent, even
with sparse annotations.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
3 years agolinux: move linux specific stuff from util.{c,h}
Klaus Jensen [Wed, 29 Sep 2021 18:20:23 +0000 (20:20 +0200)]
linux: move linux specific stuff from util.{c,h}

Add the nvme/linux.h header for Linux specific helpers. This leaves
util.{c,h} with only system-agnostic utilities.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
3 years agotypes: move the feature shift/masks from util.h
Klaus Jensen [Mon, 18 Oct 2021 18:48:48 +0000 (20:48 +0200)]
types: move the feature shift/masks from util.h

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
3 years agotypes: move command parameters from ioctl.h
Klaus Jensen [Wed, 29 Sep 2021 17:44:55 +0000 (19:44 +0200)]
types: move command parameters from ioctl.h

Move spec-defined command parameters out of nvme/ioctl.h and into
nvme/types.h. This allows third-party libraries and applications to use
the type definitions of libnvme without potentially clashing with
various function prototypes that are ioctl specific.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
3 years agomeson: revert to using the ccan configurator
Klaus Jensen [Tue, 19 Oct 2021 20:13:53 +0000 (22:13 +0200)]
meson: revert to using the ccan configurator

Something fishy is going on with the -include config.h and #include
"config.h" in the ccan sources. If examples/tests use ccan, they end up
with redefinitions caused by the ccan config defines not being properly set.

Revert to generating a ccan-specific config.h using the configurator (like the
Make-based setup).

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
3 years agosrc/Makefile: fix ccan config.h
Klaus Jensen [Tue, 19 Oct 2021 19:34:38 +0000 (21:34 +0200)]
src/Makefile: fix ccan config.h

The ccan/ccan-config.h generated by the ccan configurator is never read
by the ccan sources which expect config.h. Instead, because of -I.. in
src/Makefile, the ccan sources picks up the base config.h (as generated
by configure). All kinds of wrong since config.h should actually have
been config-host.h.

Fix the compiler args to not include the base directory and generate the
ccan config file as ccan/config.h. Rename ./config.h to ./config-host.h.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
3 years ago[Python]: Fix inaccurate Python examples
Martin Belanger [Tue, 19 Oct 2021 12:56:27 +0000 (08:56 -0400)]
[Python]: Fix inaccurate Python examples

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
3 years agoMake Python Bindings optional
Martin Belanger [Tue, 19 Oct 2021 18:34:03 +0000 (14:34 -0400)]
Make Python Bindings optional

Added a new configuration parameter "python". By default it is set to 'auto',
which means that the Python bindings will be built if all dependencies can be
found on the host. If not, Python bindings won;t be built. The option can
also be set to 'true' or 'false' to force Python bindings to be built or not.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
3 years agoMerge pull request #70 from igaw/fallback-json-c
Daniel Wagner [Tue, 19 Oct 2021 08:58:09 +0000 (10:58 +0200)]
Merge pull request #70 from igaw/fallback-json-c

build: Add fallback dependency for json-c

3 years agobuild: Add fallback dependency for json-c
Daniel Wagner [Tue, 19 Oct 2021 08:15:32 +0000 (10:15 +0200)]
build: Add fallback dependency for json-c

meson supports embedded library build. This is very handy for system
which ship outdated an really outdated json-c library.

The include path for json.h has to be adapted. The json-c upstream
project is not clear which include prefix should be used ('#include
<json-c/json.h>" vs '#include <json.h>'. In order to support embedded
builds, we need to use the second version of the include. The source
code is added to the build, hence we use the include directory path of
the project layout. And json-c has all include files in the root
directory. This is no problem when using a installed version of json-c
as pkg-config adds '-I/usr/inlude/json-c' to the include paths:

  $pkg-config --cflags json-c
  -I/usr/include/json-c

So the simplest thing to support both build cased (external/embedded)
just drop the include prefix.

While at it also fix the 'requires' argument which expects strings not
dependencies objects.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #68 from igaw/set-lib-version
Daniel Wagner [Tue, 19 Oct 2021 08:42:11 +0000 (10:42 +0200)]
Merge pull request #68 from igaw/set-lib-version

build: Split libtool versioning from project versioning

3 years agoMerge pull request #69 from birkelund/meson-fixes
Daniel Wagner [Tue, 19 Oct 2021 08:39:59 +0000 (10:39 +0200)]
Merge pull request #69 from birkelund/meson-fixes

meson fixes

Looks good to me. I'll update my PRs for my meson build fixes ontop of ours.

3 years agomeson: use library() and rely on user settings
Klaus Jensen [Mon, 18 Oct 2021 21:00:10 +0000 (23:00 +0200)]
meson: use library() and rely on user settings

There is no need to have both _static and _shared targets. Just use
library(). Project using libnvme as a subproject can now just set

  default_options: ['default_library=static']

in the subproject statement to choose the library version.

For pkgconfig, simplify and let the module figure out Libs and Requires.
This has the effect of removing Requires and making it a
Requires.private so we don't require libnvme consumers to link with
libuuid and json-c (unless they specifically needs to use it like
test/test.c).

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
3 years agoupdate libnvme.map
Klaus Jensen [Mon, 18 Oct 2021 20:59:39 +0000 (22:59 +0200)]
update libnvme.map

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
3 years agoMerge pull request #59 from martin-belanger/reowrk-python-exceptions
Hannes Reinecke [Mon, 18 Oct 2021 13:51:10 +0000 (15:51 +0200)]
Merge pull request #59 from martin-belanger/reowrk-python-exceptions

[Python]: Clean up exception handling

3 years agoMerge pull request #58 from martin-belanger/add-more-to-python
Hannes Reinecke [Mon, 18 Oct 2021 13:49:49 +0000 (15:49 +0200)]
Merge pull request #58 from martin-belanger/add-more-to-python

[Python]: Add set_persistent() and C definitions

3 years agoMerge pull request #67 from igaw/libjson-c-min-version
Daniel Wagner [Mon, 18 Oct 2021 12:26:32 +0000 (14:26 +0200)]
Merge pull request #67 from igaw/libjson-c-min-version

build: Set minimum version for json-c

3 years agobuild: Split libtool versioning from project versioning
Daniel Wagner [Mon, 18 Oct 2021 11:58:53 +0000 (13:58 +0200)]
build: Split libtool versioning from project versioning

As described in GNU autotools manuals, libtool versioning is not the
same as the project versioning.

The project versioning string is defined in project_version. meson
uses this string for all operations such a creating the tarball. I
decided against using something fancy as 'git describe' for it,
because meson is not supporting this kind of dynamic project
versioning.

Instead we just need to increment the version after the release and
before the first commit. With this scheme we basically know by looking
at the version string if it is an official released version. If this
is not good enough we can try to adopt the approach other project are
doing such as systemd which introduced an additional package
versioning which depends on 'git describe'.

There is little point in fighting the tool if it can be done quite
easily by the described approach from above.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #66 from jk-ozlabs/fixes
Daniel Wagner [Mon, 18 Oct 2021 09:39:03 +0000 (11:39 +0200)]
Merge pull request #66 from jk-ozlabs/fixes

log: we use bool, so include stdbool.h

3 years agobuild: Set minimum version for json-c
Daniel Wagner [Mon, 18 Oct 2021 09:24:34 +0000 (11:24 +0200)]
build: Set minimum version for json-c

Set minimum version for json-c to 0.13.

libnvme uses json_util_get_last_err() which got introduced in 0.13,
released in December 2017.

While at it, drop the cc.find_library() lookup logic. First, we don't
do this for libuuid and second, dependency() is using pkg-config to
figure out the dependency, thus we can set the minimum version
number. Instead, cc.find_library() will try to link a test program
with '-libjson-c' and have no way to figure out which version it
actually is. Avoid any confusion and make the meson.build script
simpler.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agolog: we use bool, so include stdbool.h
Jeremy Kerr [Fri, 6 Aug 2021 03:40:47 +0000 (11:40 +0800)]
log: we use bool, so include stdbool.h

The log headers use the bool type, so add an include for stdbool.h,
rather than requiring the includer to do so.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
3 years agoMerge pull request #64 from igaw/meson-subproject
Daniel Wagner [Tue, 12 Oct 2021 15:27:16 +0000 (17:27 +0200)]
Merge pull request #64 from igaw/meson-subproject

build: Allow subproject meson builds

3 years agobuild: Allow subproject meson builds
Daniel Wagner [Tue, 12 Oct 2021 15:18:48 +0000 (17:18 +0200)]
build: Allow subproject meson builds

meson has a very fancy feature called subproject. This allows bundle
third party libraries in a project. In order to be able to use this
for nvme-cli we need to drop all global config settings and declare
all dependencies.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoExpose C enums and #defines in Python module.
Martin Belanger [Mon, 11 Oct 2021 19:50:23 +0000 (15:50 -0400)]
Expose C enums and #defines in Python module.
Add persistent_set() method to the Python nvme_ctrl class.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
3 years agoMerge pull request #63 from igaw/remove-systemd-dep
Hannes Reinecke [Tue, 12 Oct 2021 12:48:13 +0000 (14:48 +0200)]
Merge pull request #63 from igaw/remove-systemd-dep

fabrics: Remove 'UUID derived from machine-id' feature

3 years agofabrics: Remove 'UUID derived from machine-id' feature
Daniel Wagner [Tue, 12 Oct 2021 12:26:57 +0000 (14:26 +0200)]
fabrics: Remove 'UUID derived from machine-id' feature

Commit 3e0520ecad13 ("Read system UUID from DMI and merge hostnqn
generation functions") in nvme-cli introduced the feature to create
the UUID derived from machine-id using the systemd's
sd_id128_get_machine_app_specific function. This adds many library
dependencies to libnvme.

The feature is not really necessary as we have nvme-gen-hostnqn
already in place. So drop the feature entirely.

If the feature needs to be added back, it's probably better to
reimplement this function (e.g. move the hmac_sha256 function from
nvme-cli and use this to derive the UUID from machine-id).

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #56 from igaw/meson-ci
Daniel Wagner [Tue, 12 Oct 2021 09:35:30 +0000 (11:35 +0200)]
Merge pull request #56 from igaw/meson-ci

build: Add meson CI workflow

3 years agoMerge pull request #61 from jk-ozlabs/cross
Daniel Wagner [Tue, 12 Oct 2021 09:34:34 +0000 (11:34 +0200)]
Merge pull request #61 from jk-ozlabs/cross

Support for cross-compiling libnvme

3 years agoMerge pull request #55 from igaw/fix-uuid-read-overflow
Hannes Reinecke [Tue, 12 Oct 2021 09:33:09 +0000 (11:33 +0200)]
Merge pull request #55 from igaw/fix-uuid-read-overflow

fabrics: Do not overflow when reading systemd_uuid