net/devlink/dev.c
Source file repositories/reference/linux-study-clean/net/devlink/dev.c
File Facts
- System
- Linux kernel
- Corpus path
net/devlink/dev.c- Extension
.c- Size
- 38693 bytes
- Lines
- 1444
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hnet/genetlink.hnet/sock.hdevl_internal.h
Detected Declarations
struct devlink_info_reqstruct devlink_reload_combinationstruct devlink_flash_component_lookup_ctxfunction devlink_reload_combination_is_invalidfunction devlink_reload_action_is_supportedfunction devlink_reload_limit_is_supportedfunction devlink_reload_stat_putfunction devlink_reload_stats_putfunction devlink_nl_nested_fillfunction xa_for_eachfunction devlink_nl_fillfunction devlink_notifyfunction devlink_nl_get_doitfunction devlink_nl_get_dump_onefunction devlink_nl_get_dumpitfunction devlink_rel_notify_cbfunction devlink_rel_cleanup_cbfunction devl_nested_devlink_setfunction devlink_notify_registerfunction devlink_notify_unregisterfunction devlink_reload_failed_setfunction devlink_is_reload_failedfunction __devlink_reload_stats_updatefunction for_each_set_bitfunction devlink_reload_stats_updatefunction devlink_remote_reload_actions_performedfunction devlink_reload_netns_changefunction devlink_reload_reinit_sanity_checkfunction devlink_reloadfunction devlink_nl_reload_actions_performed_sndfunction devlink_nl_reload_doitfunction devlink_reload_actions_validfunction devlink_nl_eswitch_fillfunction devlink_nl_eswitch_get_doitfunction devlink_nl_eswitch_set_doitfunction devlink_info_serial_number_putfunction devlink_info_board_serial_number_putfunction devlink_info_version_putfunction devlink_info_version_fixed_putfunction devlink_info_version_stored_putfunction devlink_info_version_stored_put_extfunction devlink_info_version_running_putfunction devlink_info_version_running_put_extfunction devlink_nl_driver_info_getfunction devlink_nl_info_fillfunction devlink_nl_info_get_doitfunction devlink_nl_info_get_dump_onefunction devlink_nl_info_get_dumpit
Annotated Snippet
static int devlink_nl_driver_info_get(const struct device_driver *drv,
struct devlink_info_req *req)
{
if (!drv)
return 0;
if (drv->name[0])
return nla_put_string(req->msg, DEVLINK_ATTR_INFO_DRIVER_NAME,
drv->name);
return 0;
}
static int
devlink_nl_info_fill(struct sk_buff *msg, struct devlink *devlink,
enum devlink_command cmd, u32 portid,
u32 seq, int flags, struct netlink_ext_ack *extack)
{
struct devlink_info_req req = {};
void *hdr;
int err;
hdr = genlmsg_put(msg, portid, seq, &devlink_nl_family, flags, cmd);
if (!hdr)
return -EMSGSIZE;
err = -EMSGSIZE;
if (devlink_nl_put_handle(msg, devlink))
goto err_cancel_msg;
req.msg = msg;
if (devlink->ops->info_get) {
err = devlink->ops->info_get(devlink, &req, extack);
if (err)
goto err_cancel_msg;
}
err = devlink_nl_driver_info_get(devlink->dev_driver, &req);
if (err)
goto err_cancel_msg;
genlmsg_end(msg, hdr);
return 0;
err_cancel_msg:
genlmsg_cancel(msg, hdr);
return err;
}
int devlink_nl_info_get_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct sk_buff *msg;
int err;
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg)
return -ENOMEM;
err = devlink_nl_info_fill(msg, devlink, DEVLINK_CMD_INFO_GET,
info->snd_portid, info->snd_seq, 0,
info->extack);
if (err) {
nlmsg_free(msg);
return err;
}
return genlmsg_reply(msg, info);
}
static int
devlink_nl_info_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
struct netlink_callback *cb, int flags)
{
int err;
err = devlink_nl_info_fill(msg, devlink, DEVLINK_CMD_INFO_GET,
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, flags,
cb->extack);
if (err == -EOPNOTSUPP)
err = 0;
return err;
}
int devlink_nl_info_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb)
{
return devlink_nl_dumpit(msg, cb, devlink_nl_info_get_dump_one);
}
Annotation
- Immediate include surface: `linux/device.h`, `net/genetlink.h`, `net/sock.h`, `devl_internal.h`.
- Detected declarations: `struct devlink_info_req`, `struct devlink_reload_combination`, `struct devlink_flash_component_lookup_ctx`, `function devlink_reload_combination_is_invalid`, `function devlink_reload_action_is_supported`, `function devlink_reload_limit_is_supported`, `function devlink_reload_stat_put`, `function devlink_reload_stats_put`, `function devlink_nl_nested_fill`, `function xa_for_each`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- 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.