Commit Graph

175 Commits

Author SHA1 Message Date
Gordon Bergling
9bca273d84 nvmecontrol(8): Fix a few mandoc related issues and add a SEE ALSO section
- inserting missing end of block: Ss breaks Bl
- skipping paragraph macro: Pp before Ss
- referenced manual not found: Xr nvme 4 (2 times)
- unknown standard specifier: St The

The macro .St can only be used for standards known by mdoc(7). So add a
SEE ALSO section and add a reference to the NVM Express Base Specification.

MFC after:	2 weeks
2020-12-19 11:47:38 +00:00
Stefan Eßer
56d11d4a37 Make use of the getlocalbase() function for run-time adjustment of the
local software base directory, as committed in SVN rev. 367813.

The pkg and mailwrapper programs used the LOCALBASE environment variable
for this purpose and this functionality is preserved by getlocalbase().

After this change, the value of the user.localbase sysctl variable is used
if present (and not overridden in the environment).

The nvmecontrol program gains support of a dynamic path to its plugin
directory with this update.

Differential Revision:	https://reviews.freebsd.org/D27237
2020-11-18 20:00:55 +00:00
Adrian Chadd
44c52406ce [nvmecontrol] Fix type signedness warning-to-error on gcc-6.4
This fixes a type signedness comparison warning-to-error on
gcc-6.4. The ternary operation casts it right but the actual
assignment doesn't.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D26791
2020-11-17 17:12:28 +00:00
Alexander Motin
329327e272 Stop using NVME_MAX_XFER_SIZE constant.
This constant depends on MAXPHYS and does not respect device capabilities.
Use proper dynamic ioctl(NVME_GET_MAX_XFER_SIZE) instead.

MFC after:	1 month
2020-11-17 16:34:58 +00:00
Scott Long
8e1031086d Revert the whole getlocalbase() set of changes while a different design is
hashed out.
2020-11-15 20:24:59 +00:00
Scott Long
1b249101df Fix the previous revision, it suffered from an incomplete change to the
getlocalbase API.  Also don't erroneously subtract the lenth from the
buffer a second time.
2020-11-15 07:50:29 +00:00
Scott Long
7ca0d5403e Replace hardcoded references to _PATH_LOCALBASE with calls to getlocalbase.3
Reviewed by:	imp, se
2020-11-14 18:01:14 +00:00
Alexander Motin
5dc463f9a5 Improve nvmecontrol error reporting.
MFC after:	1 week
Sponsored by:	iXsystems, Inc.
2020-11-13 02:05:45 +00:00
Alexander Motin
8f92938fab Use proper variable for device path.
It seems *-passthru commands were broken from the day one, since the
device path is fetched into opt.dev variable and not left in argv[optind].
The other three wrong argv[optind] instances are just in error messages.

MFC after:	1 week
Sponsored by:	iXsystems, Inc.
2020-10-28 17:28:48 +00:00
Stefan Eßer
1f474190fc Replace literal uses of /usr/local in C sources with _PATH_LOCALBASE
Literal references to /usr/local exist in a large number of files in
the FreeBSD base system. Many are in contributed software, in configuration
files, or in the documentation, but 19 uses have been identified in C
source files or headers outside the contrib and sys/contrib directories.

This commit makes it possible to set _PATH_LOCALBASE in paths.h to use
a different prefix for locally installed software.

In order to avoid changes to openssh source files, LOCALBASE is passed to
the build via Makefiles under src/secure. While _PATH_LOCALBASE could have
been used here, there is precedent in the construction of the path used to
a xauth program which depends on the LOCALBASE value passed on the compiler
command line to select a non-default directory.

This could be changed in a later commit to make the openssh build
consistently use _PATH_LOCALBASE. It is considered out-of-scope for this
commit.

Reviewed by:	imp
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D26942
2020-10-27 11:29:11 +00:00
Alexander Motin
97db031393 Fix nvmecontrol logpage -i parameter.
MFC after:	3 days
2020-10-15 15:36:08 +00:00
Warner Losh
edad03308b Use intmax_t to print uint64_t values.
This fixes the 32-bit build where the types are different.
2020-10-07 07:55:55 +00:00
Warner Losh
c03b1920fb nvmecontrol: Update wdc module for newer WDC NVMe products
Update the to log fetch operation for latest WDC NVMe products.

Tested on HGST SN100 (a few years old) and WDC SN720 (more recent).

Submitted by: Akhilesh Rn <Akhilesh.RN@wdc.com> (minor style tweak by me)
Github PR: 435
2020-10-07 05:36:05 +00:00
David Bright
52664466c7 Whitespace fix after r365948
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2020-09-21 18:34:13 +00:00
David Bright
16969d1448 Honor the FWUG value of some drives in nvmecontrol
nvmecontrol tries to upload firmware in chunks as large as it thinks
the device permits. It fails to take into account the FWUG value used
by some drives to advertise the size and alignment limits for firmware
chunks.

  - Use the firwmare update granularity value from the
  - If the granularity is not reported or not restricted, fall back to
    the previously existing logic that calculates the max transfer
    size based on MDTS.
  - Add firmware update granularity to the identify-controller output.

Reviewed by:	imp (previous version), chuck
Obtained from:	Dell EMC Isilon
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D26390
2020-09-21 15:45:49 +00:00
Alexander Motin
81614d236f Add missing newlines.
MFC after:	3 days
2020-07-23 14:33:25 +00:00
Warner Losh
e2d6a6e938 Document the passthru commands.
Reviewed by: bcr@ (earlier version)
Differential Revision: https://reviews.freebsd.org/D24639
2020-05-01 20:29:51 +00:00
Warner Losh
a41b48ea12 Various improvements to this man page:
o Be consistent about device-id and namespace-id
o Use consistent arg markup for these
o document you can use disk names too
o document nsid command better
o document the idenntify command
o add a couple of examples.

Differential Revision: https://reviews.freebsd.org/D24638
2020-05-01 20:29:46 +00:00
Alexander Motin
5458a1c840 Allow namespace-id specification where it makes sense.
It makes tool more convenient to not require user to explicitly convert
namespace device name into controller device name.  There should be no
changes to already existing syntaxes.

MFC after:	1 week
2020-04-20 14:54:41 +00:00
Alexander Motin
1f15d49eea Open device with O_RDONLY when command is non-invasive.
This allows to use some of the subcommands against mounted nvd devices.

MFC after:	1 week
Sponsored by:	iXystems, Inc.
2020-04-20 13:47:07 +00:00
Li-Wen Hsu
862ac3b74a Ensure kyua list working when there is no /dev/nvme*
Sponsored by:	The FreeBSD Foundation
2020-04-13 21:08:54 +00:00
David Bright
0e3e53d746 Add a basic test for nvmecontrol
I recently made some bug fixes in nvmecontrol. It occurred to me that
since nvmecontrol lacks any kyua tests, I should convert the informal
testing I did into a more formal automated test. The test in this
change should be considered just a starting point; it is neither
complete nor thorough. While converting the test to ATF/kyua, I
discovered a small bug in nvmecontrol; the nvmecontrol devlist command
would always exit with an unsuccessful status. So I included the fix
for that, too, so that the test won't fail.

Reviewed by:	imp@
MFC after:	3 days
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D24269
2020-04-07 20:26:42 +00:00
David Bright
6995fb5eb7 Fix various Coverity-detected errors in nvmecontrol
This fixes several Coverity-detected errors in nvmecontrol. While in
here, a couple additional errors with shift/mask confusion that were
not diagnosed by Coverity are also fixed.

CIDs addressed: 1040299, 1040300, 1403972, 1403973, 1403985, 1403988,
1403990, 1404374, 1404427, 1404469, 1404510, 1404534, 1418118

CID 1403657 (resource leak of shared library handle) was marked
"intentional" in the Coverity scan database.

Reviewed by:	vangyzen, robert.herndon_dell.com
Reviewed by:	daniel.william.ryan_gmail.com (earlier version)
Reviewed by:	rramsden_isilon.com (earlier version), imp
MFC after:	5 days
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D24203
2020-04-02 13:52:54 +00:00
Alexander Motin
83018b7987 Fix host memory buffer sizes reporting.
Hardware reports values in 4KB units, not in bytes.

MFC after:	3 days
2020-01-06 01:51:23 +00:00
Warner Losh
a35a97ae12 Size is unsigned, so remove the test entirely.
The kernel won't crash if you have a bad value and I'd rather not have
nvmecontrol know the internal details about how the nvme driver limits
the transfer size.
2019-09-25 07:51:30 +00:00
Warner Losh
087d0e0b5e After my comnd changes, the number of threads and size weren't set. In
addition, the flags are optional, but were made to be mandatory. Set
these things, as well as santiy check the specified size.

Submitted by: Stefan Rink
PR: 240798
2019-09-25 00:24:57 +00:00
Warner Losh
21fae2d64f Assume all the short args have optional args so allocate space for the
':'. It's slightly wasteful, but much easier (and the savings in bytes
at runtime would be tiny, but the code to do it larger).

Submitted by: Sebastian Huber
2019-09-11 13:34:19 +00:00
Warner Losh
10bb6d358d Report the Host Buffer Memory minimum and preferred sizes.
The Host Buffer feature (NVMe 1.4 section 89) allows for the NVMe card
request the host provide it buffer for lookaside tables and maybe
other things. Report the card's minimum and preferred sizes with
nvmecontrol/camcontrol identify.
2019-09-04 19:19:23 +00:00
Alexander Motin
4035e778f8 Print few more useful identify fields.
MFC after:	2 weeks
2019-08-14 17:36:26 +00:00
Warner Losh
ef7a2ead30 Fix mismerge.
I merged passthru.c from the wrong branch (it was a branch that went further in
a direction I wound up not taking). Fix the mismerge and turn passthru on.
2019-08-06 18:15:26 +00:00
Alexander Motin
217c81f334 Fix alignment issue r350599.
MFC after:	10 days
2019-08-05 19:30:28 +00:00
Alexander Motin
70d20ed34f Add nvmecontrol resv to handle NVMe reservations.
NVMe reservations are quite alike to SCSI persistent reservations and
can be used in clustered setups with shared multiport storage.

MFC after:	10 days
Relnotes:	yes
Sponsored by:	iXsystems, Inc.
2019-08-05 17:36:00 +00:00
Alexander Motin
278ba86cec Add nvmecontrol sanitize command.
It allows to delete all user data from NVM subsystem in one of 3 methods.
It is a close equivalent of SCSI SANITIZE command of `camcontrol sanitize`,
so I tried to keep arguments as close as possible.

While there, fix supported sanitize methods reporting in `identify`.

MFC after:	2 weeks
Relnotes:	yes
Sponsored by:	iXsystems, Inc.
2019-08-03 19:24:56 +00:00
Alexander Motin
ea44065c1f Fix parameter check broken at r350057.
MFC after:	2 weeks
2019-08-03 04:30:22 +00:00
Alexander Motin
6c99d1325e Decode few more NVMe log pages.
In particular: Changed Namespace List, Commands Supported and Effects,
Reservation Notification, Sanitize Status.

Add few new arguments to `nvmecontrol log` subcommand.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2019-08-02 20:16:21 +00:00
Alexander Motin
90dfa8f0ac Add more new fields and values from NVMe 1.4.
MFC after:	2 weeks
2019-08-02 03:43:24 +00:00
Alexander Motin
48ec75f0e7 Rename function added in r350523 to make gcc happy.
MFC after:	2 weeks
2019-08-01 22:22:06 +00:00
Alexander Motin
a7bf63be69 Add IOCTL to translate nvdX into nvmeY and NSID.
While very useful by itself, it also makes `nvmecontrol` not depend on
hardcoded device names parsing, that in its turn makes simple to take
nvdX (and potentially any other) device names as arguments.

Also added IOCTL bypass from nvdX to respective nvmeYnsZ makes them
interchangeable for management purposes.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2019-08-01 21:44:07 +00:00
Alexander Motin
3b3dd3f770 Feature-complete NVMe Namespace Management.
This adds several previously missed but important subcommands to list
namespaces and controllers.  It also fixes few previously added but
just found with real testing to be broken subcommands.

Also while there, add possibility to explicitly specify nsid for
`nvmecontrol identify` subcommand.  It may be useful to specify nsids
not having own devices, for example 0xffffffff, or just newly created
ones.

MFC after:	2 weeks
Relnotes:	yes
Sponsored by:	iXsystems, Inc.
2019-07-31 18:44:20 +00:00
Alexander Motin
e843651ba0 Tune some commands desctiption.
MFC after:	2 weeks
2019-07-31 04:19:53 +00:00
Alexander Motin
628d03169e Fix usage printing for nested subcommands.
Instead of `nvmecontrol create` should be `nvmecontrol ns create`, etc.

MFC after:	2 weeks
2019-07-31 03:48:48 +00:00
Alexander Motin
8de2d8c009 Add some new fields and bits from NVMe 1.4.
MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2019-07-29 03:28:46 +00:00
Warner Losh
160915367c Fix the fix to the logic bug. Upon further testing, the bug is that we shadoow
opt.vendor with vendor. We shouldn't. Delete the latter and use the former
everywhere and restore the prior logic which is now correct.
2019-07-24 23:08:49 +00:00
Warner Losh
ae5f2ca7b9 Fix several related coverity issues:
Make sure to always free shortopts and lopts when returning.
Fix minor logic bug to guard against NULLs properly.

CID: 1403654, 1403656, 1403658
2019-07-24 23:04:26 +00:00
Warner Losh
7d88a2f89e Implement {io,admin}-passthru commands.
These are mostly compatible with Linux, with three exceptions.
1. We don't do metadata segment stuff. Our passthrough interface
   doesn't cope. The code is there, but generates an error.
2. Linux lets you specify a namespace ID for the command. We current
   do not: we get ours from the namespace device, or pass in a generic
   one. Generally, this will lead to the same command, but FreeBSD's
   is safer since you can't specify the wrong id.
3. --show-command outputs to stderr instead of stdout so you can both
   see your command, and capture its output with a simple redirect.

Differential Revision: https://reviews.freebsd.org/D19296
2019-07-16 17:24:25 +00:00
Warner Losh
f634b4c1be Create generic command / arg parsing routines
Create a set of routines and structures to hold the data for the args
for a command. Use them to generate help and to parse args. Convert
all the current commands over to the new format. "comnd" is a hat-tip
to the TOPS-20 %COMND JSYS that (very) loosely inspired much of the
subsequent command line notions in the industry, but this is far
simpler (the %COMND man page is longer than this code) and not in the
kernel... Also, it implements today's de-facto
	command [verb]+ [opts]* [args]*
format rather than the old, archaic TOPS-20 command format :)

This is a snapshot of a work in progress to get the nvme passthru
stuff committed. In time it will become a private library and used
by some other programs in the tree that conform to the above pattern.

Differential Revision: https://reviews.freebsd.org/D19296
2019-07-16 17:24:03 +00:00
Scott Long
8212cecdde Better formatting for the logpage section 2019-05-17 18:15:47 +00:00
Alexander Motin
1aed499575 Decode Deallocate Logical Block Features.
MFC after:	1 week
2019-05-05 15:47:21 +00:00
Warner Losh
e96f6eda1b Add SPDX tag. 2019-02-28 02:29:48 +00:00
Warner Losh
f428a90ad9 Rework logpage extensibility.
Move from using a linker set to a constructor function that's
called. This simplifies the code and is slightly more obvious.  We now
keep a list of page decoders rather than having an array we managed
before. Commands will move to something similar in the future.

Reviewed by: jhb@
Differential Revision: https://reviews.freebsd.org/D19275
2019-02-22 15:15:36 +00:00