drivers/net/ethernet/mediatek/mtk_ppe_offload.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mediatek/mtk_ppe_offload.c- Extension
.c- Size
- 15002 bytes
- Lines
- 678
- 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/if_ether.hlinux/rhashtable.hlinux/ip.hlinux/ipv6.hnet/flow_offload.hnet/pkt_cls.hnet/dsa.hmtk_eth_soc.hmtk_wed.h
Detected Declarations
struct mtk_flow_datafunction mtk_flow_set_ipv4_addrfunction mtk_flow_set_ipv6_addrfunction mtk_flow_offload_mangle_ethfunction mtk_flow_get_wdma_infofunction mtk_flow_mangle_portsfunction mtk_flow_mangle_ipv4function mtk_flow_get_dsa_portfunction mtk_flow_set_output_devicefunction mtk_flow_is_valid_idevfunction mtk_flow_offload_replacefunction flow_action_for_eachfunction flow_action_for_eachfunction mtk_flow_offload_destroyfunction mtk_flow_offload_statsfunction mtk_flow_offload_cmdfunction mtk_eth_setup_tc_block_cbfunction mtk_eth_setup_tc_blockfunction mtk_eth_setup_tcfunction mtk_eth_offload_init
Annotated Snippet
struct mtk_flow_data {
struct ethhdr eth;
union {
struct {
__be32 src_addr;
__be32 dst_addr;
} v4;
struct {
struct in6_addr src_addr;
struct in6_addr dst_addr;
} v6;
};
__be16 src_port;
__be16 dst_port;
u16 vlan_in;
struct {
struct {
u16 id;
__be16 proto;
} vlans[2];
u8 num;
} vlan;
struct {
u16 sid;
u8 num;
} pppoe;
};
static const struct rhashtable_params mtk_flow_ht_params = {
.head_offset = offsetof(struct mtk_flow_entry, node),
.key_offset = offsetof(struct mtk_flow_entry, cookie),
.key_len = sizeof(unsigned long),
.automatic_shrinking = true,
};
static int
mtk_flow_set_ipv4_addr(struct mtk_eth *eth, struct mtk_foe_entry *foe,
struct mtk_flow_data *data, bool egress)
{
return mtk_foe_entry_set_ipv4_tuple(eth, foe, egress,
data->v4.src_addr, data->src_port,
data->v4.dst_addr, data->dst_port);
}
static int
mtk_flow_set_ipv6_addr(struct mtk_eth *eth, struct mtk_foe_entry *foe,
struct mtk_flow_data *data)
{
return mtk_foe_entry_set_ipv6_tuple(eth, foe,
data->v6.src_addr.s6_addr32, data->src_port,
data->v6.dst_addr.s6_addr32, data->dst_port);
}
static void
mtk_flow_offload_mangle_eth(const struct flow_action_entry *act, void *eth)
{
void *dest = eth + act->mangle.offset;
const void *src = &act->mangle.val;
if (act->mangle.offset > 8)
return;
if (act->mangle.mask == 0xffff) {
src += 2;
dest += 2;
}
memcpy(dest, src, act->mangle.mask ? 2 : 4);
}
static int
mtk_flow_get_wdma_info(struct net_device *dev, const u8 *addr, struct mtk_wdma_info *info)
{
struct net_device_path_stack stack;
struct net_device_path *path;
int err;
if (!dev)
return -ENODEV;
if (!IS_ENABLED(CONFIG_NET_MEDIATEK_SOC_WED))
return -1;
rcu_read_lock();
err = dev_fill_forward_path(dev, addr, &stack);
Annotation
- Immediate include surface: `linux/if_ether.h`, `linux/rhashtable.h`, `linux/ip.h`, `linux/ipv6.h`, `net/flow_offload.h`, `net/pkt_cls.h`, `net/dsa.h`, `mtk_eth_soc.h`.
- Detected declarations: `struct mtk_flow_data`, `function mtk_flow_set_ipv4_addr`, `function mtk_flow_set_ipv6_addr`, `function mtk_flow_offload_mangle_eth`, `function mtk_flow_get_wdma_info`, `function mtk_flow_mangle_ports`, `function mtk_flow_mangle_ipv4`, `function mtk_flow_get_dsa_port`, `function mtk_flow_set_output_device`, `function mtk_flow_is_valid_idev`.
- 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.