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>
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().
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Francis Pravin [Fri, 12 Jul 2024 06:18:51 +0000 (11:48 +0530)]
nvme: check MD size with PI size when PRACT set to 1
As per NVM Command Set Specification, Rev 1.0d, Sec-5.2.2 PRACT Bit:
"If PRACT bit is set to 1 and Metadata size equals to the Protection
Information size, the protection information is stripped or inserted
by the controller."
Currently NVMe supports 8 and 16 byte size of Protection Information.
So, use pi_size instead of 8 byte.
Signed-off-by: Francis Pravin <francis.p@samsung.com> Reviewed-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
Nitin Sao [Wed, 26 Jun 2024 03:17:42 +0000 (08:47 +0530)]
nvme-print: add new field added in TP4090
As per TP4090, a new field support is added as NPDGL (Namespace
Preferred Deallocate Granularity Large) and so the bit-field of
NSFEAT, OPTPERF get extended by 1 bit.
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>
Martin George [Mon, 8 Jul 2024 16:03:58 +0000 (21:33 +0530)]
nvme: fix verbose logging
The -v verbose option for certain nvme commands like id-ctrl,
id-ns, smart-log, sanitize-log, etc. is practically a no-op since
it only prints latency info in addition to the regular output.
But at the same time, these commands already implement a -H human
readable option which prints additional useful info. So fix the
-v option to make it synonymous with the -H option here. And while
we are at it, move the latency info from current INFO level (i.e.
-v logging) to DEBUG level (i.e. -vv logging) since it is better
suited there.
Daniel Wagner [Mon, 1 Jul 2024 12:46:04 +0000 (14:46 +0200)]
nvme: strip newline when parsing TLS key files
When exporting a TLS keys from the kernel keyring a line might have a
newline. Strip the newline away as the nvme_import_tls_key is not
expecting it and thus fails to load an exported keyfile.
Oliver Upton [Thu, 4 Jul 2024 09:09:40 +0000 (09:09 +0000)]
common.h: Avoid using unsupported load/store instructions in arm64 VMs
Using nvme show-regs within a VM on arm64 can sometimes lead to VM
termination.
To answer why this happens: one of the deficiencies of the Arm
architecture is that there exists a range of load/store instructions
that have insufficient decode information for traps taken to the
hypervisor. KVM, for example, may raise an external abort or outright
terminate the VM depending on the configuration.
This is a known problem on the kernel side, and is fixed by using
assembly MMIO accessors w/ 'safe' load/store instructions. So do
exactly that, providing arm64-specific accessors and falling back to
plain old volatile pointer accesses for other architectures.
Reported-by: William Butler <wab@google.com> Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
This commit will provide the first phase of changes
needed for parsing of OCP 2.5 Telemetry Data Areas
1 and 2. It will decode the prefined classes,
statistics, and events.
Martin George [Sun, 30 Jun 2024 07:39:07 +0000 (13:09 +0530)]
nvme: update parse_args() return value handling
Treat non-zero return values from parse_args() as errors, and not
just negative return values. Also makes this consistent with other
functions in nvme.c where parse_args() is invoked.