drivers/net/ethernet/airoha/airoha_ppe.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/airoha/airoha_ppe.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/airoha/airoha_ppe.c- Extension
.c- Size
- 42504 bytes
- Lines
- 1654
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/ip.hlinux/ipv6.hlinux/of_platform.hlinux/platform_device.hlinux/rhashtable.hnet/ipv6.hnet/pkt_cls.hairoha_regs.hairoha_eth.h
Detected Declarations
function airoha_ppe_get_num_stats_entriesfunction airoha_ppe_get_total_num_stats_entriesfunction airoha_ppe_get_total_sram_num_entriesfunction airoha_ppe_get_total_num_entriesfunction airoha_ppe_is_enabledfunction airoha_ppe_get_timestampfunction airoha_ppe_set_cpu_portfunction airoha_ppe_hw_initfunction airoha_ppe_flow_mangle_ethfunction airoha_ppe_flow_mangle_portsfunction airoha_ppe_flow_mangle_ipv4function airoha_ppe_get_wdma_infofunction airoha_get_dsa_portfunction airoha_ppe_foe_set_bridge_addrsfunction airoha_ppe_foe_entry_preparefunction airoha_ppe_foe_entry_set_ipv4_tuplefunction airoha_ppe_foe_entry_set_ipv6_tuplefunction airoha_ppe_foe_get_entry_hashfunction airoha_ppe_foe_get_flow_stats_indexfunction airoha_ppe_foe_flow_stat_entry_resetfunction airoha_ppe_foe_flow_stats_resetfunction airoha_ppe_foe_flow_stats_updatefunction airoha_ppe_foe_get_entry_lockedfunction airoha_ppe_foe_compare_entryfunction airoha_ppe_foe_commit_sram_entryfunction airoha_ppe_foe_commit_entryfunction airoha_ppe_foe_remove_flowfunction airoha_ppe_foe_remove_l2_flowfunction airoha_ppe_foe_flow_remove_entryfunction airoha_ppe_foe_commit_subflow_entryfunction airoha_ppe_foe_insert_entryfunction airoha_ppe_foe_l2_flow_commit_entryfunction airoha_ppe_foe_flow_commit_entryfunction airoha_ppe_get_entry_idle_timefunction airoha_ppe_foe_flow_l2_entry_updatefunction hlist_for_each_entry_safefunction airoha_ppe_foe_flow_entry_updatefunction airoha_ppe_entry_idle_timefunction airoha_ppe_flow_offload_replacefunction flow_action_for_eachfunction flow_action_for_eachfunction airoha_ppe_flow_offload_destroyfunction airoha_ppe_foe_entry_get_statsfunction airoha_ppe_flow_offload_statsfunction airoha_ppe_flow_offload_cmdfunction airoha_ppe_flush_sram_entriesfunction airoha_ppe_wait_for_npu_initfunction airoha_ppe_offload_setup
Annotated Snippet
if (egress) {
t = &hwe->ipv4.new_tuple;
break;
}
fallthrough;
case PPE_PKT_TYPE_IPV4_DSLITE:
case PPE_PKT_TYPE_IPV4_ROUTE:
t = &hwe->ipv4.orig_tuple;
break;
default:
WARN_ON_ONCE(1);
return -EINVAL;
}
t->src_ip = be32_to_cpu(data->v4.src_addr);
t->dest_ip = be32_to_cpu(data->v4.dst_addr);
if (type != PPE_PKT_TYPE_IPV4_ROUTE) {
t->src_port = be16_to_cpu(data->src_port);
t->dest_port = be16_to_cpu(data->dst_port);
}
return 0;
}
static int airoha_ppe_foe_entry_set_ipv6_tuple(struct airoha_foe_entry *hwe,
struct airoha_flow_data *data)
{
int type = FIELD_GET(AIROHA_FOE_IB1_BIND_PACKET_TYPE, hwe->ib1);
u32 *src, *dest;
switch (type) {
case PPE_PKT_TYPE_IPV6_ROUTE_5T:
case PPE_PKT_TYPE_IPV6_6RD:
hwe->ipv6.src_port = be16_to_cpu(data->src_port);
hwe->ipv6.dest_port = be16_to_cpu(data->dst_port);
fallthrough;
case PPE_PKT_TYPE_IPV6_ROUTE_3T:
src = hwe->ipv6.src_ip;
dest = hwe->ipv6.dest_ip;
break;
default:
WARN_ON_ONCE(1);
return -EINVAL;
}
ipv6_addr_be32_to_cpu(src, data->v6.src_addr.s6_addr32);
ipv6_addr_be32_to_cpu(dest, data->v6.dst_addr.s6_addr32);
return 0;
}
static u32 airoha_ppe_foe_get_entry_hash(struct airoha_ppe *ppe,
struct airoha_foe_entry *hwe)
{
int type = FIELD_GET(AIROHA_FOE_IB1_BIND_PACKET_TYPE, hwe->ib1);
u32 ppe_hash_mask = airoha_ppe_get_total_num_entries(ppe) - 1;
u32 hash, hv1, hv2, hv3;
switch (type) {
case PPE_PKT_TYPE_IPV4_ROUTE:
case PPE_PKT_TYPE_IPV4_HNAPT:
hv1 = hwe->ipv4.orig_tuple.ports;
hv2 = hwe->ipv4.orig_tuple.dest_ip;
hv3 = hwe->ipv4.orig_tuple.src_ip;
break;
case PPE_PKT_TYPE_IPV6_ROUTE_3T:
case PPE_PKT_TYPE_IPV6_ROUTE_5T:
hv1 = hwe->ipv6.src_ip[3] ^ hwe->ipv6.dest_ip[3];
hv1 ^= hwe->ipv6.ports;
hv2 = hwe->ipv6.src_ip[2] ^ hwe->ipv6.dest_ip[2];
hv2 ^= hwe->ipv6.dest_ip[0];
hv3 = hwe->ipv6.src_ip[1] ^ hwe->ipv6.dest_ip[1];
hv3 ^= hwe->ipv6.src_ip[0];
break;
case PPE_PKT_TYPE_BRIDGE: {
struct airoha_foe_mac_info *l2 = &hwe->bridge.l2;
hv1 = l2->common.src_mac_hi & 0xffff;
hv1 = hv1 << 16 | l2->src_mac_lo;
hv2 = l2->common.dest_mac_lo;
hv2 = hv2 << 16;
hv2 = hv2 | ((l2->common.src_mac_hi & 0xffff0000) >> 16);
hv3 = l2->common.dest_mac_hi;
break;
Annotation
- Immediate include surface: `linux/ip.h`, `linux/ipv6.h`, `linux/of_platform.h`, `linux/platform_device.h`, `linux/rhashtable.h`, `net/ipv6.h`, `net/pkt_cls.h`, `airoha_regs.h`.
- Detected declarations: `function airoha_ppe_get_num_stats_entries`, `function airoha_ppe_get_total_num_stats_entries`, `function airoha_ppe_get_total_sram_num_entries`, `function airoha_ppe_get_total_num_entries`, `function airoha_ppe_is_enabled`, `function airoha_ppe_get_timestamp`, `function airoha_ppe_set_cpu_port`, `function airoha_ppe_hw_init`, `function airoha_ppe_flow_mangle_eth`, `function airoha_ppe_flow_mangle_ports`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.