drivers/nvme/host/nvme.h
Source file repositories/reference/linux-study-clean/drivers/nvme/host/nvme.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/nvme/host/nvme.h- Extension
.h- Size
- 36555 bytes
- Lines
- 1305
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/nvme.hlinux/cdev.hlinux/pci.hlinux/kref.hlinux/blk-mq.hlinux/sed-opal.hlinux/fault-inject.hlinux/rcupdate.hlinux/wait.hlinux/t10-pi.hlinux/ratelimit_types.htrace/events/block.h
Detected Declarations
struct nvme_requeststruct nvme_fault_injectstruct nvme_ctrlstruct nvme_subsystemstruct nvme_ns_idsstruct nvme_ns_headstruct nvme_nsstruct nvme_ctrl_opsstruct nvme_zone_infoenum nvme_quirksenum nvme_ctrl_stateenum nvme_ctrl_flagsenum nvme_iopolicyenum nvme_ns_featuresfunction nvme_req_qidfunction nvme_ctrl_statefunction nvme_ns_head_multipathfunction nvme_ns_has_pifunction nvme_get_virt_boundaryfunction nvme_cidfunction nvme_strlenfunction nvme_print_device_infofunction nvme_fault_inject_initfunction nvme_reset_subsystemfunction nvme_sect_to_lbafunction nvme_lba_to_sectfunction nvme_bytes_to_numdfunction from0basedfunction nvme_is_ana_errorfunction nvme_is_path_errorfunction nvme_try_complete_reqfunction nvme_get_ctrlfunction nvme_put_ctrlfunction nvme_is_aen_reqfunction nvme_state_terminalfunction nvme_complete_batchfunction rq_list_for_eachfunction nvme_req_opfunction nvme_check_readyfunction nvme_is_unique_nsidfunction nvme_ctrl_use_anafunction nvme_trace_bio_completefunction nvme_disk_is_ns_headfunction nvme_mpath_queue_if_no_pathfunction nvme_ctrl_use_anafunction nvme_failover_reqfunction nvme_mpath_add_diskfunction nvme_mpath_revalidate_paths
Annotated Snippet
const struct blk_mq_ops *ops, unsigned int cmd_size);
void nvme_remove_admin_tag_set(struct nvme_ctrl *ctrl);
int nvme_alloc_io_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,
const struct blk_mq_ops *ops, unsigned int nr_maps,
unsigned int cmd_size);
void nvme_remove_io_tag_set(struct nvme_ctrl *ctrl);
void nvme_remove_namespaces(struct nvme_ctrl *ctrl);
void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status,
volatile union nvme_result *res);
void nvme_quiesce_io_queues(struct nvme_ctrl *ctrl);
void nvme_unquiesce_io_queues(struct nvme_ctrl *ctrl);
void nvme_quiesce_admin_queue(struct nvme_ctrl *ctrl);
void nvme_unquiesce_admin_queue(struct nvme_ctrl *ctrl);
void nvme_mark_namespaces_dead(struct nvme_ctrl *ctrl);
void nvme_sync_queues(struct nvme_ctrl *ctrl);
void nvme_sync_io_queues(struct nvme_ctrl *ctrl);
void nvme_unfreeze(struct nvme_ctrl *ctrl);
void nvme_wait_freeze(struct nvme_ctrl *ctrl);
int nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl);
void nvme_start_freeze(struct nvme_ctrl *ctrl);
static inline enum req_op nvme_req_op(struct nvme_command *cmd)
{
return nvme_is_write(cmd) ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN;
}
#define NVME_QID_ANY -1
void nvme_init_request(struct request *req, struct nvme_command *cmd);
void nvme_cleanup_cmd(struct request *req);
blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req);
blk_status_t nvme_fail_nonready_command(struct nvme_ctrl *ctrl,
struct request *req);
bool __nvme_check_ready(struct nvme_ctrl *ctrl, struct request *rq,
bool queue_live, enum nvme_ctrl_state state);
static inline bool nvme_check_ready(struct nvme_ctrl *ctrl, struct request *rq,
bool queue_live)
{
enum nvme_ctrl_state state = nvme_ctrl_state(ctrl);
if (likely(state == NVME_CTRL_LIVE))
return true;
if (ctrl->ops->flags & NVME_F_FABRICS && state == NVME_CTRL_DELETING)
return queue_live;
return __nvme_check_ready(ctrl, rq, queue_live, state);
}
/*
* NSID shall be unique for all shared namespaces, or if at least one of the
* following conditions is met:
* 1. Namespace Management is supported by the controller
* 2. ANA is supported by the controller
* 3. NVM Set are supported by the controller
*
* In other case, private namespace are not required to report a unique NSID.
*/
static inline bool nvme_is_unique_nsid(struct nvme_ctrl *ctrl,
struct nvme_ns_head *head)
{
return head->shared ||
(ctrl->oacs & NVME_CTRL_OACS_NS_MNGT_SUPP) ||
(ctrl->subsys->cmic & NVME_CTRL_CMIC_ANA) ||
(ctrl->ctratt & NVME_CTRL_CTRATT_NVM_SETS);
}
/*
* Flags for __nvme_submit_sync_cmd()
*/
typedef __u32 __bitwise nvme_submit_flags_t;
enum {
/* Insert request at the head of the queue */
NVME_SUBMIT_AT_HEAD = (__force nvme_submit_flags_t)(1 << 0),
/* Set BLK_MQ_REQ_NOWAIT when allocating request */
NVME_SUBMIT_NOWAIT = (__force nvme_submit_flags_t)(1 << 1),
/* Set BLK_MQ_REQ_RESERVED when allocating request */
NVME_SUBMIT_RESERVED = (__force nvme_submit_flags_t)(1 << 2),
/* Retry command when NVME_STATUS_DNR is not set in the result */
NVME_SUBMIT_RETRY = (__force nvme_submit_flags_t)(1 << 3),
};
int nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
void *buf, unsigned bufflen);
int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
union nvme_result *result, void *buffer, unsigned bufflen,
int qid, nvme_submit_flags_t flags);
int nvme_set_features(struct nvme_ctrl *dev, unsigned int fid,
Annotation
- Immediate include surface: `linux/nvme.h`, `linux/cdev.h`, `linux/pci.h`, `linux/kref.h`, `linux/blk-mq.h`, `linux/sed-opal.h`, `linux/fault-inject.h`, `linux/rcupdate.h`.
- Detected declarations: `struct nvme_request`, `struct nvme_fault_inject`, `struct nvme_ctrl`, `struct nvme_subsystem`, `struct nvme_ns_ids`, `struct nvme_ns_head`, `struct nvme_ns`, `struct nvme_ctrl_ops`, `struct nvme_zone_info`, `enum nvme_quirks`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.