Commit Graph

32 Commits

Author SHA1 Message Date
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
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
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
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
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
038659e7dd Implement power command to list all power modes, find out the power
mode we're in and to set the power mode.
2016-01-30 22:48:06 +00:00
Enji Cooper
a2d0c52540 Revert r295062 to unbreak buildworld
Some of the structures referenced in power.c (in particular
struct nvme_power_state) are missing from sbin/nvmecontrol/

Pointyhat to: imp
Reported by: Jenkins [*], O. Hartmann <ohartman@zedat.fu-berlin.de>, Outback Dingo <outbackdingo@gmail.com>
2016-01-30 17:10:14 +00:00
Warner Losh
d636ad2ee8 Implement power command to list all power modes, find out the power
mode we're in and to set the power mode.
2016-01-30 06:18:37 +00:00
Jim Harris
dddb618e3f Use _PATH_DEV (from paths.h) for the "/dev/" string, rather than
hard-coding it.

Sponsored by:	Intel
Suggested by:	kib
Reviewed by:	kib, carl
MFC after:	3 days
2013-07-18 23:25:57 +00:00
Jim Harris
b378da2781 Simplify open_dev() by returning errno values rather than just 0 or 1.
Also remove stat() call and just rely on errno from open() call to discern
whether dev node exists or not.

Sponsored by:	Intel
Reviewed by:	kib, carl
MFC after:	3 days
2013-07-18 23:12:44 +00:00
Jim Harris
a648fac32d Always initialize fd to 0 in open_dev().
Sponsored by:	Intel
Reviewed by:	carl
MFC after:	3 days
2013-07-17 23:14:41 +00:00
Jim Harris
2528d6a326 Send per-namespace logpage commands to the controller devnode, so they
are processed as admin commands, not I/O commands.

As part of this change, pull out the code for parsing a namespace node
string into a separate function, since it is used for both identify and
logpage commands.

Sponsored by:	Intel
MFC after:	3 days
2013-07-09 21:31:21 +00:00
Jim Harris
821ef73ca6 Incorporate feedback from bde@ based on r252672 changes:
* Use 0/1 instead of sysexits.  Man pages are confusing on this topic,
  but 0/1 is sufficient for nvmecontrol.
* Use err function family where possible instead of fprintf/exit.
* Fix some typing errors.
* Clean up some error message inconsistencies.

Sponsored by:	Intel
Submitted by:	bde (parts of firmware.c changes)
MFC after:	3 days
2013-07-09 21:14:15 +00:00
Gleb Smirnoff
25fa33476b Fix build. 2013-06-27 10:42:09 +00:00
Jim Harris
49fac6101d Add firmware replacement and activation support to nvmecontrol(8) through
a new firmware command.

NVMe controllers may support up to 7 firmware slots for storing of
different firmware revisions.  This new firmware command supports
firmware replacement (i.e. firmware download) with or without immediate
activation, or activation of a previously stored firmware image.  It
also supports selection of the firmware slot during replacement
operations, using IDENTIFY information from the controller to
check that the specified slot is valid.

Newly activated firmware does not take effect until the new controller
reset, either via a reboot or separate 'nvmecontrol reset' command to the
same controller.

Submitted by:	Joe Golio <joseph.golio@emc.com>
Obtained from:	EMC / Isilon Storage Division
MFC after:	3 days
2013-06-27 00:08:25 +00:00
Jim Harris
75871362ad Add log page support to nvmecontrol(8) through a new logpage command.
This includes pretty printers for all of the standard NVMe log pages
(Error, SMART/Health, Firmware), as well as hex output for non-standard
or vendor-specific log pages.

Submitted by:	Joe Golio <joseph.golio@emc.com>
Obtained from:	EMC / Isilon Storage Division
MFC after:	3 days
2013-06-26 23:53:54 +00:00
Jim Harris
e83c9e35a7 Add generalized helper functions for printing hex data as part of
nvmecontrol commands.

Submitted by:	Joe Golio <joseph.golio@emc.com>
Obtained from:	EMC / Isilon Storage Division
MFC after:	3 days
2013-06-26 23:46:31 +00:00
Jim Harris
d2cdb28b6f Ensure that a device node is specified when invoking the identify or reset
commands.

Also improve the checking of device node names, so that better error
messages are displayed when incorrect names are specified.

Sponsored by:	Intel
MFC after:	3 days
2013-06-26 23:41:07 +00:00
Jim Harris
7cdb43c490 Add an nvme_function structure array, defining the name, C function and
usage message for each nvmecontrol command.  This helps reduce some code
clutter both now and for future commits which will add logpage and
firmware support to nvmecontrol(8).

Also move helper function prototypes to the end of the header file, after
the per-command functions.

Sponsored by:	Intel
MFC after:	3 days
2013-06-26 23:11:20 +00:00
Jim Harris
28c091109b Break out code related to the reset command into a separate source file.
Sponsored by:	Intel
MFC after:	3 days
2013-06-26 23:05:48 +00:00
Jim Harris
bbc1ac6304 Break out code related to the perftest command into a separate file.
Sponsored by:	Intel
MFC after:	3 days
2013-06-26 23:02:48 +00:00
Jim Harris
6f0823e45d Break out code related to the identify command into a separate source file.
Sponsored by:	Intel
MFC after:	3 days
2013-06-26 23:00:42 +00:00
Jim Harris
6660d5e435 Break out code related to the devlist command into a separate source file.
Sponsored by:	Intel
MFC after:	3 days
2013-06-26 22:58:59 +00:00
Jim Harris
a4acc8c3df Add separate *_usage() functions for each nvmecontrol command.
Sponsored by:	Intel
MFC after:	3 days
2013-06-26 22:53:21 +00:00
Jim Harris
eadf2a44c2 Add an open_dev() helper function to be used in the various places
where nvmecontrol needs to open a handle to a controller or namespace
device node.

Sponsored by:	Intel
MFC after:	3 days
2013-06-26 22:50:49 +00:00
Jim Harris
5076698e19 Remove the NVME_IDENTIFY_CONTROLLER and NVME_IDENTIFY_NAMESPACE IOCTLs and replace
them with the NVMe passthrough equivalent.

Sponsored by:	Intel
2013-04-12 17:56:47 +00:00
Jim Harris
021ee26911 Fix typo (devicde -> device). 2013-04-03 20:52:17 +00:00
Jim Harris
47e56bb131 Use errno and strerror to print more descriptive messages when operations
fail in nvmecontrol(8).

While here, use consistent checks of return values from stat, open and
ioctl.

Sponsored by:	Intel
Suggested by:	carl
Reviewed by:	carl
2013-03-26 22:14:47 +00:00
Jim Harris
b846efd7ec Add controller reset capability to nvme(4) and ability to explicitly
invoke it from nvmecontrol(8).

Controller reset will be performed in cases where I/O are repeatedly
timing out, the controller reports an unrecoverable condition, or
when explicitly requested via IOCTL or an nvme consumer.  Since the
controller may be in such a state where it cannot even process queue
deletion requests, we will perform a controller reset without trying
to clean up anything on the controller first.

Sponsored by:	Intel
Reviewed by:	carl
2013-03-26 19:50:46 +00:00
Jim Harris
4cb79292f7 Add nvmecontrol(8) source code and beginnings of a man page to the tree.
Sponsored by:		Intel
Contributions from:	Joe Golio/EMC <joseph dot golio at emc dot com>
2012-09-17 21:26:55 +00:00