pax_global_header00006660000000000000000000000064126726373340014527gustar00rootroot0000000000000052 comment=76f72197156c541dab2192df391f81550cc6475e nvme-cli-0.5/000077500000000000000000000000001267263733400131055ustar00rootroot00000000000000nvme-cli-0.5/.gitignore000066400000000000000000000002121267263733400150700ustar00rootroot00000000000000nvme *.xml a.out *.o *~ *.swp NVME-VERSION-FILE /debian/files /debian/nvme-cli.debhelper.log /debian/nvme-cli.substvars /debian/nvme-cli nvme-cli-0.5/CONTRIBUTING.md000066400000000000000000000014671267263733400153460ustar00rootroot00000000000000# Contributing to the NVM-e CLI Here you will find instructions on how to contribute to the NVM-Express command line interface. Contributions and new ideas are most welcome! **NOTE: If you do decide to implement code changes and contribute them, please make sure you agree your contribution can be made available under the [GPLv2-style License used for the NVMe CLI](https://github.com/linux-nvme/nvme-cli/blob/master/LICENSE).** ### Code Contributions Please feel free to use the github forums to ask for comments & questions on your code before submitting a pull request. The NVMe CLI project uses the common *fork and merge* workflow used by most GitHub-hosted projects. ### Bug Reports Bugs for the NVM Library project are tracked in our [GitHub Issues Database](https://github.com/linux-nvme/nvme-cli/issues). nvme-cli-0.5/Documentation/000077500000000000000000000000001267263733400157165ustar00rootroot00000000000000nvme-cli-0.5/Documentation/Makefile000066400000000000000000000132351267263733400173620ustar00rootroot00000000000000# Guard against environment variables MAN1_TXT = TECH_DOCS = ARTICLES = SP_ARTICLES = MAN1_TXT += $(filter-out \ $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \ $(wildcard nvme-*.txt)) MAN1_TXT += nvme.txt MAN_TXT = $(MAN1_TXT) MAN_XML = $(patsubst %.txt,%.xml,$(MAN_TXT)) MAN_HTML = $(patsubst %.txt,%.html,$(MAN_TXT)) DOC_HTML = $(MAN_HTML) $(OBSOLETE_HTML) API_DOCS = SP_ARTICLES += $(API_DOCS) SP_ARTICLES += $(TECH_DOCS) DOC_MAN1 = $(patsubst %.txt,%.1,$(MAN1_TXT)) ASCIIDOC = asciidoc ASCIIDOC_EXTRA = ASCIIDOC_DOCBOOK = docbook ASCIIDOC_COMMON = $(ASCIIDOC) $(ASCIIDOC_EXTRA) TXT_TO_XML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_DOCBOOK) MANPAGE_XSL = manpage-normal.xsl XMLTO = xmlto XMLTO_EXTRA = INSTALL ?= install RM ?= rm -f MAN_REPO = ../../nvme-manpages ASCIIDOC_HTML = xhtml11 ASCIIDOC_CONF = -f asciidoc.conf ASCIIDOC_COMMON = $(ASCIIDOC) $(ASCIIDOC_EXTRA) $(ASCIIDOC_CONF) TXT_TO_HTML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_HTML) MAKEINFO = makeinfo INSTALL_INFO = install-info DOCBOOK2X_TEXI = docbook2x-texi DBLATEX = dblatex ASCIIDOC_DBLATEX_DIR = /etc/asciidoc/dblatex ifndef PERL_PATH PERL_PATH = /usr/bin/perl endif ifdef DOCBOOK_XSL_172 MANPAGE_XSL = manpage-1.72.xsl else ifndef ASCIIDOC_ROFF endif endif ifdef MAN_BOLD_LITERAL XMLTO_EXTRA += -m manpage-bold-literal.xsl endif ifdef DOCBOOK_SUPPRESS_SP XMLTO_EXTRA += -m manpage-suppress-sp.xsl endif ifndef MAN_BASE_URL MAN_BASE_URL = file://$(htmldir)/ endif XMLTO_EXTRA += ifdef GNU_ROFF XMLTO_EXTRA += endif SHELL_PATH ?= $(SHELL) # Shell quote; SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) ifdef DEFAULT_PAGER DEFAULT_PAGER_SQ = $(subst ','\'',$(DEFAULT_PAGER)) endif ifdef DEFAULT_EDITOR DEFAULT_EDITOR_SQ = $(subst ','\'',$(DEFAULT_EDITOR)) endif QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir QUIET_SUBDIR1 = ifneq ($(findstring $(MAKEFLAGS),w),w) PRINT_DIR = --no-print-directory else # "make -w" NO_SUBDIR = : endif DESTDIR = PREFIX := /usr/local all: man html html: $(DOC_HTML) man: man1 man1: $(DOC_MAN1) install-no-build: $(INSTALL) -d -m 755 $(DESTDIR)$(PREFIX)/share/man/man1 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(PREFIX)/share/man/man1 install: install-man install-man: man $(INSTALL) -d -m 755 $(DESTDIR)$(PREFIX)/share/man/man1 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(PREFIX)/share/man/man1 docdep_prereqs = \ cmd-list.made $(cmds_txt) doc.dep : $(docdep_prereqs) $(wildcard *.txt) build-docdep.perl $(QUIET_GEN)$(RM) $@+ $@ && \ $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \ mv $@+ $@ -include doc.dep cmds_txt = cmds-ancillaryinterrogators.txt \ cmds-ancillarymanipulators.txt \ cmds-mainporcelain.txt \ cmds-plumbinginterrogators.txt \ cmds-plumbingmanipulators.txt \ cmds-synchingrepositories.txt \ cmds-synchelpers.txt \ cmds-purehelpers.txt \ cmds-foreignscminterface.txt $(cmds_txt): cmd-list.made cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT) $(QUIET_GEN)$(RM) $@ && \ $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \ date >$@ clean: $(RM) *.xml *.xml+ *.html+ $(RM) *.texi *.texi+ *.texi++ nvme.info nvmeman.info $(RM) *.pdf $(RM) howto-index.txt howto/*.html doc.dep $(RM) technical/*.html technical/api-index.txt $(RM) $(cmds_txt) *.made $(RM) manpage-base-url.xsl $(RM) *~ clobber: clean $(RM) *.html *.1 %.1 : %.xml $(QUIET_XMLTO)$(RM) $@ && \ $(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $< %.xml : %.txt $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \ $(TXT_TO_XML) -d manpage -o $@+ $< && \ mv $@+ $@ user-manual.xml: user-manual.txt user-manual.conf $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \ $(TXT_TO_XML) -d article -o $@+ $< && \ mv $@+ $@ technical/api-index.txt: technical/api-index-skel.txt \ technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS)) $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh XSLT = docbook.xsl XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css nvme.info: user-manual.texi $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi user-manual.texi: user-manual.xml $(QUIET_DB2TEXI)$(RM) $@+ $@ && \ $(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \ $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \ rm $@++ && \ mv $@+ $@ user-manual.pdf: user-manual.xml $(QUIET_DBLATEX)$(RM) $@+ $@ && \ $(DBLATEX) -o $@+ -p $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.xsl -s $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.sty $< && \ mv $@+ $@ nvmeman.texi: $(MAN_XML) cat-texi.perl $(QUIET_DB2TEXI)$(RM) $@+ $@ && \ ($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --encoding=UTF-8 \ --to-stdout $(xml) &&) true) > $@++ && \ $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \ rm $@++ && \ mv $@+ $@ nvmeman.info: nvmeman.texi $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi $(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml $(QUIET_DB2TEXI)$(RM) $@+ $@ && \ $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \ mv $@+ $@ howto-index.txt: howto-index.sh $(wildcard howto/*.txt) $(QUIET_GEN)$(RM) $@+ $@ && \ '$(SHELL_PATH_SQ)' ./howto-index.sh $(sort $(wildcard howto/*.txt)) >$@+ && \ mv $@+ $@ WEBDOC_DEST = /pub/software/scm/nvme/docs $(MAN_HTML): %.html : %.txt $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \ $(TXT_TO_HTML) -d manpage -o $@+ $< && \ mv $@+ $@ quick-install: quick-install-man $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt $(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt install-webdoc : html '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST) require-manrepo:: @if test ! -d $(MAN_REPO); \ then echo "nvme-manpages repository must exist at $(MAN_REPO)"; exit 1; fi quick-install-man: require-manrepo '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(MAN_REPO) $(DESTDIR)$(mandir) print-man1: @for i in $(MAN1_TXT); do echo $$i; done .PHONY: FORCE nvme-cli-0.5/Documentation/asciidoc.conf000066400000000000000000000043371267263733400203520ustar00rootroot00000000000000## linknvme: macro # # Usage: linknvme:command[manpage-section] # # Note, {0} is the manpage section, while {target} is the command. # # Show Git link as: (
); if section is defined, else just show # the command. [macros] (?su)[\\]?(?Plinknvme):(?P\S*?)\[(?P.*?)\]= [attributes] asterisk=* plus=+ caret=^ startsb=[ endsb=] backslash=\ tilde=~ apostrophe=' backtick=` litdd=-- ifdef::backend-docbook[] [linknvme-inlinemacro] {0%{target}} {0#} {0#{target}{0}} {0#} endif::backend-docbook[] ifdef::backend-docbook[] ifndef::git-asciidoc-no-roff[] # "unbreak" docbook-xsl v1.68 for manpages. v1.69 works with or without this. # v1.72 breaks with this because it replaces dots not in roff requests. [listingblock] {title} | {title#} endif::git-asciidoc-no-roff[] ifdef::git-asciidoc-no-roff[] ifdef::doctype-manpage[] # The following two small workarounds insert a simple paragraph after screen [listingblock] {title} | {title#} [verseblock] {title} {title%} {title#} | {title#} {title%} endif::doctype-manpage[] endif::git-asciidoc-no-roff[] endif::backend-docbook[] ifdef::doctype-manpage[] ifdef::backend-docbook[] [header] template::[header-declarations] {mantitle} {manvolnum} NVMe {nvme_version} NVMe Manual {manname} {manpurpose} endif::backend-docbook[] endif::doctype-manpage[] ifdef::backend-xhtml11[] [attributes] git-relative-html-prefix= [linknvme-inlinemacro] {target}{0?({0})} endif::backend-xhtml11[] nvme-cli-0.5/Documentation/cmds-main.txt000066400000000000000000000035541267263733400203360ustar00rootroot00000000000000linknvme:nvme-admin-passthru[1]:: Admin Passthrough Command linknvme:nvme-compare[1]:: IO Compare linknvme:nvme-error-log[1]:: Retrieve error logs linknvme:nvme-flush[1]:: Submit flush linknvme:nvme-dms[1]:: Submit Data Set Management linknvme:nvme-format[1]:: Format namespace(s) linknvme:nvme-fw-activate[1]:: F/W Activate linknvme:nvme-fw-download[1]:: F/W Download linknvme:nvme-fw-log[1]:: Retrieve f/w log linknvme:nvme-get-feature[1]:: Get Features linknvme:nvme-get-log[1]:: Generic Get Log linknvme:nvme-smart-log[1]:: Retrieve Smart Log linknvme:nvme-get-ns-id[1]:: Retrieve namespace identifier linknvme:nvme-help[1]:: NVMe CLI Help linknvme:nvme-id-ctrl[1]:: Identify Controller linknvme:nvme-id-ns[1]:: Identify Namespace linknvme:nvme-create-ns[1]:: Create a new namespace linknvme:nvme-delete-ns[1]:: Delete existing namespace linknvme:nvme-attach-ns[1]:: Attach namespace linknvme:nvme-detach-ns[1]:: Detach namespace linknvme:nvme-io-passthru[1]:: IO Passthrough Command linknvme:nvme-list-ns[1]:: List all nvme namespaces linknvme:nvme-list[1]:: List all nvme controllers linknvme:nvme-list-ctrl[1]:: List controller in NVMe subsystem linknvme:nvme-read[1]:: Issue IO Read Command linknvme:nvme-write[1]:: Issue IO Write Command linknvme:nvme-write-zeroes[1]:: Issue IO Write Zeroes Command linknvme:nvme-write-uncor[1]:: Issue IO Write Uncorrectable Command linknvme:nvme-resv-acquire[1]:: Acquire Namespace Reservation linknvme:nvme-resv-register[1]:: Register Namespace Reservation linknvme:nvme-resv-release[1]:: Release Namespace Reservation linknvme:nvme-resv-report[1]:: Report Reservation Capabilities linknvme:nvme-security-recv[1]:: Security Receive linknvme:nvme-security-send[1]:: Security Send linknvme:nvme-set-feature[1]:: Set Feature linknvme:nvme-show-regs[1]:: Show NVMe Controller Registers nvme-cli-0.5/Documentation/install-webdoc.sh000077500000000000000000000013651267263733400211710ustar00rootroot00000000000000#!/bin/sh T="$1" for h in \ *.txt *.html \ howto/*.txt howto/*.html \ technical/*.txt technical/*.html \ RelNotes/*.txt *.css do if test ! -f "$h" then : did not match elif test -f "$T/$h" && $DIFF -u -I'^Last updated ' "$T/$h" "$h" then :; # up to date else echo >&2 "# install $h $T/$h" rm -f "$T/$h" mkdir -p $(dirname "$T/$h") cp "$h" "$T/$h" fi done strip_leading=$(echo "$T/" | sed -e 's|.|.|g') for th in \ "$T"/*.html "$T"/*.txt \ "$T"/howto/*.txt "$T"/howto/*.html \ "$T"/technical/*.txt "$T"/technical/*.html do h=$(expr "$th" : "$strip_leading"'\(.*\)') case "$h" in RelNotes-*.txt | index.html) continue ;; esac test -f "$h" && continue echo >&2 "# rm -f $th" rm -f "$th" done ln -sf git.html "$T/index.html" nvme-cli-0.5/Documentation/manpage-base.xsl000066400000000000000000000022601267263733400207660ustar00rootroot00000000000000 sp br nvme-cli-0.5/Documentation/manpage-normal.xsl000066400000000000000000000007351267263733400213510ustar00rootroot00000000000000 \ . nvme-cli-0.5/Documentation/nvme-admin-passthru.1000066400000000000000000000116241267263733400217060ustar00rootroot00000000000000'\" t .\" Title: nvme-admin-passthru .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 02/26/2016 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-ADMIN\-PASSTHR" "1" "02/26/2016" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-admin-passthru \- Submit an arbitrary admin command, return results .SH "SYNOPSIS" .sp .nf \fInvme\-admin\-passthru\fR [\-\-opcode= | \-o ] [\-\-flags= | \-f ] [\-rsvd= | \-R ] [\-\-namespace\-id=] [\-\-cdw2=] [\-\-cdw3=] [\-\-cdw10=] [\-\-cdw11=] [\-\-cdw12=] [\-\-cdw13=] [\-\-cdw14=] [\-\-cdw15=] [\-\-data\-len= | \-l ] [\-\-metadata\-len= | \-m ] [\-\-input\-file= | \-f ] [\-\-read | \-r ] [\-\-write | \-w] [\-\-timeout= | \-t ] [\-\-show\-command | \-\-dry\-run | \-s] [\-\-raw\-binary | \-b] .fi .SH "DESCRIPTION" .sp Submits an arbitrary NVMe admin command and returns the applicable results\&. This may be the simply the commands result and status, or may also include a buffer if the command returns one\&. This command does no interpretation of the opcodes or options\&. .sp The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1)\&. .sp On success, the returned structure (if applicable) may be returned in one of several ways depending on the option flags; the structure may printed by the program as a hex dump, or may be returned as a raw buffer printed to stdout for another program to parse\&. .SH "OPTIONS" .PP \-o , \-\-opcode= .RS 4 The NVMe opcode to send to the device in the command .RE .PP \-f , \-\-flags= .RS 4 The NVMe command flags to send to the device in the command .RE .PP \-R , \-\-rsvd= .RS 4 The value for the reserved field in the command\&. .RE .PP \-n , \-\-namespace\-id= .RS 4 The value for the ns\-id in the command\&. .RE .PP \-\-cdw[2\-3,10\-15]= .RS 4 Specifies the command dword value for that specified entry in the command .RE .PP \-r, \-\-read, \-w, \-\-write .RS 4 Used for the data\-direction for the command and required for commands sending/receiving data\&. Don\(cqt use both read and write at the same time\&. .RE .PP \-i , \-\-input\-file= .RS 4 If the command is a data\-out (write) command, use this file to fill the buffer sent to the device\&. If no file is given, assumed to use STDIN\&. .RE .PP \-l , \-\-data\-len= .RS 4 The data length for the buffer used for this command\&. .RE .PP \-m , \-\-metadata\-len= .RS 4 The metadata length for the buffer used for this command\&. .RE .PP \-s, \-\-show\-cmd, \-\-dry\-run .RS 4 Do not actually send the command; print out the command that would be sent\&. .RE .PP \-b, \-\-raw\-binary .RS 4 Print the raw returned buffer to stdout if the command returns a structure\&. .RE .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The following will run the admin command with opcode=6 and cdw10=1, which corresponds to an identify controller command\&. This example requires the data\-len param be 4096, which is the size of the returned structure\&. The \-r option is used because it is a data\-in command .sp .if n \{\ .RS 4 .\} .nf # nvme admin\-passthru /dev/nvme0 \-\-opcode=06 \-\-data\-len=4096 \-\-cdw10=1 \-r .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Or if you want to save that structure to a file: .sp .if n \{\ .RS 4 .\} .nf # nvme admin\-passthru /dev/nvme0 \-\-opcode=06 \-\-data\-len=4096 \-\-cdw10=1 \-r \-b > id_ns\&.raw .fi .if n \{\ .RE .\} .RE .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-admin-passthru.html000066400000000000000000000532001267263733400225060ustar00rootroot00000000000000 nvme-admin-passthru(1)

SYNOPSIS

nvme-admin-passthru <device> [--opcode=<opcode> | -o <opcode>]
                [--flags=<flags> | -f <flags>] [-rsvd=<rsvd> | -R <rsvd>]
                [--namespace-id=<nsid>] [--cdw2=<cdw2>] [--cdw3=<cdw3>]
                [--cdw10=<cdw10>] [--cdw11=<cdw11>] [--cdw12=<cdw12>]
                [--cdw13=<cdw13>] [--cdw14=<cdw14>] [--cdw15=<cdw15>]
                [--data-len=<data-len> | -l <data-len>]
                [--metadata-len=<len> | -m <len>]
                [--input-file=<file> | -f <file>]
                [--read | -r ] [--write | -w]
                [--timeout=<to> | -t <to>]
                [--show-command | --dry-run | -s]
                [--raw-binary | -b]

DESCRIPTION

Submits an arbitrary NVMe admin command and returns the applicable results. This may be the simply the commands result and status, or may also include a buffer if the command returns one. This command does no interpretation of the opcodes or options.

The <device> parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1).

On success, the returned structure (if applicable) may be returned in one of several ways depending on the option flags; the structure may printed by the program as a hex dump, or may be returned as a raw buffer printed to stdout for another program to parse.

OPTIONS

-o <opcode>
--opcode=<opcode>

The NVMe opcode to send to the device in the command

-f <flags>
--flags=<flags>

The NVMe command flags to send to the device in the command

-R <rsvd>
--rsvd=<rsvd>

The value for the reserved field in the command.

-n <nsid>
--namespace-id=<nsid>

The value for the ns-id in the command.

--cdw[2-3,10-15]=<cdw>

Specifies the command dword value for that specified entry in the command

-r
--read
-w
--write

Used for the data-direction for the command and required for commands sending/receiving data. Don’t use both read and write at the same time.

-i <file>
--input-file=<file>

If the command is a data-out (write) command, use this file to fill the buffer sent to the device. If no file is given, assumed to use STDIN.

-l <data-len>
--data-len=<data-len>

The data length for the buffer used for this command.

-m <data-len>
--metadata-len=<data-len>

The metadata length for the buffer used for this command.

-s
--show-cmd
--dry-run

Do not actually send the command; print out the command that would be sent.

-b
--raw-binary

Print the raw returned buffer to stdout if the command returns a structure.

EXAMPLES

  • The following will run the admin command with opcode=6 and cdw10=1, which corresponds to an identify controller command. This example requires the data-len param be 4096, which is the size of the returned structure. The -r option is used because it is a data-in command

    # nvme admin-passthru /dev/nvme0 --opcode=06 --data-len=4096 --cdw10=1 -r
  • Or if you want to save that structure to a file:

    # nvme admin-passthru /dev/nvme0 --opcode=06 --data-len=4096 --cdw10=1 -r -b > id_ns.raw

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-admin-passthru.txt000066400000000000000000000061721267263733400223670ustar00rootroot00000000000000nvme-admin-passthru(1) ====================== NAME ---- nvme-admin-passthru - Submit an arbitrary admin command, return results SYNOPSIS -------- [verse] 'nvme-admin-passthru' [--opcode= | -o ] [--flags= | -f ] [-rsvd= | -R ] [--namespace-id=] [--cdw2=] [--cdw3=] [--cdw10=] [--cdw11=] [--cdw12=] [--cdw13=] [--cdw14=] [--cdw15=] [--data-len= | -l ] [--metadata-len= | -m ] [--input-file= | -f ] [--read | -r ] [--write | -w] [--timeout= | -t ] [--show-command | --dry-run | -s] [--raw-binary | -b] DESCRIPTION ----------- Submits an arbitrary NVMe admin command and returns the applicable results. This may be the simply the commands result and status, or may also include a buffer if the command returns one. This command does no interpretation of the opcodes or options. The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1). On success, the returned structure (if applicable) may be returned in one of several ways depending on the option flags; the structure may printed by the program as a hex dump, or may be returned as a raw buffer printed to stdout for another program to parse. OPTIONS ------- -o :: --opcode=:: The NVMe opcode to send to the device in the command -f :: --flags=:: The NVMe command flags to send to the device in the command -R :: --rsvd=:: The value for the reserved field in the command. -n :: --namespace-id=:: The value for the ns-id in the command. --cdw[2-3,10-15]=:: Specifies the command dword value for that specified entry in the command -r:: --read:: -w:: --write:: Used for the data-direction for the command and required for commands sending/receiving data. Don't use both read and write at the same time. -i :: --input-file=:: If the command is a data-out (write) command, use this file to fill the buffer sent to the device. If no file is given, assumed to use STDIN. -l :: --data-len=:: The data length for the buffer used for this command. -m :: --metadata-len=:: The metadata length for the buffer used for this command. -s:: --show-cmd:: --dry-run:: Do not actually send the command; print out the command that would be sent. -b:: --raw-binary:: Print the raw returned buffer to stdout if the command returns a structure. EXAMPLES -------- * The following will run the admin command with opcode=6 and cdw10=1, which corresponds to an identify controller command. This example requires the data-len param be 4096, which is the size of the returned structure. The -r option is used because it is a data-in command + ------------ # nvme admin-passthru /dev/nvme0 --opcode=06 --data-len=4096 --cdw10=1 -r ------------ + * Or if you want to save that structure to a file: + ------------ # nvme admin-passthru /dev/nvme0 --opcode=06 --data-len=4096 --cdw10=1 -r -b > id_ns.raw ------------ NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-attach-ns.1000066400000000000000000000037131267263733400206310ustar00rootroot00000000000000'\" t .\" Title: nvme-attach-ns .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/08/2015 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-ATTACH\-NS" "1" "06/08/2015" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-attach-ns \- Send NVMe attach namespace, return result\&. .SH "SYNOPSIS" .sp .nf \fInvme attach\-ns\fR [\-\-namespace\-id= | \-n ] [\-\-controllers= | \-c ] .fi .SH "DESCRIPTION" .sp For the NVMe device given, sends the nvme namespace attach command for the provided namespace identifier, attaching to the provided list of controller identifiers\&. .SH "OPTIONS" .PP \-n , \-\-namespace\-id= .RS 4 The namespace identifier to attach\&. .RE .PP \-c , \-controllers= .RS 4 The comma separated list of controller identifiers to attach the namesapce too\&. .RE .SH "EXAMPLES" .sp No examples yet\&. .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-attach-ns.html000066400000000000000000000434461267263733400214440ustar00rootroot00000000000000 nvme-attach-ns(1)

SYNOPSIS

nvme attach-ns <device> [--namespace-id=<nsid> | -n <nsid>]
                        [--controllers=<ctrl-list,> | -c <ctrl-list,>]

DESCRIPTION

For the NVMe device given, sends the nvme namespace attach command for the provided namespace identifier, attaching to the provided list of controller identifiers.

OPTIONS

-n <nsid>
--namespace-id=<nsid>

The namespace identifier to attach.

-c <ctrl-list,>
-controllers=<ctrl-list,>

The comma separated list of controller identifiers to attach the namesapce too.

EXAMPLES

No examples yet.

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-attach-ns.txt000066400000000000000000000013311267263733400213020ustar00rootroot00000000000000nvme-attach-ns(1) ================= NAME ---- nvme-attach-ns - Send NVMe attach namespace, return result. SYNOPSIS -------- [verse] 'nvme attach-ns' [--namespace-id= | -n ] [--controllers= | -c ] DESCRIPTION ----------- For the NVMe device given, sends the nvme namespace attach command for the provided namespace identifier, attaching to the provided list of controller identifiers. OPTIONS ------- -n :: --namespace-id=:: The namespace identifier to attach. -c :: -controllers=:: The comma separated list of controller identifiers to attach the namesapce too. EXAMPLES -------- No examples yet. NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-compare.1000066400000000000000000000051001267263733400203650ustar00rootroot00000000000000'\" t .\" Title: nvme-compare .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/08/2015 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-COMPARE" "1" "06/08/2015" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-compare \- Send an NVMe Compare command, provide results .SH "SYNOPSIS" .sp .nf \fInvme\-compare\fR [\-\-start\-block= | \-s ] [\-\-block\-count= | \-c ] [\-\-data\-size= | \-z ] [\-\-ref\-tag= | \-r ] [\-\-data= | \-d ] [\-\-prinfo= | \-p ] [\-\-app\-tag\-mask= | \-m ] [\-\-app\-tag= | \-a ] [\-\-limited\-retry | \-l] [\-\-force\-unit\-access | \-f] .fi .SH "DESCRIPTION" .sp The Compare command reads the logical blocks specified by the command from the medium and compares the data read to a comparison data buffer transferred as part of the command\&. If the data read from the controller and the comparison data buffer are equivalent with no miscompares, then the command completes successfully\&. If there is any miscompare, the command completes with an error of Compare Failure\&. If metadata is provided, then a comparison is also performed for the metadata\&. .SH "OPTIONS" .PP \-\-start\-block=, \-s .RS 4 Start block\&. .RE .SH "EXAMPLES" .sp No examples yet\&. .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-compare.html000066400000000000000000000445561267263733400212130ustar00rootroot00000000000000 nvme-compare(1)

SYNOPSIS

nvme-compare <device> [--start-block=<slba> | -s <slba>]
                        [--block-count=<nlb> | -c <nlb>]
                        [--data-size=<size> | -z <size>]
                        [--ref-tag=<reftag> | -r <reftag>]
                        [--data=<data-file> | -d <data-file>]
                        [--prinfo=<prinfo> | -p <prinfo>]
                        [--app-tag-mask=<appmask> | -m <appmask>]
                        [--app-tag=<apptag> | -a <apptag>]
                        [--limited-retry | -l]
                        [--force-unit-access | -f]

DESCRIPTION

The Compare command reads the logical blocks specified by the command from the medium and compares the data read to a comparison data buffer transferred as part of the command. If the data read from the controller and the comparison data buffer are equivalent with no miscompares, then the command completes successfully. If there is any miscompare, the command completes with an error of Compare Failure. If metadata is provided, then a comparison is also performed for the metadata.

OPTIONS

--start-block=<slba>
-s <slba>

Start block.

EXAMPLES

No examples yet.

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-compare.txt000066400000000000000000000022201267263733400210440ustar00rootroot00000000000000nvme-compare(1) =============== NAME ---- nvme-compare - Send an NVMe Compare command, provide results SYNOPSIS -------- [verse] 'nvme-compare' [--start-block= | -s ] [--block-count= | -c ] [--data-size= | -z ] [--ref-tag= | -r ] [--data= | -d ] [--prinfo= | -p ] [--app-tag-mask= | -m ] [--app-tag= | -a ] [--limited-retry | -l] [--force-unit-access | -f] DESCRIPTION ----------- The Compare command reads the logical blocks specified by the command from the medium and compares the data read to a comparison data buffer transferred as part of the command. If the data read from the controller and the comparison data buffer are equivalent with no miscompares, then the command completes successfully. If there is any miscompare, the command completes with an error of Compare Failure. If metadata is provided, then a comparison is also performed for the metadata. OPTIONS ------- --start-block=:: -s :: Start block. EXAMPLES -------- No examples yet. NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-create-ns.1000066400000000000000000000046171267263733400206340ustar00rootroot00000000000000'\" t .\" Title: nvme-create-ns .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/08/2015 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-CREATE\-NS" "1" "06/08/2015" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-create-ns \- Send NVMe Namespace management command to create namespace, returns results\&. .SH "SYNOPSIS" .sp .nf \fInvme create\-ns\fR [\-\-nsze= | \-n ] [\-\-ncap= | \-c ] [\-\-flbas= | \-f ] [\-\-dps= | \-d ] [\-\-nmic= | \-m ] .fi .SH "DESCRIPTION" .sp For the NVMe device given, sends a namespace management command to create the namespace with the requested settings\&. On success, the namespace identifier assigned by the controller is returned\&. .sp The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1)\&. .SH "OPTIONS" .PP \-s, \-\-nsze .RS 4 The namespace size\&. .RE .PP \-c, \-\-ncap .RS 4 The namespace capacity\&. .RE .PP \-f, \-\-flbas .RS 4 The namespace formatted logical block size setting\&. .RE .PP \-d, \-\-dps .RS 4 The data protection settings\&. .RE .PP \-m, \-\-nmic .RS 4 Namespace multipath and sharing capabilities\&. .RE .SH "EXAMPLES" .sp No examples provided yet\&. .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-create-ns.html000066400000000000000000000447531267263733400214450ustar00rootroot00000000000000 nvme-create-ns(1)

SYNOPSIS

nvme create-ns <device> [--nsze=<nsze> | -n <nsze>]
                        [--ncap=<ncap> | -c <ncap>]
                        [--flbas=<flbas> | -f <flbas>]
                        [--dps=<dps> | -d <dps>]
                        [--nmic=<nmic> | -m <nmic>]

DESCRIPTION

For the NVMe device given, sends a namespace management command to create the namespace with the requested settings. On success, the namespace identifier assigned by the controller is returned.

The <device> parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1).

OPTIONS

-s
--nsze

The namespace size.

-c
--ncap

The namespace capacity.

-f
--flbas

The namespace formatted logical block size setting.

-d
--dps

The data protection settings.

-m
--nmic

Namespace multipath and sharing capabilities.

EXAMPLES

No examples provided yet.

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-create-ns.txt000066400000000000000000000020511267263733400213010ustar00rootroot00000000000000nvme-create-ns(1) ================= NAME ---- nvme-create-ns - Send NVMe Namespace management command to create namespace, returns results. SYNOPSIS -------- [verse] 'nvme create-ns' [--nsze= | -n ] [--ncap= | -c ] [--flbas= | -f ] [--dps= | -d ] [--nmic= | -m ] DESCRIPTION ----------- For the NVMe device given, sends a namespace management command to create the namespace with the requested settings. On success, the namespace identifier assigned by the controller is returned. The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1). OPTIONS ------- -s:: --nsze:: The namespace size. -c:: --ncap:: The namespace capacity. -f:: --flbas:: The namespace formatted logical block size setting. -d:: --dps:: The data protection settings. -m:: --nmic:: Namespace multipath and sharing capabilities. EXAMPLES -------- No examples provided yet. NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-delete-ns.1000066400000000000000000000036611267263733400206310ustar00rootroot00000000000000'\" t .\" Title: nvme-id-ns .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 10/21/2015 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-ID\-NS" "1" "10/21/2015" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-delete-ns \- Send NVMe Namespace Management delete namespace command, return result\&. .SH "SYNOPSIS" .sp .nf \fInvme delete\-ns\fR [\-\-namespace\-id= | \-n ] .fi .SH "DESCRIPTION" .sp For the NVMe device given, sends an nvme namespace management command to delete the requested namespace and provides the result\&. .sp The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1)\&. The \*(Aq\-\-namespace\-id\*(Aq option is mandatory\&. .SH "OPTIONS" .PP \-n , \-\-namespace\-id= .RS 4 The namespace identifier to delete\&. .RE .SH "EXAMPLES" .sp No examples yet\&. .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-delete-ns.html000066400000000000000000000433111267263733400214310ustar00rootroot00000000000000 nvme-id-ns(1)

SYNOPSIS

nvme delete-ns <device> [--namespace-id=<nsid> | -n <nsid>]

DESCRIPTION

For the NVMe device given, sends an nvme namespace management command to delete the requested namespace and provides the result.

The <device> parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1). The '--namespace-id' option is mandatory.

OPTIONS

-n <nsid>
--namespace-id=<nsid>

The namespace identifier to delete.

EXAMPLES

No examples yet.

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-delete-ns.txt000066400000000000000000000013271267263733400213050ustar00rootroot00000000000000nvme-id-ns(1) ============= NAME ---- nvme-delete-ns - Send NVMe Namespace Management delete namespace command, return result. SYNOPSIS -------- [verse] 'nvme delete-ns' [--namespace-id= | -n ] DESCRIPTION ----------- For the NVMe device given, sends an nvme namespace management command to delete the requested namespace and provides the result. The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1). The `'--namespace-id'` option is mandatory. OPTIONS ------- -n :: --namespace-id=:: The namespace identifier to delete. EXAMPLES -------- No examples yet. NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-detach-ns.1000066400000000000000000000037131267263733400206150ustar00rootroot00000000000000'\" t .\" Title: nvme-detach-ns .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 02/26/2016 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-DETACH\-NS" "1" "02/26/2016" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-detach-ns \- Send NVMe detach namespace, return result\&. .SH "SYNOPSIS" .sp .nf \fInvme detach\-ns\fR [\-\-namespace\-id= | \-n ] [\-\-controllers= | \-c .fi .SH "DESCRIPTION" .sp For the NVMe device given, sends the nvme namespace detach command for the provided namespace identifier, attaching to the provided list of controller identifiers\&. .SH "OPTIONS" .PP \-n , \-\-namespace\-id= .RS 4 The namespace identifier to detach\&. .RE .PP \-c , \-controllers= .RS 4 The comma separated list of controller identifiers to detach the namespace from\&. .RE .SH "EXAMPLES" .sp No examples yet\&. .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-detach-ns.html000066400000000000000000000434461267263733400214300ustar00rootroot00000000000000 nvme-detach-ns(1)

SYNOPSIS

nvme detach-ns <device> [--namespace-id=<nsid> | -n <nsid>]
                        [--controllers=<ctrl-list,> | -c <ctrl-list,>

DESCRIPTION

For the NVMe device given, sends the nvme namespace detach command for the provided namespace identifier, attaching to the provided list of controller identifiers.

OPTIONS

-n <nsid>
--namespace-id=<nsid>

The namespace identifier to detach.

-c <ctrl-list,>
-controllers=<ctrl-list,>

The comma separated list of controller identifiers to detach the namespace from.

EXAMPLES

No examples yet.

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-detach-ns.txt000066400000000000000000000013311267263733400212660ustar00rootroot00000000000000nvme-detach-ns(1) ================= NAME ---- nvme-detach-ns - Send NVMe detach namespace, return result. SYNOPSIS -------- [verse] 'nvme detach-ns' [--namespace-id= | -n ] [--controllers= | -c DESCRIPTION ----------- For the NVMe device given, sends the nvme namespace detach command for the provided namespace identifier, attaching to the provided list of controller identifiers. OPTIONS ------- -n :: --namespace-id=:: The namespace identifier to detach. -c :: -controllers=:: The comma separated list of controller identifiers to detach the namespace from. EXAMPLES -------- No examples yet. NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-dsm.1000066400000000000000000000073041267263733400175320ustar00rootroot00000000000000'\" t .\" Title: nvme-dsm .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 02/26/2016 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-DSM" "1" "02/26/2016" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-dsm \- Send NVMe Data Set Management, return results .SH "SYNOPSIS" .sp .nf \fInvme dsm\fR [ \-\-namespace\-id= | \-n ] [ \-\-ctx\-attrs= | \-a ] [ \-\-blocks= | \-b ] [ \-\-slbs= | \-s ] [ \-\-ad | \-d ] [ \-\-idw | \-w ] [ \-\-idr | \-r ] [ \-\-cdw11= | \-c ] .fi .SH "DESCRIPTION" .sp For the NVMe device given, sends an Data Set Management command and provides the result and returned structure\&. .sp The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1)\&. If the character device is given, the \*(Aq\-\-namespace\-id\*(Aq option is mandatory, otherwise it will use the ns\-id of the namespace for the block device you opened\&. For block devices, the ns\-id used can be overridden with the same option\&. .sp You must specify at least one of the values for range list\&. If the range lists provided do not list the same number of elements, the default values for the remaining in the range will be set to 0\&. .sp The command dword 11 may be provided at the command line\&. For convenience, the current defined attributes (discard, integral read/write) for a data\-set management have flags\&. If cdw11 is specified, this will override any settings from the flags may have provided\&. .SH "OPTIONS" .PP \-n , \-\-namespace\-id= .RS 4 Sends the command with the requested nsid\&. This is required for the character devices, or overrides the block nsid if given\&. .RE .PP \-a , \-\-ctx\-attrs= .RS 4 Comma separated list of the context attributes in each range .RE .PP \-b , \-\-blocks= .RS 4 Comma separated list of the number of blocks in each range .RE .PP \-s , \-\-slbs= .RS 4 Comma separated list of the starting block in each range .RE .PP \-d , \-\-ad= .RS 4 Attribute Deallocate\&. .RE .PP \-w , \-\-idw= .RS 4 Attribute Integral Dataset for Write\&. .RE .PP \-r , \-\-idr= .RS 4 Attribute Integral Dataset for Read\&. .RE .PP \-c , \-\-cdw11= .RS 4 All the command command dword 11 attributes\&. Use exclusive from specifying individual attributes .RE .SH "EXAMPLES" .sp No examples yet .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-dsm.html000066400000000000000000000502301267263733400203320ustar00rootroot00000000000000 nvme-dsm(1)

SYNOPSIS

nvme dsm <device>  [ --namespace-id=<nsid> | -n <nsid> ]
                        [ --ctx-attrs=<attribute-list,> | -a <attribute-list,> ]
                        [ --blocks=<nlb-list,> | -b <nlb-list,> ]
                        [ --slbs=<slba-list,> | -s <slba-list,> ]
                        [ --ad | -d ] [ --idw | -w ] [ --idr | -r ]
                        [ --cdw11=<cdw11> | -c <cdw11> ]

DESCRIPTION

For the NVMe device given, sends an Data Set Management command and provides the result and returned structure.

The <device> parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1). If the character device is given, the '--namespace-id' option is mandatory, otherwise it will use the ns-id of the namespace for the block device you opened. For block devices, the ns-id used can be overridden with the same option.

You must specify at least one of the values for range list. If the range lists provided do not list the same number of elements, the default values for the remaining in the range will be set to 0.

The command dword 11 may be provided at the command line. For convenience, the current defined attributes (discard, integral read/write) for a data-set management have flags. If cdw11 is specified, this will override any settings from the flags may have provided.

OPTIONS

-n <nsid>
--namespace-id=<nsid>

Sends the command with the requested nsid. This is required for the character devices, or overrides the block nsid if given.

-a <attribute-list,>
--ctx-attrs=<attribute-list>

Comma separated list of the context attributes in each range

-b <nlb-list,>
--blocks=<nlb-list,>

Comma separated list of the number of blocks in each range

-s <slba-list,>
--slbs=<slba-list,>

Comma separated list of the starting block in each range

-d <deallocate>
--ad=<deallocate>

Attribute Deallocate.

-w <write>
--idw=<write>

Attribute Integral Dataset for Write.

-r <read>
--idr=<read>

Attribute Integral Dataset for Read.

-c <cdw11>
--cdw11=<cdw11>

All the command command dword 11 attributes. Use exclusive from specifying individual attributes

EXAMPLES

No examples yet

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-dsm.txt000066400000000000000000000043641267263733400202140ustar00rootroot00000000000000nvme-dsm(1) =========== NAME ---- nvme-dsm - Send NVMe Data Set Management, return results SYNOPSIS -------- [verse] 'nvme dsm' [ --namespace-id= | -n ] [ --ctx-attrs= | -a ] [ --blocks= | -b ] [ --slbs= | -s ] [ --ad | -d ] [ --idw | -w ] [ --idr | -r ] [ --cdw11= | -c ] DESCRIPTION ----------- For the NVMe device given, sends an Data Set Management command and provides the result and returned structure. The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1). If the character device is given, the `'--namespace-id'` option is mandatory, otherwise it will use the ns-id of the namespace for the block device you opened. For block devices, the ns-id used can be overridden with the same option. You must specify at least one of the values for range list. If the range lists provided do not list the same number of elements, the default values for the remaining in the range will be set to 0. The command dword 11 may be provided at the command line. For convenience, the current defined attributes (discard, integral read/write) for a data-set management have flags. If cdw11 is specified, this will override any settings from the flags may have provided. OPTIONS ------- -n :: --namespace-id=:: Sends the command with the requested nsid. This is required for the character devices, or overrides the block nsid if given. -a :: --ctx-attrs=:: Comma separated list of the context attributes in each range -b :: --blocks=:: Comma separated list of the number of blocks in each range -s :: --slbs=:: Comma separated list of the starting block in each range -d :: --ad=:: Attribute Deallocate. -w :: --idw=:: Attribute Integral Dataset for Write. -r :: --idr=:: Attribute Integral Dataset for Read. -c :: --cdw11=:: All the command command dword 11 attributes. Use exclusive from specifying individual attributes EXAMPLES -------- No examples yet NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-error-log.1000066400000000000000000000064041267263733400206570ustar00rootroot00000000000000'\" t .\" Title: nvme-error-log .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 02/26/2016 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-ERROR\-LOG" "1" "02/26/2016" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-error-log \- Send NVME Error log page request, return result and log .SH "SYNOPSIS" .sp .nf \fInvme error\-log\fR [\-\-namespace\-id= | \-n ] [\-\-log\-entries= | \-e ] [\-\-raw\-binary | \-b] .fi .SH "DESCRIPTION" .sp Retrieves NVMe Error log page from an NVMe device and provides the retuned structure\&. .sp The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1)\&. .sp On success, the returned error log structure may be returned in one of several ways depending on the option flags; the structure may parsed by the program and printed in a readable format or the raw buffer may be printed to stdout for another program to parse\&. .SH "OPTIONS" .PP \-n , \-\-namespace\-id= .RS 4 Retrieve the Error Log for the given nsid\&. This is optional and its success may depend on the device\(cqs capabilities to provide this log on a per\-namespace basis (see the NVMe Identify Controller for this capability)\&. The default nsid to use is 0xffffffff for the device global error log\&. .RE .PP \-e , \-\-log\-entries= .RS 4 Specifies how many log entries the program should request from the device\&. This must be at least one, and shouldn\(cqt exceed the device\(cqs capabilities\&. Defaults to 64 log entries\&. .RE .PP \-b, \-\-raw\-binary .RS 4 Print the raw error log buffer to stdout\&. .RE .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Get the error log and print it in a human readable format: .sp .if n \{\ .RS 4 .\} .nf # nvme error\-log /dev/nvme0 .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Print the raw output to a file: .sp .if n \{\ .RS 4 .\} .nf # nvme error\-log /dev/nvme0 \-\-raw\-binary > error_log\&.raw .fi .if n \{\ .RE .\} .sp It is probably a bad idea to not redirect stdout when using this mode\&. .RE .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-error-log.html000066400000000000000000000464251267263733400214720ustar00rootroot00000000000000 nvme-error-log(1)

SYNOPSIS

nvme error-log <device>  [--namespace-id=<nsid> | -n <nsid>]
                         [--log-entries=<entries> | -e <entries>]
                         [--raw-binary | -b]

DESCRIPTION

Retrieves NVMe Error log page from an NVMe device and provides the retuned structure.

The <device> parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1).

On success, the returned error log structure may be returned in one of several ways depending on the option flags; the structure may parsed by the program and printed in a readable format or the raw buffer may be printed to stdout for another program to parse.

OPTIONS

-n <nsid>
--namespace-id=<nsid>

Retrieve the Error Log for the given nsid. This is optional and its success may depend on the device’s capabilities to provide this log on a per-namespace basis (see the NVMe Identify Controller for this capability). The default nsid to use is 0xffffffff for the device global error log.

-e <entries>
--log-entries=<entries>

Specifies how many log entries the program should request from the device. This must be at least one, and shouldn’t exceed the device’s capabilities. Defaults to 64 log entries.

-b
--raw-binary

Print the raw error log buffer to stdout.

EXAMPLES

  • Get the error log and print it in a human readable format:

    # nvme error-log /dev/nvme0
  • Print the raw output to a file:

    # nvme error-log /dev/nvme0 --raw-binary > error_log.raw

    It is probably a bad idea to not redirect stdout when using this mode.

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-error-log.txt000066400000000000000000000034121267263733400213320ustar00rootroot00000000000000nvme-error-log(1) ================= NAME ---- nvme-error-log - Send NVME Error log page request, return result and log SYNOPSIS -------- [verse] 'nvme error-log' [--namespace-id= | -n ] [--log-entries= | -e ] [--raw-binary | -b] DESCRIPTION ----------- Retrieves NVMe Error log page from an NVMe device and provides the retuned structure. The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1). On success, the returned error log structure may be returned in one of several ways depending on the option flags; the structure may parsed by the program and printed in a readable format or the raw buffer may be printed to stdout for another program to parse. OPTIONS ------- -n :: --namespace-id=:: Retrieve the Error Log for the given nsid. This is optional and its success may depend on the device's capabilities to provide this log on a per-namespace basis (see the NVMe Identify Controller for this capability). The default nsid to use is 0xffffffff for the device global error log. -e :: --log-entries=:: Specifies how many log entries the program should request from the device. This must be at least one, and shouldn't exceed the device's capabilities. Defaults to 64 log entries. -b:: --raw-binary:: Print the raw error log buffer to stdout. EXAMPLES -------- * Get the error log and print it in a human readable format: + ------------ # nvme error-log /dev/nvme0 ------------ + * Print the raw output to a file: + ------------ # nvme error-log /dev/nvme0 --raw-binary > error_log.raw ------------ + It is probably a bad idea to not redirect stdout when using this mode. NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-flush.1000066400000000000000000000036171267263733400200730ustar00rootroot00000000000000'\" t .\" Title: nvme-flush .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 02/26/2016 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-FLUSH" "1" "02/26/2016" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-flush \- Flush command\&. .SH "SYNOPSIS" .sp .nf \fInvme flush\fR [\-\-namespace\-id= | \-n ] .fi .SH "DESCRIPTION" .sp The Flush command shall commit data and metadata associated with the specified namespace(s) to nonvolatile media\&. The flush applies to all commands completed prior to the submission of the Flush command\&. The controller may also flush additional data and/or metadata from any namespace\&. .SH "OPTIONS" .PP \-n , \-\-namespace\-id= .RS 4 Specify the optional namespace id for this command\&. Defaults to 0xffffffff, indicating flush for all namespaces\&. .RE .SH "EXAMPLES" .sp No examples yet\&. .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-flush.html000066400000000000000000000432141267263733400206740ustar00rootroot00000000000000 nvme-flush(1)

SYNOPSIS

nvme flush <device> [--namespace-id=<nsid> | -n <nsid>]

DESCRIPTION

The Flush command shall commit data and metadata associated with the specified namespace(s) to nonvolatile media. The flush applies to all commands completed prior to the submission of the Flush command. The controller may also flush additional data and/or metadata from any namespace.

OPTIONS

-n <nsid>
--namespace-id=<nsid>

Specify the optional namespace id for this command. Defaults to 0xffffffff, indicating flush for all namespaces.

EXAMPLES

No examples yet.

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-flush.txt000066400000000000000000000013021267263733400205370ustar00rootroot00000000000000nvme-flush(1) ============= NAME ---- nvme-flush - Flush command. SYNOPSIS -------- [verse] 'nvme flush' [--namespace-id= | -n ] DESCRIPTION ----------- The Flush command shall commit data and metadata associated with the specified namespace(s) to nonvolatile media. The flush applies to all commands completed prior to the submission of the Flush command. The controller may also flush additional data and/or metadata from any namespace. OPTIONS ------- -n :: --namespace-id=:: Specify the optional namespace id for this command. Defaults to 0xffffffff, indicating flush for all namespaces. EXAMPLES -------- No examples yet. NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-format.1000066400000000000000000000132621267263733400202370ustar00rootroot00000000000000'\" t .\" Title: nvme-format .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 02/26/2016 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-FORMAT" "1" "02/26/2016" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-format \- Format an NVMe device .SH "SYNOPSIS" .sp .nf \fInvme format\fR [\-\-namespace\-id= | \-n ] [\-\-lbaf= | \-l ] [\-\-ses= | \-s ] [\-\-pil= | \-p ] [\-\-pi= | \-i ] [\-\-ms= | \-m ] .fi .SH "DESCRIPTION" .sp For the NVMe device given, send an nvme Format Namespace admin command and provides the results\&. .sp The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1)\&. If the character device is given, the namespace identifier will default to 0xffffffff to send the format to all namespace, but can be overridden to any namespace with the \fInamespace\-id\fR option\&. If the block device is given, the namespace identifier will default to the namespace id of the block device given, but can be overridden with the same option\&. .sp On success, the program will automatically issue BLKRRPART ioctl to force rescanning the namespaces\&. If the driver is recent enough, this will automatically update the physical block size\&. If it is not recent enough, you will need to remove and rescan your device some other way for the new block size to be visible\&. .SH "OPTIONS" .PP \-n , \-\-namespace\-id= .RS 4 Send the format command for the specified nsid\&. This can be used to override the default value for either character device (0xffffffff) or the block device (result from NVME_IOCTL_ID)\&. .RE .PP \-l , \-\-lbaf= .RS 4 LBA Format: This field specifies the LBA format to apply to the NVM media\&. This corresponds to the LBA formats indicated in the Identify Namespace command\&. Defaults to 0\&. .RE .PP \-s , \-\-ses= .RS 4 Secure Erase Settings: This field specifies whether a secure erase should be performed as part of the format and the type of the secure erase operation\&. The erase applies to all user data, regardless of location (e\&.g\&., within an exposed LBA, within a cache, within deallocated LBAs, etc)\&. Defaults to 0\&. .TS allbox tab(:); lt lt lt lt lt lt lt lt lt lt. T{ Value T}:T{ Definition T} T{ 0 T}:T{ No secure erase operation requested T} T{ 1 T}:T{ User Data Erase: All user data shall be erased, contents of the user data after the erase is indeterminate (e\&.g\&., the user data may be zero filled, one filled, etc)\&. The controller may perform a cryptographic erase when a User Data Erase is requested if all user data is encrypted\&. T} T{ 2 T}:T{ Cryptographic Erase: All user data shall be erased cryptographically\&. This is accomplished by deleting the encryption key\&. T} T{ 3\(en7 T}:T{ Reserved T} .TE .sp 1 .RE .PP \-p , \-\-pil= .RS 4 Protection Information Location: If set to \(oq1\(cq and protection information is enabled, then protection information is transferred as the first eight bytes of metadata\&. If cleared to \(oq0\(cq and protection information is enabled, then protection information is transferred as the last eight bytes of metadata\&. Defaults to 0\&. .RE .PP \-i , \-\-pi= .RS 4 Protection Information: This field specifies whether end\-to\-end data protection is enabled and the type of protection information\&. Defaults to 0\&. .TS allbox tab(:); lt lt lt lt lt lt lt lt lt lt lt lt. T{ Value T}:T{ Definition T} T{ 0 T}:T{ Protection information is not enabled T} T{ 1 T}:T{ Protection information is enabled, Type 1 T} T{ 2 T}:T{ Protection information is enabled, Type 2 T} T{ 3 T}:T{ Protection information is enabled, Type 3 T} T{ 4\(en7 T}:T{ Reserved T} .TE .sp 1 .RE .PP \-m , \-\-ms= .RS 4 Metadata Settings: This field is set to \(oq1\(cq if the metadata is transferred as part of an extended data LBA\&. This field is cleared to \(oq0\(cq if the metadata is transferred as part of a separate buffer\&. The metadata may include protection information, based on the Protection Information (PI) field\&. Defaults to 0\&. .RE .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Format the device using all defaults: .sp .if n \{\ .RS 4 .\} .nf # nvme format /dev/nvme0n1 .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Format namespace 1 with user data secure erase settings and protection information: .sp .if n \{\ .RS 4 .\} .nf # nvme format /dev/nvme0 \-\-namespace\-id=1 \-\-ses=1 \-\-pi=1 .fi .if n \{\ .RE .\} .RE .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-format.html000066400000000000000000000570101267263733400210420ustar00rootroot00000000000000 nvme-format(1)

SYNOPSIS

nvme format <device> [--namespace-id=<nsid> | -n <nsid>]
                    [--lbaf=<lbaf> | -l <lbaf>]
                    [--ses=<ses> | -s <ses>]
                    [--pil=<pil> | -p <pil>]
                    [--pi=<pi> | -i <pi>]
                    [--ms=<ms> | -m <ms>]

DESCRIPTION

For the NVMe device given, send an nvme Format Namespace admin command and provides the results.

The <device> parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1). If the character device is given, the namespace identifier will default to 0xffffffff to send the format to all namespace, but can be overridden to any namespace with the namespace-id option. If the block device is given, the namespace identifier will default to the namespace id of the block device given, but can be overridden with the same option.

On success, the program will automatically issue BLKRRPART ioctl to force rescanning the namespaces. If the driver is recent enough, this will automatically update the physical block size. If it is not recent enough, you will need to remove and rescan your device some other way for the new block size to be visible.

OPTIONS

-n <nsid>
--namespace-id=<nsid>

Send the format command for the specified nsid. This can be used to override the default value for either character device (0xffffffff) or the block device (result from NVME_IOCTL_ID).

-l <lbaf>
--lbaf=<lbaf>

LBA Format: This field specifies the LBA format to apply to the NVM media. This corresponds to the LBA formats indicated in the Identify Namespace command. Defaults to 0.

-s <ses>
--ses=<ses>

Secure Erase Settings: This field specifies whether a secure erase should be performed as part of the format and the type of the secure erase operation. The erase applies to all user data, regardless of location (e.g., within an exposed LBA, within a cache, within deallocated LBAs, etc). Defaults to 0.

Value

Definition

0

No secure erase operation requested

1

User Data Erase: All user data shall be erased, contents of the user data after the erase is indeterminate (e.g., the user data may be zero filled, one filled, etc). The controller may perform a cryptographic erase when a User Data Erase is requested if all user data is encrypted.

2

Cryptographic Erase: All user data shall be erased cryptographically. This is accomplished by deleting the encryption key.

3–7

Reserved

-p <pil>
--pil=<pil>

Protection Information Location: If set to ‘1’ and protection information is enabled, then protection information is transferred as the first eight bytes of metadata. If cleared to ‘0’ and protection information is enabled, then protection information is transferred as the last eight bytes of metadata. Defaults to 0.

-i <pi>
--pi=<pi>

Protection Information: This field specifies whether end-to-end data protection is enabled and the type of protection information. Defaults to 0.

Value

Definition

0

Protection information is not enabled

1

Protection information is enabled, Type 1

2

Protection information is enabled, Type 2

3

Protection information is enabled, Type 3

4–7

Reserved

-m <ms>
--ms=<ms>

Metadata Settings: This field is set to ‘1’ if the metadata is transferred as part of an extended data LBA. This field is cleared to ‘0’ if the metadata is transferred as part of a separate buffer. The metadata may include protection information, based on the Protection Information (PI) field. Defaults to 0.

EXAMPLES

  • Format the device using all defaults:

    # nvme format /dev/nvme0n1
  • Format namespace 1 with user data secure erase settings and protection information:

    # nvme format /dev/nvme0 --namespace-id=1 --ses=1 --pi=1

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-format.txt000066400000000000000000000076621267263733400207250ustar00rootroot00000000000000nvme-format(1) ============== NAME ---- nvme-format - Format an NVMe device SYNOPSIS -------- [verse] 'nvme format' [--namespace-id= | -n ] [--lbaf= | -l ] [--ses= | -s ] [--pil= | -p ] [--pi= | -i ] [--ms= | -m ] DESCRIPTION ----------- For the NVMe device given, send an nvme Format Namespace admin command and provides the results. The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1). If the character device is given, the namespace identifier will default to 0xffffffff to send the format to all namespace, but can be overridden to any namespace with the 'namespace-id' option. If the block device is given, the namespace identifier will default to the namespace id of the block device given, but can be overridden with the same option. On success, the program will automatically issue BLKRRPART ioctl to force rescanning the namespaces. If the driver is recent enough, this will automatically update the physical block size. If it is not recent enough, you will need to remove and rescan your device some other way for the new block size to be visible. OPTIONS ------- -n :: --namespace-id=:: Send the format command for the specified nsid. This can be used to override the default value for either character device (0xffffffff) or the block device (result from NVME_IOCTL_ID). -l :: --lbaf=:: LBA Format: This field specifies the LBA format to apply to the NVM media. This corresponds to the LBA formats indicated in the Identify Namespace command. Defaults to 0. -s :: --ses=:: Secure Erase Settings: This field specifies whether a secure erase should be performed as part of the format and the type of the secure erase operation. The erase applies to all user data, regardless of location (e.g., within an exposed LBA, within a cache, within deallocated LBAs, etc). Defaults to 0. + [] |================= |Value|Definition |0|No secure erase operation requested |1|User Data Erase: All user data shall be erased, contents of the user data after the erase is indeterminate (e.g., the user data may be zero filled, one filled, etc). The controller may perform a cryptographic erase when a User Data Erase is requested if all user data is encrypted. |2|Cryptographic Erase: All user data shall be erased cryptographically. This is accomplished by deleting the encryption key. |3–7|Reserved |================= -p :: --pil=:: Protection Information Location: If set to ‘1’ and protection information is enabled, then protection information is transferred as the first eight bytes of metadata. If cleared to ‘0’ and protection information is enabled, then protection information is transferred as the last eight bytes of metadata. Defaults to 0. -i :: --pi=:: Protection Information: This field specifies whether end-to-end data protection is enabled and the type of protection information. Defaults to 0. + [] |================= |Value|Definition |0|Protection information is not enabled |1|Protection information is enabled, Type 1 |2|Protection information is enabled, Type 2 |3|Protection information is enabled, Type 3 |4–7|Reserved |================= -m :: --ms=:: Metadata Settings: This field is set to ‘1’ if the metadata is transferred as part of an extended data LBA. This field is cleared to ‘0’ if the metadata is transferred as part of a separate buffer. The metadata may include protection information, based on the Protection Information (PI) field. Defaults to 0. EXAMPLES -------- * Format the device using all defaults: + ------------ # nvme format /dev/nvme0n1 ------------ + * Format namespace 1 with user data secure erase settings and protection information: + ------------ # nvme format /dev/nvme0 --namespace-id=1 --ses=1 --pi=1 ------------ NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-fw-activate.1000066400000000000000000000074631267263733400211670ustar00rootroot00000000000000'\" t .\" Title: nvme-fw-activate .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/08/2015 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-FW\-ACTIVATE" "1" "06/08/2015" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-fw-activate \- Used to verify and commit a firmware image\&. .SH "SYNOPSIS" .sp .nf \fInvme fw\-activate\fR [\-\-slot= | \-s ] [\-\-action= | \-a ] .fi .SH "DESCRIPTION" .sp For the NVMe device given, send an nvme Firmware Activate admin command and provides the results\&. .sp The Firmware Activate command is used to verify that a valid firmware image has been downloaded and to commit that revision to a specific firmware slot\&. The host may select the firmware image to activate on the next controller reset (CC\&.EN transitions from \(oq1\(cq to \(oq0\(cq, a PCI function level reset, and/or other Controller or NVM Subsystem Reset) as part of this command\&. The currently executing firmware revision may be determined from the Firmware Revision field of the Identify Controller data structure as indicated in the Firmware Slot Information log page\&. .sp No further action is automatically taken to reset the device, which is usually required to complete the activation process\&. If your kernel and driver are recent enough, you can activate the firmware by issuing a reset through Linux sysfs, for example: .sp .if n \{\ .RS 4 .\} .nf # echo 1 > /sys/class/misc/nvme0/device/reset .fi .if n \{\ .RE .\} .sp If your kernel is not recent enough, you will need to remove and add the device some other way\&. .SH "OPTIONS" .PP \-a , \-\-action= .RS 4 Activate Action: This field specifies the action that is taken on the image downloaded with the Firmware Image Download command or on a previously downloaded and placed image\&. .TS allbox tab(:); lt lt lt lt lt lt lt lt lt lt. T{ Value T}:T{ Definition T} T{ 0 T}:T{ Downloaded image replaces the image indicated by the Firmware Slot field\&. This image is not activated\&. T} T{ 1 T}:T{ Downloaded image replaces the image indicated by the Firmware Slot field\&. This image is activated at the next reset\&. T} T{ 2 T}:T{ The image indicated by the Firmware Slot field is activated at the next reset\&. T} T{ 3 T}:T{ Reserved\&. T} .TE .sp 1 .RE .PP \-s , \-\-slot= .RS 4 Firmware Slot: Specifies the firmware slot that shall be used for the Activate Action, if applicable\&. If the value specified is 0h, then the controller shall choose the firmware slot (slot 1 \(en 7) to use for the operation\&. .RE .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Activate the last downloaded fw to slot 1\&. .sp .if n \{\ .RS 4 .\} .nf # nvme fw\-activate /dev/nvme0 \-\-slot=1 \-\-action=2 .fi .if n \{\ .RE .\} .RE .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-fw-activate.html000066400000000000000000000507331267263733400217710ustar00rootroot00000000000000 nvme-fw-activate(1)

SYNOPSIS

nvme fw-activate <device> [--slot=<slot> | -s <slot>]
                    [--action=<action> | -a <action>]

DESCRIPTION

For the NVMe device given, send an nvme Firmware Activate admin command and provides the results.

The Firmware Activate command is used to verify that a valid firmware image has been downloaded and to commit that revision to a specific firmware slot. The host may select the firmware image to activate on the next controller reset (CC.EN transitions from ‘1’ to ‘0’, a PCI function level reset, and/or other Controller or NVM Subsystem Reset) as part of this command. The currently executing firmware revision may be determined from the Firmware Revision field of the Identify Controller data structure as indicated in the Firmware Slot Information log page.

No further action is automatically taken to reset the device, which is usually required to complete the activation process. If your kernel and driver are recent enough, you can activate the firmware by issuing a reset through Linux sysfs, for example:

 # echo 1 > /sys/class/misc/nvme0/device/reset

If your kernel is not recent enough, you will need to remove and add the device some other way.

OPTIONS

-a <action>
--action=<action>

Activate Action: This field specifies the action that is taken on the image downloaded with the Firmware Image Download command or on a previously downloaded and placed image.

Value

Definition

0

Downloaded image replaces the image indicated by the Firmware Slot field. This image is not activated.

1

Downloaded image replaces the image indicated by the Firmware Slot field. This image is activated at the next reset.

2

The image indicated by the Firmware Slot field is activated at the next reset.

3

Reserved.

-s <slot>
--slot=<slot>

Firmware Slot: Specifies the firmware slot that shall be used for the Activate Action, if applicable. If the value specified is 0h, then the controller shall choose the firmware slot (slot 1 – 7) to use for the operation.

EXAMPLES

  • Activate the last downloaded fw to slot 1.

    # nvme fw-activate /dev/nvme0 --slot=1 --action=2

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-fw-activate.txt000066400000000000000000000045451267263733400216440ustar00rootroot00000000000000nvme-fw-activate(1) =================== NAME ---- nvme-fw-activate - Used to verify and commit a firmware image. SYNOPSIS -------- [verse] 'nvme fw-activate' [--slot= | -s ] [--action= | -a ] DESCRIPTION ----------- For the NVMe device given, send an nvme Firmware Activate admin command and provides the results. The Firmware Activate command is used to verify that a valid firmware image has been downloaded and to commit that revision to a specific firmware slot. The host may select the firmware image to activate on the next controller reset (CC.EN transitions from ‘1’ to ‘0’, a PCI function level reset, and/or other Controller or NVM Subsystem Reset) as part of this command. The currently executing firmware revision may be determined from the Firmware Revision field of the Identify Controller data structure as indicated in the Firmware Slot Information log page. No further action is automatically taken to reset the device, which is usually required to complete the activation process. If your kernel and driver are recent enough, you can activate the firmware by issuing a reset through Linux sysfs, for example: ------------ # echo 1 > /sys/class/misc/nvme0/device/reset ------------ If your kernel is not recent enough, you will need to remove and add the device some other way. OPTIONS ------- -a :: --action=:: Activate Action: This field specifies the action that is taken on the image downloaded with the Firmware Image Download command or on a previously downloaded and placed image. + [] |================= |Value|Definition |0|Downloaded image replaces the image indicated by the Firmware Slot field. This image is not activated. |1|Downloaded image replaces the image indicated by the Firmware Slot field. This image is activated at the next reset. |2|The image indicated by the Firmware Slot field is activated at the next reset. |3|Reserved. |================= -s :: --slot=:: Firmware Slot: Specifies the firmware slot that shall be used for the Activate Action, if applicable. If the value specified is 0h, then the controller shall choose the firmware slot (slot 1 – 7) to use for the operation. EXAMPLES -------- * Activate the last downloaded fw to slot 1. + ------------ # nvme fw-activate /dev/nvme0 --slot=1 --action=2 ------------ NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-fw-download.1000066400000000000000000000071101267263733400211630ustar00rootroot00000000000000'\" t .\" Title: nvme-fw-download .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/08/2015 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-FW\-DOWNLOAD" "1" "06/08/2015" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-fw-download \- Download all or a portion of an nvme firmware image\&. .SH "SYNOPSIS" .sp .nf \fInvme fw\-download\fR [\-\-fw= | \-f ] [\-\-xfer= | \-x ] [\-\-offset= | \-o ] .fi .SH "DESCRIPTION" .sp The Firmware Image Download command is used to download all or a portion of the firmware image for a future update to the controller\&. The Firmware Image Download command may be submitted while other commands on the Admin Submission Queue or I/O Submission Queues are outstanding\&. The Firmware Image Download command copies the new firmware image (in whole or in part) to the controller\&. .sp The firmware image may be constructed of multiple pieces that are individually downloaded with separate Firmware Image Download commands\&. Each Firmware Image Download command includes a Dword Offset and Number of Dwords that specify a Dword range\&. The host software shall ensure that firmware pieces do not have Dword ranges that overlap\&. Firmware portions may be submitted out of order to the controller\&. .sp The new firmware image is not applied as part of the Firmware Image Download command\&. It is applied following a reset, where the image to apply and the firmware slot it should be committed to is specified with the Firmware Activate command\&. .SH "OPTIONS" .PP \-f , \-\-fw= .RS 4 Required argument\&. This specifies the path to the device\(cqs firmware file on your system that will be read by the program and sent to the device\&. .RE .PP \-x , \-\-xfer= .RS 4 This specifies the size to split each transfer\&. This is useful if the device has a max transfer size requirement for firmware\&. It defaults to 4k\&. .RE .PP \-o , \-\-offset= .RS 4 This specifies the starting offset in dwords\&. This is really only useful if your firmware is split in multiple files; otherwise the offset starts at zero and automatically adjusts based on the \fIxfer\fR size given\&. .RE .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Transfer a firmware size 128KiB at a time: .sp .if n \{\ .RS 4 .\} .nf # nvme fw\-download /dev/nvme0 \-\-fw=/path/to/nvme\&.fw \-\-xfer=0x20000 .fi .if n \{\ .RE .\} .RE .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-fw-download.html000066400000000000000000000471351267263733400220020ustar00rootroot00000000000000 nvme-fw-download(1)

SYNOPSIS

nvme fw-download <device> [--fw=<firmware-file> | -f <firmware-file>]
                    [--xfer=<transfer-size> | -x <transfer-size>]
                    [--offset=<offset> | -o <offset>]

DESCRIPTION

The Firmware Image Download command is used to download all or a portion of the firmware image for a future update to the controller. The Firmware Image Download command may be submitted while other commands on the Admin Submission Queue or I/O Submission Queues are outstanding. The Firmware Image Download command copies the new firmware image (in whole or in part) to the controller.

The firmware image may be constructed of multiple pieces that are individually downloaded with separate Firmware Image Download commands. Each Firmware Image Download command includes a Dword Offset and Number of Dwords that specify a Dword range. The host software shall ensure that firmware pieces do not have Dword ranges that overlap. Firmware portions may be submitted out of order to the controller.

The new firmware image is not applied as part of the Firmware Image Download command. It is applied following a reset, where the image to apply and the firmware slot it should be committed to is specified with the Firmware Activate command.

OPTIONS

-f <firmware-file>
--fw=<firmeware-file>

Required argument. This specifies the path to the device’s firmware file on your system that will be read by the program and sent to the device.

-x <transfer-size>
--xfer=<transfer-size>

This specifies the size to split each transfer. This is useful if the device has a max transfer size requirement for firmware. It defaults to 4k.

-o <offset>
--offset=<offset>

This specifies the starting offset in dwords. This is really only useful if your firmware is split in multiple files; otherwise the offset starts at zero and automatically adjusts based on the xfer size given.

EXAMPLES

  • Transfer a firmware size 128KiB at a time:

    # nvme fw-download /dev/nvme0 --fw=/path/to/nvme.fw --xfer=0x20000

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-fw-download.txt000066400000000000000000000042661267263733400216530ustar00rootroot00000000000000nvme-fw-download(1) =================== NAME ---- nvme-fw-download - Download all or a portion of an nvme firmware image. SYNOPSIS -------- [verse] 'nvme fw-download' [--fw= | -f ] [--xfer= | -x ] [--offset= | -o ] DESCRIPTION ----------- The Firmware Image Download command is used to download all or a portion of the firmware image for a future update to the controller. The Firmware Image Download command may be submitted while other commands on the Admin Submission Queue or I/O Submission Queues are outstanding. The Firmware Image Download command copies the new firmware image (in whole or in part) to the controller. The firmware image may be constructed of multiple pieces that are individually downloaded with separate Firmware Image Download commands. Each Firmware Image Download command includes a Dword Offset and Number of Dwords that specify a Dword range. The host software shall ensure that firmware pieces do not have Dword ranges that overlap. Firmware portions may be submitted out of order to the controller. The new firmware image is not applied as part of the Firmware Image Download command. It is applied following a reset, where the image to apply and the firmware slot it should be committed to is specified with the Firmware Activate command. OPTIONS ------- -f :: --fw=:: Required argument. This specifies the path to the device's firmware file on your system that will be read by the program and sent to the device. -x :: --xfer=:: This specifies the size to split each transfer. This is useful if the device has a max transfer size requirement for firmware. It defaults to 4k. -o :: --offset=:: This specifies the starting offset in dwords. This is really only useful if your firmware is split in multiple files; otherwise the offset starts at zero and automatically adjusts based on the 'xfer' size given. EXAMPLES -------- * Transfer a firmware size 128KiB at a time: + ------------ # nvme fw-download /dev/nvme0 --fw=/path/to/nvme.fw --xfer=0x20000 ------------ NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-fw-log.1000066400000000000000000000050311267263733400201350ustar00rootroot00000000000000'\" t .\" Title: nvme-fw-log .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/08/2015 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-FW\-LOG" "1" "06/08/2015" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-fw-log \- Send NVMe Firmware log page request, returns result and log .SH "SYNOPSIS" .sp .nf \fInvme fw\-log\fR [\-\-raw\-binary | \-b] .fi .SH "DESCRIPTION" .sp Retrieves the NVMe Firmware log page from an NVMe device and provides the retuned structure\&. .sp The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1)\&. .sp On success, the returned f/w log structure may be returned in one of several ways depending on the option flags; the structure may parsed by the program and printed in a readable format or the raw buffer may be printed to stdout for another program to parse\&. .SH "OPTIONS" .PP \-b, \-\-raw\-binary .RS 4 Print the raw fw log buffer to stdout\&. .RE .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Print the firmware log page in a human readable format: .sp .if n \{\ .RS 4 .\} .nf # nvme fw\-log /dev/nvme0 .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Print the log firmware to a file: .sp .if n \{\ .RS 4 .\} .nf # nvme fw\-log /dev/nvme0 \-\-raw\-binary > fw_log\&.raw .fi .if n \{\ .RE .\} .sp It is probably a bad idea to not redirect stdout when using this mode\&. .RE .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-fw-log.html000066400000000000000000000444721267263733400207550ustar00rootroot00000000000000 nvme-fw-log(1)

SYNOPSIS

nvme fw-log <device> [--raw-binary | -b]

DESCRIPTION

Retrieves the NVMe Firmware log page from an NVMe device and provides the retuned structure.

The <device> parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1).

On success, the returned f/w log structure may be returned in one of several ways depending on the option flags; the structure may parsed by the program and printed in a readable format or the raw buffer may be printed to stdout for another program to parse.

OPTIONS

-b
--raw-binary

Print the raw fw log buffer to stdout.

EXAMPLES

  • Print the firmware log page in a human readable format:

    # nvme fw-log /dev/nvme0
  • Print the log firmware to a file:

    # nvme fw-log /dev/nvme0 --raw-binary > fw_log.raw

    It is probably a bad idea to not redirect stdout when using this mode.

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-fw-log.txt000066400000000000000000000021731267263733400206200ustar00rootroot00000000000000nvme-fw-log(1) ============== NAME ---- nvme-fw-log - Send NVMe Firmware log page request, returns result and log SYNOPSIS -------- [verse] 'nvme fw-log' [--raw-binary | -b] DESCRIPTION ----------- Retrieves the NVMe Firmware log page from an NVMe device and provides the retuned structure. The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1). On success, the returned f/w log structure may be returned in one of several ways depending on the option flags; the structure may parsed by the program and printed in a readable format or the raw buffer may be printed to stdout for another program to parse. OPTIONS ------- -b:: --raw-binary:: Print the raw fw log buffer to stdout. EXAMPLES -------- * Print the firmware log page in a human readable format: + ------------ # nvme fw-log /dev/nvme0 ------------ + * Print the log firmware to a file: + ------------ # nvme fw-log /dev/nvme0 --raw-binary > fw_log.raw ------------ + It is probably a bad idea to not redirect stdout when using this mode. NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-get-feature.1000066400000000000000000000114561267263733400211620ustar00rootroot00000000000000'\" t .\" Title: nvme-get-feature .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 02/26/2016 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-GET\-FEATURE" "1" "02/26/2016" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-get-feature \- Gets an NVMe feature, returns applicable results .SH "SYNOPSIS" .sp .nf \fInvme get\-feature\fR [\-\-namespace\-id= | \-n ] [\-\-feature\-id= | \-f ] [\-\-cdw11=] [\-\-data\-len= | \-l ] [\-\-sel=] [\-\-raw\-binary | \-b] .fi .SH "DESCRIPTION" .sp Submits an NVMe Get Feature admin command and returns the applicable results\&. This may be the feature\(cqs value, or may also include a feature structure if the feature requires it (ex: LBA Range Type)\&. .sp The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1)\&. .sp On success, the returned feature\(cqs structure (if applicable) may be returned in one of several ways depending on the option flags; the structure may parsed by the program and printed in a readable format if it is a known structure, displayed in hex, or the raw buffer may be printed to stdout for another program to parse\&. .SH "OPTIONS" .PP \-n , \-\-namespace\-id= .RS 4 Retrieve the feature for the given nsid\&. This is optional and most features do not use this value\&. .RE .PP \-f , \-\-feature\-id= .RS 4 The feature id to send with the command\&. Value provided should be in hex\&. .RE .PP \-s .RS 4 Select (SEL): This field specifies which value of the attributes to return in the provided data: .TS allbox tab(:); lt lt lt lt lt lt lt lt lt lt lt lt. T{ Select T}:T{ Description T} T{ 0 T}:T{ Current T} T{ 1 T}:T{ Default T} T{ 2 T}:T{ Saved T} T{ 3 T}:T{ Supported capabilities T} T{ 4\(en7 T}:T{ Reserved T} .TE .sp 1 .RE .PP \-l , \-\-data\-len= .RS 4 The data length for the buffer returned for this feature\&. Most known features do not use this value\&. The exception is LBA Range Type .RE .PP \-\-cdw11= .RS 4 The value for command dword 11, if applicable\&. Only known feature using this is the interrupt vector configuration feature\&. .RE .PP \-b, \-\-raw\-binary .RS 4 Print the raw feature buffer to stdout if the feature returns a structure\&. .RE .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Retrieves the feature for Number of Queues, or feature id 7: .sp .if n \{\ .RS 4 .\} .nf # nvme get\-feature /dev/nvme0 \-f 7 .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The following retrieves the feature for the LBA Range Type, which implicitly requires a buffer and will be printed to the screen in human readable format: .sp .if n \{\ .RS 4 .\} .nf # nvme get\-feature /dev/nvme0 \-f 3 .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Retrieves the feature for the some vendor specific feature and specifically requesting a buffer be allocate for this feature, which will be displayed to the user in as a hex dump: .sp .if n \{\ .RS 4 .\} .nf # nvme get\-feature /dev/nvme0 \-f 0xc0 \-l 512 .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The following retrieves the feature for the LBA Range Type, which implicitly requires a buffer and will be saved to a file in its raw format: .sp .if n \{\ .RS 4 .\} .nf # nvme get\-feature /dev/nvme0 \-f 3 \-\-raw\-binary > lba_range\&.raw .fi .if n \{\ .RE .\} .sp It is probably a bad idea to not redirect stdout when using this mode\&. .RE .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-get-feature.html000066400000000000000000000534721267263733400217720ustar00rootroot00000000000000 nvme-get-feature(1)

SYNOPSIS

nvme get-feature <device> [--namespace-id=<nsid> | -n <nsid>]
                          [--feature-id=<fid> | -f <fid>] [--cdw11=<cdw11>]
                          [--data-len=<data-len> | -l <data-len>]
                          [--sel=<select> | -s <select>]
                          [--raw-binary | -b]

DESCRIPTION

Submits an NVMe Get Feature admin command and returns the applicable results. This may be the feature’s value, or may also include a feature structure if the feature requires it (ex: LBA Range Type).

The <device> parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1).

On success, the returned feature’s structure (if applicable) may be returned in one of several ways depending on the option flags; the structure may parsed by the program and printed in a readable format if it is a known structure, displayed in hex, or the raw buffer may be printed to stdout for another program to parse.

OPTIONS

-n <nsid>
--namespace-id=<nsid>

Retrieve the feature for the given nsid. This is optional and most features do not use this value.

-f <fid>
--feature-id=<fid>

The feature id to send with the command. Value provided should be in hex.

-s <select>
--sel=<select>

Select (SEL): This field specifies which value of the attributes to return in the provided data:

Select

Description

0

Current

1

Default

2

Saved

3

Supported capabilities

4–7

Reserved

-l <data-len>
--data-len=<data-len>

The data length for the buffer returned for this feature. Most known features do not use this value. The exception is LBA Range Type

--cdw11=<cdw11>

The value for command dword 11, if applicable. Only known feature using this is the interrupt vector configuration feature.

-b
--raw-binary

Print the raw feature buffer to stdout if the feature returns a structure.

EXAMPLES

  • Retrieves the feature for Number of Queues, or feature id 7:

    # nvme get-feature /dev/nvme0 -f 7
  • The following retrieves the feature for the LBA Range Type, which implicitly requires a buffer and will be printed to the screen in human readable format:

    # nvme get-feature /dev/nvme0 -f 3
  • Retrieves the feature for the some vendor specific feature and specifically requesting a buffer be allocate for this feature, which will be displayed to the user in as a hex dump:

    # nvme get-feature /dev/nvme0 -f 0xc0 -l 512
  • The following retrieves the feature for the LBA Range Type, which implicitly requires a buffer and will be saved to a file in its raw format:

    # nvme get-feature /dev/nvme0 -f 3 --raw-binary > lba_range.raw

    It is probably a bad idea to not redirect stdout when using this mode.

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-get-feature.txt000066400000000000000000000056661267263733400216470ustar00rootroot00000000000000nvme-get-feature(1) =================== NAME ---- nvme-get-feature - Gets an NVMe feature, returns applicable results SYNOPSIS -------- [verse] 'nvme get-feature' [--namespace-id= | -n ] [--feature-id= | -f ] [--cdw11=] [--data-len= | -l ] [--sel=] [--raw-binary | -b] DESCRIPTION ----------- Submits an NVMe Get Feature admin command and returns the applicable results. This may be the feature's value, or may also include a feature structure if the feature requires it (ex: LBA Range Type). The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1). On success, the returned feature's structure (if applicable) may be returned in one of several ways depending on the option flags; the structure may parsed by the program and printed in a readable format if it is a known structure, displayed in hex, or the raw buffer may be printed to stdout for another program to parse. OPTIONS ------- -n :: --namespace-id=:: Retrieve the feature for the given nsid. This is optional and most features do not use this value. -f :: --feature-id=:: The feature id to send with the command. Value provided should be in hex. -s :: Select (SEL): This field specifies which value of the attributes to return in the provided data: + [] |================== |Select|Description |0|Current |1|Default |2|Saved |3|Supported capabilities |4–7|Reserved |================== -l :: --data-len=:: The data length for the buffer returned for this feature. Most known features do not use this value. The exception is LBA Range Type --cdw11=:: The value for command dword 11, if applicable. Only known feature using this is the interrupt vector configuration feature. -b:: --raw-binary:: Print the raw feature buffer to stdout if the feature returns a structure. EXAMPLES -------- * Retrieves the feature for Number of Queues, or feature id 7: + ------------ # nvme get-feature /dev/nvme0 -f 7 ------------ + * The following retrieves the feature for the LBA Range Type, which implicitly requires a buffer and will be printed to the screen in human readable format: + ------------ # nvme get-feature /dev/nvme0 -f 3 ------------ + * Retrieves the feature for the some vendor specific feature and specifically requesting a buffer be allocate for this feature, which will be displayed to the user in as a hex dump: + ------------ # nvme get-feature /dev/nvme0 -f 0xc0 -l 512 ------------ + * The following retrieves the feature for the LBA Range Type, which implicitly requires a buffer and will be saved to a file in its raw format: + ------------ # nvme get-feature /dev/nvme0 -f 3 --raw-binary > lba_range.raw ------------ + It is probably a bad idea to not redirect stdout when using this mode. NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-get-log.1000066400000000000000000000070121267263733400203010ustar00rootroot00000000000000'\" t .\" Title: nvme-get-log .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/08/2015 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-GET\-LOG" "1" "06/08/2015" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-get-log \- Retrieves a log page from an NVMe device .SH "SYNOPSIS" .sp .nf \fInvme get\-log\fR [\-\-log\-id= | \-i ] [\-\-log\-len= | \-l ] [\-\-namespace\-id= | \-n ] [\-\-raw\-binary | \-b] .fi .SH "DESCRIPTION" .sp Retrieves an arbitrary NVMe log page from an NVMe device and provides the retuned structure\&. .sp The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1)\&. .sp On success, the returned log structure may be returned in one of several ways depending on the option flags; the structure may be displayed in hex by the program or the raw buffer may be printed to stdout for another program to parse\&. .SH "OPTIONS" .PP \-l , \-\-log\-len= .RS 4 Allocates a buffer of bytes size and requests this many bytes be returned in the constructed NVMe command\&. This param is mandatory\&. .RE .PP \-i , \-\-log\-id= .RS 4 Sets the commands requested log\-id to \&. Defaults to 0\&. .RE .PP \-n , \-\-namespace\-id= .RS 4 Sets the command\(cqs nsid value to the given nsid\&. Defaults to 0xffffffff if not given\&. This option may not affect anything depending on the log page, which may or may not be specific to a namespace\&. .RE .PP \-b, \-\-raw\-binary .RS 4 Print the raw log buffer to stdout\&. .RE .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Get 512 bytes from log page 2 .sp .if n \{\ .RS 4 .\} .nf # nvme get\-log /dev/nvme0 \-\-log\-id=2 \-\-log\-len=512 .fi .if n \{\ .RE .\} .sp The above example will get log page 2 (SMART), and request 512 bytes\&. On success, the returned log will be dumped in hex and not interpreted by the program\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Have the program return the raw log page in binary: .sp .if n \{\ .RS 4 .\} .nf # nvme get\-log /dev/nvme0 \-log\-id=2 \-\-log\-len=512 \-\-raw\-binary > log_page_2\&.raw # nvme get\-log /dev/nvme0 \-i 2 \-l 512 \-b > log_page_2\&.raw .fi .if n \{\ .RE .\} .sp It is not a good idea to not redirect stdout when using this mode\&. .RE .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-get-log.html000066400000000000000000000471751267263733400211230ustar00rootroot00000000000000 nvme-get-log(1)

SYNOPSIS

nvme get-log <device> [--log-id=<log-id> | -i <log-id>]
                      [--log-len=<log-len> | -l <log-len>]
                      [--namespace-id=<nsid> | -n <nsid>]
                      [--raw-binary | -b]

DESCRIPTION

Retrieves an arbitrary NVMe log page from an NVMe device and provides the retuned structure.

The <device> parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1).

On success, the returned log structure may be returned in one of several ways depending on the option flags; the structure may be displayed in hex by the program or the raw buffer may be printed to stdout for another program to parse.

OPTIONS

-l <log-len>
--log-len=<log-len>

Allocates a buffer of <log-len> bytes size and requests this many bytes be returned in the constructed NVMe command. This param is mandatory.

-i <log-id>
--log-id=<log-id>

Sets the commands requested log-id to <log-id>. Defaults to 0.

-n <nsid>
--namespace-id=<nsid>

Sets the command’s nsid value to the given nsid. Defaults to 0xffffffff if not given. This option may not affect anything depending on the log page, which may or may not be specific to a namespace.

-b
--raw-binary

Print the raw log buffer to stdout.

EXAMPLES

  • Get 512 bytes from log page 2

    # nvme get-log /dev/nvme0 --log-id=2 --log-len=512

    The above example will get log page 2 (SMART), and request 512 bytes. On success, the returned log will be dumped in hex and not interpreted by the program.

  • Have the program return the raw log page in binary:

    # nvme get-log /dev/nvme0 -log-id=2 --log-len=512 --raw-binary > log_page_2.raw
    # nvme get-log /dev/nvme0 -i 2 -l 512 -b > log_page_2.raw

    It is not a good idea to not redirect stdout when using this mode.

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-get-log.txt000066400000000000000000000037371267263733400207720ustar00rootroot00000000000000nvme-get-log(1) =============== NAME ---- nvme-get-log - Retrieves a log page from an NVMe device SYNOPSIS -------- [verse] 'nvme get-log' [--log-id= | -i ] [--log-len= | -l ] [--namespace-id= | -n ] [--raw-binary | -b] DESCRIPTION ----------- Retrieves an arbitrary NVMe log page from an NVMe device and provides the retuned structure. The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1). On success, the returned log structure may be returned in one of several ways depending on the option flags; the structure may be displayed in hex by the program or the raw buffer may be printed to stdout for another program to parse. OPTIONS ------- -l :: --log-len=:: Allocates a buffer of bytes size and requests this many bytes be returned in the constructed NVMe command. This param is mandatory. -i :: --log-id=:: Sets the commands requested log-id to . Defaults to 0. -n :: --namespace-id=:: Sets the command's nsid value to the given nsid. Defaults to 0xffffffff if not given. This option may not affect anything depending on the log page, which may or may not be specific to a namespace. -b:: --raw-binary:: Print the raw log buffer to stdout. EXAMPLES -------- * Get 512 bytes from log page 2 + ------------ # nvme get-log /dev/nvme0 --log-id=2 --log-len=512 ------------ + The above example will get log page 2 (SMART), and request 512 bytes. On success, the returned log will be dumped in hex and not interpreted by the program. * Have the program return the raw log page in binary: + ------------ # nvme get-log /dev/nvme0 -log-id=2 --log-len=512 --raw-binary > log_page_2.raw # nvme get-log /dev/nvme0 -i 2 -l 512 -b > log_page_2.raw ------------ + It is not a good idea to not redirect stdout when using this mode. NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-get-ns-id.1000066400000000000000000000034501267263733400205340ustar00rootroot00000000000000'\" t .\" Title: nvme-get-ns-id .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/08/2015 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-GET\-NS\-ID" "1" "06/08/2015" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-get-ns-id \- Retrieves the namespace ID for an NVMe block device .SH "SYNOPSIS" .sp .nf \fInvme get\-ns\-id\fR .fi .SH "DESCRIPTION" .sp Retrieves the namespace ID for an NVMe block device\&. The param is mandatory and must be an NVMe block device (ex: /dev/nvme0n1)\&. .SH "OPTIONS" .sp None .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Shows the namespace id for the given block device: .sp .if n \{\ .RS 4 .\} .nf # nvme get\-ns\-id /dev/nvme0n1 .fi .if n \{\ .RE .\} .RE .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-get-ns-id.html000066400000000000000000000426611267263733400213470ustar00rootroot00000000000000 nvme-get-ns-id(1)

SYNOPSIS

nvme get-ns-id <device>

DESCRIPTION

Retrieves the namespace ID for an NVMe block device. The <device> param is mandatory and must be an NVMe block device (ex: /dev/nvme0n1).

OPTIONS

None

EXAMPLES

  • Shows the namespace id for the given block device:

    # nvme get-ns-id /dev/nvme0n1

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-get-ns-id.txt000066400000000000000000000010131267263733400212040ustar00rootroot00000000000000nvme-get-ns-id(1) ================= NAME ---- nvme-get-ns-id - Retrieves the namespace ID for an NVMe block device SYNOPSIS -------- [verse] 'nvme get-ns-id' DESCRIPTION ----------- Retrieves the namespace ID for an NVMe block device. The param is mandatory and must be an NVMe block device (ex: /dev/nvme0n1). OPTIONS ------- None EXAMPLES -------- * Shows the namespace id for the given block device: + ------------ # nvme get-ns-id /dev/nvme0n1 ------------ NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-help.1000066400000000000000000000032741267263733400177010ustar00rootroot00000000000000'\" t .\" Title: nvme-help .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/08/2015 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-HELP" "1" "06/08/2015" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-help \- Help information\&. .SH "SYNOPSIS" .sp .nf \fInvme help\fR [] .fi .SH "DESCRIPTION" .sp Provides help information, with detailed information about the given command if provided\&. .SH "OPTIONS" .sp No Options .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Show help for nvme smart log: .sp .if n \{\ .RS 4 .\} .nf # nvme help smart\-log .fi .if n \{\ .RE .\} .sp Not much to it .RE .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-help.html000066400000000000000000000425441267263733400205100ustar00rootroot00000000000000 nvme-help(1)

SYNOPSIS

nvme help [<command>]

DESCRIPTION

Provides help information, with detailed information about the given command if provided.

OPTIONS

No Options

EXAMPLES

  • Show help for nvme smart log:

    # nvme help smart-log

    Not much to it

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-help.txt000066400000000000000000000006431267263733400203550ustar00rootroot00000000000000nvme-help(1) ============= NAME ---- nvme-help - Help information. SYNOPSIS -------- [verse] 'nvme help' [] DESCRIPTION ----------- Provides help information, with detailed information about the given command if provided. OPTIONS ------- No Options EXAMPLES -------- * Show help for nvme smart log: + ------------ # nvme help smart-log ------------ + Not much to it NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-id-ctrl.1000066400000000000000000000107461267263733400203110ustar00rootroot00000000000000'\" t .\" Title: nvme-id-ctrl .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 02/26/2016 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-ID\-CTRL" "1" "02/26/2016" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-id-ctrl \- Send NVMe Identify Controller, return result and structure .SH "SYNOPSIS" .sp .nf \fInvme id\-ctrl\fR [\-v | \-\-vendor\-specific] [\-b | \-\-raw\-binary] .fi .SH "DESCRIPTION" .sp For the NVMe device given, sends an identify controller command and provides the result and returned structure\&. .sp The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1)\&. .sp On success, the structure may be returned in one of several ways depending on the option flags; the structure may be parsed by the program or the raw buffer may be printed to stdout\&. .SH "OPTIONS" .PP \-b, \-\-raw\-binary .RS 4 Print the raw buffer to stdout\&. Structure is not parsed by program\&. This overrides the vendor specific and human readable options\&. .RE .PP \-v, \-\-vendor\-specific .RS 4 In addition to parsing known fields, this option will dump the vendor specific region of the structure in hex with ascii interpretation\&. .RE .PP \-H, \-\-human\-readable .RS 4 This option will parse and format many of the bit fields into human\-readable formats\&. .RE .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Has the program interpret the returned buffer and display the known fields in a human readable format: .sp .if n \{\ .RS 4 .\} .nf # nvme id\-ctrl /dev/nvme0 .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} In addition to showing the known fields, has the program to display the vendor unique field: .sp .if n \{\ .RS 4 .\} .nf # nvme id\-ctrl /dev/nvme0 \-\-vendor\-specific # nvme id\-ctrl /dev/nvme0 \-v .fi .if n \{\ .RE .\} .sp The above will dump the \fIvs\fR buffer in hex since it doesn\(cqt know how to interpret it\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Have the program return the raw structure in binary: .sp .if n \{\ .RS 4 .\} .nf # nvme id\-ctrl /dev/nvme0 \-\-raw\-binary > id_ctrl\&.raw # nvme id\-ctrl /dev/nvme0 \-b > id_ctrl\&.raw .fi .if n \{\ .RE .\} .sp It is probably a bad idea to not redirect stdout when using this mode\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Alternatively you may want to send the data to another program that can parse the raw buffer\&. .sp .if n \{\ .RS 4 .\} .nf # nvme id\-ctrl /dev/nvme0 \-\-raw\-binary | nvme_parse_id_ctrl .fi .if n \{\ .RE .\} .sp The parse program in the above example can be a program that shows the structure in a way you like\&. The following program is such an example that will parse it and can accept the output through a pipe, \*(Aq|\*(Aq, as shown in the above example, or you can \*(Aqcat\*(Aq a saved output buffer to it\&. .RE .sp .if n \{\ .RS 4 .\} .nf /* File: nvme_parse_id_ctrl\&.c */ #include #include #include int main(int argc, char **argv) { unsigned char buf[sizeof(struct nvme_id_ctrl)]; struct nvme_id_ctrl *ctrl = (struct nvme_id_ctrl *)buf; if (read(STDIN_FILENO, buf, sizeof(buf))) return 1; printf("vid : %#x\en", ctrl\->vid); printf("ssvid : %#x\en", ctrl\->ssvid); return 0; } .fi .if n \{\ .RE .\} .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-id-ctrl.html000066400000000000000000000510121267263733400211040ustar00rootroot00000000000000 nvme-id-ctrl(1)

SYNOPSIS

nvme id-ctrl <device> [-v | --vendor-specific] [-b | --raw-binary]

DESCRIPTION

For the NVMe device given, sends an identify controller command and provides the result and returned structure.

The <device> parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1).

On success, the structure may be returned in one of several ways depending on the option flags; the structure may be parsed by the program or the raw buffer may be printed to stdout.

OPTIONS

-b
--raw-binary

Print the raw buffer to stdout. Structure is not parsed by program. This overrides the vendor specific and human readable options.

-v
--vendor-specific

In addition to parsing known fields, this option will dump the vendor specific region of the structure in hex with ascii interpretation.

-H
--human-readable

This option will parse and format many of the bit fields into human-readable formats.

EXAMPLES

  • Has the program interpret the returned buffer and display the known fields in a human readable format:

    # nvme id-ctrl /dev/nvme0
  • In addition to showing the known fields, has the program to display the vendor unique field:

    # nvme id-ctrl /dev/nvme0 --vendor-specific
    # nvme id-ctrl /dev/nvme0 -v

    The above will dump the vs buffer in hex since it doesn’t know how to interpret it.

  • Have the program return the raw structure in binary:

    # nvme id-ctrl /dev/nvme0 --raw-binary > id_ctrl.raw
    # nvme id-ctrl /dev/nvme0 -b > id_ctrl.raw

    It is probably a bad idea to not redirect stdout when using this mode.

  • Alternatively you may want to send the data to another program that can parse the raw buffer.

    # nvme id-ctrl /dev/nvme0 --raw-binary | nvme_parse_id_ctrl

    The parse program in the above example can be a program that shows the structure in a way you like. The following program is such an example that will parse it and can accept the output through a pipe, '|', as shown in the above example, or you can 'cat' a saved output buffer to it.

/* File: nvme_parse_id_ctrl.c */

#include <linux/nvme.h>
#include <stdio.h>
#include <unistd.h>

int main(int argc, char **argv)
{
        unsigned char buf[sizeof(struct nvme_id_ctrl)];
        struct nvme_id_ctrl *ctrl = (struct nvme_id_ctrl *)buf;

        if (read(STDIN_FILENO, buf, sizeof(buf)))
                return 1;

        printf("vid   : %#x\n", ctrl->vid);
        printf("ssvid : %#x\n", ctrl->ssvid);
        return 0;
}

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-id-ctrl.txt000066400000000000000000000053251267263733400207650ustar00rootroot00000000000000nvme-id-ctrl(1) =============== NAME ---- nvme-id-ctrl - Send NVMe Identify Controller, return result and structure SYNOPSIS -------- [verse] 'nvme id-ctrl' [-v | --vendor-specific] [-b | --raw-binary] DESCRIPTION ----------- For the NVMe device given, sends an identify controller command and provides the result and returned structure. The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1). On success, the structure may be returned in one of several ways depending on the option flags; the structure may be parsed by the program or the raw buffer may be printed to stdout. OPTIONS ------- -b:: --raw-binary:: Print the raw buffer to stdout. Structure is not parsed by program. This overrides the vendor specific and human readable options. -v:: --vendor-specific:: In addition to parsing known fields, this option will dump the vendor specific region of the structure in hex with ascii interpretation. -H:: --human-readable:: This option will parse and format many of the bit fields into human-readable formats. EXAMPLES -------- * Has the program interpret the returned buffer and display the known fields in a human readable format: + ------------ # nvme id-ctrl /dev/nvme0 ------------ + * In addition to showing the known fields, has the program to display the vendor unique field: + ------------ # nvme id-ctrl /dev/nvme0 --vendor-specific # nvme id-ctrl /dev/nvme0 -v ------------ + The above will dump the 'vs' buffer in hex since it doesn't know how to interpret it. * Have the program return the raw structure in binary: + ------------ # nvme id-ctrl /dev/nvme0 --raw-binary > id_ctrl.raw # nvme id-ctrl /dev/nvme0 -b > id_ctrl.raw ------------ + It is probably a bad idea to not redirect stdout when using this mode. * Alternatively you may want to send the data to another program that can parse the raw buffer. + ------------ # nvme id-ctrl /dev/nvme0 --raw-binary | nvme_parse_id_ctrl ------------ + The parse program in the above example can be a program that shows the structure in a way you like. The following program is such an example that will parse it and can accept the output through a pipe, `'|'`, as shown in the above example, or you can `'cat'` a saved output buffer to it. ------------ /* File: nvme_parse_id_ctrl.c */ #include #include #include int main(int argc, char **argv) { unsigned char buf[sizeof(struct nvme_id_ctrl)]; struct nvme_id_ctrl *ctrl = (struct nvme_id_ctrl *)buf; if (read(STDIN_FILENO, buf, sizeof(buf))) return 1; printf("vid : %#x\n", ctrl->vid); printf("ssvid : %#x\n", ctrl->ssvid); return 0; } ------------ NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-id-ns.1000066400000000000000000000123651267263733400177640ustar00rootroot00000000000000'\" t .\" Title: nvme-id-ns .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 02/26/2016 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-ID\-NS" "1" "02/26/2016" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-id-ns \- Send NVMe Identify Namespace, return result and structure .SH "SYNOPSIS" .sp .nf \fInvme id\-ns\fR [\-v | \-\-vendor\-specific] [\-b | \-\-raw\-binary] [\-\-namespace\-id= | \-n ] .fi .SH "DESCRIPTION" .sp For the NVMe device given, sends an identify namespace command and provides the result and returned structure\&. .sp The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1)\&. If the character device is given, the \*(Aq\-\-namespace\-id\*(Aq option is mandatory, otherwise it will use the ns\-id of the namespace for the block device you opened\&. For block devices, the ns\-id used can be overridden with the same option\&. .sp On success, the structure may be returned in one of several ways depending on the option flags; the structure may be parsed by the program or the raw buffer may be printed to stdout\&. .SH "OPTIONS" .PP \-n , \-\-namespace\-id= .RS 4 Retrieve the identify namespace structure for the given nsid\&. This is required for the character devices, or overrides the block nsid if given\&. .RE .PP \-b, \-\-raw\-binary .RS 4 Print the raw buffer to stdout\&. Structure is not parsed by program\&. This overrides the vendor specific and human readable options\&. .RE .PP \-v, \-\-vendor\-specific .RS 4 In addition to parsing known fields, this option will dump the vendor specific region of the structure in hex with ascii interpretation\&. .RE .PP \-H, \-\-human\-readable .RS 4 This option will parse and format many of the bit fields into human\-readable formats\&. .RE .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Has the program interpret the returned buffer and display the known fields in a human readable format: .sp .if n \{\ .RS 4 .\} .nf # nvme id\-ns /dev/nvme0n1 .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} If using the character device or overriding namespace id: .sp .if n \{\ .RS 4 .\} .nf # nvme id\-ns /dev/nvme0 \-n 1 # nvme id\-ns /dev/nvme0n1 \-n 1 # nvme id\-ns /dev/nvme0 \-\-namespace\-id=1 .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} In addition to showing the known fields, have the program to display the vendor unique field: .sp .if n \{\ .RS 4 .\} .nf # nvme id\-ns /dev/nvme0n1 \-\-vendor\-specific # nvme id\-ns /dev/nvme0n1 \-v .fi .if n \{\ .RE .\} .sp The above will dump the \*(Aqvs\*(Aq buffer in hex since it doesn\(cqt know how to interpret it\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Have the program return the raw structure in binary: .sp .if n \{\ .RS 4 .\} .nf # nvme id\-ns /dev/nvme0n1 \-\-raw\-binary > id_ns\&.raw # nvme id\-ns /dev/nvme0n1 \-b > id_ns\&.raw .fi .if n \{\ .RE .\} .sp It is probably a bad idea to not redirect stdout when using this mode\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Alternatively you may want to send the data to another program that can parse the raw buffer\&. .sp .if n \{\ .RS 4 .\} .nf # nvme id\-ns /dev/nvme0n1 \-\-raw\-binary | nvme_parse_id_ns .fi .if n \{\ .RE .\} .sp The parse program in the above example can be a program that shows the structure in a way you like\&. The following program is such an example that will parse it and can accept the output through a pipe, \*(Aq|\*(Aq, as shown in the above example, or you can \*(Aqcat\*(Aq a saved output buffer to it\&. .RE .sp .if n \{\ .RS 4 .\} .nf /* File: nvme_parse_id_ns\&.c */ #include #include #include int main(int argc, char **argv) { unsigned char buf[sizeof(struct nvme_id_ns)]; struct nvme_id_ns *ns = (struct nvme_id_ns *)buf; if (read(STDIN_FILENO, buf, sizeof(buf))) return 1; printf("nsze : %#llx\en", ns\->nsze); printf("ncap : %#llx\en", ns\->ncap); return 0; } .fi .if n \{\ .RE .\} .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-id-ns.html000066400000000000000000000525361267263733400205740ustar00rootroot00000000000000 nvme-id-ns(1)

SYNOPSIS

nvme id-ns <device> [-v | --vendor-specific] [-b | --raw-binary]
                    [--namespace-id=<nsid> | -n <nsid>]

DESCRIPTION

For the NVMe device given, sends an identify namespace command and provides the result and returned structure.

The <device> parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1). If the character device is given, the '--namespace-id' option is mandatory, otherwise it will use the ns-id of the namespace for the block device you opened. For block devices, the ns-id used can be overridden with the same option.

On success, the structure may be returned in one of several ways depending on the option flags; the structure may be parsed by the program or the raw buffer may be printed to stdout.

OPTIONS

-n <nsid>
--namespace-id=<nsid>

Retrieve the identify namespace structure for the given nsid. This is required for the character devices, or overrides the block nsid if given.

-b
--raw-binary

Print the raw buffer to stdout. Structure is not parsed by program. This overrides the vendor specific and human readable options.

-v
--vendor-specific

In addition to parsing known fields, this option will dump the vendor specific region of the structure in hex with ascii interpretation.

-H
--human-readable

This option will parse and format many of the bit fields into human-readable formats.

EXAMPLES

  • Has the program interpret the returned buffer and display the known fields in a human readable format:

    # nvme id-ns /dev/nvme0n1
  • If using the character device or overriding namespace id:

    # nvme id-ns /dev/nvme0 -n 1
    # nvme id-ns /dev/nvme0n1 -n 1
    # nvme id-ns /dev/nvme0 --namespace-id=1
  • In addition to showing the known fields, have the program to display the vendor unique field:

    # nvme id-ns /dev/nvme0n1 --vendor-specific
    # nvme id-ns /dev/nvme0n1 -v

    The above will dump the 'vs' buffer in hex since it doesn’t know how to interpret it.

  • Have the program return the raw structure in binary:

    # nvme id-ns /dev/nvme0n1 --raw-binary > id_ns.raw
    # nvme id-ns /dev/nvme0n1 -b > id_ns.raw

    It is probably a bad idea to not redirect stdout when using this mode.

  • Alternatively you may want to send the data to another program that can parse the raw buffer.

    # nvme id-ns /dev/nvme0n1 --raw-binary | nvme_parse_id_ns

    The parse program in the above example can be a program that shows the structure in a way you like. The following program is such an example that will parse it and can accept the output through a pipe, '|', as shown in the above example, or you can 'cat' a saved output buffer to it.

/* File: nvme_parse_id_ns.c */

#include <linux/nvme.h>
#include <stdio.h>
#include <unistd.h>

int main(int argc, char **argv)
{
        unsigned char buf[sizeof(struct nvme_id_ns)];
        struct nvme_id_ns *ns = (struct nvme_id_ns *)buf;

        if (read(STDIN_FILENO, buf, sizeof(buf)))
                return 1;

        printf("nsze : %#llx\n", ns->nsze);
        printf("ncap : %#llx\n", ns->ncap);
        return 0;
}

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-id-ns.txt000066400000000000000000000065071267263733400204440ustar00rootroot00000000000000nvme-id-ns(1) ============= NAME ---- nvme-id-ns - Send NVMe Identify Namespace, return result and structure SYNOPSIS -------- [verse] 'nvme id-ns' [-v | --vendor-specific] [-b | --raw-binary] [--namespace-id= | -n ] DESCRIPTION ----------- For the NVMe device given, sends an identify namespace command and provides the result and returned structure. The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1). If the character device is given, the `'--namespace-id'` option is mandatory, otherwise it will use the ns-id of the namespace for the block device you opened. For block devices, the ns-id used can be overridden with the same option. On success, the structure may be returned in one of several ways depending on the option flags; the structure may be parsed by the program or the raw buffer may be printed to stdout. OPTIONS ------- -n :: --namespace-id=:: Retrieve the identify namespace structure for the given nsid. This is required for the character devices, or overrides the block nsid if given. -b:: --raw-binary:: Print the raw buffer to stdout. Structure is not parsed by program. This overrides the vendor specific and human readable options. -v:: --vendor-specific:: In addition to parsing known fields, this option will dump the vendor specific region of the structure in hex with ascii interpretation. -H:: --human-readable:: This option will parse and format many of the bit fields into human-readable formats. EXAMPLES -------- * Has the program interpret the returned buffer and display the known fields in a human readable format: + ------------ # nvme id-ns /dev/nvme0n1 ------------ + * If using the character device or overriding namespace id: + ------------ # nvme id-ns /dev/nvme0 -n 1 # nvme id-ns /dev/nvme0n1 -n 1 # nvme id-ns /dev/nvme0 --namespace-id=1 ------------ + * In addition to showing the known fields, have the program to display the vendor unique field: + ------------ # nvme id-ns /dev/nvme0n1 --vendor-specific # nvme id-ns /dev/nvme0n1 -v ------------ + The above will dump the \'vs' buffer in hex since it doesn't know how to interpret it. * Have the program return the raw structure in binary: + ------------ # nvme id-ns /dev/nvme0n1 --raw-binary > id_ns.raw # nvme id-ns /dev/nvme0n1 -b > id_ns.raw ------------ + It is probably a bad idea to not redirect stdout when using this mode. * Alternatively you may want to send the data to another program that can parse the raw buffer. + ------------ # nvme id-ns /dev/nvme0n1 --raw-binary | nvme_parse_id_ns ------------ + The parse program in the above example can be a program that shows the structure in a way you like. The following program is such an example that will parse it and can accept the output through a pipe, `'|'`, as shown in the above example, or you can `'cat'` a saved output buffer to it. ------------ /* File: nvme_parse_id_ns.c */ #include #include #include int main(int argc, char **argv) { unsigned char buf[sizeof(struct nvme_id_ns)]; struct nvme_id_ns *ns = (struct nvme_id_ns *)buf; if (read(STDIN_FILENO, buf, sizeof(buf))) return 1; printf("nsze : %#llx\n", ns->nsze); printf("ncap : %#llx\n", ns->ncap); return 0; } ------------ NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-io-passthru.1000066400000000000000000000105501267263733400212220ustar00rootroot00000000000000'\" t .\" Title: nvme-io-passthru .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/08/2015 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-IO\-PASSTHRU" "1" "06/08/2015" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-io-passthru \- Submit an arbitrary io command, return results .SH "SYNOPSIS" .sp .nf \fInvme\-io\-passthru\fR [\-\-opcode= | \-o ] [\-\-flags= | \-f ] [\-rsvd= | \-R ] [\-\-namespace\-id= | \-nsid ] [\-\-cdw2=] [\-\-cdw3=] [\-\-cdw10=] [\-\-cdw11=] [\-\-cdw12=] [\-\-cdw13=] [\-\-cdw14=] [\-\-cdw15=] [\-\-data\-len= | \-l ] [\-\-metadata\-len= | \-m ] [\-\-read | \-r ] [\-\-write | \-w] [\-\-input\-file= | \-f ] [\-\-timeout= | \-t ] [\-\-show\-command | \-\-dry\-run | \-s] [\-\-raw\-binary | \-b] .fi .SH "DESCRIPTION" .sp Submits an arbitrary NVMe IO command and returns the applicable results\&. This may be the simply the command\(cqs result and status, or may also include a buffer if the command returns one\&. This command does no interpretation of the opcodes or options\&. .sp The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1)\&. .sp On success, the returned structure (if applicable) may be returned in one of several ways depending on the option flags; the structure may printed by the program as a hex dump, or may be returned as a raw buffer printed to stdout for another program to parse\&. .SH "OPTIONS" .PP \-o , \-\-opcode= .RS 4 The NVMe opcode to send to the device in the command .RE .PP \-f , \-\-flags= .RS 4 The NVMe command flags to send to the device in the command .RE .PP \-R , \-\-rsvd= .RS 4 The value for the reserved field in the command\&. .RE .PP \-n , \-\-namespace\-id= .RS 4 The value for the ns\-id in the command\&. Defaults to \fI0\fR\&. .RE .PP \-\-cdw[2\-3,10\-15]= .RS 4 Specifies the command dword value for that specified entry in the command .RE .PP \-r, \-\-read, \-w, \-\-write .RS 4 Used for the data\-direction for the command and required for commands sending/receiving data\&. Don\(cqt use both read and write at the same time\&. .RE .PP \-i , \-\-input\-file= .RS 4 If the command is a data\-out (write) command, use this file to fill the buffer sent to the device\&. If no file is given, assumed to use STDIN\&. .RE .PP \-l , \-\-data\-len= .RS 4 The data length for the buffer used for this command\&. .RE .PP \-m , \-\-metadata\-len= .RS 4 The metadata length for the buffer used for this command\&. .RE .PP \-s, \-\-show\-cmd .RS 4 Print out the command to be sent\&. .RE .PP \-d, \-\-dry\-run .RS 4 Do not actually send the command\&. .RE .PP \-b, \-\-raw\-binary .RS 4 Print the raw returned buffer to stdout if the command returns data or a structure\&. .RE .SH "EXAMPLES" .sp nvme io\-passthru /dev/nvme0n1 \-\-opcode=2 \-\-namespace\-id=1 \-\-data\-len=4096 \-\-read \-\-cdw10=0 \-\-cdw11=0 \-\-cdw12=0x70000 \-\-raw\-binary .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-io-passthru.html000066400000000000000000000522441267263733400220340ustar00rootroot00000000000000 nvme-io-passthru(1)

SYNOPSIS

nvme-io-passthru <device> [--opcode=<opcode> | -o <opcode>]
                [--flags=<flags> | -f <flags>] [-rsvd=<rsvd> | -R <rsvd>]
                [--namespace-id=<nsid> | -nsid <nsid>]
                [--cdw2=<cdw2>] [--cdw3=<cdw3>] [--cdw10=<cdw10>]
                [--cdw11=<cdw11>] [--cdw12=<cdw12>] [--cdw13=<cdw13>]
                [--cdw14=<cdw14>] [--cdw15=<cdw15>]
                [--data-len=<data-len> | -l <data-len>]
                [--metadata-len=<len> | -m <len>]
                [--read | -r ] [--write | -w]
                [--input-file=<file> | -f <file>]
                [--timeout=<to> | -t <to>]
                [--show-command | --dry-run | -s]
                [--raw-binary | -b]

DESCRIPTION

Submits an arbitrary NVMe IO command and returns the applicable results. This may be the simply the command’s result and status, or may also include a buffer if the command returns one. This command does no interpretation of the opcodes or options.

The <device> parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1).

On success, the returned structure (if applicable) may be returned in one of several ways depending on the option flags; the structure may printed by the program as a hex dump, or may be returned as a raw buffer printed to stdout for another program to parse.

OPTIONS

-o <opcode>
--opcode=<opcode>

The NVMe opcode to send to the device in the command

-f <flags>
--flags=<flags>

The NVMe command flags to send to the device in the command

-R <rsvd>
--rsvd=<rsvd>

The value for the reserved field in the command.

-n <nsid>
--namespace-id=<nsid>

The value for the ns-id in the command. Defaults to 0.

--cdw[2-3,10-15]=<cdw>

Specifies the command dword value for that specified entry in the command

-r
--read
-w
--write

Used for the data-direction for the command and required for commands sending/receiving data. Don’t use both read and write at the same time.

-i <file>
--input-file=<file>

If the command is a data-out (write) command, use this file to fill the buffer sent to the device. If no file is given, assumed to use STDIN.

-l <data-len>
--data-len=<data-len>

The data length for the buffer used for this command.

-m <data-len>
--metadata-len=<data-len>

The metadata length for the buffer used for this command.

-s
--show-cmd

Print out the command to be sent.

-d
--dry-run

Do not actually send the command.

-b
--raw-binary

Print the raw returned buffer to stdout if the command returns data or a structure.

EXAMPLES

nvme io-passthru /dev/nvme0n1 --opcode=2 --namespace-id=1 --data-len=4096 --read --cdw10=0 --cdw11=0 --cdw12=0x70000 --raw-binary

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-io-passthru.txt000066400000000000000000000053601267263733400217040ustar00rootroot00000000000000nvme-io-passthru(1) =================== NAME ---- nvme-io-passthru - Submit an arbitrary io command, return results SYNOPSIS -------- [verse] 'nvme-io-passthru' [--opcode= | -o ] [--flags= | -f ] [-rsvd= | -R ] [--namespace-id= | -nsid ] [--cdw2=] [--cdw3=] [--cdw10=] [--cdw11=] [--cdw12=] [--cdw13=] [--cdw14=] [--cdw15=] [--data-len= | -l ] [--metadata-len= | -m ] [--read | -r ] [--write | -w] [--input-file= | -f ] [--timeout= | -t ] [--show-command | --dry-run | -s] [--raw-binary | -b] DESCRIPTION ----------- Submits an arbitrary NVMe IO command and returns the applicable results. This may be the simply the command's result and status, or may also include a buffer if the command returns one. This command does no interpretation of the opcodes or options. The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1). On success, the returned structure (if applicable) may be returned in one of several ways depending on the option flags; the structure may printed by the program as a hex dump, or may be returned as a raw buffer printed to stdout for another program to parse. OPTIONS ------- -o :: --opcode=:: The NVMe opcode to send to the device in the command -f :: --flags=:: The NVMe command flags to send to the device in the command -R :: --rsvd=:: The value for the reserved field in the command. -n :: --namespace-id=:: The value for the ns-id in the command. Defaults to '0'. --cdw[2-3,10-15]=:: Specifies the command dword value for that specified entry in the command -r:: --read:: -w:: --write:: Used for the data-direction for the command and required for commands sending/receiving data. Don't use both read and write at the same time. -i :: --input-file=:: If the command is a data-out (write) command, use this file to fill the buffer sent to the device. If no file is given, assumed to use STDIN. -l :: --data-len=:: The data length for the buffer used for this command. -m :: --metadata-len=:: The metadata length for the buffer used for this command. -s:: --show-cmd:: Print out the command to be sent. -d:: --dry-run:: Do not actually send the command. -b:: --raw-binary:: Print the raw returned buffer to stdout if the command returns data or a structure. EXAMPLES -------- nvme io-passthru /dev/nvme0n1 --opcode=2 --namespace-id=1 --data-len=4096 --read --cdw10=0 --cdw11=0 --cdw12=0x70000 --raw-binary NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-list-ctrl.1000066400000000000000000000050071267263733400206620ustar00rootroot00000000000000'\" t .\" Title: nvme-id-ns .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 02/26/2016 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-ID\-NS" "1" "02/26/2016" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-list-ctrl \- Send NVMe Identify List Controllers, return result and structure .SH "SYNOPSIS" .sp .nf \fInvme list\-ctrl\fR [\-\-cntid= | \-c ] [\-\-namespace\-id= | \-n ] DESCRIPTION .fi .sp .nf For the NVMe device given, sends an identify command for controller list and provides the result and returned structure\&. This uses either mode 12h or 13h depending on the requested namespace identifier\&. The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1)\&. The starting controller in the list always begins with 0 unless the `\*(Aq\-\-cntid\*(Aq` option is given to override\&. On success, the controller array is printed for each index and controller identifier\&. OPTIONS .fi .PP \-c , \-\-cntid= .RS 4 Retrieve the identify list structure starting with the given controller id\&. .RE .PP \-n , \-\-namespace\-id= .RS 4 If provided, will request the controllers attached to the specified namespace\&. If no namespace is given, or set to 0, the command requests the controller list for the entire subsystem, whether or not they are attached to namespace(s)\&. .RE .SH "EXAMPLES" .sp No examples yet\&. .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-list-ctrl.html000066400000000000000000000443671267263733400215020ustar00rootroot00000000000000 nvme-id-ns(1)

SYNOPSIS

nvme list-ctrl <device> [--cntid=<cntid> | -c <cntid>]
                        [--namespace-id=<nsid> | -n <nsid>]
DESCRIPTION
For the NVMe device given, sends an identify command for controller list
and provides the result and returned structure. This uses either mode
12h or 13h depending on the requested namespace identifier.

The <device> parameter is mandatory and may be either the NVMe character
device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1).
The starting controller in the list always begins with 0 unless the
`'--cntid'` option is given to override.

On success, the controller array is printed for each index and controller
identifier.

OPTIONS
-c <cntid>
--cntid=<cntid>

Retrieve the identify list structure starting with the given controller id.

-n <nsid>
--namespace-id=<nsid>

If provided, will request the controllers attached to the specified namespace. If no namespace is given, or set to 0, the command requests the controller list for the entire subsystem, whether or not they are attached to namespace(s).

EXAMPLES

No examples yet.

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-list-ctrl.txt000066400000000000000000000024121267263733400213360ustar00rootroot00000000000000nvme-id-ns(1) ============= NAME ---- nvme-list-ctrl - Send NVMe Identify List Controllers, return result and structure SYNOPSIS -------- [verse] 'nvme list-ctrl' [--cntid= | -c ] [--namespace-id= | -n ] DESCRIPTION ----------- For the NVMe device given, sends an identify command for controller list and provides the result and returned structure. This uses either mode 12h or 13h depending on the requested namespace identifier. The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1). The starting controller in the list always begins with 0 unless the `'--cntid'` option is given to override. On success, the controller array is printed for each index and controller identifier. OPTIONS ------- -c :: --cntid=:: Retrieve the identify list structure starting with the given controller id. -n :: --namespace-id=:: If provided, will request the controllers attached to the specified namespace. If no namespace is given, or set to 0, the command requests the controller list for the entire subsystem, whether or not they are attached to namespace(s). EXAMPLES -------- No examples yet. NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-list-ns.1000066400000000000000000000041361267263733400203400ustar00rootroot00000000000000'\" t .\" Title: nvme-id-ns .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/08/2015 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-ID\-NS" "1" "06/08/2015" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-list-ns \- Send NVMe Identify List Namespaces, return result and structure .SH "SYNOPSIS" .sp .nf \fInvme list\-ns\fR [\-\-namespace\-id= | \-n ] .fi .SH "DESCRIPTION" .sp For the NVMe device given, sends an identify command for namespace list and provides the result and returned structure\&. .sp The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1)\&. If the starting namespace in the list always begins with 0 unless the \*(Aq\-\-namespace\-id\*(Aq option is given to override\&. .sp On success, the namespace array is printed for each index and nsid for a valid nsid\&. .SH "OPTIONS" .PP \-n , \-\-namespace\-id= .RS 4 Retrieve the identify list structure starting with the given nsid\&. .RE .SH "EXAMPLES" .sp No examples yet\&. .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-list-ns.html000066400000000000000000000436311267263733400211470ustar00rootroot00000000000000 nvme-id-ns(1)

SYNOPSIS

nvme list-ns <device> [--namespace-id=<nsid> | -n <nsid>]

DESCRIPTION

For the NVMe device given, sends an identify command for namespace list and provides the result and returned structure.

The <device> parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1). If the starting namespace in the list always begins with 0 unless the '--namespace-id' option is given to override.

On success, the namespace array is printed for each index and nsid for a valid nsid.

OPTIONS

-n <nsid>
--namespace-id=<nsid>

Retrieve the identify list structure starting with the given nsid.

EXAMPLES

No examples yet.

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-list-ns.txt000066400000000000000000000016011267263733400210110ustar00rootroot00000000000000nvme-id-ns(1) ============= NAME ---- nvme-list-ns - Send NVMe Identify List Namespaces, return result and structure SYNOPSIS -------- [verse] 'nvme list-ns' [--namespace-id= | -n ] DESCRIPTION ----------- For the NVMe device given, sends an identify command for namespace list and provides the result and returned structure. The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1). If the starting namespace in the list always begins with 0 unless the `'--namespace-id'` option is given to override. On success, the namespace array is printed for each index and nsid for a valid nsid. OPTIONS ------- -n :: --namespace-id=:: Retrieve the identify list structure starting with the given nsid. EXAMPLES -------- No examples yet. NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-list.1000066400000000000000000000030771267263733400177250ustar00rootroot00000000000000'\" t .\" Title: nvme-list .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 02/26/2016 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-LIST" "1" "02/26/2016" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-list \- List all recognized NVMe devices .SH "SYNOPSIS" .sp .nf \fInvme list\fR .fi .SH "DESCRIPTION" .sp Scan the sysfs tree for NVM Express devices and return the /dev node for those devices as well as some pertinent information about them\&. .SH "OPTIONS" .sp No options yet\&. .SH "EXAMPLES" .sp No examples yet\&. .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-list.html000066400000000000000000000423171267263733400205310ustar00rootroot00000000000000 nvme-list(1)

SYNOPSIS

nvme list

DESCRIPTION

Scan the sysfs tree for NVM Express devices and return the /dev node for those devices as well as some pertinent information about them.

OPTIONS

No options yet.

EXAMPLES

No examples yet.

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-list.txt000066400000000000000000000006101267263733400203720ustar00rootroot00000000000000nvme-list(1) ============ NAME ---- nvme-list - List all recognized NVMe devices SYNOPSIS -------- [verse] 'nvme list' DESCRIPTION ----------- Scan the sysfs tree for NVM Express devices and return the /dev node for those devices as well as some pertinent information about them. OPTIONS ------- No options yet. EXAMPLES -------- No examples yet. NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-read.1000066400000000000000000000050161267263733400176600ustar00rootroot00000000000000'\" t .\" Title: nvme-read .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 10/21/2015 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-READ" "1" "10/21/2015" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-read \- Send an NVMe Read command, provide results .SH "SYNOPSIS" .sp .nf \fInvme\-read\fR [\-\-start\-block= | \-s ] [\-\-block\-count= | \-c ] [\-\-data\-size= | \-z ] [\-\-metadata\-size= | \-y ] [\-\-ref\-tag= | \-r ] [\-\-data= | \-d ] [\-\-metadata= | \-M ] [\-\-prinfo= | \-p ] [\-\-app\-tag\-mask= | \-m ] [\-\-app\-tag= | \-a ] [\-\-limited\-retry | \-l] [\-\-latency | \-t] [\-\-force\-unit\-access | \-f] .fi .SH "DESCRIPTION" .sp The Read command reads the logical blocks specified by the command from the medium and copies to the data data buffer provided\&. Will use stdout by default if you don\(cqt provide a file\&. .SH "OPTIONS" .PP \-\-start\-block=, \-s .RS 4 Start block\&. .RE .PP \-\-latency, \-t .RS 4 Print out the latency the IOCTL took (in us)\&. .RE .SH "EXAMPLES" .sp No examples yet\&. .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-read.html000066400000000000000000000446271267263733400204770ustar00rootroot00000000000000 nvme-read(1)

SYNOPSIS

nvme-read <device> [--start-block=<slba> | -s <slba>]
                        [--block-count=<nlb> | -c <nlb>]
                        [--data-size=<size> | -z <size>]
                        [--metadata-size=<size> | -y <size>]
                        [--ref-tag=<reftag> | -r <reftag>]
                        [--data=<data-file> | -d <data-file>]
                        [--metadata=<metadata-file> | -M <metadata-file>]
                        [--prinfo=<prinfo> | -p <prinfo>]
                        [--app-tag-mask=<appmask> | -m <appmask>]
                        [--app-tag=<apptag> | -a <apptag>]
                        [--limited-retry | -l]
                        [--latency | -t]
                        [--force-unit-access | -f]

DESCRIPTION

The Read command reads the logical blocks specified by the command from the medium and copies to the data data buffer provided. Will use stdout by default if you don’t provide a file.

OPTIONS

--start-block=<slba>
-s <slba>

Start block.

--latency
-t

Print out the latency the IOCTL took (in us).

EXAMPLES

No examples yet.

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-read.txt000066400000000000000000000020061267263733400203330ustar00rootroot00000000000000nvme-read(1) ============ NAME ---- nvme-read - Send an NVMe Read command, provide results SYNOPSIS -------- [verse] 'nvme-read' [--start-block= | -s ] [--block-count= | -c ] [--data-size= | -z ] [--metadata-size= | -y ] [--ref-tag= | -r ] [--data= | -d ] [--metadata= | -M ] [--prinfo= | -p ] [--app-tag-mask= | -m ] [--app-tag= | -a ] [--limited-retry | -l] [--latency | -t] [--force-unit-access | -f] DESCRIPTION ----------- The Read command reads the logical blocks specified by the command from the medium and copies to the data data buffer provided. Will use stdout by default if you don't provide a file. OPTIONS ------- --start-block=:: -s :: Start block. --latency:: -t:: Print out the latency the IOCTL took (in us). EXAMPLES -------- No examples yet. NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-reset.1000066400000000000000000000033101267263733400200620ustar00rootroot00000000000000'\" t .\" Title: nvme-reset .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 03/17/2016 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-RESET" "1" "03/17/2016" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-reset \- Reset the nvme controller\&. .SH "SYNOPSIS" .sp .nf \fInvme reset\fR .fi .SH "DESCRIPTION" .sp Requests NVMe controller reset\&. The param is mandatory and must be an NVMe character device (ex: /dev/nvme0)\&. .SH "OPTIONS" .sp None .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Resets the controller\&. .sp .if n \{\ .RS 4 .\} .nf # nvme reset /dev/nvme0 .fi .if n \{\ .RE .\} .RE .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-reset.html000066400000000000000000000425221267263733400206760ustar00rootroot00000000000000 nvme-reset(1)

SYNOPSIS

nvme reset <device>

DESCRIPTION

Requests NVMe controller reset. The <device> param is mandatory and must be an NVMe character device (ex: /dev/nvme0).

OPTIONS

None

EXAMPLES

  • Resets the controller.

    # nvme reset /dev/nvme0

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-reset.txt000066400000000000000000000006551267263733400205520ustar00rootroot00000000000000nvme-reset(1) ============= NAME ---- nvme-reset - Reset the nvme controller. SYNOPSIS -------- [verse] 'nvme reset' DESCRIPTION ----------- Requests NVMe controller reset. The param is mandatory and must be an NVMe character device (ex: /dev/nvme0). OPTIONS ------- None EXAMPLES -------- * Resets the controller. + ------------ # nvme reset /dev/nvme0 ------------ NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-resv-acquire.1000066400000000000000000000070421267263733400213540ustar00rootroot00000000000000'\" t .\" Title: nvme-resv-acquire .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/08/2015 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-RESV\-ACQUIRE" "1" "06/08/2015" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-resv-acquire \- Acquire an nvme reservation .SH "SYNOPSIS" .sp .nf \fInvme resv\-acquire\fR .fi .SH "DESCRIPTION" .sp The Reservation Acquire command is used to acquire a reservation on a namespace, preempt a reservation held on a namespace, and abort a reservation held on a namespace\&. .SH "OPTIONS" .PP \-n , \-\-namespace\-id= .RS 4 Override the nsid field\&. If using the admin character device, this parameter is required\&. .RE .PP \-c , \-\-crkey= .RS 4 Current Reservation Key: The field specifies the current reservation key associated with the host\&. If the IEKEY bit is set to \(oq1\(cq in the command, then the CRKEY check succeeds regardless of the value in this field\&. .RE .PP \-p , \-\-prkey= .RS 4 Preempt Reservation Key: If the Reservation Acquire Action is set to 001b (i\&.e\&., Preempt) or 010b (i\&.e\&., Preempt and Abort), then this field specifies the reservation key to be unregistered from the namespace\&. For all other Reservation Acquire Action values, this field is reserved\&. .RE .PP \-t , \-\-rtyep= .RS 4 Reservation Type: This field specifies the type of reservation to be created\&. .TS allbox tab(:); lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt. T{ Value T}:T{ Definition T} T{ 0h T}:T{ Reserved T} T{ 1h T}:T{ Write Exclusive Reservation T} T{ 2h T}:T{ Exclusive Access Reservation T} T{ 3h T}:T{ Write Exclusive \- Registrants Only Reservation T} T{ 4h T}:T{ Exclusive Access \- Registrants Only Reservation T} T{ 5h T}:T{ Write Exclusive \- All Registrants Reservation T} T{ 6h T}:T{ Exclusive Access \- All Registrants Reservation T} T{ 07h\-FFh T}:T{ Reserved T} .TE .sp 1 .RE .PP \-a , \-\-racqa= .RS 4 Reservation Acquire Action: This field specifies the action that is performed by the command\&. .TS allbox tab(:); lt lt lt lt lt lt lt lt lt lt. T{ Value T}:T{ Definition T} T{ 0 T}:T{ Acquire T} T{ 1 T}:T{ Preempt T} T{ 2 T}:T{ Preempt and Abort T} T{ 3\-7 T}:T{ Reserved T} .TE .sp 1 .RE .PP \-i, \-\-iekey .RS 4 Ignore Existing Key: If this bit is set to a \fI1\fR, then the Current Reservation Key (CRKEY) check is disabled and the command shall succeed regardless of the CRKEY field value\&. .sp Indicator option, defaults to \fI0\fR\&. .RE .SH "EXAMPLES" .sp No examples yet .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-resv-acquire.html000066400000000000000000000531411267263733400221610ustar00rootroot00000000000000 nvme-resv-acquire(1)

SYNOPSIS

nvme resv-acquire <device>

DESCRIPTION

The Reservation Acquire command is used to acquire a reservation on a namespace, preempt a reservation held on a namespace, and abort a reservation held on a namespace.

OPTIONS

-n <nsid>
--namespace-id=<nsid>

Override the nsid field. If using the admin character device, this parameter is required.

-c <crkey>
--crkey=<crkey>

Current Reservation Key: The field specifies the current reservation key associated with the host. If the IEKEY bit is set to ‘1’ in the command, then the CRKEY check succeeds regardless of the value in this field.

-p <prkey>
--prkey=<prkey>

Preempt Reservation Key: If the Reservation Acquire Action is set to 001b (i.e., Preempt) or 010b (i.e., Preempt and Abort), then this field specifies the reservation key to be unregistered from the namespace. For all other Reservation Acquire Action values, this field is reserved.

-t <rtype>
--rtyep=<rtype>

Reservation Type: This field specifies the type of reservation to be created.

Value

Definition

0h

Reserved

1h

Write Exclusive Reservation

2h

Exclusive Access Reservation

3h

Write Exclusive - Registrants Only Reservation

4h

Exclusive Access - Registrants Only Reservation

5h

Write Exclusive - All Registrants Reservation

6h

Exclusive Access - All Registrants Reservation

07h-FFh

Reserved

-a <racqa>
--racqa=<racqa>

Reservation Acquire Action: This field specifies the action that is performed by the command.

Value

Definition

0

Acquire

1

Preempt

2

Preempt and Abort

3-7

Reserved

-i
--iekey

Ignore Existing Key: If this bit is set to a 1, then the Current Reservation Key (CRKEY) check is disabled and the command shall succeed regardless of the CRKEY field value.

Indicator option, defaults to 0.

EXAMPLES

No examples yet

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-resv-acquire.txt000066400000000000000000000040621267263733400220320ustar00rootroot00000000000000nvme-resv-acquire(1) ==================== NAME ---- nvme-resv-acquire - Acquire an nvme reservation SYNOPSIS -------- [verse] 'nvme resv-acquire' DESCRIPTION ----------- The Reservation Acquire command is used to acquire a reservation on a namespace, preempt a reservation held on a namespace, and abort a reservation held on a namespace. OPTIONS ------- -n :: --namespace-id=:: Override the nsid field. If using the admin character device, this parameter is required. -c :: --crkey=:: Current Reservation Key: The field specifies the current reservation key associated with the host. If the IEKEY bit is set to ‘1’ in the command, then the CRKEY check succeeds regardless of the value in this field. -p :: --prkey=:: Preempt Reservation Key: If the Reservation Acquire Action is set to 001b (i.e., Preempt) or 010b (i.e., Preempt and Abort), then this field specifies the reservation key to be unregistered from the namespace. For all other Reservation Acquire Action values, this field is reserved. -t :: --rtyep=:: Reservation Type: This field specifies the type of reservation to be created. + [] |================= |Value|Definition |0h|Reserved |1h|Write Exclusive Reservation |2h|Exclusive Access Reservation |3h|Write Exclusive - Registrants Only Reservation |4h|Exclusive Access - Registrants Only Reservation |5h|Write Exclusive - All Registrants Reservation |6h|Exclusive Access - All Registrants Reservation |07h-FFh|Reserved |================= -a :: --racqa=:: Reservation Acquire Action: This field specifies the action that is performed by the command. + [] |================= |Value|Definition |0|Acquire |1|Preempt |2|Preempt and Abort |3-7|Reserved |================= -i:: --iekey:: Ignore Existing Key: If this bit is set to a '1', then the Current Reservation Key (CRKEY) check is disabled and the command shall succeed regardless of the CRKEY field value. + Indicator option, defaults to '0'. EXAMPLES -------- No examples yet NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-resv-register.1000066400000000000000000000073021267263733400215460ustar00rootroot00000000000000'\" t .\" Title: nvme-resv-register .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 02/26/2016 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-RESV\-REGISTER" "1" "02/26/2016" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-resv-register \- Register an nvme reservation .SH "SYNOPSIS" .sp .nf \fInvme resv\-register\fR .fi .SH "DESCRIPTION" .sp The Reservation Register command is used to register, unregister, or replace a reservation key\&. .SH "OPTIONS" .PP \-n , \-\-namespace\-id= .RS 4 Override the nsid field\&. If using the admin character device, this parameter is required\&. .RE .PP \-c , \-\-crkey= .RS 4 Current Reservation Key: If the Reservation Register Action is 001b (i\&.e\&., Unregister Reservation Key) or 010b (i\&.e\&., Replace Reservation Key), then this field contains the current reservation key associated with the host\&. For all other Reservation Register Action values, this field is reserved\&. The controller ignores the value of this field when the Ignore Existing Key (IEKEY) bit is set to \(oq1\(cq\&. .RE .PP \-k , \-\-nrkey= .RS 4 New Reservation Key: If the Reservation Register Action is 000b (i\&.e\&., Register Reservation Key) or 010b (i\&.e\&., Replace Reservation Key), then this field contains the new reservation key associated with the host\&. For all other Reservation Register Action values, this field is reserved\&. .RE .PP \-p , \-\-cptpl= .RS 4 Change Persist Through Power Loss State: This field allows the Persist Through Power Loss state associated with the namespace to be modified as a side effect of processing this command\&. .TS allbox tab(:); lt lt lt lt lt lt lt lt lt lt. T{ Value T}:T{ Definition T} T{ 0 T}:T{ No change to PTPL state T} T{ 1 T}:T{ Reserved T} T{ 2 T}:T{ Set PTPL state to \(oq0\(cq\&. Reservations are released and registrants are cleared on a power on\&. T} T{ 3 T}:T{ Set PTPL state to \(oq1\(cq\&. Reservations and registrants persist across a power loss\&. T} .TE .sp 1 .RE .PP \-a , \-\-rrega= .RS 4 Reservation Register Action: This field specifies the registration action that is performed by the command\&. .TS allbox tab(:); lt lt lt lt lt lt lt lt lt lt. T{ Value T}:T{ Definition T} T{ 0 T}:T{ Register Reservation Key T} T{ 1 T}:T{ Unregister Reservation Key T} T{ 2 T}:T{ Replace Reservation Key T} T{ 3\-7 T}:T{ Reserved T} .TE .sp 1 .RE .PP \-i, \-\-iekey .RS 4 Ignore Existing Key: If this bit is set to a \fI1\fR, then the Current Reservation Key (CRKEY) check is disabled and the command shall succeed regardless of the CRKEY field value\&. .sp Indicator option, defaults to \fI0\fR\&. .RE .SH "EXAMPLES" .sp No examples yet .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-resv-register.html000066400000000000000000000525401267263733400223560ustar00rootroot00000000000000 nvme-resv-register(1)

SYNOPSIS

nvme resv-register <device>

DESCRIPTION

The Reservation Register command is used to register, unregister, or replace a reservation key.

OPTIONS

-n <nsid>
--namespace-id=<nsid>

Override the nsid field. If using the admin character device, this parameter is required.

-c <crkey>
--crkey=<crkey>

Current Reservation Key: If the Reservation Register Action is 001b (i.e., Unregister Reservation Key) or 010b (i.e., Replace Reservation Key), then this field contains the current reservation key associated with the host. For all other Reservation Register Action values, this field is reserved. The controller ignores the value of this field when the Ignore Existing Key (IEKEY) bit is set to ‘1’.

-k <nrkey>
--nrkey=<nrkey>

New Reservation Key: If the Reservation Register Action is 000b (i.e., Register Reservation Key) or 010b (i.e., Replace Reservation Key), then this field contains the new reservation key associated with the host. For all other Reservation Register Action values, this field is reserved.

-p <cptpl>
--cptpl=<cptpl>

Change Persist Through Power Loss State: This field allows the Persist Through Power Loss state associated with the namespace to be modified as a side effect of processing this command.

Value

Definition

0

No change to PTPL state

1

Reserved

2

Set PTPL state to ‘0’. Reservations are released and registrants are cleared on a power on.

3

Set PTPL state to ‘1’. Reservations and registrants persist across a power loss.

-a <rrega>
--rrega=<rrega>

Reservation Register Action: This field specifies the registration action that is performed by the command.

Value

Definition

0

Register Reservation Key

1

Unregister Reservation Key

2

Replace Reservation Key

3-7

Reserved

-i
--iekey

Ignore Existing Key: If this bit is set to a 1, then the Current Reservation Key (CRKEY) check is disabled and the command shall succeed regardless of the CRKEY field value.

Indicator option, defaults to 0.

EXAMPLES

No examples yet

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-resv-register.txt000066400000000000000000000044071267263733400222300ustar00rootroot00000000000000nvme-resv-register(1) ===================== NAME ---- nvme-resv-register - Register an nvme reservation SYNOPSIS -------- [verse] 'nvme resv-register' DESCRIPTION ----------- The Reservation Register command is used to register, unregister, or replace a reservation key. OPTIONS ------- -n :: --namespace-id=:: Override the nsid field. If using the admin character device, this parameter is required. -c :: --crkey=:: Current Reservation Key: If the Reservation Register Action is 001b (i.e., Unregister Reservation Key) or 010b (i.e., Replace Reservation Key), then this field contains the current reservation key associated with the host. For all other Reservation Register Action values, this field is reserved. The controller ignores the value of this field when the Ignore Existing Key (IEKEY) bit is set to ‘1’. -k :: --nrkey=:: New Reservation Key: If the Reservation Register Action is 000b (i.e., Register Reservation Key) or 010b (i.e., Replace Reservation Key), then this field contains the new reservation key associated with the host. For all other Reservation Register Action values, this field is reserved. -p :: --cptpl=:: Change Persist Through Power Loss State: This field allows the Persist Through Power Loss state associated with the namespace to be modified as a side effect of processing this command. + [] |================= |Value|Definition |0|No change to PTPL state |1|Reserved |2|Set PTPL state to ‘0’. Reservations are released and registrants are cleared on a power on. |3|Set PTPL state to ‘1’. Reservations and registrants persist across a power loss. |================= -a :: --rrega=:: Reservation Register Action: This field specifies the registration action that is performed by the command. + [] |================= |Value|Definition |0|Register Reservation Key |1|Unregister Reservation Key |2|Replace Reservation Key |3-7|Reserved |================= -i:: --iekey:: Ignore Existing Key: If this bit is set to a '1', then the Current Reservation Key (CRKEY) check is disabled and the command shall succeed regardless of the CRKEY field value. + Indicator option, defaults to '0'. EXAMPLES -------- No examples yet NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-resv-release.1000066400000000000000000000064541267263733400213510ustar00rootroot00000000000000'\" t .\" Title: nvme-resv-release .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/08/2015 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-RESV\-RELEASE" "1" "06/08/2015" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-resv-release \- Release an nvme reservation .SH "SYNOPSIS" .sp .nf \fInvme resv\-release\fR .fi .SH "DESCRIPTION" .sp The Reservation Release command is used to release or clear a reservation held on a namespace\&. .SH "OPTIONS" .PP \-n , \-\-namespace\-id= .RS 4 Override the nsid field\&. If using the admin character device, this parameter is required\&. .RE .PP \-c , \-\-crkey= .RS 4 Current Reservation Key: If the Reservation Register Action is 001b (i\&.e\&., Unregister Reservation Key) or 010b (i\&.e\&., Replace Reservation Key), then this field contains the current reservation key associated with the host\&. For all other Reservation Register Action values, this field is reserved\&. The controller ignores the value of this field when the Ignore Existing Key (IEKEY) bit is set to \(oq1\(cq\&. .RE .PP \-t , \-\-rtyep= .RS 4 Reservation Type: This field specifies the type of reservation to be created\&. .TS allbox tab(:); lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt. T{ Value T}:T{ Definition T} T{ 0h T}:T{ Reserved T} T{ 1h T}:T{ Write Exclusive Reservation T} T{ 2h T}:T{ Exclusive Access Reservation T} T{ 3h T}:T{ Write Exclusive \- Registrants Only Reservation T} T{ 4h T}:T{ Exclusive Access \- Registrants Only Reservation T} T{ 5h T}:T{ Write Exclusive \- All Registrants Reservation T} T{ 6h T}:T{ Exclusive Access \- All Registrants Reservation T} T{ 07h\-FFh T}:T{ Reserved T} .TE .sp 1 .RE .PP \-a , \-\-rrela= .RS 4 Reservation Release Action: This field specifies the registration action that is performed by the command\&. .TS allbox tab(:); lt lt lt lt lt lt lt lt. T{ Value T}:T{ Definition T} T{ 0 T}:T{ Release T} T{ 1 T}:T{ Clear T} T{ 2\-7 T}:T{ Reserved T} .TE .sp 1 .RE .PP \-i, \-\-iekey .RS 4 Ignore Existing Key: If this bit is set to a \fI1\fR, then the Current Reservation Key (CRKEY) check is disabled and the command shall succeed regardless of the CRKEY field value\&. .sp Indicator option, defaults to \fI0\fR\&. .RE .SH "EXAMPLES" .sp No examples yet .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-resv-release.html000066400000000000000000000522361267263733400221540ustar00rootroot00000000000000 nvme-resv-release(1)

SYNOPSIS

nvme resv-release <device>

DESCRIPTION

The Reservation Release command is used to release or clear a reservation held on a namespace.

OPTIONS

-n <nsid>
--namespace-id=<nsid>

Override the nsid field. If using the admin character device, this parameter is required.

-c <crkey>
--crkey=<crkey>

Current Reservation Key: If the Reservation Register Action is 001b (i.e., Unregister Reservation Key) or 010b (i.e., Replace Reservation Key), then this field contains the current reservation key associated with the host. For all other Reservation Register Action values, this field is reserved. The controller ignores the value of this field when the Ignore Existing Key (IEKEY) bit is set to ‘1’.

-t <rtype>
--rtyep=<rtype>

Reservation Type: This field specifies the type of reservation to be created.

Value

Definition

0h

Reserved

1h

Write Exclusive Reservation

2h

Exclusive Access Reservation

3h

Write Exclusive - Registrants Only Reservation

4h

Exclusive Access - Registrants Only Reservation

5h

Write Exclusive - All Registrants Reservation

6h

Exclusive Access - All Registrants Reservation

07h-FFh

Reserved

-a <rrela>
--rrela=<rrela>

Reservation Release Action: This field specifies the registration action that is performed by the command.

Value

Definition

0

Release

1

Clear

2-7

Reserved

-i
--iekey

Ignore Existing Key: If this bit is set to a 1, then the Current Reservation Key (CRKEY) check is disabled and the command shall succeed regardless of the CRKEY field value.

Indicator option, defaults to 0.

EXAMPLES

No examples yet

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-resv-release.txt000066400000000000000000000035311267263733400220210ustar00rootroot00000000000000nvme-resv-release(1) ==================== NAME ---- nvme-resv-release - Release an nvme reservation SYNOPSIS -------- [verse] 'nvme resv-release' DESCRIPTION ----------- The Reservation Release command is used to release or clear a reservation held on a namespace. OPTIONS ------- -n :: --namespace-id=:: Override the nsid field. If using the admin character device, this parameter is required. -c :: --crkey=:: Current Reservation Key: If the Reservation Register Action is 001b (i.e., Unregister Reservation Key) or 010b (i.e., Replace Reservation Key), then this field contains the current reservation key associated with the host. For all other Reservation Register Action values, this field is reserved. The controller ignores the value of this field when the Ignore Existing Key (IEKEY) bit is set to ‘1’. -t :: --rtyep=:: Reservation Type: This field specifies the type of reservation to be created. + [] |================= |Value|Definition |0h|Reserved |1h|Write Exclusive Reservation |2h|Exclusive Access Reservation |3h|Write Exclusive - Registrants Only Reservation |4h|Exclusive Access - Registrants Only Reservation |5h|Write Exclusive - All Registrants Reservation |6h|Exclusive Access - All Registrants Reservation |07h-FFh|Reserved |================= -a :: --rrela=:: Reservation Release Action: This field specifies the registration action that is performed by the command. + [] |================= |Value|Definition |0|Release |1|Clear |2-7|Reserved |================= -i:: --iekey:: Ignore Existing Key: If this bit is set to a '1', then the Current Reservation Key (CRKEY) check is disabled and the command shall succeed regardless of the CRKEY field value. + Indicator option, defaults to '0'. EXAMPLES -------- No examples yet NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-resv-report.1000066400000000000000000000047621267263733400212440ustar00rootroot00000000000000'\" t .\" Title: nvme-resv-report .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/08/2015 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-RESV\-REPORT" "1" "06/08/2015" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-resv-report \- Send NVMe Reservation Report, parse the result .SH "SYNOPSIS" .sp .nf \fInvme resv\-report\fR [\-\-namespace\-id= | \-n ] [\-\-numd= | \-d ] [\-b | \-\-raw\-binary] .fi .SH "DESCRIPTION" .sp The Reservation Report command returns a Reservation Status data structure to host memory that describes the registration and reservation status of a namespace\&. .sp The size of the Reservation Status data structure is a function of the number of controllers in the NVM Subsystem that are associated with hosts that are registrants of the namespace (i\&.e\&., there is a Registered Controller data structure for each such controller)\&. .SH "OPTIONS" .PP \-n , \-\-namespace\-id= .RS 4 Retrieve the reservation report structure for the given nsid\&. This is required for the character devices, or overrides the block nsid if given\&. .RE .PP \-d , \-\-numd= .RS 4 Specify the number of Dwords of the Reservation Status structure to transfer\&. Defaults to 4k\&. .RE .PP \-b, \-\-raw\-binary .RS 4 Print the raw buffer to stdout\&. Structure is not parsed by program\&. .RE .SH "EXAMPLES" .sp No examples yet\&. .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-resv-report.html000066400000000000000000000447061267263733400220520ustar00rootroot00000000000000 nvme-resv-report(1)

SYNOPSIS

nvme resv-report <device> [--namespace-id=<nsid> | -n <nsid>]
                        [--numd=<num-dwords> | -d <num-dwords>]
                        [-b | --raw-binary]

DESCRIPTION

The Reservation Report command returns a Reservation Status data structure to host memory that describes the registration and reservation status of a namespace.

The size of the Reservation Status data structure is a function of the number of controllers in the NVM Subsystem that are associated with hosts that are registrants of the namespace (i.e., there is a Registered Controller data structure for each such controller).

OPTIONS

-n <nsid>
--namespace-id=<nsid>

Retrieve the reservation report structure for the given nsid. This is required for the character devices, or overrides the block nsid if given.

-d <num-dwords>
--numd=<num-dwords>

Specify the number of Dwords of the Reservation Status structure to transfer. Defaults to 4k.

-b
--raw-binary

Print the raw buffer to stdout. Structure is not parsed by program.

EXAMPLES

No examples yet.

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-resv-report.txt000066400000000000000000000023151267263733400217130ustar00rootroot00000000000000nvme-resv-report(1) =================== NAME ---- nvme-resv-report - Send NVMe Reservation Report, parse the result SYNOPSIS -------- [verse] 'nvme resv-report' [--namespace-id= | -n ] [--numd= | -d ] [-b | --raw-binary] DESCRIPTION ----------- The Reservation Report command returns a Reservation Status data structure to host memory that describes the registration and reservation status of a namespace. The size of the Reservation Status data structure is a function of the number of controllers in the NVM Subsystem that are associated with hosts that are registrants of the namespace (i.e., there is a Registered Controller data structure for each such controller). OPTIONS ------- -n :: --namespace-id=:: Retrieve the reservation report structure for the given nsid. This is required for the character devices, or overrides the block nsid if given. -d :: --numd=:: Specify the number of Dwords of the Reservation Status structure to transfer. Defaults to 4k. -b:: --raw-binary:: Print the raw buffer to stdout. Structure is not parsed by program. EXAMPLES -------- No examples yet. NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-security-recv.1000066400000000000000000000073471267263733400215620ustar00rootroot00000000000000'\" t .\" Title: nvme-security-recv .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 03/17/2016 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-SECURITY\-RECV" "1" "03/17/2016" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-security-recv \- Security Recv command .SH "SYNOPSIS" .sp .nf \fInvme security\-recv\fR [] [\-\-size= | \-x ] [\-\-secp= | \-p ] [\-\-spsp= | \-s ] [\-\-nssf= | \-N ] [\-\-tl= | \-t ] [\-\-namespace\-id= | \-n ] [\-b | \-\-raw\-binary] .fi .SH "DESCRIPTION" .sp The Security Receive command transfers the status and data result of one or more Security Send commands that were previously submitted to the controller\&. .sp The association between a Security Receive command and previous Security Send commands is dependent on the Security Protocol\&. The format of the data to be transferred is dependent on the Security Protocol\&. Refer to SPC\-4 for Security Protocol details\&. .sp Each Security Receive command returns the appropriate data corresponding to a Security Send command as defined by the rules of the Security Protocol\&. The Security Receive command data may not be retained if there is a loss of communication between the controller and host, or if a controller reset occurs\&. .SH "OPTIONS" .PP \-n , \-\-namespace\-id= .RS 4 Target a specific namespace for this security command\&. .RE .PP \-N , \-\-nssf= .RS 4 NVMe Security Specific field\&. If using security protocol EAh assigned for NVMe use, the NVMe security specific field indicates which reply memory buffer target\&. .RE .PP \-x , \-\-size= .RS 4 Size of buffer to allocate\&. One success it will be printed to STDOUT\&. .RE .PP \-p , \-\-secp= .RS 4 Security Protocol: This field specifies the security protocol as defined in SPC\-4\&. The controller shall fail the command with Invalid Parameter indicated if a reserved value of the Security Protocol is specified\&. .RE .PP \-s , \-\-spsp= .RS 4 SP Specific: The value of this field is specific to the Security Protocol as defined in SPC\-4\&. .RE .PP \-a , \-\-al= .RS 4 Allocation Length: The value of this field is specific to the Security Protocol as defined in SPC\-4\&. .RE .PP \-b, \-\-raw\-binary .RS 4 Print the raw buffer to stdout\&. Defaults to print in hex\&. .RE .SH "EXAMPLES" .sp No Examples .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-security-recv.html000066400000000000000000000501531267263733400223570ustar00rootroot00000000000000 nvme-security-recv(1)

SYNOPSIS

nvme security-recv [<device>] [--size=<size> | -x <size>]
                    [--secp=<security-protocol> | -p <security-protocol>]
                    [--spsp=<protocol-specific> | -s <protocol-specific>]
                    [--nssf=<nvme-specific> | -N <nvme-specific>]
                    [--tl=<transfer-length> | -t <transfer-length>]
                    [--namespace-id=<nsid> | -n <nsid>]
                    [-b | --raw-binary]

DESCRIPTION

The Security Receive command transfers the status and data result of one or more Security Send commands that were previously submitted to the controller.

The association between a Security Receive command and previous Security Send commands is dependent on the Security Protocol. The format of the data to be transferred is dependent on the Security Protocol. Refer to SPC-4 for Security Protocol details.

Each Security Receive command returns the appropriate data corresponding to a Security Send command as defined by the rules of the Security Protocol. The Security Receive command data may not be retained if there is a loss of communication between the controller and host, or if a controller reset occurs.

OPTIONS

-n <nsid>
--namespace-id=<nsid>

Target a specific namespace for this security command.

-N <nssf>
--nssf=<nssf>

NVMe Security Specific field. If using security protocol EAh assigned for NVMe use, the NVMe security specific field indicates which reply memory buffer target.

-x <size>
--size=<size>

Size of buffer to allocate. One success it will be printed to STDOUT.

-p <security-protocol>
--secp=<security-protocol>

Security Protocol: This field specifies the security protocol as defined in SPC-4. The controller shall fail the command with Invalid Parameter indicated if a reserved value of the Security Protocol is specified.

-s <security-protocol-specific>
--spsp=<security-protocol-specific>

SP Specific: The value of this field is specific to the Security Protocol as defined in SPC-4.

-a <allocation-length>
--al=<allocation-length>

Allocation Length: The value of this field is specific to the Security Protocol as defined in SPC-4.

-b
--raw-binary

Print the raw buffer to stdout. Defaults to print in hex.

EXAMPLES

No Examples

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-security-recv.txt000066400000000000000000000045011267263733400222260ustar00rootroot00000000000000nvme-security-recv(1) ===================== NAME ---- nvme-security-recv - Security Recv command SYNOPSIS -------- [verse] 'nvme security-recv' [] [--size= | -x ] [--secp= | -p ] [--spsp= | -s ] [--nssf= | -N ] [--tl= | -t ] [--namespace-id= | -n ] [-b | --raw-binary] DESCRIPTION ----------- The Security Receive command transfers the status and data result of one or more Security Send commands that were previously submitted to the controller. The association between a Security Receive command and previous Security Send commands is dependent on the Security Protocol. The format of the data to be transferred is dependent on the Security Protocol. Refer to SPC-4 for Security Protocol details. Each Security Receive command returns the appropriate data corresponding to a Security Send command as defined by the rules of the Security Protocol. The Security Receive command data may not be retained if there is a loss of communication between the controller and host, or if a controller reset occurs. OPTIONS ------- -n :: --namespace-id=:: Target a specific namespace for this security command. -N :: --nssf=:: NVMe Security Specific field. If using security protocol EAh assigned for NVMe use, the NVMe security specific field indicates which reply memory buffer target. -x :: --size=:: Size of buffer to allocate. One success it will be printed to STDOUT. -p :: --secp=:: Security Protocol: This field specifies the security protocol as defined in SPC-4. The controller shall fail the command with Invalid Parameter indicated if a reserved value of the Security Protocol is specified. -s :: --spsp=:: SP Specific: The value of this field is specific to the Security Protocol as defined in SPC-4. -a :: --al=:: Allocation Length: The value of this field is specific to the Security Protocol as defined in SPC-4. -b:: --raw-binary:: Print the raw buffer to stdout. Defaults to print in hex. EXAMPLES -------- No Examples NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-security-send.1000066400000000000000000000070501267263733400215430ustar00rootroot00000000000000'\" t .\" Title: nvme-security-send .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 03/03/2016 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-SECURITY\-SEND" "1" "03/03/2016" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-security-send \- Security Send command .SH "SYNOPSIS" .sp .nf \fInvme security\-send\fR [] [\-\-file= | \-f ] [\-\-secp= | \-p ] [\-\-spsp= | \-s ] [\-\-tl= | \-t ] [\-\-nssf= | \-N ] [\-\-namespace\-id= | \-n ] .fi .SH "DESCRIPTION" .sp The Security Send command is used to transfer security protocol data to the controller\&. The data structure transferred to the controller as part of this command contains security protocol specific commands to be performed by the controller\&. The data structure transferred may also contain data or parameters associated with the security protocol commands\&. Status and data that is to be returned to the host for the security protocol commands submitted by a Security Send command are retrieved with the Security Receive command\&. .sp The association between a Security Send command and subsequent Security Receive command is Security Protocol field dependent as defined in SPC\-4\&. .SH "OPTIONS" .PP \-n , \-\-namespace\-id= .RS 4 Target a specific namespace for this security command\&. .RE .PP \-N , \-\-nssf= .RS 4 NVMe Security Specific field\&. If using security protocol EAh assigned for NVMe use, the NVMe security specific field indicates which reply memory buffer target\&. .RE .PP \-f , \-\-file= .RS 4 Path to file used as the security protocol\(cqs payload\&. Required argument\&. .RE .PP \-p , \-\-secp= .RS 4 Security Protocol: This field specifies the security protocol as defined in SPC\-4\&. The controller shall fail the command with Invalid Parameter indicated if a reserved value of the Security Protocol is specified\&. .RE .PP \-s , \-\-spsp= .RS 4 SP Specific: The value of this field is specific to the Security Protocol as defined in SPC\-4\&. .RE .PP \-t , \-\-tl= .RS 4 Transfer Length: The value of this field is specific to the Security Protocol as defined in SPC\-4\&. .RE .SH "EXAMPLES" .sp No Examples .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-security-send.html000066400000000000000000000475141267263733400223600ustar00rootroot00000000000000 nvme-security-send(1)

SYNOPSIS

nvme security-send [<device>] [--file=<file> | -f <file>]
                    [--secp=<security-protocol> | -p <security-protocol>]
                    [--spsp=<protocol-specific> | -s <protocol-specific>]
                    [--tl=<transfer-length> | -t <transfer-length>]
                    [--nssf=<nvme-specific> | -N <nvme-specific>]
                    [--namespace-id=<nsid> | -n <nsid>]

DESCRIPTION

The Security Send command is used to transfer security protocol data to the controller. The data structure transferred to the controller as part of this command contains security protocol specific commands to be performed by the controller. The data structure transferred may also contain data or parameters associated with the security protocol commands. Status and data that is to be returned to the host for the security protocol commands submitted by a Security Send command are retrieved with the Security Receive command.

The association between a Security Send command and subsequent Security Receive command is Security Protocol field dependent as defined in SPC-4.

OPTIONS

-n <nsid>
--namespace-id=<nsid>

Target a specific namespace for this security command.

-N <nssf>
--nssf=<nssf>

NVMe Security Specific field. If using security protocol EAh assigned for NVMe use, the NVMe security specific field indicates which reply memory buffer target.

-f <file>
--file=<file>

Path to file used as the security protocol’s payload. Required argument.

-p <security-protocol>
--secp=<security-protocol>

Security Protocol: This field specifies the security protocol as defined in SPC-4. The controller shall fail the command with Invalid Parameter indicated if a reserved value of the Security Protocol is specified.

-s <security-protocol-specific>
--spsp=<security-protocol-specific>

SP Specific: The value of this field is specific to the Security Protocol as defined in SPC-4.

-t <trans-length>
--tl=<trans-length>

Transfer Length: The value of this field is specific to the Security Protocol as defined in SPC-4.

EXAMPLES

No Examples

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-security-send.txt000066400000000000000000000042471267263733400222270ustar00rootroot00000000000000nvme-security-send(1) ===================== NAME ---- nvme-security-send - Security Send command SYNOPSIS -------- [verse] 'nvme security-send' [] [--file= | -f ] [--secp= | -p ] [--spsp= | -s ] [--tl= | -t ] [--nssf= | -N ] [--namespace-id= | -n ] DESCRIPTION ----------- The Security Send command is used to transfer security protocol data to the controller. The data structure transferred to the controller as part of this command contains security protocol specific commands to be performed by the controller. The data structure transferred may also contain data or parameters associated with the security protocol commands. Status and data that is to be returned to the host for the security protocol commands submitted by a Security Send command are retrieved with the Security Receive command. The association between a Security Send command and subsequent Security Receive command is Security Protocol field dependent as defined in SPC-4. OPTIONS ------- -n :: --namespace-id=:: Target a specific namespace for this security command. -N :: --nssf=:: NVMe Security Specific field. If using security protocol EAh assigned for NVMe use, the NVMe security specific field indicates which reply memory buffer target. -f :: --file=:: Path to file used as the security protocol's payload. Required argument. -p :: --secp=:: Security Protocol: This field specifies the security protocol as defined in SPC-4. The controller shall fail the command with Invalid Parameter indicated if a reserved value of the Security Protocol is specified. -s :: --spsp=:: SP Specific: The value of this field is specific to the Security Protocol as defined in SPC-4. -t :: --tl=:: Transfer Length: The value of this field is specific to the Security Protocol as defined in SPC-4. EXAMPLES -------- No Examples NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-set-feature.1000066400000000000000000000114671267263733400212000ustar00rootroot00000000000000'\" t .\" Title: nvme-set-feature .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 02/26/2016 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-SET\-FEATURE" "1" "02/26/2016" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-set-feature \- Sets an NVMe feature, returns applicable results .SH "SYNOPSIS" .sp .nf \fInvme set\-feature\fR [\-\-namespace\-id= | \-n ] [\-\-feature\-id= | \-f ] [\-\-value=] [\-\-data\-len= | \-l ] [\-\-data= | \-d ] [\-\-raw\-binary | \-b] .fi .SH "DESCRIPTION" .sp Submits an NVMe Get Feature admin command and returns the applicable results\&. This may be the feature\(cqs value, or may also include a feature structure if the feature requires it (ex: LBA Range Type)\&. .sp The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1)\&. .sp On success, the returned feature\(cqs structure (if applicable) may be returned in one of several ways depending on the option flags; the structure may parsed by the program and printed in a readable format if it is a known structure, displayed in hex, or the raw buffer may be printed to stdout for another program to parse\&. .SH "OPTIONS" .PP \-n , \-\-namespace\-id= .RS 4 Retrieve the feature for the given nsid\&. This is optional and most features do not use this value\&. .RE .PP \-f , \-\-feature\-id= .RS 4 The feature id to send with the command\&. Value provided should be in hex\&. .RE .PP \-l , \-\-data\-len= .RS 4 The data length for the buffer submitted for this feature\&. Most known features do not use this value\&. The exceptions are LBA Range Type and host identifier\&. .RE .PP \-d , \-\-data= .RS 4 The data file for the buffer submitted for this feature\&. Most known features do not use this value\&. The exceptions is LBA Range Type and host identifier\&. This defaults to STDIN so files and echo can be piped\&. .RE .PP \-\-value= .RS 4 The value for command dword 11, the value you want to set the feature to\&. .RE .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Retrieves the feature for Number of Queues, or feature id 7: .sp .if n \{\ .RS 4 .\} .nf # nvme set\-feature /dev/nvme0 \-f 7 .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The following retrieves the feature for the LBA Range Type, which implicitly requires a buffer and will be printed to the screen in human readable format: .sp .if n \{\ .RS 4 .\} .nf # nvme set\-feature /dev/nvme0 \-f 3 .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Retrieves the feature for the some vendor specific feature and specifically requesting a buffer be allocate for this feature, which will be displayed to the user in as a hex dump: .sp .if n \{\ .RS 4 .\} .nf # nvme set\-feature /dev/nvme0 \-f 0xc0 \-l 512 .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Sets the host id to the ascii string\&. .sp .if n \{\ .RS 4 .\} .nf # echo "abcdefgh" | nvme set\-feature /dev/nvme0 \-f 0x81 \-l 8 .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The following retrieves the feature for the LBA Range Type, which implicitly requires a buffer and will be saved to a file in its raw format: .sp .if n \{\ .RS 4 .\} .nf # nvme set\-feature /dev/nvme0 \-f 3 \-\-raw\-binary > lba_range\&.raw .fi .if n \{\ .RE .\} .sp It is probably a bad idea to not redirect stdout when using this mode\&. .RE .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-set-feature.html000066400000000000000000000516631267263733400220060ustar00rootroot00000000000000 nvme-set-feature(1)

SYNOPSIS

nvme set-feature <device> [--namespace-id=<nsid> | -n <nsid>]
                          [--feature-id=<fid> | -f <fid>] [--value=<value>]
                          [--data-len=<data-len> | -l <data-len>]
                          [--data=<data-file> | -d <data-file>]
                          [--raw-binary | -b]

DESCRIPTION

Submits an NVMe Get Feature admin command and returns the applicable results. This may be the feature’s value, or may also include a feature structure if the feature requires it (ex: LBA Range Type).

The <device> parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1).

On success, the returned feature’s structure (if applicable) may be returned in one of several ways depending on the option flags; the structure may parsed by the program and printed in a readable format if it is a known structure, displayed in hex, or the raw buffer may be printed to stdout for another program to parse.

OPTIONS

-n <nsid>
--namespace-id=<nsid>

Retrieve the feature for the given nsid. This is optional and most features do not use this value.

-f <fid>
--feature-id=<fid>

The feature id to send with the command. Value provided should be in hex.

-l <data-len>
--data-len=<data-len>

The data length for the buffer submitted for this feature. Most known features do not use this value. The exceptions are LBA Range Type and host identifier.

-d <data-file>
--data=<data-file>

The data file for the buffer submitted for this feature. Most known features do not use this value. The exceptions is LBA Range Type and host identifier. This defaults to STDIN so files and echo can be piped.

--value=<value>

The value for command dword 11, the value you want to set the feature to.

EXAMPLES

  • Retrieves the feature for Number of Queues, or feature id 7:

    # nvme set-feature /dev/nvme0 -f 7
  • The following retrieves the feature for the LBA Range Type, which implicitly requires a buffer and will be printed to the screen in human readable format:

    # nvme set-feature /dev/nvme0 -f 3
  • Retrieves the feature for the some vendor specific feature and specifically requesting a buffer be allocate for this feature, which will be displayed to the user in as a hex dump:

    # nvme set-feature /dev/nvme0 -f 0xc0 -l 512
  • Sets the host id to the ascii string.

    # echo "abcdefgh" | nvme set-feature /dev/nvme0 -f 0x81 -l 8
  • The following retrieves the feature for the LBA Range Type, which implicitly requires a buffer and will be saved to a file in its raw format:

    # nvme set-feature /dev/nvme0 -f 3 --raw-binary > lba_range.raw

    It is probably a bad idea to not redirect stdout when using this mode.

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-set-feature.txt000066400000000000000000000056631267263733400216600ustar00rootroot00000000000000nvme-set-feature(1) =================== NAME ---- nvme-set-feature - Sets an NVMe feature, returns applicable results SYNOPSIS -------- [verse] 'nvme set-feature' [--namespace-id= | -n ] [--feature-id= | -f ] [--value=] [--data-len= | -l ] [--data= | -d ] [--raw-binary | -b] DESCRIPTION ----------- Submits an NVMe Get Feature admin command and returns the applicable results. This may be the feature's value, or may also include a feature structure if the feature requires it (ex: LBA Range Type). The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1). On success, the returned feature's structure (if applicable) may be returned in one of several ways depending on the option flags; the structure may parsed by the program and printed in a readable format if it is a known structure, displayed in hex, or the raw buffer may be printed to stdout for another program to parse. OPTIONS ------- -n :: --namespace-id=:: Retrieve the feature for the given nsid. This is optional and most features do not use this value. -f :: --feature-id=:: The feature id to send with the command. Value provided should be in hex. -l :: --data-len=:: The data length for the buffer submitted for this feature. Most known features do not use this value. The exceptions are LBA Range Type and host identifier. -d :: --data=:: The data file for the buffer submitted for this feature. Most known features do not use this value. The exceptions is LBA Range Type and host identifier. This defaults to STDIN so files and echo can be piped. --value=:: The value for command dword 11, the value you want to set the feature to. EXAMPLES -------- * Retrieves the feature for Number of Queues, or feature id 7: + ------------ # nvme set-feature /dev/nvme0 -f 7 ------------ + * The following retrieves the feature for the LBA Range Type, which implicitly requires a buffer and will be printed to the screen in human readable format: + ------------ # nvme set-feature /dev/nvme0 -f 3 ------------ + * Retrieves the feature for the some vendor specific feature and specifically requesting a buffer be allocate for this feature, which will be displayed to the user in as a hex dump: + ------------ # nvme set-feature /dev/nvme0 -f 0xc0 -l 512 ------------ + * Sets the host id to the ascii string. + ------------ # echo "abcdefgh" | nvme set-feature /dev/nvme0 -f 0x81 -l 8 ------------ + * The following retrieves the feature for the LBA Range Type, which implicitly requires a buffer and will be saved to a file in its raw format: + ------------ # nvme set-feature /dev/nvme0 -f 3 --raw-binary > lba_range.raw ------------ + It is probably a bad idea to not redirect stdout when using this mode. NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-show-regs.1000066400000000000000000000040341267263733400206620ustar00rootroot00000000000000'\" t .\" Title: nvme-id-ns .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 06/08/2015 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-ID\-NS" "1" "06/08/2015" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-show-regs \- Reads and shows the defined NVMe controller registers\&. .SH "SYNOPSIS" .sp .nf \fInvme show\-regs\fR .fi .SH "DESCRIPTION" .sp For the NVMe device given, sends an identify namespace command and provides the result and returned structure\&. .sp The parameter is mandatory and must be the nvme admin character device (ex: /dev/nvme0)\&. The program uses knowledge of the sysfs layout to map the device to the pci resource stored there and mmaps the memory to get access to the registers\&. .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Has the program map the nvme pci controller registers and prints them in a human readable format: .sp .if n \{\ .RS 4 .\} .nf # nvme show\-regs /dev/nvme0 .fi .if n \{\ .RE .\} .RE .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-show-regs.html000066400000000000000000000431261267263733400214730ustar00rootroot00000000000000 nvme-id-ns(1)

SYNOPSIS

nvme show-regs <device>

DESCRIPTION

For the NVMe device given, sends an identify namespace command and provides the result and returned structure.

The <device> parameter is mandatory and must be the nvme admin character device (ex: /dev/nvme0). The program uses knowledge of the sysfs layout to map the device to the pci resource stored there and mmaps the memory to get access to the registers.

EXAMPLES

  • Has the program map the nvme pci controller registers and prints them in a human readable format:

    # nvme show-regs /dev/nvme0

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-show-regs.txt000066400000000000000000000013741267263733400213450ustar00rootroot00000000000000nvme-id-ns(1) ============= NAME ---- nvme-show-regs - Reads and shows the defined NVMe controller registers. SYNOPSIS -------- [verse] 'nvme show-regs' DESCRIPTION ----------- For the NVMe device given, sends an identify namespace command and provides the result and returned structure. The parameter is mandatory and must be the nvme admin character device (ex: /dev/nvme0). The program uses knowledge of the sysfs layout to map the device to the pci resource stored there and mmaps the memory to get access to the registers. EXAMPLES -------- * Has the program map the nvme pci controller registers and prints them in a human readable format: + ------------ # nvme show-regs /dev/nvme0 ------------ NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-smart-log.1000066400000000000000000000057031267263733400206550ustar00rootroot00000000000000'\" t .\" Title: nvme-smart-log .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 02/26/2016 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-SMART\-LOG" "1" "02/26/2016" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-smart-log \- Send NVMe SMART log page request, returns result and log .SH "SYNOPSIS" .sp .nf \fInvme smart\-log\fR [\-\-namespace\-id= | \-n ] [\-\-raw\-binary | \-b] .fi .SH "DESCRIPTION" .sp Retrieves the NVMe SMART log page from an NVMe device and provides the retuned structure\&. .sp The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1)\&. .sp On success, the returned f/w log structure may be returned in one of several ways depending on the option flags; the structure may parsed by the program and printed in a readable format or the raw buffer may be printed to stdout for another program to parse\&. .SH "OPTIONS" .PP \-n , \-\-namespace\-id= .RS 4 Retrieve the SMART log for the given nsid\&. This is optional and its success may depend on the device\(cqs capabilities to provide this log on a per\-namespace basis (see the NVMe Identify Controller for this capability)\&. The default nsid to use is 0xffffffff for the device global SMART log\&. .RE .PP \-b, \-\-raw\-binary .RS 4 Print the raw SMART log buffer to stdout\&. .RE .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Print the SMART log page in a human readable format: .sp .if n \{\ .RS 4 .\} .nf # nvme smart\-log /dev/nvme0 .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Print the raw SMART log to a file: .sp .if n \{\ .RS 4 .\} .nf # nvme smart\-log /dev/nvme0 \-\-raw\-binary > fw_log\&.raw .fi .if n \{\ .RE .\} .sp It is probably a bad idea to not redirect stdout when using this mode\&. .RE .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-smart-log.html000066400000000000000000000455421267263733400214660ustar00rootroot00000000000000 nvme-smart-log(1)

SYNOPSIS

nvme smart-log <device> [--namespace-id=<nsid> | -n <nsid>]
                        [--raw-binary | -b]

DESCRIPTION

Retrieves the NVMe SMART log page from an NVMe device and provides the retuned structure.

The <device> parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1).

On success, the returned f/w log structure may be returned in one of several ways depending on the option flags; the structure may parsed by the program and printed in a readable format or the raw buffer may be printed to stdout for another program to parse.

OPTIONS

-n <nsid>
--namespace-id=<nsid>

Retrieve the SMART log for the given nsid. This is optional and its success may depend on the device’s capabilities to provide this log on a per-namespace basis (see the NVMe Identify Controller for this capability). The default nsid to use is 0xffffffff for the device global SMART log.

-b
--raw-binary

Print the raw SMART log buffer to stdout.

EXAMPLES

  • Print the SMART log page in a human readable format:

    # nvme smart-log /dev/nvme0
  • Print the raw SMART log to a file:

    # nvme smart-log /dev/nvme0 --raw-binary > fw_log.raw

    It is probably a bad idea to not redirect stdout when using this mode.

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-smart-log.txt000066400000000000000000000027711267263733400213360ustar00rootroot00000000000000nvme-smart-log(1) ================= NAME ---- nvme-smart-log - Send NVMe SMART log page request, returns result and log SYNOPSIS -------- [verse] 'nvme smart-log' [--namespace-id= | -n ] [--raw-binary | -b] DESCRIPTION ----------- Retrieves the NVMe SMART log page from an NVMe device and provides the retuned structure. The parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1). On success, the returned f/w log structure may be returned in one of several ways depending on the option flags; the structure may parsed by the program and printed in a readable format or the raw buffer may be printed to stdout for another program to parse. OPTIONS ------- -n :: --namespace-id=:: Retrieve the SMART log for the given nsid. This is optional and its success may depend on the device's capabilities to provide this log on a per-namespace basis (see the NVMe Identify Controller for this capability). The default nsid to use is 0xffffffff for the device global SMART log. -b:: --raw-binary:: Print the raw SMART log buffer to stdout. EXAMPLES -------- * Print the SMART log page in a human readable format: + ------------ # nvme smart-log /dev/nvme0 ------------ + * Print the raw SMART log to a file: + ------------ # nvme smart-log /dev/nvme0 --raw-binary > fw_log.raw ------------ + It is probably a bad idea to not redirect stdout when using this mode. NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-subsystem-reset.1000066400000000000000000000033701267263733400221240ustar00rootroot00000000000000'\" t .\" Title: nvme-subsystem-reset .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 03/17/2016 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-SUBSYSTEM\-RES" "1" "03/17/2016" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-subsystem-reset \- Reset the nvme subsystem\&. .SH "SYNOPSIS" .sp .nf \fInvme subsystem\-reset\fR .fi .SH "DESCRIPTION" .sp Requests NVMe subsystem reset\&. The param is mandatory and must be an NVMe character device (ex: /dev/nvme0)\&. .SH "OPTIONS" .sp None .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Resets the subsystem\&. .sp .if n \{\ .RS 4 .\} .nf # nvme subsystem\-reset /dev/nvme0 .fi .if n \{\ .RE .\} .RE .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-subsystem-reset.html000066400000000000000000000426011267263733400227300ustar00rootroot00000000000000 nvme-subsystem-reset(1)

SYNOPSIS

nvme subsystem-reset <device>

DESCRIPTION

Requests NVMe subsystem reset. The <device> param is mandatory and must be an NVMe character device (ex: /dev/nvme0).

OPTIONS

None

EXAMPLES

  • Resets the subsystem.

    # nvme subsystem-reset /dev/nvme0

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-subsystem-reset.txt000066400000000000000000000007341267263733400226040ustar00rootroot00000000000000nvme-subsystem-reset(1) ======================= NAME ---- nvme-subsystem-reset - Reset the nvme subsystem. SYNOPSIS -------- [verse] 'nvme subsystem-reset' DESCRIPTION ----------- Requests NVMe subsystem reset. The param is mandatory and must be an NVMe character device (ex: /dev/nvme0). OPTIONS ------- None EXAMPLES -------- * Resets the subsystem. + ------------ # nvme subsystem-reset /dev/nvme0 ------------ NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-write-uncor.1000066400000000000000000000034011267263733400212170ustar00rootroot00000000000000'\" t .\" Title: nvme-uncor .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 03/02/2016 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-UNCOR" "1" "03/02/2016" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-write-uncor \- Send an NVMe write uncorrectable command, return results .SH "SYNOPSIS" .sp .nf \fInvme\-write\-zeroes\fR [\-\-start\-block= | \-s ] [\-\-block\-count= | \-c ] [\-\-namespace\-id= | \-n ] .fi .SH "DESCRIPTION" .sp The Write Zeroes command is used to set a range of logical blocks to 0\&. .SH "OPTIONS" .PP \-\-start\-block=, \-s .RS 4 Start block\&. .RE .SH "EXAMPLES" .sp No examples yet\&. .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-write-uncor.html000066400000000000000000000430101267263733400220230ustar00rootroot00000000000000 nvme-uncor(1)

SYNOPSIS

nvme-write-zeroes <device> [--start-block=<slba> | -s <slba>]
                        [--block-count=<nlb> | -c <nlb>]
                        [--namespace-id=<nsid> | -n <nsid>]

DESCRIPTION

The Write Zeroes command is used to set a range of logical blocks to 0.

OPTIONS

--start-block=<slba>
-s <slba>

Start block.

EXAMPLES

No examples yet.

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-write-uncor.txt000066400000000000000000000010071267263733400216760ustar00rootroot00000000000000nvme-uncor(1) ============= NAME ---- nvme-write-uncor - Send an NVMe write uncorrectable command, return results SYNOPSIS -------- [verse] 'nvme-write-zeroes' [--start-block= | -s ] [--block-count= | -c ] [--namespace-id= | -n ] DESCRIPTION ----------- The Write Zeroes command is used to set a range of logical blocks to 0. OPTIONS ------- --start-block=:: -s :: Start block. EXAMPLES -------- No examples yet. NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-write-zeroes.1000066400000000000000000000041521267263733400214040ustar00rootroot00000000000000'\" t .\" Title: nvme-zeroes .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 03/02/2016 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-ZEROES" "1" "03/02/2016" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-write-zeroes \- Send an NVMe write zeroes command, return results .SH "SYNOPSIS" .sp .nf \fInvme\-write\-zeroes\fR [\-\-start\-block= | \-s ] [\-\-block\-count= | \-c ] [\-\-ref\-tag= | \-r ] [\-\-prinfo= | \-p ] [\-\-app\-tag\-mask= | \-m ] [\-\-app\-tag= | \-a ] [\-\-limited\-retry | \-l] [\-\-force\-unit\-access | \-f] [\-\-namespace\-id= | \-n ] .fi .SH "DESCRIPTION" .sp The Write Zeroes command is used to set a range of logical blocks to 0\&. .SH "OPTIONS" .PP \-\-start\-block=, \-s .RS 4 Start block\&. .RE .SH "EXAMPLES" .sp No examples yet\&. .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-write-zeroes.html000066400000000000000000000436161267263733400222200ustar00rootroot00000000000000 nvme-zeroes(1)

SYNOPSIS

nvme-write-zeroes <device> [--start-block=<slba> | -s <slba>]
                        [--block-count=<nlb> | -c <nlb>]
                        [--ref-tag=<reftag> | -r <reftag>]
                        [--prinfo=<prinfo> | -p <prinfo>]
                        [--app-tag-mask=<appmask> | -m <appmask>]
                        [--app-tag=<apptag> | -a <apptag>]
                        [--limited-retry | -l]
                        [--force-unit-access | -f]
                        [--namespace-id=<nsid> | -n <nsid>]

DESCRIPTION

The Write Zeroes command is used to set a range of logical blocks to 0.

OPTIONS

--start-block=<slba>
-s <slba>

Start block.

EXAMPLES

No examples yet.

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-write-zeroes.txt000066400000000000000000000013311267263733400220570ustar00rootroot00000000000000nvme-zeroes(1) ============== NAME ---- nvme-write-zeroes - Send an NVMe write zeroes command, return results SYNOPSIS -------- [verse] 'nvme-write-zeroes' [--start-block= | -s ] [--block-count= | -c ] [--ref-tag= | -r ] [--prinfo= | -p ] [--app-tag-mask= | -m ] [--app-tag= | -a ] [--limited-retry | -l] [--force-unit-access | -f] [--namespace-id= | -n ] DESCRIPTION ----------- The Write Zeroes command is used to set a range of logical blocks to 0. OPTIONS ------- --start-block=:: -s :: Start block. EXAMPLES -------- No examples yet. NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme-write.1000066400000000000000000000050111267263733400200720ustar00rootroot00000000000000'\" t .\" Title: nvme-write .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 03/02/2016 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME\-WRITE" "1" "03/02/2016" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme-write \- Send an NVMe write command, provide results .SH "SYNOPSIS" .sp .nf \fInvme\-write\fR [\-\-start\-block= | \-s ] [\-\-block\-count= | \-c ] [\-\-data\-size= | \-z ] [\-\-metadata\-size= | \-y ] [\-\-ref\-tag= | \-r ] [\-\-data= | \-d ] [\-\-metadata= | \-M ] [\-\-prinfo= | \-p ] [\-\-app\-tag\-mask= | \-m ] [\-\-app\-tag= | \-a ] [\-\-limited\-retry | \-l] [\-\-latency | \-t] [\-\-force\-unit\-access | \-f] .fi .SH "DESCRIPTION" .sp The Write command writes the logical blocks specified by the command to the medium from the data data buffer provided\&. Will use stdin by default if you don\(cqt provide a file\&. .SH "OPTIONS" .PP \-\-start\-block=, \-s .RS 4 Start block\&. .RE .PP \-\-latency, \-t .RS 4 Print out the latency the IOCTL took (in us)\&. .RE .SH "EXAMPLES" .sp No examples yet\&. .SH "NVME" .sp Part of the nvme\-user suite nvme-cli-0.5/Documentation/nvme-write.html000066400000000000000000000446211267263733400207100ustar00rootroot00000000000000 nvme-write(1)

SYNOPSIS

nvme-write <device> [--start-block=<slba> | -s <slba>]
                        [--block-count=<nlb> | -c <nlb>]
                        [--data-size=<size> | -z <size>]
                        [--metadata-size=<size> | -y <size>]
                        [--ref-tag=<reftag> | -r <reftag>]
                        [--data=<data-file> | -d <data-file>]
                        [--metadata=<metadata-file> | -M <metadata-file>]
                        [--prinfo=<prinfo> | -p <prinfo>]
                        [--app-tag-mask=<appmask> | -m <appmask>]
                        [--app-tag=<apptag> | -a <apptag>]
                        [--limited-retry | -l]
                        [--latency | -t]
                        [--force-unit-access | -f]

DESCRIPTION

The Write command writes the logical blocks specified by the command to the medium from the data data buffer provided. Will use stdin by default if you don’t provide a file.

OPTIONS

--start-block=<slba>
-s <slba>

Start block.

--latency
-t

Print out the latency the IOCTL took (in us).

EXAMPLES

No examples yet.

NVME

Part of the nvme-user suite


nvme-cli-0.5/Documentation/nvme-write.txt000066400000000000000000000020011267263733400205450ustar00rootroot00000000000000nvme-write(1) ============= NAME ---- nvme-write - Send an NVMe write command, provide results SYNOPSIS -------- [verse] 'nvme-write' [--start-block= | -s ] [--block-count= | -c ] [--data-size= | -z ] [--metadata-size= | -y ] [--ref-tag= | -r ] [--data= | -d ] [--metadata= | -M ] [--prinfo= | -p ] [--app-tag-mask= | -m ] [--app-tag= | -a ] [--limited-retry | -l] [--latency | -t] [--force-unit-access | -f] DESCRIPTION ----------- The Write command writes the logical blocks specified by the command to the medium from the data data buffer provided. Will use stdin by default if you don't provide a file. OPTIONS ------- --start-block=:: -s :: Start block. --latency:: -t:: Print out the latency the IOCTL took (in us). EXAMPLES -------- No examples yet. NVME ---- Part of the nvme-user suite nvme-cli-0.5/Documentation/nvme.1000066400000000000000000000112001267263733400167370ustar00rootroot00000000000000'\" t .\" Title: nvme .\" Author: [see the "Authors" section] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 03/02/2016 .\" Manual: NVMe Manual .\" Source: NVMe .\" Language: English .\" .TH "NVME" "1" "03/02/2016" "NVMe" "NVMe Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" nvme \- the dumb pci\-e storage utility .SH "SYNOPSIS" .sp .nf \fInvme\fR [] .fi .SH "DESCRIPTION" .sp NVM\-Express is a fast, scalable host controller interface designed to address the needs for PCI Express based solid state drives\&. .sp This \fInvme\fR program is a user space utility to provide standards compliant tooling for NVM\-Express drives\&. It was made specifically for Linux as it relies on the IOCTLs defined by the mainline kernel driver\&. .SH "NVME COMMANDS" .sp The utility has sub\-commands for all admin and io commands defined in the specification and for displaying controller registers\&. There is also an option to submit completely arbitrary commands\&. For a list of commands available, run "nvme help"\&. .SH "NVME CLI SUB-COMMANDS" .SS "Main commands" .PP \fBnvme-admin-passthru\fR(1) .RS 4 Admin Passthrough Command .RE .PP \fBnvme-compare\fR(1) .RS 4 IO Compare .RE .PP \fBnvme-error-log\fR(1) .RS 4 Retrieve error logs .RE .PP \fBnvme-flush\fR(1) .RS 4 Submit flush .RE .PP \fBnvme-dms\fR(1) .RS 4 Submit Data Set Management .RE .PP \fBnvme-format\fR(1) .RS 4 Format namespace(s) .RE .PP \fBnvme-fw-activate\fR(1) .RS 4 F/W Activate .RE .PP \fBnvme-fw-download\fR(1) .RS 4 F/W Download .RE .PP \fBnvme-fw-log\fR(1) .RS 4 Retrieve f/w log .RE .PP \fBnvme-get-feature\fR(1) .RS 4 Get Features .RE .PP \fBnvme-get-log\fR(1) .RS 4 Generic Get Log .RE .PP \fBnvme-smart-log\fR(1) .RS 4 Retrieve Smart Log .RE .PP \fBnvme-get-ns-id\fR(1) .RS 4 Retrieve namespace identifier .RE .PP \fBnvme-help\fR(1) .RS 4 NVMe CLI Help .RE .PP \fBnvme-id-ctrl\fR(1) .RS 4 Identify Controller .RE .PP \fBnvme-id-ns\fR(1) .RS 4 Identify Namespace .RE .PP \fBnvme-create-ns\fR(1) .RS 4 Create a new namespace .RE .PP \fBnvme-delete-ns\fR(1) .RS 4 Delete existing namespace .RE .PP \fBnvme-attach-ns\fR(1) .RS 4 Attach namespace .RE .PP \fBnvme-detach-ns\fR(1) .RS 4 Detach namespace .RE .PP \fBnvme-io-passthru\fR(1) .RS 4 IO Passthrough Command .RE .PP \fBnvme-list-ns\fR(1) .RS 4 List all nvme namespaces .RE .PP \fBnvme-list\fR(1) .RS 4 List all nvme controllers .RE .PP \fBnvme-list-ctrl\fR(1) .RS 4 List controller in NVMe subsystem .RE .PP \fBnvme-read\fR(1) .RS 4 Issue IO Read Command .RE .PP \fBnvme-write\fR(1) .RS 4 Issue IO Write Command .RE .PP \fBnvme-write-zeroes\fR(1) .RS 4 Issue IO Write Zeroes Command .RE .PP \fBnvme-write-uncor\fR(1) .RS 4 Issue IO Write Uncorrectable Command .RE .PP \fBnvme-resv-acquire\fR(1) .RS 4 Acquire Namespace Reservation .RE .PP \fBnvme-resv-register\fR(1) .RS 4 Register Namespace Reservation .RE .PP \fBnvme-resv-release\fR(1) .RS 4 Release Namespace Reservation .RE .PP \fBnvme-resv-report\fR(1) .RS 4 Report Reservation Capabilities .RE .PP \fBnvme-security-recv\fR(1) .RS 4 Security Receive .RE .PP \fBnvme-security-send\fR(1) .RS 4 Security Send .RE .PP \fBnvme-set-feature\fR(1) .RS 4 Set Feature .RE .PP \fBnvme-show-regs\fR(1) .RS 4 Show NVMe Controller Registers .RE .SH "FURTHER DOCUMENTATION" .sp See the freely available references on the \m[blue]\fBOfficial NVM\-Express Site\fR\m[]\&\s-2\u[1]\d\s+2\&. .SH "AUTHORS" .sp This is written and maintained by \m[blue]\fBKeith Busch\fR\m[]\&\s-2\u[2]\d\s+2\&. .SH "REPORTING BUGS" .sp Patches and issues may be submitted to the official repository at \m[blue]\fBhttps://github\&.com/linux\-nvme/nvme\-cli\fR\m[]\&. .SH "NVME" .sp Part of the nvme suite .SH "NOTES" .IP " 1." 4 Official NVM-Express Site .RS 4 \%http://nvmexpress.org .RE .IP " 2." 4 Keith Busch .RS 4 \%mailto:keith.busch@intel.com .RE nvme-cli-0.5/Documentation/nvme.html000066400000000000000000000565621267263733400175670ustar00rootroot00000000000000 nvme(1)

SYNOPSIS

nvme <command> <device> [<args>]

DESCRIPTION

NVM-Express is a fast, scalable host controller interface designed to address the needs for PCI Express based solid state drives.

This nvme program is a user space utility to provide standards compliant tooling for NVM-Express drives. It was made specifically for Linux as it relies on the IOCTLs defined by the mainline kernel driver.

NVME COMMANDS

The utility has sub-commands for all admin and io commands defined in the specification and for displaying controller registers. There is also an option to submit completely arbitrary commands. For a list of commands available, run "nvme help".

nvme cli sub-commands

Main commands

nvme-admin-passthru(1)

Admin Passthrough Command

nvme-compare(1)

IO Compare

nvme-error-log(1)

Retrieve error logs

nvme-flush(1)

Submit flush

nvme-dms(1)

Submit Data Set Management

nvme-format(1)

Format namespace(s)

nvme-fw-activate(1)

F/W Activate

nvme-fw-download(1)

F/W Download

nvme-fw-log(1)

Retrieve f/w log

nvme-get-feature(1)

Get Features

nvme-get-log(1)

Generic Get Log

nvme-smart-log(1)

Retrieve Smart Log

nvme-get-ns-id(1)

Retrieve namespace identifier

nvme-help(1)

NVMe CLI Help

nvme-id-ctrl(1)

Identify Controller

nvme-id-ns(1)

Identify Namespace

nvme-create-ns(1)

Create a new namespace

nvme-delete-ns(1)

Delete existing namespace

nvme-attach-ns(1)

Attach namespace

nvme-detach-ns(1)

Detach namespace

nvme-io-passthru(1)

IO Passthrough Command

nvme-list-ns(1)

List all nvme namespaces

nvme-list(1)

List all nvme controllers

nvme-list-ctrl(1)

List controller in NVMe subsystem

nvme-read(1)

Issue IO Read Command

nvme-write(1)

Issue IO Write Command

nvme-write-zeroes(1)

Issue IO Write Zeroes Command

nvme-write-uncor(1)

Issue IO Write Uncorrectable Command

nvme-resv-acquire(1)

Acquire Namespace Reservation

nvme-resv-register(1)

Register Namespace Reservation

nvme-resv-release(1)

Release Namespace Reservation

nvme-resv-report(1)

Report Reservation Capabilities

nvme-security-recv(1)

Security Receive

nvme-security-send(1)

Security Send

nvme-set-feature(1)

Set Feature

nvme-show-regs(1)

Show NVMe Controller Registers

FURTHER DOCUMENTATION

See the freely available references on the Official NVM-Express Site.

Authors

This is written and maintained by Keith Busch.

Reporting Bugs

Patches and issues may be submitted to the official repository at https://github.com/linux-nvme/nvme-cli.

NVME

Part of the nvme suite


nvme-cli-0.5/Documentation/nvme.txt000066400000000000000000000023651267263733400174320ustar00rootroot00000000000000nvme(1) ======= NAME ---- nvme - the dumb pci-e storage utility SYNOPSIS -------- [verse] 'nvme' [] DESCRIPTION ----------- NVM-Express is a fast, scalable host controller interface designed to address the needs for PCI Express based solid state drives. This 'nvme' program is a user space utility to provide standards compliant tooling for NVM-Express drives. It was made specifically for Linux as it relies on the IOCTLs defined by the mainline kernel driver. NVME COMMANDS ------------- The utility has sub-commands for all admin and io commands defined in the specification and for displaying controller registers. There is also an option to submit completely arbitrary commands. For a list of commands available, run "nvme help". nvme cli sub-commands --------------------- Main commands ~~~~~~~~~~~~~ include::cmds-main.txt[] FURTHER DOCUMENTATION --------------------- See the freely available references on the http://nvmexpress.org[Official NVM-Express Site]. Authors ------- This is written and maintained by mailto:keith.busch@intel.com[Keith Busch]. Reporting Bugs -------------- Patches and issues may be submitted to the official repository at https://github.com/linux-nvme/nvme-cli. NVME ---- Part of the nvme suite nvme-cli-0.5/LICENSE000066400000000000000000000431531267263733400141200ustar00rootroot00000000000000GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. {description} Copyright (C) {year} {fullname} This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. {signature of Ty Coon}, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. nvme-cli-0.5/Makefile000066400000000000000000000101761267263733400145520ustar00rootroot00000000000000CFLAGS += -std=gnu99 -O2 -g -Wall -Werror CPPFLAGS += -I $(SRC) -D_GNU_SOURCE NVME = nvme INSTALL ?= install SRC = ./src DESTDIR = PREFIX ?= /usr/local SBINDIR = $(PREFIX)/sbin LIBUDEV := $(shell ld -o /dev/null -ludev >/dev/null 2>&1; echo $$?) LIB_DEPENDS = RPMBUILD = rpmbuild TAR = tar RM = rm -f AUTHOR=Keith Busch ifeq ($(LIBUDEV),0) override LDFLAGS += -ludev override CFLAGS += -DLIBUDEV_EXISTS override LIB_DEPENDS += udev endif default: $(NVME) NVME-VERSION-FILE: FORCE @$(SHELL_PATH) ./NVME-VERSION-GEN -include NVME-VERSION-FILE override CFLAGS += -DNVME_VERSION='"$(NVME_VERSION)"' NVME_DPKG_VERSION=1~`lsb_release -sc` nvme: nvme.c ./linux/nvme.h argconfig.o suffix.o nvme-print.o nvme-ioctl.o NVME-VERSION-FILE $(CC) $(CPPFLAGS) $(CFLAGS) nvme.c $(LDFLAGS) -o $(NVME) argconfig.o suffix.o nvme-print.o nvme-ioctl.o nvme-ioctl.o: nvme-ioctl.c nvme-ioctl.h $(CC) $(CPPFLAGS) $(CFLAGS) -c nvme-ioctl.c argconfig.o: $(SRC)/argconfig.c $(SRC)/argconfig.h $(SRC)/suffix.h $(CC) $(CPPFLAGS) $(CFLAGS) -c $(SRC)/argconfig.c suffix.o: $(SRC)/suffix.c $(SRC)/suffix.h $(CC) $(CPPFLAGS) $(CFLAGS) -c $(SRC)/suffix.c nvme-print.o: nvme-print.c nvme-print.h $(CC) $(CPPFLAGS) $(CFLAGS) -c nvme-print.c doc: $(NVME) $(MAKE) -C Documentation all: doc clean: $(RM) $(NVME) *.o *~ a.out NVME-VERSION-FILE *.tar* nvme.spec version control nvme-*.deb $(MAKE) -C Documentation clean clobber: clean $(MAKE) -C Documentation clobber install-man: $(MAKE) -C Documentation install-no-build install-bin: default $(INSTALL) -d $(DESTDIR)$(SBINDIR) $(INSTALL) -m 755 nvme $(DESTDIR)$(SBINDIR) install: install-bin install-man nvme.spec: nvme.spec.in NVME-VERSION-FILE sed -e 's/@@VERSION@@/$(NVME_VERSION)/g' < $< > $@+ mv $@+ $@ dist: nvme.spec git archive --format=tar --prefix=nvme-$(NVME_VERSION)/ HEAD > nvme-$(NVME_VERSION).tar @echo $(NVME_VERSION) > version $(TAR) rf nvme-$(NVME_VERSION).tar nvme.spec version gzip -f -9 nvme-$(NVME_VERSION).tar control: nvme.control.in NVME-VERSION-FILE sed -e 's/@@VERSION@@/$(NVME_VERSION)/g' < $< > $@+ mv $@+ $@ sed -e 's/@@DEPENDS@@/$(LIB_DEPENDS)/g' < $@ > $@+ mv $@+ $@ pkg: control nvme.control.in mkdir -p nvme-$(NVME_VERSION)$(SBINDIR) mkdir -p nvme-$(NVME_VERSION)$(PREFIX)/share/man/man1 mkdir -p nvme-$(NVME_VERSION)/DEBIAN/ cp Documentation/*.1 nvme-$(NVME_VERSION)$(PREFIX)/share/man/man1 cp nvme nvme-$(NVME_VERSION)$(SBINDIR) cp control nvme-$(NVME_VERSION)/DEBIAN/ # Make a reproducible tar.gz in the super-directory. Uses # git-restore-mtime if available to adjust timestamps. ../nvme-cli_$(NVME_VERSION).orig.tar.gz: find . -type f -perm -u+rwx -exec chmod 0755 '{}' + find . -type f -perm -u+rw '!' -perm -u+x -exec chmod 0644 '{}' + if which git-restore-mtime >/dev/null; then git-restore-mtime; fi git ls-files | tar cf ../nvme-cli_$(NVME_VERSION).orig.tar \ --owner=root --group=root \ --transform='s#^#nvme-cli-$(NVME_VERSION)/#' --files-from - touch -d "`git log --format=%ci -1`" ../nvme-cli_$(NVME_VERSION).orig.tar gzip -f -9 ../nvme-cli_$(NVME_VERSION).orig.tar dist-orig: ../nvme-cli_$(NVME_VERSION).orig.tar.gz # Create a throw-away changelog, which dpkg-buildpackage uses to # determine the package version. deb-changelog: printf '%s\n\n * Auto-release.\n\n %s\n' \ "nvme-cli ($(NVME_VERSION)-$(NVME_DPKG_VERSION)) `lsb_release -sc`; urgency=low" \ "-- $(AUTHOR) `git log -1 --format=%cD`" \ > debian/changelog deb: deb-changelog dist-orig dpkg-buildpackage -uc -us -sa # After this target is build you need to do a debsign and dput on the # ../.changes file to upload onto the relevant PPA. For example: # # > make AUTHOR='First Last ' \ # NVME_DPKG_VERSION='0ubuntu1' deb-ppa # > debsign .changes # > dput ppa:/ppa .changes # # where lid is your launchpad.net ID. deb-ppa: deb-changelog dist-orig debuild -uc -us -S deb-light: $(NVME) pkg nvme.control.in dpkg-deb --build nvme-$(NVME_VERSION) rpm: dist $(RPMBUILD) -ta nvme-$(NVME_VERSION).tar.gz .PHONY: default doc all clean clobber install-man install-bin install .PHONY: dist pkg dist-orig deb deb-light rpm FORCE nvme-cli-0.5/NVME-VERSION-GEN000077500000000000000000000013711267263733400153340ustar00rootroot00000000000000#!/bin/sh GVF=NVME-VERSION-FILE DEF_VER=v0.5 LF=' ' # First see if there is a version file (included in release tarballs), # then try git-describe, then default. if test -f version then VN=$(cat version) || VN="$DEF_VER" elif test -d .git -o -f .git && VN=$(git describe --tags --match "v[0-9]*" --abbrev=4 HEAD 2>/dev/null) && case "$VN" in *$LF*) (exit 1) ;; v[0-9]*) git update-index -q --refresh test -z "$(git diff-index --name-only HEAD --)" || VN="$VN-dirty" ;; esac then VN=$(echo "$VN" | sed -e 's/-/./g'); else VN="$DEF_VER" fi VN=$(expr "$VN" : v*'\(.*\)') if test -r $GVF then VC=$(sed -e 's/^NVME_VERSION = //' <$GVF) else VC=unset fi test "$VN" = "$VC" || { echo >&2 "NVME_VERSION = $VN" echo "NVME_VERSION = $VN" >$GVF } nvme-cli-0.5/README.md000066400000000000000000000043021267263733400143630ustar00rootroot00000000000000# nvme-cli NVM-Express user space tooling for Linux. To install, run: # make && make install If not sure how to use, find the top-level documentation with: # man nvme Or find a short summary with: # nvme help ## Distro Support ### Fedora nvme-cli is available in Fedora 23 and up. Install it with your favorite package manager. For example: $ sudo dnf install nvme-cli ### Ubuntu nvme-cli is supported in the Universe package sources for Xenial for many architectures. For a complete list try running: ``` rmadison nvme-cli nvme-cli | 0.3-1 | xenial/universe | source, amd64, arm64, armhf, i386, powerpc, ppc64el, s390x ``` A Debian based package for nvme-cli is currently maintained as a Ubuntu PPA. Right now there is support for Trusty, Vivid and Wiley. To install nvme-cli using this approach please perform the following steps: 1. Add the sbates PPA to your sources. One way to do this is to run ``` sudo add-apt-repository ppa:sbates ``` 2. Perform an update of your repository list: ``` sudo apt-get update ``` 3. Get nvme-cli! ``` sudo apt-get install nvme-cli ``` 4. Test the code. ``` sudo nvme list ``` In the case of no NVMe devices you will see ``` No NVMe devices detected. ``` otherwise you will see information about each NVMe device installed in the system. ### AlpineLinux nvme-cli is tested on AlpineLinux 3.3. Install it using: # akp update && apk add nvme-cli nvme-cli-doc the "list" command will not work unless you installed udev for some reason. ``` # nvme list nvme-list: libudev not detected, install and rebuild. ``` if you just use the device you're after, it will work flawless. ``` # nvme smart-log /dev/nvme0 Smart Log for NVME device:/dev/nvme0 namespace-id:ffffffff critical_warning : 0 temperature : 49 C available_spare : 100% ``` ### openSUSE Tumbleweed nvme-cli is available in openSUSE Tumbleweed. You can install it using zypper. For example: $ sudo zypper install nvme-cli ### Arch Linux Install from AUR, e.g.: ``` $ yaourt -S nvme-cli-git ``` ### Other Distros TBD nvme-cli-0.5/completions/000077500000000000000000000000001267263733400154415ustar00rootroot00000000000000nvme-cli-0.5/completions/README000066400000000000000000000077651267263733400163400ustar00rootroot00000000000000Kelly Kaoudis, kelly.n.kaoudis at intel.com, June 2015 Setting Up NVMe Tab Autocompletion for bash or zsh ================================================== If your working shell is bash... -------------------------------- the following gets bash autocompletion to behave properly #echo "bind 'set show-all-if-ambiguous on'" >> ~/.bashrc #echo "bind 'set show-all-if-unmodified on'" >> ~/.bashrc #echo "bind 'set completion-ignore-case on'" >> ~/.bashrc #echo "bind 'set completion-map-case on'" >> ~/.bashrc add NVMe autocompletion script to your autocompletes directory #cp `pwd`/bash-nvme-completion.sh /etc/bash_completion.d/nvme make sure this bash knows where everything is #source /etc/bash_completion.d/nvme && source ~/.bashrc you should be able to autocomplete with the nvme utility now (double TABs still apply)! If autocompleting has disappeared, just re-source nvme and .bashrc. To see a full list of auto-completable NVMe commands, type "nvme help " and hit TAB. You may also need to uncomment the "enable bash completion in interactive shells" part of /etc/bash.bashrc, which hopefully looks somehting like: if [ -f /usr/share/bash-completion/bash_completion ]; then . /usr/share/bash-completion/bash_completion elif [ -f /etc/bash_completion ]; then . /etc/bash_completion fi (don't bother with the shopt part, your Bash version might not support shopt). Bash footnote: for bash vers >= 4.2, it appears to be the case that menu-complete **no longer works.** If the bash dev folks ever re-patch this, try binding TAB to menu-complete to cycle through the NVMe subcommand matches on whatever you typed. if your working shell is zsh... ------------------------------- create the zsh completions directory if you don't have it #if [ ! -e "~/.zsh" ]; then # mkdir ~/.zsh # mkdir ~/.zsh/completion #fi #cp `pwd`/_nvme ~/.zsh/completion/_nvme add compinit if you don't have it in your .zshrc #echo "autoload -Uz compinit && compinit" >> ~/.zshrc add nvme autocompletions to your .zshrc #echo "# source for tab autocompletions" >> ~/.zshrc #echo "fpath=(~/.zsh/completion $fpath)" >> ~/.zshrc #echo "source ~/.zsh/completion/_nvme" >> ~/.zshrc make sure this zsh knows where everything is #source ~/.zsh/completion/_nvme && source ~/.zshrc You should be able to autocomplete with the nvme utility now (single TAB press should get you a completion with descriptions -- sadly, bash doesn't support descriptions within completions). If autocompletes disappear, just re-source _nvme and .zshrc. Also, make sure your .zshrc is ordered correctly: we want to source _nvme before updating our fpath. Both of these should occur before compinit is loaded. Updating NVMe Tab Autocompletions ================================= zsh --- Add your new command to the _cmds array in the following format: 'command:short-form description' Add a case to the zsh case statement for autocompletion of subopts in the following format (as seen in _nvme): (bar) local _list_of_subopts _list_of_subopts=( /dev/nvme':supply a device to use (required)' --foo':do something cool' -f':alias of --foo' ) _arguments '*:: :->subcmds' _describe -t commands "nvme bar options" _list_of_subopts ;; All zsh autocompletion built-ins start with _, and so should anything internal to your autocompletes. _arguments and _describe are built-ins. The '*:: :->subcmds' bit describes the format in which we want our options to be displayed (don't change this, unless you like pain.) _describe -t adds our list of options to the data structure associated with our command `bar'. Add the name of your command to the (help) case as well. Update your ~/.zsh/completion/_nvme with your new changes and re-source as needed. bash ---- Add the name of your command to _cmds in bash_nvme_completion.sh. Add a case to _nvme_list_opts in the following format: "bar") opts+="--foo= -f --baz= -b" ;; Update your /etc/bash_completion.d/nvme version, and re-source things as needed. TO DO ----- Automatically generate man pages and autocompletions for new NVMe commands, possibly with kerneldoc. nvme-cli-0.5/completions/_nvme000066400000000000000000000542001267263733400164710ustar00rootroot00000000000000#compdef _nvme nvme # zsh completions for the nvme command-line interface, # very loosely based on git and adb command completion # Kelly Kaoudis kelly.n.kaoudis at intel.com, June 2015 _nvme () { local -a _cmds _cmds=( 'id-ctrl:display information about the controller' 'id-ns:display information about the namespace' 'list-ns:identify all namespace(s) attached' 'create-ns:create a new namespace before attachment' 'delete-ns:delete a detached namespace' 'attach-ns:attach namespace to controller' 'detach-ns:detach namespace from controller' 'list-ctrl:identify all controller(s) attached' 'get-ns-id:get namespace id of opened block device' 'get-log:retrieve any log in raw format' 'fw-log:retrieve fw log' 'smart-log:retrieve SMART log' 'smart-log-add:retrieve additional SMART log' 'error-log:retrieve error log' 'get-feature:display a controller feature' 'set-feature:set a controller feature and show results' 'format:apply new block format to namespace' 'fw-activate:activate a firmware on the device' 'fw-download:download a firmware to the device' 'admin-passthru:submit a passthrough IOCTL' 'io-passthru:submit a passthrough IOCTL' 'security-send:send security/secure data to controller' 'security-recv:ask for security/secure data from controller' 'resv-acquire:acquire reservation on a namespace' 'resv-register:register reservation on a namespace' 'resv-release:release reservation on a namespace' 'resv-report:report reservation on a namespace' 'flush:submit a flush' 'compare:compare data on device to data elsewhere' 'read:submit a read command' 'write:submit a write command' 'show-regs:shows the controller registers; requires admin character device' 'help:print brief descriptions of all nvme commands' ) local expl _arguments '*:: :->subcmds' && return 0 if (( CURRENT == 1 )); then _describe -t commands "nvme subcommands" _cmds return else case ${words[CURRENT-1]} in (id-ctrl) local _idctrl _idctrl=( /dev/nvme':supply a device to use (required)' --raw-binary':dump infos in binary format' -b':alias of --raw-binary' --human-readable':show infos in readable format' -H':alias of --human-readable' --vendor-specific':also dump binary vendor infos' -v':alias of --vendor-specific' ) _arguments '*:: :->subcmds' _describe -t commands "nvme id-ctrl options" _idctrl ;; (id-ns) local _idns _idns=( /dev/nvme':supply a device to use (required)' --namespace-id=':show infos for namespace ' -n':alias of --namespace-id' --raw-binary':dump infos in binary format' -b':alias of --raw-binary' --human-readable':show infos in readable format' -H':alias of --human-readable' --vendor-specific':also dump binary vendor infos' -v':alias of --vendor-specific' ) _arguments '*:: :->subcmds' _describe -t commands "nvme id-ns options" _idns ;; (list-ns) local _listns _listns=( /dev/nvme':supply a device to use (required)' --namespace-id=':start namespace infos listing with this nsid' -n':alias of --namespace-id' ) _arguments '*:: :->subcmds' _describe -t commands "nvme list-ns options" _listns ;; (create-ns) local _createns _createns=( /dev/nvme':supply a device to use (required)' --nsze=':namespace size to create' -s':alias of --nsze' --ncap=':namespace capacity' -c':alias of --ncap' --flbas=':FLBA size' -f':alias of --flbas' --dps=':data protection?' -d':alias of --dps' --nmic=':multipath and sharing' -n':alias of --nmic' ) _arguments '*:: :->subcmds' _describe -t commands "nvme create-ns options" _createns ;; (delete-ns) local _deletens _deletens=( /dev/nvme':supply a device to use (required)' --namespace-id=':namespace to delete' -n':alias of --namespace-id' ) _arguments '*:: :->subcmds' _describe -t commands "nvme delete-ns options" _deletens ;; (attach-ns) local _attachns _attachns=( /dev/nvme':supply a device to use (required)' --namespace-id=':namespace to attach to the controller' -n':alias of --namespace-id' --controllers=':if a device is not provided, supply a comma-sep list of controllers' -c':alias of --controllers' ) _arguments '*:: :->subcmds' _describe -t commands "nvme attach-ns options" _attachns ;; (detach-ns) local _detachns _detachns=( /dev/nvme':supply a device to use (required)' --namespace-id=':namespace to detach from controller' -n':alias of --namespace-id' --controllers=':if a device is not provided, supply a comma-sep list of controllers' -c':alias of --controllers' ) _arguments '*:: :->subcmds' _describe -t commands "nvme detach-ns options" _detachns ;; (list-ctrl) local _listctrl _listctrl=( /dev/nvme':supply a device to use (required)' --namespace-id=':show controllers attached to this namespace' -n':alias of --namespace-id' --cntid=':start the list with this controller' -c':alias of --cntid' ) _arguments '*:: :->subcmds' _describe -t commands "nvme list-ctrl options" _listctrl ;; (get-ns-id) local _getnsid _getnsid=( /dev/nvme':supply a device to use (required)' ) _arguments '*:: :->subcmds' _describe -t commands "nvme get-ns-id options" _getnsid ;; (get-log) local _getlog _getlog=( /dev/nvme':supply a device to use (required)' --log-id=':requested log number' -i':alias of --log-id' --log-len=':number of bytes to show for requested log' -l':alias of --log-len' --namespace-id=':get log specific to if namespace logs are supported' -n':alias of --namespace-id' --raw-binary':dump infos in binary format' -b':alias of --raw-binary' ) _arguments '*:: :->subcmds' _describe -t commands "nvme get-log options" _getlog ;; (fw-log) local _fwlog _fwlog=( /dev/nvme':supply a device to use (required)' --raw-binary':dump infos in binary format' -b':alias of --raw-binary' ) _arguments '*:: :->subcmds' _describe -t commands "nvme fw-log options" _fwlog ;; (smart-log) local _smartlog _smartlog=( /dev/nvme':supply a device to use (required)' --namespace-id=':get SMART log specific to if namespace logs are supported' -n':alias to --namespace-id' --raw-binary':dump infos in binary format' -b':alias to --raw-binary' ) _arguments '*:: :->subcmds' _describe -t commands "nvme smart-log options" _smartlog ;; (smart-log-add) local _add _add=( /dev/nvme':supply a device to use (required)' --namespace-id=':get additional SMART log specific to if namespace logs supported' -n':alias to --namespace-id' --raw-binary':dump infos in binary format' -b':alias to --raw-binary' ) _arguments '*:: :->subcmds' _describe -t commands "nvme smart-log-add options" _add ;; (error-log) local _errlog _errlog=( /dev/nvme':supply a device to use (required)' --namespace-id=':get log specific to if namespace logs are supported' -n':alias to --namespace-id' --raw-binary':dump infos in binary format' -b':alias to --raw-binary' --log-entries=':request n >= 1 log entries' -e':alias to --log-entries' ) _arguments '*:: :->subcmds' _describe -t commands "nvme error-log options" _errlog ;; (get-feature) local _getf _getf=( /dev/nvme':supply a device to use (required)' --namespace-id=':get feature specific to ' -n':alias to --namespace-id' --feature-id=':hexadecimal name of feature to examine (required)' -f':alias to --feature-id' --sel=':select from 0 - current, 1 - default, 2 - saved, 3 - supported' -s':alias to --sel' --data-len=':buffer len for returned LBA Type Range or host identifier data' -l':alias for --data-len' --cdw11=':dword 11 value, used for interrupt vector configuration only' --raw-binary':dump infos in binary format' -b':alias to --raw-binary' ) _arguments '*:: :->subcmds' _describe -t commands "nvme get-feature options" _getf ;; (set-feature) local _setf _setf=( /dev/nvme':supply a device to use (required)' --namespace-id=':feature is specific to ' -n':alias to --namespace-id' --feature-id=':hexadecimal name of feature to set (required)' -f':alias to --feature-id' --data-len=':buffer length, only used for LBA Type Range or host identifier data' -l':alias for --data-len' --data=':data file for LBA Type Range or host identifier buffer (defaults to stdin)' -d':alias to --data' --value=':new value of feature (required)' -v'alias to --value' ) _arguments '*:: :->subcmds' _describe -t commands "nvme set-feature options" _setf ;; (format) local _format _format=( /dev/nvme':supply a device to use (required)' --namespace-id=': of namespace to format (required)' -n':alias of --namespace-id' --lbaf=':LBA format to apply to namespace (required)' -l':alias of --lbaf' --ses=':secure erase? 0 - no-op (default), 1 - user-data erase, 2 - cryptographic erase' -s':alias of --ses' --pil=':location of protection information? 0 - end, 1 - start' -p':alias of --pil' --pi=':protection information? 0 - off, 1 - Type 1 on, 2 - Type 2 on, 3 - Type 3 on' -i':alias of --pi' --ms=':extended format? 0 - off (metadata in separate buffer), 1 - on (extended LBA used)' -m':alias of --ms' ) _arguments '*:: :->subcmds' _describe -t commands "nvme format options" _format ;; (fw-activate) local _fwact _fwact=( /dev/nvme':supply a device to use (required)' --action=':activation action (required)? 0 - replace fw without activating, 1 - replace with activation, 2 - replace with activation at next reset' -a':alias of --action' --slot=':firmware slot to activate' -s':alias of --slot' ) _arguments '*:: :->subcmds' _describe -t commands "nvme fw-activate options" _fwact ;; (fw-download) local _fwd _fwd=( /dev/nvme':supply a device to use (required)' --fw=':firmware file to download (required)' -f':alias of --fw' --xfer=':limit on chunk-size of transfer (if device has download size limit)' -x':alias of --xfer' --offset=':starting offset, in dwords (defaults to 0, only useful if download is split across multiple files)' -o':alias of --offset' ) _arguments '*:: :->subcmds' _describe -t commands "nvme fw-download options" _fwd ;; (admin-passthru) local _admin _admin=( /dev/nvme':supply a device to use (required)' --opcode=':hexadecimal opcode to send (required)' -o':alias of --opcode' --flags=':command flags' -f':alias of --flags' --rsvd=':value for reserved field' -R':alias of --rsvd' --namespace-id=':value for nsid' -n':alias of --namespace-id' --data-len=':length for data buffer' -l':alias of --data-len' --metadata-len=':length for metadata buffer' -m':alias of --metadata-len' --timeout=':value for timeout' -t':alias of --timeout' --cdw2=':value for command dword 2' -2':alias for --cdw2' --cdw3=':value for command dword 3' -3':alias for --cdw3' --cdw10=':value for command dword 10' -4':alias for --cdw10' --cdw11=':value for command dword 11' -5':alias for --cdw11' --cdw12=':value for command dword 12' -6':alias for --cdw12' --cdw13=':value for command dword 13' -7':alias for --cdw13' --cdw14=':value for command dword 14' -8':alias for command dword 14' --cdw15=':value for command dword 15' -9':alias for command dword 15' --input-file=':defaults to stdin; input for write (send direction)' -i':alias for --input-file' --raw-binary':dump output in binary format' -b':alias for --raw-binary' --show-command':simply print command instead of sending it to ' -s':alias for --show-command' --dry-run':alias for --show-command' -d':alias for --show-command' --read':set dataflow direction to receive' -r':alias for --read' --write':set dataflow direction to send' -w':alias for --write' ) _arguments '*:: :->subcmds' _describe -t commands "nvme admin-passthru options" _admin ;; (io-passthru) local _io _io=( /dev/nvme':supply a device to use (required)' --opcode=':hexadecimal opcode to send (required)' -o':alias of --opcode' --flags=':command flags' -f':alias of --flags' --rsvd=':value for reserved field' -R':alias of --rsvd' --namespace-id=':value for nsid' -n':alias of --namespace-id' --data-len=':length for data buffer' -l':alias of --data-len' --metadata-len=':length for metadata buffer' -m':alias of --metadata-len' --timeout=':value for timeout' -t':alias of --timeout' --cdw2=':value for command dword 2' -2':alias for --cdw2' --cdw3=':value for command dword 3' -3':alias for --cdw3' --cdw10=':value for command dword 10' -4':alias for --cdw10' --cdw11=':value for command dword 11' -5':alias for --cdw11' --cdw12=':value for command dword 12' -6':alias for --cdw12' --cdw13=':value for command dword 13' -7':alias for --cdw13' --cdw14=':value for command dword 14' -8':alias for command dword 14' --cdw15=':value for command dword 15' -9':alias for command dword 15' --input-file=':defaults to stdin; input for write (send direction)' -i':alias for --input-file' --raw-binary':dump output in binary format' -b':alias for --raw-binary' --show-command':simply print command instead of sending it to ' -s':alias for --show-command' --dry-run':alias for --show-command' -d':alias for --show-command' --read':set dataflow direction to receive' -r':alias for --read' --write':set dataflow direction to send' -w':alias for --write' ) _arguments '*:: :->subcmds' _describe -t commands "nvme io-passthru options" _io ;; (security-send) local _ssend _ssend=( /dev/nvme':supply a device to use (required)' --file=':payload' -f':alias for --file' --secp=':security protocol as defined in SPC-4' -p':alias for --secp' --spsp=':send security-protocol-specific data as defined in SPC-4' -s':alias for --spsp' --tl=':transfer length as defined in SPC-4' -t':alias for --tl' ) _arguments '*:: :->subcmds' _describe -t commands "nvme security-send options" _ssend ;; (security-recv) local _srecv _srecv=( /dev/nvme':supply a device to use (required)' --secp=':security protocol as defined in SPC-4' -p':alias for --secp' --spsp=':send security-protocol-specific data as defined in SPC-4' -s':alias for --spsp' --size=':size of buffer (prints to stdout on successful recv)' -x':alias for --size' --al=':allocation length as defined in SPC-4' -a':alias for --al' --raw-binary':dump output in binary format' -b':alias for --raw-binary' ) _arguments '*:: :->subcmds' _describe -t commands "nvme security-recv options" _srecv ;; (resv-acquire) local _acq _acq=( /dev/nvme':supply a device to use (required)' --namespace-id=': of namespace to try to reserve (required)' -n':alias for --namespace-id' --prkey=':pre-empt reservation key' -p':alias for --prkey' --rtype=':hexadecimal reservation type' -t':alias for --rtype' --racqa=':reservation acquiry action' -a':alias for --racqa' --iekey=':ignore existing reservation key' -i':alias for --iekey' --crkey':current reservation key' -c':alias for --crkey' ) _arguments '*:: :->subcmds' _describe -t commands "nvme resv-acquire options" _acq ;; (resv-release) local _rel _rel=( /dev/nvme':supply a device to use (required)' --namespace-id=':nsid' -n':alias of --namespace-id' --rtype=':hexadecimal reservation type' -t':alias of --rtype' --rrela=':reservation release action' -a':alias of --rrela' --iekey':ignore existing reservation key' -i':alias of --iekey' ) _arguments '*:: :->subcmds' _describe -t commands "nvme resv-release options" _rel ;; (resv-report) local _rep _rep=( /dev/nvme':supply a device to use (required)' --namespace-id=':nsid' -n':alias of --namespace-id' --numd=':number of dwords of reservation status to xfer' -d':alias of --numd' --raw-binary':dump output in binary format' -b':alias of --raw-binary' ) _arguments '*:: :->subcmds' _describe -t commands "nvme resv-report options" _rep ;; (resv-register) local _reg _reg=( /dev/nvme':supply a device to use (required)' --namespace-id=':nsid' -n':alias of --namespace-id' --crkey=':current reservation key' -c'alias of --crkey' --nrkey=':new reservation key' -k':alias of --nrkey' --cptpl=':change persistence through power loss setting' -p':alias for --cptpl' --rrega=':reservation registration action to perform' -a':alias for --rrega' --iekey':ignore existing reservation key' -i':alias for --iekey' ) _arguments '*:: :->subcmds' _describe -t commands "nvme resv-register options" _reg ;; (flush) local _flush _flush=( /dev/nvme':supply a device to use (required)' --namespace-id=':nsid' -n':alias of --namespace-id' ) _arguments '*:: :->subcmds' _describe -t commands "nvme flush options" _flush ;; (compare) local _comp _comp=( /dev/nvme':supply a device to use (required)' --start-block=':begin compare at this 64-bit LBA on device' -s':alias of --start-block' --block-count=':number of logical blocks on device to compare to local data' -c':alias of --block-count' --metadata-size=':number of bytes of metadata to compare' -y':alias of --metadata-size' --data-size=':size of local data buffer in bytes' -z':alias of --data-size' --data=':local data file to compare to blocks on device' -d':alias of --data' --prinfo=':protection information action and check field' -p':alias of --prinfo' --app-tag-mask=':application tag mask (for end to end PI)' -m':alias of --app-tag-mask' --app-tag=':application tag (for end to end PI)' -a':alias of --app-tag' --limited-retry':if included, controller should try less hard to retrieve data from media (if not included, all available data recovery means used)' -l':alias of --limited-retry' --force-unit-access':if included, the data shall be read from non-volatile media' -f':alias of --force-unit access' --show-command':show command instead of sending to device' -v':alias of --show-command' --dry-run':show command instead of sending to device' -w':alias of --show-command' ) _arguments '*:: :->subcmds' _describe -t commands "nvme compare options" _comp ;; (read) local _read _read=( /dev/nvme':supply a device to use (required)' --start-block=':64-bit address of the first logical block to be read' -s':alias of --start-block' --block-count=':number of logical blocks on device to read' -c':alias of --block-count' --data-size=':size of data to be read' -z':alias of --data-size' --metadata-size=':size of metadata to be read' -y':alias of --metadata-size' --ref-tag=':reference tag (for end to end PI)' -r':alias of --ref-tag' --data=':file into which data should be read (defaults to stdout)' -d':alias of --data' --prinfo=':protection information and check field' -p':alias of --prinfo' --app-tag-mask=':application tag mask (for end to end PI)' -m':alias of --app-tag-mask' --app-tag=':application tag (for end to end PI)' -a':alias of --app-tag' --limited-retry=':if included, controller should try less hard to retrieve data from media (if not included, all available data-recovery means used)' -l':alias of --limited-retry' --latency':latency statistics will be output following read' -t':alias of --latency' --force-unit-access':data read shall be returned from nonvolatile media before command completion is indicated' -f':alias of --force-unit-access' --show-command':show command instead of sending to device' -v':alias of --show-command' --dry-run':show command instead of sending to device' -w':alias of --show-command' ) _arguments '*:: :->subcmds' _describe -t commands "nvme read options" _read ;; (write) local _wr _wr=( /dev/nvme':supply a device to use (required)' --start-block=':64-bit address of the first logical block to be written' -s':alias of --start-block' --block-count=':number of logical blocks on device to write' -c':alias of --block-count' --data-size=':size of data to be written' -z':alias of --data-size' --metadata-size=':size of metadata to be written' -y':alias of --metadata-size' --ref-tag=':reference tag (for end to end PI)' -r':alias of --ref-tag' --data=':file from which data should be written to device (defaults to stdin)' -d':alias of --data' --prinfo=':protection information and check field' -p':alias of --prinfo' --app-tag-mask=':application tag mask (for end to end PI)' -m':alias of --app-tag-mask' --app-tag=':application tag (for end to end PI)' -a':alias of --app-tag' --limited-retry=':if included, controller should try less hard to send data to media (if not included, all available data-recovery means used)' -l':alias of --limited-retry' --latency':latency statistics will be output following write' -t':alias of --latency' --force-unit-access':data shall be written to nonvolatile media before command completion is indicated' -f':alias of --force-unit-access' --show-command':show command instead of sending to device' -v':alias of --show-command' --dry-run':show command instead of sending to device' -w':alias of --show-command' ) _arguments '*:: :->subcmds' _describe -t commands "nvme write options" _wr ;; (show-regs) local _shor _shor=( /dev/nvme':supply a device to use (required)' ) _arguments '*:: :->subcmds' _describe -t commands "nvme show-regs options" _shor ;; (help) local _h _h=( id-ctrl id-ns list-ns create-ns delete-ns attach-ns detach-ns list-ctrl get-ns-id get-log fw-log smart-log error-log get-feature set-feature format fw-activate fw-download admin-passthru io-passthru security-send security-recv resv-acquire resv-register resv-release resv-report flush compare read write show-regs ) _arguments '*:: :->subcmds' _describe -t commands "help: infos on a specific nvme command, or provide no option to see a synopsis of all nvme commands" _h ;; (*) _files ;; esac return fi _files } nvme-cli-0.5/completions/bash-nvme-completion.sh000066400000000000000000000122641267263733400220310ustar00rootroot00000000000000#!/usr/bin/env bash # bash tab completion for the nvme command line utility # (unfortunately, bash won't let me add descriptions to cmds) # Kelly Kaoudis kelly.n.kaoudis at intel.com, Aug. 2015 _cmds="admin-passthru attach-ns compare create-ns delete-ns detach-ns error-log flush format fw-activate fw-download fw-log get-feature get-log get-ns-id help id-ctrl id-ns io-passthru list-ctrl list-ns read resv-acquire resv-register resv-release resv-report security-recv security-send set-feature show-regs smart-log smart-log-add write" _nvme_list_opts () { local opts="/dev/nvme*" case "$1" in "io-passthru") opts+=" --opcode= -o --flags= -f --rsvd= -R --namespace-id= -n --data-len= -l --metadata-len= -m --timeout= -t --cdw2= -2 --cdw3= -3 --cdw10= -4 --cdw11= -5 --cdw12= -6 --cdw13= -7 --cdw14= -8 --cdw15= -9 --input-file= -i --raw-binary= -b --show-command -s --dry-run -d --read -r --write -w" ;; "admin-passthru") opts+=" --opcode= -o --flags= -f --rsvd= -R --namespace-id= -n --data-len= -l --metadata-len= -m --timeout= -t --cdw2= -2 --cdw3= -3 --cdw10= -4 --cdw11= -5 --cdw12= -6 --cdw13= -7 --cdw14= -8 --cdw15= -9 --input-file= -i --raw-binary= -b --show-command -s --dry-run -d --read -r --write -w" ;; "attach-ns") opts+=" --namespace-id= -n --controllers= -c" ;; "compare") opts+=" --start-block= -s --block-count= -c --metadata-size= -y --data-size= -z --data= -d --prinfo= -p --app-tag-mask= -m --app-tag= -a --limited-retry -l --force-unit-access -f" ;; "create-ns") opts+=" --nsze= -s --ncap= -c --flbas= -f --dps= -d --nmic= -n" ;; "delete-ns") opts+=" -namespace-id= -n" ;; "detach-ns") opts+=" --namespace-id= -n --controllers= -c" ;; "error-log") opts+=" --namespace-id= -n --raw-binary -b --log-entries= -e" ;; "flush") opts+=" --namespace-id= -n" ;; "format") opts+=" --namespace-id= -n --lbaf= -l --ses= -s --pil= -p --pi= -i --ms= -m" ;; "fw-activate") opts+=" --action= -a --slot= -s" ;; "fw-download") opts+=" --fw= -f --xfer= -x --offset= -o" ;; "fw-log") opts+=" --raw-binary -b" ;; "get-feature") opts+=" --namespace-id= -n --feature-id= -f --sel= -s --data-len= -l --cdw11= --raw-binary -b" ;; "get-log") opts+=" --log-id= -i --log-len= -l --namespace-id= -n --raw-binary= -b" ;; "get-ns-id") ;; "help") opts=$_cmds ;; "id-ctrl") opts+=" --raw-binary -b --human-readable -H --vendor-specific -v" ;; "id-ns") opts+=" --namespace-id= -n --raw-binary -b --human-readable -H --vendor-specific -v" ;; "list-ctrl") opts+=" --namespace-id= -n --cntid= -c" ;; "list-ns") opts+=" --namespace-id= -n" ;; "read") opts+=" --start-block= -s --block-count= -c --data-size= -z --metadata-size= -y --ref-tag= -r --data= -d --prinfo= -p --app-tag-mask= -m --app-tag= -a --limited-retry -l --latency -t --force-unit-access -f" ;; "resv-acquire") opts+=" --namespace-id= -n --prkey= -p --rtype= -t --racqa= -a --iekey= -i" ;; "resv-register") opts+=" --namespace-id= -n --crkey= -c --nrkey= -k --cptpl= -p --rrega= -a --iekey -i" ;; "resv-release") opts+=" --namespace-id= -n --rtype= -t --rrela= -a --iekey -i" ;; "resv-report") opts+=" --namespace-id= -n --numd= -d --raw-binary= -b" ;; "security-recv") opts+=" --secp= -p --spsp= -s --size= -x --al= -a --raw-binary -b" ;; "security-send") opts+=" --file= -f --secp= -p --spsp= -s --tl= -t" ;; "set-feature") opts+=" --namespace-id= -n --feature-id= -f --data-len= -l --data= -d --value=" ;; "show-regs") ;; "smart-log") opts+=" --namespace-id= -n --raw-binary -b" ;; "smart-log-add") opts+=" --namespace-id= -n --raw-binary -b" ;; "write") opts+=" --start-block= -s --block-count= -c --data-size= -z --metadata-size= -y --ref-tag= -r --data= -d --prinfo= -p --app-tag-mask= -m --app-tag= -a --limited-retry -l --latency -t --force-unit-access -f" ;; esac COMPREPLY+=( $( compgen -W "$opts" -- $cur ) ) return 0 } ## print the reduced sub-command match list in ## a sane way ## _compile_matches () { local matches=$1 local tab_idx=0 local this=${matches[$tab_idx]} while :; do local key=`read -r -n 1` case $key in '\t') echo -en "\033[${#this}D" (($tab_idx++)) this=${matches[$tab_idx]} printf '%s' "$this" ;; *) match_to_stop_on=$this break ;; esac done } ## reduce the full list of NVMe sub-commands to stuff starting with what ## already is part of the current token ## _match_on_cur () { local cmds read -a cmds <<<$_cmds declare -a matches local match_to_stop_on for cmd in ${cmds[@]}; do if [[ "${cmd}" =~ ^"${cur}" ]]; then matches+=("${cmd}") if [[ ${#matches} -lt 2 ]]; then COMPREPLY=($(compgen -W "$cmd" -- $cur ) ) fi fi done if [[ ${#matches} -ge 2 ]]; then _compile_matches $matches COMPREPLY=( $(compgen -W "$match_to_stop_on" -- $cur ) ) fi } _nvme_subcmds () { local prev cur words words=$(_get_comp_words_by_ref words) cur=$(_get_cword) prev=$(_get_pword) if [[ "$_cmds" =~ "$prev" ]]; then _nvme_list_opts $prev elif [[ " \r\n\t\v\e" =~ "$cur" ]]; then _match_on_cur $cur else COMPREPLY+=( $(compgen -W "$_cmds" -- $cur ) ) fi return 0 } complete -o default -F _nvme_subcmds nvme nvme-cli-0.5/debian/000077500000000000000000000000001267263733400143275ustar00rootroot00000000000000nvme-cli-0.5/debian/changelog000066400000000000000000000002321267263733400161760ustar00rootroot00000000000000nvme-cli (0.2-1) unstable; urgency=medium * Initial release. (Closes: #810033) -- Breno Leitao Tue, 05 Jan 2016 14:40:05 -0500 nvme-cli-0.5/debian/compat000066400000000000000000000000021267263733400155250ustar00rootroot000000000000009 nvme-cli-0.5/debian/control000066400000000000000000000010241267263733400157270ustar00rootroot00000000000000Source: nvme-cli Maintainer: Breno Leitao Section: admin Priority: optional Standards-Version: 3.9.6 Build-Depends: debhelper (>= 9), libudev-dev Homepage: https://github.com/linux-nvme/nvme-cli Package: nvme-cli Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Description: userspace tooling to control NVMe drives NVMe is a fast, scalable, direct attached storage interface, accessing solid state drives through PCIe. . The nvme CLI contains core management tools with minimal dependencies. nvme-cli-0.5/debian/copyright000066400000000000000000000013201267263733400162560ustar00rootroot00000000000000Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Source: https://github.com/linux-nvme/nvme-cli Files: * Copyright: 2011-2015 Intel Corporation 2014 PMC-Sierra, Inc License: GPL-2+ License: GPL-2+ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. . This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. nvme-cli-0.5/debian/rules000077500000000000000000000001311267263733400154020ustar00rootroot00000000000000#!/usr/bin/make -f %: dh $@ override_dh_auto_install: dh_auto_install -- PREFIX=/usr nvme-cli-0.5/debian/source/000077500000000000000000000000001267263733400156275ustar00rootroot00000000000000nvme-cli-0.5/debian/source/format000066400000000000000000000000141267263733400170350ustar00rootroot000000000000003.0 (quilt) nvme-cli-0.5/debian/watch000066400000000000000000000002411267263733400153550ustar00rootroot00000000000000version=3 opts="filenamemangle=s/(?:.*?)?v?(\d[\d.]*)\.tar\.gz/nvme-cli-$1.tar.gz/" \ https://github.com/linux-nvme/nvme-cli/tags (?:.*?/)?v?(\d[\d.]*)\.tar\.gz nvme-cli-0.5/linux/000077500000000000000000000000001267263733400142445ustar00rootroot00000000000000nvme-cli-0.5/linux/nvme.h000066400000000000000000000264761267263733400154010ustar00rootroot00000000000000/* * Definitions for the NVM Express interface * Copyright (c) 2011-2014, Intel Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. */ #ifndef _UAPI_LINUX_NVME_H #define _UAPI_LINUX_NVME_H #include struct nvme_error_log_page { __u64 error_count; __u16 sqid; __u16 cmdid; __u16 status_field; __u16 parm_error_location; __u64 lba; __u32 nsid; __u8 vs; __u8 resv[35]; }; struct nvme_firmware_log_page { __u8 afi; __u8 resv[7]; __u64 frs[7]; __u8 resv2[448]; }; struct nvme_id_power_state { __le16 max_power; /* centiwatts */ __u8 rsvd2; __u8 flags; __le32 entry_lat; /* microseconds */ __le32 exit_lat; /* microseconds */ __u8 read_tput; __u8 read_lat; __u8 write_tput; __u8 write_lat; __le16 idle_power; __u8 idle_scale; __u8 rsvd19; __le16 active_power; __u8 active_work_scale; __u8 rsvd23[9]; }; enum { NVME_PS_FLAGS_MAX_POWER_SCALE = 1 << 0, NVME_PS_FLAGS_NON_OP_STATE = 1 << 1, }; struct nvme_id_ctrl { __le16 vid; __le16 ssvid; char sn[20]; char mn[40]; char fr[8]; __u8 rab; __u8 ieee[3]; __u8 cmic; __u8 mdts; __le16 cntlid; __le32 ver; __le32 rtd3r; __le32 rtd3e; __le32 oaes; __u8 rsvd96[160]; __le16 oacs; __u8 acl; __u8 aerl; __u8 frmw; __u8 lpa; __u8 elpe; __u8 npss; __u8 avscc; __u8 apsta; __le16 wctemp; __le16 cctemp; __le16 mtfa; __le32 hmpre; __le32 hmmin; __u8 tnvmcap[16]; __u8 unvmcap[16]; __le32 rpmbs; __u8 rsvd316[196]; __u8 sqes; __u8 cqes; __u8 rsvd514[2]; __le32 nn; __le16 oncs; __le16 fuses; __u8 fna; __u8 vwc; __le16 awun; __le16 awupf; __u8 nvscc; __u8 rsvd531; __le16 acwu; __u8 rsvd534[2]; __le32 sgls; __u8 rsvd540[1508]; struct nvme_id_power_state psd[32]; __u8 vs[1024]; }; enum { NVME_CTRL_ONCS_COMPARE = 1 << 0, NVME_CTRL_ONCS_WRITE_UNCORRECTABLE = 1 << 1, NVME_CTRL_ONCS_DSM = 1 << 2, NVME_CTRL_VWC_PRESENT = 1 << 0, }; struct nvme_lbaf { __le16 ms; __u8 ds; __u8 rp; }; struct nvme_id_ns { __le64 nsze; __le64 ncap; __le64 nuse; __u8 nsfeat; __u8 nlbaf; __u8 flbas; __u8 mc; __u8 dpc; __u8 dps; __u8 nmic; __u8 rescap; __u8 fpi; __u8 rsvd33; __le16 nawun; __le16 nawupf; __le16 nacwu; __le16 nabsn; __le16 nabo; __le16 nabspf; __u16 rsvd46; __u8 nvmcap[16]; __u8 rsvd64[40]; __u8 nguid[16]; __u8 eui64[8]; struct nvme_lbaf lbaf[16]; __u8 rsvd192[192]; __u8 vs[3712]; }; enum { NVME_NS_FEAT_THIN = 1 << 0, NVME_LBAF_RP_BEST = 0, NVME_LBAF_RP_BETTER = 1, NVME_LBAF_RP_GOOD = 2, NVME_LBAF_RP_DEGRADED = 3, }; struct nvme_smart_log { __u8 critical_warning; __u8 temperature[2]; __u8 avail_spare; __u8 spare_thresh; __u8 percent_used; __u8 rsvd6[26]; __u8 data_units_read[16]; __u8 data_units_written[16]; __u8 host_reads[16]; __u8 host_writes[16]; __u8 ctrl_busy_time[16]; __u8 power_cycles[16]; __u8 power_on_hours[16]; __u8 unsafe_shutdowns[16]; __u8 media_errors[16]; __u8 num_err_log_entries[16]; __le32 warning_temp_time; __le32 critical_comp_time; __le16 temp_sensor[8]; __u8 rsvd216[296]; }; enum { NVME_SMART_CRIT_SPARE = 1 << 0, NVME_SMART_CRIT_TEMPERATURE = 1 << 1, NVME_SMART_CRIT_RELIABILITY = 1 << 2, NVME_SMART_CRIT_MEDIA = 1 << 3, NVME_SMART_CRIT_VOLATILE_MEMORY = 1 << 4, }; #pragma pack(push,1) struct nvme_additional_smart_log_item { __u8 key; __u8 _kp[2]; __u8 norm; __u8 _np; union { __u8 raw[6]; struct wear_level { __le16 min; __le16 max; __le16 avg; } wear_level ; struct thermal_throttle { __u8 pct; __u32 count; } thermal_throttle; }; __u8 _rp; }; #pragma pack(pop) struct nvme_additional_smart_log { struct nvme_additional_smart_log_item program_fail_cnt; struct nvme_additional_smart_log_item erase_fail_cnt; struct nvme_additional_smart_log_item wear_leveling_cnt; struct nvme_additional_smart_log_item e2e_err_cnt; struct nvme_additional_smart_log_item crc_err_cnt; struct nvme_additional_smart_log_item timed_workload_media_wear; struct nvme_additional_smart_log_item timed_workload_host_reads; struct nvme_additional_smart_log_item timed_workload_timer; struct nvme_additional_smart_log_item thermal_throttle_status; struct nvme_additional_smart_log_item retry_buffer_overflow_cnt; struct nvme_additional_smart_log_item pll_lock_loss_cnt; struct nvme_additional_smart_log_item nand_bytes_written; struct nvme_additional_smart_log_item host_bytes_written; }; struct nvme_lba_range_type { __u8 type; __u8 attributes; __u8 rsvd2[14]; __u64 slba; __u64 nlb; __u8 guid[16]; __u8 rsvd48[16]; }; struct nvme_host_mem_buffer { __u32 hsize; __u32 hmdlal; __u32 hmdlau; __u32 hmdlec; __u8 rsvd16[4080]; }; struct nvme_auto_pst { __u32 data; __u32 rsvd32; }; enum { NVME_LBART_TYPE_FS = 0x01, NVME_LBART_TYPE_RAID = 0x02, NVME_LBART_TYPE_CACHE = 0x03, NVME_LBART_TYPE_SWAP = 0x04, NVME_LBART_ATTRIB_TEMP = 1 << 0, NVME_LBART_ATTRIB_HIDE = 1 << 1, }; struct nvme_reservation_status { __le32 gen; __u8 rtype; __u8 regctl[2]; __u8 resv5[2]; __u8 ptpls; __u8 resv10[13]; struct { __le16 cntlid; __u8 rcsts; __u8 resv3[5]; __le64 hostid; __le64 rkey; } regctl_ds[]; }; /* I/O commands */ enum nvme_opcode { nvme_cmd_flush = 0x00, nvme_cmd_write = 0x01, nvme_cmd_read = 0x02, nvme_cmd_write_uncor = 0x04, nvme_cmd_compare = 0x05, nvme_cmd_write_zeroes = 0x08, nvme_cmd_dsm = 0x09, nvme_cmd_resv_register = 0x0d, nvme_cmd_resv_report = 0x0e, nvme_cmd_resv_acquire = 0x11, nvme_cmd_resv_release = 0x15, }; enum { NVME_RW_LR = 1 << 15, NVME_RW_FUA = 1 << 14, NVME_RW_DSM_FREQ_UNSPEC = 0, NVME_RW_DSM_FREQ_TYPICAL = 1, NVME_RW_DSM_FREQ_RARE = 2, NVME_RW_DSM_FREQ_READS = 3, NVME_RW_DSM_FREQ_WRITES = 4, NVME_RW_DSM_FREQ_RW = 5, NVME_RW_DSM_FREQ_ONCE = 6, NVME_RW_DSM_FREQ_PREFETCH = 7, NVME_RW_DSM_FREQ_TEMP = 8, NVME_RW_DSM_LATENCY_NONE = 0 << 4, NVME_RW_DSM_LATENCY_IDLE = 1 << 4, NVME_RW_DSM_LATENCY_NORM = 2 << 4, NVME_RW_DSM_LATENCY_LOW = 3 << 4, NVME_RW_DSM_SEQ_REQ = 1 << 6, NVME_RW_DSM_COMPRESSED = 1 << 7, }; enum { NVME_DSMGMT_IDR = 1 << 0, NVME_DSMGMT_IDW = 1 << 1, NVME_DSMGMT_AD = 1 << 2, }; struct nvme_dsm_range { __le32 cattr; __le32 nlb; __le64 slba; }; struct nvme_controller_list { __le16 num; __le16 identifier[]; }; /* Admin commands */ enum nvme_admin_opcode { nvme_admin_delete_sq = 0x00, nvme_admin_create_sq = 0x01, nvme_admin_get_log_page = 0x02, nvme_admin_delete_cq = 0x04, nvme_admin_create_cq = 0x05, nvme_admin_identify = 0x06, nvme_admin_abort_cmd = 0x08, nvme_admin_set_features = 0x09, nvme_admin_get_features = 0x0a, nvme_admin_async_event = 0x0c, nvme_admin_ns_mgmt = 0x0d, nvme_admin_activate_fw = 0x10, nvme_admin_download_fw = 0x11, nvme_admin_ns_attach = 0x15, nvme_admin_format_nvm = 0x80, nvme_admin_security_send = 0x81, nvme_admin_security_recv = 0x82, }; enum { NVME_QUEUE_PHYS_CONTIG = (1 << 0), NVME_CQ_IRQ_ENABLED = (1 << 1), NVME_SQ_PRIO_URGENT = (0 << 1), NVME_SQ_PRIO_HIGH = (1 << 1), NVME_SQ_PRIO_MEDIUM = (2 << 1), NVME_SQ_PRIO_LOW = (3 << 1), NVME_FEAT_ARBITRATION = 0x01, NVME_FEAT_POWER_MGMT = 0x02, NVME_FEAT_LBA_RANGE = 0x03, NVME_FEAT_TEMP_THRESH = 0x04, NVME_FEAT_ERR_RECOVERY = 0x05, NVME_FEAT_VOLATILE_WC = 0x06, NVME_FEAT_NUM_QUEUES = 0x07, NVME_FEAT_IRQ_COALESCE = 0x08, NVME_FEAT_IRQ_CONFIG = 0x09, NVME_FEAT_WRITE_ATOMIC = 0x0a, NVME_FEAT_ASYNC_EVENT = 0x0b, NVME_FEAT_AUTO_PST = 0x0c, NVME_FEAT_HOST_MEM_BUF = 0x0d, NVME_FEAT_SW_PROGRESS = 0x80, NVME_FEAT_HOST_ID = 0x81, NVME_FEAT_RESV_MASK = 0x82, NVME_FEAT_RESV_PERSIST = 0x83, NVME_LOG_ERROR = 0x01, NVME_LOG_SMART = 0x02, NVME_LOG_FW_SLOT = 0x03, NVME_LOG_RESERVATION = 0x80, NVME_FWACT_REPL = (0 << 3), NVME_FWACT_REPL_ACTV = (1 << 3), NVME_FWACT_ACTV = (2 << 3), }; enum { NVME_SC_SUCCESS = 0x0, NVME_SC_INVALID_OPCODE = 0x1, NVME_SC_INVALID_FIELD = 0x2, NVME_SC_CMDID_CONFLICT = 0x3, NVME_SC_DATA_XFER_ERROR = 0x4, NVME_SC_POWER_LOSS = 0x5, NVME_SC_INTERNAL = 0x6, NVME_SC_ABORT_REQ = 0x7, NVME_SC_ABORT_QUEUE = 0x8, NVME_SC_FUSED_FAIL = 0x9, NVME_SC_FUSED_MISSING = 0xa, NVME_SC_INVALID_NS = 0xb, NVME_SC_CMD_SEQ_ERROR = 0xc, NVME_SC_SGL_INVALID_LAST = 0xd, NVME_SC_SGL_INVALID_COUNT = 0xe, NVME_SC_SGL_INVALID_DATA = 0xf, NVME_SC_SGL_INVALID_METADATA = 0x10, NVME_SC_SGL_INVALID_TYPE = 0x11, NVME_SC_LBA_RANGE = 0x80, NVME_SC_CAP_EXCEEDED = 0x81, NVME_SC_NS_NOT_READY = 0x82, NVME_SC_RESERVATION_CONFLICT = 0x83, NVME_SC_CQ_INVALID = 0x100, NVME_SC_QID_INVALID = 0x101, NVME_SC_QUEUE_SIZE = 0x102, NVME_SC_ABORT_LIMIT = 0x103, NVME_SC_ABORT_MISSING = 0x104, NVME_SC_ASYNC_LIMIT = 0x105, NVME_SC_FIRMWARE_SLOT = 0x106, NVME_SC_FIRMWARE_IMAGE = 0x107, NVME_SC_INVALID_VECTOR = 0x108, NVME_SC_INVALID_LOG_PAGE = 0x109, NVME_SC_INVALID_FORMAT = 0x10a, NVME_SC_FIRMWARE_NEEDS_RESET = 0x10b, NVME_SC_INVALID_QUEUE = 0x10c, NVME_SC_FEATURE_NOT_SAVEABLE = 0x10d, NVME_SC_FEATURE_NOT_CHANGEABLE = 0x10e, NVME_SC_FEATURE_NOT_PER_NS = 0x10f, NVME_SC_FW_NEEDS_RESET_SUBSYS = 0x110, NVME_SC_BAD_ATTRIBUTES = 0x180, NVME_SC_INVALID_PI = 0x181, NVME_SC_READ_ONLY = 0x182, NVME_SC_WRITE_FAULT = 0x280, NVME_SC_READ_ERROR = 0x281, NVME_SC_GUARD_CHECK = 0x282, NVME_SC_APPTAG_CHECK = 0x283, NVME_SC_REFTAG_CHECK = 0x284, NVME_SC_COMPARE_FAILED = 0x285, NVME_SC_ACCESS_DENIED = 0x286, NVME_SC_DNR = 0x4000, }; struct nvme_user_io { __u8 opcode; __u8 flags; __u16 control; __u16 nblocks; __u16 rsvd; __u64 metadata; __u64 addr; __u64 slba; __u32 dsmgmt; __u32 reftag; __u16 apptag; __u16 appmask; }; struct nvme_passthru_cmd { __u8 opcode; __u8 flags; __u16 rsvd1; __u32 nsid; __u32 cdw2; __u32 cdw3; __u64 metadata; __u64 addr; __u32 metadata_len; __u32 data_len; __u32 cdw10; __u32 cdw11; __u32 cdw12; __u32 cdw13; __u32 cdw14; __u32 cdw15; __u32 timeout_ms; __u32 result; }; struct nvme_bar { __u64 cap; /* Controller Capabilities */ __u32 vs; /* Version */ __u32 intms; /* Interrupt Mask Set */ __u32 intmc; /* Interrupt Mask Clear */ __u32 cc; /* Controller Configuration */ __u32 rsvd1; /* Reserved */ __u32 csts; /* Controller Status */ __u32 nssr; /* NVM Subsystem Reset */ __u32 aqa; /* Admin Queue Attributes */ __u64 asq; /* Admin SQ Base Address */ __u64 acq; /* Admin CQ Base Address */ __u32 cmbloc; /* Controller Memory Buffer Location */ __u32 cmbsz; /* Controller Memory Buffer Size */ }; #define nvme_admin_cmd nvme_passthru_cmd #define NVME_VS(major, minor) (((major) << 16) | ((minor) << 8)) #define NVME_IOCTL_ID _IO('N', 0x40) #define NVME_IOCTL_ADMIN_CMD _IOWR('N', 0x41, struct nvme_admin_cmd) #define NVME_IOCTL_SUBMIT_IO _IOW('N', 0x42, struct nvme_user_io) #define NVME_IOCTL_IO_CMD _IOWR('N', 0x43, struct nvme_passthru_cmd) #define NVME_IOCTL_RESET _IO('N', 0x44) #define NVME_IOCTL_SUBSYS_RESET _IO('N', 0x45) #endif /* _UAPI_LINUX_NVME_H */ nvme-cli-0.5/nvme-ioctl.c000066400000000000000000000337411267263733400153360ustar00rootroot00000000000000#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "nvme-ioctl.h" int nvme_subsystem_reset(int fd) { static struct stat nvme_stat; int err = fstat(fd, &nvme_stat); if (err < 0) return err; if (!S_ISCHR(nvme_stat.st_mode)) { fprintf(stderr, "Error: requesting subsystem reset on non-controller handle\n"); exit(ENOTBLK); } return ioctl(fd, NVME_IOCTL_SUBSYS_RESET); } int nvme_reset_controller(int fd) { static struct stat nvme_stat; int err = fstat(fd, &nvme_stat); if (err < 0) return err; if (!S_ISCHR(nvme_stat.st_mode)) { fprintf(stderr, "Error: requesting reset on non-controller handle\n"); exit(ENOTBLK); } return ioctl(fd, NVME_IOCTL_RESET); } int nvme_get_nsid(int fd) { static struct stat nvme_stat; int err = fstat(fd, &nvme_stat); if (err < 0) return err; if (!S_ISBLK(nvme_stat.st_mode)) { fprintf(stderr, "Error: requesting namespace-id from non-block device\n"); exit(ENOTBLK); } return ioctl(fd, NVME_IOCTL_ID); } int nvme_submit_passthru(int fd, int ioctl_cmd, struct nvme_passthru_cmd *cmd) { return ioctl(fd, ioctl_cmd, cmd); } int nvme_submit_admin_passthru(int fd, struct nvme_passthru_cmd *cmd) { return ioctl(fd, NVME_IOCTL_ADMIN_CMD, cmd); } int nvme_submit_io_passthru(int fd, struct nvme_passthru_cmd *cmd) { return ioctl(fd, NVME_IOCTL_IO_CMD, cmd); } int nvme_passthru(int fd, int ioctl_cmd, __u8 opcode, __u8 flags, __u16 rsvd, __u32 nsid, __u32 cdw2, __u32 cdw3, __u32 cdw10, __u32 cdw11, __u32 cdw12, __u32 cdw13, __u32 cdw14, __u32 cdw15, __u32 data_len, void *data, __u32 metadata_len, void *metadata, __u32 timeout_ms, __u32 *result) { struct nvme_passthru_cmd cmd = { .opcode = opcode, .flags = flags, .rsvd1 = rsvd, .nsid = nsid, .cdw2 = cdw2, .cdw3 = cdw3, .metadata = (__u64)(uintptr_t) metadata, .addr = (__u64)(uintptr_t) data, .metadata_len = metadata_len, .data_len = data_len, .cdw10 = cdw10, .cdw11 = cdw11, .cdw12 = cdw12, .cdw13 = cdw13, .cdw14 = cdw14, .cdw15 = cdw15, .timeout_ms = timeout_ms, .result = 0, }; int err; err = nvme_submit_passthru(fd, ioctl_cmd, &cmd); if (!err && result) *result = cmd.result; return err; } int nvme_io(int fd, __u8 opcode, __u64 slba, __u16 nblocks, __u16 control, __u32 dsmgmt, __u32 reftag, __u16 apptag, __u16 appmask, void *data, void *metadata) { struct nvme_user_io io = { .opcode = opcode, .flags = 0, .control = control, .nblocks = nblocks, .rsvd = 0, .metadata = (__u64)(uintptr_t) metadata, .addr = (__u64)(uintptr_t) data, .slba = slba, .dsmgmt = dsmgmt, .reftag = reftag, .appmask = apptag, .apptag = appmask, }; return ioctl(fd, NVME_IOCTL_SUBMIT_IO, &io); } int nvme_read(int fd, __u64 slba, __u16 nblocks, __u16 control, __u32 dsmgmt, __u32 reftag, __u16 apptag, __u16 appmask, void *data, void *metadata) { return nvme_io(fd, nvme_cmd_read, slba, nblocks, control, dsmgmt, reftag, apptag, appmask, data, metadata); } int nvme_write(int fd, __u64 slba, __u16 nblocks, __u16 control, __u32 dsmgmt, __u32 reftag, __u16 apptag, __u16 appmask, void *data, void *metadata) { return nvme_io(fd, nvme_cmd_write, slba, nblocks, control, dsmgmt, reftag, apptag, appmask, data, metadata); } int nvme_compare(int fd, __u64 slba, __u16 nblocks, __u16 control, __u32 dsmgmt, __u32 reftag, __u16 apptag, __u16 appmask, void *data, void *metadata) { return nvme_io(fd, nvme_cmd_compare, slba, nblocks, control, dsmgmt, reftag, apptag, appmask, data, metadata); } int nvme_passthru_io(int fd, __u8 opcode, __u8 flags, __u16 rsvd, __u32 nsid, __u32 cdw2, __u32 cdw3, __u32 cdw10, __u32 cdw11, __u32 cdw12, __u32 cdw13, __u32 cdw14, __u32 cdw15, __u32 data_len, void *data, __u32 metadata_len, void *metadata, __u32 timeout_ms) { return nvme_passthru(fd, NVME_IOCTL_IO_CMD, opcode, flags, rsvd, nsid, cdw2, cdw3, cdw10, cdw11, cdw12, cdw13, cdw14, cdw15, data_len, data, metadata_len, metadata, timeout_ms, NULL); } int nvme_write_zeros(int fd, __u32 nsid, __u64 slba, __u16 nlb, __u16 control, __u32 reftag, __u16 apptag, __u16 appmask) { struct nvme_passthru_cmd cmd = { .opcode = nvme_cmd_write_zeroes, .nsid = nsid, .cdw10 = slba & 0xffffffff, .cdw11 = slba >> 32, .cdw12 = nlb | (control << 16), .cdw14 = reftag, .cdw15 = apptag | (appmask << 16), }; return nvme_submit_io_passthru(fd, &cmd); } int nvme_write_uncorrectable(int fd, __u32 nsid, __u64 slba, __u16 nlb) { struct nvme_passthru_cmd cmd = { .opcode = nvme_cmd_write_uncor, .nsid = nsid, .cdw10 = slba & 0xffffffff, .cdw11 = slba >> 32, .cdw12 = nlb, }; return nvme_submit_io_passthru(fd, &cmd); } int nvme_flush(int fd, __u32 nsid) { struct nvme_passthru_cmd cmd = { .opcode = nvme_cmd_flush, .nsid = nsid, }; return nvme_submit_io_passthru(fd, &cmd); } int nvme_dsm(int fd, __u32 nsid, __u32 cdw11, struct nvme_dsm_range *dsm, __u16 nr_ranges) { struct nvme_passthru_cmd cmd = { .opcode = nvme_cmd_dsm, .nsid = nsid, .addr = (__u64)(uintptr_t) dsm, .data_len = nr_ranges * sizeof(*dsm), .cdw10 = nr_ranges - 1, .cdw11 = cdw11, }; return nvme_submit_io_passthru(fd, &cmd); } struct nvme_dsm_range *nvme_setup_dsm_range(__u32 *ctx_attrs, __u32 *llbas, __u64 *slbas, __u16 nr_ranges) { int i; struct nvme_dsm_range *dsm = malloc(nr_ranges * sizeof(*dsm)); if (!dsm) exit(ENOMEM); for (i = 0; i < nr_ranges; i++) { dsm[i].cattr = htole32(ctx_attrs[i]); dsm[i].nlb = htole32(llbas[i]); dsm[i].slba = htole64(slbas[i]); } return dsm; } int nvme_resv_acquire(int fd, __u32 nsid, __u8 rtype, __u8 racqa, bool iekey, __u64 crkey, __u64 nrkey) { __le64 payload[2] = { htole64(crkey), htole64(nrkey) }; __u32 cdw10 = racqa | (iekey ? 1 << 3 : 0) | rtype << 8; struct nvme_passthru_cmd cmd = { .opcode = nvme_cmd_resv_acquire, .nsid = nsid, .cdw10 = cdw10, .addr = (__u64)(uintptr_t) (payload), .data_len = sizeof(payload), }; return nvme_submit_io_passthru(fd, &cmd); } int nvme_resv_register(int fd, __u32 nsid, __u8 rrega, __u8 cptpl, bool iekey, __u64 crkey, __u64 nrkey) { __le64 payload[2] = { htole64(crkey), htole64(nrkey) }; __u32 cdw10 = rrega | (iekey ? 1 << 3 : 0) | cptpl << 30; struct nvme_passthru_cmd cmd = { .opcode = nvme_cmd_resv_register, .nsid = nsid, .cdw10 = cdw10, .addr = (__u64)(uintptr_t) (payload), .data_len = sizeof(payload), }; return nvme_submit_io_passthru(fd, &cmd); } int nvme_resv_release(int fd, __u32 nsid, __u8 rtype, __u8 rrela, bool iekey, __u64 crkey) { __le64 payload[1] = { htole64(crkey) }; __u32 cdw10 = rrela | (iekey ? 1 << 3 : 0) | rtype << 8; struct nvme_passthru_cmd cmd = { .opcode = nvme_cmd_resv_register, .nsid = nsid, .cdw10 = cdw10, .addr = (__u64)(uintptr_t) (payload), .data_len = sizeof(payload), }; return nvme_submit_io_passthru(fd, &cmd); } int nvme_resv_report(int fd, __u32 nsid, __u32 numd, void *data) { struct nvme_passthru_cmd cmd = { .opcode = nvme_cmd_resv_report, .nsid = nsid, .addr = (__u64)(uintptr_t) data, .data_len = numd << 2, }; return nvme_submit_io_passthru(fd, &cmd); } int nvme_passthru_admin(int fd, __u8 opcode, __u8 flags, __u16 rsvd, __u32 nsid, __u32 cdw2, __u32 cdw3, __u32 cdw10, __u32 cdw11, __u32 cdw12, __u32 cdw13, __u32 cdw14, __u32 cdw15, __u32 data_len, void *data, __u32 metadata_len, void *metadata, __u32 timeout_ms) { return nvme_passthru(fd, NVME_IOCTL_ADMIN_CMD, opcode, flags, rsvd, nsid, cdw2, cdw3, cdw10, cdw11, cdw12, cdw13, cdw14, cdw15, data_len, data, metadata_len, metadata, timeout_ms, NULL); } int nvme_identify(int fd, __u32 nsid, __u32 cdw10, void *data) { struct nvme_admin_cmd cmd = { .opcode = nvme_admin_identify, .nsid = nsid, .addr = (__u64)(uintptr_t) data, .data_len = 0x1000, .cdw10 = cdw10, }; return nvme_submit_admin_passthru(fd, &cmd); } int nvme_identify_ctrl(int fd, void *data) { return nvme_identify(fd, 0, 1, data); } int nvme_identify_ns(int fd, __u32 nsid, bool present, void *data) { return nvme_identify(fd, nsid, present ? 0x11 : 0, data); } int nvme_identify_ns_list(int fd, __u32 nsid, bool all, void *data) { return nvme_identify(fd, nsid, all ? 0x10 : 0x2, data); } int nvme_identify_ctrl_list(int fd, __u32 nsid, __u16 cntid, void *data) { return nvme_identify(fd, nsid, (cntid << 16) | (nsid ? 0x13 : 0x12), data); } int nvme_get_log(int fd, __u32 nsid, __u32 cdw10, __u32 data_len, void *data) { struct nvme_admin_cmd cmd = { .opcode = nvme_admin_get_log_page, .nsid = nsid, .addr = (__u64)(uintptr_t) data, .data_len = data_len, .cdw10 = cdw10, }; return nvme_submit_admin_passthru(fd, &cmd); } int nvme_log(int fd, __u32 nsid, __u8 log_id, __u32 data_len, void *data) { __u32 cdw10 = log_id | ((data_len >> 2) - 1) << 16; return nvme_get_log(fd, nsid, cdw10, data_len, data); } int nvme_fw_log(int fd, struct nvme_firmware_log_page *fw_log) { return nvme_log(fd, 0xffffffff, 3, sizeof(*fw_log), fw_log); } int nvme_error_log(int fd, __u32 nsid, int entries, struct nvme_error_log_page *err_log) { return nvme_log(fd, nsid, 1, entries * sizeof(*err_log), err_log); } int nvme_smart_log(int fd, __u32 nsid, struct nvme_smart_log *smart_log) { return nvme_log(fd, nsid, 2, sizeof(*smart_log), smart_log); } int nvme_intel_smart_log(int fd, __u32 nsid, struct nvme_additional_smart_log *intel_smart_log) { return nvme_log(fd, nsid, 0xca, sizeof(*intel_smart_log), intel_smart_log); } int nvme_feature(int fd, __u8 opcode, __u32 nsid, __u32 cdw10, __u32 cdw11, __u32 data_len, void *data, __u32 *result) { struct nvme_admin_cmd cmd = { .opcode = opcode, .nsid = nsid, .cdw10 = cdw10, .cdw11 = cdw11, .addr = (__u64)(uintptr_t) data, .data_len = data_len, }; int err; err = nvme_submit_admin_passthru(fd, &cmd); if (!err && result) *result = cmd.result; return err; } int nvme_set_feature(int fd, __u32 nsid, __u8 fid, __u32 value, bool save, __u32 data_len, void *data, __u32 *result) { __u32 cdw10 = fid | (save ? 1 << 31 : 0); return nvme_feature(fd, nvme_admin_set_features, nsid, cdw10, value, data_len, data, result); } int nvme_get_feature(int fd, __u32 nsid, __u8 fid, __u8 sel, __u32 cdw11, __u32 data_len, void *data, __u32 *result) { __u32 cdw10 = fid | sel << 8; return nvme_feature(fd, nvme_admin_get_features, nsid, cdw10, cdw11, data_len, data, result); } int nvme_format(int fd, __u32 nsid, __u8 lbaf, __u8 ses, __u8 pi, __u8 pil, __u8 ms, __u32 timeout) { __u32 cdw10 = lbaf | ms << 4 | pi << 5 | pil << 8 | ses << 9; struct nvme_admin_cmd cmd = { .opcode = nvme_admin_format_nvm, .nsid = nsid, .cdw10 = cdw10, .timeout_ms = timeout, }; return nvme_submit_admin_passthru(fd, &cmd); } int nvme_ns_create(int fd, __u64 nsze, __u64 ncap, __u8 flbas, __u8 dps, __u8 nmic, __u32 *result) { struct nvme_id_ns ns = { .nsze = htole64(nsze), .ncap = htole64(ncap), .flbas = flbas, .dps = dps, .nmic = nmic, }; struct nvme_admin_cmd cmd = { .opcode = nvme_admin_ns_mgmt, .addr = (__u64)(uintptr_t) ((void *)&ns), .cdw10 = 0, .data_len = 0x1000, }; int err; err = nvme_submit_admin_passthru(fd, &cmd); if (!err && result) *result = cmd.result; return err; } int nvme_ns_delete(int fd, __u32 nsid) { struct nvme_admin_cmd cmd = { .opcode = nvme_admin_ns_mgmt, .nsid = nsid, .cdw10 = 1, }; return nvme_submit_admin_passthru(fd, &cmd); } int nvme_ns_attachment(int fd, __u32 nsid, __u16 num_ctrls, __u16 *ctrlist, bool attach) { int i; __u8 buf[0x1000]; struct nvme_controller_list *cntlist = (struct nvme_controller_list *)buf; struct nvme_admin_cmd cmd = { .opcode = nvme_admin_ns_attach, .addr = (__u64)(uintptr_t) cntlist, .cdw10 = attach ? 0 : 1, .data_len = 0x1000, }; memset(buf, 0, sizeof(buf)); cntlist->num = num_ctrls; for (i = 0; i < cntlist->num; i++) cntlist->identifier[i] = htole16((__u16) ctrlist[i]); return nvme_submit_admin_passthru(fd, &cmd); } int nvme_ns_attach_ctrls(int fd, __u32 nsid, __u16 num_ctrls, __u16 *ctrlist) { return nvme_ns_attachment(fd, nsid, num_ctrls, ctrlist, true); } int nvme_ns_detach_ctrls(int fd, __u32 nsid, __u16 num_ctrls, __u16 *ctrlist) { return nvme_ns_attachment(fd, nsid, num_ctrls, ctrlist, false); } int nvme_fw_download(int fd, __u32 offset, __u32 data_len, void *data) { struct nvme_admin_cmd cmd = { .opcode = nvme_admin_download_fw, .addr = (__u64)(uintptr_t) data, .data_len = data_len, .cdw10 = (data_len >> 2) - 1, .cdw11 = offset >> 2, }; return nvme_submit_admin_passthru(fd, &cmd); } int nvme_fw_activate(int fd, __u8 slot, __u8 action) { struct nvme_admin_cmd cmd = { .opcode = nvme_admin_activate_fw, .cdw10 = (action << 3) | slot, }; return nvme_submit_admin_passthru(fd, &cmd); } int nvme_sec_send(int fd, __u32 nsid, __u8 nssf, __u16 spsp, __u8 secp, __u32 tl, __u32 data_len, void *data, __u32 *result) { struct nvme_admin_cmd cmd = { .opcode = nvme_admin_security_send, .addr = (__u64)(uintptr_t) data, .data_len = data_len, .nsid = nsid, .cdw10 = secp << 24 | spsp << 8 | nssf, .cdw11 = tl, }; int err; err = nvme_submit_admin_passthru(fd, &cmd); if (!err && result) *result = cmd.result; return err; } int nvme_sec_recv(int fd, __u32 nsid, __u8 nssf, __u16 spsp, __u8 secp, __u32 al, __u32 data_len, void *data, __u32 *result) { struct nvme_admin_cmd cmd = { .opcode = nvme_admin_security_recv, .cdw10 = secp << 24 | spsp << 8 | nssf, .cdw11 = al, .addr = (__u64)(uintptr_t) data, .data_len = data_len, }; int err; err = nvme_submit_admin_passthru(fd, &cmd); if (!err && result) *result = cmd.result; return err; } nvme-cli-0.5/nvme-ioctl.h000066400000000000000000000114151267263733400153350ustar00rootroot00000000000000#ifndef _NVME_LIB_H #define _NVME_LIB_H #include #include "linux/nvme.h" int nvme_get_nsid(int fd); /* Generic passthrough */ int nvme_submit_passthru(int fd, int ioctl_cmd, struct nvme_passthru_cmd *cmd); int nvme_passthru(int fd, int ioctl_cmd, __u8 opcode, __u8 flags, __u16 rsvd, __u32 nsid, __u32 cdw2, __u32 cdw3, __u32 cdw10, __u32 cdw11, __u32 cdw12, __u32 cdw13, __u32 cdw14, __u32 cdw15, __u32 data_len, void *data, __u32 metadata_len, void *metadata, __u32 timeout_ms, __u32 *result); /* NVME_SUBMIT_IO */ int nvme_io(int fd, __u8 opcode, __u64 slba, __u16 nblocks, __u16 control, __u32 dsmgmt, __u32 reftag, __u16 apptag, __u16 appmask, void *data, void *metadata); int nvme_read(int fd, __u64 slba, __u16 nblocks, __u16 control, __u32 dsmgmt, __u32 reftag, __u16 apptag, __u16 appmask, void *data, void *metadata); int nvme_write(int fd, __u64 slba, __u16 nblocks, __u16 control, __u32 dsmgmt, __u32 reftag, __u16 apptag, __u16 appmask, void *data, void *metadata); int nvme_compare(int fd, __u64 slba, __u16 nblocks, __u16 control, __u32 dsmgmt, __u32 reftag, __u16 apptag, __u16 appmask, void *data, void *metadata); /* NVME_IO_CMD */ int nvme_passthru_io(int fd, __u8 opcode, __u8 flags, __u16 rsvd, __u32 nsid, __u32 cdw2, __u32 cdw3, __u32 cdw10, __u32 cdw11, __u32 cdw12, __u32 cdw13, __u32 cdw14, __u32 cdw15, __u32 data_len, void *data, __u32 metadata_len, void *metadata, __u32 timeout); int nvme_write_zeros(int fd, __u32 nsid, __u64 slba, __u16 nlb, __u16 control, __u32 reftag, __u16 apptag, __u16 appmask); int nvme_write_uncorrectable(int fd, __u32 nsid, __u64 slba, __u16 nlb); int nvme_flush(int fd, __u32 nsid); int nvme_dsm(int fd, __u32 nsid, __u32 cdw11, struct nvme_dsm_range *dsm, __u16 nr_ranges); struct nvme_dsm_range *nvme_setup_dsm_range(__u32 *ctx_attrs, __u32 *llbas, __u64 *slbas, __u16 nr_ranges); int nvme_resv_acquire(int fd, __u32 nsid, __u8 rtype, __u8 racqa, bool iekey, __u64 crkey, __u64 nrkey); int nvme_resv_register(int fd, __u32 nsid, __u8 rrega, __u8 cptpl, bool iekey, __u64 crkey, __u64 nrkey); int nvme_resv_release(int fd, __u32 nsid, __u8 rtype, __u8 rrela, bool iekey, __u64 crkey); int nvme_resv_report(int fd, __u32 nsid, __u32 numd, void *data); /* NVME_ADMIN_CMD */ int nvme_passthru_admin(int fd, __u8 opcode, __u8 flags, __u16 rsvd, __u32 nsid, __u32 cdw2, __u32 cdw3, __u32 cdw10, __u32 cdw11, __u32 cdw12, __u32 cdw13, __u32 cdw14, __u32 cdw15, __u32 data_len, void *data, __u32 metadata_len, void *metadata, __u32 timeout); int nvme_identify(int fd, __u32 nsid, __u32 cdw10, void *data); int nvme_identify_ctrl(int fd, void *data); int nvme_identify_ns(int fd, __u32 nsid, bool present, void *data); int nvme_identify_ns_list(int fd, __u32 nsid, bool all, void *data); int nvme_identify_ctrl_list(int fd, __u32 nsid, __u16 cntid, void *data); int nvme_get_log(int fd, __u32 nsid, __u32 cdw10, __u32 data_len, void *data); int nvme_log(int fd, __u32 nsid, __u8 log_id, __u32 data_len, void *data); int nvme_fw_log(int fd, struct nvme_firmware_log_page *fw_log); int nvme_error_log(int fd, __u32 nsid, int entries, struct nvme_error_log_page *err_log); int nvme_smart_log(int fd, __u32 nsid, struct nvme_smart_log *smart_log); int nvme_intel_smart_log(int fd, __u32 nsid, struct nvme_additional_smart_log *intel_smart_log); int nvme_feature(int fd, __u8 opcode, __u32 nsid, __u32 cdw10, __u32 cdw11, __u32 data_len, void *data, __u32 *result); int nvme_set_feature(int fd, __u32 nsid, __u8 fid, __u32 value, bool save, __u32 data_len, void *data, __u32 *result); int nvme_get_feature(int fd, __u32 nsid, __u8 fid, __u8 sel, __u32 cdw11, __u32 data_len, void *data, __u32 *result); int nvme_format(int fd, __u32 nsid, __u8 lbaf, __u8 ses, __u8 pi, __u8 pil, __u8 ms, __u32 timeout); int nvme_ns_create(int fd, __u64 nsze, __u64 ncap, __u8 flbas, __u8 dps, __u8 nmic, __u32 *result); int nvme_ns_delete(int fd, __u32 nsid); int nvme_ns_attachment(int fd, __u32 nsid, __u16 num_ctrls, __u16 *ctrlist, bool attach); int nvme_ns_attach_ctrls(int fd, __u32 nsid, __u16 num_ctrls, __u16 *ctrlist); int nvme_ns_detach_ctrls(int fd, __u32 nsid, __u16 num_ctrls, __u16 *ctrlist); int nvme_fw_download(int fd, __u32 offset, __u32 data_len, void *data); int nvme_fw_activate(int fd, __u8 slot, __u8 action); int nvme_sec_send(int fd, __u32 nsid, __u8 nssf, __u16 spsp, __u8 secp, __u32 tl, __u32 data_len, void *data, __u32 *result); int nvme_sec_recv(int fd, __u32 nsid, __u8 nssf, __u16 spsp, __u8 secp, __u32 al, __u32 data_len, void *data, __u32 *result); int nvme_subsystem_reset(int fd); int nvme_reset_controller(int fd); #endif /* _NVME_LIB_H */ nvme-cli-0.5/nvme-print.c000066400000000000000000001100521267263733400153470ustar00rootroot00000000000000#include #include #include #include "nvme-print.h" static long double int128_to_double(__u8 *data) { int i; long double result = 0; for (i = 0; i < 16; i++) { result *= 256; result += data[15 - i]; } return result; } void d(unsigned char *buf, int len, int width, int group) { int i, offset = 0, line_done = 0; char ascii[width + 1]; printf(" "); for (i = 0; i <= 15; i++) printf("%3x", i); for (i = 0; i < len; i++) { line_done = 0; if (i % width == 0) printf( "\n%04x:", offset); if (i % group == 0) printf( " %02x", buf[i]); else printf( "%02x", buf[i]); ascii[i % width] = (buf[i] >= '!' && buf[i] <= '~') ? buf[i] : '.'; if (((i + 1) % width) == 0) { ascii[i % width + 1] = '\0'; printf( " \"%.*s\"", width, ascii); offset += width; line_done = 1; } } if (!line_done) { unsigned b = width - (i % width); ascii[i % width + 1] = '\0'; printf( " %*s \"%.*s\"", 2 * b + b / group + (b % group ? 1 : 0), "", width, ascii); } printf( "\n"); } void d_raw(unsigned char *buf, unsigned len) { unsigned i; for (i = 0; i < len; i++) putchar(*(buf+i)); } static void show_nvme_id_ctrl_cmic(__u8 cmic) { __u8 rsvd = (cmic & 0xF8) >> 3; __u8 sriov = (cmic & 0x4) >> 2; __u8 mctl = (cmic & 0x2) >> 1; __u8 mp = cmic & 0x1; if (rsvd) printf(" [7:3] : %#x\tReserved\n", rsvd); printf(" [2:2] : %#x\t%s\n", sriov, sriov ? "SR-IOV" : "PCI"); printf(" [1:1] : %#x\t%s Controller\n", mctl, mctl ? "Multi" : "Single"); printf(" [0:0] : %#x\t%s Port\n", mp, mp ? "Multi" : "Single"); printf("\n"); } static void show_nvme_id_ctrl_oaes(__le32 ctrl_oaes) { __u32 oaes = le32toh(ctrl_oaes); __u32 rsvd0 = (oaes & 0xFFFFFE00) >> 9; __u32 nace = (oaes & 0x100) >> 8; __u32 rsvd1 = oaes & 0xFF; if (rsvd0) printf(" [31:9] : %#x\tReserved\n", rsvd0); printf(" [8:8] : %#x\tNamespace Attribute Changed Event %sSupported\n", nace, nace ? "" : "Not "); if (rsvd1) printf(" [7:0] : %#x\tReserved\n", rsvd1); printf("\n"); } static void show_nvme_id_ctrl_oacs(__le16 ctrl_oacs) { __u16 oacs = le16toh(ctrl_oacs); __u16 rsvd = (oacs & 0xFFF0) >> 4; __u16 nsm = (oacs & 0x8) >> 3; __u16 fwc = (oacs & 0x4) >> 2; __u16 fmt = (oacs & 0x2) >> 1; __u16 sec = oacs & 0x1; if (rsvd) printf(" [15:4] : %#x\tReserved\n", rsvd); printf(" [3:3] : %#x\tNS Management and Attachment %sSupported\n", nsm, nsm ? "" : "Not "); printf(" [2:2] : %#x\tFW Commit and Download %sSupported\n", fwc, fwc ? "" : "Not "); printf(" [1:1] : %#x\tFormat NVM %sSupported\n", fmt, fmt ? "" : "Not "); printf(" [0:0] : %#x\tSec. Send and Receive %sSupported\n", sec, sec ? "" : "Not "); printf("\n"); } static void show_nvme_id_ctrl_frmw(__u8 frmw) { __u8 rsvd = (frmw & 0xE0) >> 5; __u8 fawr = (frmw & 0x10) >> 4; __u8 nfws = (frmw & 0xE) >> 1; __u8 s1ro = frmw & 0x1; if (rsvd) printf(" [7:5] : %#x\tReserved\n", rsvd); printf(" [4:4] : %#x\tFirmware Activate Without Reset %sSupported\n", fawr, fawr ? "" : "Not "); printf(" [3:1] : %#x\tNumber of Firmware Slots\n", nfws); printf(" [0:0] : %#x\tFirmware Slot 1 Read%s\n", s1ro, s1ro ? "-Only" : "/Write"); printf("\n"); } static void show_nvme_id_ctrl_lpa(__u8 lpa) { __u8 rsvd = (lpa & 0xFC) >> 2; __u8 celp = (lpa & 0x2) >> 1; __u8 smlp = lpa & 0x1; if (rsvd) printf(" [7:2] : %#x\tReserved\n", rsvd); printf(" [1:1] : %#x\tCommand Effects Log Page %sSupported\n", celp, celp ? "" : "Not "); printf(" [0:0] : %#x\tSMART/Health Log Page per NS %sSupported\n", smlp, smlp ? "" : "Not "); printf("\n"); } static void show_nvme_id_ctrl_avscc(__u8 avscc) { __u8 rsvd = (avscc & 0xFE) >> 1; __u8 fmt = avscc & 0x1; if (rsvd) printf(" [7:1] : %#x\tReserved\n", rsvd); printf(" [0:0] : %#x\tAdmin Vendor Specific Commands uses %s Format\n", fmt, fmt ? "NVMe" : "Vendor Specific"); printf("\n"); } static void show_nvme_id_ctrl_apsta(__u8 apsta) { __u8 rsvd = (apsta & 0xFE) >> 1; __u8 apst = apsta & 0x1; if (rsvd) printf(" [7:1] : %#x\tReserved\n", rsvd); printf(" [0:0] : %#x\tAutonomous Power State Transitions %sSupported\n", apst, apst ? "" : "Not "); printf("\n"); } static void show_nvme_id_ctrl_rpmbs(__le32 ctrl_rpmbs) { __u32 rpmbs = le32toh(ctrl_rpmbs); __u32 asz = (rpmbs & 0xFF000000) >> 24; __u32 tsz = (rpmbs & 0xFF0000) >> 16; __u32 rsvd = (rpmbs & 0xFFC0) >> 6; __u32 auth = (rpmbs & 0x38) >> 3; __u32 rpmb = rpmbs & 0x3; printf(" [31:24]: %#x\tAccess Size\n", asz); printf(" [23:16]: %#x\tTotal Size\n", tsz); if (rsvd) printf(" [15:6] : %#x\tReserved\n", rsvd); printf(" [5:3] : %#x\tAuthentication Method\n", auth); printf(" [2:0] : %#x\tNumber of RPMB Units\n", rpmb); printf("\n"); } static void show_nvme_id_ctrl_sqes(__u8 sqes) { __u8 msqes = (sqes & 0xF0) >> 4; __u8 rsqes = sqes & 0xF; printf(" [7:4] : %#x\tMax SQ Entry Size (%d)\n", msqes, 1 << msqes); printf(" [3:0] : %#x\tMin SQ Entry Size (%d)\n", rsqes, 1 << rsqes); printf("\n"); } static void show_nvme_id_ctrl_cqes(__u8 cqes) { __u8 mcqes = (cqes & 0xF0) >> 4; __u8 rcqes = cqes & 0xF; printf(" [7:4] : %#x\tMax CQ Entry Size (%d)\n", mcqes, 1 << mcqes); printf(" [3:0] : %#x\tMin CQ Entry Size (%d)\n", rcqes, 1 << rcqes); printf("\n"); } static void show_nvme_id_ctrl_oncs(__le16 ctrl_oncs) { __u16 oncs = le16toh(ctrl_oncs); __u16 rsvd = (oncs & 0xFFC0) >> 6; __u16 resv = (oncs & 0x20) >> 5; __u16 save = (oncs & 0x10) >> 4; __u16 wzro = (oncs & 0x8) >> 3; __u16 dsms = (oncs & 0x4) >> 2; __u16 wunc = (oncs & 0x2) >> 1; __u16 cmp = oncs & 0x1; if (rsvd) printf(" [15:6] : %#x\tReserved\n", rsvd); printf(" [5:5] : %#x\tReservations %sSupported\n", resv, resv ? "" : "Not "); printf(" [4:4] : %#x\tSave and Select %sSupported\n", save, save ? "" : "Not "); printf(" [3:3] : %#x\tWrite Zeroes %sSupported\n", wzro, wzro ? "" : "Not "); printf(" [2:2] : %#x\tData Set Management %sSupported\n", dsms, dsms ? "" : "Not "); printf(" [1:1] : %#x\tWrite Uncorrectable %sSupported\n", wunc, wunc ? "" : "Not "); printf(" [0:0] : %#x\tCompare %sSupported\n", cmp, cmp ? "" : "Not "); printf("\n"); } static void show_nvme_id_ctrl_fuses(__le16 ctrl_fuses) { __u16 fuses = le16toh(ctrl_fuses); __u16 rsvd = (fuses & 0xFE) >> 1; __u16 cmpw = fuses & 0x1; if (rsvd) printf(" [15:1] : %#x\tReserved\n", rsvd); printf(" [0:0] : %#x\tFused Compare and Write %sSupported\n", cmpw, cmpw ? "" : "Not "); printf("\n"); } static void show_nvme_id_ctrl_fna(__u8 fna) { __u8 rsvd = (fna & 0xF8) >> 3; __u8 cese = (fna & 0x4) >> 2; __u8 cens = (fna & 0x2) >> 1; __u8 fmns = fna & 0x1; if (rsvd) printf(" [7:3] : %#x\tReserved\n", rsvd); printf(" [2:2] : %#x\tCrypto Erase %sSupported as part of Secure Erase\n", cese, cese ? "" : "Not "); printf(" [1:1] : %#x\tCrypto Erase Applies to %s Namespace(s)\n", cens, cens ? "All" : "Single"); printf(" [0:0] : %#x\tFormat Applies to %s Namespace(s)\n", fmns, fmns ? "All" : "Single"); printf("\n"); } static void show_nvme_id_ctrl_vwc(__u8 vwc) { __u8 rsvd = (vwc & 0xFE) >> 1; __u8 vwcp = vwc & 0x1; if (rsvd) printf(" [7:3] : %#x\tReserved\n", rsvd); printf(" [0:0] : %#x\tVolatile Write Cache %sPresent\n", vwcp, vwcp ? "" : "Not "); printf("\n"); } static void show_nvme_id_ctrl_nvscc(__u8 nvscc) { __u8 rsvd = (nvscc & 0xFE) >> 1; __u8 fmt = nvscc & 0x1; if (rsvd) printf(" [7:1] : %#x\tReserved\n", rsvd); printf(" [0:0] : %#x\tNVM Vendor Specific Commands uses %s Format\n", fmt, fmt ? "NVMe" : "Vendor Specific"); printf("\n"); } static void show_nvme_id_ctrl_sgls(__le32 ctrl_sgls) { __u32 sgls = le32toh(ctrl_sgls); __u32 rsvd0 = (sgls & 0xFFF80000) >> 19; __u32 sglltb = (sgls & 0x40000) >> 18; __u32 bacmdb = (sgls & 0x20000) >> 17; __u32 bbs = (sgls & 0x10000) >> 16; __u32 rsvd1 = (sgls & 0xFFFE) >> 1; __u32 sglsp = sgls & 0x1; if (rsvd0) printf(" [31:19]: %#x\tReserved\n", rsvd0); if (sglsp || (!sglsp && sglltb)) printf(" [18:18]: %#x\tSGL Length Larger than Buffer %sSupported\n", sglltb, sglltb ? "" : "Not "); if (sglsp || (!sglsp && bacmdb)) printf(" [17:17]: %#x\tByte-Aligned Contig. MD Buffer %sSupported\n", bacmdb, bacmdb ? "" : "Not "); if (sglsp || (!sglsp && bbs)) printf(" [16:16]: %#x\tSGL Bit-Bucket %sSupported\n", bbs, bbs ? "" : "Not "); if (rsvd1) printf(" [15:1] : %#x\tReserved\n", rsvd1); printf(" [0:0] : %#x\tScatter-Gather Lists %sSupported\n", sglsp, sglsp ? "" : "Not "); printf("\n"); } static void show_nvme_id_ns_nsfeat(__u8 nsfeat) { __u8 rsvd = (nsfeat & 0xF8) >> 3; __u8 dulbe = (nsfeat & 0x4) >> 2; __u8 na = (nsfeat & 0x2) >> 1; __u8 thin = nsfeat & 0x1; if (rsvd) printf(" [7:3] : %#x\tReserved\n", rsvd); printf(" [2:2] : %#x\tDeallocated or Unwritten Logical Block error %sSupported\n", dulbe, dulbe ? "" : "Not "); printf(" [1:1] : %#x\tNamespace uses %s\n", na, na ? "NAWUN, NAWUPF, and NACWU" : "AWUN, AWUPF, and ACWU"); printf(" [0:0] : %#x\tThin Provisioning %sSupported\n", thin, thin ? "" : "Not "); printf("\n"); } static void show_nvme_id_ns_flbas(__u8 flbas) { __u8 rsvd = (flbas & 0xE0) >> 5; __u8 mdedata = (flbas & 0x10) >> 4; __u8 lbaf = flbas & 0xF; if (rsvd) printf(" [7:5] : %#x\tReserved\n", rsvd); printf(" [4:4] : %#x\tMetadata Transferred %s\n", mdedata, mdedata ? "at End of Data LBA" : "in Separate Contiguous Buffer"); printf(" [3:0] : %#x\tCurrent LBA Format Selected\n", lbaf); printf("\n"); } static void show_nvme_id_ns_mc(__u8 mc) { __u8 rsvd = (mc & 0xFC) >> 2; __u8 mdp = (mc & 0x2) >> 1; __u8 extdlba = mc & 0x1; if (rsvd) printf(" [7:2] : %#x\tReserved\n", rsvd); printf(" [1:1] : %#x\tMetadata Pointer %sSupported\n", mdp, mdp ? "" : "Not "); printf(" [0:0] : %#x\tMetadata as Part of Extended Data LBA %sSupported\n", extdlba, extdlba ? "" : "Not "); printf("\n"); } static void show_nvme_id_ns_dpc(__u8 dpc) { __u8 rsvd = (dpc & 0xE0) >> 5; __u8 pil8 = (dpc & 0x10) >> 4; __u8 pif8 = (dpc & 0x8) >> 3; __u8 pit3 = (dpc & 0x4) >> 2; __u8 pit2 = (dpc & 0x2) >> 1; __u8 pit1 = dpc & 0x1; if (rsvd) printf(" [7:5] : %#x\tReserved\n", rsvd); printf(" [4:4] : %#x\tProtection Information Transferred as Last 8 Bytes of Metadata %sSupported\n", pil8, pil8 ? "" : "Not "); printf(" [3:3] : %#x\tProtection Information Transferred as First 8 Bytes of Metadata %sSupported\n", pif8, pif8 ? "" : "Not "); printf(" [2:2] : %#x\tProtection Information Type 3 %sSupported\n", pit3, pit3 ? "" : "Not "); printf(" [1:1] : %#x\tProtection Information Type 2 %sSupported\n", pit2, pit2 ? "" : "Not "); printf(" [0:0] : %#x\tProtection Information Type 1 %sSupported\n", pit1, pit1 ? "" : "Not "); printf("\n"); } static void show_nvme_id_ns_dps(__u8 dps) { __u8 rsvd = (dps & 0xF0) >> 4; __u8 pif8 = (dps & 0x8) >> 3; __u8 pit = dps & 0x7; if (rsvd) printf(" [7:4] : %#x\tReserved\n", rsvd); printf(" [3:3] : %#x\tProtection Information is Transferred as %s 8 Bytes of Metadata\n", pif8, pif8 ? "First" : "Last"); printf(" [2:0] : %#x\tProtection Information %s\n", pit, pit == 3 ? "Type 3 Enabled" : pit == 2 ? "Type 2 Enabled" : pit == 1 ? "Type 1 Enabled" : pit == 0 ? "Disabled" : "Reserved Enabled"); printf("\n"); } static void show_nvme_id_ns_nmic(__u8 nmic) { __u8 rsvd = (nmic & 0xFE) >> 1; __u8 mp = nmic & 0x1; if (rsvd) printf(" [7:1] : %#x\tReserved\n", rsvd); printf(" [0:0] : %#x\tNamespace Multipath %sCapable\n", mp, mp ? "" : "Not "); printf("\n"); } static void show_nvme_id_ns_rescap(__u8 rescap) { __u8 rsvd = (rescap & 0x80) >> 7; __u8 eaar = (rescap & 0x40) >> 6; __u8 wear = (rescap & 0x20) >> 5; __u8 earo = (rescap & 0x10) >> 4; __u8 wero = (rescap & 0x8) >> 3; __u8 ea = (rescap & 0x4) >> 2; __u8 we = (rescap & 0x2) >> 1; __u8 ptpl = rescap & 0x1; if (rsvd) printf(" [7:7] : %#x\tReserved\n", rsvd); printf(" [6:6] : %#x\tExclusive Access - All Registrants %sSupported\n", eaar, eaar ? "" : "Not "); printf(" [5:5] : %#x\tWrite Exclusive - All Registrants %sSupported\n", wear, wear ? "" : "Not "); printf(" [4:4] : %#x\tExclusive Access - Registrants Only %sSupported\n", earo, earo ? "" : "Not "); printf(" [3:3] : %#x\tWrite Exclusive - Registrants Only %sSupported\n", wero, wero ? "" : "Not "); printf(" [2:2] : %#x\tExclusive Access %sSupported\n", ea, ea ? "" : "Not "); printf(" [1:1] : %#x\tWrite Exclusive %sSupported\n", we, we ? "" : "Not "); printf(" [0:0] : %#x\tPersist Through Power Loss %sSupported\n", ptpl, ptpl ? "" : "Not "); printf("\n"); } static void show_nvme_id_ns_fpi(__u8 fpi) { __u8 fpis = (fpi & 0x80) >> 7; __u8 fpii = fpi & 0x7F; printf(" [7:7] : %#x\tFormat Progress Indicator %sSupported\n", fpis, fpis ? "" : "Not "); if (fpis || (!fpis && fpii)) printf(" [6:0] : %#x\tFormat Progress Indicator (Remaining %d%%)\n", fpii, 100 - fpii); printf("\n"); } void show_nvme_id_ns(struct nvme_id_ns *ns, unsigned int mode) { int i; int human = mode&HUMAN, vs = mode&VS; printf("nsze : %#"PRIx64"\n", (uint64_t)le64toh(ns->nsze)); printf("ncap : %#"PRIx64"\n", (uint64_t)le64toh(ns->ncap)); printf("nuse : %#"PRIx64"\n", (uint64_t)le64toh(ns->nuse)); printf("nsfeat : %#x\n", ns->nsfeat); if (human) show_nvme_id_ns_nsfeat(ns->nsfeat); printf("nlbaf : %d\n", ns->nlbaf); printf("flbas : %#x\n", ns->flbas); if (human) show_nvme_id_ns_flbas(ns->flbas); printf("mc : %#x\n", ns->mc); if (human) show_nvme_id_ns_mc(ns->mc); printf("dpc : %#x\n", ns->dpc); if (human) show_nvme_id_ns_dpc(ns->dpc); printf("dps : %#x\n", ns->dps); if (human) show_nvme_id_ns_dps(ns->dps); printf("nmic : %#x\n", ns->nmic); if (human) show_nvme_id_ns_nmic(ns->nmic); printf("rescap : %#x\n", ns->rescap); if (human) show_nvme_id_ns_rescap(ns->rescap); printf("fpi : %#x\n", ns->fpi); if (human) show_nvme_id_ns_fpi(ns->fpi); printf("nawun : %d\n", le16toh(ns->nawun)); printf("nawupf : %d\n", le16toh(ns->nawupf)); printf("nacwu : %d\n", le16toh(ns->nacwu)); printf("nabsn : %d\n", le16toh(ns->nabsn)); printf("nabo : %d\n", le16toh(ns->nabo)); printf("nabspf : %d\n", le16toh(ns->nabspf)); printf("nvmcap : %.0Lf\n", int128_to_double(ns->nvmcap)); printf("nguid : "); for (i = 0; i < 16; i++) printf("%02x", ns->nguid[i]); printf("\n"); printf("eui64 : "); for (i = 0; i < 8; i++) printf("%02x", ns->eui64[i]); printf("\n"); for (i = 0; i <= ns->nlbaf; i++) { if (human) printf("LBA Format %2d : Metadata Size: %-3d bytes - " "Data Size: %-2d bytes - Relative Performance: %#x %s %s\n", i, le16toh(ns->lbaf[i].ms), 1 << ns->lbaf[i].ds, ns->lbaf[i].rp, ns->lbaf[i].rp == 3 ? "Degraded" : ns->lbaf[i].rp == 2 ? "Good" : ns->lbaf[i].rp == 1 ? "Better" : "Best", i == (ns->flbas & 0xf) ? "(in use)" : ""); else printf("lbaf %2d : ms:%-3d ds:%-2d rp:%#x %s\n", i, le16toh(ns->lbaf[i].ms), ns->lbaf[i].ds, ns->lbaf[i].rp, i == (ns->flbas & 0xf) ? "(in use)" : ""); } if (vs) { printf("vs[]:"); d(ns->vs, sizeof(ns->vs), 16, 1); } } static void print_ps_power_and_scale(__le16 ctr_power, __u8 scale) { __u16 power = le16toh(ctr_power); switch (scale & 0x3) { case 0: /* Not reported for this power state */ printf("-"); break; case 1: /* Units of 0.0001W */ printf("%01u.%04uW", power / 10000, power % 10000); break; case 2: /* Units of 0.01W */ printf("%01u.%02uW", power / 100, scale % 100); break; default: printf("reserved"); } } static void show_nvme_id_ctrl_power(struct nvme_id_ctrl *ctrl, unsigned int mode) { int i; for (i = 0; i <= ctrl->npss; i++) { __u16 max_power = le16toh(ctrl->psd[i].max_power); printf("ps %4d : mp:", i); if (ctrl->psd[i].flags & NVME_PS_FLAGS_MAX_POWER_SCALE) printf("%01u.%04uW ", max_power / 10000, max_power % 10000); else printf("%01u.%02uW ", max_power / 100, max_power % 100); if (ctrl->psd[i].flags & NVME_PS_FLAGS_NON_OP_STATE) printf("non-"); printf("operational enlat:%d exlat:%d rrt:%d rrl:%d\n" " rwt:%d rwl:%d idle_power:", le32toh(ctrl->psd[i].entry_lat), le32toh(ctrl->psd[i].exit_lat), ctrl->psd[i].read_tput, ctrl->psd[i].read_lat, ctrl->psd[i].write_tput, ctrl->psd[i].write_lat); print_ps_power_and_scale(ctrl->psd[i].idle_power, ctrl->psd[i].idle_scale); printf(" active_power:"); print_ps_power_and_scale(ctrl->psd[i].active_power, ctrl->psd[i].active_work_scale); printf("\n"); } } void show_nvme_id_ctrl(struct nvme_id_ctrl *ctrl, unsigned int mode) { int human = mode & HUMAN, vs = mode & VS; printf("vid : %#x\n", le16toh(ctrl->vid)); printf("ssvid : %#x\n", le16toh(ctrl->ssvid)); printf("sn : %-20.20s\n", ctrl->sn); printf("mn : %-20.20s\n", ctrl->mn); printf("fr : %-.8s\n", ctrl->fr); printf("rab : %d\n", ctrl->rab); printf("ieee : %02x%02x%02x\n", ctrl->ieee[2], ctrl->ieee[1], ctrl->ieee[0]); printf("cmic : %#x\n", ctrl->cmic); if (human) show_nvme_id_ctrl_cmic(ctrl->cmic); printf("mdts : %d\n", ctrl->mdts); printf("cntlid : %x\n", le16toh(ctrl->cntlid)); printf("ver : %x\n", le32toh(ctrl->ver)); printf("rtd3r : %x\n", le32toh(ctrl->rtd3r)); printf("rtd3e : %x\n", le32toh(ctrl->rtd3e)); printf("oaes : %#x\n", le32toh(ctrl->oaes)); if (human) show_nvme_id_ctrl_oaes(ctrl->oaes); printf("oacs : %#x\n", le16toh(ctrl->oacs)); if (human) show_nvme_id_ctrl_oacs(ctrl->oacs); printf("acl : %d\n", ctrl->acl); printf("aerl : %d\n", ctrl->aerl); printf("frmw : %#x\n", ctrl->frmw); if (human) show_nvme_id_ctrl_frmw(ctrl->frmw); printf("lpa : %#x\n", ctrl->lpa); if (human) show_nvme_id_ctrl_lpa(ctrl->lpa); printf("elpe : %d\n", ctrl->elpe); printf("npss : %d\n", ctrl->npss); printf("avscc : %#x\n", ctrl->avscc); if (human) show_nvme_id_ctrl_avscc(ctrl->avscc); printf("apsta : %#x\n", ctrl->apsta); if (human) show_nvme_id_ctrl_apsta(ctrl->apsta); printf("wctemp : %d\n", le16toh(ctrl->wctemp)); printf("cctemp : %d\n", le16toh(ctrl->cctemp)); printf("mtfa : %d\n", le16toh(ctrl->mtfa)); printf("hmpre : %d\n", le32toh(ctrl->hmpre)); printf("hmmin : %d\n", le32toh(ctrl->hmmin)); printf("tnvmcap : %.0Lf\n", int128_to_double(ctrl->tnvmcap)); printf("unvmcap : %.0Lf\n", int128_to_double(ctrl->unvmcap)); printf("rpmbs : %#x\n", le32toh(ctrl->rpmbs)); if (human) show_nvme_id_ctrl_rpmbs(ctrl->rpmbs); printf("sqes : %#x\n", ctrl->sqes); if (human) show_nvme_id_ctrl_sqes(ctrl->sqes); printf("cqes : %#x\n", ctrl->cqes); if (human) show_nvme_id_ctrl_cqes(ctrl->cqes); printf("nn : %d\n", le32toh(ctrl->nn)); printf("oncs : %#x\n", le16toh(ctrl->oncs)); if (human) show_nvme_id_ctrl_oncs(ctrl->oncs); printf("fuses : %#x\n", le16toh(ctrl->fuses)); if (human) show_nvme_id_ctrl_fuses(ctrl->fuses); printf("fna : %#x\n", ctrl->fna); if (human) show_nvme_id_ctrl_fna(ctrl->fna); printf("vwc : %#x\n", ctrl->vwc); if (human) show_nvme_id_ctrl_vwc(ctrl->vwc); printf("awun : %d\n", le16toh(ctrl->awun)); printf("awupf : %d\n", le16toh(ctrl->awupf)); printf("nvscc : %d\n", ctrl->nvscc); if (human) show_nvme_id_ctrl_nvscc(ctrl->nvscc); printf("acwu : %d\n", le16toh(ctrl->acwu)); printf("sgls : %x\n", le32toh(ctrl->sgls)); if (human) show_nvme_id_ctrl_sgls(ctrl->sgls); show_nvme_id_ctrl_power(ctrl, mode); if (vs) { printf("vs[]:\n"); d(ctrl->vs, sizeof(ctrl->vs), 16, 1); } } void show_error_log(struct nvme_error_log_page *err_log, int entries, const char *devname) { int i; printf("Error Log Entries for device:%s entries:%d\n", devname, entries); printf(".................\n"); for (i = 0; i < entries; i++) { printf(" Entry[%2d] \n", i); printf(".................\n"); printf("error_count : %"PRIu64"\n", (uint64_t)le64toh(err_log[i].error_count)); printf("sqid : %d\n", err_log[i].sqid); printf("cmdid : %#x\n", err_log[i].cmdid); printf("status_field : %#x\n", err_log[i].status_field); printf("parm_err_loc : %#x\n", err_log[i].parm_error_location); printf("lba : %#"PRIx64"\n",(uint64_t)le64toh(err_log[i].lba)); printf("nsid : %d\n", err_log[i].nsid); printf("vs : %d\n", err_log[i].vs); printf(".................\n"); } } void show_nvme_resv_report(struct nvme_reservation_status *status) { int i, regctl; regctl = status->regctl[0] | (status->regctl[1] << 8); printf("\nNVME Reservation status:\n\n"); printf("gen : %d\n", le32toh(status->gen)); printf("regctl : %d\n", regctl); printf("rtype : %d\n", status->rtype); printf("ptpls : %d\n", status->ptpls); for (i = 0; i < regctl; i++) { printf("regctl[%d] :\n", i); printf(" cntlid : %x\n", le16toh(status->regctl_ds[i].cntlid)); printf(" rcsts : %x\n", status->regctl_ds[i].rcsts); printf(" hostid : %"PRIx64"\n", (uint64_t)le64toh(status->regctl_ds[i].hostid)); printf(" rkey : %"PRIx64"\n", (uint64_t)le64toh(status->regctl_ds[i].rkey)); } printf("\n"); } static char *fw_to_string(__u64 fw) { static char ret[9]; char *c = (char *)&fw; int i; for (i = 0; i < 8; i++) ret[i] = c[i] >= '!' && c[i] <= '~' ? c[i] : '.'; ret[i] = '\0'; return ret; } void show_fw_log(struct nvme_firmware_log_page *fw_log, const char *devname) { int i; printf("Firmware Log for device:%s\n", devname); printf("afi : %#x\n", fw_log->afi); for (i = 0; i < 7; i++) if (fw_log->frs[i]) printf("frs%d : %#016"PRIx64" (%s)\n", i + 1, (uint64_t)fw_log->frs[i], fw_to_string(fw_log->frs[i])); } static unsigned long int48_to_long(__u8 *data) { int i; long result = 0; for (i = 0; i < 6; i++) { result *= 256; result += data[5 - i]; } return result; } void show_smart_log(struct nvme_smart_log *smart, unsigned int nsid, const char *devname) { /* convert temperature from Kelvin to Celsius */ int c; unsigned int temperature = ((smart->temperature[1] << 8) | smart->temperature[0]) - 273; printf("Smart Log for NVME device:%s namespace-id:%x\n", devname, nsid); printf("critical_warning : %#x\n", smart->critical_warning); printf("temperature : %u C\n", temperature); printf("available_spare : %u%%\n", smart->avail_spare); printf("available_spare_threshold : %u%%\n", smart->spare_thresh); printf("percentage_used : %u%%\n", smart->percent_used); printf("data_units_read : %'.0Lf\n", int128_to_double(smart->data_units_read)); printf("data_units_written : %'.0Lf\n", int128_to_double(smart->data_units_written)); printf("host_read_commands : %'.0Lf\n", int128_to_double(smart->host_reads)); printf("host_write_commands : %'.0Lf\n", int128_to_double(smart->host_writes)); printf("controller_busy_time : %'.0Lf\n", int128_to_double(smart->ctrl_busy_time)); printf("power_cycles : %'.0Lf\n", int128_to_double(smart->power_cycles)); printf("power_on_hours : %'.0Lf\n", int128_to_double(smart->power_on_hours)); printf("unsafe_shutdowns : %'.0Lf\n", int128_to_double(smart->unsafe_shutdowns)); printf("media_errors : %'.0Lf\n", int128_to_double(smart->media_errors)); printf("num_err_log_entries : %'.0Lf\n", int128_to_double(smart->num_err_log_entries)); printf("Warning Temperature Time : %u\n", le32toh(smart->warning_temp_time)); printf("Critical Composite Temperature Time : %u\n", le32toh(smart->critical_comp_time)); for (c=0; c < 8; c++) { __u16 temp = le16toh(smart->temp_sensor[c]); printf("Temperature Sensor %d : %u C\n", c + 1, temp ? temp - 273 : 0); } } void show_intel_smart_log(struct nvme_additional_smart_log *smart, unsigned int nsid, const char *devname) { printf("Additional Smart Log for NVME device:%s namespace-id:%x\n", devname, nsid); printf("key normalized raw\n"); printf("program_fail_count : %3d%% %lu\n", smart->program_fail_cnt.norm, int48_to_long(smart->program_fail_cnt.raw)); printf("erase_fail_count : %3d%% %lu\n", smart->erase_fail_cnt.norm, int48_to_long(smart->erase_fail_cnt.raw)); printf("wear_leveling : %3d%% min: %u, max: %u, avg: %u\n", smart->wear_leveling_cnt.norm, le16toh(smart->wear_leveling_cnt.wear_level.min), le16toh(smart->wear_leveling_cnt.wear_level.max), le16toh(smart->wear_leveling_cnt.wear_level.avg)); printf("end_to_end_error_detection_count: %3d%% %lu\n", smart->e2e_err_cnt.norm, int48_to_long(smart->e2e_err_cnt.raw)); printf("crc_error_count : %3d%% %lu\n", smart->crc_err_cnt.norm, int48_to_long(smart->crc_err_cnt.raw)); printf("timed_workload_media_wear : %3d%% %.3f%%\n", smart->timed_workload_media_wear.norm, ((float)int48_to_long(smart->timed_workload_media_wear.raw)) / 1024); printf("timed_workload_host_reads : %3d%% %lu%%\n", smart->timed_workload_host_reads.norm, int48_to_long(smart->timed_workload_host_reads.raw)); printf("timed_workload_timer : %3d%% %lu min\n", smart->timed_workload_timer.norm, int48_to_long(smart->timed_workload_timer.raw)); printf("thermal_throttle_status : %3d%% %u%%, cnt: %u\n", smart->thermal_throttle_status.norm, smart->thermal_throttle_status.thermal_throttle.pct, smart->thermal_throttle_status.thermal_throttle.count); printf("retry_buffer_overflow_count : %3d%% %lu\n", smart->retry_buffer_overflow_cnt.norm, int48_to_long(smart->retry_buffer_overflow_cnt.raw)); printf("pll_lock_loss_count : %3d%% %lu\n", smart->pll_lock_loss_cnt.norm, int48_to_long(smart->pll_lock_loss_cnt.raw)); printf("nand_bytes_written : %3d%% sectors: %lu\n", smart->nand_bytes_written.norm, int48_to_long(smart->nand_bytes_written.raw)); printf("host_bytes_written : %3d%% sectors: %lu\n", smart->host_bytes_written.norm, int48_to_long(smart->host_bytes_written.raw)); } char *nvme_feature_to_string(int feature) { switch (feature) { case NVME_FEAT_ARBITRATION: return "Arbitration"; case NVME_FEAT_POWER_MGMT: return "Power Management"; case NVME_FEAT_LBA_RANGE: return "LBA Range Type"; case NVME_FEAT_TEMP_THRESH: return "Temperature Threshold"; case NVME_FEAT_ERR_RECOVERY: return "Error Recovery"; case NVME_FEAT_VOLATILE_WC: return "Volatile Write Cache"; case NVME_FEAT_NUM_QUEUES: return "Number of Queues"; case NVME_FEAT_IRQ_COALESCE: return "Interrupt Coalescing"; case NVME_FEAT_IRQ_CONFIG: return "Interrupt Vector Configuration"; case NVME_FEAT_WRITE_ATOMIC: return "Write Atomicity Normal"; case NVME_FEAT_ASYNC_EVENT: return "Async Event Configuration"; case NVME_FEAT_AUTO_PST: return "Autonomous Power State Transition"; case NVME_FEAT_HOST_MEM_BUF: return "Host Memory Buffer"; case NVME_FEAT_SW_PROGRESS: return "Software Progress"; case NVME_FEAT_HOST_ID: return "Host Identifier"; case NVME_FEAT_RESV_MASK: return "Reservation Notification Mask"; case NVME_FEAT_RESV_PERSIST: return "Reservation Persistence"; default: return "Unknown"; } } char* nvme_select_to_string(int sel) { switch (sel) { case 0: return "Current"; case 1: return "Default"; case 2: return "Saved"; case 3: return "Supported capabilities"; default: return "Reserved"; } } char *nvme_status_to_string(__u32 status) { switch (status & 0x3ff) { case NVME_SC_SUCCESS: return "SUCCESS"; case NVME_SC_INVALID_OPCODE: return "INVALID_OPCODE"; case NVME_SC_INVALID_FIELD: return "INVALID_FIELD"; case NVME_SC_CMDID_CONFLICT: return "CMDID_CONFLICT"; case NVME_SC_DATA_XFER_ERROR: return "DATA_XFER_ERROR"; case NVME_SC_POWER_LOSS: return "POWER_LOSS"; case NVME_SC_INTERNAL: return "INTERNAL"; case NVME_SC_ABORT_REQ: return "ABORT_REQ"; case NVME_SC_ABORT_QUEUE: return "ABORT_QUEUE"; case NVME_SC_FUSED_FAIL: return "FUSED_FAIL"; case NVME_SC_FUSED_MISSING: return "FUSED_MISSING"; case NVME_SC_INVALID_NS: return "INVALID_NS"; case NVME_SC_CMD_SEQ_ERROR: return "CMD_SEQ_ERROR"; case NVME_SC_LBA_RANGE: return "LBA_RANGE"; case NVME_SC_CAP_EXCEEDED: return "CAP_EXCEEDED"; case NVME_SC_NS_NOT_READY: return "NS_NOT_READY"; case NVME_SC_CQ_INVALID: return "CQ_INVALID"; case NVME_SC_QID_INVALID: return "QID_INVALID"; case NVME_SC_QUEUE_SIZE: return "QUEUE_SIZE"; case NVME_SC_ABORT_LIMIT: return "ABORT_LIMIT"; case NVME_SC_ABORT_MISSING: return "ABORT_MISSING"; case NVME_SC_ASYNC_LIMIT: return "ASYNC_LIMIT"; case NVME_SC_FIRMWARE_SLOT: return "FIRMWARE_SLOT"; case NVME_SC_FIRMWARE_IMAGE: return "FIRMWARE_IMAGE"; case NVME_SC_INVALID_VECTOR: return "INVALID_VECTOR"; case NVME_SC_INVALID_LOG_PAGE: return "INVALID_LOG_PAGE"; case NVME_SC_INVALID_FORMAT: return "INVALID_FORMAT"; case NVME_SC_BAD_ATTRIBUTES: return "BAD_ATTRIBUTES"; case NVME_SC_WRITE_FAULT: return "WRITE_FAULT"; case NVME_SC_READ_ERROR: return "READ_ERROR"; case NVME_SC_GUARD_CHECK: return "GUARD_CHECK"; case NVME_SC_APPTAG_CHECK: return "APPTAG_CHECK"; case NVME_SC_REFTAG_CHECK: return "REFTAG_CHECK"; case NVME_SC_COMPARE_FAILED: return "COMPARE_FAILED"; case NVME_SC_ACCESS_DENIED: return "ACCESS_DENIED"; default: return "Unknown"; } } static char* nvme_feature_lba_type_to_string(__u8 type) { switch (type) { case 0: return "Reserved"; case 1: return "Filesystem"; case 2: return "RAID"; case 3: return "Cache"; case 4: return "Page / Swap file"; default: if (type>=0x05 && type<=0x7f) return "Reserved"; else return "Vendor Specific"; } } void show_lba_range(struct nvme_lba_range_type *lbrt, int nr_ranges) { int i, j; for (i = 0; i <= nr_ranges; i++) { printf("\ttype : %#x - %s\n", lbrt[i].type, nvme_feature_lba_type_to_string(lbrt[i].type)); printf("\tattributes : %#x - %s, %s\n", lbrt[i].attributes, (lbrt[i].attributes & 0x0001) ? "LBA range may be overwritten":"LBA range should not be overwritten", ((lbrt[i].attributes & 0x0002) >> 1) ? "LBA range should be hidden from the OS/EFI/BIOS":"LBA range should be visible from the OS/EFI/BIOS"); printf("\tslba : %#"PRIx64"\n", (uint64_t)(lbrt[i].slba)); printf("\tnlb : %#"PRIx64"\n", (uint64_t)(lbrt[i].nlb)); printf("\tguid : "); for (j = 0; j < 16; j++) printf("%02x", lbrt[i].guid[j]); printf("\n"); } } static char *nvme_feature_wl_hints_to_string(__u8 wh) { switch (wh) { case 0: return "No Workload"; case 1: return "Extended Idle Period with a Burst of Random Writes"; case 2: return "Heavy Sequential Writes"; default:return "Reserved"; } } static char *nvme_feature_temp_type_to_string(__u8 type) { switch (type) { case 0: return "Over Temperature Threshold"; case 1: return "Under Temperature Threshold"; default:return "Reserved"; } } static char *nvme_feature_temp_sel_to_string(__u8 sel) { switch (sel) { case 0: return "Composite Temperature"; case 1: return "Temperature Sensor 1"; case 2: return "Temperature Sensor 2"; case 3: return "Temperature Sensor 3"; case 4: return "Temperature Sensor 4"; case 5: return "Temperature Sensor 5"; case 6: return "Temperature Sensor 6"; case 7: return "Temperature Sensor 7"; case 8: return "Temperature Sensor 8"; default:return "Reserved"; } } static void show_auto_pst(struct nvme_auto_pst *apst) { int i; printf( "\tAuto PST Entries"); printf("\t.................\n"); for (i = 0; i < 32; i++) { printf("\tEntry[%2d] \n", i); printf("\t.................\n"); printf("\tIdle Time Prior to Transition (ITPT): %u ms\n", (apst[i].data & 0xffffff00) >> 8); printf("\tIdle Transition Power State (ITPS): %u\n", (apst[i].data & 0x000000f8) >> 3); printf("\t.................\n"); } } static void show_host_mem_buffer(struct nvme_host_mem_buffer *hmb) { printf("\tHost Memory Descriptor List Entry Count (HMDLEC): %u\n", hmb->hmdlec); printf("\tHost Memory Descriptor List Address (HMDLAU): %u\n", hmb->hmdlau); printf("\tHost Memory Descriptor List Address (HMDLAL): %u\n", hmb->hmdlal); printf("\tHost Memory Buffer Size (HSIZE): %u\n", hmb->hsize); } void nvme_feature_show_fields(__u32 fid, unsigned int result, unsigned char *buf) { __u8 field; uint64_t ull; switch (fid) { case NVME_FEAT_ARBITRATION: printf("\tHigh Priority Weight (HPW): %u\n", ((result & 0xff000000) >> 24) + 1); printf("\tMedium Priority Weight (MPW): %u\n", ((result & 0x00ff0000) >> 16) + 1); printf("\tLow Priority Weight (LPW): %u\n", ((result & 0x0000ff00) >> 8) + 1); printf("\tArbitration Burst (AB): %u\n", 1 << (result & 0x00000007)); break; case NVME_FEAT_POWER_MGMT: field = (result & 0x000000E0) >> 5; printf("\tWorkload Hint (WH): %u - %s\n", field, nvme_feature_wl_hints_to_string(field)); printf("\tPower State (PS): %u\n", result & 0x0000001f); break; case NVME_FEAT_LBA_RANGE: field = result & 0x0000003f; printf("\tNumber of LBA Ranges (NUM): %u\n", field + 1); show_lba_range((struct nvme_lba_range_type *)buf, field); break; case NVME_FEAT_TEMP_THRESH: field = (result & 0x00300000) >> 20; printf("\tThreshold Type Select (THSEL): %u - %s\n", field, nvme_feature_temp_type_to_string(field)); field = (result & 0x000f0000) >> 16; printf("\tThreshold Temperature Select (TMPSEL): %u - %s\n", field, nvme_feature_temp_sel_to_string(field)); printf("\tTemperature Threshold (TMPTH): %u C\n", (result & 0x0000ffff) - 273); break; case NVME_FEAT_ERR_RECOVERY: printf("\tDeallocated or Unwritten Logical Block Error Enable (DULBE): %s\n", ((result & 0x00010000) >> 16) ? "Enabled":"Disabled"); printf("\tTime Limited Error Recovery (TLER): %u ms\n", (result & 0x0000ffff) * 100); break; case NVME_FEAT_VOLATILE_WC: printf("\tVolatile Write Cache Enable (WCE): %s\n", (result & 0x00000001) ? "Enabled":"Disabled"); break; case NVME_FEAT_NUM_QUEUES: printf("\tNumber of IO Completion Queues Allocated (NCQA): %u\n", ((result & 0xffff0000) >> 16) + 1); printf("\tNumber of IO Submission Queues Allocated (NSQA): %u\n", (result & 0x0000ffff) + 1); break; case NVME_FEAT_IRQ_COALESCE: printf("\tAggregation Time (TIME): %u ms\n", ((result & 0x0000ff00) >> 8) * 100); printf("\tAggregation Threshold (THR): %u\n", (result & 0x000000ff) + 1); break; case NVME_FEAT_IRQ_CONFIG: printf("\tCoalescing Disable (CD): %s\n", ((result & 0x00010000) >> 16) ? "True":"False"); printf("\tInterrupt Vector (IV): %u\n", result & 0x0000ffff); break; case NVME_FEAT_WRITE_ATOMIC: printf("\tDisable Normal (DN): %s\n", (result & 0x00000001) ? "True":"False"); break; case NVME_FEAT_ASYNC_EVENT: printf("\tFirmware Activation Notices : %s\n", ((result & 0x00000200) >> 9) ? "Send async event":"Do not send async event"); printf("\tNamespace Attribute Notices : %s\n", ((result & 0x00000100) >> 8) ? "Send NameSpace Attribute Changed event":"Do not send NameSpace Attribute Changed event"); printf("\tSMART / Health Critical Warnings: %s\n", (result & 0x000000ff) ? "Send async event":"Do not send async event"); break; case NVME_FEAT_AUTO_PST: printf("\tAutonomous Power State Transition Enable (APSTE): %s\n", (result & 0x00000001) ? "Enabled":"Disabled"); show_auto_pst((struct nvme_auto_pst *)buf); break; case NVME_FEAT_HOST_MEM_BUF: printf("\tMemory Return (MR): %s\n", ((result & 0x00000002) >> 1) ? "True":"False"); printf("\tEnable Host Memory (EHM): %s\n", (result & 0x00000001) ? "Enabled":"Disabled"); show_host_mem_buffer((struct nvme_host_mem_buffer *)buf); break; case NVME_FEAT_SW_PROGRESS: printf("\tPre-boot Software Load Count (PBSLC): %u\n", result & 0x000000ff); break; case NVME_FEAT_HOST_ID: ull = buf[7]; ull <<= 8; ull |= buf[6]; ull <<= 8; ull |= buf[5]; ull <<= 8; ull |= buf[4]; ull <<= 8; ull |= buf[3]; ull <<= 8; ull |= buf[2]; ull <<= 8; ull |= buf[1]; ull <<= 8; ull |= buf[0]; printf("\tHost Identifier (HOSTID): %" PRIu64 "\n", ull); break; case NVME_FEAT_RESV_MASK: printf("\tMask Reservation Preempted Notification (RESPRE): %s\n", ((result & 0x00000008) >> 3) ? "True":"False"); printf("\tMask Reservation Released Notification (RESREL): %s\n", ((result & 0x00000004) >> 2) ? "True":"False"); printf("\tMask Registration Preempted Notification (REGPRE): %s\n", ((result & 0x00000002) >> 1) ? "True":"False"); break; case NVME_FEAT_RESV_PERSIST: printf("\tPersist Through Power Loss (PTPL): %s\n", (result & 0x00000001) ? "True":"False"); break; } } nvme-cli-0.5/nvme-print.h000066400000000000000000000023061267263733400153560ustar00rootroot00000000000000#ifndef COMMON_H #define COMMON_H #include "linux/nvme.h" enum { TERSE = 0x1u, // only show a few useful fields HUMAN = 0x2u, // interpret some values for humans VS = 0x4u, // print vendor specific data area RAW = 0x8u, // just dump raw bytes }; void d(unsigned char *buf, int len, int width, int group); void d_raw(unsigned char *buf, unsigned len); void show_nvme_id_ctrl(struct nvme_id_ctrl *ctrl, unsigned int mode); void show_nvme_id_ns(struct nvme_id_ns *ns, unsigned int flags); void show_nvme_resv_report(struct nvme_reservation_status *status); void show_lba_range(struct nvme_lba_range_type *lbrt, int nr_ranges); void show_error_log(struct nvme_error_log_page *err_log, int entries, const char *devname); void show_intel_smart_log(struct nvme_additional_smart_log *smart, unsigned int nsid, const char *devname); void show_smart_log(struct nvme_smart_log *smart, unsigned int nsid, const char *devname); void show_fw_log(struct nvme_firmware_log_page *fw_log, const char *devname); void nvme_feature_show_fields(__u32 fid, unsigned int result, unsigned char *buf); char *nvme_status_to_string(__u32 status); char *nvme_select_to_string(int sel); char *nvme_feature_to_string(int feature); #endif nvme-cli-0.5/nvme.c000066400000000000000000002406661267263733400142340ustar00rootroot00000000000000/* * nvme.c -- NVM-Express command line utility. * * Copyright (c) 2014-2015, Intel Corporation. * * Written by Keith Busch * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * This program uses NVMe IOCTLs to run native nvme commands to a device. */ #include #include #include #include #include #include #include #include #include #include #include #ifdef LIBUDEV_EXISTS #include #endif #include #include #include #include #include #include #include "nvme-print.h" #include "nvme-ioctl.h" #include "src/argconfig.h" #include "src/suffix.h" #define array_len(x) ((size_t)(sizeof(x) / sizeof(x[0]))) #define min(x, y) (x) > (y) ? (y) : (x) #define max(x, y) (x) > (y) ? (x) : (y) static int fd; static struct stat nvme_stat; static const char *devicename; static const char nvme_version_string[] = NVME_VERSION; #define COMMAND_LIST \ ENTRY(LIST, "list", "List all NVMe devices and namespaces on machine", list) \ ENTRY(ID_CTRL, "id-ctrl", "Send NVMe Identify Controller", id_ctrl) \ ENTRY(ID_NS, "id-ns", "Send NVMe Identify Namespace, display structure", id_ns) \ ENTRY(LIST_NS, "list-ns", "Send NVMe Identify List, display structure", list_ns) \ ENTRY(CREATE_NS, "create-ns", "Creates a namespace with the provided parameters", create_ns) \ ENTRY(DELETE_NS, "delete-ns", "Deletes a namespace from the controller", delete_ns) \ ENTRY(ATTACH_NS, "attach-ns", "Attaches a namespace to requested controller(s)", attach_ns) \ ENTRY(DETACH_NS, "detach-ns", "Detaches a namespace from requested controller(s)", detach_ns) \ ENTRY(LIST_CTRL, "list-ctrl", "Send NVMe Identify Controller List, display structure", list_ctrl) \ ENTRY(GET_NS_ID, "get-ns-id", "Retrieve the namespace ID of opened block device", get_ns_id) \ ENTRY(GET_LOG, "get-log", "Generic NVMe get log, returns log in raw format", get_log) \ ENTRY(GET_FW_LOG, "fw-log", "Retrieve FW Log, show it", get_fw_log) \ ENTRY(GET_SMART_LOG, "smart-log", "Retrieve SMART Log, show it", get_smart_log) \ ENTRY(GET_ADDITIONAL_SMART_LOG, "smart-log-add", "Retrieve additional SMART Log, show it", get_additional_smart_log) \ ENTRY(GET_ERR_LOG, "error-log", "Retrieve Error Log, show it", get_error_log) \ ENTRY(GET_FEATURE, "get-feature", "Get feature and show the resulting value", get_feature) \ ENTRY(SET_FEATURE, "set-feature", "Set a feature and show the resulting value", set_feature) \ ENTRY(FORMAT, "format", "Format namespace with new block format", format) \ ENTRY(FW_ACTIVATE, "fw-activate", "Activate new firmware slot", fw_activate) \ ENTRY(FW_DOWNLOAD, "fw-download", "Download new firmware", fw_download) \ ENTRY(ADMIN_PASSTHRU, "admin-passthru", "Submit arbitrary admin command, return results", admin_passthru) \ ENTRY(IO_PASSTHRU, "io-passthru", "Submit an arbitrary IO command, return results", io_passthru) \ ENTRY(SECURITY_SEND, "security-send", "Submit a Security Send command, return results", sec_send) \ ENTRY(SECURITY_RECV, "security-recv", "Submit a Security Receive command, return results", sec_recv) \ ENTRY(RESV_ACQUIRE, "resv-acquire", "Submit a Reservation Acquire, return results", resv_acquire) \ ENTRY(RESV_REGISTER, "resv-register", "Submit a Reservation Register, return results", resv_register) \ ENTRY(RESV_RELEASE, "resv-release", "Submit a Reservation Release, return results", resv_release) \ ENTRY(RESV_REPORT, "resv-report", "Submit a Reservation Report, return results", resv_report) \ ENTRY(DSM, "dsm", "Submit a Data Set Management command, return results", dsm) \ ENTRY(FLUSH, "flush", "Submit a Flush command, return results", flush) \ ENTRY(COMPARE, "compare", "Submit a Compare command, return results", compare) \ ENTRY(READ_CMD, "read", "Submit a read command, return results", read_cmd) \ ENTRY(WRITE_CMD, "write", "Submit a write command, return results", write_cmd) \ ENTRY(WRITE_ZEROES_CMD, "write-zeroes", "Submit a write zeroes command, return results", write_zeroes) \ ENTRY(WRITE_UNCOR_CMD, "write-uncor", "Submit a write uncorrectable command, return results", write_uncor) \ ENTRY(RESET, "reset", "Resets the controller", reset) \ ENTRY(SUBSYS_RESET, "subsystem-reset", "Resets the controller", subsystem_reset) \ ENTRY(REGISTERS, "show-regs", "Shows the controller registers. Requires admin character device", show_registers) \ ENTRY(VERSION, "version", "Shows the program version", version) \ ENTRY(HELP, "help", "Display this help", help) #define ENTRY(i, n, h, f) \ static int f(int argc, char **argv); COMMAND_LIST #undef ENTRY enum { #define ENTRY(i, n, h, f) i, COMMAND_LIST #undef ENTRY NUM_COMMANDS }; struct command { char *name; char *help; char *man; int (*fn)(int argc, char **argv); }; struct command commands[] = { #define ENTRY(i, n, h, f)\ { \ .name = n, \ .help = h, \ .fn = f, \ .man = "nvme-"n, \ }, COMMAND_LIST #undef ENTRY }; static unsigned long long elapsed_utime(struct timeval start_time, struct timeval end_time) { unsigned long long ret = (end_time.tv_sec - start_time.tv_sec)*1000000 + (end_time.tv_usec - start_time.tv_usec); return ret; } static void open_dev(const char *dev) { int err; devicename = basename(dev); fd = open(dev, O_RDONLY); if (fd < 0) goto perror; err = fstat(fd, &nvme_stat); if (err < 0) goto perror; if (!S_ISCHR(nvme_stat.st_mode) && !S_ISBLK(nvme_stat.st_mode)) { fprintf(stderr, "%s is not a block or character device\n", dev); exit(ENODEV); } return; perror: perror(dev); exit(errno); } static void get_dev(int argc, char **argv) { if (optind >= argc) { errno = EINVAL; perror(argv[0]); exit(errno); } open_dev((const char *)argv[optind]); } static int get_smart_log(int argc, char **argv) { struct nvme_smart_log smart_log; const char *desc = "Retrieve SMART log for the given device "\ "(or optionally a namespace) in either decoded format "\ "(default) or binary."; const char *namespace = "(optional) desired namespace"; const char *raw = "output in binary format"; int err; struct config { __u32 namespace_id; __u8 raw_binary; }; struct config cfg = { .namespace_id = 0xffffffff, }; const struct argconfig_commandline_options command_line_options[] = { {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace}, {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, (void *)&cfg, sizeof(cfg)); get_dev(argc, argv); err = nvme_smart_log(fd, cfg.namespace_id, &smart_log); if (!err) { if (!cfg.raw_binary) show_smart_log(&smart_log, cfg.namespace_id, devicename); else d_raw((unsigned char *)&smart_log, sizeof(smart_log)); } else if (err > 0) fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(err), err); return err; } static int get_additional_smart_log(int argc, char **argv) { struct nvme_additional_smart_log smart_log; int err; char *desc = "Get Intel vendor specific additional smart log (optionally, "\ "for the specified namespace), and show it."; const char *namespace = "(optional) desired namespace"; const char *raw = "dump output in binary format"; struct config { __u32 namespace_id; __u8 raw_binary; }; struct config cfg = { .namespace_id = 0xffffffff, }; const struct argconfig_commandline_options command_line_options[] = { {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace}, {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); get_dev(argc, argv); err = nvme_intel_smart_log(fd, cfg.namespace_id, &smart_log); if (!err) { if (!cfg.raw_binary) show_intel_smart_log(&smart_log, cfg.namespace_id, devicename); else d_raw((unsigned char *)&smart_log, sizeof(smart_log)); } else if (err > 0) fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(err), err); return err; } static int get_error_log(int argc, char **argv) { const char *desc = "Retrieve specified number of "\ "error log entries from a given device (or "\ "namespace) in either decoded format (default) or binary."; const char *namespace_id = "desired namespace"; const char *log_entries = "number of entries to retrieve"; const char *raw_binary = "dump in binary format"; struct nvme_id_ctrl ctrl; int err; struct config { __u32 namespace_id; __u32 log_entries; __u8 raw_binary; }; struct config cfg = { .namespace_id = 0xffffffff, .log_entries = 64, }; const struct argconfig_commandline_options command_line_options[] = { {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id}, {"log-entries", 'e', "NUM", CFG_POSITIVE, &cfg.log_entries, required_argument, log_entries}, {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw_binary}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); get_dev(argc, argv); if (!cfg.log_entries) { fprintf(stderr, "non-zero log-entries is required param\n"); return EINVAL; } err = nvme_identify_ctrl(fd, &ctrl); cfg.log_entries = min(cfg.log_entries, ctrl.elpe + 1); if (err) { fprintf(stderr, "could not identify controller\n"); return ENODEV; } else { struct nvme_error_log_page err_log[cfg.log_entries]; err = nvme_error_log(fd, cfg.namespace_id, cfg.log_entries, err_log); if (!err) { if (!cfg.raw_binary) show_error_log(err_log, cfg.log_entries, devicename); else d_raw((unsigned char *)err_log, sizeof(err_log)); } else if (err > 0) fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(err), err); } return err; } static int get_fw_log(int argc, char **argv) { const char *desc = "Retrieve the firmware log for the "\ "specified device in either decoded format (default) or binary."; const char *raw_binary = "use binary output"; int err; struct nvme_firmware_log_page fw_log; struct config { __u8 raw_binary; }; struct config cfg = { }; const struct argconfig_commandline_options command_line_options[] = { {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw_binary}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); get_dev(argc, argv); err = nvme_fw_log(fd, &fw_log); if (!err) { if (!cfg.raw_binary) show_fw_log(&fw_log, devicename); else d_raw((unsigned char *)&fw_log, sizeof(fw_log)); } else if (err > 0) fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(err), err); else perror("fw log"); return err; } static int get_log(int argc, char **argv) { const char *desc = "Retrieve desired number of bytes "\ "from a given log on a specified device in either "\ "hex-dump (default) or binary format"; const char *namespace_id = "desired namespace"; const char *log_id = "identifier of log to retrieve"; const char *log_len = "how many bytes to retrieve"; const char *raw_binary = "output in raw format"; int err; struct config { __u32 namespace_id; __u32 log_id; __u32 log_len; __u8 raw_binary; }; struct config cfg = { .namespace_id = 0xffffffff, .log_id = 0, .log_len = 0, }; const struct argconfig_commandline_options command_line_options[] = { {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id}, {"log-id", 'i', "NUM", CFG_POSITIVE, &cfg.log_id, required_argument, log_id}, {"log-len", 'l', "NUM", CFG_POSITIVE, &cfg.log_len, required_argument, log_len}, {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw_binary}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); get_dev(argc, argv); if (!cfg.log_len) { fprintf(stderr, "non-zero log-len is required param\n"); return EINVAL; } else { unsigned char log[cfg.log_len]; err = nvme_log(fd, cfg.namespace_id, cfg.log_id, cfg.log_len, log); if (!err) { if (!cfg.raw_binary) { printf("Device:%s log-id:%d namespace-id:%#x\n", devicename, cfg.log_id, cfg.namespace_id); d(log, cfg.log_len, 16, 1); } else d_raw((unsigned char *)log, cfg.log_len); } else if (err > 0) fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(err), err); return err; } } static int list_ctrl(int argc, char **argv) { const char *desc = "Show controller list information for the subsystem the "\ "given device is part of, or optionally controllers attached to a specific namespace."; const char *controller = "controller to display"; const char *namespace_id = "optional namespace attached to controller"; int err, i; struct nvme_controller_list *cntlist; struct config { __u16 cntid; __u32 namespace_id; }; struct config cfg = { .cntid = 0, }; const struct argconfig_commandline_options command_line_options[] = { {"cntid", 'c', "NUM", CFG_SHORT, &cfg.cntid, required_argument, controller}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); get_dev(argc, argv); if (posix_memalign((void *)&cntlist, getpagesize(), 0x1000)) return ENOMEM; err = nvme_identify_ctrl_list(fd, cfg.namespace_id, cfg.cntid, cntlist); if (!err) { __u16 num = le16toh(cntlist->num); for (i = 0; i < (min(num, 2048)); i++) printf("[%4u]:%#x\n", i, le16toh(cntlist->identifier[i])); } else if (err > 0) fprintf(stderr, "NVMe Status:%s(%x) cntid:%d\n", nvme_status_to_string(err), err, cfg.cntid); return err; } static int list_ns(int argc, char **argv) { const char *desc = "For the specified device, show the "\ "namespace list in a NVMe subsystem, optionally starting with a given namespace"; const char *namespace_id = "namespace number returned list should to start after"; const char *all = "show all namespaces in the subsystem, whether attached or inactive"; int err, i; __u32 ns_list[1024]; struct config { __u32 namespace_id; __u8 all; }; struct config cfg = { .namespace_id = 0, }; const struct argconfig_commandline_options command_line_options[] = { {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id}, {"all", 'a', "", CFG_NONE, &cfg.all, no_argument, all}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); get_dev(argc, argv); err = nvme_identify_ns_list(fd, cfg.namespace_id, !!cfg.all, ns_list); if (!err) { for (i = 0; i < 1024; i++) if (ns_list[i]) printf("[%4u]:%#x\n", i, ns_list[i]); } else if (err > 0) fprintf(stderr, "NVMe Status:%s(%x) NSID:%d\n", nvme_status_to_string(err), err, cfg.namespace_id); return err; } static int delete_ns(int argc, char **argv) { const char *desc = "Delete the given namespace by "\ "sending a namespace management command to "\ "the provided device. All controllers should be detached from "\ "the namespace prior to namespace deletion. A namespace ID "\ "becomes inactive when that namespace is detached or, if "\ "the namespace is not already inactive, once deleted."; const char *namespace_id = "namespace to delete"; int err; struct config { __u32 namespace_id; }; struct config cfg = { .namespace_id = 0, }; const struct argconfig_commandline_options command_line_options[] = { {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); if (!cfg.namespace_id) { fprintf(stderr, "%s: namespace-id parameter required\n", commands[DELETE_NS].name); return EINVAL; } get_dev(argc, argv); err = nvme_ns_delete(fd, cfg.namespace_id); if (!err) printf("%s: Success, deleted nsid:%d\n", commands[DELETE_NS].name, cfg.namespace_id); else if (err > 0) fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(err), err); else fprintf(stderr, "system error:(%x)\n", err); return err; } static int nvme_attach_ns(int argc, char **argv, int attach, const char *desc) { char *name = commands[attach ? ATTACH_NS : DETACH_NS].name; int err, num, i, list[2048]; __u16 ctrlist[2048]; const char *namespace_id = "namespace to attach"; const char *cont = "optional comma-sep controllers list"; struct config { char *cntlist; __u32 namespace_id; }; struct config cfg = { .cntlist = "", .namespace_id = 0, }; const struct argconfig_commandline_options command_line_options[] = { {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id}, {"controllers", 'c', "LIST", CFG_STRING, &cfg.cntlist, required_argument, cont}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); if (!cfg.namespace_id) { fprintf(stderr, "%s: namespace-id parameter required\n", name); return EINVAL; } num = argconfig_parse_comma_sep_array(cfg.cntlist, list, 2047); for (i = 0; i < num; i++) ctrlist[i] = ((uint16_t)list[i]); get_dev(argc, argv); if (attach) err = nvme_ns_attach_ctrls(fd, cfg.namespace_id, num, ctrlist); else err = nvme_ns_detach_ctrls(fd, cfg.namespace_id, num, ctrlist); if (!err) printf("%s: Success, nsid:%d\n", name, cfg.namespace_id); else if (err > 0) fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(err), err); else fprintf(stderr, "system error:(%x)\n", err); return err; } static int attach_ns(int argc, char **argv) { const char *desc = "Attach the given namespace to the "\ "given controller or comma-sep list of controllers. ID of the "\ "given namespace becomes active upon attachment to a "\ "controller. A namespace must be attached to a controller "\ "before IO commands may be directed to that namespace."; return nvme_attach_ns(argc, argv, 1, desc); } static int detach_ns(int argc, char **argv) { const char *desc = "Detach the given namespace from the "\ "given controller; de-activates the given namespace's ID. A "\ "namespace must be attached to a controller before IO "\ "commands may be directed to that namespace."; return nvme_attach_ns(argc, argv, 0, desc); } static int create_ns(int argc, char **argv) { const char *desc = "Send a namespace management command "\ "to the specified device to create a namespace with the given "\ "parameters. The next available namespace ID is used for the "\ "create operation. Note that create-ns does not attach the "\ "namespace to a controller, the attach-ns command is needed."; int err = 0; __u32 nsid; struct config { __u64 nsze; __u64 ncap; __u8 flbas; __u8 dps; __u8 nmic; }; struct config cfg = { }; const char *nsze = "size of ns"; const char *ncap = "capacity of ns"; const char *flbas = "FLBA size"; const char *dps = "data protection capabilities"; const char *nmic = "multipath and sharing capabilities"; const struct argconfig_commandline_options command_line_options[] = { {"nsze", 's', "NUM", CFG_LONG_SUFFIX, &cfg.nsze, required_argument, nsze}, {"ncap", 'c', "NUM", CFG_LONG_SUFFIX, &cfg.ncap, required_argument, ncap}, {"flbas", 'f', "NUM", CFG_BYTE, &cfg.flbas, required_argument, flbas}, {"dps", 'd', "NUM", CFG_BYTE, &cfg.dps, required_argument, dps}, {"nmic", 'm', "NUM", CFG_BYTE, &cfg.nmic, required_argument, nmic}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); get_dev(argc, argv); err = nvme_ns_create(fd, cfg.nsze, cfg.ncap, cfg.flbas, cfg.dps, cfg.nmic, &nsid); if (!err) printf("%s: Success, created nsid:%d\n", commands[CREATE_NS].name, nsid); else if (err > 0) fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(err), err); return err; } static char *nvme_char_from_block(char *block) { char slen[16]; unsigned len; if (strncmp("nvme", block, 4)) { fprintf(stderr,"Device %s is not a nvme device.", block); exit(-1); } sscanf(block,"nvme%d", &len); sprintf(slen,"%d", len); block[4+strlen(slen)] = 0; return block; } static void get_registers(struct nvme_bar **bar) { int pci_fd; char *base, path[512]; void *membase; base = nvme_char_from_block((char *)devicename); sprintf(path, "/sys/class/nvme/%s/device/resource0", base); pci_fd = open(path, O_RDONLY); if (pci_fd < 0) { sprintf(path, "/sys/class/misc/%s/device/resource0", base); pci_fd = open(path, O_RDONLY); } if (pci_fd < 0) { fprintf(stderr, "%s did not find a pci resource\n", base); exit(ENODEV); } membase = mmap(0, getpagesize(), PROT_READ, MAP_SHARED, pci_fd, 0); if (membase == MAP_FAILED) { fprintf(stderr, "%s failed to map\n", base); exit(ENODEV); } *bar = membase; } struct list_item { char node[1024]; struct nvme_id_ctrl ctrl; int nsid; struct nvme_id_ns ns; unsigned block; __le32 ver; }; #ifdef LIBUDEV_EXISTS /* For pre NVMe 1.2 devices we must get the version from the BAR, not the * ctrl_id.*/ static void get_version(struct list_item* list_item) { struct nvme_bar *bar; list_item->ver = list_item->ctrl.ver; if (list_item->ctrl.ver) return; get_registers(&bar); list_item->ver = bar->vs; } static void print_list_item(struct list_item list_item) { double nsze = list_item.ns.nsze; double nuse = list_item.ns.nuse; long long int lba = list_item.ns.lbaf[(list_item.ns.flbas & 0x0f)].ds; lba = (1 << lba); nsze *= lba; nuse *= lba; const char *s_suffix = suffix_si_get(&nsze); const char *u_suffix = suffix_si_get(&nuse); const char *l_suffix = suffix_binary_get(&lba); char usage[128]; sprintf(usage,"%6.2f %2sB / %6.2f %2sB", nuse, u_suffix, nsze, s_suffix); char format[128]; sprintf(format,"%3.0f %2sB + %2d B", (double)lba, l_suffix, list_item.ns.lbaf[(list_item.ns.flbas & 0x0f)].ms); char version[128]; sprintf(version,"%d.%d", (list_item.ver >> 16), (list_item.ver >> 8) & 0xff); printf("%-16s %-20.20s %-8s %-8d %-26s %-16s %-.8s\n", list_item.node, list_item.ctrl.mn, version, list_item.nsid, usage, format, list_item.ctrl.fr); } static void print_list_items(struct list_item *list_items, unsigned len) { unsigned i; printf("%-16s %-20s %-8s %-8s %-26s %-16s %-8s\n", "Node","Model","Version","Namepace", "Usage", "Format", "FW Rev"); printf("%-16s %-20s %-8s %-8s %-26s %-16s %-8s\n", "----------------","--------------------","--------","--------", "--------------------------","----------------","--------"); for (i = 0 ; i < len ; i++) print_list_item(list_items[i]); } #else static int list(int argc, char **argv) { fprintf(stderr,"nvme-list: libudev not detected, install and rebuild.\n"); return -1; } #endif #ifdef LIBUDEV_EXISTS #define MAX_LIST_ITEMS 256 static int list(int argc, char **argv) { struct udev *udev; struct udev_enumerate *enumerate; struct udev_list_entry *devices, *dev_list_entry; struct udev_device *dev; struct list_item list_items[MAX_LIST_ITEMS]; unsigned count=0; udev = udev_new(); if (!udev) { perror("nvme-list: Cannot create udev context."); return errno; } enumerate = udev_enumerate_new(udev); udev_enumerate_add_match_subsystem(enumerate, "block"); udev_enumerate_add_match_property(enumerate, "DEVTYPE", "disk"); udev_enumerate_scan_devices(enumerate); devices = udev_enumerate_get_list_entry(enumerate); udev_list_entry_foreach(dev_list_entry, devices) { int err; const char *path, *node; path = udev_list_entry_get_name(dev_list_entry); dev = udev_device_new_from_syspath(udev, path); node = udev_device_get_devnode(dev); if (strstr(node,"nvme")!=NULL){ open_dev(node); err = nvme_identify_ctrl(fd, &list_items[count].ctrl); if (err > 0) return err; list_items[count].nsid = nvme_get_nsid(fd); err = nvme_identify_ns(fd, list_items[count].nsid, 0, &list_items[count].ns); if (err > 0) return err; strcpy(list_items[count].node, node); list_items[count].block = S_ISBLK(nvme_stat.st_mode); get_version(&list_items[count]); count++; } } udev_enumerate_unref(enumerate); udev_unref(udev); if (count) print_list_items(list_items, count); else printf("No NVMe devices detected.\n"); return 0; } #endif static int id_ctrl(int argc, char **argv) { const char *desc = "Send an Identify Controller command to "\ "the given device and report information about the specified "\ "controller in human-readable or "\ "binary format. May also return vendor-specific "\ "controller attributes in hex-dump if requested."; const char *vendor_specific = "dump binary vendor infos"; const char *raw_binary = "show infos in binary format"; const char *human_readable = "show infos in readable format"; int err; unsigned int flags = 0; struct nvme_id_ctrl ctrl; struct config { __u8 vendor_specific; __u8 raw_binary; __u8 human_readable; }; struct config cfg = { }; const struct argconfig_commandline_options command_line_options[] = { {"vendor-specific", 'v', "", CFG_NONE, &cfg.vendor_specific, no_argument, vendor_specific}, {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw_binary}, {"human-readable", 'H', "", CFG_NONE, &cfg.human_readable, no_argument, human_readable}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); if (cfg.vendor_specific) flags |= VS; if (cfg.human_readable) flags |= HUMAN; get_dev(argc, argv); err = nvme_identify_ctrl(fd, &ctrl); if (!err) { if (cfg.raw_binary) { d_raw((unsigned char *)&ctrl, sizeof(ctrl)); } else { printf("NVME Identify Controller:\n"); show_nvme_id_ctrl(&ctrl, flags); } } else if (err > 0) fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(err), err); return err; } static int id_ns(int argc, char **argv) { const char *desc = "Send an Identify Namespace command to the "\ "given device, returns properties of the specified namespace "\ "in either human-readable or binary format. Can also return "\ "binary vendor-specific namespace attributes."; const char *vendor_specific = "dump binary vendor infos"; const char *raw_binary = "show infos in binary format"; const char *human_readable = "show infos in readable format"; const char *namespace_id = "identifier of desired namespace"; struct nvme_id_ns ns; int err; unsigned int flags = 0; struct config { __u32 namespace_id; __u8 vendor_specific; __u8 raw_binary; __u8 human_readable; }; struct config cfg = { .namespace_id = 0, }; const struct argconfig_commandline_options command_line_options[] = { {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id}, {"vendor-specific", 'v', "FLAG", CFG_NONE, &cfg.vendor_specific, no_argument, vendor_specific}, {"raw-binary", 'b', "FLAG", CFG_NONE, &cfg.raw_binary, no_argument, raw_binary}, {"human-readable", 'H', "FLAG", CFG_NONE, &cfg.human_readable, no_argument, human_readable}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); if (cfg.vendor_specific) flags |= VS; if (cfg.human_readable) flags |= HUMAN; get_dev(argc, argv); if (!cfg.namespace_id) { cfg.namespace_id = nvme_get_nsid(fd); if (cfg.namespace_id <= 0) { perror(devicename); exit(errno); } } err = nvme_identify_ns(fd, cfg.namespace_id, 0, &ns); if (!err) { if (cfg.raw_binary) d_raw((unsigned char *)&ns, sizeof(ns)); else { printf("NVME Identify Namespace %d:\n", cfg.namespace_id); show_nvme_id_ns(&ns, flags); } } else if (err > 0) fprintf(stderr, "NVMe Status:%s(%x) NSID:%d\n", nvme_status_to_string(err), err, cfg.namespace_id); return err; } static int get_ns_id(int argc, char **argv) { int nsid; open_dev(argv[1]); nsid = nvme_get_nsid(fd); if (nsid <= 0) { perror(devicename); exit(errno); } printf("%s: namespace-id:%d\n", devicename, nsid); return 0; } static int get_feature(int argc, char **argv) { const char *desc = "Read operating parameters of the "\ "specified controller. Operating parameters are grouped "\ "and identified by Feature Identifiers; each Feature "\ "Identifier contains one or more attributes that may affect "\ "behaviour of the feature. Each Feature has three possible "\ "settings: default, saveable, and current. If a Feature is "\ "saveable, it may be modified by set-feature. Default values "\ "are vendor-specific and not changeable. Use set-feature to "\ "change saveable Features."; const char *raw_binary = "show infos in binary format"; const char *namespace_id = "identifier of desired namespace"; const char *feature_id = "hexadecimal feature name"; const char *sel = "[0-3]: curr./default/saved/supp."; const char *data_len = "buffer len (if) data is returned"; const char *cdw11 = "dword 11 for interrupt vector config"; const char *human_readable = "show infos in readable format"; int err; __u32 result; void *buf = NULL; struct config { __u32 namespace_id; __u32 feature_id; __u8 sel; __u32 cdw11; __u32 data_len; __u8 raw_binary; __u8 human_readable; }; struct config cfg = { .namespace_id = 1, .feature_id = 0, .sel = 0, .cdw11 = 0, .data_len = 0, }; const struct argconfig_commandline_options command_line_options[] = { {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id}, {"feature-id", 'f', "NUM", CFG_POSITIVE, &cfg.feature_id, required_argument, feature_id}, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, required_argument, sel}, {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len, required_argument, data_len}, {"raw-binary", 'b', "FLAG",CFG_NONE, &cfg.raw_binary, no_argument, raw_binary}, {"cdw11", 'c', "NUM", CFG_POSITIVE, &cfg.cdw11, required_argument, cdw11}, {"human-readable", 'H', "FLAG",CFG_NONE, &cfg.human_readable, no_argument, human_readable}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); get_dev(argc, argv); if (cfg.sel > 7) { fprintf(stderr, "invalid 'select' param:%d\n", cfg.sel); return EINVAL; } if (!cfg.feature_id) { fprintf(stderr, "feature-id required param\n"); return EINVAL; } switch (cfg.feature_id) { case NVME_FEAT_LBA_RANGE: cfg.data_len = 4096; break; case NVME_FEAT_AUTO_PST: cfg.data_len = 256; break; case NVME_FEAT_HOST_MEM_BUF: cfg.data_len = 4096; break; case NVME_FEAT_HOST_ID: cfg.data_len = 8; break; } if (cfg.data_len) buf = malloc(cfg.data_len); err = nvme_get_feature(fd, cfg.namespace_id, cfg.feature_id, cfg.sel, cfg.cdw11, cfg.data_len, buf, &result); if (!err) { printf("get-feature:0x%02x (%s), %s value: %#08x\n", cfg.feature_id, nvme_feature_to_string(cfg.feature_id), nvme_select_to_string(cfg.sel), result); if (cfg.human_readable) nvme_feature_show_fields(cfg.feature_id, result, buf); else { if (buf) { if (!cfg.raw_binary) d(buf, cfg.data_len, 16, 1); else d_raw(buf, cfg.data_len); } } } else if (err > 0) fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(err), err); if (buf) free(buf); return err; } static int fw_download(int argc, char **argv) { const char *desc = "Copy all or part of a firmware image to "\ "a controller for future update. Optionally, specify how "\ "many KiB of the firmware to transfer at once. The offset will "\ "start at 0 and automatically adjust based on xfer size "\ "unless fw is split across multiple files. May be submitted "\ "while outstanding commands exist on the Admin and IO "\ "Submission Queues. Activate downloaded firmware with "\ "fw-activate, and then reset the device to apply the downloaded firmware."; const char *fw = "firmware file (required)"; const char *xfer = "transfer chunksize limit"; const char *offset = "starting dword offset, default 0"; int err, fw_fd = -1; unsigned int fw_size; struct stat sb; void *fw_buf; struct config { char *fw; __u32 xfer; __u32 offset; }; struct config cfg = { .fw = "", .xfer = 4096, .offset = 0, }; const struct argconfig_commandline_options command_line_options[] = { {"fw", 'f', "FILE", CFG_STRING, &cfg.fw, required_argument, fw}, {"xfer", 'x', "NUM", CFG_POSITIVE, &cfg.xfer, required_argument, xfer}, {"offset", 'o', "NUM", CFG_POSITIVE, &cfg.offset, required_argument, offset}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); get_dev(argc, argv); fw_fd = open(cfg.fw, O_RDONLY); cfg.offset <<= 2; if (fw_fd < 0) { fprintf(stderr, "no firmware file provided\n"); return EINVAL; } err = fstat(fw_fd, &sb); if (err < 0) { perror("fstat"); exit(errno); } fw_size = sb.st_size; if (fw_size & 0x3) { fprintf(stderr, "Invalid size:%d for f/w image\n", fw_size); return EINVAL; } if (posix_memalign(&fw_buf, getpagesize(), fw_size)) { fprintf(stderr, "No memory for f/w size:%d\n", fw_size); return ENOMEM; } if (cfg.xfer == 0 || cfg.xfer % 4096) cfg.xfer = 4096; if (read(fw_fd, fw_buf, fw_size) != ((ssize_t)(fw_size))) return EIO; while (fw_size > 0) { cfg.xfer = min(cfg.xfer, fw_size); err = nvme_fw_download(fd, cfg.offset, cfg.xfer, fw_buf); if (err < 0) { perror("fw-download"); exit(errno); } else if (err != 0) { fprintf(stderr, "NVME Admin command error:%s(%x)\n", nvme_status_to_string(err), err); break; } fw_buf += cfg.xfer; fw_size -= cfg.xfer; cfg.offset += cfg.xfer; } if (!err) printf("Firmware download success\n"); return err; } static int fw_activate(int argc, char **argv) { const char *desc = "Verify downloaded firmware image and "\ "commit to specific firmware slot. Device is not automatically "\ "reset following firmware activation. A reset may be issued "\ "with an 'echo 1 > /sys/class/nvme/nvmeX/reset_controller'. "\ "Ensure nvmeX is the device you just activated before reset."; const char *slot = "firmware slot to activate"; const char *action = "[0-2]: replacement action"; int err; struct config { __u8 slot; __u8 action; }; struct config cfg = { .slot = 0, .action = 0, }; const struct argconfig_commandline_options command_line_options[] = { {"slot", 's', "NUM", CFG_BYTE, &cfg.slot, required_argument, slot}, {"action", 'a', "NUM", CFG_BYTE, &cfg.action, required_argument, action}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); get_dev(argc, argv); if (cfg.slot > 7) { fprintf(stderr, "invalid slot:%d\n", cfg.slot); return EINVAL; } if (cfg.action > 3) { fprintf(stderr, "invalid action:%d\n", cfg.action); return EINVAL; } err = nvme_fw_activate(fd, cfg.slot, cfg.action); if (err < 0) perror("fw-activate"); else if (err != 0) if (err == NVME_SC_FIRMWARE_NEEDS_RESET) printf("Success activating firmware action:%d slot:%d, but a conventional reset is required\n", cfg.action, cfg.slot); else fprintf(stderr, "NVME Admin command error:%s(%x)\n", nvme_status_to_string(err), err); else printf("Success activating firmware action:%d slot:%d\n", cfg.action, cfg.slot); return err; } static void clear_args(int argc, char **argv) { int opt, long_index; while ((opt = getopt_long(argc, (char **)argv, "", NULL, &long_index)) != -1); get_dev(argc, argv); } static int subsystem_reset(int argc, char **argv) { clear_args(argc, argv); return nvme_subsystem_reset(fd); } static int reset(int argc, char **argv) { clear_args(argc, argv); return nvme_reset_controller(fd); } static void print_lo_hi_64(uint32_t *val) { printf("%x%08x\n", val[1], val[0]); } static int show_registers(int argc, char **argv) { int opt, long_index; struct nvme_bar *bar; while ((opt = getopt_long(argc, (char **)argv, "", NULL, &long_index)) != -1); devicename = basename(argv[optind]); get_registers(&bar); printf("cap : "); print_lo_hi_64((uint32_t *)&bar->cap); printf("version : %x\n", bar->vs); printf("intms : %x\n", bar->intms); printf("intmc : %x\n", bar->intmc); printf("cc : %x\n", bar->cc); printf("csts : %x\n", bar->csts); printf("nssr : %x\n", bar->nssr); printf("aqa : %x\n", bar->aqa); printf("asq : "); print_lo_hi_64((uint32_t *)&bar->asq); printf("acq : "); print_lo_hi_64((uint32_t *)&bar->acq); printf("cmbloc : %x\n", bar->cmbloc); printf("cmbsz : %x\n", bar->cmbsz); return 0; } static int format(int argc, char **argv) { const char *desc = "Re-format a specified namespace on the "\ "given device. Can erase all data in namespace (user "\ "data erase) or delete data encryption key if specified. "\ "Can also be used to change LBAF to change the namespaces reported physical block format."; const char *namespace_id = "identifier of desired namespace"; const char *lbaf = "LBA format to apply (required)"; const char *ses = "[0-2]: secure erase"; const char *pil = "[0-1]: protection info location last/first 8 bytes of metadata"; const char *pi = "[0-3]: protection info off/Type 1/Type 2/Type 3"; const char *ms = "[0-1]: extended format off/on"; const char *timeout = "timeout value"; int err; struct config { __u32 namespace_id; __u32 timeout; __u8 lbaf; __u8 ses; __u8 pi; __u8 pil; __u8 ms; }; struct config cfg = { .namespace_id = 0xffffffff, .timeout = 120000, .lbaf = 0, .ses = 0, .pi = 0, }; const struct argconfig_commandline_options command_line_options[] = { {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id}, {"timeout", 't', "NUM", CFG_POSITIVE, &cfg.timeout, required_argument, timeout}, {"lbaf", 'l', "NUM", CFG_BYTE, &cfg.lbaf, required_argument, lbaf}, {"ses", 's', "NUM", CFG_BYTE, &cfg.ses, required_argument, ses}, {"pi", 'i', "NUM", CFG_BYTE, &cfg.pi, required_argument, pi}, {"pil", 'p', "NUM", CFG_BYTE, &cfg.pil, required_argument, pil}, {"ms", 'm', "NUM", CFG_BYTE, &cfg.ms, required_argument, ms}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); get_dev(argc, argv); /* ses & pi checks set to 7 for forward-compatibility */ if (cfg.ses > 7) { fprintf(stderr, "invalid secure erase settings:%d\n", cfg.ses); return EINVAL; } if (cfg.lbaf > 15) { fprintf(stderr, "invalid lbaf:%d\n", cfg.lbaf); return EINVAL; } if (cfg.pi > 7) { fprintf(stderr, "invalid pi:%d\n", cfg.pi); return EINVAL; } if (cfg.pil > 1) { fprintf(stderr, "invalid pil:%d\n", cfg.pil); return EINVAL; } if (cfg.ms > 1) { fprintf(stderr, "invalid ms:%d\n", cfg.ms); return EINVAL; } if (S_ISBLK(nvme_stat.st_mode)) { cfg.namespace_id = nvme_get_nsid(fd); if (cfg.namespace_id <= 0) { fprintf(stderr, "%s: failed to return namespace id\n", devicename); return errno; } } err = nvme_format(fd, cfg.namespace_id, cfg.lbaf, cfg.ses, cfg.pi, cfg.pil, cfg.ms, cfg.timeout); if (err < 0) perror("format"); else if (err != 0) fprintf(stderr, "NVME Admin command error:%s(%x)\n", nvme_status_to_string(err), err); else { printf("Success formatting namespace:%x\n", cfg.namespace_id); ioctl(fd, BLKRRPART); } return err; } static int set_feature(int argc, char **argv) { const char *desc = "Modify the saveable or changeable "\ "current operating parameters of the controller. Operating "\ "parameters are grouped and identified by Feature "\ "Identifiers. Feature settings can be applied to the entire "\ "controller and all associated namespaces, or to only a few "\ "namespace(s) associated with the controller. Default values "\ "for each Feature are vendor-specific and may not be modified."\ "Use get-feature to determine which Features are supported by "\ "the controller and are saveable/changeable."; const char *namespace_id = "desired namespace"; const char *feature_id = "hex feature name (required)"; const char *data_len = "buffer length if data required"; const char *data = "optional file for feature data (default stdin)"; const char *value = "new value of feature (required)"; int err; __u32 result; void *buf = NULL; int ffd = STDIN_FILENO; struct config { char *file; __u32 namespace_id; __u32 feature_id; __u32 value; __u32 data_len; }; struct config cfg = { .file = "", .namespace_id = 0, .feature_id = 0, .value = 0, .data_len = 0, }; const struct argconfig_commandline_options command_line_options[] = { {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id}, {"feature-id", 'f', "NUM", CFG_POSITIVE, &cfg.feature_id, required_argument, feature_id}, {"value", 'v', "NUM", CFG_POSITIVE, &cfg.value, required_argument, value}, {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len, required_argument, data_len}, {"data", 'd', "FILE", CFG_STRING, &cfg.file, required_argument, data}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); get_dev(argc, argv); if (!cfg.feature_id) { fprintf(stderr, "feature-id required param\n"); return EINVAL; } if (cfg.feature_id == NVME_FEAT_LBA_RANGE) cfg.data_len = 4096; if (cfg.data_len) buf = malloc(cfg.data_len); if (buf) { if (strlen(cfg.file)) { ffd = open(cfg.file, O_RDONLY); if (ffd <= 0) { fprintf(stderr, "no firmware file provided\n"); return -EINVAL; } } if (read(ffd, (void *)buf, cfg.data_len) < 0) { fprintf(stderr, "failed to read data buffer from input file\n"); return EINVAL; } } err = nvme_set_feature(fd, cfg.namespace_id, cfg.feature_id, cfg.value, 0, cfg.data_len, buf, &result); if (err < 0) { perror("set-feature"); return errno; } if (!err) { printf("set-feature:%02x (%s), value:%#08x\n", cfg.feature_id, nvme_feature_to_string(cfg.feature_id), result); if (buf) { if (cfg.feature_id == NVME_FEAT_LBA_RANGE) show_lba_range((struct nvme_lba_range_type *)buf, result); else d(buf, cfg.data_len, 16, 1); } } else if (err > 0) fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(err), err); if (buf) free(buf); return err; } static int sec_send(int argc, char **argv) { struct stat sb; const char *desc = "Transfer security protocol data to "\ "a controller. Security Receives for the same protocol should be "\ "performed after Security Sends. The security protocol field "\ "associates Security Sends (security-send) and Security Receives "\ "(security-recv)."; const char *file = "transfer payload"; const char *secp = "security protocol (cf. SPC-4)"; const char *spsp = "security-protocol-specific (cf. SPC-4)"; const char *tl = "transfer length (cf. SPC-4)"; const char *namespace_id = "desired namespace"; const char *nssf = "NVMe Security Specific Field"; int err, sec_fd = -1; void *sec_buf; unsigned int sec_size; __u32 result; struct config { __u32 namespace_id; char *file; __u8 nssf; __u8 secp; __u16 spsp; __u32 tl; }; struct config cfg = { .file = "", .secp = 0, .spsp = 0, .tl = 0, }; const struct argconfig_commandline_options command_line_options[] = { {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id}, {"file", 'f', "FILE", CFG_STRING, &cfg.file, required_argument, file}, {"nssf", 'N', "NUM", CFG_BYTE, &cfg.nssf, required_argument, nssf}, {"secp", 'p', "NUM", CFG_BYTE, &cfg.secp, required_argument, secp}, {"spsp", 's', "NUM", CFG_SHORT, &cfg.spsp, required_argument, spsp}, {"tl", 't', "NUM", CFG_POSITIVE, &cfg.tl, required_argument, tl}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); get_dev(argc, argv); sec_fd = open(cfg.file, O_RDONLY); if (sec_fd < 0) { fprintf(stderr, "no firmware file provided\n"); return EINVAL; } err = fstat(sec_fd, &sb); if (err < 0) { perror("fstat"); return errno; } sec_size = sb.st_size; if (posix_memalign(&sec_buf, getpagesize(), sec_size)) { fprintf(stderr, "No memory for security size:%d\n", sec_size); return ENOMEM; } err = nvme_sec_send(fd, cfg.namespace_id, cfg.nssf, cfg.spsp, cfg.secp, cfg.tl, sec_size, sec_buf, &result); if (err < 0) return errno; else if (err != 0) fprintf(stderr, "NVME Security Send Command Error:%d\n", err); else printf("NVME Security Send Command Success:%d\n", result); return err; } static int write_uncor(int argc, char **argv) { int err; const char *desc = "The Write Uncorrectable command is used to set a "\ "range of logical blocks to invalid."; const char *namespace_id = "desired namespace"; const char *start_block = "64-bit LBA of first block to access"; const char *block_count = "number of blocks on device to access"; struct config { __u64 start_block; __u32 namespace_id; __u16 block_count; }; struct config cfg = { .start_block = 0, .namespace_id = 0, .block_count = 0, }; const struct argconfig_commandline_options command_line_options[] = { {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id}, {"start-block", 's', "NUM", CFG_LONG_SUFFIX, &cfg.start_block, required_argument, start_block}, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count, required_argument, block_count}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); get_dev(argc, argv); if (!cfg.namespace_id) { cfg.namespace_id = nvme_get_nsid(fd); if (cfg.namespace_id <= 0) { fprintf(stderr, "%s: failed to return namespace id\n", devicename); return errno; } } err = nvme_write_uncorrectable(fd, cfg.namespace_id, cfg.start_block, cfg.block_count); if (err < 0) return errno; else if (err != 0) fprintf(stderr, "NVME Write Uncorrectable Command Error:%d\n", err); else printf("NVME Write Uncorrectable Success\n"); return err; } static int write_zeroes(int argc, char **argv) { int err; __u16 control = 0; const char *desc = "The Write Zeroes command is used to set a "\ "range of logical blocks to zero."; const char *namespace_id = "desired namespace"; const char *start_block = "64-bit LBA of first block to access"; const char *block_count = "number of blocks on device to access"; const char *limited_retry = "limit media access attempts"; const char *force = "force device to commit data before command completes"; const char *prinfo = "PI and check field"; const char *ref_tag = "reference tag (for end to end PI)"; const char *app_tag_mask = "app tag mask (for end to end PI)"; const char *app_tag = "app tag (for end to end PI)"; struct config { __u64 start_block; __u32 namespace_id; __u32 ref_tag; __u32 app_tag; __u16 block_count; __u8 prinfo; __u8 app_tag_mask; __u8 limited_retry; __u8 force_unit_access; }; struct config cfg = { .start_block = 0, .block_count = 0, .prinfo = 0, .ref_tag = 0, .app_tag_mask = 0, .app_tag = 0, }; const struct argconfig_commandline_options command_line_options[] = { {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id}, {"start-block", 's', "NUM", CFG_LONG_SUFFIX, &cfg.start_block, required_argument, start_block}, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count, required_argument, block_count}, {"limited-retry", 'l', "", CFG_NONE, &cfg.limited_retry, no_argument, limited_retry}, {"force-unit-access", 'f', "", CFG_NONE, &cfg.force_unit_access, no_argument, force}, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, required_argument, prinfo}, {"ref-tag", 'r', "NUM", CFG_POSITIVE, &cfg.ref_tag, required_argument, ref_tag}, {"app-tag-mask", 'm', "NUM", CFG_BYTE, &cfg.app_tag_mask, required_argument, app_tag_mask}, {"app-tag", 'a', "NUM", CFG_POSITIVE, &cfg.app_tag, required_argument, app_tag}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); get_dev(argc, argv); if (cfg.prinfo > 0xf) return EINVAL; control |= (cfg.prinfo << 10); if (cfg.limited_retry) control |= NVME_RW_LR; if (cfg.force_unit_access) control |= NVME_RW_FUA; if (!cfg.namespace_id) { cfg.namespace_id = nvme_get_nsid(fd); if (cfg.namespace_id <= 0) { fprintf(stderr, "%s: failed to return namespace id\n", devicename); return errno; } } err = nvme_write_zeros(fd, cfg.namespace_id, cfg.start_block, cfg.block_count, control, cfg.ref_tag, cfg.app_tag, cfg.app_tag_mask); if (err < 0) return errno; else if (err != 0) fprintf(stderr, "NVME Write Zeroes Command Error:%d\n", err); else printf("NVME Write Zeroes Success\n"); return err; } static int dsm(int argc, char **argv) { const char *desc = "The Dataset Management command is used by the host to "\ "indicate attributes for ranges of logical blocks. This includes attributes "\ "for discarding unused blocks, data read and write frequency, access size, and other "\ "information that may be used to optimize performance and reliability."; const char *namespace_id = "identifier of desired namespace"; const char *blocks = "Comma separated list of the number of blocks in each range"; const char *starting_blocks = "Comma separated list of the starting block in each range"; const char *context_attrs = "Comma separated list of the context attributes in each range"; const char *ad = "Attribute Deallocate"; const char *idw = "Attribute Integral Dataset for Write"; const char *idr = "Attribute Integral Dataset for Read"; const char *cdw11 = "All the command DWORD 11 attributes. Use instead of specifying individual attributes"; int err; uint16_t nr, nc, nb, ns; int ctx_attrs[256] = {0,}; int nlbs[256] = {0,}; unsigned long long slbas[256] = {0,}; struct nvme_dsm_range *dsm; struct config { char *ctx_attrs; char *blocks; char *slbas; int ad; int idw; int idr; __u32 cdw11; __u32 namespace_id; }; struct config cfg = { .ctx_attrs = "", .blocks = "", .slbas = "", .namespace_id = 0, .ad = 0, .idw = 0, .idr = 0, .cdw11 = 0, }; const struct argconfig_commandline_options command_line_options[] = { {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id}, {"ctx-attrs", 'c', "LIST", CFG_STRING, &cfg.ctx_attrs, required_argument, context_attrs}, {"blocks", 'b', "LIST", CFG_STRING, &cfg.blocks, required_argument, blocks}, {"slbs", 's', "LIST", CFG_STRING, &cfg.slbas, required_argument, starting_blocks}, {"ad", 'd', "FLAG", CFG_NONE, &cfg.ad, no_argument, ad}, {"idw", 'w', "FLAG", CFG_NONE, &cfg.idw, no_argument, idw}, {"idr", 'r', "FLAG", CFG_NONE, &cfg.idr, no_argument, idr}, {"cdw11", 'c', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, cdw11}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); get_dev(argc, argv); nc = argconfig_parse_comma_sep_array(cfg.ctx_attrs, ctx_attrs, array_len(ctx_attrs)); nb = argconfig_parse_comma_sep_array(cfg.blocks, nlbs, array_len(nlbs)); ns = argconfig_parse_comma_sep_array_long(cfg.slbas, slbas, array_len(slbas)); nr = max(nc, max(nb, ns)); if (!nr || nr > 256) { fprintf(stderr, "No range definition provided\n"); return EINVAL; } if (!cfg.namespace_id) { cfg.namespace_id = nvme_get_nsid(fd); if (cfg.namespace_id <= 0) { fprintf(stderr, "%s: failed to return namespace id\n", devicename); return errno; } } if (!cfg.cdw11) cfg.cdw11 = (cfg.ad << 2) | (cfg.idw << 1) | (cfg.idr << 0); dsm = nvme_setup_dsm_range((__u32 *)ctx_attrs, (__u32 *)nlbs, (__u64 *)slbas, nr); err = nvme_dsm(fd, cfg.namespace_id, cfg.cdw11, dsm, nr); if (err < 0) { fprintf(stderr, "error:%x\n", err); return errno; } else if (err != 0) fprintf(stderr, "NVME IO command error:%s(%x)\n", nvme_status_to_string(err), err); else printf("NVMe DSM: success\n"); return 0; } static int flush(int argc, char **argv) { const char *desc = "Commit data and metadata associated with "\ "given namespaces to nonvolatile media. Applies to all commands "\ "finished before the flush was submitted. Additional data may also be "\ "flushed by the controller, from any namespace, depending on controller and "\ "associated namespace status."; const char *namespace_id = "identifier of desired namespace"; int err; struct config { __u32 namespace_id; }; struct config cfg = { .namespace_id = 0xffffffff, }; const struct argconfig_commandline_options command_line_options[] = { {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); get_dev(argc, argv); err = nvme_flush(fd, cfg.namespace_id); if (err < 0) return errno; else if (err != 0) fprintf(stderr, "NVME IO command error:%s(%x)\n", nvme_status_to_string(err), err); else printf("NVMe Flush: success\n"); return 0; } static int resv_acquire(int argc, char **argv) { const char *desc = "Obtain a reservation on a given "\ "namespace. Only one reservation is allowed at a time on a "\ "given namespace, though multiple controllers may register "\ "with that namespace. Namespace reservation will abort with "\ "status Reservation Conflict if the given namespace is "\ "already reserved."; const char *namespace_id = "identifier of desired namespace"; const char *crkey = "current reservation key"; const char *prkey = "pre-empt reservation key"; const char *rtype = "hex reservation type"; const char *racqa = "reservation acquiry action"; const char *iekey = "ignore existing res. key"; int err; struct config { __u32 namespace_id; __u64 crkey; __u64 prkey; __u8 rtype; __u8 racqa; __u8 iekey; }; struct config cfg = { .namespace_id = 0, .crkey = 0, .prkey = 0, .rtype = 0, .racqa = 0, }; const struct argconfig_commandline_options command_line_options[] = { {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id}, {"crkey", 'c', "NUM", CFG_LONG_SUFFIX, &cfg.crkey, required_argument, crkey}, {"prkey", 'p', "NUM", CFG_LONG_SUFFIX, &cfg.prkey, required_argument, prkey}, {"rtype", 't', "NUM", CFG_BYTE, &cfg.rtype, required_argument, rtype}, {"racqa", 'a', "NUM", CFG_BYTE, &cfg.racqa, required_argument, racqa}, {"iekey", 'i', "", CFG_NONE, &cfg.iekey, no_argument, iekey}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); get_dev(argc, argv); if (!cfg.namespace_id) { cfg.namespace_id = nvme_get_nsid(fd); if (cfg.namespace_id <= 0) { fprintf(stderr, "%s: failed to return namespace id\n", devicename); return errno; } } if (cfg.racqa > 7) { fprintf(stderr, "invalid racqa:%d\n", cfg.racqa); return EINVAL; } err = nvme_resv_acquire(fd, cfg.namespace_id, cfg.rtype, cfg.racqa, !!cfg.iekey, cfg.crkey, cfg.prkey); if (err < 0) return errno; else if (err != 0) fprintf(stderr, "NVME IO command error:%04x\n", err); else printf("NVME Reservation Acquire success\n"); return 0; } static int resv_register(int argc, char **argv) { const char *desc = "Register, de-register, or "\ "replace a controller's reservation on a given namespace. "\ "Only one reservation at a time is allowed on any namespace."; const char *namespace_id = "identifier of desired namespace"; const char *crkey = "current reservation key"; const char *iekey = "ignore existing res. key"; const char *nrkey = "new reservation key"; const char *rrega = "reservation registration action"; const char *cptpl = "change persistence through power loss setting"; int err; struct config { __u32 namespace_id; __u64 crkey; __u64 nrkey; __u8 rrega; __u8 cptpl; __u8 iekey; }; struct config cfg = { .namespace_id = 0, .crkey = 0, .nrkey = 0, .rrega = 0, .cptpl = 0, }; const struct argconfig_commandline_options command_line_options[] = { {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id}, {"crkey", 'c', "NUM", CFG_LONG_SUFFIX, &cfg.crkey, required_argument, crkey}, {"nrkey", 'k', "NUM", CFG_LONG_SUFFIX, &cfg.nrkey, required_argument, nrkey}, {"rrega", 'r', "NUM", CFG_BYTE, &cfg.rrega, required_argument, rrega}, {"cptpl", 'p', "NUM", CFG_BYTE, &cfg.cptpl, required_argument, cptpl}, {"iekey", 'i', "", CFG_NONE, &cfg.iekey, no_argument, iekey}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); get_dev(argc, argv); if (!cfg.namespace_id) { cfg.namespace_id = nvme_get_nsid(fd); if (cfg.namespace_id <= 0) { fprintf(stderr, "%s: failed to return namespace id\n", devicename); return errno; } } if (cfg.cptpl > 3) { fprintf(stderr, "invalid cptpl:%d\n", cfg.cptpl); return EINVAL; } err = nvme_resv_register(fd, cfg.namespace_id, cfg.rrega, cfg.cptpl, !!cfg.iekey, cfg.crkey, cfg.nrkey); if (err < 0) return errno; else if (err != 0) fprintf(stderr, "NVME IO command error:%04x\n", err); else printf("NVME Reservation success\n"); return 0; } static int resv_release(int argc, char **argv) { const char *desc = "Releases reservation held on a "\ "namespace by the given controller. If rtype != current reservation"\ "type, release will fails. If the given controller holds no "\ "reservation on the namespace or is not the namespace's current "\ "reservation holder, the release command completes with no "\ "effect. If the reservation type is not Write Exclusive or "\ "Exclusive Access, all registrants on the namespace except "\ "the issuing controller are notified."; const char *namespace_id = "desired namespace"; const char *crkey = "current reservation key"; const char *iekey = "ignore existing res. key"; const char *rtype = "hex reservation type"; const char *rrela = "reservation release action"; int err; struct config { __u32 namespace_id; __u64 crkey; __u8 rtype; __u8 rrela; __u8 iekey; }; struct config cfg = { .namespace_id = 0, .crkey = 0, .rtype = 0, .rrela = 0, .iekey = 0, }; const struct argconfig_commandline_options command_line_options[] = { {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id}, {"crkey", 'c', "NUM", CFG_LONG_SUFFIX, &cfg.crkey, required_argument, crkey}, {"rtype", 't', "NUM", CFG_BYTE, &cfg.rtype, required_argument, rtype}, {"rrela", 'a', "NUM", CFG_BYTE, &cfg.rrela, required_argument, rrela}, {"iekey", 'i', "NUM", CFG_BYTE, &cfg.iekey, required_argument, iekey}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); get_dev(argc, argv); if (!cfg.namespace_id) { cfg.namespace_id = nvme_get_nsid(fd); if (cfg.namespace_id <= 0) { fprintf(stderr, "%s: failed to return namespace id\n", devicename); return errno; } } if (cfg.iekey > 1) { fprintf(stderr, "invalid iekey:%d\n", cfg.iekey); return EINVAL; } if (cfg.rrela > 7) { fprintf(stderr, "invalid rrela:%d\n", cfg.rrela); return EINVAL; } err = nvme_resv_release(fd, cfg.namespace_id, cfg.rtype, cfg.rrela, !!cfg.iekey, cfg.crkey); if (err < 0) return errno; else if (err != 0) fprintf(stderr, "NVME IO command error:%04x\n", err); else printf("NVME Reservation Register success\n"); return 0; } static int resv_report(int argc, char **argv) { const char *desc = "Returns Reservation Status data "\ "structure describing any existing reservations on and the "\ "status of a given namespace. Namespace Reservation Status "\ "depends on the number of controllers registered for that "\ "namespace."; const char *namespace_id = "identifier of desired namespace"; const char *numd = "number of dwords to transfer"; const char *raw_binary = "dump output in binary format"; int err; struct nvme_reservation_status *status; struct config { __u32 namespace_id; __u32 numd; __u8 raw_binary; }; struct config cfg = { .namespace_id = 0, .numd = 0, }; const struct argconfig_commandline_options command_line_options[] = { {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id}, {"numd", 'd', "NUM", CFG_POSITIVE, &cfg.numd, required_argument, numd}, {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw_binary}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); get_dev(argc, argv); if (!cfg.namespace_id) { cfg.namespace_id = nvme_get_nsid(fd); if (cfg.namespace_id <= 0) { fprintf(stderr, "%s: failed to return namespace id\n", devicename); return errno; } } if (!cfg.numd || cfg.numd > (0x1000 >> 2)) cfg.numd = 0x1000 >> 2; if (posix_memalign((void **)&status, getpagesize(), cfg.numd << 2)) { fprintf(stderr, "No memory for resv report:%d\n", cfg.numd << 2); return ENOMEM; } err = nvme_resv_report(fd, cfg.namespace_id, cfg.numd, status); if (err < 0) return errno; else if (err != 0) fprintf(stderr, "NVME IO command error:%04x\n", err); else { if (!cfg.raw_binary) { printf("NVME Reservation Report success\n"); show_nvme_resv_report(status); } else d_raw((unsigned char *)status, cfg.numd << 2); } return 0; } static int submit_io(int opcode, char *command, const char *desc, int argc, char **argv) { struct timeval start_time, end_time; void *buffer, *mbuffer = NULL; int err = 0; int dfd, mfd; int flags = opcode & 1 ? O_RDONLY : O_WRONLY | O_CREAT; int mode = S_IRUSR | S_IWUSR |S_IRGRP | S_IWGRP| S_IROTH; __u16 control = 0; const char *start_block = "64-bit addr of first block to access"; const char *block_count = "number of blocks on device to access"; const char *data_size = "size of data in bytes"; const char *metadata_size = "size of metadata in bytes"; const char *ref_tag = "reference tag (for end to end PI)"; const char *data = "data file"; const char *metadata = "metadata file"; const char *prinfo = "PI and check field"; const char *app_tag_mask = "app tag mask (for end to end PI)"; const char *app_tag = "app tag (for end to end PI)"; const char *limited_retry = "limit num. media access attempts"; const char *latency = "output latency statistics"; const char *force = "force device to commit data before command completes"; const char *show = "show command before sending"; const char *dry = "show command instead of sending"; struct config { __u64 start_block; __u16 block_count; __u32 data_size; __u32 metadata_size; __u32 ref_tag; char *data; char *metadata; __u8 prinfo; __u8 app_tag_mask; __u32 app_tag; __u8 limited_retry; __u8 force_unit_access; __u8 show; __u8 dry_run; __u8 latency; }; struct config cfg = { .start_block = 0, .block_count = 0, .data_size = 0, .metadata_size = 0, .ref_tag = 0, .data = "", .metadata = "", .prinfo = 0, .app_tag_mask = 0, .app_tag = 0, }; const struct argconfig_commandline_options command_line_options[] = { {"start-block", 's', "NUM", CFG_LONG_SUFFIX, &cfg.start_block, required_argument, start_block}, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count, required_argument, block_count}, {"data-size", 'z', "NUM", CFG_LONG_SUFFIX, &cfg.data_size, required_argument, data_size}, {"metadata-size", 'y', "NUM", CFG_LONG_SUFFIX, &cfg.metadata_size, required_argument, metadata_size}, {"ref-tag", 'r', "NUM", CFG_POSITIVE, &cfg.ref_tag, required_argument, ref_tag}, {"data", 'd', "FILE", CFG_STRING, &cfg.data, required_argument, data}, {"metadata", 'M', "FILE", CFG_STRING, &cfg.metadata, required_argument, metadata}, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, required_argument, prinfo}, {"app-tag-mask", 'm', "NUM", CFG_BYTE, &cfg.app_tag_mask, required_argument, app_tag_mask}, {"app-tag", 'a', "NUM", CFG_POSITIVE, &cfg.app_tag, required_argument, app_tag}, {"limited-retry", 'l', "", CFG_NONE, &cfg.limited_retry, no_argument, limited_retry}, {"force-unit-access", 'f', "", CFG_NONE, &cfg.force_unit_access, no_argument, force}, {"show-command", 'v', "", CFG_NONE, &cfg.show, no_argument, show}, {"dry-run", 'w', "", CFG_NONE, &cfg.dry_run, no_argument, dry}, {"latency", 't', "", CFG_NONE, &cfg.latency, no_argument, latency}, {0} }; dfd = mfd = opcode & 1 ? STDIN_FILENO : STDOUT_FILENO; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); if (cfg.prinfo > 0xf) return EINVAL; control |= (cfg.prinfo << 10); if (cfg.limited_retry) control |= NVME_RW_LR; if (cfg.force_unit_access) control |= NVME_RW_FUA; if (strlen(cfg.data)){ dfd = open(cfg.data, flags, mode); if (dfd < 0) { perror(cfg.data); return EINVAL; } mfd = dfd; } if (strlen(cfg.metadata)){ mfd = open(cfg.metadata, flags, mode); if (mfd < 0) { perror(cfg.data); return EINVAL; } } get_dev(argc, argv); if (!cfg.data_size) { fprintf(stderr, "data size not provided\n"); return EINVAL; } buffer = malloc(cfg.data_size); if (!buffer) return ENOMEM; if (cfg.metadata_size) { mbuffer = malloc(cfg.metadata_size); if (!mbuffer) { free(buffer); return ENOMEM; } } if ((opcode & 1) && read(dfd, (void *)buffer, cfg.data_size) < 0) { fprintf(stderr, "failed to read data buffer from input file\n"); free(buffer); return EINVAL; } if ((opcode & 1) && cfg.metadata_size && read(mfd, (void *)mbuffer, cfg.metadata_size) < 0) { fprintf(stderr, "failed to read meta-data buffer from input file\n"); err = EINVAL; goto free_and_return; } if (cfg.show) { printf("opcode : %02x\n", opcode); printf("flags : %02x\n", 0); printf("control : %04x\n", control); printf("nblocks : %04x\n", cfg.block_count); printf("rsvd : %04x\n", 0); printf("metadata : %"PRIx64"\n", (uint64_t)(uintptr_t)mbuffer); printf("addr : %"PRIx64"\n", (uint64_t)(uintptr_t)buffer); printf("sbla : %"PRIx64"\n", (uint64_t)cfg.start_block); printf("dsmgmt : %08x\n", 0); printf("reftag : %08x\n", cfg.ref_tag); printf("apptag : %04x\n", cfg.app_tag); printf("appmask : %04x\n", cfg.app_tag_mask); if (cfg.dry_run) goto free_and_return; } gettimeofday(&start_time, NULL); err = nvme_io(fd, opcode, cfg.start_block, cfg.block_count, control, 0, cfg.ref_tag, cfg.app_tag, cfg.app_tag_mask, buffer, mbuffer); gettimeofday(&end_time, NULL); if (cfg.latency) printf(" latency: %s: %llu us\n", command, elapsed_utime(start_time, end_time)); if (err < 0) perror("submit-io"); else if (err) printf("%s:%s(%04x)\n", command, nvme_status_to_string(err), err); else { if (!(opcode & 1) && write(dfd, (void *)buffer, cfg.data_size) < 0) { fprintf(stderr, "failed to write buffer to output file\n"); err = EINVAL; goto free_and_return; } else if (!(opcode & 1) && cfg.metadata_size && write(mfd, (void *)mbuffer, cfg.metadata_size) < 0) { fprintf(stderr, "failed to write meta-data buffer to output file\n"); err = EINVAL; goto free_and_return; } else fprintf(stderr, "%s: Success\n", command); } free_and_return: free(buffer); if (cfg.metadata_size) free(mbuffer); return err; } static int compare(int argc, char **argv) { const char *desc = "Compare specified logical blocks on "\ "device with specified data buffer; return failure if buffer "\ "and block(s) are dissimilar"; return submit_io(nvme_cmd_compare, "compare", desc, argc, argv); } static int read_cmd(int argc, char **argv) { const char *desc = "Copy specified logical blocks on the given "\ "device to specified data buffer (default buffer is stdout)."; return submit_io(nvme_cmd_read, "read", desc, argc, argv); } static int write_cmd(int argc, char **argv) { const char *desc = "Copy from provided data buffer (default "\ "buffer is stdin) to specified logical blocks on the given "\ "device."; return submit_io(nvme_cmd_write, "write", desc, argc, argv); } static int sec_recv(int argc, char **argv) { const char *desc = "Obtain results of one or more "\ "previously submitted security-sends. Results, and association "\ "between Security Send and Receive, depend on the security "\ "protocol field as they are defined by the security protocol "\ "used. A Security Receive must follow a Security Send made with "\ "the same security protocol."; const char *size = "size of buffer (prints to stdout on success)"; const char *secp = "security protocol (cf. SPC-4)"; const char *spsp = "security-protocol-specific (cf. SPC-4)"; const char *al = "allocation length (cf. SPC-4)"; const char *raw_binary = "dump output in binary format"; const char *namespace_id = "desired namespace"; const char *nssf = "NVMe Security Specific Field"; int err; void *sec_buf = NULL; __u32 result; struct config { __u32 namespace_id; __u32 size; __u8 secp; __u8 nssf; __u16 spsp; __u32 al; __u8 raw_binary; }; struct config cfg = { .size = 0, .secp = 0, .spsp = 0, .al = 0, }; const struct argconfig_commandline_options command_line_options[] = { {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id}, {"size", 'x', "NUM", CFG_POSITIVE, &cfg.size, required_argument, size}, {"nssf", 'N', "NUM", CFG_BYTE, &cfg.nssf, required_argument, nssf}, {"secp", 'p', "NUM", CFG_BYTE, &cfg.secp, required_argument, secp}, {"spsp", 's', "NUM", CFG_SHORT, &cfg.spsp, required_argument, spsp}, {"al", 't', "NUM", CFG_POSITIVE, &cfg.al, required_argument, al}, {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw_binary}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); get_dev(argc, argv); if (cfg.size) { if (posix_memalign(&sec_buf, getpagesize(), cfg.size)) { fprintf(stderr, "No memory for security size:%d\n", cfg.size); return ENOMEM; } } err = nvme_sec_recv(fd, cfg.namespace_id, cfg.nssf, cfg.spsp, cfg.secp, cfg.al, cfg.size, sec_buf, &result); if (err < 0) return errno; else if (err != 0) fprintf(stderr, "NVME Security Receive Command Error:%d\n", err); else { if (!cfg.raw_binary) { printf("NVME Security Receive Command Success:%d\n", result); d(sec_buf, cfg.size, 16, 1); } else if (cfg.size) d_raw((unsigned char *)&sec_buf, cfg.size); } return err; } static int passthru(int argc, char **argv, int ioctl_cmd, const char *desc) { void *data = NULL, *metadata = NULL; int err = 0, wfd = STDIN_FILENO; __u32 result; struct config { __u8 opcode; __u8 flags; __u16 rsvd; __u32 namespace_id; __u32 data_len; __u32 metadata_len; __u32 timeout; __u32 cdw2; __u32 cdw3; __u32 cdw10; __u32 cdw11; __u32 cdw12; __u32 cdw13; __u32 cdw14; __u32 cdw15; char *input_file; __u8 raw_binary; __u8 show_command; __u8 dry_run; __u8 read; __u8 write; }; struct config cfg = { .opcode = 0, .flags = 0, .rsvd = 0, .namespace_id = 0, .data_len = 0, .metadata_len = 0, .timeout = 0, .cdw2 = 0, .cdw3 = 0, .cdw10 = 0, .cdw11 = 0, .cdw12 = 0, .cdw13 = 0, .cdw14 = 0, .cdw15 = 0, .input_file = "", }; const char *opcode = "hex opcode (required)"; const char *flags = "command flags"; const char *rsvd = "value for reserved field"; const char *namespace_id = "desired namespace"; const char *data_len = "data I/O length (bytes)"; const char *metadata_len = "metadata seg. length (bytes)"; const char *timeout = "timeout value"; const char *cdw2 = "command dword 2 value"; const char *cdw3 = "command dword 3 value"; const char *cdw10 = "command dword 10 value"; const char *cdw11 = "command dword 11 value"; const char *cdw12 = "command dword 12 value"; const char *cdw13 = "command dword 13 value"; const char *cdw14 = "command dword 14 value"; const char *cdw15 = "command dword 15 value"; const char *input = "write/send file (default stdin)"; const char *raw_binary = "dump output in binary format"; const char *show = "print command before sending"; const char *dry = "show command instead of sending"; const char *re = "set dataflow direction to receive"; const char *wr = "set dataflow direction to send"; const struct argconfig_commandline_options command_line_options[] = { {"opcode", 'o', "NUM", CFG_BYTE, &cfg.opcode, required_argument, opcode}, {"flags", 'f', "NUM", CFG_BYTE, &cfg.flags, required_argument, flags}, {"rsvd", 'R', "NUM", CFG_SHORT, &cfg.rsvd, required_argument, rsvd}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id}, {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len, required_argument, data_len}, {"metadata-len", 'm', "NUM", CFG_POSITIVE, &cfg.metadata_len, required_argument, metadata_len}, {"timeout", 't', "NUM", CFG_POSITIVE, &cfg.timeout, required_argument, timeout}, {"cdw2", '2', "NUM", CFG_POSITIVE, &cfg.cdw2, required_argument, cdw2}, {"cdw3", '3', "NUM", CFG_POSITIVE, &cfg.cdw3, required_argument, cdw3}, {"cdw10", '4', "NUM", CFG_POSITIVE, &cfg.cdw10, required_argument, cdw10}, {"cdw11", '5', "NUM", CFG_POSITIVE, &cfg.cdw11, required_argument, cdw11}, {"cdw12", '6', "NUM", CFG_POSITIVE, &cfg.cdw12, required_argument, cdw12}, {"cdw13", '7', "NUM", CFG_POSITIVE, &cfg.cdw13, required_argument, cdw13}, {"cdw14", '8', "NUM", CFG_POSITIVE, &cfg.cdw14, required_argument, cdw14}, {"cdw15", '9', "NUM", CFG_POSITIVE, &cfg.cdw15, required_argument, cdw15}, {"input-file", 'i', "FILE", CFG_STRING, &cfg.input_file, required_argument, input}, {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw_binary}, {"show-command", 's', "", CFG_NONE, &cfg.show_command, no_argument, show}, {"dry-run", 'd', "", CFG_NONE, &cfg.dry_run, no_argument, dry}, {"read", 'r', "", CFG_NONE, &cfg.read, no_argument, re}, {"write", 'w', "", CFG_NONE, &cfg.write, no_argument, wr}, {0} }; argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); if (strlen(cfg.input_file)){ wfd = open(cfg.input_file, O_RDONLY, S_IRUSR | S_IRGRP | S_IROTH); if (wfd < 0) { perror(cfg.input_file); return EINVAL; } } get_dev(argc, argv); if (cfg.metadata_len) metadata = malloc(cfg.metadata_len); if (cfg.data_len) { data = malloc(cfg.data_len); if (!cfg.read && !cfg.write) { fprintf(stderr, "data direction not given\n"); err = EINVAL; goto free_and_return; } if (cfg.read && cfg.write) { fprintf(stderr, "command can't be both read and write\n"); err = EINVAL; goto free_and_return; } if (cfg.write) { if (read(wfd, data, cfg.data_len) < 0) { fprintf(stderr, "failed to read write buffer\n"); err = EINVAL; goto free_and_return; } } } if (cfg.show_command) { printf("opcode : %02x\n", cfg.opcode); printf("flags : %02x\n", cfg.flags); printf("rsvd1 : %04x\n", cfg.rsvd); printf("nsid : %08x\n", cfg.namespace_id); printf("cdw2 : %08x\n", cfg.cdw2); printf("cdw3 : %08x\n", cfg.cdw3); printf("data_len : %08x\n", cfg.data_len); printf("metadata_len : %08x\n", cfg.metadata_len); printf("addr : %"PRIx64"\n", (uint64_t)(uintptr_t)data); printf("metadata : %"PRIx64"\n", (uint64_t)(uintptr_t)metadata); printf("cdw10 : %08x\n", cfg.cdw10); printf("cdw11 : %08x\n", cfg.cdw11); printf("cdw12 : %08x\n", cfg.cdw12); printf("cdw13 : %08x\n", cfg.cdw13); printf("cdw14 : %08x\n", cfg.cdw14); printf("cdw15 : %08x\n", cfg.cdw15); printf("timeout_ms : %08x\n", cfg.timeout); if (cfg.dry_run) goto free_and_return; } err = nvme_passthru(fd, ioctl_cmd, cfg.opcode, cfg.flags, cfg.rsvd, cfg.namespace_id, cfg.cdw2, cfg.cdw3, cfg.cdw10, cfg.cdw11, cfg.cdw12, cfg.cdw13, cfg.cdw14, cfg.cdw15, cfg.data_len, data, cfg.metadata_len, metadata, cfg.timeout, &result); if (err < 0) perror("passthru"); else if (err) printf("NVMe Status:%s Command Result:%08x\n", nvme_status_to_string(err), result); else { if (!cfg.raw_binary) { printf("NVMe command result:%08x\n", result); if (data && cfg.read && !err) d((unsigned char *)data, cfg.data_len, 16, 1); } else if (data && cfg.read) d_raw((unsigned char *)data, cfg.data_len); } return err; free_and_return: free(data); free(metadata); return err; } static int io_passthru(int argc, char **argv) { const char *desc = "Send a user-defined IO command to the specified "\ "device via IOCTL passthrough, return results."; return passthru(argc, argv, NVME_IOCTL_IO_CMD, desc); } static int admin_passthru(int argc, char **argv) { const char *desc = "Send a user-defined Admin command to the specified "\ "device via IOCTL passthrough, return results."; return passthru(argc, argv, NVME_IOCTL_ADMIN_CMD, desc); } static void usage() { printf("usage: nvme [] []\n"); } static void command_help(const char *cmd) { unsigned i; struct command *c; for (i = 0; i < NUM_COMMANDS; i++) { c = &commands[i]; if (strcmp(c->name, cmd)) continue; exit(execlp("man", "man", c->man, (char *)NULL)); } fprintf(stderr, "No entry for nvme sub-command %s\n", cmd); } static void general_help() { unsigned i; const char *desc = "The '' may be either an NVMe character "\ "device (ex: /dev/nvme0) or an nvme block device "\ "(ex: /dev/nvme0n1).\n\n"; printf("nvme-%s\n", nvme_version_string); usage(); printf("\n"); print_word_wrapped(desc, 0, 0); printf("The following are all implemented sub-commands:\n"); for (i = 0; i < NUM_COMMANDS; i++) printf(" %-*s %s\n", 15, commands[i].name, commands[i].help); printf("\n"); printf("See 'nvme help ' for more information on a specific command.\n"); } static int version(int argc, char **argv) { printf("nvme version %s\n", nvme_version_string); return 0; } static int help(int argc, char **argv) { if (argc == 1) general_help(); else command_help(argv[1]); return 0; } static void handle_internal_command(int argc, char **argv) { unsigned i; struct command *cmd; char *str = argv[0]; char usage[0x100]; sprintf(usage, "nvme %s [OPTIONS]", str); argconfig_append_usage(usage); /* translate --help and --version into commands */ while (*str == '-') str++; for (i = 0; i < NUM_COMMANDS; i++) { cmd = &commands[i]; if (strcmp(str, cmd->name)) continue; exit(cmd->fn(argc, argv)); } fprintf(stderr, "unknown command '%s'\n", argv[0]); help(1, NULL); exit(1); } int main(int argc, char **argv) { if (argc < 2) { usage(); return 0; } setlocale(LC_ALL, ""); handle_internal_command(argc - 1, &argv[1]); return 0; } nvme-cli-0.5/nvme.control.in000066400000000000000000000003471267263733400160650ustar00rootroot00000000000000Package: nvme Version: @@VERSION@@ Section: base Priority: optional Architecture: amd64 Depends: @@DEPENDS@@ Maintainer: Keith Busch Description: NVM-Express Command Line Interface The nvme management tool nvme-cli-0.5/nvme.spec.in000066400000000000000000000013271267263733400153360ustar00rootroot00000000000000Name: nvme Version: @@VERSION@@ Release: 1%{?dist} Summary: Core nvme tools License: GPL Group: Development/Tools URL: https://github.com/linux-nvme/nvme-cli/ Source: nvme-@@VERSION@@.tar.gz Provides: nvme BuildRoot: %{_tmppath}/%{name}-%{version}-root %description NVMe is a fast, scalable, direct attached storage interface. The nvme cli rpm installs core management tools with minimal dependencies. %prep %setup %build make %install rm -rf $RPM_BUILD_ROOT make install PREFIX=%{buildroot}/usr %files %defattr(-,root,root) %doc Documentation/nvme*.1 %{_sbindir}/nvme %{_mandir}/man1/nvme*.1* %clean rm -rf $RPM_BUILD_ROOT %changelog * Thu Oct 15 2015 Keith Busch - Initial RPM spec nvme-cli-0.5/regress000077500000000000000000000055371267263733400145170ustar00rootroot00000000000000#!/bin/bash # # Copyright 2015 PMC-Sierra, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. # # Author: Stephen Bates # # Description: # Regression test-suite for the NVM Express CLI. # DEVICE= WRITE=false LIST=false RAND_BASE=temp.rand RAND_WFILE=${RAND_BASE}.write RAND_RFILE=${RAND_BASE}.read RAND_SIZE=4k green=$(tput bold)$(tput setaf 2) red=$(tput bold)$(tput setaf 1) rst=$(tput sgr0) while getopts ":d:wl" opt; do case $opt in d) DEVICE=${OPTARG} ;; w) echo "WARNING: Write mode enabled, this might trash your drive!" WRITE=true ;; l) LIST=true ;; \?) echo "Invalid option: -$OPTARG" >&2 exit 1 ;; :) echo "Option -$OPTARG requires an argument." >&2 exit 1 ;; esac done if [ -z "$DEVICE" ]; then echo "regress: You must specify a NVMe device using -d" exit 1 fi function print_pass_fail { $* > /dev/null 2>&1 if (( $? )); then echo ${red}"FAILED!"${rst} echo "Failed running command: " echo " $*" exit 1 else echo ${green}"PASSED!"${rst} fi } function run_test { LINE="$*" printf " %-3s %-68s : " "RUN" "${LINE::67}" print_pass_fail $* } make clean > /dev/null || exit -1 make install > /dev/null || exit -1 if $LIST ; then run_test nvme list fi run_test nvme id-ctrl ${DEVICE} run_test nvme id-ns -raw-binary ${DEVICE} run_test nvme list-ns -n 1 ${DEVICE} run_test nvme get-ns-id ${DEVICE} run_test nvme get-log ${DEVICE} --log-id=2 --log-len=512 run_test nvme fw-log ${DEVICE} run_test nvme fw-log ${DEVICE} -b run_test nvme smart-log ${DEVICE} run_test nvme error-log ${DEVICE} run_test nvme get-feature ${DEVICE} -f 7 run_test nvme flush ${DEVICE} if $WRITE ; then run_test dd if=/dev/urandom of=${RAND_WFILE} bs=${RAND_SIZE} count=1 run_test nvme write ${DEVICE} --start-block=0 --block-count=0 --data-size=${RAND_SIZE} --data ${RAND_WFILE} fi run_test nvme read ${DEVICE} --start-block=0 --block-count=0 --data-size=${RAND_SIZE} --data ${RAND_RFILE} --latency if $WRITE ; then run_test diff ${RAND_RFILE} ${RAND_WFILE} rm ${RAND_WFILE} > /dev/null fi rm ${RAND_RFILE} > /dev/null nvme-cli-0.5/scripts/000077500000000000000000000000001267263733400145745ustar00rootroot00000000000000nvme-cli-0.5/scripts/latency000077500000000000000000000052661267263733400161720ustar00rootroot00000000000000#!/bin/bash # # Copyright 2015 PMC-Sierra, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. # # Author: Stephen Bates # # Description: # A shell script that calls the NVMe CLI multiple times to gather # latency data. Consider this a poor man's iometer or fio for QD=1 # analysis. Of course this is below the file-system and block # layer so is a best case measurement. # DEVICE= WRITE=false COUNT=10 DATA_SIZE=4096 METADATA_SIZE=64 RAND_BASE=temp.rand RAND_WFILE=${RAND_BASE}.write RAND_RFILE=${RAND_BASE}.read OUTPUT=latency.dat green=$(tput bold)$(tput setaf 2) red=$(tput bold)$(tput setaf 1) rst=$(tput sgr0) while getopts ":d:n:w" opt; do case $opt in d) DEVICE=${OPTARG} ;; n) COUNT=${OPTARG} ;; w) echo "WARNING: Write mode enabled, this might trash your drive!" WRITE=true ;; \?) echo "Invalid option: -$OPTARG" >&2 exit 1 ;; :) echo "Option -$OPTARG requires an argument." >&2 exit 1 ;; esac done if [ -z "$DEVICE" ]; then echo "regress: You must specify a NVMe device using -d" exit 1 fi function run_test { $* | grep -i latency >> ${OUTPUT} 2>&1 if (( $? )); then echo ${red}"FAILED!"${rst} echo "Failed running command: " echo " $*" exit 1 fi } rm -f ${OUTPUT} > /dev/null || exit -1 make clean > /dev/null || exit -1 make install > /dev/null || exit -1 for i in `seq 1 ${COUNT}`; do if $WRITE ; then run_test dd if=/dev/urandom of=${RAND_WFILE} bs=${DATA_SIZE} count=1 run_test nvme write ${DEVICE} --start-block=0 --block-count=0 \ --metadata-size=${METADATA_SIZE} --data-size=${DATA_SIZE} \ --data ${RAND_WFILE} --latency rm ${RAND_WFILE} > /dev/null else run_test nvme read ${DEVICE} --start-block=0 --block-count=0 \ --metadata-size=${METADATA_SIZE} --data-size=${DATA_SIZE} \ --data ${RAND_RFILE} --latency rm ${RAND_RFILE} > /dev/null fi done nvme-cli-0.5/src/000077500000000000000000000000001267263733400136745ustar00rootroot00000000000000nvme-cli-0.5/src/argconfig.c000066400000000000000000000426471267263733400160140ustar00rootroot00000000000000//////////////////////////////////////////////////////////////////////// // // Copyright 2014 PMC-Sierra, Inc. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// // // Author: Logan Gunthorpe // // Date: Oct 23 2014 // // Description: // Functions for parsing command line options. // //////////////////////////////////////////////////////////////////////// #include "argconfig.h" #include "suffix.h" #include #include #include #include #include #include #include static argconfig_help_func *help_funcs[MAX_HELP_FUNC] = { NULL }; char END_DEFAULT[] = "__end_default__"; const char *append_usage_str = ""; void argconfig_append_usage(const char *str) { append_usage_str = str; } void print_word_wrapped(const char *s, int indent, int start) { const int width = 76; const char *c, *t; int next_space = -1; int last_line = indent; while (start < indent) { putc(' ', stderr); start++; } for (c = s; *c != 0; c++) { if (*c == ' ' || next_space < 0) { next_space = 0; for (t = c + 1; *t != 0 && *t != ' '; t++) next_space++; if (((int)(c - s) + start + next_space) > (last_line - indent + width)) { int i; last_line = (int) (c-s) + start; putc('\n', stderr); for (i = 0; i < indent; i++) putc(' ', stderr); start = indent; continue; } } putc(*c, stderr); } } static void show_option(const struct argconfig_commandline_options *option) { char buffer[0x1000]; char *b = buffer; b += sprintf(b, " [ "); if (option->option) { b += sprintf(b, " --%s", option->option); if (option->argument_type == optional_argument) b += sprintf(b, "[=<%s>]", option->meta ? option->meta : "arg"); if (option->argument_type == required_argument) b += sprintf(b, "=<%s>", option->meta ? option->meta : "arg"); if (option->short_option) b += sprintf(b, ","); } if (option->short_option) { b += sprintf(b, " -%c", option->short_option); if (option->argument_type == optional_argument) b += sprintf(b, " [<%s>]", option->meta ? option->meta : "arg"); if (option->argument_type == required_argument) b += sprintf(b, " <%s>", option->meta ? option->meta : "arg"); } b += sprintf(b, " ] "); fprintf(stderr, "%s", buffer); if (option->help) { print_word_wrapped("--- ", 40, b - buffer); print_word_wrapped(option->help, 44, 44); } fprintf(stderr, "\n"); } static void argconfig_print_help(const char *program_desc, const struct argconfig_commandline_options *options) { const struct argconfig_commandline_options *s; printf("\033[1mUsage: %s\033[0m\n\n", append_usage_str); print_word_wrapped(program_desc, 0, 0); printf("\n\n\033[1mOptions:\033[0m\n"); for (s = options; (s->option != 0) && (s != NULL); s++) show_option(s); } int argconfig_parse(int argc, char *argv[], const char *program_desc, const struct argconfig_commandline_options *options, void *config_out, size_t config_size) { char *short_opts; char *endptr; struct option *long_opts; const struct argconfig_commandline_options *s; int c, option_index = 0, short_index = 0, options_count = 0; void *value_addr; errno = 0; for (s = options; s->option != 0; s++) options_count++; long_opts = malloc(sizeof(struct option) * (options_count + 2)); short_opts = malloc(sizeof(*short_opts) * (options_count * 3 + 4)); for (s = options; (s->option != 0) && (option_index < options_count); s++) { if (s->short_option != 0) { short_opts[short_index++] = s->short_option; if (s->argument_type == required_argument || s->argument_type == optional_argument) short_opts[short_index++] = ':'; if (s->argument_type == optional_argument) short_opts[short_index++] = ':'; } if (s->option && strlen(s->option)) { long_opts[option_index].name = s->option; long_opts[option_index].has_arg = s->argument_type; if (s->argument_type == no_argument && s->default_value != NULL) { value_addr = (void *)(char *)s->default_value; long_opts[option_index].flag = value_addr; long_opts[option_index].val = 1; } else { long_opts[option_index].flag = NULL; long_opts[option_index].val = 0; } } option_index++; } long_opts[option_index].name = "help"; long_opts[option_index].flag = NULL; long_opts[option_index].val = 'h'; option_index++; long_opts[option_index].name = NULL; long_opts[option_index].flag = NULL; long_opts[option_index].val = 0; short_opts[short_index++] = '?'; short_opts[short_index++] = 'h'; short_opts[short_index] = 0; while ((c = getopt_long_only(argc, argv, short_opts, long_opts, &option_index)) != -1) { if (c != 0) { if (c == '?' || c == 'h') { argconfig_print_help(program_desc, options); goto exit; } for (option_index = 0; option_index < options_count; option_index++) { if (c == options[option_index].short_option) break; } if (option_index == options_count) continue; if (long_opts[option_index].flag) { *(uint8_t *)(long_opts[option_index].flag) = 1; continue; } } s = &options[option_index]; value_addr = (void *)(char *)s->default_value; if (s->config_type == CFG_STRING) { *((char **)value_addr) = optarg; } else if (s->config_type == CFG_SIZE) { *((size_t *) value_addr) = strtol(optarg, &endptr, 0); if (errno || optarg == endptr) { fprintf(stderr, "Expected integer argument for '%s' but got '%s'!\n", long_opts[option_index].name, optarg); goto exit; } } else if (s->config_type == CFG_INT) { *((int *)value_addr) = strtol(optarg, &endptr, 0); if (errno || optarg == endptr) { fprintf(stderr, "Expected integer argument for '%s' but got '%s'!\n", long_opts[option_index].name, optarg); goto exit; } } else if (s->config_type == CFG_BOOL) { int tmp = strtol(optarg, &endptr, 0); if (errno || tmp < 0 || tmp > 1 || optarg == endptr) { fprintf(stderr, "Expected 0 or 1 argument for '%s' but got '%s'!\n", long_opts[option_index].name, optarg); goto exit; } *((int *)value_addr) = tmp; } else if (s->config_type == CFG_BYTE) { uint8_t tmp = strtol(optarg, &endptr, 0); if (errno || tmp < 0 || optarg == endptr) { fprintf(stderr, "Expected positive argument for '%s' but got '%s'!\n", long_opts[option_index].name, optarg); goto exit; } *((uint8_t *) value_addr) = tmp; } else if (s->config_type == CFG_SHORT) { uint16_t tmp = strtol(optarg, &endptr, 0); if (errno || tmp < 0 || optarg == endptr) { fprintf(stderr, "Expected positive argument for '%s' but got '%s'!\n", long_opts[option_index].name, optarg); goto exit; } *((uint16_t *) value_addr) = tmp; } else if (s->config_type == CFG_POSITIVE) { uint32_t tmp = strtol(optarg, &endptr, 0); if (errno || tmp < 0 || optarg == endptr) { fprintf(stderr, "Expected positive argument for '%s' but got '%s'!\n", long_opts[option_index].name, optarg); goto exit; } *((uint32_t *) value_addr) = tmp; } else if (s->config_type == CFG_INCREMENT) { (*((int *)value_addr))++; } else if (s->config_type == CFG_LONG) { *((long *)value_addr) = strtol(optarg, &endptr, 0); if (errno || optarg == endptr) { fprintf(stderr, "Expected long integer argument for '%s' but got '%s'!\n", long_opts[option_index].name, optarg); goto exit; } } else if (s->config_type == CFG_LONG_SUFFIX) { *((long *)value_addr) = suffix_binary_parse(optarg); if (errno) { fprintf(stderr, "Expected long suffixed integer argument for '%s' but got '%s'!\n", long_opts[option_index].name, optarg); goto exit; } } else if (s->config_type == CFG_DOUBLE) { *((double *)value_addr) = strtod(optarg, &endptr); if (errno || optarg == endptr) { fprintf(stderr, "Expected float argument for '%s' but got '%s'!\n", long_opts[option_index].name, optarg); goto exit; } } else if (s->config_type == CFG_SUBOPTS) { char **opts = ((char **)value_addr); int remaining_space = CFG_MAX_SUBOPTS; int enddefault = 0; while (0 && *opts != NULL) { if (*opts == END_DEFAULT) enddefault = 1; remaining_space--; opts++; } if (!enddefault) { *opts = END_DEFAULT; remaining_space -= 2; opts += 2; } int r = argconfig_parse_subopt_string(optarg, opts, remaining_space); if (r == 2) { fprintf(stderr, "Error Parsing Sub-Options: Too many options!\n"); goto exit; } else if (r) { fprintf(stderr, "Error Parsing Sub-Options\n"); goto exit; } } else if (s->config_type == CFG_FILE_A || s->config_type == CFG_FILE_R || s->config_type == CFG_FILE_W || s->config_type == CFG_FILE_AP || s->config_type == CFG_FILE_RP || s->config_type == CFG_FILE_WP) { const char *fopts = ""; if (s->config_type == CFG_FILE_A) fopts = "a"; else if (s->config_type == CFG_FILE_R) fopts = "r"; else if (s->config_type == CFG_FILE_W) fopts = "w"; else if (s->config_type == CFG_FILE_AP) fopts = "a+"; else if (s->config_type == CFG_FILE_RP) fopts = "r+"; else if (s->config_type == CFG_FILE_WP) fopts = "w+"; FILE *f = fopen(optarg, fopts); if (f == NULL) { fprintf(stderr, "Unable to open %s file: %s\n", s->option, optarg); goto exit; } *((FILE **) value_addr) = f; } } free(short_opts); free(long_opts); return 0; exit: free(short_opts); free(long_opts); exit(1); } int argconfig_parse_subopt_string(char *string, char **options, size_t max_options) { char **o = options; char *tmp; if (!strlen(string) || string == NULL) { *(o++) = NULL; *(o++) = NULL; return 0; } tmp = calloc(strlen(string) + 2, 1); strcpy(tmp, string); size_t toklen; toklen = strcspn(tmp, "="); if (!toklen) { free(tmp); return 1; } *(o++) = tmp; tmp[toklen] = 0; tmp += toklen + 1; while (1) { if (*tmp == '"' || *tmp == '\'' || *tmp == '[' || *tmp == '(' || *tmp == '{') { tmp++; toklen = strcspn(tmp, "\"'])}"); if (!toklen) return 1; *(o++) = tmp; tmp[toklen] = 0; tmp += toklen + 1; toklen = strcspn(tmp, ";:,"); tmp[toklen] = 0; tmp += toklen + 1; } else { toklen = strcspn(tmp, ";:,"); if (!toklen) return 1; *(o++) = tmp; tmp[toklen] = 0; tmp += toklen + 1; } toklen = strcspn(tmp, "="); if (!toklen) break; *(o++) = tmp; tmp[toklen] = 0; tmp += toklen + 1; if ((o - options) > (max_options - 2)) return 2; } *(o++) = NULL; *(o++) = NULL; return 0; } unsigned argconfig_parse_comma_sep_array(char *string, int *val, unsigned max_length) { unsigned ret = 0; char *tmp; char *p; if (!strlen(string) || string == NULL) return 0; tmp = strtok(string, ","); if (!tmp) return 0; val[ret] = strtol(tmp, &p, 0); if (*p != 0) exit(1); ret++; while (1) { tmp = strtok(NULL, ","); if (tmp == NULL) return ret; if (ret >= max_length) exit(1); val[ret] = strtol(tmp, &p, 0); if (*p != 0) exit(1); ret++; } } unsigned argconfig_parse_comma_sep_array_long(char *string, unsigned long long *val, unsigned max_length) { unsigned ret = 0; char *tmp; char *p; if (!strlen(string) || string == NULL) return 0; tmp = strtok(string, ","); if (tmp == NULL) return 0; val[ret] = strtoll(tmp, &p, 0); if (*p != 0) exit(1); ret++; while (1) { tmp = strtok(NULL, ","); if (tmp == NULL) return ret; if (ret >= max_length) exit(1); val[ret] = strtoll(tmp, &p, 0); if (*p != 0) exit(1); ret++; } } void argconfig_register_help_func(argconfig_help_func * f) { int i; for (i = 0; i < MAX_HELP_FUNC; i++) { if (help_funcs[i] == NULL) { help_funcs[i] = f; help_funcs[i + 1] = NULL; break; } } } void argconfig_parse_subopt(char *const opts[], const char *module, const struct argconfig_sub_options *options, void *config_out, size_t config_size) { int enddefault = 0; int tmp; const struct argconfig_sub_options *s; char *const *o; errno = 0; for (o = opts; o != NULL && *o != NULL; o += 2) { if (*o == END_DEFAULT) { enddefault = 1; continue; } for (s = options; s->option != NULL; s++) if (strcmp(o[0], s->option) == 0) break; if (s->option == NULL && enddefault) { fprintf(stderr, "%s: Invalid sub-option '%s'.\n", module, o[0]); exit(1); } else if (s->option == NULL) { continue; } void *value_addr = (void *)(char *)s->default_value; if (s->config_type == CFG_STRING) { *((char **)value_addr) = o[1]; } else if (s->config_type == CFG_INT) { *((int *)value_addr) = (int)strtol(o[1], NULL, 0); } else if (s->config_type == CFG_SIZE) { *((size_t *) value_addr) = (size_t) strtol(o[1], NULL, 0); } else if (s->config_type == CFG_LONG) { *((long *)value_addr) = strtol(o[1], NULL, 0); } else if (s->config_type == CFG_LONG_SUFFIX) { *((long *)value_addr) = suffix_binary_parse(o[1]); } else if (s->config_type == CFG_DOUBLE) { *((double *)value_addr) = strtod(o[1], NULL); } else if (s->config_type == CFG_BOOL) { tmp = strtol(o[1], NULL, 0); if (tmp < 0 || tmp > 1) errno = 1; *((int *)value_addr) = (int)tmp; } else if (s->config_type == CFG_POSITIVE) { tmp = strtol(o[1], NULL, 0); if (tmp < 0) errno = 1; *((int *)value_addr) = (int)tmp; } else if (s->config_type == CFG_FILE_A || s->config_type == CFG_FILE_R || s->config_type == CFG_FILE_W || s->config_type == CFG_FILE_AP || s->config_type == CFG_FILE_RP || s->config_type == CFG_FILE_WP) { const char *fopts = ""; if (s->config_type == CFG_FILE_A) fopts = "a"; else if (s->config_type == CFG_FILE_R) fopts = "r"; else if (s->config_type == CFG_FILE_W) fopts = "w"; else if (s->config_type == CFG_FILE_AP) fopts = "a+"; else if (s->config_type == CFG_FILE_RP) fopts = "r+"; else if (s->config_type == CFG_FILE_WP) fopts = "w+"; FILE *f = fopen(o[1], fopts); if (f == NULL) { fprintf(stderr, "Unable to open %s file: %s\n", s->option, o[1]); exit(1); } *((FILE **) value_addr) = f; } if (errno) { fprintf(stderr, "%s: Invalid value '%s' for option '%s'.\n", module, o[1], o[0]); exit(1); } } } int argconfig_set_subopt(const char *opt, const struct argconfig_sub_options *options, void *config_out, va_list argp) { const struct argconfig_sub_options *s; for (s = options; s->option != NULL; s++) if (strcmp(opt, s->option) == 0) break; if (s->option == NULL) return 1; void *value_addr = (void *)(char *)s->default_value; if (s->config_type == CFG_STRING) { *((char **)value_addr) = va_arg(argp, char *); } else if (s->config_type == CFG_INT || s->config_type == CFG_BOOL || s->config_type == CFG_POSITIVE) { *((int *)value_addr) = va_arg(argp, int); } else if (s->config_type == CFG_SIZE) { *((size_t *) value_addr) = va_arg(argp, size_t); } else if (s->config_type == CFG_LONG) { *((long *)value_addr) = va_arg(argp, long); } else if (s->config_type == CFG_LONG_SUFFIX) { *((long *)value_addr) = va_arg(argp, long); } else if (s->config_type == CFG_DOUBLE) { *((double *)value_addr) = va_arg(argp, double); } else if (s->config_type == CFG_FILE_A || s->config_type == CFG_FILE_R || s->config_type == CFG_FILE_W || s->config_type == CFG_FILE_AP || s->config_type == CFG_FILE_RP || s->config_type == CFG_FILE_WP) { *((FILE **) value_addr) = va_arg(argp, FILE *); } return 0; } int argconfig_get_subopt(const char *opt, const struct argconfig_sub_options *options, void *config_out, va_list argp) { const struct argconfig_sub_options *s; for (s = options; s->option != NULL; s++) if (strcmp(opt, s->option) == 0) break; if (s->option == NULL) return 1; void *value_addr = (void *)(char *)s->default_value; if (s->config_type == CFG_STRING) { *va_arg(argp, char **) = *((char **)value_addr); } else if (s->config_type == CFG_INT || s->config_type == CFG_BOOL || s->config_type == CFG_POSITIVE) { *va_arg(argp, int *) = *((int *)value_addr); } else if (s->config_type == CFG_SIZE) { *va_arg(argp, size_t *) = *((size_t *) value_addr); } else if (s->config_type == CFG_LONG) { *va_arg(argp, long *) = *((long *)value_addr); } else if (s->config_type == CFG_LONG_SUFFIX) { *va_arg(argp, long *) = *((long *)value_addr); } else if (s->config_type == CFG_DOUBLE) { *va_arg(argp, double *) = *((double *)value_addr); } else if (s->config_type == CFG_FILE_A || s->config_type == CFG_FILE_R || s->config_type == CFG_FILE_W || s->config_type == CFG_FILE_AP || s->config_type == CFG_FILE_RP || s->config_type == CFG_FILE_WP) { *va_arg(argp, FILE **) = *((FILE **) value_addr); } return 0; } nvme-cli-0.5/src/argconfig.h000066400000000000000000000064031267263733400160070ustar00rootroot00000000000000//////////////////////////////////////////////////////////////////////// // // Copyright 2014 PMC-Sierra, Inc. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// // // Author: Logan Gunthorpe // Logan Gunthorpe // // Date: Oct 23 2014 // // Description: // Header file for argconfig.c // //////////////////////////////////////////////////////////////////////// #ifndef argconfig_H #define argconfig_H #include #include #include enum argconfig_types { CFG_NONE, CFG_STRING, CFG_INT, CFG_SIZE, CFG_LONG, CFG_LONG_SUFFIX, CFG_DOUBLE, CFG_BOOL, CFG_BYTE, CFG_SHORT, CFG_POSITIVE, CFG_INCREMENT, CFG_SUBOPTS, CFG_FILE_A, CFG_FILE_W, CFG_FILE_R, CFG_FILE_AP, CFG_FILE_WP, CFG_FILE_RP, }; struct argconfig_commandline_options { const char *option; const char short_option; const char *meta; enum argconfig_types config_type; void *default_value; int argument_type; const char *help; }; #define CFG_MAX_SUBOPTS 500 #define MAX_HELP_FUNC 20 struct argconfig_sub_options { const char *option; const char short_option; const char *meta; enum argconfig_types config_type; const void *default_value; const char *help; }; #ifdef __cplusplus extern "C" { #endif typedef void argconfig_help_func(); void argconfig_append_usage(const char *str); int argconfig_parse(int argc, char *argv[], const char *program_desc, const struct argconfig_commandline_options *options, void *config_out, size_t config_size); int argconfig_parse_subopt_string(char *string, char **options, size_t max_options); unsigned argconfig_parse_comma_sep_array(char *string, int *ret, unsigned max_length); unsigned argconfig_parse_comma_sep_array_long(char *string, unsigned long long *ret, unsigned max_length); void argconfig_register_help_func(argconfig_help_func * f); void argconfig_print_subopt_help(const struct argconfig_sub_options *options, int indent); void argconfig_parse_subopt(char *const opts[], const char *module, const struct argconfig_sub_options *options, void *config_out, size_t config_size); int argconfig_set_subopt(const char *opt, const struct argconfig_sub_options *options, void *config_out, va_list arg); int argconfig_get_subopt(const char *opt, const struct argconfig_sub_options *options, void *config_out, va_list arg); void print_word_wrapped(const char *s, int indent, int start); #ifdef __cplusplus } #endif #endif nvme-cli-0.5/src/suffix.c000066400000000000000000000053741267263733400153550ustar00rootroot00000000000000//////////////////////////////////////////////////////////////////////// // // Copyright 2014 PMC-Sierra, Inc. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// // // Author: Logan Gunthorpe // // Date: Oct 23 2014 // // Description: // Functions for dealing with number suffixes // //////////////////////////////////////////////////////////////////////// #include "suffix.h" #include #include #include static struct si_suffix { double magnitude; const char *suffix; } si_suffixes[] = { {1e15, "P"}, {1e12, "T"}, {1e9, "G"}, {1e6, "M"}, {1e3, "k"}, {1e0, ""}, {1e-3, "m"}, {1e-6, "u"}, {1e-9, "n"}, {1e-12, "p"}, {1e-15, "f"}, {0} }; const char *suffix_si_get(double *value) { struct si_suffix *s; for (s = si_suffixes; s->magnitude != 0; s++) { if (*value >= s->magnitude) { *value /= s->magnitude; return s->suffix; } } return ""; } static struct binary_suffix { int shift; const char *suffix; } binary_suffixes[] = { {50, "Pi"}, {40, "Ti"}, {30, "Gi"}, {20, "Mi"}, {10, "Ki"}, {0, ""} }; const char *suffix_binary_get(long long *value) { struct binary_suffix *s; for (s = binary_suffixes; s->shift != 0; s++) { if (llabs(*value) >= (1LL << s->shift)) { *value = (*value + (1 << (s->shift - 1))) / (1 << s->shift); return s->suffix; } } return ""; } const char *suffix_dbinary_get(double *value) { struct binary_suffix *s; for (s = binary_suffixes; s->shift != 0; s++) { if (llabs(*value) >= (1LL << s->shift)) { *value = *value / (1 << s->shift); return s->suffix; } } return ""; } long long suffix_binary_parse(const char *value) { char *suffix; errno = 0; long long ret = strtol(value, &suffix, 0); if (errno) return 0; struct binary_suffix *s; for (s = binary_suffixes; s->shift != 0; s++) { if (tolower(suffix[0]) == tolower(s->suffix[0])) { ret <<= s->shift; return ret; } } if (suffix[0] != '\0') errno = EINVAL; return ret; } nvme-cli-0.5/src/suffix.h000066400000000000000000000026131267263733400153530ustar00rootroot00000000000000//////////////////////////////////////////////////////////////////////// // // Copyright 2014 PMC-Sierra, Inc. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// // // Author: Logan Gunthorpe // // Date: Oct 23 2014 // // Description: // Functions for dealing with number suffixes // //////////////////////////////////////////////////////////////////////// #ifndef __ARGCONFIG_SUFFIX_H__ const char *suffix_si_get(double *value); const char *suffix_binary_get(long long *value); const char *suffix_dbinary_get(double *value); long long suffix_binary_parse(const char *value); #endif