]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sbin/nvmecontrol/nvmecontrol.8
Import DTS files for arm, arm64, riscv from Linux 5.8
[FreeBSD/FreeBSD.git] / sbin / nvmecontrol / nvmecontrol.8
1 .\"
2 .\" Copyright (c) 2020 Warner Losh <imp@FreeBSD.org>
3 .\" Copyright (c) 2018-2019 Alexander Motin <mav@FreeBSD.org>
4 .\" Copyright (c) 2012 Intel Corporation
5 .\" All rights reserved.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\"    notice, this list of conditions, and the following disclaimer,
12 .\"    without modification.
13 .\" 2. Redistributions in binary form must reproduce at minimum a disclaimer
14 .\"    substantially similar to the "NO WARRANTY" disclaimer below
15 .\"    ("Disclaimer") and any redistribution must be conditioned upon
16 .\"    including a substantially similar Disclaimer requirement for further
17 .\"    binary redistribution.
18 .\"
19 .\" NO WARRANTY
20 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
23 .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 .\" HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 .\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 .\" POSSIBILITY OF SUCH DAMAGES.
31 .\"
32 .\" nvmecontrol man page.
33 .\"
34 .\" Author: Jim Harris <jimharris@FreeBSD.org>
35 .\"
36 .\" $FreeBSD$
37 .\"
38 .Dd April 30, 2020
39 .Dt NVMECONTROL 8
40 .Os
41 .Sh NAME
42 .Nm nvmecontrol
43 .Nd NVM Express control utility
44 .Sh SYNOPSIS
45 .Nm
46 .Ic devlist
47 .Nm
48 .Ic identify
49 .Op Fl v
50 .Op Fl x
51 .Op Fl n Ar nsid
52 .Aq Ar device-id | Ar namespace-id
53 .Nm
54 .Ic perftest
55 .Aq Fl n Ar num_threads
56 .Aq Fl o Ar read|write
57 .Op Fl p
58 .Aq Fl s Ar size_in_bytes
59 .Aq Fl t Ar time_in_sec
60 .Aq Ar namespace-id
61 .Nm
62 .Ic reset
63 .Aq Ar device-id
64 .Nm
65 .Ic logpage
66 .Aq Fl p Ar page_id
67 .Op Fl x
68 .Op Fl v Ar vendor-string
69 .Op Fl b
70 .Op Fl f Ar LSP
71 .Op Fl i Ar LSI
72 .Op Fl r
73 .Aq Ar device-id | Ar namespace-id
74 .Nm
75 .Ic ns active
76 .Aq Ar device-id
77 .Nm
78 .Ic ns allocated
79 .Aq Ar device-id
80 .Nm
81 .Ic ns attach
82 .Aq Fl n Ar nsid
83 .Aq Fl c Ar cntid
84 .Aq Ar device-id
85 .Nm
86 .Ic ns attached
87 .Aq Fl n Ar nsid
88 .Aq Ar device-id
89 .Nm
90 .Ic ns controllers
91 .Aq Ar device-id
92 .Nm
93 .Ic ns create
94 .Aq Fl s Ar nsze
95 .Op Fl c Ar ncap
96 .Op Fl f Ar lbaf
97 .Op Fl m Ar mset
98 .Op Fl n Ar nmic
99 .Op Fl p Ar pi
100 .Op Fl l Ar pil
101 .Op Fl L Ar flbas
102 .Op Fl d Ar dps
103 .Aq Ar device-id
104 .Nm
105 .Ic ns delete
106 .Aq Fl n Ar nsid
107 .Aq Ar device-id
108 .Nm
109 .Ic ns detach
110 .Aq Fl n Ar nsid
111 .Aq Fl c Ar cntid
112 .Aq Ar device-id
113 .Nm
114 .Ic ns identify
115 .Op Fl v
116 .Op Fl x
117 .Aq Fl n Ar nsid
118 .Aq Ar device-id
119 .Nm
120 .Ic nsid
121 .Aq Ar device-id | Ar namespace-id
122 .Nm
123 .Ic resv acquire
124 .Aq Fl c Ar crkey
125 .Op Fl p Ar prkey
126 .Aq Fl t Ar rtype
127 .Aq Fl a Ar racqa
128 .Aq Ar namespace-id
129 .Nm
130 .Ic resv register
131 .Op Fl c Ar crkey
132 .Aq Fl k Ar nrkey
133 .Aq Fl r Ar rrega
134 .Op Fl i Ar iekey
135 .Op Fl p Ar cptpl
136 .Aq Ar namespace-id
137 .Nm
138 .Ic resv release
139 .Aq Fl c Ar crkey
140 .Aq Fl t Ar rtype
141 .Aq Fl a Ar rrela
142 .Aq Ar namespace-id
143 .Nm
144 .Ic resv report
145 .Op Fl e
146 .Op Fl v
147 .Op Fl x
148 .Aq Ar namespace-id
149 .Nm
150 .Ic firmware
151 .Op Fl s Ar slot
152 .Op Fl f Ar path_to_firmware
153 .Op Fl a
154 .Aq Ar device-id
155 .Nm
156 .Ic format
157 .Op Fl f Ar fmt
158 .Op Fl m Ar mset
159 .Op Fl o Ar pi
160 .Op Fl l Ar pil
161 .Op Fl E
162 .Op Fl C
163 .Aq Ar device-id | Ar namespace-id
164 .Nm
165 .Ic sanitize
166 .Aq Fl a Ar sanact
167 .Op Fl c Ar owpass
168 .Op Fl d
169 .Op Fl p Ar ovrpat
170 .Op Fl r
171 .Op Fl I
172 .Op Fl U
173 .Aq Ar device-id
174 .Nm
175 .Ic power
176 .Op Fl l
177 .Op Fl p power_state
178 .Op Fl w workload_hint
179 .Nm
180 .Ic wdc cap-diag
181 .Op Fl o path_template
182 .Aq Ar device-id
183 .Nm
184 .Ic wdc drive-log
185 .Op Fl o path_template
186 .Aq Ar device-id
187 .Nm
188 .Ic wdc get-crash-dump
189 .Op Fl o path_template
190 .Aq Ar device-id
191 .\" .Nm
192 .\" .Ic wdc purge
193 .\" .Aq device-id
194 .\" .Nm
195 .\" .Ic wdc purge-monitor
196 .\" .Aq device-id
197 .Nm
198 .Ic admin-passthru
199 .Op args
200 .Aq Ar device-id
201 .Nm
202 .Ic io-passthru
203 .Op args
204 .Aq Ar namespace-id
205 .Sh DESCRIPTION
206 NVM Express (NVMe) is a storage protocol standard, for SSDs and other
207 high-speed storage devices over PCI Express.
208 .Pp
209 .Ss identify
210 The identify commands reports information from the drive's
211 .Dv IDENTIFY_CONTROLLER
212 if a
213 .Ar device-id
214 is specified.
215 It reports
216 .Dv IDENTIFY_NAMESPACE
217 data if a
218 .Ar namespace-id
219 is specified.
220 When used with disk names, the
221 .Dv IDENTIFY_NAMESPACE
222 data is reported, unless the namespace
223 .Ar nsid
224 is overridden with the
225 .Fl n
226 flag.
227 Then that namespace's data is reported, if it exists.
228 The command accepts the following parameters:
229 .Bl -tag -width 6n
230 .It Fl n
231 The namespace
232 .Aq nsid
233 to use instead of the namespace associated with the device.
234 A
235 .Ar nsid
236 of
237 .Dq 0
238 is used to retrieve the
239 .Dv IDENTIFY_CONTROLLER
240 data associated with that drive.
241 .Ss logpage
242 The logpage command knows how to print log pages of various types.
243 It also knows about vendor specific log pages from hgst/wdc and intel.
244 Note that some vendors use the same log page numbers for different data.
245 .Pp
246 .Bl -tag -compact -width "Page 0x00"
247 .It Dv Page 0x01
248 Drive Error Log
249 .It Dv Page 0x02
250 Health/SMART Data
251 .It Dv Page 0x03
252 Firmware Information
253 .It Dv Page 0x04
254 Changed Namespace List
255 .It Dv Page 0x05
256 Commands Supported and Effects
257 .It Dv Page 0x80
258 Reservation Notification
259 .It Dv Page 0x81
260 Sanitize Status
261 .It Dv Page 0xc1
262 Advanced SMART information (WDC/HGST)
263 .It Dv Page 0xc1
264 Read latency stats (Intel)
265 .It Dv Page 0xc2
266 Wite latency stats (Intel)
267 .It Dv Page 0xc5
268 Temperature stats (Intel)
269 .It Dv Page 0xca
270 Advanced SMART information (Intel)
271 .El
272 .Pp
273 Specifying
274 .Fl v
275 .Ic help
276 will list all valid vendors and pages.
277 .Fl x
278 will print the page as hex.
279 .Fl b
280 will print the binary data for the page.
281 .Fl s
282 will set Log Specific Field.
283 .Fl i
284 will set Log Specific Identifier.
285 .Fl r
286 will set Retain Asynchronous Event.
287 .Ss ns
288 Various namespace management commands.
289 If namespace management is supported by device, allow list, create and delete
290 namespaces, list, attach and detach controllers to namespaces.
291 .Ss nsid
292 Reports the namespace id and controller device associated with the
293 .Aq Ar namespace-id
294 or
295 .Aq Ar device-id
296 argument.
297 .Ss resv acquire
298 Acquire or preempt namespace reservation, using specified parameters:
299 .Bl -tag -width 6n
300 .It Fl a
301 Acquire action:
302 .Bl -tag -compact -width 6n
303 .It Dv 0
304 Acquire
305 .It Dv 1
306 Preempt
307 .It Dv 2
308 Preempt and abort
309 .El
310 .It Fl c
311 Current reservation key.
312 .It Fl p
313 Preempt reservation key.
314 .It Fl t
315 Reservation type:
316 .Bl -tag -compact -width 6n
317 .It Dv 1
318 Write Exclusive
319 .It Dv 2
320 Exclusive Access
321 .It Dv 3
322 Write Exclusive - Registrants Only
323 .It Dv 4
324 Exclusive Access - Registrants Only
325 .It Dv 5
326 Write Exclusive - All Registrants
327 .It Dv 6
328 Exclusive Access - All Registrants
329 .El
330 .El
331 .Ss resv register
332 Register, unregister or replace reservation key, using specified parameters:
333 .Bl -tag -width 6n
334 .It Fl c
335 Current reservation key.
336 .It Fl k
337 New reservation key.
338 .It Fl r
339 Register action:
340 .Bl -tag -compact -width 6n
341 .It Dv 0
342 Register
343 .It Dv 1
344 Unregister
345 .It Dv 2
346 Replace
347 .El
348 .It Fl i
349 Ignore Existing Key
350 .It Fl p
351 Change Persist Through Power Loss State:
352 .Bl -tag -compact -width 6n
353 .It Dv 0
354 No change to PTPL state
355 .It Dv 2
356 Set PTPL state to â€˜0’.
357 Reservations are released and registrants are cleared on a power on.
358 .It Dv 3
359 Set PTPL state to â€˜1’.
360 Reservations and registrants persist across a power loss.
361 .El
362 .El
363 .Ss resv release
364 Release or clear reservation, using specified parameters:
365 .Bl -tag -width 6n
366 .It Fl c
367 Current reservation key.
368 .It Fl t
369 Reservation type.
370 .It Fl a
371 Release action:
372 .Bl -tag -compact -width 6n
373 .It Dv 0
374 Release
375 .It Dv 1
376 Clean
377 .El
378 .El
379 .Ss resv report
380 Print reservation status, using specified parameters:
381 .Bl -tag -width 6n
382 .It Fl x
383 Print reservation status in hex.
384 .It Fl e
385 Use Extended Data Structure.
386 .El
387 .Ss format
388 Format either specified namespace, or all namespaces of specified controller,
389 using specified parameters:
390 .Ar fmt
391 LBA Format,
392 .Ar mset
393 Metadata Settings,
394 .Ar pi
395 Protection Information,
396 .Ar pil
397 Protection Information Location.
398 When formatting specific namespace, existing values are used as defaults.
399 When formatting all namespaces, all parameters should be specified.
400 Some controllers may not support formatting or erasing specific or all
401 namespaces.
402 Option
403 .Fl E
404 enables User Data Erase during format.
405 Option
406 .Fl C
407 enables Cryptographic Erase during format.
408 .Ss sanitize
409 Sanitize NVM subsystem of specified controller,
410 using specified parameters:
411 .Bl -tag -width 6n
412 .It Fl a Ar operation
413 Specify the sanitize operation to perform.
414 .Bl -tag -width 16n
415 .It overwrite
416 Perform an overwrite operation by writing a user supplied
417 data pattern to the device one or more times.
418 The pattern is given by the
419 .Fl p
420 argument.
421 The number of times is given by the
422 .Fl c
423 argument.
424 .It block
425 Perform a block erase operation.
426 All the device's blocks are set to a vendor defined
427 value, typically zero.
428 .It crypto
429 Perform a cryptographic erase operation.
430 The encryption keys are changed to prevent the decryption
431 of the data.
432 .It exitfailure
433 Exits a previously failed sanitize operation.
434 A failed sanitize operation can only be exited if it was
435 run in the unrestricted completion mode, as provided by the
436 .Fl U
437 argument.
438 .El
439 .It Fl c Ar passes
440 The number of passes when performing an
441 .Sq overwrite
442 operation.
443 Valid values are between 1 and 16.
444 The default is 1.
445 .It Fl d
446 No Deallocate After Sanitize.
447 .It Fl I
448 When performing an
449 .Sq overwrite
450 operation, the pattern is inverted between consecutive passes.
451 .It Fl p Ar pattern
452 32 bits of pattern to use when performing an
453 .Sq overwrite
454 operation.
455 The pattern is repeated as needed to fill each block.
456 .It Fl U
457 Perform the sanitize in the unrestricted completion mode.
458 If the operation fails, it can later be exited with the
459 .Sq exitfailure
460 operation.
461 .It Fl r
462 Run in
463 .Dq report only
464 mode.
465 This will report status on a sanitize that is already running on the drive.
466 .El
467 .Ss wdc
468 The various wdc command retrieve log data from the wdc/hgst drives.
469 The
470 .Fl o
471 flag specifies a path template to use to output the files.
472 Each file takes the path template (which defaults to nothing), appends
473 the drive's serial number and the type of dump it is followed
474 by .bin.
475 These logs must be sent to the vendor for analysis.
476 This tool only provides a way to extract them.
477 .Ss passthru
478 The
479 .Dq admin-passthru
480 and
481 .Dq io-passthru
482 commands send NVMe commands to
483 either the administrative or the data part of the device.
484 These commands are expected to be compatible with nvme-cli.
485 Please see
486 .St The NVMe Standard
487 for details.
488 .Bl -tag -width 16n
489 .It Fl o -opcode Ar opcode
490 Opcode to send.
491 .It Fl 2 -cdw2 Ar value
492 32-bit value for CDW2.
493 .It Fl 3 -cdw3 Ar value
494 32-bit value for CDW3.
495 .It Fl 4 -cdw10 Ar value
496 32-bit value for CDW10.
497 .It Fl 5 -cdw11 Ar value
498 32-bit value for CDW11.
499 .It Fl 6 -cdw12 Ar value
500 32-bit value for CDW12.
501 .It Fl 7 -cdw13 Ar value
502 32-bit value for CDW13.
503 .It Fl 8 -cdw14 Ar value
504 32-bit value for CDW14.
505 .It Fl 9 -cdw15 Ar value
506 32-bit value for CDW15.
507 .It Fl l -data-len
508 Length of the data for I/O (bytes).
509 .It Fl m -metadata-len
510 Length of the metadata segment for command (bytes).
511 This is ignored and not implemented in
512 .Xr nvme 4 .
513 .It Fl f -flags
514 Nvme command flags.
515 .It Fl n -namespace-id
516 Namespace ID for command (Ignored).
517 .It Fl p -prefill
518 Value to prefill payload with.
519 .It Fl b -raw-binary
520 Output in binary format (otherwise a hex dump is produced).
521 .It Fl d -dry-run
522 Do not actually execute the command, but perform sanity checks on it.
523 .It Fl r -read
524 Command reads data from the device.
525 .It Fl s -show-command
526 Show all the command values on stdout.
527 .It Fl w -write
528 Command writes data to the device.
529 .El
530 Send arbitrary commands to the device.
531 Can be used to extract vendor specific logs.
532 Transfers to/from the device possible, but limited to
533 .Dv MAXPHYS
534 bytes.
535 Commands either read data or write it, but not both.
536 Commands needing metadata are not supported by the
537 .Xr nvme 4
538 drive.
539 .Sh DEVICE NAMES
540 Where
541 .Aq Ar namespace-id
542 is required, you can use either the
543 .Pa nvmeXnsY
544 device, or the disk device such as
545 .Pa ndaZ
546 or
547 .Pa nvdZ .
548 The leading
549 .Pa /dev/
550 is omitted.
551 Where
552 .Aq Ar device-id
553 is required, you can use either the
554 .Pa nvmeX
555 device, or the disk device such as
556 .Pa nda Z
557 or
558 .Pa nvdZ .
559 For commands that take an optional
560 .Aq nsid
561 you can use it to get information on other namespaces, or to query the
562 drive itself.
563 A
564 .Aq nsid
565 of
566 .Dq 0
567 means query the drive itself.
568 .Sh EXAMPLES
569 .Dl nvmecontrol devlist
570 .Pp
571 Display a list of NVMe controllers and namespaces along with their device nodes.
572 .Pp
573 .Dl nvmecontrol identify nvme0
574 .Dl nvmecontrol identify -n 0 nvd0
575 .Pp
576 Display a human-readable summary of the nvme0
577 .Dv IDENTIFY_CONTROLLER
578 data.
579 In this example, nvd0 is connected to nvme0.
580 .Pp
581 .Dl nvmecontrol identify -x -v nvme0ns1
582 .Dl nvmecontrol identify -x -v -n 1 nvme0
583 .Pp
584 Display an hexadecimal dump of the nvme0
585 .Dv IDENTIFY_NAMESPACE
586 data for namespace 1.
587 .Pp
588 .Dl nvmecontrol perftest -n 32 -o read -s 512 -t 30 nvme0ns1
589 .Pp
590 Run a performance test on nvme0ns1 using 32 kernel threads for 30 seconds.
591 Each thread will issue a single 512 byte read command.
592 Results are printed to stdout when 30 seconds expires.
593 .Pp
594 .Dl nvmecontrol reset nvme0
595 .Dl nvmecontrol reset nda4
596 .Pp
597 Perform a controller-level reset of the nvme0 controller.
598 In this example, nda4 is wired to nvme0.
599 .Pp
600 .Dl nvmecontrol logpage -p 1 nvme0
601 .Pp
602 Display a human-readable summary of the nvme0 controller's Error Information Log.
603 Log pages defined by the NVMe specification include Error Information Log (ID=1),
604 SMART/Health Information Log (ID=2), and Firmware Slot Log (ID=3).
605 .Pp
606 .Dl nvmecontrol logpage -p 0xc1 -v wdc nvme0
607 .Pp
608 Display a human-readable summary of the nvme0's wdc-specific advanced
609 SMART data.
610 .Pp
611 .Dl nvmecontrol logpage -p 1 -x nvme0
612 .Pp
613 Display a hexadecimal dump of the nvme0 controller's Error Information Log.
614 .Pp
615 .Dl nvmecontrol logpage -p 0xcb -b nvme0 > /tmp/page-cb.bin
616 .Pp
617 Print the contents of vendor specific page 0xcb as binary data on
618 standard out.
619 Redirect it to a temporary file.
620 .Pp
621 .Dl nvmecontrol firmware -s 2 -f /tmp/nvme_firmware nvme0
622 .Pp
623 Download the firmware image contained in "/tmp/nvme_firmware" to slot 2 of the
624 nvme0 controller, but do not activate the image.
625 .Pp
626 .Dl nvmecontrol firmware -s 4 -a nvme0
627 .Pp
628 Activate the firmware in slot 4 of the nvme0 controller on the next reset.
629 .Pp
630 .Dl nvmecontrol firmware -s 7 -f /tmp/nvme_firmware -a nvme0
631 .Pp
632 Download the firmware image contained in "/tmp/nvme_firmware" to slot 7 of the
633 nvme0 controller and activate it on the next reset.
634 .Pp
635 .Dl nvmecontrol power -l nvme0
636 .Pp
637 List all the current power modes.
638 .Pp
639 .Dl nvmecontrol power -p 3 nvme0
640 .Pp
641 Set the current power mode.
642 .Pp
643 .Dl nvmecontrol power nvme0
644 .Pp
645 Get the current power mode.
646 .Pp
647 .Dl nvmecontrol identify -n 0 nda0
648 .Pp
649 Identify the drive data associated with the
650 .Pa nda0
651 device.
652 The corresponding
653 .Pa nvmeX
654 devices is used automatically.
655 .Pp
656 .Dl nvmecontrol identify nda0
657 .Pp
658 Get the namespace parameters associated with the
659 .Pa nda0
660 device.
661 The corresponding
662 .Pa nvmeXnsY
663 device is used automatically.
664 .Sh DYNAMIC LOADING
665 The directories
666 .Pa /lib/nvmecontrol
667 and
668 .Pa /usr/local/lib/nvmecontrol
669 are scanned for any .so files.
670 These files are loaded.
671 The members of the
672 .Va top
673 linker set are added to the top-level commands.
674 The members of the
675 .Va logpage
676 linker set are added to the logpage parsers.
677 .Sh HISTORY
678 The
679 .Nm
680 utility appeared in
681 .Fx 9.2 .
682 .Sh AUTHORS
683 .An -nosplit
684 .Nm
685 was developed by Intel and originally written by
686 .An Jim Harris Aq Mt jimharris@FreeBSD.org .
687 .Pp
688 This man page was written by
689 .An Jim Harris Aq Mt jimharris@FreeBSD.org .