Commit Graph

109 Commits

Author SHA1 Message Date
Warner Losh
fbf14fe84b Return after we find the dispatched function.
If the dispatched function doesn't exit, then we get can get a
spurious function not found message. They all do exit, but this is a
little cleaner.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D18403
2018-12-02 23:12:48 +00:00
Warner Losh
e2ed7941e0 Move the hgst/wdc log page printing code into wdc.c
These are all hgst/wdc specific, so move them into the wdc.c to live
with the wdc command.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D18403
2018-12-02 23:12:37 +00:00
Warner Losh
a773b08b88 Move common logpage routines into nvmecontrol.h
For the upcoming move of vendor specific code into vendor specific
files, make the common logpage routines global and move them to
nvmecontrol.h.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D18403
2018-12-02 23:12:26 +00:00
Warner Losh
aecd1901a9 Make logpage functions a linker set.
Move logpage function def to header. Convert all the logpage_function
elements to elements of the linker set. Leave them all in logpage.c
for the moment.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D18403
2018-12-02 23:12:16 +00:00
Warner Losh
a13a291adf Move nvmecontrol to using linker sets for commands
More commands will be added to nvmecontrol. Also, there will be a few
more vendor commands (some of which may need to remain private to
companies writing them). The first step on that journey is to move to
using linker sets to dispatch commands. The next step will be using
dlopen to bring in the .so's that have the command that might need
to remain private for seamless integration.

Similar changes to this will be needed for vendor specific log pages.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D18403
2018-12-02 23:10:55 +00:00
Warner Losh
102cb8b907 Fix typo
The vendor name wds should have been wdc. Add wdc and keep the wds for
script compat.

MFC after: 3 days
2018-10-20 21:13:57 +00:00
Chuck Tuffli
9544e6dcf1 Make NVMe compatible with the original API
The original NVMe API used bit-fields to represent fields in data
structures defined by the specification (e.g. the op-code in the command
data structure). The implementation targeted x86_64 processors and
defined the bit fields for little endian dwords (i.e. 32 bits).

This approach does not work as-is for big endian architectures and was
changed to use a combination of bit shifts and masks to support PowerPC.
Unfortunately, this changed the NVMe API and forces #ifdef's based on
the OS revision level in user space code.

This change reverts to something that looks like the original API, but
it uses bytes instead of bit-fields inside the packed command structure.
As a bonus, this works as-is for both big and little endian CPU
architectures.

Bump __FreeBSD_version to 1200081 due to API change

Reviewed by: imp, kbowling, smh, mav
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D16404
2018-08-22 04:29:24 +00:00
Warner Losh
e505b7eced Make it possible to use print_controller from another program
Rename print_controller to nvme_print_controller. Put it in its
own file for easy inclusion. Move util.c to be nc_util.c to not
conflict with camcontrol. add nvecontrol_ext.h to define shared
interfaces.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D15371
2018-06-13 22:00:02 +00:00
Justin Hibbits
2bac48c266 Print Maximum Data Transfer Size as a long rather than int
PowerPC has PAGE_SIZE as a long, not an int.  This causes the compiler to throw
a format mismatch warning on this print.  To work around the difference, print
it as a long instead of an int, and force the argument to a long.

Reviewed By: imp
Differential Revision: https://reviews.freebsd.org/D15653
2018-06-07 04:02:09 +00:00
Alexander Motin
ba405bc811 Add NVMe Namespace Management support to nvmecontrol(8).
This allows create/delete/attach/detach namespaces on new NVMe controllers.
This is only a first user-level part of the bigger change set.  Kernel part
required to detect and handle the configuration changes without reboot is
completely independent and will be added separately.

Submitted by:	Matt Williams <mffbsdw@gmail.com> (original version)
Differential Revision:	https://reviews.freebsd.org/D11399
2018-05-05 20:08:03 +00:00
Alexander Motin
011bbaa513 Add some argument checks to be more user-friendly.
MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2018-03-13 15:29:13 +00:00
Alexander Motin
635c517ae9 Add nvmecontrol format subcommand.
It allows to change namespace parameters, such as block size, metadata,
protection information, etc. and/or erase the data.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2018-03-13 03:02:09 +00:00
Alexander Motin
01c1be35e0 Print fuses and fna fields in identify data.
MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2018-03-12 16:31:25 +00:00
Alexander Motin
3fa5467a06 Add new identify data structures fields from NVMe 1.3a.
Some of them are already supported by existing hardware, so reporting
them `nvmecontrol identify` can be useful.
2018-03-11 05:09:02 +00:00
Alan Somers
deeec7728b nvmecontrol: fix build on amd64/clang
Broken by:	329824
Sponsored by:	Spectra Logic Corp
2018-02-22 17:47:16 +00:00
Wojciech Macek
0d787e9b35 NVMe: Add big-endian support
Remove bitfields from defined structures as they are not portable.
Instead use shift and mask macros in the driver and nvmecontrol application.

NVMe is now working on powerpc64 host.

Submitted by:          Michal Stanek <mst@semihalf.com>
Obtained from:         Semihalf
Reviewed by:           imp, wma
Sponsored by:          IBM, QCM Technologies
Differential revision: https://reviews.freebsd.org/D13916
2018-02-22 13:32:31 +00:00
Pedro F. Giffuni
1de7b4b805 various: general adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.
2017-11-27 15:37:16 +00:00
Bryan Drewery
ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Warner Losh
24e99dabf7 Report only the valid slots in the firmware log page.
Printing the entire log page is causing confusion over available
slots. Report only those slots that are valid. In the case where the
firmware download isn't supported, assume that only the first slot is
valid (I have no hardware to test this assumption though)

Sponsored by: Netflix
2017-10-25 15:26:03 +00:00
Warner Losh
8ce85adf7d Add nvme_controller_data argument to all print functions.
It's desirable to access controler data to inform printing log pages
(such as limiting the printing to valid ranges).

Sponsored by: Netflix
2017-10-25 15:25:55 +00:00
Warner Losh
781fe538ae Print the controller's ID in identify.
Submitted by: Matt Williams
Sponsored by: Netflix
2017-08-28 23:54:08 +00:00
Warner Losh
4d81e14528 Fix sign of resid and add a mostly useless cast to cope with signed vs
unsigned check warnings from traditional unix code construsts bogusly
flagged as potentially unsafe.
2017-07-01 02:19:48 +00:00
Warner Losh
440f35093c Improve wdc error log pulling.
After review by the WDC engineers, improve how we pull down the
so-called 'e6' logs. The 'c6' logs are obsolete and support for them
has been removed because FreeBSD needed to pull them in chunks, which
is incompatible with the 0xc6 opcode implementation. Rather than leave
the code in place that produces bad log pulls, remove it.
2017-06-29 23:15:28 +00:00
Warner Losh
bbd508cae9 Report some aspects of namespaces and namespace support in identify
command.

Sponsored by: Netflix
Submitted by: Matt Williams (via D11330)
2017-06-27 20:24:44 +00:00
Warner Losh
970d454f63 Move 128-bit integer routines to util.c so they can be used by more
than just the log page code.

Sponsored by: Netflix, Inc
Submitted by: Matt Williams (via D11330)
2017-06-27 20:24:25 +00:00
Enji Cooper
4914b39f09 Don't use K&R style prototypes; ANSIfy them
This fixes several -Wold-style-definition warnings.

X-MFC with:	313191
Reported by:	amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc)
Sponsored by:	Dell EMC Isilon
2017-03-28 20:34:02 +00:00
Enji Cooper
22289a8c3d sbin: normalize paths using SRCTOP-relative paths or :H when possible
This simplifies make logic/output

MFC after:	1 month
Sponsored by:	Dell EMC Isilon
2017-03-04 11:33:01 +00:00
Warner Losh
d8fab838af Make nvmecontrol logpage -p help list known pages.
Make -p help and -v help list all the pages we know about.
Add -v to usage.
Update the man page.

Sponsored by: Netflix
2017-02-25 00:09:16 +00:00
Warner Losh
e71bab696f Exit with usage if argv[1] is NULL in dispatch. This fixes core dumps
when a command has subcommands, but the user doesn't give the
parameters on the command line.

Sponsored by: Netflix
2017-02-25 00:09:12 +00:00
Warner Losh
56e101b337 Fix typos in output.
Sponsored by: Netflix
2017-02-25 00:09:02 +00:00
Warner Losh
1b44f31b19 Use ssize_t instead of uint32_t to prevent warnings about a comparison
with different signs. Due to the promotion rules, this would only
happen on 32-bit platforms.
2017-02-05 01:20:39 +00:00
Warner Losh
ba6da68645 Add the ability to dump log pages directly in binary to stdout.
Update man page to include this flag, and an example of dumping a
vendor-specific page while I'm here.
2017-02-05 00:55:07 +00:00
Warner Losh
033ccbc91f Add some descriptions to the man page for the supported log pages as
well as the new wdc commands. Make wdc be an alias for hgst when
specifying the vendor to use to interpret the page.
2017-02-05 00:45:02 +00:00
Warner Losh
0fe4a5189c Fix off by one error that truncated the serial number for filenames. 2017-02-04 20:43:54 +00:00
Warner Losh
dd8374eb70 Fix a typo in usage string for unimplemented command. 2017-02-04 20:43:45 +00:00
Warner Losh
ffce99f502 Implement 5 wdc-specific nvme control options for their HGST drives:
wdc cap-diag		Capture diagnostic data from drive
	wdc drive-log		Capture drive history data from drive
	wdc get-crash-dump	Retrieve firmware crash dump from drive
2017-02-04 05:53:00 +00:00
Warner Losh
ccac2ba7ec Move the usage and command name lookup into functions. 2017-02-04 05:52:53 +00:00
Warner Losh
3f13e7a8a2 Put the arguments to aligned_alloc in the right order. 2017-02-04 05:52:50 +00:00
Warner Losh
dc935c4f19 Use aligned buffer for the firmware data. Otherwise, when loading a
MAXPHYS bytes of data, the I/O would require MAXPHYS + PAGE_SIZE worth
of pages to do the I/O and we'd hit an assertion in
vm_fault_quick_hold_pages unless MAXPHYS was larger than 1M +
PAGE_SIZE.
2017-02-02 23:04:00 +00:00
Warner Losh
40975988cb Implement Intel's log page 0xc1 (Read Command Latency Log) and page
0xc1 (Write Command Latency Log).

Sponsored By: Netflix, Inc
2016-12-09 23:37:14 +00:00
Warner Losh
f1b276bec8 Fix Typo 2016-12-07 21:47:14 +00:00
Warner Losh
5619c99fb3 Flag the vendor specific pages as such. This allows different decoding
for the same page number as different vendors encode vendor specific
pages differently.
2016-12-02 14:44:45 +00:00
Warner Losh
4e44c386ff i386 turns out to not have __uint128_t. So confusingly use 64-bit math
instead. Since we're little endian, we can get away with it. Also,
since the counters in quesitons would require billions of iops for
tens of billions of seconds to overflow, and since such data rates are
unlikely for people using i386 for a while, that's OK. The fastest
cards today can't do even a million IOPs.

Noticed by: dim@
Sponsored by: Netflix, Inc
2016-11-19 21:46:13 +00:00
Warner Losh
9caeb4305d Decode the Intel-specific Additional SMART data page (0xca) and print
it in human readable form. Include a pointer to the public spec that
was followed to implement this in the code. Samsung also implements
page 0xca on some of their drives, but the format is slighly
different, so the code skips printing zero keys. Samsung's log page
has additional, unknown data after the end of Intel defined data which
isn't displayed.

Supported by: Netfix, Inc
2016-11-19 17:13:12 +00:00
Warner Losh
0cf14228c4 Implement HGST Log page 0xc1, as documented in the HGST SN100 and
SN150 product manuals. Subpage 0x32 is documented, but not implemented.

Sponsored by: Netflix, Inc
2016-11-19 17:13:08 +00:00
Warner Losh
ab1dd0917b Print Intel's expanded Temperature log page.
Sponsored by: Netflix, Inc
2016-11-19 17:13:03 +00:00
Warner Losh
dc58cdf95e Expand the SMART / Health Information Log Page (Page 02) printout
based on NVM Express 1.2.1 Standard.

Sponsored by: Netflix, Inc
2016-11-19 17:12:49 +00:00
Warner Losh
33a099d2e5 Print numbers instead of hex values for smart data. The full 128-bit
number is printed, even though you'd need like a billion IOPs for a 10
billion seconds to overflow the 64-bit counters (~300 years).

Sponsored by: Netflix, Inc
2016-11-19 17:12:44 +00:00
Warner Losh
cc63e8e6ab Use a table for pages we know the size of. We have a special case for
the error log since it isn't a fixed size.

Sponsored by: Netflix, Inc
2016-11-19 17:12:39 +00:00
Warner Losh
fbc3f2995e Remove check for valid log pages. Let the drive tell us which pages
are valid or not. While many pages are reserved in the standard, that
doesn't make them invalid and future versions of the standard may
define then.

Sponsored by: Netflix, Inc
2016-11-19 17:12:28 +00:00