drivers/net/ethernet/marvell/prestera/prestera_router_hw.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/prestera/prestera_router_hw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/marvell/prestera/prestera_router_hw.c- Extension
.c- Size
- 17218 bytes
- Lines
- 689
- 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
linux/rhashtable.hprestera.hprestera_hw.hprestera_router_hw.hprestera_acl.h
Detected Declarations
function prestera_nh_neigh_key_is_validfunction prestera_router_hw_initfunction prestera_router_hw_finifunction list_for_each_entryfunction __prestera_vr_destroyfunction prestera_vr_putfunction __prestera_rif_entry_key_copyfunction prestera_rif_entry_findfunction list_for_each_entryfunction prestera_rif_entry_destroyfunction prestera_rif_entry_createfunction __prestera_nh_neigh_destroyfunction __prestera_nh_neigh_createfunction prestera_nh_neigh_findfunction prestera_nh_neigh_getfunction prestera_nh_neigh_putfunction prestera_nh_neigh_setfunction list_for_each_entryfunction prestera_nh_neigh_util_hw_statefunction __prestera_nexthop_group_createfunction __prestera_nexthop_group_destroyfunction __prestera_nexthop_group_findfunction prestera_nexthop_group_getfunction prestera_nexthop_group_putfunction prestera_nexthop_group_setfunction prestera_nexthop_group_util_hw_statefunction msecs_to_jiffiesfunction prestera_fib_node_findfunction __prestera_fib_node_destructfunction prestera_fib_node_destroyfunction prestera_fib_node_destroy_ht_cbfunction prestera_fib_node_create
Annotated Snippet
msecs_to_jiffies(PRESTERA_NH_ACTIVE_JIFFER_FILTER))) {
err = prestera_hw_nhgrp_blk_get(sw, cache, buf_size);
if (err) {
pr_err("Failed to get hw state nh_grp's");
return false;
}
sw->router->nhgrp_hw_cache_kick = jiffies;
}
if (cache[gid / 8] & BIT(gid % 8))
return true;
return false;
}
struct prestera_fib_node *
prestera_fib_node_find(struct prestera_switch *sw, struct prestera_fib_key *key)
{
struct prestera_fib_node *fib_node;
fib_node = rhashtable_lookup_fast(&sw->router->fib_ht, key,
__prestera_fib_ht_params);
return fib_node;
}
static void __prestera_fib_node_destruct(struct prestera_switch *sw,
struct prestera_fib_node *fib_node)
{
struct prestera_vr *vr;
vr = fib_node->info.vr;
prestera_hw_lpm_del(sw, vr->hw_vr_id, fib_node->key.addr.u.ipv4,
fib_node->key.prefix_len);
switch (fib_node->info.type) {
case PRESTERA_FIB_TYPE_UC_NH:
prestera_nexthop_group_put(sw, fib_node->info.nh_grp);
break;
case PRESTERA_FIB_TYPE_TRAP:
break;
case PRESTERA_FIB_TYPE_DROP:
break;
default:
pr_err("Unknown fib_node->info.type = %d",
fib_node->info.type);
}
prestera_vr_put(sw, vr);
}
void prestera_fib_node_destroy(struct prestera_switch *sw,
struct prestera_fib_node *fib_node)
{
__prestera_fib_node_destruct(sw, fib_node);
rhashtable_remove_fast(&sw->router->fib_ht, &fib_node->ht_node,
__prestera_fib_ht_params);
kfree(fib_node);
}
static void prestera_fib_node_destroy_ht_cb(void *ptr, void *arg)
{
struct prestera_fib_node *node = ptr;
struct prestera_switch *sw = arg;
__prestera_fib_node_destruct(sw, node);
kfree(node);
}
struct prestera_fib_node *
prestera_fib_node_create(struct prestera_switch *sw,
struct prestera_fib_key *key,
enum prestera_fib_type fib_type,
struct prestera_nexthop_group_key *nh_grp_key)
{
struct prestera_fib_node *fib_node;
u32 grp_id;
struct prestera_vr *vr;
int err;
fib_node = kzalloc_obj(*fib_node);
if (!fib_node)
goto err_kzalloc;
memcpy(&fib_node->key, key, sizeof(*key));
fib_node->info.type = fib_type;
vr = prestera_vr_get(sw, key->tb_id, NULL);
if (IS_ERR(vr))
goto err_vr_get;
Annotation
- Immediate include surface: `linux/rhashtable.h`, `prestera.h`, `prestera_hw.h`, `prestera_router_hw.h`, `prestera_acl.h`.
- Detected declarations: `function prestera_nh_neigh_key_is_valid`, `function prestera_router_hw_init`, `function prestera_router_hw_fini`, `function list_for_each_entry`, `function __prestera_vr_destroy`, `function prestera_vr_put`, `function __prestera_rif_entry_key_copy`, `function prestera_rif_entry_find`, `function list_for_each_entry`, `function prestera_rif_entry_destroy`.
- 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.