drivers/net/netdevsim/health.c
Source file repositories/reference/linux-study-clean/drivers/net/netdevsim/health.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/netdevsim/health.c- Extension
.c- Size
- 6528 bytes
- Lines
- 232
- 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.
- 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/err.hlinux/kernel.hlinux/slab.hnetdevsim.h
Detected Declarations
struct nsim_dev_dummy_reporter_ctxfunction nsim_dev_empty_reporter_dumpfunction nsim_dev_empty_reporter_diagnosefunction nsim_dev_dummy_reporter_recoverfunction nsim_dev_dummy_fmsg_putfunction nsim_dev_dummy_reporter_dumpfunction nsim_dev_dummy_reporter_diagnosefunction nsim_dev_health_break_writefunction nsim_dev_health_initfunction nsim_dev_health_exit
Annotated Snippet
static const struct file_operations nsim_dev_health_break_fops = {
.open = simple_open,
.write = nsim_dev_health_break_write,
.llseek = generic_file_llseek,
.owner = THIS_MODULE,
};
int nsim_dev_health_init(struct nsim_dev *nsim_dev, struct devlink *devlink)
{
struct nsim_dev_health *health = &nsim_dev->health;
int err;
health->empty_reporter =
devl_health_reporter_create(devlink,
&nsim_dev_empty_reporter_ops,
health);
if (IS_ERR(health->empty_reporter))
return PTR_ERR(health->empty_reporter);
health->dummy_reporter =
devl_health_reporter_create(devlink,
&nsim_dev_dummy_reporter_ops,
health);
if (IS_ERR(health->dummy_reporter)) {
err = PTR_ERR(health->dummy_reporter);
goto err_empty_reporter_destroy;
}
health->ddir = debugfs_create_dir("health", nsim_dev->ddir);
if (IS_ERR(health->ddir)) {
err = PTR_ERR(health->ddir);
goto err_dummy_reporter_destroy;
}
health->recovered_break_msg = NULL;
debugfs_create_file("break_health", 0200, health->ddir, health,
&nsim_dev_health_break_fops);
health->binary_len = 16;
debugfs_create_u32("binary_len", 0600, health->ddir,
&health->binary_len);
health->fail_recover = false;
debugfs_create_bool("fail_recover", 0600, health->ddir,
&health->fail_recover);
return 0;
err_dummy_reporter_destroy:
devl_health_reporter_destroy(health->dummy_reporter);
err_empty_reporter_destroy:
devl_health_reporter_destroy(health->empty_reporter);
return err;
}
void nsim_dev_health_exit(struct nsim_dev *nsim_dev)
{
struct nsim_dev_health *health = &nsim_dev->health;
debugfs_remove_recursive(health->ddir);
kfree(health->recovered_break_msg);
devl_health_reporter_destroy(health->dummy_reporter);
devl_health_reporter_destroy(health->empty_reporter);
}
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/err.h`, `linux/kernel.h`, `linux/slab.h`, `netdevsim.h`.
- Detected declarations: `struct nsim_dev_dummy_reporter_ctx`, `function nsim_dev_empty_reporter_dump`, `function nsim_dev_empty_reporter_diagnose`, `function nsim_dev_dummy_reporter_recover`, `function nsim_dev_dummy_fmsg_put`, `function nsim_dev_dummy_reporter_dump`, `function nsim_dev_dummy_reporter_diagnose`, `function nsim_dev_health_break_write`, `function nsim_dev_health_init`, `function nsim_dev_health_exit`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
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.