net/devlink/region.c
Source file repositories/reference/linux-study-clean/net/devlink/region.c
File Facts
- System
- Linux kernel
- Corpus path
net/devlink/region.c- Extension
.c- Size
- 31915 bytes
- Lines
- 1259
- 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.
- 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
devl_internal.h
Detected Declarations
struct devlink_regionstruct devlink_snapshotfunction devlink_region_get_by_namefunction devlink_port_region_get_by_namefunction devlink_region_snapshot_get_by_idfunction devlink_nl_region_snapshot_id_putfunction devlink_nl_region_snapshots_id_putfunction list_for_each_entryfunction devlink_nl_region_fillfunction devlink_nl_region_notify_buildfunction devlink_nl_region_notifyfunction devlink_regions_notify_registerfunction devlink_regions_notify_unregisterfunction devlink_region_snapshot_id_getfunction __devlink_snapshot_id_decrementfunction __devlink_snapshot_id_insertfunction __devlink_region_snapshot_id_getfunction __devlink_region_snapshot_createfunction devlink_region_snapshot_delfunction devlink_nl_region_get_doitfunction devlink_nl_cmd_region_get_port_dumpitfunction list_for_each_entryfunction devlink_nl_region_get_dump_onefunction list_for_each_entryfunction xa_for_eachfunction devlink_nl_region_get_dumpitfunction devlink_nl_region_del_doitfunction devlink_nl_region_new_doitfunction devlink_nl_cmd_region_read_chunk_fillfunction devlink_nl_region_read_fillfunction devlink_region_snapshot_fillfunction devlink_region_port_direct_fillfunction devlink_region_direct_fillfunction devlink_nl_region_read_dumpitfunction devlink_region_createfunction devlink_port_region_createfunction devl_region_destroyfunction devlink_region_destroyfunction devlink_region_snapshot_id_getfunction devlink_region_snapshot_id_putfunction devlink_region_snapshot_createexport devl_region_createexport devlink_region_createexport devlink_port_region_createexport devl_region_destroyexport devlink_region_destroyexport devlink_region_snapshot_id_getexport devlink_region_snapshot_id_put
Annotated Snippet
struct devlink_region {
struct devlink *devlink;
struct devlink_port *port;
struct list_head list;
union {
const struct devlink_region_ops *ops;
const struct devlink_port_region_ops *port_ops;
};
struct mutex snapshot_lock; /* protects snapshot_list,
* max_snapshots and cur_snapshots
* consistency.
*/
struct list_head snapshot_list;
u32 max_snapshots;
u32 cur_snapshots;
u64 size;
};
struct devlink_snapshot {
struct list_head list;
struct devlink_region *region;
u8 *data;
u32 id;
};
static struct devlink_region *
devlink_region_get_by_name(struct devlink *devlink, const char *region_name)
{
struct devlink_region *region;
list_for_each_entry(region, &devlink->region_list, list)
if (!strcmp(region->ops->name, region_name))
return region;
return NULL;
}
static struct devlink_region *
devlink_port_region_get_by_name(struct devlink_port *port,
const char *region_name)
{
struct devlink_region *region;
list_for_each_entry(region, &port->region_list, list)
if (!strcmp(region->port_ops->name, region_name))
return region;
return NULL;
}
static struct devlink_snapshot *
devlink_region_snapshot_get_by_id(struct devlink_region *region, u32 id)
{
struct devlink_snapshot *snapshot;
list_for_each_entry(snapshot, ®ion->snapshot_list, list)
if (snapshot->id == id)
return snapshot;
return NULL;
}
static int devlink_nl_region_snapshot_id_put(struct sk_buff *msg,
struct devlink *devlink,
struct devlink_snapshot *snapshot)
{
struct nlattr *snap_attr;
int err;
snap_attr = nla_nest_start_noflag(msg, DEVLINK_ATTR_REGION_SNAPSHOT);
if (!snap_attr)
return -EMSGSIZE;
err = nla_put_u32(msg, DEVLINK_ATTR_REGION_SNAPSHOT_ID, snapshot->id);
if (err)
goto nla_put_failure;
nla_nest_end(msg, snap_attr);
return 0;
nla_put_failure:
nla_nest_cancel(msg, snap_attr);
return err;
}
static int devlink_nl_region_snapshots_id_put(struct sk_buff *msg,
struct devlink *devlink,
struct devlink_region *region)
{
struct devlink_snapshot *snapshot;
Annotation
- Immediate include surface: `devl_internal.h`.
- Detected declarations: `struct devlink_region`, `struct devlink_snapshot`, `function devlink_region_get_by_name`, `function devlink_port_region_get_by_name`, `function devlink_region_snapshot_get_by_id`, `function devlink_nl_region_snapshot_id_put`, `function devlink_nl_region_snapshots_id_put`, `function list_for_each_entry`, `function devlink_nl_region_fill`, `function devlink_nl_region_notify_build`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
- 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.