Commit Graph

24 Commits

Author SHA1 Message Date
Warner Losh
0d095c23a0 Const poison the command interface
Make the pointers we pass into the commands const, also make the
linker set mirrors const.

Suggested by: cem@
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D18459
2018-12-06 22:58:42 +00:00
Warner Losh
d4fdb249f2 Usage cleanup pt 2
Eliminage redundant spaces and nvmecontrol at start of all the usage
strings. Update the usage printing code to add them back when
presenting to the user. Allow multi-line usage messages and print
proper leading spaces for lines starting with a space.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D18403
2018-12-02 23:13:12 +00:00
Warner Losh
7d923c13d7 Usage cleanup pt 1
Provide a usage() function that takes a struct nvme_function pointer
and produces a usage mssage. Eliminate all now-redundant usage
functions. Propigate the new argument through the program as needed.
Use common routine to print usage.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D18403
2018-12-02 23:12:58 +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
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
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
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
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
Jim Harris
38441bd9a9 Add message when nvd disks are attached and detached.
As part of this commit, add an nvme_strvis() function which borrows
heavily from cam_strvis().  This will allow stripping of
leading/trailing whitespace and also handle unprintable characters
in model/serial numbers.  This function goes into a new nvme_util.c
file which is used by both the driver and nvmecontrol.

Sponsored by:	Intel
Reviewed by:	carl
MFC after:	3 days
2013-07-19 21:40:57 +00:00
Jim Harris
e8f25c6266 Define constants for the lengths of the serial number, model number
and firmware revision in the controller's identify structure.

Also modify consumers of these fields to ensure they only use the
specified number of bytes for their respective fields.

Sponsored by:	Intel
Reviewed by:	carl
MFC after:	3 days
2013-07-17 23:23:38 +00:00
Jim Harris
08c29873bf Ensure controller or namespace node name is specified before trying to
access it.

While here, also fix the identify usage message to show the -v and -x
parameters.

Sponsored by:	Intel
MFC after:	3 days
2013-07-09 21:33:12 +00:00
Jim Harris
9c0871b260 Condense the output for displaying LBA formats.
Sponsored by:	Intel
MFC after:	3 days
2013-07-09 21:31:58 +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
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
6420873cd6 Create #defines for NVME_CTRLR_PREFIX and NVME_NS_PREFIX for the "nvme"
and "ns" strings, rather than hardcoding the string values throughout the
nvmecontrol code base.

Sponsored by:	Intel
MFC after:	3 days
2013-06-26 23:20:08 +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