1.\" 2.\" SPDX-License-Identifier: BSD-2-Clause 3.\" 4.\" Copyright (c) 2017 Netflix, Inc. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26.\" SUCH DAMAGE. 27.\" 28.Dd October 2, 2025 29.Dt NDA 4 30.Os 31.Sh NAME 32.Nm nda 33.Nd NVMe Direct Access device driver 34.Sh SYNOPSIS 35.Cd device nvme 36.Cd device scbus 37.Sh DESCRIPTION 38The 39.Nm 40driver provides support for direct access devices, implementing the 41.Tn NVMe 42command protocol, that are attached to the system through a host adapter 43supported by the CAM subsystem. 44.Sh HARDWARE 45The 46.Nm 47driver supports NVMe 48.Pq Non-Volatile Memory Express 49storage devices connected via PCIe or over NVMF 50.Pq NVMe over Fabric 51via the CAM subsystem. 52.Sh SYSCTL VARIABLES 53The following variables are available as both 54.Xr sysctl 8 55variables and 56.Xr loader 8 57tunables: 58.Bl -tag -width 12 59.It Va hw.nvme.use_nvd 60The 61.Xr nvme 4 62driver will create 63.Nm 64device nodes for block storage when set to 0. 65Create 66.Xr nvd 4 67device nodes for block storage when set to 1. 68See 69.Xr nvd 4 70when set to 1. 71.It Va kern.cam.nda.nvd_compat 72When set to 1, 73.Xr nvd 4 74aliases will be created for all 75.Nm 76devices, including partitions and other 77.Xr geom 4 78providers that take their names from the disk's name. 79.Xr nvd 4 80devices will not, however, be reported in the 81.Va kern.disks 82.Xr sysctl 8 . 83.It Va kern.cam.nda.sort_io_queue 84This variable determines whether the software queued entries are 85sorted in LBA order or not. 86Sorting is almost always a waste of time. 87The default is to not sort. 88.It Va kern.cam.nda.enable_biospeedup 89This variable determines if the 90.Nm 91devices participate in the speedup protocol. 92When the device participates in the speedup, then when the upper layers 93send a 94.Va BIO_SPEEDUP , 95all current 96.Va BIO_DELETE 97requests not yet sent to the hardware are completed successfully immediate 98without sending them to the hardware. 99Used in low disk space scenarios when the filesystem encounters 100a critical shortage and needs blocks immediately. 101Since trims have maximum benefit when the LBA is unused for a long time, 102skipping the trim when space is needed for immediate writes results in little to 103no excess wear. 104When participation is disabled, 105.Va BIO_SPEEDUP 106requests are ignored. 107.It Va kern.cam.nda.max_trim 108The maximum number of LBA ranges to be collected together for each DSM trims 109send to the hardware. 110Defaults to 256, which is the maximum number of ranges the protocol supports. 111Sometimes poor trim performance can be mitigated by limiting the number of 112ranges sent to the device. 113This value must be between 1 and 256 inclusive. 114.El 115.Pp 116The following report per-device settings, and are read-only unless 117otherwise indicated. 118Replace 119.Va N 120with the device unit number. 121.Bl -tag -width 12 122.It Va kern.cam.nda.N.rotating 123This variable reports whether the storage volume is spinning or 124flash. 125Its value is hard coded to 0 indicating flash. 126.It Va kern.cam.nda.N.unmapped_io 127This variable reports whether the 128.Nm 129driver accepts unmapped I/O for this unit. 130.It Va kern.cam.nda.N.flags 131This variable reports the current flags. 132.Bl -tag -width 12 133.It Va OPEN 134The device is open. 135.It Va DIRTY 136Set when a write to the drive is scheduled. 137Cleared after flush commands. 138.It Va SCTX_INIT 139Internal flag set after 140.Xr sysctl 8 141nodes have been created. 142.El 143.It Va kern.cam.nda.N.sort_io_queue 144Same as the 145.Va kern.cam.nda.sort_io_queue 146tunable. 147.It Va kern.cam.nda.N.trim_ticks 148Writable. 149When greater than zero, hold trims for up to this many ticks before sending 150to the drive. 151Sometimes waiting a little bit to collect more trims to send at one time 152improves trim performance. 153When 0, no delaying of trims are done. 154.It Va kern.cam.nda.N.trim_goal 155Writable. 156When delaying a bit to collect multiple trims, send the accumulated DSM TRIM to 157the drive. 158.It Va kern.cam.nda.N.trim_lbas 159Total number of LBAs that have been trimmed. 160.It Va kern.cam.nda.N.trim_ranges 161Total number of LBA ranges that have been trimmed. 162.It Va kern.cam.nda.N.trim_count 163Total number of trims sent to the hardware. 164.It Va kern.cam.nda.N.deletes 165Total number of 166.Va BIO_DELETE 167requests queued to the device. 168.El 169.Sh NAMESPACE MAPPING 170Each 171.Xr nvme 4 172drive has one or more namespaces associated with it. 173One instance of the 174.Nm 175driver will be created for each of the namespaces on 176the drive. 177All the 178.Nm 179nodes for a 180.Xr nvme 4 181device are at target 0. 182However, the namespace ID maps to the CAM lun, as reported 183in kernel messages and in the 184.Va devlist 185sub command of 186.Xr camcontrol 8 . 187.Pp 188Namespaces are managed with the 189.Va ns 190sub command of 191.Xr nvmecontrol 8 . 192Not all drives support namespace management, 193but all drives support at least one namespace. 194Device nodes for 195.Nm 196will be created and destroyed dynamically as 197namespaces are activated or detached. 198.Sh FILES 199.Bl -tag -width ".Pa /dev/nda*" -compact 200.It Pa /dev/nda* 201NVMe storage device nodes 202.El 203.Sh SEE ALSO 204.Xr cam 4 , 205.Xr geom 4 , 206.Xr nvd 4 , 207.Xr nvme 4 , 208.Xr gpart 8 209.Sh HISTORY 210The 211.Nm 212driver first appeared in 213.Fx 12.0 . 214.Sh AUTHORS 215.An Warner Losh Aq Mt imp@FreeBSD.org 216