net/devlink/health.c
Source file repositories/reference/linux-study-clean/net/devlink/health.c
File Facts
- System
- Linux kernel
- Corpus path
net/devlink/health.c- Extension
.c- Size
- 36075 bytes
- Lines
- 1351
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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
net/genetlink.hnet/sock.htrace/events/devlink.hdevl_internal.h
Detected Declarations
struct devlink_fmsg_itemstruct devlink_fmsgstruct devlink_health_reporterfunction devlink_fmsg_freefunction list_for_each_entry_safefunction devlink_health_reporter_privfunction __devlink_health_reporter_find_by_namefunction devlink_health_reporter_find_by_namefunction devlink_port_health_reporter_find_by_namefunction __devlink_health_reporter_createfunction devl_port_health_reporter_createfunction devlink_port_health_reporter_createfunction devl_health_reporter_createfunction devlink_health_reporter_createfunction devlink_health_reporter_freefunction devl_health_reporter_destroyfunction devlink_health_reporter_destroyfunction devlink_nl_health_reporter_fillfunction devlink_health_reporter_get_from_attrsfunction devlink_health_reporter_get_from_infofunction devlink_nl_health_reporter_get_doitfunction devlink_nl_health_reporter_get_dump_onefunction list_for_each_entryfunction list_for_each_entryfunction devlink_nl_health_reporter_get_dumpitfunction devlink_nl_health_reporter_set_doitfunction devlink_recover_notifyfunction devlink_health_reporter_in_burstfunction devlink_health_reporter_recovery_donefunction devlink_health_reporter_recoverfunction devlink_health_dump_clearfunction devlink_health_do_dumpfunction devlink_health_recover_abortfunction devlink_health_reportfunction devlink_health_reporter_state_updatefunction devlink_nl_health_reporter_recover_doitfunction devlink_fmsg_err_if_binaryfunction devlink_fmsg_nest_commonfunction devlink_fmsg_obj_nest_startfunction devlink_fmsg_nest_endfunction devlink_fmsg_obj_nest_endfunction devlink_fmsg_put_namefunction devlink_fmsg_pair_nest_startfunction devlink_fmsg_pair_nest_endfunction devlink_fmsg_arr_pair_nest_startfunction devlink_fmsg_arr_pair_nest_endfunction devlink_fmsg_binary_pair_nest_startfunction devlink_fmsg_binary_pair_nest_end
Annotated Snippet
struct devlink_fmsg_item {
struct list_head list;
int attrtype;
u8 nla_type;
u16 len;
int value[];
};
struct devlink_fmsg {
struct list_head item_list;
int err; /* first error encountered on some devlink_fmsg_XXX() call */
bool putting_binary; /* This flag forces enclosing of binary data
* in an array brackets. It forces using
* of designated API:
* devlink_fmsg_binary_pair_nest_start()
* devlink_fmsg_binary_pair_nest_end()
*/
};
static struct devlink_fmsg *devlink_fmsg_alloc(void)
{
struct devlink_fmsg *fmsg;
fmsg = kzalloc_obj(*fmsg);
if (!fmsg)
return NULL;
INIT_LIST_HEAD(&fmsg->item_list);
return fmsg;
}
static void devlink_fmsg_free(struct devlink_fmsg *fmsg)
{
struct devlink_fmsg_item *item, *tmp;
list_for_each_entry_safe(item, tmp, &fmsg->item_list, list) {
list_del(&item->list);
kfree(item);
}
kfree(fmsg);
}
struct devlink_health_reporter {
struct list_head list;
void *priv;
const struct devlink_health_reporter_ops *ops;
struct devlink *devlink;
struct devlink_port *devlink_port;
struct devlink_fmsg *dump_fmsg;
u64 graceful_period;
u64 burst_period;
bool auto_recover;
bool auto_dump;
u8 health_state;
u64 dump_ts;
u64 dump_real_ts;
u64 error_count;
u64 recovery_count;
u64 last_recovery_ts;
};
void *
devlink_health_reporter_priv(struct devlink_health_reporter *reporter)
{
return reporter->priv;
}
EXPORT_SYMBOL_GPL(devlink_health_reporter_priv);
static struct devlink_health_reporter *
__devlink_health_reporter_find_by_name(struct list_head *reporter_list,
const char *reporter_name)
{
struct devlink_health_reporter *reporter;
list_for_each_entry(reporter, reporter_list, list)
if (!strcmp(reporter->ops->name, reporter_name))
return reporter;
return NULL;
}
static struct devlink_health_reporter *
devlink_health_reporter_find_by_name(struct devlink *devlink,
const char *reporter_name)
{
return __devlink_health_reporter_find_by_name(&devlink->reporter_list,
reporter_name);
}
static struct devlink_health_reporter *
Annotation
- Immediate include surface: `net/genetlink.h`, `net/sock.h`, `trace/events/devlink.h`, `devl_internal.h`.
- Detected declarations: `struct devlink_fmsg_item`, `struct devlink_fmsg`, `struct devlink_health_reporter`, `function devlink_fmsg_free`, `function list_for_each_entry_safe`, `function devlink_health_reporter_priv`, `function __devlink_health_reporter_find_by_name`, `function devlink_health_reporter_find_by_name`, `function devlink_port_health_reporter_find_by_name`, `function __devlink_health_reporter_create`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration 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.