net/devlink/sb.c
Source file repositories/reference/linux-study-clean/net/devlink/sb.c
File Facts
- System
- Linux kernel
- Corpus path
net/devlink/sb.c- Extension
.c- Size
- 25511 bytes
- Lines
- 996
- 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
devl_internal.h
Detected Declarations
struct devlink_sbfunction devlink_sb_pool_countfunction list_for_each_entryfunction devlink_sb_index_existsfunction devlink_sb_pool_index_get_from_attrsfunction devlink_sb_pool_index_get_from_infofunction devlink_sb_pool_type_get_from_attrsfunction devlink_sb_pool_type_get_from_infofunction devlink_sb_th_type_get_from_attrsfunction devlink_sb_th_type_get_from_infofunction devlink_sb_tc_index_get_from_attrsfunction devlink_sb_tc_index_get_from_infofunction devlink_nl_sb_fillfunction devlink_nl_sb_get_doitfunction devlink_nl_sb_get_dump_onefunction list_for_each_entryfunction devlink_nl_sb_get_dumpitfunction devlink_nl_sb_pool_fillfunction devlink_nl_sb_pool_get_doitfunction __sb_pool_get_dumpitfunction devlink_nl_sb_pool_get_dump_onefunction list_for_each_entryfunction devlink_nl_sb_pool_get_dumpitfunction devlink_sb_pool_setfunction devlink_nl_sb_pool_set_doitfunction devlink_nl_sb_port_pool_fillfunction devlink_nl_sb_port_pool_get_doitfunction __sb_port_pool_get_dumpitfunction xa_for_eachfunction devlink_nl_sb_port_pool_get_dump_onefunction list_for_each_entryfunction devlink_nl_sb_port_pool_get_dumpitfunction devlink_sb_port_pool_setfunction devlink_nl_sb_port_pool_set_doitfunction devlink_nl_sb_tc_pool_bind_fillfunction devlink_nl_sb_tc_pool_bind_get_doitfunction __sb_tc_pool_bind_get_dumpitfunction xa_for_eachfunction devlink_nl_sb_tc_pool_bind_get_dump_onefunction list_for_each_entryfunction devlink_nl_sb_tc_pool_bind_get_dumpitfunction devlink_sb_tc_pool_bind_setfunction devlink_nl_sb_tc_pool_bind_set_doitfunction devlink_nl_sb_occ_snapshot_doitfunction devlink_nl_sb_occ_max_clear_doitfunction devl_sb_registerfunction devlink_sb_registerfunction devl_sb_unregister
Annotated Snippet
struct devlink_sb {
struct list_head list;
unsigned int index;
u32 size;
u16 ingress_pools_count;
u16 egress_pools_count;
u16 ingress_tc_count;
u16 egress_tc_count;
};
static u16 devlink_sb_pool_count(struct devlink_sb *devlink_sb)
{
return devlink_sb->ingress_pools_count + devlink_sb->egress_pools_count;
}
static struct devlink_sb *devlink_sb_get_by_index(struct devlink *devlink,
unsigned int sb_index)
{
struct devlink_sb *devlink_sb;
list_for_each_entry(devlink_sb, &devlink->sb_list, list) {
if (devlink_sb->index == sb_index)
return devlink_sb;
}
return NULL;
}
static bool devlink_sb_index_exists(struct devlink *devlink,
unsigned int sb_index)
{
return devlink_sb_get_by_index(devlink, sb_index);
}
static struct devlink_sb *devlink_sb_get_from_attrs(struct devlink *devlink,
struct nlattr **attrs)
{
if (attrs[DEVLINK_ATTR_SB_INDEX]) {
u32 sb_index = nla_get_u32(attrs[DEVLINK_ATTR_SB_INDEX]);
struct devlink_sb *devlink_sb;
devlink_sb = devlink_sb_get_by_index(devlink, sb_index);
if (!devlink_sb)
return ERR_PTR(-ENODEV);
return devlink_sb;
}
return ERR_PTR(-EINVAL);
}
static struct devlink_sb *devlink_sb_get_from_info(struct devlink *devlink,
struct genl_info *info)
{
return devlink_sb_get_from_attrs(devlink, info->attrs);
}
static int devlink_sb_pool_index_get_from_attrs(struct devlink_sb *devlink_sb,
struct nlattr **attrs,
u16 *p_pool_index)
{
u16 val;
if (!attrs[DEVLINK_ATTR_SB_POOL_INDEX])
return -EINVAL;
val = nla_get_u16(attrs[DEVLINK_ATTR_SB_POOL_INDEX]);
if (val >= devlink_sb_pool_count(devlink_sb))
return -EINVAL;
*p_pool_index = val;
return 0;
}
static int devlink_sb_pool_index_get_from_info(struct devlink_sb *devlink_sb,
struct genl_info *info,
u16 *p_pool_index)
{
return devlink_sb_pool_index_get_from_attrs(devlink_sb, info->attrs,
p_pool_index);
}
static int
devlink_sb_pool_type_get_from_attrs(struct nlattr **attrs,
enum devlink_sb_pool_type *p_pool_type)
{
u8 val;
if (!attrs[DEVLINK_ATTR_SB_POOL_TYPE])
return -EINVAL;
val = nla_get_u8(attrs[DEVLINK_ATTR_SB_POOL_TYPE]);
if (val != DEVLINK_SB_POOL_TYPE_INGRESS &&
val != DEVLINK_SB_POOL_TYPE_EGRESS)
Annotation
- Immediate include surface: `devl_internal.h`.
- Detected declarations: `struct devlink_sb`, `function devlink_sb_pool_count`, `function list_for_each_entry`, `function devlink_sb_index_exists`, `function devlink_sb_pool_index_get_from_attrs`, `function devlink_sb_pool_index_get_from_info`, `function devlink_sb_pool_type_get_from_attrs`, `function devlink_sb_pool_type_get_from_info`, `function devlink_sb_th_type_get_from_attrs`, `function devlink_sb_th_type_get_from_info`.
- 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.