drivers/net/ethernet/intel/libie/fwlog.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/libie/fwlog.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/intel/libie/fwlog.c- Extension
.c- Size
- 29879 bytes
- Lines
- 1141
- Domain
- Driver Families
- Bucket
- drivers/net
- 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/debugfs.hlinux/export.hlinux/fs.hlinux/net/intel/libie/fwlog.hlinux/pci.hlinux/random.hlinux/vmalloc.h
Detected Declarations
function libie_fwlog_ring_emptyfunction libie_fwlog_ring_incrementfunction libie_fwlog_alloc_ring_buffsfunction libie_fwlog_free_ring_buffsfunction libie_fwlog_realloc_ringsfunction libie_init_hwfunction libie_aq_fwlog_setfunction libie_fwlog_setfunction libie_aq_fwlog_registerfunction libie_fwlog_registerfunction libie_fwlog_unregisterfunction libie_fwlog_print_module_cfgfunction libie_find_module_by_dentryfunction libie_debugfs_module_showfunction libie_debugfs_module_openfunction libie_debugfs_module_writefunction libie_debugfs_nr_messages_readfunction libie_debugfs_nr_messages_writefunction libie_debugfs_enable_readfunction libie_debugfs_enable_writefunction libie_debugfs_log_size_readfunction libie_debugfs_log_size_writefunction libie_debugfs_data_readfunction libie_debugfs_data_writefunction libie_debugfs_fwlog_initfunction libie_fwlog_ring_fullfunction libie_aq_fwlog_getfunction libie_fwlog_set_supportedfunction libie_init_hwfunction libie_deinit_hwfunction libie_get_fwlog_datafunction libie_fwlog_reregisterexport libie_fwlog_initexport libie_fwlog_deinitexport libie_get_fwlog_dataexport libie_fwlog_reregister
Annotated Snippet
static const struct file_operations libie_debugfs_module_fops = {
.owner = THIS_MODULE,
.open = libie_debugfs_module_open,
.read = seq_read,
.release = single_release,
.write = libie_debugfs_module_write,
};
/**
* libie_debugfs_nr_messages_read - read from 'nr_messages' file
* @filp: the opened file
* @buffer: where to write the data for the user to read
* @count: the size of the user's buffer
* @ppos: file position offset
*/
static ssize_t libie_debugfs_nr_messages_read(struct file *filp,
char __user *buffer, size_t count,
loff_t *ppos)
{
struct libie_fwlog *fwlog = filp->private_data;
char buff[32] = {};
snprintf(buff, sizeof(buff), "%d\n",
fwlog->cfg.log_resolution);
return simple_read_from_buffer(buffer, count, ppos, buff, strlen(buff));
}
/**
* libie_debugfs_nr_messages_write - write into 'nr_messages' file
* @filp: the opened file
* @buf: where to find the user's data
* @count: the length of the user's data
* @ppos: file position offset
*/
static ssize_t
libie_debugfs_nr_messages_write(struct file *filp, const char __user *buf,
size_t count, loff_t *ppos)
{
struct libie_fwlog *fwlog = filp->private_data;
struct device *dev = &fwlog->pdev->dev;
char user_val[8], *cmd_buf;
s16 nr_messages;
ssize_t ret;
/* don't allow partial writes or invalid input */
if (*ppos != 0 || count > 4)
return -EINVAL;
cmd_buf = memdup_user_nul(buf, count);
if (IS_ERR(cmd_buf))
return PTR_ERR(cmd_buf);
ret = sscanf(cmd_buf, "%s", user_val);
if (ret != 1) {
count = -EINVAL;
goto free_cmd_buf;
}
ret = kstrtos16(user_val, 0, &nr_messages);
if (ret) {
count = ret;
goto free_cmd_buf;
}
if (nr_messages < LIBIE_AQC_FW_LOG_MIN_RESOLUTION ||
nr_messages > LIBIE_AQC_FW_LOG_MAX_RESOLUTION) {
dev_err(dev, "Invalid FW log number of messages %d, value must be between %d - %d\n",
nr_messages, LIBIE_AQC_FW_LOG_MIN_RESOLUTION,
LIBIE_AQC_FW_LOG_MAX_RESOLUTION);
count = -EINVAL;
goto free_cmd_buf;
}
fwlog->cfg.log_resolution = nr_messages;
free_cmd_buf:
kfree(cmd_buf);
return count;
}
static const struct file_operations libie_debugfs_nr_messages_fops = {
.owner = THIS_MODULE,
.open = simple_open,
.read = libie_debugfs_nr_messages_read,
.write = libie_debugfs_nr_messages_write,
};
/**
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/export.h`, `linux/fs.h`, `linux/net/intel/libie/fwlog.h`, `linux/pci.h`, `linux/random.h`, `linux/vmalloc.h`.
- Detected declarations: `function libie_fwlog_ring_empty`, `function libie_fwlog_ring_increment`, `function libie_fwlog_alloc_ring_buffs`, `function libie_fwlog_free_ring_buffs`, `function libie_fwlog_realloc_rings`, `function libie_init_hw`, `function libie_aq_fwlog_set`, `function libie_fwlog_set`, `function libie_aq_fwlog_register`, `function libie_fwlog_register`.
- Atlas domain: Driver Families / drivers/net.
- 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.