drivers/net/ethernet/marvell/prestera/prestera_devlink.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/prestera/prestera_devlink.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/marvell/prestera/prestera_devlink.c- Extension
.c- Size
- 16301 bytes
- Lines
- 600
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- 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/devlink.hprestera_devlink.hprestera_hw.h
Detected Declarations
struct prestera_trapstruct prestera_trap_itemstruct prestera_trap_datafunction prestera_dl_info_getfunction prestera_devlink_freefunction prestera_devlink_registerfunction prestera_devlink_unregisterfunction prestera_devlink_port_registerfunction prestera_devlink_port_unregisterfunction prestera_devlink_traps_registerfunction prestera_get_trap_item_by_cpu_codefunction prestera_devlink_trap_reportfunction prestera_devlink_trap_item_lookupfunction prestera_trap_initfunction prestera_trap_action_setfunction prestera_drop_counter_getfunction prestera_devlink_traps_unregister
Annotated Snippet
struct prestera_trap {
struct devlink_trap trap;
u8 cpu_code;
};
struct prestera_trap_item {
enum devlink_trap_action action;
void *trap_ctx;
};
struct prestera_trap_data {
struct prestera_switch *sw;
struct prestera_trap_item *trap_items_arr;
u32 traps_count;
};
#define PRESTERA_TRAP_METADATA DEVLINK_TRAP_METADATA_TYPE_F_IN_PORT
#define PRESTERA_TRAP_CONTROL(_id, _group_id, _action) \
DEVLINK_TRAP_GENERIC(CONTROL, _action, _id, \
DEVLINK_TRAP_GROUP_GENERIC_ID_##_group_id, \
PRESTERA_TRAP_METADATA)
#define PRESTERA_TRAP_DRIVER_CONTROL(_id, _group_id) \
DEVLINK_TRAP_DRIVER(CONTROL, TRAP, DEVLINK_PRESTERA_TRAP_ID_##_id, \
DEVLINK_PRESTERA_TRAP_NAME_##_id, \
DEVLINK_TRAP_GROUP_GENERIC_ID_##_group_id, \
PRESTERA_TRAP_METADATA)
#define PRESTERA_TRAP_EXCEPTION(_id, _group_id) \
DEVLINK_TRAP_GENERIC(EXCEPTION, TRAP, _id, \
DEVLINK_TRAP_GROUP_GENERIC_ID_##_group_id, \
PRESTERA_TRAP_METADATA)
#define PRESTERA_TRAP_DRIVER_EXCEPTION(_id, _group_id) \
DEVLINK_TRAP_DRIVER(EXCEPTION, TRAP, DEVLINK_PRESTERA_TRAP_ID_##_id, \
DEVLINK_PRESTERA_TRAP_NAME_##_id, \
DEVLINK_TRAP_GROUP_GENERIC_ID_##_group_id, \
PRESTERA_TRAP_METADATA)
#define PRESTERA_TRAP_DRIVER_DROP(_id, _group_id) \
DEVLINK_TRAP_DRIVER(DROP, DROP, DEVLINK_PRESTERA_TRAP_ID_##_id, \
DEVLINK_PRESTERA_TRAP_NAME_##_id, \
DEVLINK_TRAP_GROUP_GENERIC_ID_##_group_id, \
PRESTERA_TRAP_METADATA)
static const struct devlink_trap_group prestera_trap_groups_arr[] = {
/* No policer is associated with following groups (policerid == 0)*/
DEVLINK_TRAP_GROUP_GENERIC(L2_DROPS, 0),
DEVLINK_TRAP_GROUP_GENERIC(L3_DROPS, 0),
DEVLINK_TRAP_GROUP_GENERIC(L3_EXCEPTIONS, 0),
DEVLINK_TRAP_GROUP_GENERIC(NEIGH_DISCOVERY, 0),
DEVLINK_TRAP_GROUP_GENERIC(ACL_TRAP, 0),
DEVLINK_TRAP_GROUP_GENERIC(ACL_DROPS, 0),
DEVLINK_TRAP_GROUP_GENERIC(ACL_SAMPLE, 0),
DEVLINK_TRAP_GROUP_GENERIC(OSPF, 0),
DEVLINK_TRAP_GROUP_GENERIC(STP, 0),
DEVLINK_TRAP_GROUP_GENERIC(LACP, 0),
DEVLINK_TRAP_GROUP_GENERIC(LLDP, 0),
DEVLINK_TRAP_GROUP_GENERIC(VRRP, 0),
DEVLINK_TRAP_GROUP_GENERIC(DHCP, 0),
DEVLINK_TRAP_GROUP_GENERIC(BGP, 0),
DEVLINK_TRAP_GROUP_GENERIC(LOCAL_DELIVERY, 0),
DEVLINK_TRAP_GROUP_GENERIC(BUFFER_DROPS, 0),
};
/* Initialize trap list, as well as associate CPU code with them. */
static struct prestera_trap prestera_trap_items_arr[] = {
{
.trap = PRESTERA_TRAP_DRIVER_CONTROL(ARP_BC, NEIGH_DISCOVERY),
.cpu_code = 5,
},
{
.trap = PRESTERA_TRAP_DRIVER_CONTROL(IS_IS, LOCAL_DELIVERY),
.cpu_code = 13,
},
{
.trap = PRESTERA_TRAP_DRIVER_CONTROL(OSPF, OSPF),
.cpu_code = 16,
},
{
.trap = PRESTERA_TRAP_DRIVER_CONTROL(IP_BC_MAC, LOCAL_DELIVERY),
.cpu_code = 19,
},
{
.trap = PRESTERA_TRAP_CONTROL(STP, STP, TRAP),
.cpu_code = 26,
},
{
.trap = PRESTERA_TRAP_CONTROL(LACP, LACP, TRAP),
Annotation
- Immediate include surface: `net/devlink.h`, `prestera_devlink.h`, `prestera_hw.h`.
- Detected declarations: `struct prestera_trap`, `struct prestera_trap_item`, `struct prestera_trap_data`, `function prestera_dl_info_get`, `function prestera_devlink_free`, `function prestera_devlink_register`, `function prestera_devlink_unregister`, `function prestera_devlink_port_register`, `function prestera_devlink_port_unregister`, `function prestera_devlink_traps_register`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source 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.