]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
add lockdown command support
authorGollu Appalanaidu <anaidu.gollu@samsung.com>
Thu, 9 Sep 2021 09:22:03 +0000 (14:52 +0530)
committerDaniel Wagner <dwagner@suse.de>
Mon, 15 Nov 2021 11:06:29 +0000 (12:06 +0100)
Signed-off-by: Karthik Balan karthik.b82@samsung.com
Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
[dwagner: dropped nvme-ioctl.c changes, part of libnvme]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Documentation/nvme-lockdown.1 [new file with mode: 0644]
Documentation/nvme-lockdown.html [new file with mode: 0644]
Documentation/nvme-lockdown.txt [new file with mode: 0644]
completions/_nvme
completions/bash-nvme-completion.sh
nvme-builtin.h
nvme.c

diff --git a/Documentation/nvme-lockdown.1 b/Documentation/nvme-lockdown.1
new file mode 100644 (file)
index 0000000..0c93229
--- /dev/null
@@ -0,0 +1,75 @@
+'\" t
+.\"     Title: nvme-lockdown
+.\"    Author: [FIXME: author] [see http://docbook.sf.net/el/author]
+.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
+.\"      Date: 09/09/2021
+.\"    Manual: NVMe Manual
+.\"    Source: NVMe
+.\"  Language: English
+.\"
+.TH "NVME\-LOCKDOWN" "1" "09/09/2021" "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-lockdown \- Send an NVMe Lockdown command to prohibit or allow the execution of command
+.SH "SYNOPSIS"
+.sp
+.nf
+\fInvme\-lockdown\fR <device> [\-\-ofi=<ofi> | \-o <ofi>]
+                        [\-\-ifc=<ifc> | \-f <ifc>]
+                        [\-\-prhbt=<prhbt> | \-p <prhbt>]
+                        [\-\-scp=<scp> | \-s <scp>]
+                        [\-\-uuid=<UUID_Index> | \-U <UUID_Index>]
+.fi
+.SH "DESCRIPTION"
+.sp
+The Lockdown command is used to control the Command and Feature Lockdown capability which configures the prohibition or allowance of execution of the specified commandor Set Features command targeting a specific Feature Identifier\&.
+.SH "OPTIONS"
+.PP
+\-\-ofi=<ofi>, \-o <ofi>
+.RS 4
+Opcode or Feature Identifier(OFI) specifies the command opcode or Set Features Feature Identifier identified by the Scope field\&.
+.RE
+.PP
+\-\-ifc=<ifc>, \-f <ifc>
+.RS 4
+Interface (INF) field identifies the interfaces affected by this command\&.
+.RE
+.PP
+\-\-prhbt=<prhbt>, \-p <prhbt>
+.RS 4
+Prohibit(PRHBT) bit specifies whether to prohibit or allow the command opcode or Set Features Feature Identifier specified by this command\&.
+.RE
+.PP
+\-\-scp=<scp>, \-s <scp>
+.RS 4
+Scope(SCP) field specifies the contents of the Opcode or Feature Identifier field\&.
+.RE
+.PP
+\-\-uuid=<UUID_Index>, \-U <UUID_Index>
+.RS 4
+UUID Index \- If this field is set to a non\-zerovalue, then the value of this field is the index of a UUID in the UUIDList that is used by the command\&. If this field is cleared to 0h,then no UUID index is specified\&.
+.RE
+.SH "EXAMPLES"
+.sp
+No examples yet\&.
+.SH "NVME"
+.sp
+Part of the nvme\-user suite
diff --git a/Documentation/nvme-lockdown.html b/Documentation/nvme-lockdown.html
new file mode 100644 (file)
index 0000000..cb2e86c
--- /dev/null
@@ -0,0 +1,857 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"\r
+    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\r
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\r
+<head>\r
+<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />\r
+<meta name="generator" content="AsciiDoc 8.6.10" />\r
+<title>nvme-lockdown(1)</title>\r
+<style type="text/css">\r
+/* Shared CSS for AsciiDoc xhtml11 and html5 backends */\r
+\r
+/* Default font. */\r
+body {\r
+  font-family: Georgia,serif;\r
+}\r
+\r
+/* Title font. */\r
+h1, h2, h3, h4, h5, h6,\r
+div.title, caption.title,\r
+thead, p.table.header,\r
+#toctitle,\r
+#author, #revnumber, #revdate, #revremark,\r
+#footer {\r
+  font-family: Arial,Helvetica,sans-serif;\r
+}\r
+\r
+body {\r
+  margin: 1em 5% 1em 5%;\r
+}\r
+\r
+a {\r
+  color: blue;\r
+  text-decoration: underline;\r
+}\r
+a:visited {\r
+  color: fuchsia;\r
+}\r
+\r
+em {\r
+  font-style: italic;\r
+  color: navy;\r
+}\r
+\r
+strong {\r
+  font-weight: bold;\r
+  color: #083194;\r
+}\r
+\r
+h1, h2, h3, h4, h5, h6 {\r
+  color: #527bbd;\r
+  margin-top: 1.2em;\r
+  margin-bottom: 0.5em;\r
+  line-height: 1.3;\r
+}\r
+\r
+h1, h2, h3 {\r
+  border-bottom: 2px solid silver;\r
+}\r
+h2 {\r
+  padding-top: 0.5em;\r
+}\r
+h3 {\r
+  float: left;\r
+}\r
+h3 + * {\r
+  clear: left;\r
+}\r
+h5 {\r
+  font-size: 1.0em;\r
+}\r
+\r
+div.sectionbody {\r
+  margin-left: 0;\r
+}\r
+\r
+hr {\r
+  border: 1px solid silver;\r
+}\r
+\r
+p {\r
+  margin-top: 0.5em;\r
+  margin-bottom: 0.5em;\r
+}\r
+\r
+ul, ol, li > p {\r
+  margin-top: 0;\r
+}\r
+ul > li     { color: #aaa; }\r
+ul > li > * { color: black; }\r
+\r
+.monospaced, code, pre {\r
+  font-family: "Courier New", Courier, monospace;\r
+  font-size: inherit;\r
+  color: navy;\r
+  padding: 0;\r
+  margin: 0;\r
+}\r
+pre {\r
+  white-space: pre-wrap;\r
+}\r
+\r
+#author {\r
+  color: #527bbd;\r
+  font-weight: bold;\r
+  font-size: 1.1em;\r
+}\r
+#email {\r
+}\r
+#revnumber, #revdate, #revremark {\r
+}\r
+\r
+#footer {\r
+  font-size: small;\r
+  border-top: 2px solid silver;\r
+  padding-top: 0.5em;\r
+  margin-top: 4.0em;\r
+}\r
+#footer-text {\r
+  float: left;\r
+  padding-bottom: 0.5em;\r
+}\r
+#footer-badges {\r
+  float: right;\r
+  padding-bottom: 0.5em;\r
+}\r
+\r
+#preamble {\r
+  margin-top: 1.5em;\r
+  margin-bottom: 1.5em;\r
+}\r
+div.imageblock, div.exampleblock, div.verseblock,\r
+div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,\r
+div.admonitionblock {\r
+  margin-top: 1.0em;\r
+  margin-bottom: 1.5em;\r
+}\r
+div.admonitionblock {\r
+  margin-top: 2.0em;\r
+  margin-bottom: 2.0em;\r
+  margin-right: 10%;\r
+  color: #606060;\r
+}\r
+\r
+div.content { /* Block element content. */\r
+  padding: 0;\r
+}\r
+\r
+/* Block element titles. */\r
+div.title, caption.title {\r
+  color: #527bbd;\r
+  font-weight: bold;\r
+  text-align: left;\r
+  margin-top: 1.0em;\r
+  margin-bottom: 0.5em;\r
+}\r
+div.title + * {\r
+  margin-top: 0;\r
+}\r
+\r
+td div.title:first-child {\r
+  margin-top: 0.0em;\r
+}\r
+div.content div.title:first-child {\r
+  margin-top: 0.0em;\r
+}\r
+div.content + div.title {\r
+  margin-top: 0.0em;\r
+}\r
+\r
+div.sidebarblock > div.content {\r
+  background: #ffffee;\r
+  border: 1px solid #dddddd;\r
+  border-left: 4px solid #f0f0f0;\r
+  padding: 0.5em;\r
+}\r
+\r
+div.listingblock > div.content {\r
+  border: 1px solid #dddddd;\r
+  border-left: 5px solid #f0f0f0;\r
+  background: #f8f8f8;\r
+  padding: 0.5em;\r
+}\r
+\r
+div.quoteblock, div.verseblock {\r
+  padding-left: 1.0em;\r
+  margin-left: 1.0em;\r
+  margin-right: 10%;\r
+  border-left: 5px solid #f0f0f0;\r
+  color: #888;\r
+}\r
+\r
+div.quoteblock > div.attribution {\r
+  padding-top: 0.5em;\r
+  text-align: right;\r
+}\r
+\r
+div.verseblock > pre.content {\r
+  font-family: inherit;\r
+  font-size: inherit;\r
+}\r
+div.verseblock > div.attribution {\r
+  padding-top: 0.75em;\r
+  text-align: left;\r
+}\r
+/* DEPRECATED: Pre version 8.2.7 verse style literal block. */\r
+div.verseblock + div.attribution {\r
+  text-align: left;\r
+}\r
+\r
+div.admonitionblock .icon {\r
+  vertical-align: top;\r
+  font-size: 1.1em;\r
+  font-weight: bold;\r
+  text-decoration: underline;\r
+  color: #527bbd;\r
+  padding-right: 0.5em;\r
+}\r
+div.admonitionblock td.content {\r
+  padding-left: 0.5em;\r
+  border-left: 3px solid #dddddd;\r
+}\r
+\r
+div.exampleblock > div.content {\r
+  border-left: 3px solid #dddddd;\r
+  padding-left: 0.5em;\r
+}\r
+\r
+div.imageblock div.content { padding-left: 0; }\r
+span.image img { border-style: none; vertical-align: text-bottom; }\r
+a.image:visited { color: white; }\r
+\r
+dl {\r
+  margin-top: 0.8em;\r
+  margin-bottom: 0.8em;\r
+}\r
+dt {\r
+  margin-top: 0.5em;\r
+  margin-bottom: 0;\r
+  font-style: normal;\r
+  color: navy;\r
+}\r
+dd > *:first-child {\r
+  margin-top: 0.1em;\r
+}\r
+\r
+ul, ol {\r
+    list-style-position: outside;\r
+}\r
+ol.arabic {\r
+  list-style-type: decimal;\r
+}\r
+ol.loweralpha {\r
+  list-style-type: lower-alpha;\r
+}\r
+ol.upperalpha {\r
+  list-style-type: upper-alpha;\r
+}\r
+ol.lowerroman {\r
+  list-style-type: lower-roman;\r
+}\r
+ol.upperroman {\r
+  list-style-type: upper-roman;\r
+}\r
+\r
+div.compact ul, div.compact ol,\r
+div.compact p, div.compact p,\r
+div.compact div, div.compact div {\r
+  margin-top: 0.1em;\r
+  margin-bottom: 0.1em;\r
+}\r
+\r
+tfoot {\r
+  font-weight: bold;\r
+}\r
+td > div.verse {\r
+  white-space: pre;\r
+}\r
+\r
+div.hdlist {\r
+  margin-top: 0.8em;\r
+  margin-bottom: 0.8em;\r
+}\r
+div.hdlist tr {\r
+  padding-bottom: 15px;\r
+}\r
+dt.hdlist1.strong, td.hdlist1.strong {\r
+  font-weight: bold;\r
+}\r
+td.hdlist1 {\r
+  vertical-align: top;\r
+  font-style: normal;\r
+  padding-right: 0.8em;\r
+  color: navy;\r
+}\r
+td.hdlist2 {\r
+  vertical-align: top;\r
+}\r
+div.hdlist.compact tr {\r
+  margin: 0;\r
+  padding-bottom: 0;\r
+}\r
+\r
+.comment {\r
+  background: yellow;\r
+}\r
+\r
+.footnote, .footnoteref {\r
+  font-size: 0.8em;\r
+}\r
+\r
+span.footnote, span.footnoteref {\r
+  vertical-align: super;\r
+}\r
+\r
+#footnotes {\r
+  margin: 20px 0 20px 0;\r
+  padding: 7px 0 0 0;\r
+}\r
+\r
+#footnotes div.footnote {\r
+  margin: 0 0 5px 0;\r
+}\r
+\r
+#footnotes hr {\r
+  border: none;\r
+  border-top: 1px solid silver;\r
+  height: 1px;\r
+  text-align: left;\r
+  margin-left: 0;\r
+  width: 20%;\r
+  min-width: 100px;\r
+}\r
+\r
+div.colist td {\r
+  padding-right: 0.5em;\r
+  padding-bottom: 0.3em;\r
+  vertical-align: top;\r
+}\r
+div.colist td img {\r
+  margin-top: 0.3em;\r
+}\r
+\r
+@media print {\r
+  #footer-badges { display: none; }\r
+}\r
+\r
+#toc {\r
+  margin-bottom: 2.5em;\r
+}\r
+\r
+#toctitle {\r
+  color: #527bbd;\r
+  font-size: 1.1em;\r
+  font-weight: bold;\r
+  margin-top: 1.0em;\r
+  margin-bottom: 0.1em;\r
+}\r
+\r
+div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {\r
+  margin-top: 0;\r
+  margin-bottom: 0;\r
+}\r
+div.toclevel2 {\r
+  margin-left: 2em;\r
+  font-size: 0.9em;\r
+}\r
+div.toclevel3 {\r
+  margin-left: 4em;\r
+  font-size: 0.9em;\r
+}\r
+div.toclevel4 {\r
+  margin-left: 6em;\r
+  font-size: 0.9em;\r
+}\r
+\r
+span.aqua { color: aqua; }\r
+span.black { color: black; }\r
+span.blue { color: blue; }\r
+span.fuchsia { color: fuchsia; }\r
+span.gray { color: gray; }\r
+span.green { color: green; }\r
+span.lime { color: lime; }\r
+span.maroon { color: maroon; }\r
+span.navy { color: navy; }\r
+span.olive { color: olive; }\r
+span.purple { color: purple; }\r
+span.red { color: red; }\r
+span.silver { color: silver; }\r
+span.teal { color: teal; }\r
+span.white { color: white; }\r
+span.yellow { color: yellow; }\r
+\r
+span.aqua-background { background: aqua; }\r
+span.black-background { background: black; }\r
+span.blue-background { background: blue; }\r
+span.fuchsia-background { background: fuchsia; }\r
+span.gray-background { background: gray; }\r
+span.green-background { background: green; }\r
+span.lime-background { background: lime; }\r
+span.maroon-background { background: maroon; }\r
+span.navy-background { background: navy; }\r
+span.olive-background { background: olive; }\r
+span.purple-background { background: purple; }\r
+span.red-background { background: red; }\r
+span.silver-background { background: silver; }\r
+span.teal-background { background: teal; }\r
+span.white-background { background: white; }\r
+span.yellow-background { background: yellow; }\r
+\r
+span.big { font-size: 2em; }\r
+span.small { font-size: 0.6em; }\r
+\r
+span.underline { text-decoration: underline; }\r
+span.overline { text-decoration: overline; }\r
+span.line-through { text-decoration: line-through; }\r
+\r
+div.unbreakable { page-break-inside: avoid; }\r
+\r
+\r
+/*\r
+ * xhtml11 specific\r
+ *\r
+ * */\r
+\r
+div.tableblock {\r
+  margin-top: 1.0em;\r
+  margin-bottom: 1.5em;\r
+}\r
+div.tableblock > table {\r
+  border: 3px solid #527bbd;\r
+}\r
+thead, p.table.header {\r
+  font-weight: bold;\r
+  color: #527bbd;\r
+}\r
+p.table {\r
+  margin-top: 0;\r
+}\r
+/* Because the table frame attribute is overriden by CSS in most browsers. */\r
+div.tableblock > table[frame="void"] {\r
+  border-style: none;\r
+}\r
+div.tableblock > table[frame="hsides"] {\r
+  border-left-style: none;\r
+  border-right-style: none;\r
+}\r
+div.tableblock > table[frame="vsides"] {\r
+  border-top-style: none;\r
+  border-bottom-style: none;\r
+}\r
+\r
+\r
+/*\r
+ * html5 specific\r
+ *\r
+ * */\r
+\r
+table.tableblock {\r
+  margin-top: 1.0em;\r
+  margin-bottom: 1.5em;\r
+}\r
+thead, p.tableblock.header {\r
+  font-weight: bold;\r
+  color: #527bbd;\r
+}\r
+p.tableblock {\r
+  margin-top: 0;\r
+}\r
+table.tableblock {\r
+  border-width: 3px;\r
+  border-spacing: 0px;\r
+  border-style: solid;\r
+  border-color: #527bbd;\r
+  border-collapse: collapse;\r
+}\r
+th.tableblock, td.tableblock {\r
+  border-width: 1px;\r
+  padding: 4px;\r
+  border-style: solid;\r
+  border-color: #527bbd;\r
+}\r
+\r
+table.tableblock.frame-topbot {\r
+  border-left-style: hidden;\r
+  border-right-style: hidden;\r
+}\r
+table.tableblock.frame-sides {\r
+  border-top-style: hidden;\r
+  border-bottom-style: hidden;\r
+}\r
+table.tableblock.frame-none {\r
+  border-style: hidden;\r
+}\r
+\r
+th.tableblock.halign-left, td.tableblock.halign-left {\r
+  text-align: left;\r
+}\r
+th.tableblock.halign-center, td.tableblock.halign-center {\r
+  text-align: center;\r
+}\r
+th.tableblock.halign-right, td.tableblock.halign-right {\r
+  text-align: right;\r
+}\r
+\r
+th.tableblock.valign-top, td.tableblock.valign-top {\r
+  vertical-align: top;\r
+}\r
+th.tableblock.valign-middle, td.tableblock.valign-middle {\r
+  vertical-align: middle;\r
+}\r
+th.tableblock.valign-bottom, td.tableblock.valign-bottom {\r
+  vertical-align: bottom;\r
+}\r
+\r
+\r
+/*\r
+ * manpage specific\r
+ *\r
+ * */\r
+\r
+body.manpage h1 {\r
+  padding-top: 0.5em;\r
+  padding-bottom: 0.5em;\r
+  border-top: 2px solid silver;\r
+  border-bottom: 2px solid silver;\r
+}\r
+body.manpage h2 {\r
+  border-style: none;\r
+}\r
+body.manpage div.sectionbody {\r
+  margin-left: 3em;\r
+}\r
+\r
+@media print {\r
+  body.manpage div#toc { display: none; }\r
+}\r
+\r
+\r
+</style>\r
+<script type="text/javascript">\r
+/*<![CDATA[*/\r
+var asciidoc = {  // Namespace.\r
+\r
+/////////////////////////////////////////////////////////////////////\r
+// Table Of Contents generator\r
+/////////////////////////////////////////////////////////////////////\r
+\r
+/* Author: Mihai Bazon, September 2002\r
+ * http://students.infoiasi.ro/~mishoo\r
+ *\r
+ * Table Of Content generator\r
+ * Version: 0.4\r
+ *\r
+ * Feel free to use this script under the terms of the GNU General Public\r
+ * License, as long as you do not remove or alter this notice.\r
+ */\r
+\r
+ /* modified by Troy D. Hanson, September 2006. License: GPL */\r
+ /* modified by Stuart Rackham, 2006, 2009. License: GPL */\r
+\r
+// toclevels = 1..4.\r
+toc: function (toclevels) {\r
+\r
+  function getText(el) {\r
+    var text = "";\r
+    for (var i = el.firstChild; i != null; i = i.nextSibling) {\r
+      if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.\r
+        text += i.data;\r
+      else if (i.firstChild != null)\r
+        text += getText(i);\r
+    }\r
+    return text;\r
+  }\r
+\r
+  function TocEntry(el, text, toclevel) {\r
+    this.element = el;\r
+    this.text = text;\r
+    this.toclevel = toclevel;\r
+  }\r
+\r
+  function tocEntries(el, toclevels) {\r
+    var result = new Array;\r
+    var re = new RegExp('[hH]([1-'+(toclevels+1)+'])');\r
+    // Function that scans the DOM tree for header elements (the DOM2\r
+    // nodeIterator API would be a better technique but not supported by all\r
+    // browsers).\r
+    var iterate = function (el) {\r
+      for (var i = el.firstChild; i != null; i = i.nextSibling) {\r
+        if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {\r
+          var mo = re.exec(i.tagName);\r
+          if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {\r
+            result[result.length] = new TocEntry(i, getText(i), mo[1]-1);\r
+          }\r
+          iterate(i);\r
+        }\r
+      }\r
+    }\r
+    iterate(el);\r
+    return result;\r
+  }\r
+\r
+  var toc = document.getElementById("toc");\r
+  if (!toc) {\r
+    return;\r
+  }\r
+\r
+  // Delete existing TOC entries in case we're reloading the TOC.\r
+  var tocEntriesToRemove = [];\r
+  var i;\r
+  for (i = 0; i < toc.childNodes.length; i++) {\r
+    var entry = toc.childNodes[i];\r
+    if (entry.nodeName.toLowerCase() == 'div'\r
+     && entry.getAttribute("class")\r
+     && entry.getAttribute("class").match(/^toclevel/))\r
+      tocEntriesToRemove.push(entry);\r
+  }\r
+  for (i = 0; i < tocEntriesToRemove.length; i++) {\r
+    toc.removeChild(tocEntriesToRemove[i]);\r
+  }\r
+\r
+  // Rebuild TOC entries.\r
+  var entries = tocEntries(document.getElementById("content"), toclevels);\r
+  for (var i = 0; i < entries.length; ++i) {\r
+    var entry = entries[i];\r
+    if (entry.element.id == "")\r
+      entry.element.id = "_toc_" + i;\r
+    var a = document.createElement("a");\r
+    a.href = "#" + entry.element.id;\r
+    a.appendChild(document.createTextNode(entry.text));\r
+    var div = document.createElement("div");\r
+    div.appendChild(a);\r
+    div.className = "toclevel" + entry.toclevel;\r
+    toc.appendChild(div);\r
+  }\r
+  if (entries.length == 0)\r
+    toc.parentNode.removeChild(toc);\r
+},\r
+\r
+\r
+/////////////////////////////////////////////////////////////////////\r
+// Footnotes generator\r
+/////////////////////////////////////////////////////////////////////\r
+\r
+/* Based on footnote generation code from:\r
+ * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html\r
+ */\r
+\r
+footnotes: function () {\r
+  // Delete existing footnote entries in case we're reloading the footnodes.\r
+  var i;\r
+  var noteholder = document.getElementById("footnotes");\r
+  if (!noteholder) {\r
+    return;\r
+  }\r
+  var entriesToRemove = [];\r
+  for (i = 0; i < noteholder.childNodes.length; i++) {\r
+    var entry = noteholder.childNodes[i];\r
+    if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote")\r
+      entriesToRemove.push(entry);\r
+  }\r
+  for (i = 0; i < entriesToRemove.length; i++) {\r
+    noteholder.removeChild(entriesToRemove[i]);\r
+  }\r
+\r
+  // Rebuild footnote entries.\r
+  var cont = document.getElementById("content");\r
+  var spans = cont.getElementsByTagName("span");\r
+  var refs = {};\r
+  var n = 0;\r
+  for (i=0; i<spans.length; i++) {\r
+    if (spans[i].className == "footnote") {\r
+      n++;\r
+      var note = spans[i].getAttribute("data-note");\r
+      if (!note) {\r
+        // Use [\s\S] in place of . so multi-line matches work.\r
+        // Because JavaScript has no s (dotall) regex flag.\r
+        note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];\r
+        spans[i].innerHTML =\r
+          "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +\r
+          "' title='View footnote' class='footnote'>" + n + "</a>]";\r
+        spans[i].setAttribute("data-note", note);\r
+      }\r
+      noteholder.innerHTML +=\r
+        "<div class='footnote' id='_footnote_" + n + "'>" +\r
+        "<a href='#_footnoteref_" + n + "' title='Return to text'>" +\r
+        n + "</a>. " + note + "</div>";\r
+      var id =spans[i].getAttribute("id");\r
+      if (id != null) refs["#"+id] = n;\r
+    }\r
+  }\r
+  if (n == 0)\r
+    noteholder.parentNode.removeChild(noteholder);\r
+  else {\r
+    // Process footnoterefs.\r
+    for (i=0; i<spans.length; i++) {\r
+      if (spans[i].className == "footnoteref") {\r
+        var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");\r
+        href = href.match(/#.*/)[0];  // Because IE return full URL.\r
+        n = refs[href];\r
+        spans[i].innerHTML =\r
+          "[<a href='#_footnote_" + n +\r
+          "' title='View footnote' class='footnote'>" + n + "</a>]";\r
+      }\r
+    }\r
+  }\r
+},\r
+\r
+install: function(toclevels) {\r
+  var timerId;\r
+\r
+  function reinstall() {\r
+    asciidoc.footnotes();\r
+    if (toclevels) {\r
+      asciidoc.toc(toclevels);\r
+    }\r
+  }\r
+\r
+  function reinstallAndRemoveTimer() {\r
+    clearInterval(timerId);\r
+    reinstall();\r
+  }\r
+\r
+  timerId = setInterval(reinstall, 500);\r
+  if (document.addEventListener)\r
+    document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);\r
+  else\r
+    window.onload = reinstallAndRemoveTimer;\r
+}\r
+\r
+}\r
+asciidoc.install();\r
+/*]]>*/\r
+</script>\r
+</head>\r
+<body class="manpage">\r
+<div id="header">\r
+<h1>\r
+nvme-lockdown(1) Manual Page\r
+</h1>\r
+<h2>NAME</h2>\r
+<div class="sectionbody">\r
+<p>nvme-lockdown -\r
+   Send an NVMe Lockdown command to prohibit or allow the execution of command\r
+</p>\r
+</div>\r
+</div>\r
+<div id="content">\r
+<div class="sect1">\r
+<h2 id="_synopsis">SYNOPSIS</h2>\r
+<div class="sectionbody">\r
+<div class="verseblock">\r
+<pre class="content"><em>nvme-lockdown</em> &lt;device&gt; [--ofi=&lt;ofi&gt; | -o &lt;ofi&gt;]\r
+                        [--ifc=&lt;ifc&gt; | -f &lt;ifc&gt;]\r
+                        [--prhbt=&lt;prhbt&gt; | -p &lt;prhbt&gt;]\r
+                        [--scp=&lt;scp&gt; | -s &lt;scp&gt;]\r
+                        [--uuid=&lt;UUID_Index&gt; | -U &lt;UUID_Index&gt;]</pre>\r
+<div class="attribution">\r
+</div></div>\r
+</div>\r
+</div>\r
+<div class="sect1">\r
+<h2 id="_description">DESCRIPTION</h2>\r
+<div class="sectionbody">\r
+<div class="paragraph"><p>The Lockdown command is used to control the Command and Feature Lockdown\r
+capability which configures the prohibition or allowance of execution of the\r
+specified commandor Set Features command targeting a specific Feature\r
+Identifier.</p></div>\r
+</div>\r
+</div>\r
+<div class="sect1">\r
+<h2 id="_options">OPTIONS</h2>\r
+<div class="sectionbody">\r
+<div class="dlist"><dl>\r
+<dt class="hdlist1">\r
+--ofi=&lt;ofi&gt;\r
+</dt>\r
+<dt class="hdlist1">\r
+-o &lt;ofi&gt;\r
+</dt>\r
+<dd>\r
+<p>\r
+        Opcode or Feature Identifier(OFI) specifies the command opcode or Set\r
+        Features Feature Identifier identified by the Scope field.\r
+</p>\r
+</dd>\r
+<dt class="hdlist1">\r
+--ifc=&lt;ifc&gt;\r
+</dt>\r
+<dt class="hdlist1">\r
+-f &lt;ifc&gt;\r
+</dt>\r
+<dd>\r
+<p>\r
+        Interface (INF) field identifies the interfaces affected by this command.\r
+</p>\r
+</dd>\r
+<dt class="hdlist1">\r
+--prhbt=&lt;prhbt&gt;\r
+</dt>\r
+<dt class="hdlist1">\r
+-p &lt;prhbt&gt;\r
+</dt>\r
+<dd>\r
+<p>\r
+        Prohibit(PRHBT) bit specifies whether to prohibit or allow the command\r
+        opcode or Set Features Feature Identifier specified by this command.\r
+</p>\r
+</dd>\r
+<dt class="hdlist1">\r
+--scp=&lt;scp&gt;\r
+</dt>\r
+<dt class="hdlist1">\r
+-s &lt;scp&gt;\r
+</dt>\r
+<dd>\r
+<p>\r
+        Scope(SCP) field specifies the contents of the Opcode or Feature Identifier field.\r
+</p>\r
+</dd>\r
+<dt class="hdlist1">\r
+--uuid=&lt;UUID_Index&gt;\r
+</dt>\r
+<dt class="hdlist1">\r
+-U &lt;UUID_Index&gt;\r
+</dt>\r
+<dd>\r
+<p>\r
+        UUID Index - If this field is set to a non-zerovalue, then the value of\r
+        this field is the index of a UUID in the UUIDList that is used by the command.\r
+        If this field is cleared to 0h,then no UUID index is specified.\r
+</p>\r
+</dd>\r
+</dl></div>\r
+</div>\r
+</div>\r
+<div class="sect1">\r
+<h2 id="_examples">EXAMPLES</h2>\r
+<div class="sectionbody">\r
+<div class="paragraph"><p>No examples yet.</p></div>\r
+</div>\r
+</div>\r
+<div class="sect1">\r
+<h2 id="_nvme">NVME</h2>\r
+<div class="sectionbody">\r
+<div class="paragraph"><p>Part of the nvme-user suite</p></div>\r
+</div>\r
+</div>\r
+</div>\r
+<div id="footnotes"><hr /></div>\r
+<div id="footer">\r
+<div id="footer-text">\r
+Last updated\r
+ 2021-09-09 14:46:45 IST\r
+</div>\r
+</div>\r
+</body>\r
+</html>\r
diff --git a/Documentation/nvme-lockdown.txt b/Documentation/nvme-lockdown.txt
new file mode 100644 (file)
index 0000000..e9ba86c
--- /dev/null
@@ -0,0 +1,56 @@
+nvme-lockdown(1)
+================
+
+NAME
+----
+nvme-lockdown - Send an NVMe Lockdown command to prohibit or allow the execution of command
+
+SYNOPSIS
+--------
+[verse]
+'nvme-lockdown' <device> [--ofi=<ofi> | -o <ofi>]
+                       [--ifc=<ifc> | -f <ifc>]
+                       [--prhbt=<prhbt> | -p <prhbt>]
+                       [--scp=<scp> | -s <scp>]
+                       [--uuid=<UUID_Index> | -U <UUID_Index>]
+
+DESCRIPTION
+-----------
+The Lockdown command is used to control the Command and Feature Lockdown
+capability which configures the prohibition or allowance of execution of the
+specified commandor Set Features command targeting a specific Feature
+Identifier.
+
+OPTIONS
+-------
+--ofi=<ofi>::
+-o <ofi>::
+       Opcode or Feature Identifier(OFI) specifies the command opcode or Set
+       Features Feature Identifier identified by the Scope field.
+
+--ifc=<ifc>::
+-f <ifc>::
+       Interface (INF) field identifies the interfaces affected by this command.
+
+--prhbt=<prhbt>::
+-p <prhbt>::
+       Prohibit(PRHBT) bit specifies whether to prohibit or allow the command
+       opcode or Set Features Feature Identifier specified by this command.
+
+--scp=<scp>::
+-s <scp>::
+       Scope(SCP) field specifies the contents of the Opcode or Feature Identifier field.
+
+--uuid=<UUID_Index>::
+-U <UUID_Index>::
+       UUID Index - If this field is set to a non-zerovalue, then the value of
+       this field is the index of a UUID in the UUIDList that is used by the command.
+       If this field is cleared to 0h,then no UUID index is specified.
+
+EXAMPLES
+--------
+No examples yet.
+
+NVME
+----
+Part of the nvme-user suite
\ No newline at end of file
index 17fc994c5e42e042277a66f2ba8d7c59a6c31107..3ce202fdccaf1f0792fbbae3a10aa579f876879b 100644 (file)
@@ -54,6 +54,7 @@ _nvme () {
        'boot-part-log: retrieve boot partition log'
        'fid-support-effects-log:retrieve fid support and effects log'
        'supported-log-pages: retrieve support log pages details'
+       'lockdown:submit a lockdown command'
        'help:print brief descriptions of all nvme commands'
        )
 
@@ -394,6 +395,24 @@ _nvme () {
                        _arguments '*:: :->subcmds'
                        _describe -t commands "nvme get-feature options" _getf
                        ;;
+               (lockdown)
+                       local _lockdown
+                       _lockdown=(
+                       /dev/nvme':supply a device to use (required)'
+                       --ofi=': Opcode or Feature Identifier(OFI) (required)'
+                       -o':alias of --ofi'
+                       --ifc=':Interface (INF) field Information (required)'
+                       -f':alias of --ifc'
+                       --prhbt=':Prohibit(PRHBT) bit field (required)'
+                       -p':alias of --prhbt'
+                       --scp=':Scope(SCP) field for identifying opcode or feature id (required)'
+                       -s':alias of --scp'
+                       --uuid=':UUID Index field required aligned with Scope'
+                       -U':alias of --uuid'
+                       )
+                       _arguments '*:: :->subcmds'
+                       _describe -t commands "nvme lockdown options" _lockdown
+                       ;;
                (set-feature)
                        local _setf
                        _setf=(
@@ -871,7 +890,7 @@ _nvme () {
                             resv-report flush compare read write copy show-regs persistent-event-log
                                 pred-lat-event-agg-log nvm-id-ctrl endurance-event-agg-log lba-status-log
                                 resv-notif-log capacity-mgmt id-domain boot-part-log fid-support-effects-log
-                                supported-log-pages
+                                supported-log-pages lockdown
                           )
                        _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
index ba219e355e35e4eed1c10a2b33ae12e228691980..76088d5b871eab2927ea5a6b0947a4dc569c1742 100644 (file)
@@ -101,7 +101,7 @@ _cmds="list list-subsys id-ctrl id-ns \
        connect disconnect disconnect-all gen-hostnqn \
        show-hostnqn dir-receive dir-send virt-mgmt \
        rpmb boot-part-log fid-support-effects-log \
-       supported-log-pages"
+       supported-log-pages lockdown"
 
 # Add plugins:
 for plugin in "${!_plugin_subcmds[@]}"; do
@@ -301,6 +301,10 @@ nvme_list_opts () {
                opts+=" --operation= -f --element-id= -i --cap-lower= -l \
                                --cap-upper= -u"
                        ;;
+               "lockdown")
+               opts+=" --ofi= -O --ifc= -F --prhbt= -P \
+                       -scp= -S --uuid -U"
+                       ;;
                "admin-passthru")
                opts+=" --opcode= -o --flags= -f --prefil= -p --rsvd= -R \
                        --namespace-id= -n --data-len= -l --metadata-len= -m \
@@ -584,7 +588,7 @@ plugin_amzn_opts () {
                "id-ctrl")
                opts+=" --raw-binary -b --human-readable -H \
                        --vendor-specific -v --output-format= -o"
-                       ;;      
+                       ;;
                "help")
                opts+=$NO_OPTS
                        ;;
@@ -636,7 +640,7 @@ plugin_lnvm_opts () {
                opts+=" --target-name= -n"
                        ;;
                "factory")
-               opts+=" --device-name= -d --erase-only-marked -e 
+               opts+=" --device-name= -d --erase-only-marked -e
                        --clear-host-side-blks -s --clear-bb-blks -b"
                        ;;
                "diag-bbtbl")
@@ -848,7 +852,7 @@ plugin_huawei_opts () {
                "id-ctrl")
                opts+=" --raw-binary -b --human-readable -H \
                        --vendor-specific -v --output-format= -o"
-                       ;;      
+                       ;;
                "help")
                opts+=$NO_OPTS
                        ;;
@@ -890,7 +894,7 @@ plugin_toshiba_opts () {
                opts+=$NO_OPTS
                        ;;
        esac
-       
+
        COMPREPLY+=( $( compgen $compargs -W "$opts" -- $cur ) )
 
        return 0
@@ -1093,12 +1097,12 @@ plugin_shannon_opts () {
                "id-ctrl")
                opts+=" --raw-binary -b --human-readable -H \
                        --vendor-specific -v --output-format= -o"
-                       ;;      
+                       ;;
                "help")
                opts+=$NO_OPTS
                        ;;
        esac
-       
+
        COMPREPLY+=( $( compgen $compargs -W "$opts" -- $cur ) )
 
        return 0
@@ -1124,12 +1128,12 @@ plugin_dera_opts () {
        case "$1" in
                "smart-log-add")
                opts+=$NO_OPTS
-                       ;;      
+                       ;;
                "help")
                opts+=$NO_OPTS
                        ;;
        esac
-       
+
        COMPREPLY+=( $( compgen $compargs -W "$opts" -- $cur ) )
 
        return 0
@@ -1178,7 +1182,7 @@ plugin_sfx_opts () {
                opts+=$NO_OPTS
                        ;;
        esac
-       
+
        COMPREPLY+=( $( compgen $compargs -W "$opts" -- $cur ) )
 
        return 0
@@ -1324,7 +1328,7 @@ plugin_nvidia_opts () {
                "id-ctrl")
                opts+=" --raw-binary -b --human-readable -H \
                        --vendor-specific -v --output-format= -o"
-                       ;;      
+                       ;;
                "help")
                opts+=$NO_OPTS
                        ;;
@@ -1355,12 +1359,12 @@ plugin_ymtc_opts () {
        case "$1" in
                "smart-log-add")
                opts+=" --namespace-id= -n --raw-binary -b"
-                       ;;      
+                       ;;
                "help")
                opts+=NO_OPTS
                        ;;
        esac
-       
+
        COMPREPLY+=( $( compgen $compargs -W "$opts" -- $cur ) )
 
        return 0
index a495488610adb4e727f49593f14eeaf5078c50eb..72f64cf2f4eef717b471c7dd994173279700e88e 100644 (file)
@@ -91,6 +91,7 @@ COMMAND_LIST(
        ENTRY("virt-mgmt", "Manage Flexible Resources between Primary and Secondary Controller ", virtual_mgmt)
        ENTRY("rpmb", "Replay Protection Memory Block commands", rpmb_cmd)
        ENTRY("fid-support-effects-log", "Submit Feature ID Support and Effects Log, Return result", get_fid_support_effects_log)
+       ENTRY("lockdown", "Submit a Lockdown command,return result", lockdown_cmd)
 );
 
 #endif
diff --git a/nvme.c b/nvme.c
index 2c91362f48f20ce7e0a1dc5948c7dfb0ba21dff7..9f3aaab43461674bcb33bbd8e53c0488b27cfefb 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -6170,6 +6170,100 @@ static int rpmb_cmd(int argc, char **argv, struct command *cmd, struct plugin *p
        return rpmb_cmd_option(argc, argv, cmd, plugin);
 }
 
+static int lockdown_cmd(int argc, char **argv, struct command *cmd, struct plugin *plugin)
+{
+       const char *desc = "The Lockdown command is used to control the "\
+               "Command and Feature Lockdown capability which configures the "\
+               "prohibition or allowance of execution of the specified command "\
+               "or Set Features command targeting a specific Feature Identifier.";
+       const char *ofi_desc = "Opcode or Feature Identifier(OFI) "\
+               "specifies the command opcode or Set Features Feature Identifier "\
+               "identified by the Scope field.";
+       const char *ifc_desc = "[0-3] Interface (INF) field identifies the "\
+               "interfaces affected by this command.";
+       const char *prhbt_desc = "[0-1]Prohibit(PRHBT) bit specifies whether "\
+               "to prohibit or allow the command opcode or Set Features Feature "\
+               "Identifier specified by this command.";
+       const char *scp_desc = "[0-15]Scope(SCP) field specifies the contents "\
+               "of the Opcode or Feature Identifier field.";
+       const char *uuid_desc = "UUID Index - If this field is set to a non-zero "\
+               "value, then the value of this field is the index of a UUID in the UUID "\
+               "List that is used by the command.If this field is cleared to 0h,"\
+               "then no UUID index is specified";
+
+       int fd, err = -1;
+
+       struct config {
+               __u8    ofi;
+               __u8    ifc;
+               __u8    prhbt;
+               __u8    scp;
+               __u8    uuid;
+       };
+
+       struct config cfg = {
+               .ofi = 0,
+               .ifc = 0,
+               .prhbt = 0,
+               .scp = 0,
+               .uuid = 0,
+       };
+
+       OPT_ARGS(opts) = {
+               OPT_BYTE("ofi",         'o', &cfg.ofi,          ofi_desc),
+               OPT_BYTE("ifc",         'f', &cfg.ifc,      ifc_desc),
+               OPT_BYTE("prhbt",       'p', &cfg.prhbt,    prhbt_desc),
+               OPT_BYTE("scp",         's', &cfg.scp,      scp_desc),
+               OPT_BYTE("uuid",        'U', &cfg.uuid,     uuid_desc),
+               OPT_END()
+       };
+
+       err = fd = parse_and_open(argc, argv, desc, opts);
+       if (fd < 0)
+               goto ret;
+
+       /* check for input arguement limit */
+       if (cfg.ifc > 3) {
+               fprintf(stderr, "invalid interface settings:%d\n", cfg.ifc);
+               errno = EINVAL;
+               err = -1;
+               goto close_fd;
+       }
+       if (cfg.prhbt > 1) {
+               fprintf(stderr, "invalid prohibit settings:%d\n", cfg.prhbt);
+               errno = EINVAL;
+               err = -1;
+               goto close_fd;
+       }
+       if (cfg.scp > 15) {
+               fprintf(stderr, "invalid scope settings:%d\n", cfg.scp);
+               errno = EINVAL;
+               err = -1;
+               goto close_fd;
+       }
+       if (cfg.uuid > 127) {
+               fprintf(stderr, "invalid UUID index settings:%d\n", cfg.uuid);
+               errno = EINVAL;
+               err = -1;
+               goto close_fd;
+       }
+
+       err = nvme_lockdown(fd, cfg.scp,cfg.prhbt,cfg.ifc,cfg.ofi,
+                       cfg.uuid);
+
+       if (err < 0)
+               perror("lockdown");
+       else if (err > 0)
+               nvme_show_status(err);
+       else
+               printf("Lockdown Command is Successful\n");
+
+close_fd:
+       close(fd);
+ret:
+       return nvme_status_to_errno(err, false);
+}
+
 static int passthru(int argc, char **argv, bool admin,
                const char *desc, struct command *cmd)
 {