Skip to content

[Deepin-Kernel-SIG] [linux 6.6.y] [Upstream] Add WED support for MT7988 chipset from mainline-v6.7-rc1#1854

Merged
opsiff merged 18 commits into
deepin-community:linux-6.6.yfrom
opsiff:linux-6.6.y-2026-06-12-mtk-wed-support
Jun 12, 2026
Merged

[Deepin-Kernel-SIG] [linux 6.6.y] [Upstream] Add WED support for MT7988 chipset from mainline-v6.7-rc1#1854
opsiff merged 18 commits into
deepin-community:linux-6.6.yfrom
opsiff:linux-6.6.y-2026-06-12-mtk-wed-support

Conversation

@opsiff

@opsiff opsiff commented Jun 12, 2026

Copy link
Copy Markdown
Member

Link: https://lore.kernel.org/all/cover.1695032290.git.lorenzo@kernel.org/

Merged:
net: ethernet: mtk_wed: fix EXT_INT_STATUS_RX_FBUF definitions for MT7986 SoC

Similar to MT7622 and MT7986, introduce Wireless Ethernet Dispatcher (WED)
support for MT7988 chipset in order to offload to the hw packet engine traffic
received from LAN/WAN device to WLAN nic (MT7996E).
Add WED RX support in order to offload traffic received by WLAN nic to the
wired interfaces (LAN/WAN).

Changes since v1:

  • introduce mtk_wed_soc_data data structure to contain per-SoC definitions
  • get rid of buf pointer in mtk_wed_hwrro_buffer_alloc()
  • rebase on top of net-next

Lorenzo Bianconi (12):
dt-bindings: soc: mediatek: mt7986-wo-ccif: add binding for MT7988 SoC
dt-bindings: arm: mediatek: mt7622-wed: add WED binding for MT7988 SoC
net: ethernet: mtk_wed: introduce versioning utility routines
net: ethernet: mtk_wed: do not configure rx offload if not supported
net: ethernet: mtk_wed: rename mtk_rxbm_desc in mtk_wed_bm_desc
net: ethernet: mtk_wed: introduce mtk_wed_buf structure
net: ethernet: mtk_wed: move mem_region array out of
mtk_wed_mcu_load_firmware
net: ethernet: mtk_wed: make memory region optional
net: ethernet: mtk_wed: fix EXT_INT_STATUS_RX_FBUF definitions for
MT7986 SoC
net: ethernet: mtk_wed: add mtk_wed_soc_data structure
net: ethernet: mtk_wed: refactor mtk_wed_check_wfdma_rx_fill routine
net: ethernet: mtk_wed: debugfs: move wed_v2 specific regs out of regs
array

Sujuan Chen (5):
net: ethernet: mtk_wed: introduce WED support for MT7988
net: ethernet: mtk_wed: introduce partial AMSDU offload support for
MT7988
net: ethernet: mtk_wed: introduce hw_rro support for MT7988
net: ethernet: mtk_wed: debugfs: add WED 3.0 debugfs entries
net: ethernet: mtk_wed: add wed 3.0 reset support

.../arm/mediatek/mediatek,mt7622-wed.yaml | 1 +
.../soc/mediatek/mediatek,mt7986-wo-ccif.yaml | 1 +
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 1 +
drivers/net/ethernet/mediatek/mtk_eth_soc.h | 2 +-
drivers/net/ethernet/mediatek/mtk_ppe.c | 4 +-
drivers/net/ethernet/mediatek/mtk_ppe.h | 19 +-
.../net/ethernet/mediatek/mtk_ppe_offload.c | 6 +-
drivers/net/ethernet/mediatek/mtk_wed.c | 1400 ++++++++++++++---
drivers/net/ethernet/mediatek/mtk_wed.h | 57 +
.../net/ethernet/mediatek/mtk_wed_debugfs.c | 400 ++++-
drivers/net/ethernet/mediatek/mtk_wed_mcu.c | 95 +-
drivers/net/ethernet/mediatek/mtk_wed_regs.h | 369 ++++-
drivers/net/ethernet/mediatek/mtk_wed_wo.h | 3 +-
.../net/wireless/mediatek/mt76/mt7915/mmio.c | 2 +-
include/linux/netdevice.h | 1 +
include/linux/soc/mediatek/mtk_wed.h | 76 +-
16 files changed, 2109 insertions(+), 328 deletions(-)

--
2.41.0

Summary by Sourcery

Add WED v3 support for the MT7988 SoC, including RX/RRO/AMSDU offload paths and per-SoC abstraction, and extend PPE/WED integration and debugfs/firmware handling accordingly.

New Features:

  • Introduce WED offload support for the MT7988 chipset, including RX path, hardware RRO, and partial AMSDU offload.
  • Add per-SoC WED configuration via mtk_wed_soc_data, enabling different descriptor layouts and register mappings for MT7622, MT7986, and MT7988.
  • Expose new WED 3.0 debugfs interfaces for RX, AMSDU engine, route QM, and RRO/IND CMD monitoring.

Bug Fixes:

  • Correct EXT_INT_STATUS_RX_FBUF bit definitions for MT7986 WED and adjust interrupt handling masks accordingly.

Enhancements:

  • Refactor WED core to use version helper checks and per-SoC register/descriptor sizes, and to better separate TX/RX capabilities by hardware version.
  • Extend WED DMA/reset, buffer management, and PCIe/MSI configuration to handle WED v3 hardware specifics, including new prefetch/writeback FIFOs and RX page BM.
  • Wire AMSDU capability and per-flow AMSDU hints through PPE offload (FOE) and WDMA metadata.
  • Make WED WO firmware loading more flexible with shared memory-region metadata, support for MT7988 firmware images, and optional regions.

Documentation:

  • Update WED and WO-CCIF devicetree bindings to document the MT7988-compatible compatibles.

LorenzoBianconi and others added 16 commits June 12, 2026 14:16
mainline inclusion
from mainline-v6.7-rc1
category: feature

Introduce MT7988 SoC compatibility string in mt7986-wo-ccif binding.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
(cherry picked from commit 4518b25)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion
from mainline-v6.7-rc1
category: feature

Introduce MT7988 SoC compatibility string in mtk_wed binding.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
(cherry picked from commit f881f27)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion
from mainline-v6.7-rc1
category: feature

Similar to mtk_eth_soc, introduce the following wed versioning
utility routines:
- mtk_wed_is_v1
- mtk_wed_is_v2

This is a preliminary patch to introduce WED support for MT7988 SoC

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
(cherry picked from commit d274d52)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion
from mainline-v6.7-rc1
category: feature

Check if rx offload is supported running mtk_wed_get_rx_capa routine
before configuring it. This is a preliminary patch to introduce Wireless
Ethernet Dispatcher (WED) support for MT7988 SoC.

Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
(cherry picked from commit 7d5a727)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion
from mainline-v6.7-rc1
category: feature

Rename mtk_rxbm_desc structure in mtk_wed_bm_desc since it will be used
even on tx side by MT7988 SoC.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
(cherry picked from commit bafd764)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion
from mainline-v6.7-rc1
category: feature

Introduce mtk_wed_buf structure to store both virtual and physical
addresses allocated in mtk_wed_tx_buffer_alloc() routine. This is a
preliminary patch to add WED support for MT7988 SoC since it relies on a
different dma descriptor layout not storing page dma addresses.

Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
(cherry picked from commit ff0ea57)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
…_firmware

mainline inclusion
from mainline-v6.7-rc1
category: feature

Remove mtk_wed_wo_memory_region boot structure in mtk_wed_wo.
This is a preliminary patch to introduce WED support for MT7988 SoC.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
(cherry picked from commit c6d961a)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion
from mainline-v6.7-rc1
category: feature

Make mtk_wed_wo_memory_region optionals.
This is a preliminary patch to introduce Wireless Ethernet Dispatcher
support for MT7988 SoC since MT7988 WED fw image will have a different
layout.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
(cherry picked from commit 71e2135)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion
from mainline-v6.7-rc1
category: feature

Introduce mtk_wed_soc_data utility structure to contain per-SoC
definitions.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
(cherry picked from commit 9ae7eca)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion
from mainline-v6.7-rc1
category: feature

Similar to MT7986 and MT7622, enable Wireless Ethernet Ditpatcher for
MT7988 in order to offload traffic forwarded from LAN/WLAN to WLAN/LAN

Co-developed-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
(cherry picked from commit e2f64db)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion
from mainline-v6.7-rc1
category: feature

Refactor mtk_wed_check_wfdma_rx_fill() in order to be reused adding HW
receive offload support for MT7988 SoC.

Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
(cherry picked from commit 96ddb4d)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
…T7988

mainline inclusion
from mainline-v6.7-rc1
category: feature

Introduce partial AMSDU offload support for MT7988 SoC in order to merge
in hw packets belonging to the same AMSDU before passing them to the
WLAN nic.

Co-developed-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
(cherry picked from commit b230812)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion
from mainline-v6.7-rc1
category: feature

MT7988 SoC support 802.11 receive reordering offload in hw while
MT7986 SoC implements it through the firmware running on the mcu.

Co-developed-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
(cherry picked from commit 6757d34)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
…s array

mainline inclusion
from mainline-v6.7-rc1
category: feature

Move specific WED2.0 debugfs entries out of regs array. This is a
preliminary patch to introduce WED 3.0 debugfs info.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
(cherry picked from commit 4b7e02b)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion
from mainline-v6.7-rc1
category: feature

Introduce WED3.0 debugfs entries useful for debugging.

Co-developed-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
(cherry picked from commit 3f3de09)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion
from mainline-v6.7-rc1
category: feature

Introduce support for resetting Wireless Ethernet Dispatcher 3.0
available on MT988 SoC.

Co-developed-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
(cherry picked from commit 1543b8f)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
@sourcery-ai

sourcery-ai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds WED 3.0 support and MT7988 SoC integration, including HW RRO and partial AMSDU offload paths, extends PPE/WDMA plumbing and debugfs/MCU firmware handling, and refactors WED core code around SoC-specific data and versioned capabilities.

File-Level Changes

Change Details Files
Introduce versioned WED core with SoC-specific register/descriptor layout and MT7988 (WED v3) support
  • Add mtk_wed_soc_data describing per-SoC register offsets, descriptor sizes, and reset masks, with instances for MT7622, MT7986, and new MT7988
  • Replace direct version checks with helpers (mtk_wed_is_v1/v2/v3_or_greater) and route most control paths (DMA/reset/IRQ, route QM, 512-WCID support) through SoC- or version-aware branches
  • Extend WED hardware list and eth SoC maps to support a third WED/WDMA instance and netsys v3 versioning for MT7988
drivers/net/ethernet/mediatek/mtk_wed.c
drivers/net/ethernet/mediatek/mtk_wed.h
drivers/net/ethernet/mediatek/mtk_eth_soc.c
drivers/net/ethernet/mediatek/mtk_eth_soc.h
Add TX/RX data-path support for WED v3: new buffer management, HW RRO page pool, and reset/enable sequencing
  • Increase WED buffer sizing, introduce mtk_wed_buf and replace mtk_rxbm_desc with mtk_wed_bm_desc, splitting TX and RX buffer management and adding a dedicated HW RRO pool (page-based RX BM)
  • Modify TX buffer ring allocation to use SoC-specific descriptor sizes and WED v3 token-based descriptors; update free paths accordingly
  • Add WED/WDMA v3-specific RX/TX reset helpers that flush prefetch/core/writeback FIFOs, reset prefetch indices, and handle new prefetch/DDONE2 paths
  • Update DMA enable/disable and reset flows to handle RX-capability gating, HW RRO enablement, WDMA/WPDMA prefetch control, and new WED status bits
  • Wire up new RX RRO, page-ring, and indirect-command rings into the WED device, including init/deinit, reset, and IRQ configuration
drivers/net/ethernet/mediatek/mtk_wed.c
include/linux/soc/mediatek/mtk_wed.h
drivers/net/wireless/mediatek/mt76/mt7915/mmio.c
drivers/net/ethernet/mediatek/mtk_wed_regs.h
Implement MT7988 HW RRO and partial AMSDU offload support, including PPE integration and control-plane APIs
  • Add WED-side AMSDU engine support: large TXD buffer allocation, initialization (station parameters, qmem, partial AMSDU TXD source), enable/disable paths, and reset handling in DMA reset/deinit sequences
  • Add HW RRO setup helpers (start_hw_rro, rro_rx_ring_setup, msdu_pg_rx_ring_setup, ind_rx_ring_setup) exposed through mtk_wed_ops, and integrate them into attach/start flows and capability checks
  • Extend PPE offload API and FOE entry layout to carry AMSDU metadata (per-flow AMSDU enable flag and fields), and propagate AMSDU flag via net_device_path->mtk_wdma.amsdu
  • Gate RX capability on hw_rro for v3 and add helper to query AMSDU support from consumers
drivers/net/ethernet/mediatek/mtk_wed.c
drivers/net/ethernet/mediatek/mtk_ppe.c
drivers/net/ethernet/mediatek/mtk_ppe.h
drivers/net/ethernet/mediatek/mtk_ppe_offload.c
include/linux/netdevice.h
include/linux/soc/mediatek/mtk_wed.h
Extend WED debugfs and register definitions for WED 3.0 (RRO, AMSDU, Route QM) introspection
  • Refactor wed_rxinfo debugfs to share a common set of registers and add version-specific dumps for WED v2 and v3, including new RRO RX, MSDU page, and indirect command rings for v3
  • Add dedicated debugfs files for AMSDU, Route QM, and RRO statistics containing counters, queue depths, and pointer state using new masked register-dump helpers
  • Introduce many new WED/WDMA/RRO/AMSDU register and bitfield definitions to support v3 features (prefetch, writeback, page BM, RTQM IGRS counters, AMSDU qmem and engine counters, PCIE base/INT control)
drivers/net/ethernet/mediatek/mtk_wed_debugfs.c
drivers/net/ethernet/mediatek/mtk_wed_regs.h
drivers/net/ethernet/mediatek/mtk_wed.c
Update WED MCU/WO firmware handling for multiple memory regions and MT7988 firmware images
  • Move WO memory-region descriptions to a global array, make data/boot regions optional, and change register access helpers to use the boot memory-region mapping
  • Refactor memory-region discovery to accept DT index, so regions can be optional per-SoC, and only run firmware loading when a region is defined
  • Select firmware image based on WED hardware version (MT7981/MT7986 for v2, new MT7988_wo_0/1 for v3) and adjust boot address and reset logic to always start WM core
  • Register MT7988 WO firmware blobs with MODULE_FIRMWARE and drop per-wo boot region from struct mtk_wed_wo
drivers/net/ethernet/mediatek/mtk_wed_mcu.c
drivers/net/ethernet/mediatek/mtk_wed_wo.h
drivers/net/ethernet/mediatek/mtk_wed_wo.h
Add devicetree bindings and SoC plumbing for MT7988 WED and WO-CCIF
  • Extend mt7622-wed YAML binding to accept mediatek,mt7988-wed compatible and mt7986-wo-ccif YAML to accept mediatek,mt7988-wo-ccif
  • Update WED/eth SoC integration to derive hw->version from eth->soc->version, select mt7988_data for v3, and hook WED v3 into netsys v3 register map (including third WDMA base)
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml
Documentation/devicetree/bindings/soc/mediatek/mediatek,mt7986-wo-ccif.yaml
drivers/net/ethernet/mediatek/mtk_eth_soc.c
drivers/net/ethernet/mediatek/mtk_eth_soc.h
drivers/net/ethernet/mediatek/mtk_wed.c

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@Avenger-285714

Copy link
Copy Markdown
Member

/approve

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • The new buffer allocation helpers (e.g. mtk_wed_amsdu_buffer_alloc() and mtk_wed_hwrro_buffer_alloc()) lack symmetric cleanup on failure paths: already-allocated pages and descriptors are not freed/unmapped when a later allocation or dma_map_single/page fails, which will leak memory and DMA mappings in partial-init scenarios; consider adding unwind loops mirroring the success cleanup logic.
  • In the HW RRO buffer handling, the size used for descriptor allocation and that used for freeing differ (allocation uses dev->wlan.rx_nbuf * sizeof(*desc) while free uses dev->hw_rro.size * sizeof(*desc)), which can lead to over/under frees when rx_nbuf is not equal to the aligned size; it would be safer to use a single, consistent length field for both alloc and free.
  • Some of the new debugfs register mask dumps (e.g. the WED_MON_AMSDU_ENG_CNT9() indices reused across different engines) appear to copy-paste indices inconsistently, which risks exposing misleading counters; it may be worth double-checking the engine index and field macros per block to ensure they match the intended hardware registers.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new buffer allocation helpers (e.g. mtk_wed_amsdu_buffer_alloc() and mtk_wed_hwrro_buffer_alloc()) lack symmetric cleanup on failure paths: already-allocated pages and descriptors are not freed/unmapped when a later allocation or dma_map_single/page fails, which will leak memory and DMA mappings in partial-init scenarios; consider adding unwind loops mirroring the success cleanup logic.
- In the HW RRO buffer handling, the size used for descriptor allocation and that used for freeing differ (allocation uses dev->wlan.rx_nbuf * sizeof(*desc) while free uses dev->hw_rro.size * sizeof(*desc)), which can lead to over/under frees when rx_nbuf is not equal to the aligned size; it would be safer to use a single, consistent length field for both alloc and free.
- Some of the new debugfs register mask dumps (e.g. the WED_MON_AMSDU_ENG_CNT9() indices reused across different engines) appear to copy-paste indices inconsistently, which risks exposing misleading counters; it may be worth double-checking the engine index and field macros per block to ensure they match the intended hardware registers.

## Individual Comments

### Comment 1
<location path="drivers/net/ethernet/mediatek/mtk_wed.c" line_range="522" />
<code_context>
 }

+static int
+mtk_wed_amsdu_buffer_alloc(struct mtk_wed_device *dev)
+{
+	struct mtk_wed_hw *hw = dev->hw;
</code_context>
<issue_to_address>
**issue:** AMSdu buffer error path leaks pages and partially mapped buffers.

In mtk_wed_amsdu_buffer_alloc(), if __get_free_pages() or dma_map_single() fails, the error path only dma_unmap_single()s previously mapped buffers and returns, but never free_pages() the corresponding allocations. This leaks memory on partial init failures. Please also free the pages (and reset wed_amsdu[i].txd / txd_phy as needed), mirroring mtk_wed_amsdu_free_buffer().
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

}

static int
mtk_wed_amsdu_buffer_alloc(struct mtk_wed_device *dev)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: AMSdu buffer error path leaks pages and partially mapped buffers.

In mtk_wed_amsdu_buffer_alloc(), if __get_free_pages() or dma_map_single() fails, the error path only dma_unmap_single()s previously mapped buffers and returns, but never free_pages() the corresponding allocations. This leaks memory on partial init failures. Please also free the pages (and reset wed_amsdu[i].txd / txd_phy as needed), mirroring mtk_wed_amsdu_free_buffer().

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR backports upstream MediaTek WED (Wireless Ethernet Dispatcher) v3 support for MT7988 into the 6.6.y tree, extending the existing WED/PPE integration to support new RX/RRO and (partial) AMSDU offload paths, plus new per-SoC abstractions and debugfs visibility.

Changes:

  • Add MT7988 (WED v3) support including new rings, reset paths, and RX/RRO/AMSDU plumbing.
  • Introduce per-SoC WED definitions via mtk_wed_soc_data to handle differing register layouts/descriptor sizes across MT7622/MT7986/MT7988.
  • Extend PPE/WED offload metadata and debugfs outputs for v3-specific monitoring.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
include/linux/soc/mediatek/mtk_wed.h Extends public WED device structures and ops for v3 (RRO/page rings, AMSDU capability helpers).
include/linux/netdevice.h Adds WDMA path metadata (amsdu) to net_device_path.
drivers/net/wireless/mediatek/mt76/mt7915/mmio.c Updates RX BM descriptor type rename usage.
drivers/net/ethernet/mediatek/mtk_wed.h Adds per-SoC data, version helper utilities, and PCIe base selection logic.
drivers/net/ethernet/mediatek/mtk_wed.c Main WED v3 implementation: new reset flows, AMSDU buffers, HW-RRO/page BM buffers, ring setup, and IRQ/config changes.
drivers/net/ethernet/mediatek/mtk_wed_wo.h Adds MT7988 WO firmware names and adjusts WO struct fields.
drivers/net/ethernet/mediatek/mtk_wed_regs.h Adds/updates many v3 register definitions and new reset/ctrl bits.
drivers/net/ethernet/mediatek/mtk_wed_mcu.c Refactors WO firmware region handling and adds MT7988 firmware selection.
drivers/net/ethernet/mediatek/mtk_wed_debugfs.c Adds v3 debugfs entries and expands rxinfo/rtqm/rro/amsdu dumps.
drivers/net/ethernet/mediatek/mtk_ppe.h Renames/repurposes FOE fields for AMSDU hints and updates WDMA setter signature.
drivers/net/ethernet/mediatek/mtk_ppe.c Threads AMSDU enable into netsys v3 FOE entries.
drivers/net/ethernet/mediatek/mtk_ppe_offload.c Propagates amsdu from netdevice path into FOE setup; adds WDMA2 port mapping.
drivers/net/ethernet/mediatek/mtk_eth_soc.h Expands WDMA base array to 3 entries.
drivers/net/ethernet/mediatek/mtk_eth_soc.c Adds WDMA2 base for MT7988.
Documentation/devicetree/bindings/soc/mediatek/mediatek,mt7986-wo-ccif.yaml Adds MT7988 WO-CCIF compatible.
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml Adds MT7988 WED compatible.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +536 to +562
for (i = 0; i < MTK_WED_AMSDU_NPAGES; i++) {
void *ptr;

/* each segment is 64K */
ptr = (void *)__get_free_pages(GFP_KERNEL | __GFP_NOWARN |
__GFP_ZERO | __GFP_COMP |
GFP_DMA32,
get_order(MTK_WED_AMSDU_BUF_SIZE));
if (!ptr)
goto error;

wed_amsdu[i].txd = ptr;
wed_amsdu[i].txd_phy = dma_map_single(hw->dev, ptr,
MTK_WED_AMSDU_BUF_SIZE,
DMA_TO_DEVICE);
if (dma_mapping_error(hw->dev, wed_amsdu[i].txd_phy))
goto error;
}
dev->hw->wed_amsdu = wed_amsdu;

return 0;

error:
for (i--; i >= 0; i--)
dma_unmap_single(hw->dev, wed_amsdu[i].txd_phy,
MTK_WED_AMSDU_BUF_SIZE, DMA_TO_DEVICE);
return -ENOMEM;
Comment on lines 692 to +716
for (s = 0; s < MTK_WED_BUF_PER_PAGE; s++) {
u32 txd_size;
u32 ctrl;

txd_size = dev->wlan.init_buf(buf, buf_phys, token++);
struct mtk_wdma_desc *desc = desc_ptr;

desc->buf0 = cpu_to_le32(buf_phys);
desc->buf1 = cpu_to_le32(buf_phys + txd_size);

if (dev->hw->version == 1)
ctrl = FIELD_PREP(MTK_WDMA_DESC_CTRL_LEN0, txd_size) |
FIELD_PREP(MTK_WDMA_DESC_CTRL_LEN1,
MTK_WED_BUF_SIZE - txd_size) |
MTK_WDMA_DESC_CTRL_LAST_SEG1;
else
ctrl = FIELD_PREP(MTK_WDMA_DESC_CTRL_LEN0, txd_size) |
FIELD_PREP(MTK_WDMA_DESC_CTRL_LEN1_V2,
MTK_WED_BUF_SIZE - txd_size) |
MTK_WDMA_DESC_CTRL_LAST_SEG0;
desc->ctrl = cpu_to_le32(ctrl);
desc->info = 0;
desc++;

if (!mtk_wed_is_v3_or_greater(dev->hw)) {
u32 txd_size, ctrl;

txd_size = dev->wlan.init_buf(buf, buf_phys,
token++);
desc->buf1 = cpu_to_le32(buf_phys + txd_size);
ctrl = FIELD_PREP(MTK_WDMA_DESC_CTRL_LEN0, txd_size);
if (mtk_wed_is_v1(dev->hw))
ctrl |= MTK_WDMA_DESC_CTRL_LAST_SEG1 |
FIELD_PREP(MTK_WDMA_DESC_CTRL_LEN1,
MTK_WED_BUF_SIZE - txd_size);
else
ctrl |= MTK_WDMA_DESC_CTRL_LAST_SEG0 |
FIELD_PREP(MTK_WDMA_DESC_CTRL_LEN1_V2,
MTK_WED_BUF_SIZE - txd_size);
desc->ctrl = cpu_to_le32(ctrl);
desc->info = 0;
} else {
desc->ctrl = cpu_to_le32(token << 16);
}

Comment on lines +779 to +785
dev->hw_rro.size = dev->wlan.rx_nbuf & ~(MTK_WED_BUF_PER_PAGE - 1);
dev->hw_rro.pages = page_list;
desc = dma_alloc_coherent(dev->hw->dev,
dev->wlan.rx_nbuf * sizeof(*desc),
&desc_phys, GFP_KERNEL);
if (!desc)
return -ENOMEM;
Comment on lines 1716 to +1717
mtk_wed_free_rx_buffer(dev);
mtk_wed_hwrro_free_buffer(dev);
Comment on lines +19 to 43
static struct mtk_wed_wo_memory_region mem_region[] = {
[MTK_WED_WO_REGION_EMI] = {
.name = "wo-emi",
},
[MTK_WED_WO_REGION_ILM] = {
.name = "wo-ilm",
},
[MTK_WED_WO_REGION_DATA] = {
.name = "wo-data",
.shared = true,
},
[MTK_WED_WO_REGION_BOOT] = {
.name = "wo-boot",
},
};

static u32 wo_r32(struct mtk_wed_wo *wo, u32 reg)
{
return readl(wo->boot.addr + reg);
return readl(mem_region[MTK_WED_WO_REGION_BOOT].addr + reg);
}

static void wo_w32(struct mtk_wed_wo *wo, u32 reg, u32 val)
{
writel(val, wo->boot.addr + reg);
writel(val, mem_region[MTK_WED_WO_REGION_BOOT].addr + reg);
}
Comment on lines +313 to +316
DUMP_WED_MASK(WED_MON_AMSDU_ENG_CNT9(2),
WED_AMSDU_ENG_MAX_BUF_MERGED),
DUMP_WED_MASK(WED_MON_AMSDU_ENG_CNT9(2),
WED_AMSDU_ENG_MAX_MSDU_MERGED),
Comment on lines +417 to +418
DUMP_WED_MASK(WED_MON_AMSDU_ENG_CNT9(4),
WED_AMSDU_ENG_MAX_MSDU_MERGED),
Comment on lines +502 to +536
DUMP_STR("WED Route QM IGRS0(N2H + Recycle)"),
DUMP_WED(WED_RTQM_IGRS0_I2HW_DMAD_CNT),
DUMP_WED(WED_RTQM_IGRS0_I2H_DMAD_CNT(0)),
DUMP_WED(WED_RTQM_IGRS0_I2H_DMAD_CNT(1)),
DUMP_WED(WED_RTQM_IGRS0_I2HW_PKT_CNT),
DUMP_WED(WED_RTQM_IGRS0_I2H_PKT_CNT(0)),
DUMP_WED(WED_RTQM_IGRS0_I2H_PKT_CNT(0)),
DUMP_WED(WED_RTQM_IGRS0_FDROP_CNT),

DUMP_STR("WED Route QM IGRS1(Legacy)"),
DUMP_WED(WED_RTQM_IGRS1_I2HW_DMAD_CNT),
DUMP_WED(WED_RTQM_IGRS1_I2H_DMAD_CNT(0)),
DUMP_WED(WED_RTQM_IGRS1_I2H_DMAD_CNT(1)),
DUMP_WED(WED_RTQM_IGRS1_I2HW_PKT_CNT),
DUMP_WED(WED_RTQM_IGRS1_I2H_PKT_CNT(0)),
DUMP_WED(WED_RTQM_IGRS1_I2H_PKT_CNT(1)),
DUMP_WED(WED_RTQM_IGRS1_FDROP_CNT),

DUMP_STR("WED Route QM IGRS2(RRO3.0)"),
DUMP_WED(WED_RTQM_IGRS2_I2HW_DMAD_CNT),
DUMP_WED(WED_RTQM_IGRS2_I2H_DMAD_CNT(0)),
DUMP_WED(WED_RTQM_IGRS2_I2H_DMAD_CNT(1)),
DUMP_WED(WED_RTQM_IGRS2_I2HW_PKT_CNT),
DUMP_WED(WED_RTQM_IGRS2_I2H_PKT_CNT(0)),
DUMP_WED(WED_RTQM_IGRS2_I2H_PKT_CNT(1)),
DUMP_WED(WED_RTQM_IGRS2_FDROP_CNT),

DUMP_STR("WED Route QM IGRS3(DEBUG)"),
DUMP_WED(WED_RTQM_IGRS2_I2HW_DMAD_CNT),
DUMP_WED(WED_RTQM_IGRS3_I2H_DMAD_CNT(0)),
DUMP_WED(WED_RTQM_IGRS3_I2H_DMAD_CNT(1)),
DUMP_WED(WED_RTQM_IGRS3_I2HW_PKT_CNT),
DUMP_WED(WED_RTQM_IGRS3_I2H_PKT_CNT(0)),
DUMP_WED(WED_RTQM_IGRS3_I2H_PKT_CNT(1)),
DUMP_WED(WED_RTQM_IGRS3_FDROP_CNT),
LorenzoBianconi and others added 2 commits June 12, 2026 15:02
mainline inclusion
from mainline-v6.7-rc1
category: bugfix

The WED mcu firmware does not contain all the memory regions defined in
the dts reserved_memory node (e.g. MT7986 WED firmware does not contain
cpu-boot region).
Reverse the mtk_wed_mcu_run_firmware() logic to check all the fw
sections are defined in the dts reserved_memory node.

Fixes: c6d961a ("net: ethernet: mtk_wed: move mem_region array out of mtk_wed_mcu_load_firmware")
Tested-by: Frank Wunderlich <frank-w@public-files.de>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Link: https://lore.kernel.org/r/d983cbfe8ea562fef9264de8f0c501f7d5705bd5.1698098381.git.lorenzo@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
(cherry picked from commit c35d763)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion
from mainline-v6.12-rc6
category: bugfix

linux-firmware commit 808cba84 ("mtk_wed: add firmware for mt7988
Wireless Ethernet Dispatcher") added mt7988_wo_{0,1}.bin in the
'mediatek/mt7988' directory while driver current expects the files in
the 'mediatek' directory.

Change path in the driver header now that the firmware has been added.

Fixes: e2f64db ("net: ethernet: mtk_wed: introduce WED support for MT7988")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://patch.msgid.link/Zxz0GWTR5X5LdWPe@pidgin.makrotopia.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
(cherry picked from commit 637f414)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Avenger-285714

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@opsiff opsiff merged commit 76e128c into deepin-community:linux-6.6.y Jun 12, 2026
14 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants