aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/nvmf/host
Commit message (Collapse)AuthorAgeFilesLines
* nvmf: Add support for DIOCGIDENTJohn Baldwin2025-11-172-0/+6
| | | | | | | | This mirrors commit 6d0001d44490becdd20d627ce663c72a30b9aac3 but for nvmf(4). Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D53339
* nvmf: Honor any data transfer limit imposed by the transportJohn Baldwin2025-11-103-3/+17
| | | | | | | If the transport has a data transfer limit, restrict I/O transfers to the largest multiple of MPS that fits within the limit. Sponsored by: Chelsio Communications
* nvmf: Auto-reconnect periodically after a disconnectJohn Baldwin2025-07-092-5/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use a timer in the nvmf(4) driver to periodically trigger a devctl "RECONNECT" notification. A trigger in the /etc/devd/nvmf.conf file invokes "nvmecontrol reconnect nvmeX" upon each notification. This differs from iSCSI which uses a dedicated daemon (iscsid(8)) to wait inside a custom ioctl for an iSCSI initiator event to occur, but I think this design might be simpler. Similar to nvme-cli, the interval between reconnection attempts is specified in seconds by the --reconnect-delay argument to the connect and reconnect commands. Note that nvme-cli uses -c for short letter of this command, but that was already taken so nvmecontrol uses -r. The default is 10 seconds to match Linux. In addition, a second timeout can be used to force a full detach of a disconnected the nvmeX device after the controller loss timeout expires. The timeout for this is specified in seconds by the --ctrl-loss-tmo/-l options (identical to nvme-cli). The default is 600 seconds. Either of these timers can be disabled by setting the timer to 0. In that case, the associated action (devctl notifications or full detach) will not occur after a disconnect. Note that this adds a dedicated taskqueue for nvmf tasks instead of using taskqueue_thread as the controller loss task could deadlock waiting for the completion of other tasks queued to taskqueue_thread. (Specifically, tearing down the CAM SIM can trigger destroy_dev_sched_cb() and waits for the callback to run, but the callback is scheduled to run in a task on taskqueue_thread. Possibly, destroy_dev_sched should be using a dedicated taskqueue.) Reviewed by: imp (earlier version) Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D50222
* newbus: replace leftover device unit wildcardsAhmad Khalifa2025-06-211-1/+1
| | | | | | Reviewed by: imp, jhb Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D50913
* machine/stdarg.h -> sys/stdarg.hBrooks Davis2025-06-111-1/+1
| | | | | | | | | | | | | Switch to using sys/stdarg.h for va_list type and va_* builtins. Make an attempt to insert the include in a sensible place. Where style(9) was followed this is easy, where it was ignored, aim for the first block of sys/*.h headers and don't get too fussy or try to fix other style bugs. Reviewed by: imp Exp-run by: antoine (PR 286274) Pull Request: https://github.com/freebsd/freebsd-src/pull/1595
* nvmf: Add NVMF_CONNECTION_STATUS ioctlJohn Baldwin2025-01-312-0/+27
| | | | | | | | | This returns an nvlist indicating if a Fabrics host is connected and the time of the most recent disconnection. Reviewed by: imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D48219
* nvme/nvmf: Add NVME_GET_CONTROLLER_DATA ioctl to fetch cached cdataJohn Baldwin2025-01-311-0/+3
| | | | | | | | | | | Both nvme and nvmf cache a copy of the controller's identify data in the softc. Add an ioctl to fetch this copy of the cdata. This is primarily useful for allowing commands like 'nvmecontrol devlist' to work against a disconnected Fabrics host. Reviewed by: dab, imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D48218
* nvmf: Refactor reconnection supportJohn Baldwin2025-01-242-20/+36
| | | | | | | | | | | | | | | | | | | | | | | | Save more data associated with a new association including the network address of the remote controller. This permits reconnecting an association without providing the address or other details. To use this new mode, provide only an existing device ID to nvmecontrol's reconnect command. An address can still be provided to request a different address or other different settings for the new association. The saved data includes an entire Discovery Log page entry to aim to be compatible with other transports in the future. When a remote controller is connected to via a Discovery Log page entry (nvmecontrol connect-all), the raw entry is used. When a remote controller is connected to via an explicit address, an entry is synthesized from the parameters. Note that this is a pseudo-ABI break for the ioctls used by nvmf(4) in that the nvlists for handoff and reconnect now use a slightly different set of elements. Since this is only present in main I did not bother implementing compatability shims. Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D48214
* nvmf: Defer the post-sync shutdown handler to SHUTDOWN_PRI_LASTJohn Baldwin2025-01-131-1/+13
| | | | | | | | | | | | | | | | nda(4) has its own shutdown handler that runs at SHUTDOWN_PRI_DEFAULT that calls ndaflush() that could run after the nvmf handler. Instead, give a the flush a chance to run before the graceful shutdown of the controller. While here, be a bit more defensive in the post-sync case and shutdown the consumers (sim and /dev/nvmeXnY devices) before destroying the queue pairs so that if any requests are submitted after the post-sync handler they fail gracefully instead of trying to use a destroyed queue pair. Reported by: Sony Arpita Das <sonyarpitad@chelsio.com> Sponsored by: Chelsio Communications
* nvmf: Switch several ioctls to using nvlistsJohn Baldwin2024-12-304-106/+136
| | | | | | | | | | | | | | | | | For requests that handoff queues from userspace to the kernel as well as the request to fetch reconnect parameters from the kernel, switch from using flat structures to nvlists. In particular, this will permit adding support for additional transports in the future without breaking the ABI of the structures. Note that this is an ABI break for the ioctls used by nvmf(4) and nvmft(4). Since this is only present in main I did not bother implementing compatability shims. Inspired by: imp (suggestion on a different review) Reviewed by: imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D48230
* nvmf: Track SQ flow controlJohn Baldwin2024-11-111-5/+28
| | | | | | | | | | This isn't really needed since the host driver never submits more commands to a queue than it can hold, but I noticed that the recently-added SQ head and tail sysctl nodes were not updating. This fixes that and also uses these values to assert that there we never submit a command while a queue pair is full. Sponsored by: Chelsio Communications
* nvmf: Schedule requests across multiple I/O queuesJohn Baldwin2024-11-112-5/+5
| | | | | | | | | | | Similar to nvme(4), use the current CPU to select which I/O queue to use. The assignment in nvmf_attach() had to be moved down since sc->num_io_queues is initialized in nvmf_establish_connection(). Note that nvmecontrol(8) still defaults to using a single I/O queue for an association. Sponsored by: Chelsio Communications
* nvmf: Fix an off by one error when scanning active namespace IDsJohn Baldwin2024-11-051-2/+2
| | | | | | | | | | | | | | | The active namespace list query fetches namespaces greater than the passed in namespace ID, not greater than or equal to the passed in namespace ID. Thus, a multi-page request should start with the last namespace ID from the previous page, not that ID plus 1. While here, make use of NVME_GLOBAL_NAMESPACE_TAG instead of a magic number to handle the edge case that the last namespace ID in a page is the largest valid namespace ID. Reviewed by: chuck Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D47393
* nvmf: Deregister the post_sync eventhandler correctly during detachJohn Baldwin2024-11-021-1/+1
| | | | | | | Previously the handler was removed from the wrong eventhandler list. Fixes: f46d4971b5af nvmf: Handle shutdowns more gracefully Sponsored by: Chelsio Communications
* nvmf: Add sysctl nodes for each queue pairJohn Baldwin2024-11-023-4/+53
| | | | | | | These report the queue size, queue head, queue tail, and the number of commands submitted. Sponsored by: Chelsio Communications
* nvmf: Fail pass through commands while a controller is not associatedJohn Baldwin2024-10-171-0/+9
| | | | | | | | | | | | | | Previously this just dereferenced NULL qp pointers and panicked. Instead, use a shared lock on the connection lock to protect access to the qp pointers and allocate a request. If the controller is not associated, fail the request with ECONNABORTED. Possibly this should be honoring kern.nvmf.fail_on_disconnection and block waiting for a reconnect request while disconnected if that tunable is false. Reported by: Suhas Lokesha <suhas@chelsio.com> Sponsored by: Chelsio Communications
* nvmf: Narrow scope of sim lock in nvmf_sim_ioJohn Baldwin2024-09-261-2/+1
| | | | | | | | | | | | | | nvmf_submit_request() handles races with concurrent queue pair destruction (or the queue pair being destroyed between nvmf_allocate_request and nvmf_submit_request), so the lock is not needed here. This avoids holding the lock across transport-specific logic such as queueing mbufs for PDUs to a socket buffer, etc. Holding the lock across nvmf_allocate_request() ensures that the queue pair pointers in the softc are still valid as shutdown attempts will block on the lock before destroying the queue pairs. Sponsored by: Chelsio Communications
* nvmf: Always use xpt_done instead of xpt_done_directJohn Baldwin2024-09-261-1/+1
| | | | | | | | | | | | The last reference on a pending I/O request might be held by an mbuf in the socket buffer. When this mbuf is freed, the I/O request is completed which triggers completion of the CCB. However, this can occur with locks held (e.g. with so_snd locked when the mbuf is freed by sbdrop()) raising a LOR between so_snd and the CAM device lock. Instead, defer CCB completion processing to a thread where locks are not held. Sponsored by: Chelsio Communications
* nvmf: Use device_set_descf()Mark Johnston2024-06-161-3/+1
| | | | | | No functional change intended. MFC after: 1 week
* nvmf: Handle shutdowns more gracefullyJohn Baldwin2024-06-054-7/+114
| | | | | | | | | | | | | If an association is disconnected during a clean shutdown, abort all pending and future I/O requests with an error to avoid hangs either due to filesystem unmounts or a stuck GEOM event. If an association is connected during a clean shutdown, gracefully disconnect from the remote controller and close the open queues. Reviewed by: imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D45462
* nvmf: Permit failing I/O requests while disconnectedJohn Baldwin2024-06-054-7/+36
| | | | | | | | | | | | | Add a kern.nvmf.fail_on_disconnection sysctl similar to the kern.iscsi.fail_on_disconnection sysctl. This causes pending I/O requests to fail with an error if an association is disconnected instead of requeueing to be retried once the association is reconnected. As with iSCSI, the default is to queue and retry operations. Reviewed by: imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D45308
* nvmf: Rescan namespaces after reconnectingJohn Baldwin2024-06-051-0/+2
| | | | | | | | | | While a host was disconnected from a remote controller, namespaces might have been added, removed, or altered properties. Rescan the namespaces after reconnecting to detect any such changes. Reviewed by: imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D45461
* nvmf: Rescan all namespaces if the changed NS log page is too largeJohn Baldwin2024-06-053-1/+51
| | | | | | | | Previously this just punted with a warning message. Reviewed by: imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D45460
* nvmf: Factor out most of nvmf_rescan_ns into a helper routineJohn Baldwin2024-06-051-22/+30
| | | | | | | | | This function accepts a namespace ID and associated namespace data from IDENTIFY and takes care of updating nvmeXnY and ndaZ. Reviewed by: imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D45459
* nvmf: Refactor nvmf_add_namespaces to be more genericJohn Baldwin2024-06-051-27/+47
| | | | | | | | | | | Rename to nvmf_scan_active_namespaces and accept an additional callback function and callback argument. The callback is invoked on each active namespace enumerated by the active namespace list from the IDENTIFY command. Reviewed by: imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D45458
* nvmf: Pass const pointers to namespace data to nvmf_*_nsJohn Baldwin2024-06-052-4/+5
| | | | | | Reviewed by: imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D45457
* nvme: Change namespace device nameChuck Tuffli2024-06-011-2/+6
| | | | | | | | | | | | | | Changes the device name for NVMe and NVMe-oF namespaces from using "ns" to "n" to be more compatible with other operating systems. For example, a device which was previously /dev/nvme0ns1 is now /dev/nvme0n1. Preserves the existing functionality by creating alias from nvmeXnY to nvmeXnsY. Reviewed by: imp MFC after: 1 month Relnotes: yes Differential Revision: https://reviews.freebsd.org/D45414
* nvme/f: Use strlcpy instead of strncpy + manual string terminationJohn Baldwin2024-05-132-4/+2
| | | | | | Reviewed by: dab, imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D45153
* nvmf: Use strlcpy instead of strncpy to ensure terminationJohn Baldwin2024-05-101-1/+1
| | | | | | Reported by: Coverity Scan CID: 1545054 Sponsored by: Chelsio Communications
* nvmf: The in-kernel NVMe over Fabrics hostJohn Baldwin2024-05-028-0/+2968
This is the client (initiator in SCSI terms) for NVMe over Fabrics. Userland is responsible for creating a set of queue pairs and then handing them off via an ioctl to this driver, e.g. via the 'connect' command from nvmecontrol(8). An nvmeX new-bus device is created at the top-level to represent the remote controller similar to PCI nvmeX devices for PCI-express controllers. As with nvme(4), namespace devices named /dev/nvmeXnsY are created and pass through commands can be submitted to either the namespace devices or the controller device. For example, 'nvmecontrol identify nvmeX' works for a remote Fabrics controller the same as for a PCI-express controller. nvmf exports remote namespaces via nda(4) devices using the new NVMF CAM transport. nvmf does not support nvd(4), only nda(4). Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D44714