net/devlink/param.c
Source file repositories/reference/linux-study-clean/net/devlink/param.c
File Facts
- System
- Linux kernel
- Corpus path
net/devlink/param.c- Extension
.c- Size
- 27530 bytes
- Lines
- 1012
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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
function devlink_param_generic_verifyfunction devlink_param_driver_verifyfunction devlink_param_find_by_namefunction xa_for_eachfunction devlink_param_find_by_idfunction devlink_param_cmode_is_supportedfunction devlink_param_getfunction devlink_param_setfunction devlink_param_get_defaultfunction devlink_param_reset_defaultfunction devlink_nl_param_value_putfunction devlink_nl_param_value_fill_onefunction devlink_nl_param_fillfunction devlink_param_notifyfunction devlink_params_notifyfunction devlink_params_notify_registerfunction devlink_params_notify_unregisterfunction devlink_nl_param_get_dump_onefunction xa_for_each_startfunction devlink_nl_param_get_dumpitfunction devlink_param_type_get_from_infofunction devlink_param_value_get_from_infofunction nla_for_each_attr_typefunction devlink_param_get_from_infofunction devlink_nl_param_get_doitfunction __devlink_nl_cmd_param_set_doitfunction devlink_nl_param_set_doitfunction devlink_nl_port_param_get_dumpitfunction devlink_nl_port_param_get_doitfunction devlink_nl_port_param_set_doitfunction devlink_param_verifyfunction devlink_param_registerfunction devlink_param_unregisterfunction devl_params_registerfunction devlink_params_registerfunction devl_params_unregisterfunction devlink_params_unregisterfunction devl_param_driverinit_value_setfunction devl_param_driverinit_value_setfunction devlink_params_driverinit_load_newfunction xa_for_eachfunction devl_param_value_changedexport devl_params_registerexport devlink_params_registerexport devl_params_unregisterexport devlink_params_unregisterexport devl_param_driverinit_value_getexport devl_param_driverinit_value_set
Annotated Snippet
if (flag_as_u8) {
if (nla_put_u8(msg, nla_type, val->vbool))
return -EMSGSIZE;
} else {
if (val->vbool && nla_put_flag(msg, nla_type))
return -EMSGSIZE;
}
break;
case DEVLINK_PARAM_TYPE_U64_ARRAY:
if (val->u64arr.size > __DEVLINK_PARAM_MAX_ARRAY_SIZE)
return -EMSGSIZE;
for (int i = 0; i < val->u64arr.size; i++) {
if (nla_put_uint(msg, nla_type, val->u64arr.val[i]))
return -EMSGSIZE;
}
break;
}
return 0;
}
static int
devlink_nl_param_value_fill_one(struct sk_buff *msg,
enum devlink_param_type type,
enum devlink_param_cmode cmode,
union devlink_param_value *val,
union devlink_param_value *default_val,
bool has_default)
{
struct nlattr *param_value_attr;
int err = -EMSGSIZE;
param_value_attr = nla_nest_start_noflag(msg,
DEVLINK_ATTR_PARAM_VALUE);
if (!param_value_attr)
return -EMSGSIZE;
if (nla_put_u8(msg, DEVLINK_ATTR_PARAM_VALUE_CMODE, cmode))
goto value_nest_cancel;
err = devlink_nl_param_value_put(msg, type,
DEVLINK_ATTR_PARAM_VALUE_DATA,
val, false);
if (err)
goto value_nest_cancel;
if (has_default) {
err = devlink_nl_param_value_put(msg, type,
DEVLINK_ATTR_PARAM_VALUE_DEFAULT,
default_val, true);
if (err)
goto value_nest_cancel;
}
nla_nest_end(msg, param_value_attr);
return 0;
value_nest_cancel:
nla_nest_cancel(msg, param_value_attr);
return err;
}
static int devlink_nl_param_fill(struct sk_buff *msg, struct devlink *devlink,
unsigned int port_index,
struct devlink_param_item *param_item,
enum devlink_command cmd,
u32 portid, u32 seq, int flags,
struct netlink_ext_ack *extack)
{
bool default_value_set[DEVLINK_PARAM_CMODE_MAX + 1] = {};
bool param_value_set[DEVLINK_PARAM_CMODE_MAX + 1] = {};
const struct devlink_param *param = param_item->param;
union devlink_param_value *default_value;
union devlink_param_value *param_value;
struct devlink_param_gset_ctx *ctx;
struct nlattr *param_values_list;
struct nlattr *param_attr;
void *hdr;
int err;
int i;
default_value = kcalloc(DEVLINK_PARAM_CMODE_MAX + 1,
sizeof(*default_value), GFP_KERNEL);
if (!default_value)
return -ENOMEM;
param_value = kcalloc(DEVLINK_PARAM_CMODE_MAX + 1,
sizeof(*param_value), GFP_KERNEL);
if (!param_value) {
kfree(default_value);
Annotation
- Immediate include surface: `devl_internal.h`.
- Detected declarations: `function devlink_param_generic_verify`, `function devlink_param_driver_verify`, `function devlink_param_find_by_name`, `function xa_for_each`, `function devlink_param_find_by_id`, `function devlink_param_cmode_is_supported`, `function devlink_param_get`, `function devlink_param_set`, `function devlink_param_get_default`, `function devlink_param_reset_default`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.