drivers/scsi/fnic/fnic_main.c
Source file repositories/reference/linux-study-clean/drivers/scsi/fnic/fnic_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/fnic/fnic_main.c- Extension
.c- Size
- 40692 bytes
- Lines
- 1406
- Domain
- Driver Families
- Bucket
- drivers/scsi
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- 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.
- 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/module.hlinux/mempool.hlinux/string.hlinux/slab.hlinux/errno.hlinux/init.hlinux/pci.hlinux/skbuff.hlinux/interrupt.hlinux/irq.hlinux/spinlock.hlinux/workqueue.hlinux/if_ether.hscsi/fc/fc_fip.hscsi/scsi_host.hscsi/scsi_transport.hscsi/scsi_transport_fc.hscsi/scsi_tcq.hscsi/fc_frame.hvnic_dev.hvnic_intr.hvnic_stats.hfnic_io.hfnic.hfnic_fdls.hfdls_fc.h
Detected Declarations
function fnic_sdev_initfunction fnic_set_rport_dev_loss_tmofunction fnic_get_host_speedfunction fnic_dump_fchost_statsfunction fnic_reset_host_statsfunction fnic_log_q_errorfunction fnic_handle_link_eventfunction fnic_notify_setfunction fnic_notify_timerfunction fnic_notify_timer_startfunction fnic_dev_waitfunction fnic_cleanupfunction fnic_iounmapfunction fnic_set_vlanfunction fnic_scsi_initfunction fnic_free_ioreq_tables_mqfunction fnic_scsi_drv_initfunction fnic_mq_map_queues_cpusfunction fnic_probefunction fnic_removefunction fnic_init_modulefunction fnic_cleanup_modulemodule init fnic_init_module
Annotated Snippet
static struct pci_driver fnic_driver = {
.name = DRV_NAME,
.id_table = fnic_id_table,
.probe = fnic_probe,
.remove = fnic_remove,
};
static int __init fnic_init_module(void)
{
size_t len;
int err = 0;
printk(KERN_INFO PFX "%s, ver %s\n", DRV_DESCRIPTION, DRV_VERSION);
/* Create debugfs entries for fnic */
err = fnic_debugfs_init();
if (err < 0) {
printk(KERN_ERR PFX "Failed to create fnic directory "
"for tracing and stats logging\n");
fnic_debugfs_terminate();
}
/* Allocate memory for trace buffer */
err = fnic_trace_buf_init();
if (err < 0) {
printk(KERN_ERR PFX
"Trace buffer initialization Failed. "
"Fnic Tracing utility is disabled\n");
fnic_trace_free();
}
/* Allocate memory for fc trace buffer */
err = fnic_fc_trace_init();
if (err < 0) {
printk(KERN_ERR PFX "FC trace buffer initialization Failed "
"FC frame tracing utility is disabled\n");
fnic_fc_trace_free();
}
/* Create a cache for allocation of default size sgls */
len = sizeof(struct fnic_dflt_sgl_list);
fnic_sgl_cache[FNIC_SGL_CACHE_DFLT] = kmem_cache_create
("fnic_sgl_dflt", len + FNIC_SG_DESC_ALIGN, FNIC_SG_DESC_ALIGN,
SLAB_HWCACHE_ALIGN,
NULL);
if (!fnic_sgl_cache[FNIC_SGL_CACHE_DFLT]) {
printk(KERN_ERR PFX "failed to create fnic dflt sgl slab\n");
err = -ENOMEM;
goto err_create_fnic_sgl_slab_dflt;
}
/* Create a cache for allocation of max size sgls*/
len = sizeof(struct fnic_sgl_list);
fnic_sgl_cache[FNIC_SGL_CACHE_MAX] = kmem_cache_create
("fnic_sgl_max", len + FNIC_SG_DESC_ALIGN, FNIC_SG_DESC_ALIGN,
SLAB_HWCACHE_ALIGN,
NULL);
if (!fnic_sgl_cache[FNIC_SGL_CACHE_MAX]) {
printk(KERN_ERR PFX "failed to create fnic max sgl slab\n");
err = -ENOMEM;
goto err_create_fnic_sgl_slab_max;
}
/* Create a cache of io_req structs for use via mempool */
fnic_io_req_cache = kmem_cache_create("fnic_io_req",
sizeof(struct fnic_io_req),
0, SLAB_HWCACHE_ALIGN, NULL);
if (!fnic_io_req_cache) {
printk(KERN_ERR PFX "failed to create fnic io_req slab\n");
err = -ENOMEM;
goto err_create_fnic_ioreq_slab;
}
fdls_frame_cache = kmem_cache_create("fdls_frames",
FNIC_FCOE_FRAME_MAXSZ,
0, SLAB_HWCACHE_ALIGN, NULL);
if (!fdls_frame_cache) {
pr_err("fnic fdls frame cache create failed\n");
err = -ENOMEM;
goto err_create_fdls_frame_cache;
}
fdls_frame_elem_cache = kmem_cache_create("fdls_frame_elem",
sizeof(struct fnic_frame_list),
0, SLAB_HWCACHE_ALIGN, NULL);
if (!fdls_frame_elem_cache) {
pr_err("fnic fdls frame elem cache create failed\n");
err = -ENOMEM;
goto err_create_fdls_frame_cache_elem;
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/mempool.h`, `linux/string.h`, `linux/slab.h`, `linux/errno.h`, `linux/init.h`, `linux/pci.h`, `linux/skbuff.h`.
- Detected declarations: `function fnic_sdev_init`, `function fnic_set_rport_dev_loss_tmo`, `function fnic_get_host_speed`, `function fnic_dump_fchost_stats`, `function fnic_reset_host_stats`, `function fnic_log_q_error`, `function fnic_handle_link_event`, `function fnic_notify_set`, `function fnic_notify_timer`, `function fnic_notify_timer_start`.
- Atlas domain: Driver Families / drivers/scsi.
- 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.