drivers/net/ethernet/intel/i40e/i40e_debugfs.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/intel/i40e/i40e_debugfs.c- Extension
.c- Size
- 57479 bytes
- Lines
- 1756
- 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.
- 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/fs.hlinux/debugfs.hlinux/if_bridge.hi40e.hi40e_virtchnl_pf.h
Detected Declarations
enum ring_typefunction i40e_dbg_dump_vsi_seidfunction i40e_dbg_dump_aq_descfunction i40e_dbg_dump_descfunction i40e_dbg_dump_vsi_no_seidfunction i40e_dbg_dump_eth_statsfunction i40e_dbg_dump_veb_seidfunction i40e_dbg_dump_veb_allfunction i40e_dbg_dump_vffunction i40e_dbg_dump_vf_allfunction i40e_dbg_command_writefunction i40e_dbg_netdev_ops_writefunction i40e_dbg_pf_initfunction i40e_dbg_pf_exitfunction i40e_dbg_initfunction i40e_dbg_exit
Annotated Snippet
static const struct file_operations i40e_dbg_command_fops = {
.owner = THIS_MODULE,
.open = simple_open,
.write = i40e_dbg_command_write,
};
/**************************************************************
* netdev_ops
* The netdev_ops entry in debugfs is for giving the driver commands
* to be executed from the netdev operations.
**************************************************************/
/**
* i40e_dbg_netdev_ops_write - write into netdev_ops datum
* @filp: the opened file
* @buffer: where to find the user's data
* @count: the length of the user's data
* @ppos: file position offset
**/
static ssize_t i40e_dbg_netdev_ops_write(struct file *filp,
const char __user *buffer,
size_t count, loff_t *ppos)
{
struct i40e_pf *pf = filp->private_data;
char *cmd_buf, *buf_tmp;
int bytes_not_copied;
struct i40e_vsi *vsi;
int vsi_seid;
int i, cnt;
/* don't allow partial writes */
if (*ppos != 0)
return 0;
cmd_buf = kzalloc(count + 1, GFP_KERNEL);
if (!cmd_buf)
return count;
bytes_not_copied = copy_from_user(cmd_buf, buffer, count);
if (bytes_not_copied) {
kfree(cmd_buf);
return -EFAULT;
}
cmd_buf[count] = '\0';
buf_tmp = strchr(cmd_buf, '\n');
if (buf_tmp) {
*buf_tmp = '\0';
count = buf_tmp - cmd_buf + 1;
}
if (strncmp(cmd_buf, "change_mtu", 10) == 0) {
int mtu;
cnt = sscanf(&cmd_buf[11], "%i %i",
&vsi_seid, &mtu);
if (cnt != 2) {
dev_info(&pf->pdev->dev, "change_mtu <vsi_seid> <mtu>\n");
goto netdev_ops_write_done;
}
vsi = i40e_dbg_find_vsi(pf, vsi_seid);
if (!vsi) {
dev_info(&pf->pdev->dev,
"change_mtu: VSI %d not found\n", vsi_seid);
} else if (!vsi->netdev) {
dev_info(&pf->pdev->dev, "change_mtu: no netdev for VSI %d\n",
vsi_seid);
} else if (rtnl_trylock()) {
vsi->netdev->netdev_ops->ndo_change_mtu(vsi->netdev,
mtu);
rtnl_unlock();
dev_info(&pf->pdev->dev, "change_mtu called\n");
} else {
dev_info(&pf->pdev->dev, "Could not acquire RTNL - please try again\n");
}
} else if (strncmp(cmd_buf, "set_rx_mode", 11) == 0) {
cnt = sscanf(&cmd_buf[11], "%i", &vsi_seid);
if (cnt != 1) {
dev_info(&pf->pdev->dev, "set_rx_mode <vsi_seid>\n");
goto netdev_ops_write_done;
}
vsi = i40e_dbg_find_vsi(pf, vsi_seid);
if (!vsi) {
dev_info(&pf->pdev->dev,
"set_rx_mode: VSI %d not found\n", vsi_seid);
} else if (!vsi->netdev) {
dev_info(&pf->pdev->dev, "set_rx_mode: no netdev for VSI %d\n",
vsi_seid);
} else if (rtnl_trylock()) {
vsi->netdev->netdev_ops->ndo_set_rx_mode(vsi->netdev);
Annotation
- Immediate include surface: `linux/fs.h`, `linux/debugfs.h`, `linux/if_bridge.h`, `i40e.h`, `i40e_virtchnl_pf.h`.
- Detected declarations: `enum ring_type`, `function i40e_dbg_dump_vsi_seid`, `function i40e_dbg_dump_aq_desc`, `function i40e_dbg_dump_desc`, `function i40e_dbg_dump_vsi_no_seid`, `function i40e_dbg_dump_eth_stats`, `function i40e_dbg_dump_veb_seid`, `function i40e_dbg_dump_veb_all`, `function i40e_dbg_dump_vf`, `function i40e_dbg_dump_vf_all`.
- 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.
- 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.