drivers/net/ethernet/microchip/lan966x/lan966x_fdb.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/microchip/lan966x/lan966x_fdb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/microchip/lan966x/lan966x_fdb.c- Extension
.c- Size
- 7238 bytes
- Lines
- 290
- 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/switchdev.hlan966x_main.h
Detected Declarations
struct lan966x_fdb_event_workstruct lan966x_fdb_entryfunction lan966x_fdb_find_entryfunction list_for_each_entryfunction lan966x_fdb_add_entryfunction lan966x_fdb_del_entryfunction list_for_each_entry_safefunction lan966x_fdb_write_entriesfunction list_for_each_entryfunction lan966x_fdb_erase_entriesfunction list_for_each_entryfunction lan966x_fdb_purge_entriesfunction list_for_each_entry_safefunction lan966x_fdb_initfunction lan966x_fdb_deinitfunction lan966x_fdb_flush_workqueuefunction lan966x_fdb_port_event_workfunction lan966x_fdb_bridge_event_workfunction lan966x_fdb_lag_event_workfunction lan966x_fdb_event_workfunction lan966x_handle_fdb
Annotated Snippet
struct lan966x_fdb_event_work {
struct work_struct work;
struct switchdev_notifier_fdb_info fdb_info;
struct net_device *dev;
struct net_device *orig_dev;
struct lan966x *lan966x;
unsigned long event;
};
struct lan966x_fdb_entry {
struct list_head list;
unsigned char mac[ETH_ALEN] __aligned(2);
u16 vid;
u32 references;
};
static struct lan966x_fdb_entry *
lan966x_fdb_find_entry(struct lan966x *lan966x,
struct switchdev_notifier_fdb_info *fdb_info)
{
struct lan966x_fdb_entry *fdb_entry;
list_for_each_entry(fdb_entry, &lan966x->fdb_entries, list) {
if (fdb_entry->vid == fdb_info->vid &&
ether_addr_equal(fdb_entry->mac, fdb_info->addr))
return fdb_entry;
}
return NULL;
}
static void lan966x_fdb_add_entry(struct lan966x *lan966x,
struct switchdev_notifier_fdb_info *fdb_info)
{
struct lan966x_fdb_entry *fdb_entry;
fdb_entry = lan966x_fdb_find_entry(lan966x, fdb_info);
if (fdb_entry) {
fdb_entry->references++;
return;
}
fdb_entry = kzalloc_obj(*fdb_entry);
if (!fdb_entry)
return;
ether_addr_copy(fdb_entry->mac, fdb_info->addr);
fdb_entry->vid = fdb_info->vid;
fdb_entry->references = 1;
list_add_tail(&fdb_entry->list, &lan966x->fdb_entries);
}
static bool lan966x_fdb_del_entry(struct lan966x *lan966x,
struct switchdev_notifier_fdb_info *fdb_info)
{
struct lan966x_fdb_entry *fdb_entry, *tmp;
list_for_each_entry_safe(fdb_entry, tmp, &lan966x->fdb_entries,
list) {
if (fdb_entry->vid == fdb_info->vid &&
ether_addr_equal(fdb_entry->mac, fdb_info->addr)) {
fdb_entry->references--;
if (!fdb_entry->references) {
list_del(&fdb_entry->list);
kfree(fdb_entry);
return true;
}
break;
}
}
return false;
}
void lan966x_fdb_write_entries(struct lan966x *lan966x, u16 vid)
{
struct lan966x_fdb_entry *fdb_entry;
list_for_each_entry(fdb_entry, &lan966x->fdb_entries, list) {
if (fdb_entry->vid != vid)
continue;
lan966x_mac_cpu_learn(lan966x, fdb_entry->mac, fdb_entry->vid);
}
}
void lan966x_fdb_erase_entries(struct lan966x *lan966x, u16 vid)
{
struct lan966x_fdb_entry *fdb_entry;
Annotation
- Immediate include surface: `net/switchdev.h`, `lan966x_main.h`.
- Detected declarations: `struct lan966x_fdb_event_work`, `struct lan966x_fdb_entry`, `function lan966x_fdb_find_entry`, `function list_for_each_entry`, `function lan966x_fdb_add_entry`, `function lan966x_fdb_del_entry`, `function list_for_each_entry_safe`, `function lan966x_fdb_write_entries`, `function list_for_each_entry`, `function lan966x_fdb_erase_entries`.
- 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.