drivers/net/ethernet/mediatek/mtk_ppe.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mediatek/mtk_ppe.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mediatek/mtk_ppe.c- Extension
.c- Size
- 28974 bytes
- Lines
- 1141
- 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.
- 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/kernel.hlinux/io.hlinux/iopoll.hlinux/etherdevice.hlinux/platform_device.hlinux/if_ether.hlinux/if_vlan.hnet/dst_metadata.hnet/dsa.hnet/ipv6.hmtk_eth_soc.hmtk_ppe.hmtk_ppe_regs.h
Detected Declarations
function ppe_w32function ppe_r32function ppe_m32function ppe_setfunction ppe_clearfunction mtk_eth_timestampfunction mtk_ppe_wait_busyfunction mtk_ppe_mib_wait_busyfunction mtk_mib_entry_readfunction mtk_ppe_cache_clearfunction mtk_ppe_cache_enablefunction mtk_ppe_hash_entryfunction mtk_foe_entry_l2function mtk_foe_entry_ib2function mtk_foe_entry_preparefunction mtk_foe_entry_set_pse_portfunction mtk_foe_entry_set_ipv4_tuplefunction mtk_foe_entry_set_ipv6_tuplefunction mtk_foe_entry_set_dsafunction mtk_foe_entry_set_vlanfunction mtk_foe_entry_set_pppoefunction mtk_foe_entry_set_wdmafunction mtk_foe_entry_set_queuefunction mtk_flow_entry_matchfunction __mtk_foe_entry_clearfunction __mtk_foe_entry_idle_timefunction mtk_flow_entry_update_l2function mtk_flow_entry_updatefunction __mtk_foe_entry_commitfunction mtk_foe_entry_clearfunction mtk_foe_entry_commit_l2function mtk_foe_entry_commitfunction mtk_foe_entry_commit_subflowfunction __mtk_ppe_check_skbfunction hlist_for_each_entry_safefunction mtk_foe_entry_idle_timefunction mtk_ppe_prepare_resetfunction mtk_ppe_deinitfunction mtk_ppe_init_foe_tablefunction mtk_ppe_update_mtufunction mtk_ppe_startfunction mtk_ppe_stop
Annotated Snippet
if (egress) {
t = &entry->ipv4.new;
break;
}
fallthrough;
case MTK_PPE_PKT_TYPE_IPV4_DSLITE:
case MTK_PPE_PKT_TYPE_IPV4_ROUTE:
t = &entry->ipv4.orig;
break;
case MTK_PPE_PKT_TYPE_IPV6_6RD:
entry->ipv6_6rd.tunnel_src_ip = be32_to_cpu(src_addr);
entry->ipv6_6rd.tunnel_dest_ip = be32_to_cpu(dest_addr);
return 0;
default:
WARN_ON_ONCE(1);
return -EINVAL;
}
t->src_ip = be32_to_cpu(src_addr);
t->dest_ip = be32_to_cpu(dest_addr);
if (type == MTK_PPE_PKT_TYPE_IPV4_ROUTE)
return 0;
t->src_port = be16_to_cpu(src_port);
t->dest_port = be16_to_cpu(dest_port);
return 0;
}
int mtk_foe_entry_set_ipv6_tuple(struct mtk_eth *eth,
struct mtk_foe_entry *entry,
__be32 *src_addr, __be16 src_port,
__be32 *dest_addr, __be16 dest_port)
{
int type = mtk_get_ib1_pkt_type(eth, entry->ib1);
u32 *src, *dest;
switch (type) {
case MTK_PPE_PKT_TYPE_IPV4_DSLITE:
src = entry->dslite.tunnel_src_ip;
dest = entry->dslite.tunnel_dest_ip;
break;
case MTK_PPE_PKT_TYPE_IPV6_ROUTE_5T:
case MTK_PPE_PKT_TYPE_IPV6_6RD:
entry->ipv6.src_port = be16_to_cpu(src_port);
entry->ipv6.dest_port = be16_to_cpu(dest_port);
fallthrough;
case MTK_PPE_PKT_TYPE_IPV6_ROUTE_3T:
src = entry->ipv6.src_ip;
dest = entry->ipv6.dest_ip;
break;
default:
WARN_ON_ONCE(1);
return -EINVAL;
}
ipv6_addr_be32_to_cpu(src, src_addr);
ipv6_addr_be32_to_cpu(dest, dest_addr);
return 0;
}
int mtk_foe_entry_set_dsa(struct mtk_eth *eth, struct mtk_foe_entry *entry,
int port)
{
struct mtk_foe_mac_info *l2 = mtk_foe_entry_l2(eth, entry);
l2->etype = BIT(port);
if (!(entry->ib1 & mtk_get_ib1_vlan_layer_mask(eth)))
entry->ib1 |= mtk_prep_ib1_vlan_layer(eth, 1);
else
l2->etype |= BIT(8);
entry->ib1 &= ~mtk_get_ib1_vlan_tag_mask(eth);
return 0;
}
int mtk_foe_entry_set_vlan(struct mtk_eth *eth, struct mtk_foe_entry *entry,
int vid)
{
struct mtk_foe_mac_info *l2 = mtk_foe_entry_l2(eth, entry);
switch (mtk_get_ib1_vlan_layer(eth, entry->ib1)) {
case 0:
entry->ib1 |= mtk_get_ib1_vlan_tag_mask(eth) |
mtk_prep_ib1_vlan_layer(eth, 1);
l2->vlan1 = vid;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/io.h`, `linux/iopoll.h`, `linux/etherdevice.h`, `linux/platform_device.h`, `linux/if_ether.h`, `linux/if_vlan.h`, `net/dst_metadata.h`.
- Detected declarations: `function ppe_w32`, `function ppe_r32`, `function ppe_m32`, `function ppe_set`, `function ppe_clear`, `function mtk_eth_timestamp`, `function mtk_ppe_wait_busy`, `function mtk_ppe_mib_wait_busy`, `function mtk_mib_entry_read`, `function mtk_ppe_cache_clear`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source 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.