drivers/net/ethernet/mediatek/mtk_wed_wo.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mediatek/mtk_wed_wo.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mediatek/mtk_wed_wo.c- Extension
.c- Size
- 10864 bytes
- Lines
- 492
- 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/dma-mapping.hlinux/interrupt.hlinux/mfd/syscon.hlinux/of.hlinux/of_irq.hlinux/bitfield.hmtk_wed.hmtk_wed_regs.hmtk_wed_wo.h
Detected Declarations
function mtk_wed_mmio_r32function mtk_wed_mmio_w32function mtk_wed_wo_get_isrfunction mtk_wed_wo_set_isrfunction mtk_wed_wo_set_ackfunction mtk_wed_wo_set_isr_maskfunction mtk_wed_wo_irq_enablefunction mtk_wed_wo_irq_disablefunction mtk_wed_wo_kickoutfunction mtk_wed_wo_queue_kickfunction mtk_wed_wo_dequeuefunction mtk_wed_wo_queue_refillfunction mtk_wed_wo_rx_completefunction mtk_wed_wo_rx_run_queuefunction mtk_wed_wo_irq_handlerfunction mtk_wed_wo_irq_taskletfunction mtk_wed_wo_queue_allocfunction mtk_wed_wo_queue_freefunction mtk_wed_wo_queue_tx_cleanfunction mtk_wed_wo_queue_rx_cleanfunction mtk_wed_wo_queue_resetfunction mtk_wed_wo_queue_tx_skbfunction mtk_wed_wo_exception_initfunction mtk_wed_wo_hardware_initfunction mtk_wed_wo_hw_deinitfunction mtk_wed_wo_initfunction mtk_wed_wo_deinit
Annotated Snippet
if (unlikely(dma_mapping_error(wo->hw->dev, addr))) {
skb_free_frag(buf);
break;
}
q->head = (q->head + 1) % q->n_desc;
entry = &q->entry[q->head];
entry->addr = addr;
entry->len = q->buf_size;
q->entry[q->head].buf = buf;
if (rx) {
struct mtk_wed_wo_queue_desc *desc = &q->desc[q->head];
u32 ctrl = MTK_WED_WO_CTL_LAST_SEC0 |
FIELD_PREP(MTK_WED_WO_CTL_SD_LEN0,
entry->len);
WRITE_ONCE(desc->buf0, cpu_to_le32(addr));
WRITE_ONCE(desc->ctrl, cpu_to_le32(ctrl));
}
q->queued++;
n_buf++;
}
return n_buf;
}
static void
mtk_wed_wo_rx_complete(struct mtk_wed_wo *wo)
{
mtk_wed_wo_set_ack(wo, MTK_WED_WO_RXCH_INT_MASK);
mtk_wed_wo_irq_enable(wo, MTK_WED_WO_RXCH_INT_MASK);
}
static void
mtk_wed_wo_rx_run_queue(struct mtk_wed_wo *wo, struct mtk_wed_wo_queue *q)
{
for (;;) {
struct mtk_wed_mcu_hdr *hdr;
struct sk_buff *skb;
void *data;
u32 len;
data = mtk_wed_wo_dequeue(wo, q, &len, false);
if (!data)
break;
skb = build_skb(data, q->buf_size);
if (!skb) {
skb_free_frag(data);
continue;
}
__skb_put(skb, len);
if (mtk_wed_mcu_check_msg(wo, skb)) {
dev_kfree_skb(skb);
continue;
}
hdr = (struct mtk_wed_mcu_hdr *)skb->data;
if (hdr->flag & cpu_to_le16(MTK_WED_WARP_CMD_FLAG_RSP))
mtk_wed_mcu_rx_event(wo, skb);
else
mtk_wed_mcu_rx_unsolicited_event(wo, skb);
}
if (mtk_wed_wo_queue_refill(wo, q, true)) {
u32 index = (q->head - 1) % q->n_desc;
mtk_wed_wo_queue_kick(wo, q, index);
}
}
static irqreturn_t
mtk_wed_wo_irq_handler(int irq, void *data)
{
struct mtk_wed_wo *wo = data;
mtk_wed_wo_set_isr(wo, 0);
tasklet_schedule(&wo->mmio.irq_tasklet);
return IRQ_HANDLED;
}
static void mtk_wed_wo_irq_tasklet(struct tasklet_struct *t)
{
struct mtk_wed_wo *wo = from_tasklet(wo, t, mmio.irq_tasklet);
u32 intr, mask;
/* disable interrupts */
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/dma-mapping.h`, `linux/interrupt.h`, `linux/mfd/syscon.h`, `linux/of.h`, `linux/of_irq.h`, `linux/bitfield.h`, `mtk_wed.h`.
- Detected declarations: `function mtk_wed_mmio_r32`, `function mtk_wed_mmio_w32`, `function mtk_wed_wo_get_isr`, `function mtk_wed_wo_set_isr`, `function mtk_wed_wo_set_ack`, `function mtk_wed_wo_set_isr_mask`, `function mtk_wed_wo_irq_enable`, `function mtk_wed_wo_irq_disable`, `function mtk_wed_wo_kickout`, `function mtk_wed_wo_queue_kick`.
- 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.