]> www.infradead.org Git - users/sagi/nvme-cli.git/log
users/sagi/nvme-cli.git
10 months agoocp: fix to set return value to get c9 log page data
Tokunori Ikegami [Sun, 1 Sep 2024 13:50:43 +0000 (22:50 +0900)]
ocp: fix to set return value to get c9 log page data

The value not set but checked the ret variable after the call.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
10 months agonvme: update nvme_insert_tls_key_versioned() return handling
Martin George [Sun, 1 Sep 2024 11:51:47 +0000 (17:21 +0530)]
nvme: update nvme_insert_tls_key_versioned() return handling

Treat nvme_insert_tls_key_versioned() return value of zero as
errors too.

Signed-off-by: Martin George <marting@netapp.com>
10 months agonvme-print-stdout: add print_array function
Tokunori Ikegami [Sat, 31 Aug 2024 05:54:16 +0000 (14:54 +0900)]
nvme-print-stdout: add print_array function

To reduce the repeated print code for arrays.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
10 months agologging: add print_info function
Tokunori Ikegami [Sat, 31 Aug 2024 06:24:30 +0000 (15:24 +0900)]
logging: add print_info function

This is for debugging print.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
10 months agoutil: extern uint128_t_to_double() function
Tokunori Ikegami [Fri, 30 Aug 2024 18:49:45 +0000 (03:49 +0900)]
util: extern uint128_t_to_double() function

Use the function to calculate with the uint128_t value.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
10 months agonvme-print: sanitize error-log output
Martin George [Thu, 29 Aug 2024 06:01:13 +0000 (11:31 +0530)]
nvme-print: sanitize error-log output

Minor textual and formatting changes to the error-log output.

Signed-off-by: Martin George <marting@netapp.com>
10 months agoplugins/solidigm : Fixing vs-internal-log to generate identify per allocated namespace.
Haro Panosyan [Wed, 21 Aug 2024 23:38:03 +0000 (16:38 -0700)]
plugins/solidigm : Fixing vs-internal-log to generate identify per allocated namespace.

CNS 11h is for namespace data structures for allocated namespaces.
Earlier code was using attached namespaces. This fix is to generate
identify data structures per allocated namespace.

Signed-off-by: Haro Panosyan <haro.panosyan@solidigm.com>
11 months agonvme-print: added new fields for nvm_id_ns
Ankit Soni [Fri, 23 Aug 2024 10:43:46 +0000 (16:13 +0530)]
nvme-print: added new fields for nvm_id_ns

Added new fields from I/O Command Set Specific Identify Namespace
Data Structure CNS5 as per NVM Command Set Specification(Rev 1.1).

Signed-off-by: Ankit Soni <soni.ankit@samsung.com>
Reviewed-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
11 months agobuild: update libnvme wrap
Ankit Soni [Fri, 23 Aug 2024 10:36:33 +0000 (16:06 +0530)]
build: update libnvme wrap

5585f06 - types: added new fields in nvme_nvme_id_ns

Signed-off-by: Ankit Soni <soni.ankit@samsung.com>
11 months agoplugins/fdp: bugfix error check to validate output format
Minsik Jeon [Wed, 21 Aug 2024 10:22:01 +0000 (19:22 +0900)]
plugins/fdp: bugfix error check to validate output format

The return value of validate_output_format functions is whether the
functions fails. So I fix to check the err variable.

Signed-off-by: Minsik Jeon <hmi.jeon@samsung.com>
11 months agoplugins/wdc: fix json output for vs-nand-stats
Carl Moran [Fri, 16 Aug 2024 00:49:46 +0000 (17:49 -0700)]
plugins/wdc: fix json output for vs-nand-stats

Running nvme wdc vs-nand-stats will change the values of the user data fields
depending on output format used. In regular stdout, the ordering is TLC min,
TLC Max, SLC Min, SLC Max. However in json, the values get reassigned, what
was SLC Min in stdout will become TLC >

Regular format (TLC Min, TLC Max, SLC Min, SLC Max)
[root@ /tmp/]# nvme wdc vs-nand-stats /dev/nvme0n1 | grep User\ Data
User Data Erase Counts - TLC Min 169
User Data Erase Counts - TLC Max 310
User Data Erase Counts - SLC Min 10719
User Data Erase Counts - SLC Max 11676

Json format (SLC Min, SLC Max, TLC Min, TLC Max)
[root@ /tmp/]# nvme wdc vs-nand-stats /dev/nvme0n1 -o json | grep User\ Data
"User Data Erase Counts - SLC Min" : 169,
"User Data Erase Counts - SLC Max" : 310,
"User Data Erase Counts - TLC Min" : 10719,
"User Data Erase Counts - TLC Max" : 11676,

The difference can be traced to how the array subscripts are being
used in the two output formats

stdout : https://t.ly/sRIDz

tlc_min == 0
tlc_max == 1
slc_min == 2
slc_max == 3

json : https://t.ly/pmU-m
slc_min = 0
slc_max = 1
tlc_min = 2
tlc_max = 3

With the patch, we rename the fields to be the same for both stdout & json.
Output comparison below

Regular format (TLC Min, TLC Max, SLC Min, SLC Max)
[root@ /tmp/]# ./nvme wdc vs-nand-stats /dev/nvme0n1 | grep User\ Data
User Data Erase Counts - TLC Min 169
User Data Erase Counts - TLC Max 310
User Data Erase Counts - SLC Min 10719
User Data Erase Counts - SLC Max 11676

Json format (TLC Min, TLC Max, SLC Min, SLC Max)
[root@ /tmp/]# ./nvme wdc vs-nand-stats /dev/nvme0n1 -o json | grep User\ Data
"User Data Erase Counts - TLC Min":169,
"User Data Erase Counts - TLC Max":310,
"User Data Erase Counts - SLC Min":10719,
"User Data Erase Counts - SLC Max":11676,

Signed-off-by: Carl Moran<carl.moran1@meta.com>
11 months agonvme-print-stdout: use NVME_FEAT util definitions
Tokunori Ikegami [Mon, 19 Aug 2024 12:13:49 +0000 (21:13 +0900)]
nvme-print-stdout: use NVME_FEAT util definitions

Some NVME_FEAT definitions needed to add for FDP, etc.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
11 months agonvme-print: update subsys verbose outputs
Martin George [Sun, 18 Aug 2024 16:54:18 +0000 (22:24 +0530)]
nvme-print: update subsys verbose outputs

The current list-subsys & show-topology simple outputs are a
little crowded. Also the respective verbose options to both
these commands are a no-op at the moment. So move the iopolicy
and subsystype details to the respective verbose outputs instead
so that the simple outputs are restricted to displaying key subsys
details like subsys name & NQN alone.

Signed-off-by: Martin George <marting@netapp.com>
11 months agonvme-print: add subsystype to the list-subsys output
Martin George [Sun, 18 Aug 2024 16:42:58 +0000 (22:12 +0530)]
nvme-print: add subsystype to the list-subsys output

The nvme list-subsys and show-topology outputs misses out on the
subsystype details. Add the same.

Signed-off-by: Martin George <marting@netapp.com>
11 months agonetapp: print output for single device too
Martin George [Fri, 16 Aug 2024 13:35:13 +0000 (19:05 +0530)]
netapp: print output for single device too

In addition to printing info of all ontap devices on the host,
provide an option to print the output for the specified
device alone.

Signed-off-by: Martin George <marting@netapp.com>
11 months agonetapp: segregate the print routines
Martin George [Fri, 16 Aug 2024 12:42:04 +0000 (18:12 +0530)]
netapp: segregate the print routines

Segregate printing the respective regular/normal and json outputs
into separate routines for better readability.

Signed-off-by: Martin George <marting@netapp.com>
11 months agonetapp: fix uninitialized value from heap error
Martin George [Fri, 16 Aug 2024 11:42:44 +0000 (17:12 +0530)]
netapp: fix uninitialized value from heap error

Valgrind complained about an "uninitialized value created by a
heap allocation" error. Fix the same.

Signed-off-by: Martin George <marting@netapp.com>
11 months agonvme-print: print the new fields added in TP4142
Francis Pravin [Fri, 16 Aug 2024 06:42:36 +0000 (12:12 +0530)]
nvme-print: print the new fields added in TP4142

Print the new fields added in Identify Controller Data Structure.
Also, print the field added in Temperature Threshold feature.

Signed-off-by: Francis Pravin <francis.p@samsung.com>
Reviewed-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
11 months agoplugins/innogrit: modify for project tacoma
innogritkenny [Wed, 14 Aug 2024 04:50:28 +0000 (12:50 +0800)]
plugins/innogrit: modify for project tacoma

modify get-eventlog and remove smart-log-add function

Signed-off-by: innogritkenny <kenny.chu@innogrit.com>
11 months agowdc: Add Support for new SN-861 PCI device id
jeff-lien-wdc [Thu, 8 Aug 2024 19:59:50 +0000 (14:59 -0500)]
wdc: Add Support for new SN-861 PCI device id

A new form factor (EDSFF E3.S) of the SN-861
drive was added to the wdc plugin code.

Signed-off-by: jeff-lien-wdc <jeff.lien@wdc.com>
11 months agonvme-print: use LC_MEASUREMENT to check fahrenheit temperature
Tokunori Ikegami [Sun, 11 Aug 2024 04:29:17 +0000 (13:29 +0900)]
nvme-print: use LC_MEASUREMENT to check fahrenheit temperature

Previously used LC_ALL so not checked correctly if LC_MEASUREMENT set.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
11 months agonvme-print: use Completion Condition enum
Francis Pravin [Fri, 9 Aug 2024 11:42:03 +0000 (17:12 +0530)]
nvme-print: use Completion Condition enum

Use the Completion Condition enum for LBA Status Descriptor.
Also, modified the print statement of Completion Condition.

Signed-off-by: Francis Pravin <francis.p@samsung.com>
11 months agobuild: update libnvme wrap
Francis Pravin [Fri, 9 Aug 2024 10:43:43 +0000 (16:13 +0530)]
build: update libnvme wrap

9bee8e1 - types: add new fields added in TP4142
df12de6 - types: Add enum for Completion Condition of
Get LBA status command

Signed-off-by: Francis Pravin <francis.p@samsung.com>
11 months agocompletions: add the zsh completion of the dapustor plugin
Xiaoyuan Zhang [Thu, 8 Aug 2024 11:31:06 +0000 (19:31 +0800)]
completions: add the zsh completion of the dapustor plugin

add the zsh completion of the dapustor plugin

Signed-off-by: Xiaoyuan Zhang <zhxiaoy2024@gmail.com>
11 months agonvme-print: print the new fields added in TP4165
Francis Pravin [Wed, 7 Aug 2024 12:38:05 +0000 (18:08 +0530)]
nvme-print: print the new fields added in TP4165

Print the new fields added in TP4165.

Signed-off-by: Francis Pravin <francis.p@samsung.com>
Reviewed-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
11 months agoplugins/dapustor: dapustor smart-log-add update
Xiaoyuan Zhang [Wed, 7 Aug 2024 10:24:58 +0000 (18:24 +0800)]
plugins/dapustor: dapustor smart-log-add update

Extended Additional SMART log is optional.
If the collection fails, the command dose not stop.

Add the manual of dapustor plugin.
Update tab completion.

Signed-off-by: Xiaoyuan Zhang <zhxiaoy2024@gmail.com>
11 months agonvme-print-stdout: Added print for new field CSER (TP4167)
Nitin Sao [Tue, 6 Aug 2024 05:45:11 +0000 (11:15 +0530)]
nvme-print-stdout: Added print for new field CSER (TP4167)

As per TP4167, added print for a new field CSER (Command Submission
and Execution Relaxations) [15:14] added in Commands Supported and
Effects Data Structure.

Signed-off-by: Nitin Sao <nitin.sao@samsung.com>
Reviewed-by: Mohit Kapoor <mohit.kap@samsung.com>
11 months agobuild: bump libnvme wrap
Nitin Sao [Tue, 6 Aug 2024 05:40:13 +0000 (11:10 +0530)]
build: bump libnvme wrap

fetch NVME_CMD_EFFECTS_CSER_MASK from enum nvme_cmd_effects

Signed-off-by: Nitin Sao <nitin.sao@samsung.com>
11 months agoplugins: Add a new DapuStor plugin and the smart-log-add command
Xiaoyuan Zhang [Tue, 6 Aug 2024 07:37:09 +0000 (15:37 +0800)]
plugins: Add a new DapuStor plugin and the smart-log-add command

Add the DapuStor plugin to support the retrieval and
display of the Vendor Specific SMART logs:
Additional SMART log page (0xCA)
Extended Additional SMART log page (0xCB)

Signed-off-by: Xiaoyuan Zhang <zhxiaoy2024@gmail.com>
11 months agoRelease v2.10.2
Daniel Wagner [Mon, 5 Aug 2024 13:42:49 +0000 (15:42 +0200)]
Release v2.10.2

Signed-off-by: Daniel Wagner <dwagner@suse.de>
11 months agodoc: Regenerate all docs for v2.10.2
Daniel Wagner [Mon, 5 Aug 2024 13:42:49 +0000 (15:42 +0200)]
doc: Regenerate all docs for v2.10.2

Signed-off-by: Daniel Wagner <dwagner@suse.de>
11 months agobuild: fix libnvme dependency
Daniel Wagner [Mon, 5 Aug 2024 13:41:52 +0000 (15:41 +0200)]
build: fix libnvme dependency

Undo last libnvme dependency update which was done automatically
done by the release script.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
11 months agoRelease v2.10.1
Daniel Wagner [Mon, 5 Aug 2024 13:33:31 +0000 (15:33 +0200)]
Release v2.10.1

Signed-off-by: Daniel Wagner <dwagner@suse.de>
11 months agodoc: Regenerate all docs for v2.10.1
Daniel Wagner [Mon, 5 Aug 2024 13:33:31 +0000 (15:33 +0200)]
doc: Regenerate all docs for v2.10.1

Signed-off-by: Daniel Wagner <dwagner@suse.de>
11 months agobuild: add install step to doc CI build
Daniel Wagner [Fri, 2 Aug 2024 11:08:13 +0000 (13:08 +0200)]
build: add install step to doc CI build

We had some fallouts which were happened at the install step when the
documentation was build. Let's add this step, so we catch those errors
in future.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
11 months agodocs: rename ocp-unsupported-req-log file
Daniel Wagner [Fri, 2 Aug 2024 09:46:49 +0000 (11:46 +0200)]
docs: rename ocp-unsupported-req-log file

The filename has to match the command name, thus rename the filename.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
11 months agoRelease v2.10
Daniel Wagner [Fri, 2 Aug 2024 07:58:11 +0000 (09:58 +0200)]
Release v2.10

Signed-off-by: Daniel Wagner <dwagner@suse.de>
11 months agodoc: Regenerate all docs for v2.10
Daniel Wagner [Fri, 2 Aug 2024 07:58:11 +0000 (09:58 +0200)]
doc: Regenerate all docs for v2.10

Signed-off-by: Daniel Wagner <dwagner@suse.de>
11 months agobuild: bump libnvme wrap
Daniel Wagner [Fri, 2 Aug 2024 07:54:53 +0000 (09:54 +0200)]
build: bump libnvme wrap

Update to libnvme v1.10 release.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
11 months agosed: Fix parsing of Discovery0 features
Milan Broz [Thu, 1 Aug 2024 08:41:50 +0000 (10:41 +0200)]
sed: Fix parsing of Discovery0 features

TCG SED features have variable sizes, so the code needs to use
stored length to move the offset for the next feature.
Otherwise, it checks the code at the wrong offset.

Signed-off-by: Milan Broz <gmazyland@gmail.com>
11 months agofabrics: avoid potential segfault in nvmf_dim()
Martin George [Thu, 1 Aug 2024 19:07:12 +0000 (00:37 +0530)]
fabrics: avoid potential segfault in nvmf_dim()

Eliminate the call to nvme_free_tree() in nvmf_dim() since the
cleanup helper is already available here.

Signed-off-by: Martin George <marting@netapp.com>
11 months agonvme: avoid segfault in show-topology
Martin George [Thu, 1 Aug 2024 19:02:27 +0000 (00:32 +0530)]
nvme: avoid segfault in show-topology

The show-topology command currently ends in a segfault for
ENOENT scenarios:

nvme show-topology
Failed to scan topology: No such file or directory
Segmentation fault (core dumped)

Fix this by eliminating the call to nvme_free_tree() since the
cleanup helper is already available here.

Signed-off-by: Martin George <marting@netapp.com>
11 months agofabrics: do not leak nvme_ctrl_t object on connect
Daniel Wagner [Thu, 1 Aug 2024 13:08:06 +0000 (15:08 +0200)]
fabrics: do not leak nvme_ctrl_t object on connect

valgrinds reports that the nvme_ctrl_t is leaked in the connect command.
Let's introduced a new cleanup helper for this.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
11 months agonvme: extend help message when mmap regs fails
Daniel Wagner [Thu, 1 Aug 2024 11:23:28 +0000 (13:23 +0200)]
nvme: extend help message when mmap regs fails

Newer kernels enable the lockdown feature when secure boot is enabled.
This feature also prevents the register mapping into userspace. Thus it
is not enough to have CONFIG_IO_STRICT_DEVMEM disabled. Extend the
message with the hint also to disable secure boot.

While at it, also lower the reporting level to INFO, so that one single
'-v' is enough to get this information.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
11 months agonvme: return -ENXIO value to open device if errno not set
Tokunori Ikegami [Thu, 18 Jul 2024 15:11:10 +0000 (00:11 +0900)]
nvme: return -ENXIO value to open device if errno not set

The APIs may not set errno so set errno to ENXIO before the device open.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
11 months agowdc: OCP 2.5 Log Page Updates
jeff-lien-wdc [Tue, 16 Jul 2024 20:26:49 +0000 (15:26 -0500)]
wdc: OCP 2.5 Log Page Updates

Add panic count and prev panic id to Error Recovery log page (0xC1)

Add debug telemetry log size to Latency Monitor log page (0xc3)

Signed-off-by: jeff-lien-wdc <jeff.lien@wdc.com>
11 months agofabrics: drop --quiet alias -S
Daniel Wagner [Thu, 11 Jul 2024 17:06:29 +0000 (19:06 +0200)]
fabrics: drop --quiet alias -S

-S has been allocated for the global dhchap secret option. It's likely
that the --quiet option is less used, thus drop the -S alias for it.

Fixes: 0571307d3af0 ("nvme-connect: Add 'dhchap-secret' and 'dhchap-ctrl-secret' arguments")
Signed-off-by: Daniel Wagner <dwagner@suse.de>
11 months agofabrics: drop --disable-sqflow alias -d
Daniel Wagner [Thu, 11 Jul 2024 16:53:36 +0000 (18:53 +0200)]
fabrics: drop --disable-sqflow alias -d

The alias for --disable-sqflow -d clashes with --device for the
discover command. Since the --disable-sqflow is not so commonly used,
let's free -d for other uses.

Fixes: 18de3a6d61a7 ("Convert to libnvme")
Signed-off-by: Daniel Wagner <dwagner@suse.de>
11 months agofabrics: check if json config is existing
Daniel Wagner [Thu, 11 Jul 2024 16:42:23 +0000 (18:42 +0200)]
fabrics: check if json config is existing

nvme_read_config will return success even if the file doesn't exist.
This leads to the situation that we always execute
discover_from_json_config_file even though there is no json config
file.

One side effect of this is that when executing 'nvme discover -d
/dev/nvmeXXX' we will always do a discover for the first controller we
find.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
11 months agoplugins/ocp: fix UAF when printing telemetry log
Vigneshwaran Saravanan/Vigneshwaran Saravanan [Tue, 30 Jul 2024 13:45:52 +0000 (19:15 +0530)]
plugins/ocp: fix UAF when printing telemetry log

Take care the below failures for "telemetry-string-log". Resolved the
Segmentation Fault issue while printing.

Signed-off-by: Vigneshwaran Saravanan/Vigneshwaran Saravanan <s.vignesh@samsung.com>
Reviewed-by: Karthik Balan <karthik.b82@samsung.com>
Reviewed-by: Arunpandian J <arun.j@samsung.com>
11 months agonvme-print-stdout: fix persistent-event-log set feature event output
Xiaoyuan Zhang [Sat, 27 Jul 2024 07:46:30 +0000 (15:46 +0800)]
nvme-print-stdout: fix persistent-event-log set feature event output

Refer to FDP Events Set Feature Data Structure:
the number of FDP Event Types is only Dword11 bits [23:16].
the buffer only contains FDP Event Type.

The value of mem_buf is incorrect:
the pointer 'set_feat_event' should be converted to 'unsigned char *' first

Signed-off-by: Xiaoyuan Zhang <zhxiaoy2024@gmail.com>
11 months agofabrics: do not report error when no modules are loaded when disconnecting
Daniel Wagner [Fri, 26 Jul 2024 12:20:09 +0000 (14:20 +0200)]
fabrics: do not report error when no modules are loaded when disconnecting

Do not report an error when the libnvme reports that the subsystem is
not available when the user tries to disconnect. This allows the user to
call disconnect without filtering this special case. The result is the
same, after this call the host is not connected anymore.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
11 months agofabrics: use cleanup helper where possible
Daniel Wagner [Fri, 26 Jul 2024 12:14:16 +0000 (14:14 +0200)]
fabrics: use cleanup helper where possible

Let's make the error path shorter and simpler by using the cleanup
helpers.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
11 months agofabrics: print an error for ENOENT too
Martin George [Wed, 17 Jul 2024 08:17:51 +0000 (13:47 +0530)]
fabrics: print an error for ENOENT too

Many nvme commands such as discover, connect, connect-all, etc.
simply return to the prompt without printing any useful error
message when the respective nvme driver modules are not loaded in
the kernel. This is because nothing gets printed when
nvme_scan_topology() returns an ENOENT due to missing nvme system
files stemming from not loading the appropriate nvme modules.
Fix the same.

Signed-off-by: Martin George <marting@netapp.com>
12 months agoplugins/virtium: use time_t for time_stamp values
Heitor Alves de Siqueira [Wed, 24 Jul 2024 16:15:35 +0000 (13:15 -0300)]
plugins/virtium: use time_t for time_stamp values

In the vtview_log structs, time_t should be used for any time_stamp
values instead of long. This ensures correct builds on 32-bit
architectures even with 64-bit time_t (e.g. armhf on Ubuntu).

Signed-off-by: Heitor Alves de Siqueira <halves@canonical.com>
12 months agocompletions: add ocp set-error-injection command
Tokunori Ikegami [Sun, 21 Jul 2024 01:16:28 +0000 (10:16 +0900)]
completions: add ocp set-error-injection command

The command injects error conditions.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
12 months agodoc: add ocp set-error-injection command
Tokunori Ikegami [Sun, 21 Jul 2024 00:53:11 +0000 (09:53 +0900)]
doc: add ocp set-error-injection command

The command injects error conditions.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
12 months agoocp: add set-error-injection command
Tokunori Ikegami [Sun, 7 Jul 2024 14:37:43 +0000 (23:37 +0900)]
ocp: add set-error-injection command

The command injects error conditions.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
12 months agonvme: use argconfig_parse_seen to check conditions
zhangxiaoyuan [Fri, 19 Jul 2024 10:23:44 +0000 (18:23 +0800)]
nvme: use argconfig_parse_seen to check conditions

The value of NVME_FEAT_FID_TIMESTAMP cannot be set
to 0 through 'set-feature /dev/nvmeX -f 0xe -v 0'.
using argconfig_parse_seen() can fix this issue.

Signed-off-by: Xiaoyuan Zhang <zhxiaoy@outlook.com>
12 months agonvme: use proper mask to get correct lbafu value
Francis Pravin [Thu, 18 Jul 2024 10:05:44 +0000 (15:35 +0530)]
nvme: use proper mask to get correct lbafu value

The NVME_NS_FLBAS_HIGHER/LOWER_MASK is used to get the format index
value from Formatted LBA Size (FLBAS) field of Identify Namespace
Data Structure. But, We are not getting the proper lbafu value while
using the same macro on user passed format index value.
So, use the proper mask to get the correct lbafu value.

Signed-off-by: Francis Pravin <francis.p@samsung.com>
Reviewed-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
12 months agoutils: fix print formatting option
Daniel Wagner [Wed, 17 Jul 2024 15:39:23 +0000 (17:39 +0200)]
utils: fix print formatting option

A 64bit value to print needs to use the PRIx macros to work on 32bit and
64bit platforms.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
12 months agoutils: cleanup includes in utils.h
Daniel Wagner [Wed, 17 Jul 2024 15:25:18 +0000 (17:25 +0200)]
utils: cleanup includes in utils.h

There a plenty of includes which are not necessary. Remove them.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
12 months agoutils: add missing header
Daniel Wagner [Wed, 17 Jul 2024 15:24:32 +0000 (17:24 +0200)]
utils: add missing header

The build breaks because convert_ts is missing.

Also utils.c depends on json_object_add_value_string, thus define one
when we don't use json-c.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
12 months agonvme-print: Added print for two new fields for HMB feature
Nitin Sao [Tue, 16 Jul 2024 06:28:18 +0000 (11:58 +0530)]
nvme-print: Added print for two new fields for HMB feature

As per TP4104, added print for two new fields for HMB feature
HMNARE (Host Memory Non-operational Access Restriction Enable) and
HMNAR (Host Memory Non-operational Access Restricted) with 1 bit
each. Bit 1 is not used for Get Feature command and will be 0.
And added print for HMBR field in stdout_id_ctrl_ctratt.

Signed-off-by: Nitin Sao <nitin.sao@samsung.com>
Reviewed-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
Reviewed-by: Mohit Kapoor <mohit.kap@samsung.com>
12 months agoplugins/micron: Move OCP internal log parsing from Micron to OCP Plugin.
Chaithanya shoba [Sun, 14 Jul 2024 17:29:11 +0000 (22:59 +0530)]
plugins/micron: Move OCP internal log parsing from Micron to OCP Plugin.

Move OCP internal log parsing from Micron to OCP Plugin. Previous
PR https://github.com/linux-nvme/nvme-cli/pull/2354. Datacenter
NVMe SSD Specification v2.5r9, section 4.9.

Signed-off-by: Chaithanya shoba <ashoba@micron.com>
12 months agofabrics: remove unused _discover_from_json_config_file() argument
Caleb Sander Mateos [Wed, 17 Jul 2024 02:26:05 +0000 (20:26 -0600)]
fabrics: remove unused _discover_from_json_config_file() argument

_discover_from_json_config_file() takes a nvme_subsystem_t argument
but doesn't use it.
Drop the unnecessary argument.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Fixes: b3b9963396c5 ("fabrics: refactore discover from json config")
12 months agonvme: avoid unnecessary dup() + close() in io_mgmt_send()
Caleb Sander Mateos [Wed, 17 Jul 2024 02:04:04 +0000 (20:04 -0600)]
nvme: avoid unnecessary dup() + close() in io_mgmt_send()

_cleanup_fd_ doesn't close STD{IN,OUT,ERR}_FILENO,
so don't bother creating a duplicate fd.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Fixes: 7e1f6799f8cd ("nvme: use cleanup helper to close file descriptor")
12 months agoutil: remove unnecessary NULL check in cleanup_nvme_root()
Caleb Sander Mateos [Tue, 16 Jul 2024 15:59:29 +0000 (09:59 -0600)]
util: remove unnecessary NULL check in cleanup_nvme_root()

cleanup_nvme_root() is checking whether the passed pointer is non-NULL,
but since the pointer is to a local variable, this will always be true.
Therefore, remove the check and always call nvme_free_tree().

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
12 months agonvme: use argconfig_parse_comma_sep_array_u16() in attach-ns
Caleb Sander Mateos [Tue, 16 Jul 2024 21:34:57 +0000 (15:34 -0600)]
nvme: use argconfig_parse_comma_sep_array_u16() in attach-ns

nvme_attach_ns() is using argconfig_parse_comma_sep_array()
to parse a list of ints and then copying them into a list of u16s.

Use argconfig_parse_comma_sep_array_u16() instead to save on memory
and avoid needing to copy the values to another list.
This also checks that the values fit in u16.

Also use NVME_ID_CTRL_LIST_MAX instead of hard-coding the max list size.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
12 months agoutil: avoid duplication in argconfig_parse_comma_sep_array*()
Caleb Sander Mateos [Tue, 16 Jul 2024 21:28:53 +0000 (15:28 -0600)]
util: avoid duplication in argconfig_parse_comma_sep_array*()

Use the loop body to convert the first token to an int.

Extend the existing macro so it can be used to define all the functions.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
12 months agoutil: remove redundant loop condition in argconfig_parse()
Caleb Sander Mateos [Tue, 16 Jul 2024 19:11:34 +0000 (13:11 -0600)]
util: remove redundant loop condition in argconfig_parse()

Since options_count is computed as the number of options
until the first one with a NULL option field,
s->option and option_index < options_count are equivalent.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
12 months agoutil: introduce is_null_or_empty() to avoid strlen()
Caleb Sander Mateos [Tue, 16 Jul 2024 21:43:18 +0000 (15:43 -0600)]
util: introduce is_null_or_empty() to avoid strlen()

argconfig uses strlen() in several places to check for empty strings.
strlen() traverses the entire string though only the first char matters.

Add a helper function is_null_or_empty() that only checks the first char
for NUL. It also encapsulates the NULL check performed by each caller.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
12 months agoutil: reduce allocation sizes in argconfig_parse()
Caleb Sander Mateos [Tue, 16 Jul 2024 19:07:23 +0000 (13:07 -0600)]
util: reduce allocation sizes in argconfig_parse()

long_opts stores up to 1 element per option, plus a help element,
and a zerored final element. So it can be allocated with length
options_count + 2 instead of options_count + 3.
short_opts stores up to 3 characters per option, plus 2 help characters,
and a NUL terminator. So it can be allocated with length
options_count * 3 + 3 instead of options_count * 3 + 5.

Also use the two arguments to calloc() instead of multiplying the sizes.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
12 months agoutil: consolidate call paths to argconfig_parse_type()
Caleb Sander Mateos [Tue, 16 Jul 2024 19:01:36 +0000 (13:01 -0600)]
util: consolidate call paths to argconfig_parse_type()

argconfig_parse_val() already falls back on argconfig_parse_type()
if no option values match.
So always call argconfig_parse_val() from argconfig_parse()
instead of checking whether any option values are defined.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
12 months agoutil: reduce complexity of argconfig_parse_val()
Caleb Sander Mateos [Tue, 16 Jul 2024 16:53:59 +0000 (10:53 -0600)]
util: reduce complexity of argconfig_parse_val()

Assuming constant-length value strings, argconfig_parse_val()'s runtime
is currently quadratic in the number of option values.
For each option value, it computes a minimum prefix length
that distinguishes that option from all others.
It then checks whether the input matches up to that prefix length.

Instead, compare the input directly against each option value.
If exactly one matches, select that option value.
Otherwise, fallback on the default value parser.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
12 months agoutil: reduce arguments passed to argconfig_parse_type()
Caleb Sander Mateos [Tue, 16 Jul 2024 16:35:07 +0000 (10:35 -0600)]
util: reduce arguments passed to argconfig_parse_type()

Arguments option and index are only used to get the name of the option.
This can be obtained from s->option instead.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
12 months agoutil: remove empty default case in argconfig functions
Caleb Sander Mateos [Tue, 16 Jul 2024 16:21:04 +0000 (10:21 -0600)]
util: remove empty default case in argconfig functions

Both argconfig_parse_type() and argconfig_set_opt_val()
switch on the argument value type and have an empty default case.
This is unnecessary and masks errors from unhandled enum values.
So drop the default cases.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
12 months agoutil: remove unnecessary parentheses in argconfig_parse_type()
Caleb Sander Mateos [Tue, 16 Jul 2024 16:17:46 +0000 (10:17 -0600)]
util: remove unnecessary parentheses in argconfig_parse_type()

Match the style in argconfig_set_opt_val().

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
12 months agoutil: remove redundant cast in argconfig_parse_type()
Caleb Sander Mateos [Tue, 16 Jul 2024 16:13:01 +0000 (10:13 -0600)]
util: remove redundant cast in argconfig_parse_type()

s->default_value is already a void *,
so there is no need to cast it to a char * and back.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
12 months agoutil: inline argconfig_parse_byte()
Caleb Sander Mateos [Tue, 16 Jul 2024 16:10:48 +0000 (10:10 -0600)]
util: inline argconfig_parse_byte()

argconfig_parse_byte() is only used in argconfig_parse_type().
For consistency with the other cases, inline it into the function.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
12 months agoutil: remove redundant NULL check in argconfig_print_help()
Caleb Sander Mateos [Tue, 16 Jul 2024 16:05:41 +0000 (10:05 -0600)]
util: remove redundant NULL check in argconfig_print_help()

s has been checked to be non-NULL earlier,
so there is no need to check it in the loop.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
12 months agoutil: use cleanup to avoid goto in argconfig_parse()
Caleb Sander Mateos [Tue, 16 Jul 2024 15:57:38 +0000 (09:57 -0600)]
util: use cleanup to avoid goto in argconfig_parse()

Use _cleanup_free_ in place of explicit calls to free()
in argconfig_parse(). This simplifies the code
and allows using an early return in place of a goto.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
12 months agoutil: make argconfig_set_opt_val() a void function
Caleb Sander Mateos [Tue, 16 Jul 2024 15:49:46 +0000 (09:49 -0600)]
util: make argconfig_set_opt_val() a void function

argconfig_set_opt_val() always returns 0,
so there is no need for its return value.
Return 0 in the one caller, argconfig_set_opt_val(), instead.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
12 months agoutil: remove argconfig_parse_val() declaration
Caleb Sander Mateos [Tue, 16 Jul 2024 15:42:36 +0000 (09:42 -0600)]
util: remove argconfig_parse_val() declaration

argconfig_parse_val() is defined before it is used,
so there is no need to pre-declare it.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
12 months agoutil: remove argconfig CFG_SIZE type
Caleb Sander Mateos [Tue, 16 Jul 2024 18:42:44 +0000 (12:42 -0600)]
util: remove argconfig CFG_SIZE type

CFG_SIZE is unused and not handled by argconfig_set_opt_val().

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
12 months agotest: add test cases for argconfig comma-separated array parsing
Caleb Sander Mateos [Tue, 16 Jul 2024 22:46:04 +0000 (16:46 -0600)]
test: add test cases for argconfig comma-separated array parsing

There are no unit tests currently covering
argconfig's comma-separated integer array parsing.
Add test cases to test-argconfig-parse.c
that use argconfig_parse_comma_sep_array_u32(),
verifying its functionality and edge cases.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
12 months agotest: add test cases for argconfig option values
Caleb Sander Mateos [Tue, 16 Jul 2024 18:38:11 +0000 (12:38 -0600)]
test: add test cases for argconfig option values

test-argconfig-parse.c tests argconfig option parsing,
but is missing test cases for options with opt_val lists.

Add test cases to verify this functionality and its edge cases.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
12 months agowdc: Update and refactor the C0h log page parsing
jeff-lien-wdc [Mon, 8 Jan 2024 15:38:55 +0000 (09:38 -0600)]
wdc: Update and refactor the C0h log page parsing

Add OCP 2.5 fields
Create common functions to get and parse the
different variations of the C0 log page.

Signed-off-by: jeff-lien-wdc <jeff.lien@wdc.com>
12 months agobuild(deps): bump mosteo-actions/docker-run from 1 to 2
dependabot[bot] [Mon, 15 Jul 2024 18:23:37 +0000 (18:23 +0000)]
build(deps): bump mosteo-actions/docker-run from 1 to 2

Bumps [mosteo-actions/docker-run](https://github.com/mosteo-actions/docker-run) from 1 to 2.
- [Release notes](https://github.com/mosteo-actions/docker-run/releases)
- [Commits](https://github.com/mosteo-actions/docker-run/compare/v1...v2)

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

Signed-off-by: dependabot[bot] <support@github.com>
12 months agobuild: use official download action
Daniel Wagner [Fri, 12 Jul 2024 18:38:38 +0000 (20:38 +0200)]
build: use official download action

There is no point in using 3rd party actions for downloading the
artifacts. Let's use the official one.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
12 months agobuild: fetch complete git history
Daniel Wagner [Fri, 12 Jul 2024 12:51:14 +0000 (14:51 +0200)]
build: fetch complete git history

In order to build a image with which contains the correct git version
SHA we need to fetch the complete git tree. Otherwise 'git describe'
fails and we use the project version string as fallback.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
12 months agobuild: show git version used during configuration
Daniel Wagner [Fri, 12 Jul 2024 12:18:12 +0000 (14:18 +0200)]
build: show git version used during configuration

Show which git version is used when configuration phase.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
12 months agobuild: add static build target
Daniel Wagner [Fri, 12 Jul 2024 11:52:54 +0000 (13:52 +0200)]
build: add static build target

Add a static build target.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
12 months agoccan: Add freed pointer checking to delete strset member
Tokunori Ikegami [Fri, 23 Feb 2024 12:07:48 +0000 (21:07 +0900)]
ccan: Add freed pointer checking to delete strset member

Add to set freed entry pointer to NULL then check it if NULL.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
12 months agofabrics: connect all hosts in config.json
Daniel Wagner [Tue, 9 Jul 2024 09:02:48 +0000 (11:02 +0200)]
fabrics: connect all hosts in config.json

Iterate over all hosts defined in the config.json configuration file,
instead just the default controller.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
12 months agofabrics: refactore discover from json config
Daniel Wagner [Fri, 5 Jul 2024 12:35:30 +0000 (14:35 +0200)]
fabrics: refactore discover from json config

Move the connect logic out of the subsystem, ctrl loop. Too much
indention.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
12 months agofabrics: first read config before topology scanning
Daniel Wagner [Thu, 11 Jul 2024 08:49:23 +0000 (10:49 +0200)]
fabrics: first read config before topology scanning

The topology scanning will create nodes in the internal libnvme tree. As
we rely on the order of the nodes in the tree, we need to read the
config before we scan. This makes sure the first node is the one we have
defined in the config.json. This is important because the first node
provides default hosnqn configuration in absents of /etc/nvme/hostnqn.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
12 months agofabrics: use helper to lookup default hostnqn/hostid
Daniel Wagner [Wed, 3 Jul 2024 08:22:18 +0000 (10:22 +0200)]
fabrics: use helper to lookup default hostnqn/hostid

libnvme provides a handy new helper to lookup the hostnqn and hostid.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
12 months agofabrics: extend already connected message
Daniel Wagner [Thu, 11 Jul 2024 11:40:42 +0000 (13:40 +0200)]
fabrics: extend already connected message

The 'already connected' message only contains the traddr as info. Add
the missing information so that it's possible to figure out what
combination is already in use.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
12 months agofabrics: use cleanup helper to free nvme root object
Daniel Wagner [Wed, 3 Jul 2024 09:42:42 +0000 (11:42 +0200)]
fabrics: use cleanup helper to free nvme root object

Simplify the error handling path by using the cleanup helpers.

Signed-off-by: Daniel Wagner <dwagner@suse.de>