drivers/scsi/fnic/fnic_debugfs.c
Source file repositories/reference/linux-study-clean/drivers/scsi/fnic/fnic_debugfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/fnic/fnic_debugfs.c- Extension
.c- Size
- 20029 bytes
- Lines
- 722
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/errno.hlinux/debugfs.hlinux/vmalloc.hfnic.h
Detected Declarations
struct fc_trace_flag_typefunction fnic_debugfs_initfunction fnic_debugfs_terminatefunction fnic_trace_ctrl_readfunction fnic_trace_ctrl_writefunction fnic_trace_debugfs_openfunction fnic_trace_debugfs_lseekfunction readfunction fnic_trace_debugfs_releasefunction fnic_trace_debugfs_initfunction fnic_trace_debugfs_terminatefunction fnic_fc_trace_debugfs_initfunction fnic_fc_trace_debugfs_terminatefunction fnic_reset_stats_openfunction fnic_reset_stats_readfunction fnic_reset_stats_writefunction fnic_reset_stats_releasefunction fnic_stats_debugfs_openfunction readfunction fnic_stats_debugfs_releasefunction fnic_stats_debugfs_initfunction fnic_stats_debugfs_remove
Annotated Snippet
static const struct file_operations fnic_trace_ctrl_fops = {
.owner = THIS_MODULE,
.open = simple_open,
.read = fnic_trace_ctrl_read,
.write = fnic_trace_ctrl_write,
};
/*
* fnic_trace_debugfs_open - Open the fnic trace log
* @inode: The inode pointer
* @file: The file pointer to attach the log output
*
* Description:
* This routine is the entry point for the debugfs open file operation.
* It allocates the necessary buffer for the log, fills the buffer from
* the in-memory log and then returns a pointer to that log in
* the private_data field in @file.
*
* Returns:
* This function returns zero if successful. On error it will return
* a negative error value.
*/
static int fnic_trace_debugfs_open(struct inode *inode,
struct file *file)
{
fnic_dbgfs_t *fnic_dbg_prt;
u8 *rdata_ptr;
rdata_ptr = (u8 *)inode->i_private;
fnic_dbg_prt = kzalloc_obj(fnic_dbgfs_t);
if (!fnic_dbg_prt)
return -ENOMEM;
if (*rdata_ptr == fc_trc_flag->fnic_trace) {
fnic_dbg_prt->buffer = vzalloc(array3_size(3, trace_max_pages,
PAGE_SIZE));
if (!fnic_dbg_prt->buffer) {
kfree(fnic_dbg_prt);
return -ENOMEM;
}
fnic_dbg_prt->buffer_len = fnic_get_trace_data(fnic_dbg_prt);
} else {
fnic_dbg_prt->buffer =
vzalloc(array3_size(3, fnic_fc_trace_max_pages,
PAGE_SIZE));
if (!fnic_dbg_prt->buffer) {
kfree(fnic_dbg_prt);
return -ENOMEM;
}
fnic_dbg_prt->buffer_len =
fnic_fc_trace_get_data(fnic_dbg_prt, *rdata_ptr);
}
file->private_data = fnic_dbg_prt;
return 0;
}
/*
* fnic_trace_debugfs_lseek - Seek through a debugfs file
* @file: The file pointer to seek through.
* @offset: The offset to seek to or the amount to seek by.
* @howto: Indicates how to seek.
*
* Description:
* This routine is the entry point for the debugfs lseek file operation.
* The @howto parameter indicates whether @offset is the offset to directly
* seek to, or if it is a value to seek forward or reverse by. This function
* figures out what the new offset of the debugfs file will be and assigns
* that value to the f_pos field of @file.
*
* Returns:
* This function returns the new offset if successful and returns a negative
* error if unable to process the seek.
*/
static loff_t fnic_trace_debugfs_lseek(struct file *file,
loff_t offset,
int howto)
{
fnic_dbgfs_t *fnic_dbg_prt = file->private_data;
return fixed_size_llseek(file, offset, howto,
fnic_dbg_prt->buffer_len);
}
/*
* fnic_trace_debugfs_read - Read a debugfs file
* @file: The file pointer to read from.
* @ubuf: The buffer to copy the data to.
* @nbytes: The number of bytes to read.
* @pos: The position in the file to start reading from.
*
* Description:
Annotation
- Immediate include surface: `linux/module.h`, `linux/errno.h`, `linux/debugfs.h`, `linux/vmalloc.h`, `fnic.h`.
- Detected declarations: `struct fc_trace_flag_type`, `function fnic_debugfs_init`, `function fnic_debugfs_terminate`, `function fnic_trace_ctrl_read`, `function fnic_trace_ctrl_write`, `function fnic_trace_debugfs_open`, `function fnic_trace_debugfs_lseek`, `function read`, `function fnic_trace_debugfs_release`, `function fnic_trace_debugfs_init`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.