drivers/nvme/host/fabrics.c
Source file repositories/reference/linux-study-clean/drivers/nvme/host/fabrics.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nvme/host/fabrics.c- Extension
.c- Size
- 40425 bytes
- Lines
- 1558
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/miscdevice.hlinux/module.hlinux/mutex.hlinux/parser.hlinux/seq_file.hnvme.hfabrics.hlinux/nvme-keyring.h
Detected Declarations
function nvmf_host_destroyfunction nvmf_host_putfunction nvmf_get_addressfunction nvmf_reg_read32function nvmf_reg_read64function nvmf_reg_write32function nvmf_subsystem_resetfunction nvmf_log_connect_errorfunction nvmf_connect_cmd_prepfunction nvmf_connect_admin_queuefunction nvmf_connect_io_queuefunction nvmf_should_reconnectfunction nvmf_register_transportfunction nvmf_unregister_transportfunction list_for_each_entryfunction nvmf_parse_optionsfunction nvmf_set_io_queuesfunction nvmf_map_queuesfunction nvmf_check_required_optsfunction nvmf_ip_options_matchfunction nvmf_check_allowed_optsfunction nvmf_free_optionsfunction nvmf_create_ctrlfunction nvmf_dev_writefunction __nvmf_concat_opt_tokensfunction nvmf_dev_showfunction nvmf_dev_openfunction nvmf_dev_releasefunction nvmf_initfunction nvmf_exitmodule init nvmf_initexport nvmf_get_addressexport nvmf_reg_read32export nvmf_reg_read64export nvmf_reg_write32export nvmf_subsystem_resetexport nvmf_connect_admin_queueexport nvmf_connect_io_queueexport nvmf_should_reconnectexport nvmf_register_transportexport nvmf_unregister_transportexport nvmf_set_io_queuesexport nvmf_map_queuesexport nvmf_ip_options_matchexport nvmf_free_options
Annotated Snippet
static const struct file_operations nvmf_dev_fops = {
.owner = THIS_MODULE,
.write = nvmf_dev_write,
.read = seq_read,
.open = nvmf_dev_open,
.release = nvmf_dev_release,
};
static struct miscdevice nvmf_misc = {
.minor = MISC_DYNAMIC_MINOR,
.name = "nvme-fabrics",
.fops = &nvmf_dev_fops,
};
static int __init nvmf_init(void)
{
int ret;
nvmf_default_host = nvmf_host_default();
if (!nvmf_default_host)
return -ENOMEM;
ret = class_register(&nvmf_class);
if (ret) {
pr_err("couldn't register class nvme-fabrics\n");
goto out_free_host;
}
nvmf_device =
device_create(&nvmf_class, NULL, MKDEV(0, 0), NULL, "ctl");
if (IS_ERR(nvmf_device)) {
pr_err("couldn't create nvme-fabrics device!\n");
ret = PTR_ERR(nvmf_device);
goto out_destroy_class;
}
ret = misc_register(&nvmf_misc);
if (ret) {
pr_err("couldn't register misc device: %d\n", ret);
goto out_destroy_device;
}
return 0;
out_destroy_device:
device_destroy(&nvmf_class, MKDEV(0, 0));
out_destroy_class:
class_unregister(&nvmf_class);
out_free_host:
nvmf_host_put(nvmf_default_host);
return ret;
}
static void __exit nvmf_exit(void)
{
misc_deregister(&nvmf_misc);
device_destroy(&nvmf_class, MKDEV(0, 0));
class_unregister(&nvmf_class);
nvmf_host_put(nvmf_default_host);
BUILD_BUG_ON(sizeof(struct nvmf_common_command) != 64);
BUILD_BUG_ON(sizeof(struct nvmf_connect_command) != 64);
BUILD_BUG_ON(sizeof(struct nvmf_property_get_command) != 64);
BUILD_BUG_ON(sizeof(struct nvmf_property_set_command) != 64);
BUILD_BUG_ON(sizeof(struct nvmf_auth_send_command) != 64);
BUILD_BUG_ON(sizeof(struct nvmf_auth_receive_command) != 64);
BUILD_BUG_ON(sizeof(struct nvmf_connect_data) != 1024);
BUILD_BUG_ON(sizeof(struct nvmf_auth_dhchap_negotiate_data) != 8);
BUILD_BUG_ON(sizeof(struct nvmf_auth_dhchap_challenge_data) != 16);
BUILD_BUG_ON(sizeof(struct nvmf_auth_dhchap_reply_data) != 16);
BUILD_BUG_ON(sizeof(struct nvmf_auth_dhchap_success1_data) != 16);
BUILD_BUG_ON(sizeof(struct nvmf_auth_dhchap_success2_data) != 16);
}
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("NVMe host fabrics library");
module_init(nvmf_init);
module_exit(nvmf_exit);
Annotation
- Immediate include surface: `linux/init.h`, `linux/miscdevice.h`, `linux/module.h`, `linux/mutex.h`, `linux/parser.h`, `linux/seq_file.h`, `nvme.h`, `fabrics.h`.
- Detected declarations: `function nvmf_host_destroy`, `function nvmf_host_put`, `function nvmf_get_address`, `function nvmf_reg_read32`, `function nvmf_reg_read64`, `function nvmf_reg_write32`, `function nvmf_subsystem_reset`, `function nvmf_log_connect_error`, `function nvmf_connect_cmd_prep`, `function nvmf_connect_admin_queue`.
- 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.
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.