drivers/scsi/fnic/fnic_trace.c
Source file repositories/reference/linux-study-clean/drivers/scsi/fnic/fnic_trace.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/fnic/fnic_trace.c- Extension
.c- Size
- 30315 bytes
- Lines
- 884
- Domain
- Driver Families
- Bucket
- drivers/scsi
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/module.hlinux/mempool.hlinux/errno.hlinux/spinlock.hlinux/kallsyms.hlinux/time.hlinux/vmalloc.hscsi/scsi_transport_fc.hfnic_io.hfnic.h
Detected Declarations
function fnic_get_trace_datafunction fnic_get_stats_datafunction fnic_get_debug_infofunction fnic_trace_buf_initfunction fnic_trace_freefunction Page_offsetfunction fnic_fc_trace_freefunction fnic_fc_trace_set_datafunction fnic_fc_trace_get_datafunction copy_and_format_trace_data
Annotated Snippet
while (1) {
/* Start from read index @rd_idx */
tbp = (fnic_trace_data_t *)
fnic_trace_entries.page_offset[rd_idx];
if (!tbp) {
spin_unlock_irqrestore(&fnic_trace_lock, flags);
return 0;
}
/* Convert function pointer to function name */
if (sizeof(unsigned long) < 8) {
sprint_symbol(str, tbp->fnaddr.low);
jiffies_to_timespec64(tbp->timestamp.low, &val);
} else {
sprint_symbol(str, tbp->fnaddr.val);
jiffies_to_timespec64(tbp->timestamp.val, &val);
}
/*
* Dump trace buffer entry to memory file
* and increment read index @rd_idx
*/
len += scnprintf(fnic_dbgfs_prt->buffer + len,
(trace_max_pages * PAGE_SIZE * 3) - len,
"%ptSp %-50s %8x %8x %16llx %16llx %16llx %16llx %16llx\n",
&val, str, tbp->host_no, tbp->tag,
tbp->data[0], tbp->data[1], tbp->data[2],
tbp->data[3], tbp->data[4]);
rd_idx++;
/*
* If rd_idx is reached to maximum trace entries
* then move rd_idx to zero
*/
if (rd_idx > (fnic_max_trace_entries-1))
rd_idx = 0;
/*
* Continue dumping trace buffer entries into
* memory file till rd_idx reaches write index
*/
if (rd_idx == wr_idx)
break;
}
} else if (wr_idx > rd_idx) {
while (1) {
/* Start from read index @rd_idx */
tbp = (fnic_trace_data_t *)
fnic_trace_entries.page_offset[rd_idx];
if (!tbp) {
spin_unlock_irqrestore(&fnic_trace_lock, flags);
return 0;
}
/* Convert function pointer to function name */
if (sizeof(unsigned long) < 8) {
sprint_symbol(str, tbp->fnaddr.low);
jiffies_to_timespec64(tbp->timestamp.low, &val);
} else {
sprint_symbol(str, tbp->fnaddr.val);
jiffies_to_timespec64(tbp->timestamp.val, &val);
}
/*
* Dump trace buffer entry to memory file
* and increment read index @rd_idx
*/
len += scnprintf(fnic_dbgfs_prt->buffer + len,
(trace_max_pages * PAGE_SIZE * 3) - len,
"%ptSp %-50s %8x %8x %16llx %16llx %16llx %16llx %16llx\n",
&val, str, tbp->host_no, tbp->tag,
tbp->data[0], tbp->data[1], tbp->data[2],
tbp->data[3], tbp->data[4]);
rd_idx++;
/*
* Continue dumping trace buffer entries into
* memory file till rd_idx reaches write index
*/
if (rd_idx == wr_idx)
break;
}
}
spin_unlock_irqrestore(&fnic_trace_lock, flags);
return len;
}
/*
* fnic_get_stats_data - Copy fnic stats buffer to a memory file
* @fnic_dbgfs_t: pointer to debugfs fnic stats buffer
*
* Description:
* This routine gathers the fnic stats debugfs data from the fnic_stats struct
* and dumps it to stats_debug_info.
*
* Return Value:
* This routine returns the amount of bytes that were dumped into
Annotation
- Immediate include surface: `linux/module.h`, `linux/mempool.h`, `linux/errno.h`, `linux/spinlock.h`, `linux/kallsyms.h`, `linux/time.h`, `linux/vmalloc.h`, `scsi/scsi_transport_fc.h`.
- Detected declarations: `function fnic_get_trace_data`, `function fnic_get_stats_data`, `function fnic_get_debug_info`, `function fnic_trace_buf_init`, `function fnic_trace_free`, `function Page_offset`, `function fnic_fc_trace_free`, `function fnic_fc_trace_set_data`, `function fnic_fc_trace_get_data`, `function copy_and_format_trace_data`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: source 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.