drivers/net/ethernet/mediatek/mtk_wed.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mediatek/mtk_wed.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mediatek/mtk_wed.c- Extension
.c- Size
- 76419 bytes
- Lines
- 2903
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/platform_device.hlinux/slab.hlinux/module.hlinux/bitfield.hlinux/dma-mapping.hlinux/skbuff.hlinux/of_platform.hlinux/of_address.hlinux/of_reserved_mem.hlinux/mfd/syscon.hlinux/debugfs.hlinux/soc/mediatek/mtk_wed.hnet/flow_offload.hnet/pkt_cls.hmtk_eth_soc.hmtk_wed.hmtk_ppe.hmtk_wed_wo.h
Detected Declarations
struct mtk_wed_flow_block_privfunction wed_m32function wed_setfunction wed_clrfunction wdma_m32function wdma_setfunction wdma_clrfunction wifi_r32function wifi_w32function mtk_wed_read_resetfunction mtk_wdma_read_resetfunction mtk_wdma_v3_rx_resetfunction mtk_wdma_rx_resetfunction mtk_wed_check_busyfunction mtk_wed_poll_busyfunction mtk_wdma_v3_tx_resetfunction mtk_wdma_tx_resetfunction mtk_wed_resetfunction mtk_wed_wo_read_statusfunction mtk_wed_wo_resetfunction mtk_wed_fe_resetfunction mtk_wed_fe_reset_completefunction mtk_wed_assignfunction mtk_wed_amsdu_buffer_allocfunction mtk_wed_amsdu_free_bufferfunction mtk_wed_amsdu_initfunction mtk_wed_tx_buffer_allocfunction mtk_wed_free_tx_bufferfunction mtk_wed_hwrro_buffer_allocfunction mtk_wed_rx_buffer_allocfunction mtk_wed_hwrro_free_bufferfunction mtk_wed_free_rx_bufferfunction mtk_wed_hwrro_initfunction mtk_wed_rx_buffer_hw_initfunction mtk_wed_free_ringfunction mtk_wed_free_rx_ringsfunction mtk_wed_free_tx_ringsfunction mtk_wed_set_ext_intfunction mtk_wed_set_512_supportfunction mtk_wed_check_wfdma_rx_fillfunction mtk_wed_dma_disablefunction mtk_wed_stopfunction mtk_wed_deinitfunction __mtk_wed_detachfunction mtk_wed_detachfunction mtk_wed_bus_initfunction mtk_wed_set_wpdmafunction mtk_wed_hw_init_early
Annotated Snippet
struct mtk_wed_flow_block_priv {
struct mtk_wed_hw *hw;
struct net_device *dev;
};
static const struct mtk_wed_soc_data mt7622_data = {
.regmap = {
.tx_bm_tkid = 0x088,
.wpdma_rx_ring = {
0x770,
},
.reset_idx_tx_mask = GENMASK(3, 0),
.reset_idx_rx_mask = GENMASK(17, 16),
},
.tx_ring_desc_size = sizeof(struct mtk_wdma_desc),
.wdma_desc_size = sizeof(struct mtk_wdma_desc),
};
static const struct mtk_wed_soc_data mt7986_data = {
.regmap = {
.tx_bm_tkid = 0x0c8,
.wpdma_rx_ring = {
0x770,
},
.reset_idx_tx_mask = GENMASK(1, 0),
.reset_idx_rx_mask = GENMASK(7, 6),
},
.tx_ring_desc_size = sizeof(struct mtk_wdma_desc),
.wdma_desc_size = 2 * sizeof(struct mtk_wdma_desc),
};
static const struct mtk_wed_soc_data mt7988_data = {
.regmap = {
.tx_bm_tkid = 0x0c8,
.wpdma_rx_ring = {
0x7d0,
0x7d8,
},
.reset_idx_tx_mask = GENMASK(1, 0),
.reset_idx_rx_mask = GENMASK(7, 6),
},
.tx_ring_desc_size = sizeof(struct mtk_wed_bm_desc),
.wdma_desc_size = 2 * sizeof(struct mtk_wdma_desc),
};
static void
wed_m32(struct mtk_wed_device *dev, u32 reg, u32 mask, u32 val)
{
regmap_update_bits(dev->hw->regs, reg, mask | val, val);
}
static void
wed_set(struct mtk_wed_device *dev, u32 reg, u32 mask)
{
return wed_m32(dev, reg, 0, mask);
}
static void
wed_clr(struct mtk_wed_device *dev, u32 reg, u32 mask)
{
return wed_m32(dev, reg, mask, 0);
}
static void
wdma_m32(struct mtk_wed_device *dev, u32 reg, u32 mask, u32 val)
{
wdma_w32(dev, reg, (wdma_r32(dev, reg) & ~mask) | val);
}
static void
wdma_set(struct mtk_wed_device *dev, u32 reg, u32 mask)
{
wdma_m32(dev, reg, 0, mask);
}
static void
wdma_clr(struct mtk_wed_device *dev, u32 reg, u32 mask)
{
wdma_m32(dev, reg, mask, 0);
}
static u32
wifi_r32(struct mtk_wed_device *dev, u32 reg)
{
return readl(dev->wlan.base + reg);
}
static void
wifi_w32(struct mtk_wed_device *dev, u32 reg, u32 val)
{
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/platform_device.h`, `linux/slab.h`, `linux/module.h`, `linux/bitfield.h`, `linux/dma-mapping.h`, `linux/skbuff.h`, `linux/of_platform.h`.
- Detected declarations: `struct mtk_wed_flow_block_priv`, `function wed_m32`, `function wed_set`, `function wed_clr`, `function wdma_m32`, `function wdma_set`, `function wdma_clr`, `function wifi_r32`, `function wifi_w32`, `function mtk_wed_read_reset`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.