Kenneth Heitke [Thu, 27 Jun 2019 16:56:03 +0000 (10:56 -0600)]
nvme-print: Show value for Transport SGL Data Block Descriptor support
The Transport SGL Data Block Descriptor is a new SGL Descriptor Type added in
NVMe 1.4. Support for this descriptor type is added to the SGL Support (SGLS)
field of the Identify Controller data structure.
Bart Van Assche [Mon, 24 Jun 2019 15:47:27 +0000 (08:47 -0700)]
nvme-cli: Fix more endianness issues
Declare little endian variables as __le*. Use the proper le*_to_cpu()
conversion functions for little endian integers. Do not use le*_to_cpu()
for variables of type uint8_t.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Bart Van Assche [Mon, 24 Jun 2019 13:55:21 +0000 (06:55 -0700)]
nvme-cli: Restore RHEL 7 compatibility
With glibc version 2.24 and before the endianness conversion macros
return a value with an incorrect type. Avoid that this causes the
nvme-cli build to fail on e.g. RHEL 7. A side effect of this patch
is that it allows sparse to verify the type of the endianness
conversion functions.
See also https://sourceware.org/bugzilla/show_bug.cgi?id=16458
Bart Van Assche [Mon, 24 Jun 2019 17:41:37 +0000 (10:41 -0700)]
nvme-cli: Restore support for older gcc versions
Older versions of gcc do not support initializing another than the first
member of a union in an initializer. Rewrite some code such that support
for older gcc versions is restored.
Fixes: 301e263c34e8 ("nvme-cli: Rework the code for getting and setting NVMf properties") Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Minwoo Im [Thu, 23 May 2019 14:33:48 +0000 (23:33 +0900)]
fabrics: Return errno mapped for fabrics error status
If discover has been failed due to a nvme status, it will be returned to
main() with mapped value for fabrics get log page command.
Now connect command related status cannot be added in this patch because
kernel is not currently returning the nvme status, it's instead
returning -EIO if fails. errno for connect command can be added once
kernel is ready to return the proper value for nvme status.
Minwoo Im [Tue, 18 Jun 2019 12:53:38 +0000 (21:53 +0900)]
fabrics: return error when discovery retry exhausted
If the discovery page is not updated to the latest one over the 10
times, it's currently returning DISC_OK if the numrec has no problem.
If so, the caller might think that the discovery has been successfully
done without any errors even there is.
This patch makes it return an error -EAGAIN if retry(10 times) has been
exhausted.
Minwoo Im [Thu, 23 May 2019 14:28:11 +0000 (23:28 +0900)]
nvme: Return errno mapped for nvme error status
If ioctl module has returned a nvme error status, it will be returned
by being converted to a mapped errno value which has been provided by
previous commits.
Cc: Keith Busch <kbusch@kernel.org> Cc: Chaitanya Kulkarni <chaitanya.Kulkarni@wdc.com> Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com> Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Minwoo Im [Tue, 21 May 2019 16:36:57 +0000 (01:36 +0900)]
nvme-status: Introduce nvme status module to map errno
Background:
It's not enough to return the nvme status value in main() because it's
allowed to be in 8bits, but nvme status is indicated in 16bits. So we
has not been able to figure out what kind of nvme status has been
returned by return value.
This patch introduces nvme-status module that manages mapping between
nvme status and errno. It's not possible to make 1:1 mapping relations,
but we can map it as a groups.
All the internal errors which has been returned in a negative value will
be returned with ECOMM that indicates communication errors. In this
case, we can see what happened via stderr.
Cc: Keith Busch <kbusch@kernel.org> Cc: Chaitanya Kulkarni <chaitanya.Kulkarni@wdc.com> Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com> Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Minwoo Im [Thu, 23 May 2019 14:09:09 +0000 (23:09 +0900)]
nvme: Return negative error value for internal errors
To support the mapping of error values which will be introduced in the
next patches, All the internal errors caused in the middle of the
subcommands preparation or teardown should be returned as a negative
value to make it distinguished from nvme error status which is positive.
This patch makes all the internal error values which used to be returned
as a positive value to be returned as a negative value.
Cc: Keith Busch <kbusch@kernel.org> Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com> Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Minwoo Im [Thu, 23 May 2019 14:16:54 +0000 (23:16 +0900)]
fabrics: Do not return in the middle of the subcommand
This patch also makes fabrics module to not return the internal error
status in the middle of the subcommands to support uniformed mapped
error value which will be introduced in the next patches.
Minwoo Im [Thu, 23 May 2019 14:02:48 +0000 (23:02 +0900)]
nvme: Do not return in the middle of the subcommand
To make nvme-cli subcommand return a mapped errno value to main(), it
should return the error status in a single place because it would be
great if the return statements and free operations are in an one shot
place.
This patch makes all the subcommands in nvme module return the error
which means internal error which should be in negative and nvme error
status which is in positive at the end of the subcommand.
Most of the changed parts are file descriptors which is returned from
parse_and_open() function. The "fd" could be in a negative value so
that it needs to be mapped to a uniformed errno value which will be
applied by the next patches.
Cc: Keith Busch <kbusch@kernel.org> Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com> Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Bart Van Assche [Tue, 18 Jun 2019 16:13:52 +0000 (09:13 -0700)]
nvme-cli: Report the NVMe 1.4 NPWG, NPWA, NPDG, NPDA and NOWS fields
From the NVMe 1.4 paragraph about NSFEAT:
"Bit 4 if set to 1: indicates that the fields NPWG, NPWA, NPDG, NPDA, and
NOWS are defined for this namespace and should be used by the host for I/O
optimization; and NOWS defined for this namespace shall adhere to Optimal
Write Size field setting defined in NVM Sets Attributes Entry (refer to
Figure 251) for the NVM Set with which this namespace is associated."
Hence only report these fields if bit 4 in NSFEAT has been set.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Bart Van Assche [Tue, 18 Jun 2019 16:07:27 +0000 (09:07 -0700)]
Introduce NVMe 1.4 Identify Namespace fields in struct nvme_id_ns
Several new fields have been introduced in version 1.4 of the NVMe spec
at offsets that were defined as reserved in version 1.3d of the NVMe
spec. Update the definition of the nvme_id_ns data structure such that
it is in sync with version 1.4 of the NVMe spec. This change preserves
backwards compatibility.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Bart Van Assche [Wed, 19 Jun 2019 17:09:54 +0000 (10:09 -0700)]
nvme-cli: Skip properties that are not supported
Instead of causing the show-regs command to fail if a property is
encountered that is not supported by the target side, do not display
the property. With this patch applied the following output is displayed
for the Linux NVMf target:
$ nvme show-regs /dev/nvme0
cap : f0003ff
version : 10300
cc : 460001
csts : 1
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Bart Van Assche [Wed, 19 Jun 2019 15:07:50 +0000 (08:07 -0700)]
nvme-cli: Rework the code for getting and setting NVMf properties
The current nvme_property() implementation is much harder to read
because it uses an nvme_admin_cmd structure to represent the
nvmf_property_get_command and nvmf_property_set_command data structures.
Verifying the implementation of nvme_property() requires to compare the
offsets of members of nvme_admin_cmd with the offsets of members of
nvmf_property_[gs]et_command. Make the code easier to read by using the
nvmf_property_get_command and nvmf_property_set data structures directly.
This patch fixes the sparse complaints about endianness mismatches in the
nvme_property(), nvme_get_property() and nvme_set_property() functions.
Cc: Eyal Ben David <eyalbe@il.ibm.com> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Bart Van Assche [Tue, 18 Jun 2019 17:15:06 +0000 (10:15 -0700)]
wdc: Fix endianness bugs
Insert le16_to_cpu() / le32_to_cpu() where required.
Cc: Dong Ho <Dong.Ho@wdc.com> Fixes: 6bd8ab436693 ("wdc: Add data area extraction for DUI command"). Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Bart Van Assche [Wed, 19 Jun 2019 15:30:47 +0000 (08:30 -0700)]
lightnvm: Fix an endianness issue
This patch avoids that sparse reports the following:
nvme-lightnvm.c:497:35: warning: incorrect type in initializer (different base types)
nvme-lightnvm.c:497:35: expected unsigned int [usertype] data_len
nvme-lightnvm.c:497:35: got restricted __le32 [usertype]
Cc: Matias Bjorling <m@bjorling.me> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
According to the le64toh() man page, the return type of that function
is uint64_t. Hence drop the cast from (uint64_t)le64_to_cpu(x)
expressions. This patch has been generated as follows:
git ls-tree --name-only -r HEAD |
while read f; do
[ -f "$f" ] && sed -i 's/(uint64_t)le64_to_cpu(/le64_to_cpu(/g' "$f"
done
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
yongxing [Mon, 10 Jun 2019 14:56:33 +0000 (22:56 +0800)]
NVMe-Cli Shannon Plugin-add support for shannon systems.
Hello,current NVMe-Cli tools hasn't supprot for shannon systems, we want to add it.
May we add some specific commands?
We add four NVMe commands for shannon temporarily,smart-log-add, get-feature-add, set-feature-add,
and id-ctrl.
Max Gurtovoy [Thu, 30 May 2019 09:43:23 +0000 (12:43 +0300)]
nvme: update description for "nvme list" command
The "nvme list" command doesn't get any device handle as an input
argument. This operation prints out a basic information for all NVMe
namespaces in the system.
Reviewed-by: Minwoo Im <minwoo.im@samsung.com> Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
Max Gurtovoy [Thu, 30 May 2019 09:43:22 +0000 (12:43 +0300)]
nvme: update list-ns nsid option
This commit updates the optional nsid argument to define the wanted
nsid for start, instead of starting from nsid + 1. E.g. in case we've
wanted to get the list of namespaces starting from 1, before this
commit, we used the "--namespace-id=0" option. Nsid 0 is not valid in
NVMe spec, thus change it to start counting from the given nsid.
Reviewed-by: Minwoo Im <minwoo.im@samsung.com> Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
Minwoo Im [Thu, 16 May 2019 17:23:49 +0000 (10:23 -0700)]
nvme-cli: don't try to disconnect for ctrl with pcie transport
If a host system has both pcie and fabrics controllers, the following
nvme-cli disconnect-all command will might not be working because
contrlller with pcie transport does not have delete_controller in sysfs.
root@target:~# nvme list
Node SN Model Namespace Usage Format FW Rev
---------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- --------
/dev/nvme0n1 foo QEMU NVMe Ctrl 1 536.87 MB / 536.87 MB 512 B + 0 B 1.0
/dev/nvme1n1 b92326b9b2323bf0 Linux 1 134.22 MB / 134.22 MB 512 B + 0 B 5.1.0-rc
/dev/nvme2n1 65fa04eddd9bbac0 Linux 1 134.22 MB / 134.22 MB 512 B + 0 B 5.1.0-rc
root@target:~/nvme-cli.git# nvme disconnect-all
Failed to open /sys/class/nvme/nvme0/delete_controller: No such file or directory
This patch checks the transport type of the controller in iteration.
Keith Busch [Thu, 23 May 2019 21:04:56 +0000 (15:04 -0600)]
Fix sprintf truncate
Buffer was 16k, __builtin___snprintf_chk says it may require 18834. Up
to 20k. Note, we'd usually prefer dynamic buffers for such strings:
asprintf is your friend.
Kenneth Heitke [Fri, 10 May 2019 21:55:57 +0000 (15:55 -0600)]
nvme-print: remove Virtual Management support from ONCS
Revert commit 096fd4d which mistakenly reported Virtual Management
support in the ONCS field of the Identify Controller data structure.
Virtual Management support is part of OACS instead of ONCS and was
already correctly being displayed.
Kenneth Heitke [Wed, 8 May 2019 17:13:29 +0000 (11:13 -0600)]
nvme-print: update self-test log to include 'aborted due to sanitize'
TP 4022 states that when a sanitize operation is started, self-test
operations in progress shall be aborted. The device-self test log page
includes a new result code that indicates if a self-test was aborted due
to a sanitize operation.
Dominique Leuenberger [Wed, 8 May 2019 16:48:02 +0000 (18:48 +0200)]
DOC: Move to DocBook 5 when using asciidoctor
DocBook 5 has been released about a decade ago. Newer versions of
asciidoctor (since version 2.x) no longer support the previously
used DocBook 4.x format, so it is about time for us to switch too.
Minwoo Im [Sun, 5 May 2019 11:58:59 +0000 (20:58 +0900)]
property: Fit print size for a property
We may or may not be able to see the following output in nvme-loop env.
# nvme get-property /dev/nvme0 -o 0x14
property: 0x14 (Controller Configuration), value: 7f7800460001
The register CC is not in 64bit, but the upper bits are showing some values
even it's reserved in spec.
This patch makes this print size to fit to its own size of register.
Minwoo Im [Sun, 5 May 2019 11:52:40 +0000 (20:52 +0900)]
property: Remove unnecessary wrapper function
nvme_get_property_helper() used to be an actual function who is getting the
value of the given property with offset. But, Now we don't have any 'advance'
argument to get back to the caller so that we can remove the helper function by
making it nvme_get_property() which is more intuitive.
Minwoo Im [Sun, 5 May 2019 11:46:39 +0000 (20:46 +0900)]
property: Introduce inline function to check 64bit reg
This patch removes 'advance' argument used in get_property_helper() to tell
the register of the given offset is whether 64bit or not, instead introduce a
inline function to check it simply.
This kind of check might be needed at the print module to figure out if given
register should be printed out in 32bit format or 64bit format.
spec, Makefile: add /etc/nvme files to package files
This way it can automatically be removed upon uninstallation
and we don't need %preun target. Also, this will also allow
to get these files on manual installation from sources.
Also, don't settle on the "file exists" check, use the '-s'
to check that it is not empty as well.
Lastly, in order to have hostnqn and hostid updated upon pkg
install, we have install-spec target that would omit hostnqn and
hostid files, and let the rpm %post do it (otherwise we
use the normal install target).
Reviewed-by: Minwoo Im <minwoo.im.dev@gmail.com> Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Minwoo Im [Thu, 25 Apr 2019 12:40:14 +0000 (21:40 +0900)]
print: Introduce show_nvme_status to print nvme status
We have so many subcommands so that we need to have a function in
common to print out status of nvme command.
The nvme status will be printed out in case the subcommand itself fails
due to a reason. In case of command which is in the middle of the
subcommand, it will be printed as "<cmd> failed" before status.
This patch has nothing to do with functional change.
Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>