drivers/scsi/qla2xxx/qla_dfs.c
Source file repositories/reference/linux-study-clean/drivers/scsi/qla2xxx/qla_dfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/qla2xxx/qla_dfs.c- Extension
.c- Size
- 22890 bytes
- Lines
- 808
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
qla_def.hlinux/debugfs.hlinux/seq_file.h
Detected Declarations
function qla_dfs_rport_getfunction qla_dfs_rport_setfunction qla2x00_dfs_create_rportfunction qla2x00_dfs_remove_rportfunction qla2x00_dfs_tgt_sess_showfunction qla2x00_dfs_tgt_port_database_showfunction qla_dfs_fw_resource_cnt_showfunction qla_dfs_tgt_counters_showfunction list_for_each_entryfunction qla2x00_dfs_fce_showfunction qla2x00_dfs_fce_openfunction qla2x00_dfs_fce_releasefunction qla2x00_dfs_fce_writefunction qla_dfs_naqp_showfunction qla_dfs_naqp_writefunction qla2x00_dfs_setupfunction qla2x00_dfs_remove
Annotated Snippet
static const struct file_operations dfs_fce_ops = {
.open = qla2x00_dfs_fce_open,
.read = seq_read,
.llseek = seq_lseek,
.release = qla2x00_dfs_fce_release,
.write = qla2x00_dfs_fce_write,
};
static int
qla_dfs_naqp_show(struct seq_file *s, void *unused)
{
struct scsi_qla_host *vha = s->private;
struct qla_hw_data *ha = vha->hw;
seq_printf(s, "%d\n", ha->tgt.num_act_qpairs);
return 0;
}
/*
* Helper macros for setting up debugfs entries.
* _name: The name of the debugfs entry
* _ctx_struct: The context that was passed when creating the debugfs file
*
* QLA_DFS_SETUP_RD could be used when there is only a show function.
* - show function take the name qla_dfs_<sysfs-name>_show
*
* QLA_DFS_SETUP_RW could be used when there are both show and write functions.
* - show function take the name qla_dfs_<sysfs-name>_show
* - write function take the name qla_dfs_<sysfs-name>_write
*
* To have a new debugfs entry, do:
* 1. Create a "struct dentry *" in the appropriate structure in the format
* dfs_<sysfs-name>
* 2. Setup debugfs entries using QLA_DFS_SETUP_RD / QLA_DFS_SETUP_RW
* 3. Create debugfs file in qla2x00_dfs_setup() using QLA_DFS_CREATE_FILE
* or QLA_DFS_ROOT_CREATE_FILE
* 4. Remove debugfs file in qla2x00_dfs_remove() using QLA_DFS_REMOVE_FILE
* or QLA_DFS_ROOT_REMOVE_FILE
*
* Example for creating "TEST" sysfs file:
* 1. struct qla_hw_data { ... struct dentry *dfs_TEST; }
* 2. QLA_DFS_SETUP_RD(TEST);
* 3. In qla2x00_dfs_setup():
* QLA_DFS_CREATE_FILE(ha, TEST, 0600, ha->dfs_dir, vha);
* 4. In qla2x00_dfs_remove():
* QLA_DFS_REMOVE_FILE(ha, TEST);
*/
#define QLA_DFS_SETUP_RD(_name) DEFINE_SHOW_ATTRIBUTE(qla_dfs_##_name)
#define QLA_DFS_SETUP_RW(_name) DEFINE_SHOW_STORE_ATTRIBUTE(qla_dfs_##_name)
#define QLA_DFS_ROOT_CREATE_FILE(_name, _perm, _ctx) \
do { \
if (!qla_dfs_##_name) \
qla_dfs_##_name = debugfs_create_file(#_name, \
_perm, qla2x00_dfs_root, _ctx, \
&qla_dfs_##_name##_fops); \
} while (0)
#define QLA_DFS_ROOT_REMOVE_FILE(_name) \
do { \
if (qla_dfs_##_name) { \
debugfs_remove(qla_dfs_##_name); \
qla_dfs_##_name = NULL; \
} \
} while (0)
#define QLA_DFS_CREATE_FILE(_struct, _name, _perm, _parent, _ctx) \
do { \
(_struct)->dfs_##_name = debugfs_create_file(#_name, \
_perm, _parent, _ctx, \
&qla_dfs_##_name##_fops) \
} while (0)
#define QLA_DFS_REMOVE_FILE(_struct, _name) \
do { \
if ((_struct)->dfs_##_name) { \
debugfs_remove((_struct)->dfs_##_name); \
(_struct)->dfs_##_name = NULL; \
} \
} while (0)
static ssize_t
qla_dfs_naqp_write(struct file *file, const char __user *buffer,
size_t count, loff_t *pos)
{
struct seq_file *s = file->private_data;
struct scsi_qla_host *vha = s->private;
struct qla_hw_data *ha = vha->hw;
char *buf;
Annotation
- Immediate include surface: `qla_def.h`, `linux/debugfs.h`, `linux/seq_file.h`.
- Detected declarations: `function qla_dfs_rport_get`, `function qla_dfs_rport_set`, `function qla2x00_dfs_create_rport`, `function qla2x00_dfs_remove_rport`, `function qla2x00_dfs_tgt_sess_show`, `function qla2x00_dfs_tgt_port_database_show`, `function qla_dfs_fw_resource_cnt_show`, `function qla_dfs_tgt_counters_show`, `function list_for_each_entry`, `function qla2x00_dfs_fce_show`.
- 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.