* Re: [PATCH v4 5/5] [PATCH v4] [PATCH 05/05] wifi: mt76: mt7922/mt7928: send Tx/Rx statistics to FW for link tuning @ 2026-11-02 7:17 Anthony Liu (劉良棟) 2026-11-26 9:54 ` [PATCH v5 0/5] wifi: mt76: optimize mt7922/mt7928 T-put per Tx/Rx stats Anthony Liu 0 siblings, 1 reply; 14+ messages in thread From: Anthony Liu (劉良棟) @ 2026-11-02 7:17 UTC (permalink / raw) To: Felix Fietkau, lorenzo@kernel.org Cc: Sean Wang, Leon Yen (顏良儒), Quan Zhou (周全), Ryder Lee, Litien Chang (張立典), Kun Wu (吳謹至), JB Tsai (蔡志彬), Emery Hsin (辛承宣), linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org Hi, Felix, Thanks for reviewing. On Tue, 2026-10-06 at 16:48 +0200, Felix Fietkau wrote: > Hi, > > On 05.10.26 10:31, Anthony Liu wrote: > > Update Tx/Rx statistics to FW for link speed tuning in FW. > > > > Signed-off-by: Anthony Liu <anthony.liu@mediatek.com> > A few issues in this series: > 1. Please fix the email subject > 2. It seems that some places may need checks to exclude mt7921. > 3. Some duplication in debugfs.c > 4. mt792x_mcu_set_perf_ind could be static > 5. Check if the pointer derefs in mt792x_perf_account_rx are safe. I'll revise accordingly. One issue occurred is this is a 5-patches series. But I found the first patch is already in nbd/wireless. Should I upload 4 v5 patches (2~5) or how to do this properly? > Aside from this, I also have some questions: > - is this on by default or can it only be enabled via debugfs? > - why does the host have to keep statistics on tx/rx, when the > firmware > could do that and handle it internally? 1. It's meant to be turned on via debugfs so customers can turn turn on/off based on their need. 2. There are a few reasons for this: a. This is a working and common design among several chips' F/W and other platform drivers. b. F/W size is approaching it's limits in several chip branches. To keep design consistent, we chose to not add more complexity to the maintenance of F/W. br, anthony > Thanks, > > - Felix ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v5 0/5] wifi: mt76: optimize mt7922/mt7928 T-put per Tx/Rx stats 2026-11-02 7:17 [PATCH v4 5/5] [PATCH v4] [PATCH 05/05] wifi: mt76: mt7922/mt7928: send Tx/Rx statistics to FW for link tuning Anthony Liu (劉良棟) @ 2026-11-26 9:54 ` Anthony Liu 2026-11-26 9:54 ` [PATCH v5 1/5] wifi: mt76: refactor chip_config to accept generic commands Anthony Liu ` (5 more replies) 0 siblings, 6 replies; 14+ messages in thread From: Anthony Liu @ 2026-11-26 9:54 UTC (permalink / raw) To: anthony.liu Cc: Emery.Hsin, Jb.Tsai, Leon.Yen, Litien.Chang, Quan.Zhou, Ryder.Lee, Sean.Wang, kun.wu, linux-mediatek, linux-wireless, lorenzo, nbd This series adds: 1. Read the HW charactistics flag from ACPI BIOS. 2. If the HW needs, collect and update Tx/Rx statistics to FW. 3. FW can then decide how to adjust PCIe link to improve T-put. Anthony Liu (5): [PATCH 01/05] wifi: mt76: refactor chip_config to accept generic commands [PATCH 02/05] wifi: mt76: refactor chip_cfg commands to be a generic API [PATCH 03/05] wifi: mt76: add ACPI MTFG option for bus configuration [PATCH 04/05] wifi: mt76: add PCIe speed tuning for mt7922/mt7928 [PATCH 05/05] wifi: mt76: mt7922/mt7928: send Tx/Rx statistics to FW for link tuning .../wireless/mediatek/mt76/mt7615/debugfs.c | 2 +- .../wireless/mediatek/mt76/mt76_connac_mcu.c | 54 ++++- .../wireless/mediatek/mt76/mt76_connac_mcu.h | 60 ++++- .../wireless/mediatek/mt76/mt7921/debugfs.c | 38 +++- .../net/wireless/mediatek/mt76/mt7921/init.c | 5 + .../net/wireless/mediatek/mt76/mt7921/mac.c | 4 + .../net/wireless/mediatek/mt76/mt7921/main.c | 2 + .../net/wireless/mediatek/mt76/mt7921/pci.c | 8 + .../wireless/mediatek/mt76/mt7921/pci_mac.c | 8 + .../wireless/mediatek/mt76/mt7925/debugfs.c | 47 +++- .../net/wireless/mediatek/mt76/mt7925/init.c | 2 + .../net/wireless/mediatek/mt76/mt7925/mac.c | 4 + .../net/wireless/mediatek/mt76/mt7925/main.c | 4 + .../net/wireless/mediatek/mt76/mt7925/mcu.c | 6 +- .../net/wireless/mediatek/mt76/mt7925/mcu.h | 1 - .../net/wireless/mediatek/mt76/mt7925/pci.c | 14 ++ .../wireless/mediatek/mt76/mt7925/pci_mac.c | 8 + drivers/net/wireless/mediatek/mt76/mt792x.h | 57 +++++ .../wireless/mediatek/mt76/mt792x_acpi_sar.c | 1 + .../net/wireless/mediatek/mt76/mt792x_core.c | 211 ++++++++++++++++++ 20 files changed, 526 insertions(+), 10 deletions(-) base-commit: 86b8d5b18d9712ae0001f078d1893c2dceac0bdb -- 2.45.2 --- V3 -> V4: Add cover letter, fix crash (misuse of deflink) in mt792x_perf_account_rx(). V2 -> V3: Remove Gerrit-only: Change-Id. V1 -> V2: Remove not needed lines copied from internal commits. ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v5 1/5] wifi: mt76: refactor chip_config to accept generic commands 2026-11-26 9:54 ` [PATCH v5 0/5] wifi: mt76: optimize mt7922/mt7928 T-put per Tx/Rx stats Anthony Liu @ 2026-11-26 9:54 ` Anthony Liu 2026-11-26 9:54 ` [PATCH v5 2/5] wifi: mt76: refactor chip_cfg commands to be a generic API Anthony Liu ` (4 subsequent siblings) 5 siblings, 0 replies; 14+ messages in thread From: Anthony Liu @ 2026-11-26 9:54 UTC (permalink / raw) To: anthony.liu Cc: Emery.Hsin, Jb.Tsai, Leon.Yen, Litien.Chang, Quan.Zhou, Ryder.Lee, Sean.Wang, kun.wu, linux-mediatek, linux-wireless, lorenzo, nbd The API, mt76_connac_mcu_chip_config(), was only used to send reset command but the chip_config command is a carrier of more commands. This patch enables other FW commands to be carried over mt76_connac_mcu_chip_config(). Signed-off-by: Anthony Liu <anthony.liu@mediatek.com> Reviewed-by: Felix Fietkau <nbd@nbd.name> --- drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c | 2 +- drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 4 ++-- drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h | 2 +- drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c index 6a1475e3c899..83cffa94bc0e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c @@ -54,7 +54,7 @@ static int mt7615_config(void *data, u64 val) int ret; mt7615_mutex_acquire(dev); - ret = mt76_connac_mcu_chip_config(&dev->mt76); + ret = mt76_connac_mcu_chip_config(&dev->mt76, "assert"); mt7615_mutex_release(dev); return ret; diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c index 744b4d1f6519..0e3f23e52382 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c @@ -2047,13 +2047,13 @@ int mt76_connac_mcu_sched_scan_enable(struct mt76_phy *phy, } EXPORT_SYMBOL_GPL(mt76_connac_mcu_sched_scan_enable); -int mt76_connac_mcu_chip_config(struct mt76_dev *dev) +int mt76_connac_mcu_chip_config(struct mt76_dev *dev, const char *cmd) { struct mt76_connac_config req = { .resp_type = 0, }; - strscpy(req.data, "assert"); + strscpy(req.data, cmd); return mt76_mcu_send_msg(dev, MCU_CE_CMD(CHIP_CONFIG), &req, sizeof(req), false); diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h index 6a51b1df4fc7..c5fb7e2adab1 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h @@ -2122,7 +2122,7 @@ void mt76_connac_mcu_set_suspend_iter(void *priv, u8 *mac, int mt76_connac_sta_state_dp(struct mt76_dev *dev, enum ieee80211_sta_state old_state, enum ieee80211_sta_state new_state); -int mt76_connac_mcu_chip_config(struct mt76_dev *dev); +int mt76_connac_mcu_chip_config(struct mt76_dev *dev, const char *cmd); int mt76_connac_mcu_set_deep_sleep(struct mt76_dev *dev, bool enable); void mt76_connac_mcu_coredump_event(struct mt76_dev *dev, struct sk_buff *skb, struct mt76_connac_coredump *coredump); diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c index 825dfcd2c6ac..14c70ffa9665 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c @@ -238,7 +238,7 @@ static int mt7921_chip_reset(void *data, u64 val) default: /* Collect the core dump before reset wifisys. */ mt792x_mutex_acquire(dev); - ret = mt76_connac_mcu_chip_config(&dev->mt76); + ret = mt76_connac_mcu_chip_config(&dev->mt76, "assert"); mt792x_mutex_release(dev); break; } -- 2.45.2 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v5 2/5] wifi: mt76: refactor chip_cfg commands to be a generic API 2026-11-26 9:54 ` [PATCH v5 0/5] wifi: mt76: optimize mt7922/mt7928 T-put per Tx/Rx stats Anthony Liu 2026-11-26 9:54 ` [PATCH v5 1/5] wifi: mt76: refactor chip_config to accept generic commands Anthony Liu @ 2026-11-26 9:54 ` Anthony Liu 2026-11-26 9:54 ` [PATCH v5 3/5] wifi: mt76: add ACPI MTFG option for bus configuration Anthony Liu ` (3 subsequent siblings) 5 siblings, 0 replies; 14+ messages in thread From: Anthony Liu @ 2026-11-26 9:54 UTC (permalink / raw) To: anthony.liu Cc: Emery.Hsin, Jb.Tsai, Leon.Yen, Litien.Chang, Quan.Zhou, Ryder.Lee, Sean.Wang, kun.wu, linux-mediatek, linux-wireless, lorenzo, nbd New chip_cfg command isn't chip specific but only available to mt7925. 1. Move chip specific mt7925_mcu_chip_config() from mt76/mt7925/mcu.c to mt76_connac_mcu_uni_chip_config() in mt76/mt76_connac_mcu.c. 2. mt792x_mcu_chip_config() uses mt76_connac_mcu_uni_chip_config() if is dealing with CONNAC3 FW, and uses mt76_connac_mcu_chip_config() otherwise. Signed-off-by: Anthony Liu <anthony.liu@mediatek.com> Reviewed-by: Felix Fietkau <nbd@nbd.name> --- .../wireless/mediatek/mt76/mt76_connac_mcu.c | 35 +++++++++++++++++++ .../wireless/mediatek/mt76/mt76_connac_mcu.h | 5 +++ .../wireless/mediatek/mt76/mt7925/debugfs.c | 2 +- .../net/wireless/mediatek/mt76/mt7925/mcu.c | 6 ++-- .../net/wireless/mediatek/mt76/mt7925/mcu.h | 1 - drivers/net/wireless/mediatek/mt76/mt792x.h | 1 + .../net/wireless/mediatek/mt76/mt792x_core.c | 13 +++++++ 7 files changed, 58 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c index 0e3f23e52382..01434b1e01f5 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c @@ -2060,6 +2060,41 @@ int mt76_connac_mcu_chip_config(struct mt76_dev *dev, const char *cmd) } EXPORT_SYMBOL_GPL(mt76_connac_mcu_chip_config); +/* Unified-command form of chip_config (connac3, e.g. MT7925/MT7928): the same + * CE payload carried as a TLV inside MCU_UNI_CMD_CHIP_CONFIG. + */ +int mt76_connac_mcu_uni_chip_config(struct mt76_dev *dev, const char *cmd) +{ + ssize_t len; + + struct { + u8 rsv[4]; + __le16 tag; + __le16 len; + struct mt76_connac_config config; + } __packed req = { + .tag = cpu_to_le16(UNI_CHIP_CONFIG_CHIP_CFG), + .len = cpu_to_le16(sizeof(req) - sizeof(req.rsv)), + .config = { + .resp_type = 0, + .type = 0, + }, + }; + + if (!cmd) + return -EINVAL; + + len = strscpy(req.config.data, cmd); + if (len == -E2BIG) + return -E2BIG; + + req.config.data_size = cpu_to_le16(len + 1); + + return mt76_mcu_send_msg(dev, MCU_UNI_CMD(CHIP_CONFIG), + &req, sizeof(req), false); +} +EXPORT_SYMBOL_GPL(mt76_connac_mcu_uni_chip_config); + int mt76_connac_mcu_set_deep_sleep(struct mt76_dev *dev, bool enable) { struct mt76_connac_config req = { diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h index c5fb7e2adab1..0d2670b7b9fb 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h @@ -1467,6 +1467,10 @@ enum UNI_ALL_STA_INFO_TAG { UNI_ALL_STA_MAX_NUM }; +enum { + UNI_CHIP_CONFIG_CHIP_CFG = 2, +}; + enum { MT_NIC_CAP_TX_RESOURCE, MT_NIC_CAP_TX_EFUSE_ADDR, @@ -2123,6 +2127,7 @@ int mt76_connac_sta_state_dp(struct mt76_dev *dev, enum ieee80211_sta_state old_state, enum ieee80211_sta_state new_state); int mt76_connac_mcu_chip_config(struct mt76_dev *dev, const char *cmd); +int mt76_connac_mcu_uni_chip_config(struct mt76_dev *dev, const char *cmd); int mt76_connac_mcu_set_deep_sleep(struct mt76_dev *dev, bool enable); void mt76_connac_mcu_coredump_event(struct mt76_dev *dev, struct sk_buff *skb, struct mt76_connac_coredump *coredump); diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c index 0c40741273a9..cfe175dbc5f3 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c @@ -280,7 +280,7 @@ static int mt7925_chip_reset(void *data, u64 val) default: /* Collect the core dump before reset wifisys. */ mt792x_mutex_acquire(dev); - ret = mt7925_mcu_chip_config(dev, "assert"); + ret = mt792x_mcu_chip_config(dev, "assert"); mt792x_mutex_release(dev); break; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c index d89230fc9687..83f5f02395ec 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c @@ -1280,7 +1280,7 @@ int mt7925_mcu_set_deep_sleep(struct mt792x_dev *dev, bool enable) snprintf(cmd, sizeof(cmd), "KeepFullPwr %d", !enable); - return mt7925_mcu_chip_config(dev, cmd); + return mt792x_mcu_chip_config(dev, cmd); } EXPORT_SYMBOL_GPL(mt7925_mcu_set_deep_sleep); @@ -1291,11 +1291,11 @@ int mt7925_mcu_set_thermal_protect(struct mt792x_dev *dev) snprintf(cmd, sizeof(cmd), "ThermalProtGband %d %d %d %d %d %d %d %d %d %d", 0, 100, 90, 80, 30, 1, 1, 115, 105, 5); - ret = mt7925_mcu_chip_config(dev, cmd); + ret = mt792x_mcu_chip_config(dev, cmd); snprintf(cmd, sizeof(cmd), "ThermalProtAband %d %d %d %d %d %d %d %d %d %d", 1, 100, 90, 80, 30, 1, 1, 115, 105, 5); - ret |= mt7925_mcu_chip_config(dev, cmd); + ret |= mt792x_mcu_chip_config(dev, cmd); return ret; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h index fe40873e6107..7a9005db9c00 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h @@ -115,7 +115,6 @@ enum { }; enum { - UNI_CHIP_CONFIG_CHIP_CFG = 0x2, UNI_CHIP_CONFIG_NIC_CAPA = 0x3, }; diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h index 260abdc978f8..79f57736db35 100644 --- a/drivers/net/wireless/mediatek/mt76/mt792x.h +++ b/drivers/net/wireless/mediatek/mt76/mt792x.h @@ -669,6 +669,7 @@ void mt792x_mac_link_bss_remove(struct mt792x_dev *dev, struct mt792x_bss_conf *mconf, struct mt792x_link_sta *mlink); void mt792x_config_mac_addr_list(struct mt792x_dev *dev); +int mt792x_mcu_chip_config(struct mt792x_dev *dev, const char *cmd); static inline char *mt792x_ram_name(struct mt792x_dev *dev) { diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_core.c b/drivers/net/wireless/mediatek/mt76/mt792x_core.c index 7dddce02d600..a59aedd498b2 100644 --- a/drivers/net/wireless/mediatek/mt76/mt792x_core.c +++ b/drivers/net/wireless/mediatek/mt76/mt792x_core.c @@ -1238,6 +1238,19 @@ void mt792x_config_mac_addr_list(struct mt792x_dev *dev) } EXPORT_SYMBOL_GPL(mt792x_config_mac_addr_list); +/* Pick the chip_config command form the running chip's firmware understands: + * connac3 (mt7925/mt7928) needs the unified command, connac2 (mt7921/mt7922) + * uses the legacy CE command. + */ +int mt792x_mcu_chip_config(struct mt792x_dev *dev, const char *cmd) +{ + if (is_connac3(&dev->mt76)) + return mt76_connac_mcu_uni_chip_config(&dev->mt76, cmd); + + return mt76_connac_mcu_chip_config(&dev->mt76, cmd); +} +EXPORT_SYMBOL_GPL(mt792x_mcu_chip_config); + MODULE_DESCRIPTION("MediaTek MT792x core driver"); MODULE_LICENSE("Dual BSD/GPL"); MODULE_AUTHOR("Lorenzo Bianconi <lorenzo@kernel.org>"); -- 2.45.2 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v5 3/5] wifi: mt76: add ACPI MTFG option for bus configuration 2026-11-26 9:54 ` [PATCH v5 0/5] wifi: mt76: optimize mt7922/mt7928 T-put per Tx/Rx stats Anthony Liu 2026-11-26 9:54 ` [PATCH v5 1/5] wifi: mt76: refactor chip_config to accept generic commands Anthony Liu 2026-11-26 9:54 ` [PATCH v5 2/5] wifi: mt76: refactor chip_cfg commands to be a generic API Anthony Liu @ 2026-11-26 9:54 ` Anthony Liu 2026-11-26 9:54 ` [PATCH v5 4/5] wifi: mt76: add PCIe speed tuning for mt7922/mt7928 Anthony Liu ` (2 subsequent siblings) 5 siblings, 0 replies; 14+ messages in thread From: Anthony Liu @ 2026-11-26 9:54 UTC (permalink / raw) To: anthony.liu Cc: Emery.Hsin, Jb.Tsai, Leon.Yen, Litien.Chang, Quan.Zhou, Ryder.Lee, Sean.Wang, kun.wu, linux-mediatek, linux-wireless, lorenzo, nbd Extend ACPI MTFG table parsing to support an additional MTFG bus configuration option. Signed-off-by: Anthony Liu <anthony.liu@mediatek.com> Reviewed-by: Felix Fietkau <nbd@nbd.name> --- drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c b/drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c index 2d7a967fd399..d8268ec56f98 100644 --- a/drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c +++ b/drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c @@ -398,6 +398,7 @@ u8 mt792x_acpi_get_flags(struct mt792x_phy *phy) } map[] = { { 1, 1 }, { 4, 2 }, + { 13, 3 }, }; u8 flags = BIT(0); int i, j; -- 2.45.2 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v5 4/5] wifi: mt76: add PCIe speed tuning for mt7922/mt7928 2026-11-26 9:54 ` [PATCH v5 0/5] wifi: mt76: optimize mt7922/mt7928 T-put per Tx/Rx stats Anthony Liu ` (2 preceding siblings ...) 2026-11-26 9:54 ` [PATCH v5 3/5] wifi: mt76: add ACPI MTFG option for bus configuration Anthony Liu @ 2026-11-26 9:54 ` Anthony Liu 2026-11-26 9:54 ` [PATCH v5 5/5] wifi: mt76: mt7922/mt7928: send Tx/Rx statistics to FW for link tuning Anthony Liu 2026-11-26 16:03 ` [PATCH v5 0/5] wifi: mt76: optimize mt7922/mt7928 T-put per Tx/Rx stats Felix Fietkau 5 siblings, 0 replies; 14+ messages in thread From: Anthony Liu @ 2026-11-26 9:54 UTC (permalink / raw) To: anthony.liu Cc: Emery.Hsin, Jb.Tsai, Leon.Yen, Litien.Chang, Quan.Zhou, Ryder.Lee, Sean.Wang, kun.wu, linux-mediatek, linux-wireless, lorenzo, nbd Some hardware platforms use ACPI MTFG table denoting the existence of noise that impacts Wi-Fi performance. This patch reads the ACPI SAR info and notifies FW to detect current status and to adjust PCIe bus to mitigate the noise. Signed-off-by: Anthony Liu <anthony.liu@mediatek.com> Reviewed-by: Felix Fietkau <nbd@nbd.name> --- .../net/wireless/mediatek/mt76/mt7921/init.c | 5 ++++ .../wireless/mediatek/mt76/mt7921/pci_mac.c | 6 ++++ .../net/wireless/mediatek/mt76/mt7925/init.c | 2 ++ .../wireless/mediatek/mt76/mt7925/pci_mac.c | 6 ++++ drivers/net/wireless/mediatek/mt76/mt792x.h | 4 +++ .../net/wireless/mediatek/mt76/mt792x_core.c | 28 +++++++++++++++++++ 6 files changed, 51 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/init.c b/drivers/net/wireless/mediatek/mt76/mt7921/init.c index a87ebcff547b..8059405f2d5c 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/init.c @@ -102,6 +102,11 @@ static int __mt7921_init_hardware(struct mt792x_dev *dev) goto out; ret = mt7921_mac_init(dev); + if (ret) + goto out; + + if (is_mt7922(&dev->mt76)) + ret = mt792x_mcu_set_dyn_pcie_gen(dev); out: return ret; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c index d5c33a0d409c..6d8e221eb83f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c @@ -118,6 +118,12 @@ int mt7921e_mac_reset(struct mt792x_dev *dev) if (err) goto out; + if (is_mt7922(&dev->mt76)) { + err = mt792x_mcu_set_dyn_pcie_gen(dev); + if (err) + goto out; + } + err = __mt7921_start(&dev->phy); out: diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/init.c b/drivers/net/wireless/mediatek/mt76/mt7925/init.c index ad51f71babd7..b8d629f9bbe5 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/init.c @@ -126,6 +126,8 @@ static int __mt7925_init_hardware(struct mt792x_dev *dev) } } + if (is_mt7928(&dev->mt76)) + ret = mt792x_mcu_set_dyn_pcie_gen(dev); out: return ret; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c index 6189615d6604..85da7645c8e2 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c @@ -202,6 +202,12 @@ int mt7925e_mac_reset(struct mt792x_dev *dev) goto out; } + if (is_mt7928(&dev->mt76)) { + err = mt792x_mcu_set_dyn_pcie_gen(dev); + if (err) + goto out; + } + err = __mt7925_start(&dev->phy); out: clear_bit(MT76_RESET, &dev->mphy.state); diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h index 79f57736db35..cdaf07725598 100644 --- a/drivers/net/wireless/mediatek/mt76/mt792x.h +++ b/drivers/net/wireless/mediatek/mt76/mt792x.h @@ -670,6 +670,7 @@ void mt792x_mac_link_bss_remove(struct mt792x_dev *dev, struct mt792x_link_sta *mlink); void mt792x_config_mac_addr_list(struct mt792x_dev *dev); int mt792x_mcu_chip_config(struct mt792x_dev *dev, const char *cmd); +int mt792x_mcu_set_dyn_pcie_gen(struct mt792x_dev *dev); static inline char *mt792x_ram_name(struct mt792x_dev *dev) { @@ -768,6 +769,9 @@ int __mt792xe_mcu_drv_pmctrl(struct mt792x_dev *dev); int mt792xe_mcu_drv_pmctrl(struct mt792x_dev *dev); int mt792xe_mcu_fw_pmctrl(struct mt792x_dev *dev); +#define MT792X_ACPI_FLAG_VALID BIT(0) /* ACPI SAR is valid */ +#define MT792X_ACPI_FLAG_PCIe BIT(3) /* Valid only when valid is set */ + #ifdef CONFIG_ACPI int mt792x_init_acpi_sar(struct mt792x_dev *dev); int mt792x_init_acpi_sar_power(struct mt792x_phy *phy, bool set_default); diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_core.c b/drivers/net/wireless/mediatek/mt76/mt792x_core.c index a59aedd498b2..25408fcc8af3 100644 --- a/drivers/net/wireless/mediatek/mt76/mt792x_core.c +++ b/drivers/net/wireless/mediatek/mt76/mt792x_core.c @@ -1251,6 +1251,34 @@ int mt792x_mcu_chip_config(struct mt792x_dev *dev, const char *cmd) } EXPORT_SYMBOL_GPL(mt792x_mcu_chip_config); +int mt792x_mcu_set_dyn_pcie_gen(struct mt792x_dev *dev) +{ + u8 acpi_conf = mt792x_acpi_get_flags(&dev->phy); + char cmd[64]; + int ret = 0; + + if (!(acpi_conf & MT792X_ACPI_FLAG_VALID) || + !(acpi_conf & MT792X_ACPI_FLAG_PCIe)) + return 0; + + strscpy(cmd, "PcieGenSwitch 1 1200 0 -60"); + ret = mt792x_mcu_chip_config(dev, cmd); + if (ret) + return ret; + + strscpy(cmd, "PcieGenSwitchAGGen2 0"); + ret = mt792x_mcu_chip_config(dev, cmd); + if (ret) + return ret; + + if (!dev->mphy.cap.has_6ghz) + return 0; + + strscpy(cmd, "PcieGenSwitch6G 1"); + return mt792x_mcu_chip_config(dev, cmd); +} +EXPORT_SYMBOL_GPL(mt792x_mcu_set_dyn_pcie_gen); + MODULE_DESCRIPTION("MediaTek MT792x core driver"); MODULE_LICENSE("Dual BSD/GPL"); MODULE_AUTHOR("Lorenzo Bianconi <lorenzo@kernel.org>"); -- 2.45.2 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v5 5/5] wifi: mt76: mt7922/mt7928: send Tx/Rx statistics to FW for link tuning 2026-11-26 9:54 ` [PATCH v5 0/5] wifi: mt76: optimize mt7922/mt7928 T-put per Tx/Rx stats Anthony Liu ` (3 preceding siblings ...) 2026-11-26 9:54 ` [PATCH v5 4/5] wifi: mt76: add PCIe speed tuning for mt7922/mt7928 Anthony Liu @ 2026-11-26 9:54 ` Anthony Liu 2026-11-26 16:03 ` [PATCH v5 0/5] wifi: mt76: optimize mt7922/mt7928 T-put per Tx/Rx stats Felix Fietkau 5 siblings, 0 replies; 14+ messages in thread From: Anthony Liu @ 2026-11-26 9:54 UTC (permalink / raw) To: anthony.liu Cc: Emery.Hsin, Jb.Tsai, Leon.Yen, Litien.Chang, Quan.Zhou, Ryder.Lee, Sean.Wang, kun.wu, linux-mediatek, linux-wireless, lorenzo, nbd Update Tx/Rx statistics to FW for link speed tuning in FW. Signed-off-by: Anthony Liu <anthony.liu@mediatek.com> Reviewed-by: Felix Fietkau <nbd@nbd.name> --- .../wireless/mediatek/mt76/mt76_connac_mcu.c | 15 ++ .../wireless/mediatek/mt76/mt76_connac_mcu.h | 53 ++++++ .../wireless/mediatek/mt76/mt7921/debugfs.c | 14 ++ .../net/wireless/mediatek/mt76/mt7921/mac.c | 6 + .../net/wireless/mediatek/mt76/mt7921/main.c | 4 + .../net/wireless/mediatek/mt76/mt7921/pci.c | 12 ++ .../wireless/mediatek/mt76/mt7921/pci_mac.c | 3 + .../wireless/mediatek/mt76/mt7925/debugfs.c | 13 ++ .../net/wireless/mediatek/mt76/mt7925/mac.c | 5 +- .../net/wireless/mediatek/mt76/mt7925/main.c | 4 + .../net/wireless/mediatek/mt76/mt7925/pci.c | 15 ++ .../wireless/mediatek/mt76/mt7925/pci_mac.c | 3 + drivers/net/wireless/mediatek/mt76/mt792x.h | 55 ++++++ .../net/wireless/mediatek/mt76/mt792x_core.c | 169 ++++++++++++++++++ .../wireless/mediatek/mt76/mt792x_debugfs.c | 32 ++++ 15 files changed, 402 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c index 01434b1e01f5..56f287c8ee54 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c @@ -272,6 +272,21 @@ int mt76_connac_mcu_set_rts_thresh(struct mt76_dev *dev, u32 val, u8 band) } EXPORT_SYMBOL_GPL(mt76_connac_mcu_set_rts_thresh); +int mt76_connac_mcu_uni_set_perf_ind(struct mt76_dev *dev, u32 valid_period, + const u64 *tx_bytes, const u64 *rx_bytes) +{ + struct mt76_connac_uni_perf_ind req = { + .tag = cpu_to_le16(UNI_PERF_IND_PARM), + .len = cpu_to_le16(sizeof(req) - sizeof(req.rsv)), + }; + + mt76_connac_perf_ind_v1_fill(&req.perf, valid_period, tx_bytes, rx_bytes); + + return mt76_mcu_send_msg(dev, MCU_UNI_CMD(PERF_IND), &req, + sizeof(req), false); +} +EXPORT_SYMBOL_GPL(mt76_connac_mcu_uni_set_perf_ind); + void mt76_connac_mcu_beacon_loss_iter(void *priv, u8 *mac, struct ieee80211_vif *vif) { diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h index 0d2670b7b9fb..605030f70a02 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h @@ -1354,6 +1354,7 @@ enum { MCU_UNI_CMD_PP = 0x38, MCU_UNI_CMD_FIXED_RATE_TABLE = 0x40, MCU_UNI_CMD_RSSI_MONITOR = 0x41, + MCU_UNI_CMD_PERF_IND = 0x44, MCU_UNI_CMD_TESTMODE_CTRL = 0x46, MCU_UNI_CMD_NAN = 0x56, MCU_UNI_CMD_RRO = 0x57, @@ -1404,6 +1405,7 @@ enum { MCU_CE_CMD_SET_RATE_TX_POWER = 0x5d, MCU_CE_CMD_SCHED_SCAN_ENABLE = 0x61, MCU_CE_CMD_SCHED_SCAN_REQ = 0x62, + MCU_CE_CMD_PERF_IND = 0x7e, MCU_CE_CMD_GET_NIC_CAPAB = 0x8a, MCU_CE_CMD_RSSI_MONITOR = 0xa1, MCU_CE_CMD_SET_MU_EDCA_PARMS = 0xb0, @@ -1471,6 +1473,10 @@ enum { UNI_CHIP_CONFIG_CHIP_CFG = 2, }; +enum { + UNI_PERF_IND_PARM = 0, +}; + enum { MT_NIC_CAP_TX_RESOURCE, MT_NIC_CAP_TX_EFUSE_ADDR, @@ -1883,6 +1889,51 @@ struct mt76_connac_config { u8 data[320]; } __packed; +struct mt76_connac_perf_ind { + /* DW0 - common info*/ + u8 cmd_ver; + u8 mask; /* per-field valid bitmap */ + __le16 cmd_len; + + /* DW1 - valid period of the stats */ + __le32 valid_period; + + /* DW2~15 - stats */ + __le32 cur_tx_bytes[4]; + __le32 cur_rx_bytes[4]; + __le16 cur_rx_rate[4]; + u8 cur_rx_rcpi0[4]; + u8 cur_rx_rcpi1[4]; + u8 cur_rx_nss[4]; + u8 cur_rx_nss2[4]; + + /* DW16-77 padding */ + __le32 pad[62]; +} __packed; + +struct mt76_connac_uni_perf_ind { + u8 rsv[4]; + __le16 tag; + __le16 len; + struct mt76_connac_perf_ind perf; +} __packed; + +static inline void +mt76_connac_perf_ind_v1_fill(struct mt76_connac_perf_ind *perf, u32 valid_period, + const u64 *tx_bytes, const u64 *rx_bytes) +{ + int i; + + perf->mask = BIT(0) | BIT(1); + perf->cmd_len = cpu_to_le16(sizeof(*perf)); + perf->valid_period = cpu_to_le32(valid_period); + + for (i = 0; i < ARRAY_SIZE(perf->cur_tx_bytes); i++) { + perf->cur_tx_bytes[i] = cpu_to_le32(tx_bytes[i]); + perf->cur_rx_bytes[i] = cpu_to_le32(rx_bytes[i]); + } +} + struct mt76_connac_mcu_uni_event { u8 cid; u8 pad[3]; @@ -2083,6 +2134,8 @@ int mt76_connac_mcu_sta_cmd(struct mt76_phy *phy, void mt76_connac_mcu_beacon_loss_iter(void *priv, u8 *mac, struct ieee80211_vif *vif); int mt76_connac_mcu_set_rts_thresh(struct mt76_dev *dev, u32 val, u8 band); +int mt76_connac_mcu_uni_set_perf_ind(struct mt76_dev *dev, u32 valid_period, + const u64 *tx_bytes, const u64 *rx_bytes); int mt76_connac_mcu_set_mac_enable(struct mt76_dev *dev, int band, bool enable, bool hdr_trans); int mt76_connac_mcu_init_download(struct mt76_dev *dev, u32 addr, u32 len, diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c index 14c70ffa9665..5fa3c51a53bd 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c @@ -262,6 +262,11 @@ mt7921s_sched_quota_read(struct seq_file *s, void *data) return 0; } +DEFINE_DEBUGFS_ATTRIBUTE(fops_perf_ind_trig, NULL, mt792x_perf_ind_trig, "%lld\n"); + +DEFINE_DEBUGFS_ATTRIBUTE(fops_perf_ind_enable, mt792x_perf_ind_enable_get, + mt792x_perf_ind_enable_set, "%lld\n"); + int mt7921_init_debugfs(struct mt792x_dev *dev) { struct dentry *dir; @@ -291,5 +296,14 @@ int mt7921_init_debugfs(struct mt792x_dev *dev) if (mt76_is_sdio(&dev->mt76)) debugfs_create_devm_seqfile(dev->mt76.dev, "sched-quota", dir, mt7921s_sched_quota_read); + + /* PERF_IND is supported on MT7922 PCIe version */ + if (mt76_is_mmio(&dev->mt76) && is_mt7922(&dev->mt76)) { + debugfs_create_file("perf_ind_enable", 0600, dir, dev, + &fops_perf_ind_enable); + debugfs_create_file("perf_ind_trig", 0200, dir, dev, + &fops_perf_ind_trig); + } + return 0; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c index a2d577872566..30188fda893e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c @@ -613,6 +613,12 @@ void mt7921_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, case PKT_TYPE_NORMAL_MCU: case PKT_TYPE_NORMAL: if (!mt7921_mac_fill_rx(dev, skb)) { + struct mt76_rx_status *status = + (struct mt76_rx_status *)skb->cb; + + if (is_mt7922(&dev->mt76)) + mt792x_perf_account_rx(dev, status->wcid, skb->len); + mt76_rx(&dev->mt76, q, skb); return; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index 9b13e9c25cf3..02f1feef0140 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -728,6 +728,10 @@ static void mt7921_bss_info_changed(struct ieee80211_hw *hw, mt7921_mcu_sta_update(dev, NULL, vif, true, MT76_STA_INFO_STATE_ASSOC); mt7921_mcu_set_beacon_filter(dev, vif, vif->cfg.assoc); + + /* PERF_IND is supported on MT7922 only within this family */ + if (is_mt7922(&dev->mt76)) + mt792x_perf_ind_update(dev, vif, MT792x_PERF_IND_TIME); } if (changed & BSS_CHANGED_ARP_FILTER) { diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c index 8d6c964bd6b6..87e42686358a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c @@ -68,6 +68,8 @@ static void mt7921e_unregister_device(struct mt792x_dev *dev) netif_napi_del(&dev->mt76.napi[i]); } skb_queue_purge(&dev->phy.scan_event_list); + if (is_mt7922(&dev->mt76)) + cancel_delayed_work_sync(&dev->perf.work); cancel_delayed_work_sync(&dev->coredump.work); skb_queue_purge(&dev->coredump.msg_list); @@ -455,6 +457,10 @@ static int mt7921_pci_probe(struct pci_dev *pdev, if (ret) goto err_free_irq; + /* the periodic performance indication is started on association */ + if (is_mt7922(&dev->mt76)) + mt792x_perf_ind_init(dev); + if (of_property_read_bool(dev->mt76.dev->of_node, "wakeup-source")) device_init_wakeup(dev->mt76.dev, true); @@ -494,6 +500,8 @@ static int mt7921_pci_suspend(struct device *device) pm->suspended = true; flush_work(&dev->reset_work); + if (is_mt7922(&dev->mt76)) + cancel_delayed_work_sync(&dev->perf.work); cancel_delayed_work_sync(&pm->ps_work); cancel_work_sync(&pm->wake_work); @@ -617,6 +625,10 @@ static int mt7921_pci_resume(struct device *device) mt7921_mcu_regd_update(dev, mdev->alpha2, dev->country_ie_env); err = mt7921_mcu_radio_led_ctrl(dev, EXT_CMD_RADIO_ON_LED); + + /* re-arm the periodic performance indication if any bss is connected */ + if (is_mt7922(&dev->mt76)) + mt792x_perf_ind_resched(dev); failed: pm->suspended = false; diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c index 6d8e221eb83f..b3f36a630292 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c @@ -21,6 +21,9 @@ int mt7921e_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, if (unlikely(tx_info->skb->len <= ETH_HLEN)) return -EINVAL; + if (is_mt7922(&dev->mt76)) + mt792x_perf_account_tx(dev, info->control.vif, tx_info->skb->len); + if (!wcid) wcid = &dev->mt76.global_wcid; diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c index cfe175dbc5f3..a92b930f6686 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c @@ -290,6 +290,11 @@ static int mt7925_chip_reset(void *data, u64 val) DEFINE_DEBUGFS_ATTRIBUTE(fops_reset, NULL, mt7925_chip_reset, "%lld\n"); +DEFINE_DEBUGFS_ATTRIBUTE(fops_perf_ind_trig, NULL, mt792x_perf_ind_trig, "%lld\n"); + +DEFINE_DEBUGFS_ATTRIBUTE(fops_perf_ind_enable, mt792x_perf_ind_enable_get, + mt792x_perf_ind_enable_set, "%lld\n"); + int mt7925_init_debugfs(struct mt792x_dev *dev) { struct dentry *dir; @@ -317,5 +322,13 @@ int mt7925_init_debugfs(struct mt792x_dev *dev) mt792x_pm_stats); debugfs_create_file("deep-sleep", 0600, dir, dev, &fops_ds); + /* PERF_IND is supported on MT7928 PCIe version */ + if (mt76_is_mmio(&dev->mt76) && is_mt7928(&dev->mt76)) { + debugfs_create_file("perf_ind_enable", 0600, dir, dev, + &fops_perf_ind_enable); + debugfs_create_file("perf_ind_trig", 0200, dir, dev, + &fops_perf_ind_trig); + } + return 0; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c index 692616df110f..4b233a234ab0 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c @@ -1533,12 +1533,15 @@ void mt7925_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; - if (!(status->flag & RX_FLAG_8023) && + if (!(status->flag & RX_FLAG_8023) && mt7925_p2p_rx_drop_chan_mismatch(dev, skb)) { dev_kfree_skb(skb); return; } + if (is_mt7928(&dev->mt76)) + mt792x_perf_account_rx(dev, status->wcid, skb->len); + mt76_rx(&dev->mt76, q, skb); return; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c index b7348e6f0290..1a2e47603d24 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c @@ -2470,6 +2470,10 @@ static void mt7925_vif_cfg_changed(struct ieee80211_hw *hw, if (ieee80211_vif_is_mld(vif)) mvif->mlo_pm_state = MT792x_MLO_LINK_ASSOC; + + /* PERF_IND is supported on MT7928 only within this family */ + if (is_mt7928(&dev->mt76)) + mt792x_perf_ind_update(dev, vif, MT792x_PERF_IND_TIME); } if (changed & BSS_CHANGED_ARP_FILTER) { diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/pci.c b/drivers/net/wireless/mediatek/mt76/mt7925/pci.c index e49fddc9c81f..a2fefe2642ef 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/pci.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/pci.c @@ -117,6 +117,9 @@ static void mt7925e_unregister_device(struct mt792x_dev *dev) cancel_work_sync(&dev->init_work); dev->hw_init_done = false; + if (is_mt7928(&dev->mt76)) + cancel_delayed_work_sync(&dev->perf.work); + mt76_unregister_device(&dev->mt76); set_bit(MT76_REMOVED, &dev->mphy.state); cancel_work_sync(&dev->reset_work); @@ -779,6 +782,12 @@ static int mt7925_pci_probe(struct pci_dev *pdev, if (ret) goto err_free_dma; + /* PERF_IND is only supported on MT7928 in this family; MT7925 opts out. + * The periodic indication itself is started on association. + */ + if (is_mt7928(&dev->mt76)) + mt792x_perf_ind_init(dev); + return 0; err_free_dma: @@ -815,6 +824,8 @@ static int mt7925_pci_suspend(struct device *device) pm->suspended = true; dev->hif_resumed = false; flush_work(&dev->reset_work); + if (is_mt7928(&dev->mt76)) + cancel_delayed_work_sync(&dev->perf.work); cancel_delayed_work_sync(&pm->ps_work); cancel_delayed_work_sync(&dev->mlo_pm_work); cancel_work_sync(&pm->wake_work); @@ -950,6 +961,10 @@ static int _mt7925_pci_resume(struct device *device, bool restore) mt7925_mcu_set_deep_sleep(dev, false); mt7925_mcu_regd_update(dev, mdev->alpha2, dev->country_ie_env); + + /* re-arm the periodic performance indication if any bss is connected */ + if (is_mt7928(&dev->mt76)) + mt792x_perf_ind_resched(dev); failed: pm->suspended = false; diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c index 85da7645c8e2..31667c80ab74 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c @@ -24,6 +24,9 @@ int mt7925e_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, if (unlikely(tx_info->skb->len <= ETH_HLEN)) return -EINVAL; + if (is_mt7928(&dev->mt76)) + mt792x_perf_account_tx(dev, info->control.vif, tx_info->skb->len); + if (!wcid) wcid = &dev->mt76.global_wcid; diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h index cdaf07725598..860f4c9dc326 100644 --- a/drivers/net/wireless/mediatek/mt76/mt792x.h +++ b/drivers/net/wireless/mediatek/mt76/mt792x.h @@ -45,6 +45,9 @@ #define MT792x_WATCHDOG_TIME (HZ / 4) +#define MT792x_PERF_UPDATE_PERIOD 1000 /* ms */ +#define MT792x_PERF_IND_TIME (HZ) /* 1 second */ + #define MT792x_DRV_OWN_RETRY_COUNT 10 #define MT792x_MCU_INIT_RETRY_COUNT 10 #define MT792x_WFSYS_INIT_RETRY_COUNT 2 @@ -175,6 +178,12 @@ struct mt792x_bss_conf { /* For group-addressed frames that are sent outside a TXQ */ struct mt792x_link_sta bmc; bool bmc_valid; + + /* Tx/Rx statistics */ + atomic64_t perf_tx_bytes; + atomic64_t perf_rx_bytes; + u64 perf_last_tx_bytes; + u64 perf_last_rx_bytes; }; struct mt792x_nan_conf { @@ -433,6 +442,11 @@ struct mt792x_dev { u32 size; bool reused; } cached_cal; + + struct { + struct delayed_work work; + bool enabled; + } perf; }; static inline bool @@ -483,6 +497,39 @@ mt792x_sta_to_link(struct mt792x_sta *msta, u8 link_id) lockdep_is_held(&msta->vif->phy->dev->mt76.mutex)); } +/* accumulate TX bytes for the interface transmitting @len bytes */ +static inline void +mt792x_perf_account_tx(struct mt792x_dev *dev, struct ieee80211_vif *vif, + u32 len) +{ + struct mt792x_vif *mvif; + + if (!vif) + return; + + mvif = (struct mt792x_vif *)vif->drv_priv; + + atomic64_add(len, &mvif->bss_conf.perf_tx_bytes); +} + +/* accumulate RX bytes for the interface owning @wcid */ +static inline void +mt792x_perf_account_rx(struct mt792x_dev *dev, struct mt76_wcid *wcid, u32 len) +{ + struct mt792x_link_sta *link; + + // allow only real station link through + if (!wcid || !wcid->sta) + return; + + link = container_of(wcid, struct mt792x_link_sta, wcid); + + if (!link->sta || !link->sta->vif) + return; + + atomic64_add(len, &link->sta->vif->bss_conf.perf_rx_bytes); +} + static inline struct mt792x_link_sta * mt792x_sta_to_link_rcu(struct mt792x_sta *msta, u8 link_id) { @@ -671,6 +718,14 @@ void mt792x_mac_link_bss_remove(struct mt792x_dev *dev, void mt792x_config_mac_addr_list(struct mt792x_dev *dev); int mt792x_mcu_chip_config(struct mt792x_dev *dev, const char *cmd); int mt792x_mcu_set_dyn_pcie_gen(struct mt792x_dev *dev); +void mt792x_perf_ind_update(struct mt792x_dev *dev, struct ieee80211_vif *vif, + unsigned long delay); +void mt792x_perf_ind_init(struct mt792x_dev *dev); +void mt792x_perf_ind_resched(struct mt792x_dev *dev); +int mt792x_perf_ind_trigger(struct mt792x_dev *dev, u64 val); +int mt792x_perf_ind_trig(void *data, u64 val); +int mt792x_perf_ind_enable_get(void *data, u64 *val); +int mt792x_perf_ind_enable_set(void *data, u64 val); static inline char *mt792x_ram_name(struct mt792x_dev *dev) { diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_core.c b/drivers/net/wireless/mediatek/mt76/mt792x_core.c index 25408fcc8af3..46536abf7287 100644 --- a/drivers/net/wireless/mediatek/mt76/mt792x_core.c +++ b/drivers/net/wireless/mediatek/mt76/mt792x_core.c @@ -367,6 +367,175 @@ int mt792x_get_stats(struct ieee80211_hw *hw, } EXPORT_SYMBOL_GPL(mt792x_get_stats); +static int mt792x_mcu_set_perf_ind(struct mt792x_dev *dev, u32 valid_period, + const u64 *tx_bytes, const u64 *rx_bytes) +{ + struct mt76_connac_perf_ind req = {}; + + mt76_connac_perf_ind_v1_fill(&req, valid_period, tx_bytes, rx_bytes); + + return mt76_mcu_send_msg(&dev->mt76, MCU_CE_CMD(PERF_IND), + &req, sizeof(req), false); +} + +static int mt792x_mcu_perf_ind(struct mt792x_dev *dev, u32 valid_period, + const u64 *tx_bytes, const u64 *rx_bytes) +{ + if (is_connac3(&dev->mt76)) + return mt76_connac_mcu_uni_set_perf_ind(&dev->mt76, valid_period, + tx_bytes, rx_bytes); + + return mt792x_mcu_set_perf_ind(dev, valid_period, tx_bytes, rx_bytes); +} + +static bool mt792x_perf_vif_active(struct ieee80211_vif *vif) +{ + return vif->cfg.assoc; +} + +struct mt792x_perf_iter_data { + u64 tx_delta[MT792x_MAX_INTERFACES]; + u64 rx_delta[MT792x_MAX_INTERFACES]; + bool connected; +}; + +static void mt792x_perf_collect_iter(void *priv, u8 *mac, + struct ieee80211_vif *vif) +{ + struct mt792x_perf_iter_data *data = priv; + struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; + struct mt792x_bss_conf *mconf = &mvif->bss_conf; + u8 idx = mconf->mt76.idx; + u64 tx, rx, last_tx, last_rx; + + if (!mt792x_perf_vif_active(vif) || idx >= MT792x_MAX_INTERFACES) + return; + + data->connected = true; + + tx = atomic64_read(&mconf->perf_tx_bytes); + if (!tx) { + data->tx_delta[idx] = 0; + } else { + last_tx = mconf->perf_last_tx_bytes; + data->tx_delta[idx] = tx <= last_tx ? 0 : tx - last_tx; + mconf->perf_last_tx_bytes = tx; + } + + rx = atomic64_read(&mconf->perf_rx_bytes); + if (!rx) { + data->rx_delta[idx] = 0; + } else { + last_rx = mconf->perf_last_rx_bytes; + data->rx_delta[idx] = rx <= last_rx ? 0 : rx - last_rx; + mconf->perf_last_rx_bytes = rx; + } +} + +static void mt792x_perf_active_iter(void *priv, u8 *mac, + struct ieee80211_vif *vif) +{ + bool *active = priv; + + if (mt792x_perf_vif_active(vif)) + *active = true; +} + +static bool mt792x_perf_any_connected(struct mt792x_dev *dev) +{ + bool active = false; + + ieee80211_iterate_active_interfaces(dev->mphy.hw, + IEEE80211_IFACE_ITER_NORMAL, + mt792x_perf_active_iter, + &active); + return active; +} + +void mt792x_perf_ind_update(struct mt792x_dev *dev, struct ieee80211_vif *vif, + unsigned long delay) +{ + struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; + + /* Reset snapshots so a future re-association starts clean */ + if (!mt792x_perf_vif_active(vif)) { + atomic64_set(&mvif->bss_conf.perf_tx_bytes, 0); + atomic64_set(&mvif->bss_conf.perf_rx_bytes, 0); + mvif->bss_conf.perf_last_tx_bytes = 0; + mvif->bss_conf.perf_last_rx_bytes = 0; + } + + if (!mt76_is_mmio(&dev->mt76)) + return; + + if (mt792x_perf_any_connected(dev)) + queue_delayed_work(dev->mt76.wq, &dev->perf.work, delay); + else + cancel_delayed_work(&dev->perf.work); +} +EXPORT_SYMBOL_GPL(mt792x_perf_ind_update); + +static void mt792x_perf_work(struct work_struct *work) +{ + struct mt792x_dev *dev = container_of(work, struct mt792x_dev, + perf.work.work); + struct mt792x_perf_iter_data data = {}; + + /* not enabled */ + if (!dev->perf.enabled) + return; + + /* skip while asleep */ + if (!mt76_connac_pm_ref(&dev->mphy, &dev->pm)) + goto reschedule; + + ieee80211_iterate_active_interfaces(dev->mphy.hw, + IEEE80211_IFACE_ITER_NORMAL, + mt792x_perf_collect_iter, &data); + + if (data.connected) + mt792x_mcu_perf_ind(dev, MT792x_PERF_UPDATE_PERIOD, + data.tx_delta, data.rx_delta); + + mt76_connac_pm_unref(&dev->mphy, &dev->pm); + +reschedule: + if (mt792x_perf_any_connected(dev)) + queue_delayed_work(dev->mt76.wq, &dev->perf.work, + MT792x_PERF_IND_TIME); +} + +void mt792x_perf_ind_init(struct mt792x_dev *dev) +{ + INIT_DELAYED_WORK(&dev->perf.work, mt792x_perf_work); +} +EXPORT_SYMBOL_GPL(mt792x_perf_ind_init); + +void mt792x_perf_ind_resched(struct mt792x_dev *dev) +{ + if (mt792x_perf_any_connected(dev)) + queue_delayed_work(dev->mt76.wq, &dev->perf.work, + MT792x_PERF_IND_TIME); +} +EXPORT_SYMBOL_GPL(mt792x_perf_ind_resched); + +int mt792x_perf_ind_trigger(struct mt792x_dev *dev, u64 val) +{ + u64 bytes[MT792x_MAX_INTERFACES]; + int i; + + for (i = 0; i < MT792x_MAX_INTERFACES; i++) + bytes[i] = val; + + /* wake the chip and serialize against other MCU commands */ + mt792x_mutex_acquire(dev); + mt792x_mcu_perf_ind(dev, MT792x_PERF_UPDATE_PERIOD, bytes, bytes); + mt792x_mutex_release(dev); + + return 0; +} +EXPORT_SYMBOL_GPL(mt792x_perf_ind_trigger); + u64 mt792x_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_debugfs.c b/drivers/net/wireless/mediatek/mt76/mt792x_debugfs.c index 65c37e0cef8f..98683cdc7205 100644 --- a/drivers/net/wireless/mediatek/mt76/mt792x_debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt792x_debugfs.c @@ -166,3 +166,35 @@ int mt792x_pm_idle_timeout_get(void *data, u64 *val) return 0; } EXPORT_SYMBOL_GPL(mt792x_pm_idle_timeout_get); + +/* send one perf_ind carrying the written value in every tx/rx byte field */ +int mt792x_perf_ind_trig(void *data, u64 val) +{ + struct mt76_dev *mdev = data; + struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); + + return mt792x_perf_ind_trigger(dev, val); +} +EXPORT_SYMBOL_GPL(mt792x_perf_ind_trig); + +int mt792x_perf_ind_enable_get(void *data, u64 *val) +{ + struct mt76_dev *mdev = data; + struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); + + *val = dev->perf.enabled; + + return 0; +} +EXPORT_SYMBOL_GPL(mt792x_perf_ind_enable_get); + +int mt792x_perf_ind_enable_set(void *data, u64 val) +{ + struct mt76_dev *mdev = data; + struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); + + dev->perf.enabled = !!val; + + return 0; +} +EXPORT_SYMBOL_GPL(mt792x_perf_ind_enable_set); -- 2.45.2 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v5 0/5] wifi: mt76: optimize mt7922/mt7928 T-put per Tx/Rx stats 2026-11-26 9:54 ` [PATCH v5 0/5] wifi: mt76: optimize mt7922/mt7928 T-put per Tx/Rx stats Anthony Liu ` (4 preceding siblings ...) 2026-11-26 9:54 ` [PATCH v5 5/5] wifi: mt76: mt7922/mt7928: send Tx/Rx statistics to FW for link tuning Anthony Liu @ 2026-11-26 16:03 ` Felix Fietkau 2026-11-27 9:11 ` [PATCH v6 " Anthony Liu 5 siblings, 1 reply; 14+ messages in thread From: Felix Fietkau @ 2026-11-26 16:03 UTC (permalink / raw) To: Anthony Liu Cc: Emery.Hsin, Jb.Tsai, Leon.Yen, Litien.Chang, Quan.Zhou, Ryder.Lee, Sean.Wang, kun.wu, linux-mediatek, linux-wireless, lorenzo Hi Anthony, On 26.11.26 10:54, Anthony Liu wrote: > This series adds: > 1. Read the HW charactistics flag from ACPI BIOS. > 2. If the HW needs, collect and update Tx/Rx statistics to FW. > 3. FW can then decide how to adjust PCIe link to improve T-put. Please don't add tags like Reviewed-by for me when I haven't written that myself. Regarding the series - why is dev->perf.enabled disabled by default and only enabled via debugfs? Thanks, - Felix ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v6 0/5] wifi: mt76: optimize mt7922/mt7928 T-put per Tx/Rx stats 2026-11-26 16:03 ` [PATCH v5 0/5] wifi: mt76: optimize mt7922/mt7928 T-put per Tx/Rx stats Felix Fietkau @ 2026-11-27 9:11 ` Anthony Liu 2026-11-27 9:11 ` [PATCH v6 1/5] wifi: mt76: refactor chip_config to accept generic commands Anthony Liu ` (4 more replies) 0 siblings, 5 replies; 14+ messages in thread From: Anthony Liu @ 2026-11-27 9:11 UTC (permalink / raw) To: anthony.liu Cc: Emery.Hsin, Jb.Tsai, Leon.Yen, Litien.Chang, Quan.Zhou, Ryder.Lee, Sean.Wang, kun.wu, linux-mediatek, linux-wireless, lorenzo, nbd This series adds: 1. Read the HW charactistics flag from ACPI BIOS. 2. If the HW needs, collect and update Tx/Rx statistics to FW. 3. FW can then decide how to adjust PCIe link to improve T-put. Anthony Liu (5): wifi: mt76: refactor chip_config to accept generic commands wifi: mt76: refactor chip_cfg commands to be a generic API wifi: mt76: add ACPI MTFG option for bus configuration wifi: mt76: add PCIe speed tuning for mt7922/mt7928 wifi: mt76: mt7922/mt7928: send Tx/Rx statistics to FW for link tuning .../wireless/mediatek/mt76/mt7615/debugfs.c | 2 +- .../wireless/mediatek/mt76/mt76_connac_mcu.c | 54 ++++- .../wireless/mediatek/mt76/mt76_connac_mcu.h | 60 ++++- .../wireless/mediatek/mt76/mt7921/debugfs.c | 16 +- .../net/wireless/mediatek/mt76/mt7921/init.c | 5 + .../net/wireless/mediatek/mt76/mt7921/mac.c | 6 + .../net/wireless/mediatek/mt76/mt7921/main.c | 4 + .../net/wireless/mediatek/mt76/mt7921/pci.c | 17 ++ .../wireless/mediatek/mt76/mt7921/pci_mac.c | 9 + .../wireless/mediatek/mt76/mt7925/debugfs.c | 15 +- .../net/wireless/mediatek/mt76/mt7925/init.c | 2 + .../net/wireless/mediatek/mt76/mt7925/mac.c | 3 + .../net/wireless/mediatek/mt76/mt7925/main.c | 4 + .../net/wireless/mediatek/mt76/mt7925/mcu.c | 6 +- .../net/wireless/mediatek/mt76/mt7925/mcu.h | 1 - .../net/wireless/mediatek/mt76/mt7925/pci.c | 18 ++ .../wireless/mediatek/mt76/mt7925/pci_mac.c | 9 + drivers/net/wireless/mediatek/mt76/mt792x.h | 60 +++++ .../wireless/mediatek/mt76/mt792x_acpi_sar.c | 1 + .../net/wireless/mediatek/mt76/mt792x_core.c | 210 ++++++++++++++++++ .../wireless/mediatek/mt76/mt792x_debugfs.c | 32 +++ 21 files changed, 524 insertions(+), 10 deletions(-) -- 2.45.2 --- V5 -> V6: Enable perf_ind by default, remove wrongly added Reviewed-By V4 -> V5: Fix email title, reduce dup code, more checks to exclude 7921. V3 -> V4: Add cover letter, fix crash (misuse of deflink) in mt792x_perf_account_rx(). V2 -> V3: Remove Gerrit-only: Change-Id. V1 -> V2: Remove not needed lines copied from internal commits. ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v6 1/5] wifi: mt76: refactor chip_config to accept generic commands 2026-11-27 9:11 ` [PATCH v6 " Anthony Liu @ 2026-11-27 9:11 ` Anthony Liu 2026-11-27 9:11 ` [PATCH v6 2/5] wifi: mt76: refactor chip_cfg commands to be a generic API Anthony Liu ` (3 subsequent siblings) 4 siblings, 0 replies; 14+ messages in thread From: Anthony Liu @ 2026-11-27 9:11 UTC (permalink / raw) To: anthony.liu Cc: Emery.Hsin, Jb.Tsai, Leon.Yen, Litien.Chang, Quan.Zhou, Ryder.Lee, Sean.Wang, kun.wu, linux-mediatek, linux-wireless, lorenzo, nbd The API, mt76_connac_mcu_chip_config(), was only used to send reset command but the chip_config command is a carrier of more commands. This patch enables other FW commands to be carried over mt76_connac_mcu_chip_config(). Signed-off-by: Anthony Liu <anthony.liu@mediatek.com> --- drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c | 2 +- drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 4 ++-- drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h | 2 +- drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c index 6a1475e3c899..83cffa94bc0e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c @@ -54,7 +54,7 @@ static int mt7615_config(void *data, u64 val) int ret; mt7615_mutex_acquire(dev); - ret = mt76_connac_mcu_chip_config(&dev->mt76); + ret = mt76_connac_mcu_chip_config(&dev->mt76, "assert"); mt7615_mutex_release(dev); return ret; diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c index 744b4d1f6519..0e3f23e52382 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c @@ -2047,13 +2047,13 @@ int mt76_connac_mcu_sched_scan_enable(struct mt76_phy *phy, } EXPORT_SYMBOL_GPL(mt76_connac_mcu_sched_scan_enable); -int mt76_connac_mcu_chip_config(struct mt76_dev *dev) +int mt76_connac_mcu_chip_config(struct mt76_dev *dev, const char *cmd) { struct mt76_connac_config req = { .resp_type = 0, }; - strscpy(req.data, "assert"); + strscpy(req.data, cmd); return mt76_mcu_send_msg(dev, MCU_CE_CMD(CHIP_CONFIG), &req, sizeof(req), false); diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h index 6a51b1df4fc7..c5fb7e2adab1 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h @@ -2122,7 +2122,7 @@ void mt76_connac_mcu_set_suspend_iter(void *priv, u8 *mac, int mt76_connac_sta_state_dp(struct mt76_dev *dev, enum ieee80211_sta_state old_state, enum ieee80211_sta_state new_state); -int mt76_connac_mcu_chip_config(struct mt76_dev *dev); +int mt76_connac_mcu_chip_config(struct mt76_dev *dev, const char *cmd); int mt76_connac_mcu_set_deep_sleep(struct mt76_dev *dev, bool enable); void mt76_connac_mcu_coredump_event(struct mt76_dev *dev, struct sk_buff *skb, struct mt76_connac_coredump *coredump); diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c index 825dfcd2c6ac..14c70ffa9665 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c @@ -238,7 +238,7 @@ static int mt7921_chip_reset(void *data, u64 val) default: /* Collect the core dump before reset wifisys. */ mt792x_mutex_acquire(dev); - ret = mt76_connac_mcu_chip_config(&dev->mt76); + ret = mt76_connac_mcu_chip_config(&dev->mt76, "assert"); mt792x_mutex_release(dev); break; } -- 2.45.2 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v6 2/5] wifi: mt76: refactor chip_cfg commands to be a generic API 2026-11-27 9:11 ` [PATCH v6 " Anthony Liu 2026-11-27 9:11 ` [PATCH v6 1/5] wifi: mt76: refactor chip_config to accept generic commands Anthony Liu @ 2026-11-27 9:11 ` Anthony Liu 2026-11-27 9:11 ` [PATCH v6 3/5] wifi: mt76: add ACPI MTFG option for bus configuration Anthony Liu ` (2 subsequent siblings) 4 siblings, 0 replies; 14+ messages in thread From: Anthony Liu @ 2026-11-27 9:11 UTC (permalink / raw) To: anthony.liu Cc: Emery.Hsin, Jb.Tsai, Leon.Yen, Litien.Chang, Quan.Zhou, Ryder.Lee, Sean.Wang, kun.wu, linux-mediatek, linux-wireless, lorenzo, nbd New chip_cfg command isn't chip specific but only available to mt7925. 1. Move chip specific mt7925_mcu_chip_config() from mt76/mt7925/mcu.c to mt76_connac_mcu_uni_chip_config() in mt76/mt76_connac_mcu.c. 2. mt792x_mcu_chip_config() uses mt76_connac_mcu_uni_chip_config() if is dealing with CONNAC3 FW, and uses mt76_connac_mcu_chip_config() otherwise. Signed-off-by: Anthony Liu <anthony.liu@mediatek.com> --- .../wireless/mediatek/mt76/mt76_connac_mcu.c | 35 +++++++++++++++++++ .../wireless/mediatek/mt76/mt76_connac_mcu.h | 5 +++ .../wireless/mediatek/mt76/mt7925/debugfs.c | 2 +- .../net/wireless/mediatek/mt76/mt7925/mcu.c | 6 ++-- .../net/wireless/mediatek/mt76/mt7925/mcu.h | 1 - drivers/net/wireless/mediatek/mt76/mt792x.h | 1 + .../net/wireless/mediatek/mt76/mt792x_core.c | 13 +++++++ 7 files changed, 58 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c index 0e3f23e52382..01434b1e01f5 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c @@ -2060,6 +2060,41 @@ int mt76_connac_mcu_chip_config(struct mt76_dev *dev, const char *cmd) } EXPORT_SYMBOL_GPL(mt76_connac_mcu_chip_config); +/* Unified-command form of chip_config (connac3, e.g. MT7925/MT7928): the same + * CE payload carried as a TLV inside MCU_UNI_CMD_CHIP_CONFIG. + */ +int mt76_connac_mcu_uni_chip_config(struct mt76_dev *dev, const char *cmd) +{ + ssize_t len; + + struct { + u8 rsv[4]; + __le16 tag; + __le16 len; + struct mt76_connac_config config; + } __packed req = { + .tag = cpu_to_le16(UNI_CHIP_CONFIG_CHIP_CFG), + .len = cpu_to_le16(sizeof(req) - sizeof(req.rsv)), + .config = { + .resp_type = 0, + .type = 0, + }, + }; + + if (!cmd) + return -EINVAL; + + len = strscpy(req.config.data, cmd); + if (len == -E2BIG) + return -E2BIG; + + req.config.data_size = cpu_to_le16(len + 1); + + return mt76_mcu_send_msg(dev, MCU_UNI_CMD(CHIP_CONFIG), + &req, sizeof(req), false); +} +EXPORT_SYMBOL_GPL(mt76_connac_mcu_uni_chip_config); + int mt76_connac_mcu_set_deep_sleep(struct mt76_dev *dev, bool enable) { struct mt76_connac_config req = { diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h index c5fb7e2adab1..0d2670b7b9fb 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h @@ -1467,6 +1467,10 @@ enum UNI_ALL_STA_INFO_TAG { UNI_ALL_STA_MAX_NUM }; +enum { + UNI_CHIP_CONFIG_CHIP_CFG = 2, +}; + enum { MT_NIC_CAP_TX_RESOURCE, MT_NIC_CAP_TX_EFUSE_ADDR, @@ -2123,6 +2127,7 @@ int mt76_connac_sta_state_dp(struct mt76_dev *dev, enum ieee80211_sta_state old_state, enum ieee80211_sta_state new_state); int mt76_connac_mcu_chip_config(struct mt76_dev *dev, const char *cmd); +int mt76_connac_mcu_uni_chip_config(struct mt76_dev *dev, const char *cmd); int mt76_connac_mcu_set_deep_sleep(struct mt76_dev *dev, bool enable); void mt76_connac_mcu_coredump_event(struct mt76_dev *dev, struct sk_buff *skb, struct mt76_connac_coredump *coredump); diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c index 0c40741273a9..cfe175dbc5f3 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c @@ -280,7 +280,7 @@ static int mt7925_chip_reset(void *data, u64 val) default: /* Collect the core dump before reset wifisys. */ mt792x_mutex_acquire(dev); - ret = mt7925_mcu_chip_config(dev, "assert"); + ret = mt792x_mcu_chip_config(dev, "assert"); mt792x_mutex_release(dev); break; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c index d89230fc9687..83f5f02395ec 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c @@ -1280,7 +1280,7 @@ int mt7925_mcu_set_deep_sleep(struct mt792x_dev *dev, bool enable) snprintf(cmd, sizeof(cmd), "KeepFullPwr %d", !enable); - return mt7925_mcu_chip_config(dev, cmd); + return mt792x_mcu_chip_config(dev, cmd); } EXPORT_SYMBOL_GPL(mt7925_mcu_set_deep_sleep); @@ -1291,11 +1291,11 @@ int mt7925_mcu_set_thermal_protect(struct mt792x_dev *dev) snprintf(cmd, sizeof(cmd), "ThermalProtGband %d %d %d %d %d %d %d %d %d %d", 0, 100, 90, 80, 30, 1, 1, 115, 105, 5); - ret = mt7925_mcu_chip_config(dev, cmd); + ret = mt792x_mcu_chip_config(dev, cmd); snprintf(cmd, sizeof(cmd), "ThermalProtAband %d %d %d %d %d %d %d %d %d %d", 1, 100, 90, 80, 30, 1, 1, 115, 105, 5); - ret |= mt7925_mcu_chip_config(dev, cmd); + ret |= mt792x_mcu_chip_config(dev, cmd); return ret; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h index fe40873e6107..7a9005db9c00 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h @@ -115,7 +115,6 @@ enum { }; enum { - UNI_CHIP_CONFIG_CHIP_CFG = 0x2, UNI_CHIP_CONFIG_NIC_CAPA = 0x3, }; diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h index 260abdc978f8..79f57736db35 100644 --- a/drivers/net/wireless/mediatek/mt76/mt792x.h +++ b/drivers/net/wireless/mediatek/mt76/mt792x.h @@ -669,6 +669,7 @@ void mt792x_mac_link_bss_remove(struct mt792x_dev *dev, struct mt792x_bss_conf *mconf, struct mt792x_link_sta *mlink); void mt792x_config_mac_addr_list(struct mt792x_dev *dev); +int mt792x_mcu_chip_config(struct mt792x_dev *dev, const char *cmd); static inline char *mt792x_ram_name(struct mt792x_dev *dev) { diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_core.c b/drivers/net/wireless/mediatek/mt76/mt792x_core.c index 7dddce02d600..a59aedd498b2 100644 --- a/drivers/net/wireless/mediatek/mt76/mt792x_core.c +++ b/drivers/net/wireless/mediatek/mt76/mt792x_core.c @@ -1238,6 +1238,19 @@ void mt792x_config_mac_addr_list(struct mt792x_dev *dev) } EXPORT_SYMBOL_GPL(mt792x_config_mac_addr_list); +/* Pick the chip_config command form the running chip's firmware understands: + * connac3 (mt7925/mt7928) needs the unified command, connac2 (mt7921/mt7922) + * uses the legacy CE command. + */ +int mt792x_mcu_chip_config(struct mt792x_dev *dev, const char *cmd) +{ + if (is_connac3(&dev->mt76)) + return mt76_connac_mcu_uni_chip_config(&dev->mt76, cmd); + + return mt76_connac_mcu_chip_config(&dev->mt76, cmd); +} +EXPORT_SYMBOL_GPL(mt792x_mcu_chip_config); + MODULE_DESCRIPTION("MediaTek MT792x core driver"); MODULE_LICENSE("Dual BSD/GPL"); MODULE_AUTHOR("Lorenzo Bianconi <lorenzo@kernel.org>"); -- 2.45.2 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v6 3/5] wifi: mt76: add ACPI MTFG option for bus configuration 2026-11-27 9:11 ` [PATCH v6 " Anthony Liu 2026-11-27 9:11 ` [PATCH v6 1/5] wifi: mt76: refactor chip_config to accept generic commands Anthony Liu 2026-11-27 9:11 ` [PATCH v6 2/5] wifi: mt76: refactor chip_cfg commands to be a generic API Anthony Liu @ 2026-11-27 9:11 ` Anthony Liu 2026-11-27 9:11 ` [PATCH v6 4/5] wifi: mt76: add PCIe speed tuning for mt7922/mt7928 Anthony Liu 2026-11-27 9:11 ` [PATCH v6 5/5] wifi: mt76: mt7922/mt7928: send Tx/Rx statistics to FW for link tuning Anthony Liu 4 siblings, 0 replies; 14+ messages in thread From: Anthony Liu @ 2026-11-27 9:11 UTC (permalink / raw) To: anthony.liu Cc: Emery.Hsin, Jb.Tsai, Leon.Yen, Litien.Chang, Quan.Zhou, Ryder.Lee, Sean.Wang, kun.wu, linux-mediatek, linux-wireless, lorenzo, nbd Extend ACPI MTFG table parsing to support an additional MTFG bus configuration option. Signed-off-by: Anthony Liu <anthony.liu@mediatek.com> --- drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c b/drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c index 2d7a967fd399..d8268ec56f98 100644 --- a/drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c +++ b/drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c @@ -398,6 +398,7 @@ u8 mt792x_acpi_get_flags(struct mt792x_phy *phy) } map[] = { { 1, 1 }, { 4, 2 }, + { 13, 3 }, }; u8 flags = BIT(0); int i, j; -- 2.45.2 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v6 4/5] wifi: mt76: add PCIe speed tuning for mt7922/mt7928 2026-11-27 9:11 ` [PATCH v6 " Anthony Liu ` (2 preceding siblings ...) 2026-11-27 9:11 ` [PATCH v6 3/5] wifi: mt76: add ACPI MTFG option for bus configuration Anthony Liu @ 2026-11-27 9:11 ` Anthony Liu 2026-11-27 9:11 ` [PATCH v6 5/5] wifi: mt76: mt7922/mt7928: send Tx/Rx statistics to FW for link tuning Anthony Liu 4 siblings, 0 replies; 14+ messages in thread From: Anthony Liu @ 2026-11-27 9:11 UTC (permalink / raw) To: anthony.liu Cc: Emery.Hsin, Jb.Tsai, Leon.Yen, Litien.Chang, Quan.Zhou, Ryder.Lee, Sean.Wang, kun.wu, linux-mediatek, linux-wireless, lorenzo, nbd Some hardware platforms use ACPI MTFG table denoting the existence of noise that impacts Wi-Fi performance. This patch reads the ACPI SAR info and notifies FW to detect current status and to adjust PCIe bus to mitigate the noise. Signed-off-by: Anthony Liu <anthony.liu@mediatek.com> --- .../net/wireless/mediatek/mt76/mt7921/init.c | 5 ++++ .../wireless/mediatek/mt76/mt7921/pci_mac.c | 6 ++++ .../net/wireless/mediatek/mt76/mt7925/init.c | 2 ++ .../wireless/mediatek/mt76/mt7925/pci_mac.c | 6 ++++ drivers/net/wireless/mediatek/mt76/mt792x.h | 4 +++ .../net/wireless/mediatek/mt76/mt792x_core.c | 28 +++++++++++++++++++ 6 files changed, 51 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/init.c b/drivers/net/wireless/mediatek/mt76/mt7921/init.c index a87ebcff547b..8059405f2d5c 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/init.c @@ -102,6 +102,11 @@ static int __mt7921_init_hardware(struct mt792x_dev *dev) goto out; ret = mt7921_mac_init(dev); + if (ret) + goto out; + + if (is_mt7922(&dev->mt76)) + ret = mt792x_mcu_set_dyn_pcie_gen(dev); out: return ret; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c index d5c33a0d409c..6d8e221eb83f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c @@ -118,6 +118,12 @@ int mt7921e_mac_reset(struct mt792x_dev *dev) if (err) goto out; + if (is_mt7922(&dev->mt76)) { + err = mt792x_mcu_set_dyn_pcie_gen(dev); + if (err) + goto out; + } + err = __mt7921_start(&dev->phy); out: diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/init.c b/drivers/net/wireless/mediatek/mt76/mt7925/init.c index ad51f71babd7..b8d629f9bbe5 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/init.c @@ -126,6 +126,8 @@ static int __mt7925_init_hardware(struct mt792x_dev *dev) } } + if (is_mt7928(&dev->mt76)) + ret = mt792x_mcu_set_dyn_pcie_gen(dev); out: return ret; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c index 6189615d6604..85da7645c8e2 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c @@ -202,6 +202,12 @@ int mt7925e_mac_reset(struct mt792x_dev *dev) goto out; } + if (is_mt7928(&dev->mt76)) { + err = mt792x_mcu_set_dyn_pcie_gen(dev); + if (err) + goto out; + } + err = __mt7925_start(&dev->phy); out: clear_bit(MT76_RESET, &dev->mphy.state); diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h index 79f57736db35..cdaf07725598 100644 --- a/drivers/net/wireless/mediatek/mt76/mt792x.h +++ b/drivers/net/wireless/mediatek/mt76/mt792x.h @@ -670,6 +670,7 @@ void mt792x_mac_link_bss_remove(struct mt792x_dev *dev, struct mt792x_link_sta *mlink); void mt792x_config_mac_addr_list(struct mt792x_dev *dev); int mt792x_mcu_chip_config(struct mt792x_dev *dev, const char *cmd); +int mt792x_mcu_set_dyn_pcie_gen(struct mt792x_dev *dev); static inline char *mt792x_ram_name(struct mt792x_dev *dev) { @@ -768,6 +769,9 @@ int __mt792xe_mcu_drv_pmctrl(struct mt792x_dev *dev); int mt792xe_mcu_drv_pmctrl(struct mt792x_dev *dev); int mt792xe_mcu_fw_pmctrl(struct mt792x_dev *dev); +#define MT792X_ACPI_FLAG_VALID BIT(0) /* ACPI SAR is valid */ +#define MT792X_ACPI_FLAG_PCIe BIT(3) /* Valid only when valid is set */ + #ifdef CONFIG_ACPI int mt792x_init_acpi_sar(struct mt792x_dev *dev); int mt792x_init_acpi_sar_power(struct mt792x_phy *phy, bool set_default); diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_core.c b/drivers/net/wireless/mediatek/mt76/mt792x_core.c index a59aedd498b2..25408fcc8af3 100644 --- a/drivers/net/wireless/mediatek/mt76/mt792x_core.c +++ b/drivers/net/wireless/mediatek/mt76/mt792x_core.c @@ -1251,6 +1251,34 @@ int mt792x_mcu_chip_config(struct mt792x_dev *dev, const char *cmd) } EXPORT_SYMBOL_GPL(mt792x_mcu_chip_config); +int mt792x_mcu_set_dyn_pcie_gen(struct mt792x_dev *dev) +{ + u8 acpi_conf = mt792x_acpi_get_flags(&dev->phy); + char cmd[64]; + int ret = 0; + + if (!(acpi_conf & MT792X_ACPI_FLAG_VALID) || + !(acpi_conf & MT792X_ACPI_FLAG_PCIe)) + return 0; + + strscpy(cmd, "PcieGenSwitch 1 1200 0 -60"); + ret = mt792x_mcu_chip_config(dev, cmd); + if (ret) + return ret; + + strscpy(cmd, "PcieGenSwitchAGGen2 0"); + ret = mt792x_mcu_chip_config(dev, cmd); + if (ret) + return ret; + + if (!dev->mphy.cap.has_6ghz) + return 0; + + strscpy(cmd, "PcieGenSwitch6G 1"); + return mt792x_mcu_chip_config(dev, cmd); +} +EXPORT_SYMBOL_GPL(mt792x_mcu_set_dyn_pcie_gen); + MODULE_DESCRIPTION("MediaTek MT792x core driver"); MODULE_LICENSE("Dual BSD/GPL"); MODULE_AUTHOR("Lorenzo Bianconi <lorenzo@kernel.org>"); -- 2.45.2 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v6 5/5] wifi: mt76: mt7922/mt7928: send Tx/Rx statistics to FW for link tuning 2026-11-27 9:11 ` [PATCH v6 " Anthony Liu ` (3 preceding siblings ...) 2026-11-27 9:11 ` [PATCH v6 4/5] wifi: mt76: add PCIe speed tuning for mt7922/mt7928 Anthony Liu @ 2026-11-27 9:11 ` Anthony Liu 4 siblings, 0 replies; 14+ messages in thread From: Anthony Liu @ 2026-11-27 9:11 UTC (permalink / raw) To: anthony.liu Cc: Emery.Hsin, Jb.Tsai, Leon.Yen, Litien.Chang, Quan.Zhou, Ryder.Lee, Sean.Wang, kun.wu, linux-mediatek, linux-wireless, lorenzo, nbd Update Tx/Rx statistics to FW for link speed tuning in FW. Signed-off-by: Anthony Liu <anthony.liu@mediatek.com> --- .../wireless/mediatek/mt76/mt76_connac_mcu.c | 15 ++ .../wireless/mediatek/mt76/mt76_connac_mcu.h | 53 ++++++ .../wireless/mediatek/mt76/mt7921/debugfs.c | 14 ++ .../net/wireless/mediatek/mt76/mt7921/mac.c | 6 + .../net/wireless/mediatek/mt76/mt7921/main.c | 4 + .../net/wireless/mediatek/mt76/mt7921/pci.c | 17 ++ .../wireless/mediatek/mt76/mt7921/pci_mac.c | 3 + .../wireless/mediatek/mt76/mt7925/debugfs.c | 13 ++ .../net/wireless/mediatek/mt76/mt7925/mac.c | 3 + .../net/wireless/mediatek/mt76/mt7925/main.c | 4 + .../net/wireless/mediatek/mt76/mt7925/pci.c | 18 ++ .../wireless/mediatek/mt76/mt7925/pci_mac.c | 3 + drivers/net/wireless/mediatek/mt76/mt792x.h | 55 ++++++ .../net/wireless/mediatek/mt76/mt792x_core.c | 169 ++++++++++++++++++ .../wireless/mediatek/mt76/mt792x_debugfs.c | 32 ++++ 15 files changed, 409 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c index 01434b1e01f5..56f287c8ee54 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c @@ -272,6 +272,21 @@ int mt76_connac_mcu_set_rts_thresh(struct mt76_dev *dev, u32 val, u8 band) } EXPORT_SYMBOL_GPL(mt76_connac_mcu_set_rts_thresh); +int mt76_connac_mcu_uni_set_perf_ind(struct mt76_dev *dev, u32 valid_period, + const u64 *tx_bytes, const u64 *rx_bytes) +{ + struct mt76_connac_uni_perf_ind req = { + .tag = cpu_to_le16(UNI_PERF_IND_PARM), + .len = cpu_to_le16(sizeof(req) - sizeof(req.rsv)), + }; + + mt76_connac_perf_ind_v1_fill(&req.perf, valid_period, tx_bytes, rx_bytes); + + return mt76_mcu_send_msg(dev, MCU_UNI_CMD(PERF_IND), &req, + sizeof(req), false); +} +EXPORT_SYMBOL_GPL(mt76_connac_mcu_uni_set_perf_ind); + void mt76_connac_mcu_beacon_loss_iter(void *priv, u8 *mac, struct ieee80211_vif *vif) { diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h index 0d2670b7b9fb..605030f70a02 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h @@ -1354,6 +1354,7 @@ enum { MCU_UNI_CMD_PP = 0x38, MCU_UNI_CMD_FIXED_RATE_TABLE = 0x40, MCU_UNI_CMD_RSSI_MONITOR = 0x41, + MCU_UNI_CMD_PERF_IND = 0x44, MCU_UNI_CMD_TESTMODE_CTRL = 0x46, MCU_UNI_CMD_NAN = 0x56, MCU_UNI_CMD_RRO = 0x57, @@ -1404,6 +1405,7 @@ enum { MCU_CE_CMD_SET_RATE_TX_POWER = 0x5d, MCU_CE_CMD_SCHED_SCAN_ENABLE = 0x61, MCU_CE_CMD_SCHED_SCAN_REQ = 0x62, + MCU_CE_CMD_PERF_IND = 0x7e, MCU_CE_CMD_GET_NIC_CAPAB = 0x8a, MCU_CE_CMD_RSSI_MONITOR = 0xa1, MCU_CE_CMD_SET_MU_EDCA_PARMS = 0xb0, @@ -1471,6 +1473,10 @@ enum { UNI_CHIP_CONFIG_CHIP_CFG = 2, }; +enum { + UNI_PERF_IND_PARM = 0, +}; + enum { MT_NIC_CAP_TX_RESOURCE, MT_NIC_CAP_TX_EFUSE_ADDR, @@ -1883,6 +1889,51 @@ struct mt76_connac_config { u8 data[320]; } __packed; +struct mt76_connac_perf_ind { + /* DW0 - common info*/ + u8 cmd_ver; + u8 mask; /* per-field valid bitmap */ + __le16 cmd_len; + + /* DW1 - valid period of the stats */ + __le32 valid_period; + + /* DW2~15 - stats */ + __le32 cur_tx_bytes[4]; + __le32 cur_rx_bytes[4]; + __le16 cur_rx_rate[4]; + u8 cur_rx_rcpi0[4]; + u8 cur_rx_rcpi1[4]; + u8 cur_rx_nss[4]; + u8 cur_rx_nss2[4]; + + /* DW16-77 padding */ + __le32 pad[62]; +} __packed; + +struct mt76_connac_uni_perf_ind { + u8 rsv[4]; + __le16 tag; + __le16 len; + struct mt76_connac_perf_ind perf; +} __packed; + +static inline void +mt76_connac_perf_ind_v1_fill(struct mt76_connac_perf_ind *perf, u32 valid_period, + const u64 *tx_bytes, const u64 *rx_bytes) +{ + int i; + + perf->mask = BIT(0) | BIT(1); + perf->cmd_len = cpu_to_le16(sizeof(*perf)); + perf->valid_period = cpu_to_le32(valid_period); + + for (i = 0; i < ARRAY_SIZE(perf->cur_tx_bytes); i++) { + perf->cur_tx_bytes[i] = cpu_to_le32(tx_bytes[i]); + perf->cur_rx_bytes[i] = cpu_to_le32(rx_bytes[i]); + } +} + struct mt76_connac_mcu_uni_event { u8 cid; u8 pad[3]; @@ -2083,6 +2134,8 @@ int mt76_connac_mcu_sta_cmd(struct mt76_phy *phy, void mt76_connac_mcu_beacon_loss_iter(void *priv, u8 *mac, struct ieee80211_vif *vif); int mt76_connac_mcu_set_rts_thresh(struct mt76_dev *dev, u32 val, u8 band); +int mt76_connac_mcu_uni_set_perf_ind(struct mt76_dev *dev, u32 valid_period, + const u64 *tx_bytes, const u64 *rx_bytes); int mt76_connac_mcu_set_mac_enable(struct mt76_dev *dev, int band, bool enable, bool hdr_trans); int mt76_connac_mcu_init_download(struct mt76_dev *dev, u32 addr, u32 len, diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c index 14c70ffa9665..fe7a6b5b785f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c @@ -262,6 +262,11 @@ mt7921s_sched_quota_read(struct seq_file *s, void *data) return 0; } +DEFINE_DEBUGFS_ATTRIBUTE(fops_perf_ind_trig, NULL, mt792x_perf_ind_trig, "%lld\n"); + +DEFINE_DEBUGFS_ATTRIBUTE(fops_perf_ind_enable, mt792x_perf_ind_enable_get, + mt792x_perf_ind_enable_set, "%lld\n"); + int mt7921_init_debugfs(struct mt792x_dev *dev) { struct dentry *dir; @@ -291,5 +296,14 @@ int mt7921_init_debugfs(struct mt792x_dev *dev) if (mt76_is_sdio(&dev->mt76)) debugfs_create_devm_seqfile(dev->mt76.dev, "sched-quota", dir, mt7921s_sched_quota_read); + + /* PERF_IND is supported on MT7922 PCIe version */ + if (mt76_is_mmio(&dev->mt76) && is_mt7922(&dev->mt76)) { + debugfs_create_file("perf_ind_enable", 0600, dir, dev, + &fops_perf_ind_enable); + debugfs_create_file("perf_ind_trig", 0200, dir, dev, + &fops_perf_ind_trig); + } + return 0; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c index a2d577872566..30188fda893e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c @@ -613,6 +613,12 @@ void mt7921_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, case PKT_TYPE_NORMAL_MCU: case PKT_TYPE_NORMAL: if (!mt7921_mac_fill_rx(dev, skb)) { + struct mt76_rx_status *status = + (struct mt76_rx_status *)skb->cb; + + if (is_mt7922(&dev->mt76)) + mt792x_perf_account_rx(dev, status->wcid, skb->len); + mt76_rx(&dev->mt76, q, skb); return; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index 9b13e9c25cf3..02f1feef0140 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -728,6 +728,10 @@ static void mt7921_bss_info_changed(struct ieee80211_hw *hw, mt7921_mcu_sta_update(dev, NULL, vif, true, MT76_STA_INFO_STATE_ASSOC); mt7921_mcu_set_beacon_filter(dev, vif, vif->cfg.assoc); + + /* PERF_IND is supported on MT7922 only within this family */ + if (is_mt7922(&dev->mt76)) + mt792x_perf_ind_update(dev, vif, MT792x_PERF_IND_TIME); } if (changed & BSS_CHANGED_ARP_FILTER) { diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c index 8d6c964bd6b6..da6decc22ecb 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c @@ -68,6 +68,8 @@ static void mt7921e_unregister_device(struct mt792x_dev *dev) netif_napi_del(&dev->mt76.napi[i]); } skb_queue_purge(&dev->phy.scan_event_list); + if (is_mt7922(&dev->mt76)) + cancel_delayed_work_sync(&dev->perf.work); cancel_delayed_work_sync(&dev->coredump.work); skb_queue_purge(&dev->coredump.msg_list); @@ -455,6 +457,15 @@ static int mt7921_pci_probe(struct pci_dev *pdev, if (ret) goto err_free_irq; + /* PERF_IND is only supported on MT7922 in this family; + * MT7921 opts out. + * The periodic indication itself is started on association. + */ + if (is_mt7922(&dev->mt76)) { + dev->perf.enabled = true; + mt792x_perf_ind_init(dev); + } + if (of_property_read_bool(dev->mt76.dev->of_node, "wakeup-source")) device_init_wakeup(dev->mt76.dev, true); @@ -494,6 +505,8 @@ static int mt7921_pci_suspend(struct device *device) pm->suspended = true; flush_work(&dev->reset_work); + if (is_mt7922(&dev->mt76)) + cancel_delayed_work_sync(&dev->perf.work); cancel_delayed_work_sync(&pm->ps_work); cancel_work_sync(&pm->wake_work); @@ -617,6 +630,10 @@ static int mt7921_pci_resume(struct device *device) mt7921_mcu_regd_update(dev, mdev->alpha2, dev->country_ie_env); err = mt7921_mcu_radio_led_ctrl(dev, EXT_CMD_RADIO_ON_LED); + + /* re-arm the periodic performance indication if any bss is connected */ + if (is_mt7922(&dev->mt76)) + mt792x_perf_ind_resched(dev); failed: pm->suspended = false; diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c index 6d8e221eb83f..b3f36a630292 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c @@ -21,6 +21,9 @@ int mt7921e_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, if (unlikely(tx_info->skb->len <= ETH_HLEN)) return -EINVAL; + if (is_mt7922(&dev->mt76)) + mt792x_perf_account_tx(dev, info->control.vif, tx_info->skb->len); + if (!wcid) wcid = &dev->mt76.global_wcid; diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c index cfe175dbc5f3..02e70db1a9c1 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c @@ -290,6 +290,11 @@ static int mt7925_chip_reset(void *data, u64 val) DEFINE_DEBUGFS_ATTRIBUTE(fops_reset, NULL, mt7925_chip_reset, "%lld\n"); +DEFINE_DEBUGFS_ATTRIBUTE(fops_perf_ind_trig, NULL, mt792x_perf_ind_trig, "%lld\n"); + +DEFINE_DEBUGFS_ATTRIBUTE(fops_perf_ind_enable, mt792x_perf_ind_enable_get, + mt792x_perf_ind_enable_set, "%lld\n"); + int mt7925_init_debugfs(struct mt792x_dev *dev) { struct dentry *dir; @@ -317,5 +322,13 @@ int mt7925_init_debugfs(struct mt792x_dev *dev) mt792x_pm_stats); debugfs_create_file("deep-sleep", 0600, dir, dev, &fops_ds); + /* PERF_IND is supported on MT7928 PCIe version */ + if (mt76_is_mmio(&dev->mt76) && is_mt7928(&dev->mt76)) { + debugfs_create_file("perf_ind_enable", 0600, dir, dev, + &fops_perf_ind_enable); + debugfs_create_file("perf_ind_trig", 0200, dir, dev, + &fops_perf_ind_trig); + } + return 0; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c index 3389a3236187..f1798022b14b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c @@ -1539,6 +1539,9 @@ void mt7925_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, return; } + if (is_mt7928(&dev->mt76)) + mt792x_perf_account_rx(dev, status->wcid, skb->len); + mt76_rx(&dev->mt76, q, skb); return; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c index c26d9982650f..b7698f995ff6 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c @@ -2470,6 +2470,10 @@ static void mt7925_vif_cfg_changed(struct ieee80211_hw *hw, if (ieee80211_vif_is_mld(vif)) mvif->mlo_pm_state = MT792x_MLO_LINK_ASSOC; + + /* PERF_IND is supported on MT7928 only within this family */ + if (is_mt7928(&dev->mt76)) + mt792x_perf_ind_update(dev, vif, MT792x_PERF_IND_TIME); } if (changed & BSS_CHANGED_ARP_FILTER) { diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/pci.c b/drivers/net/wireless/mediatek/mt76/mt7925/pci.c index e49fddc9c81f..49cd75b7eef1 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/pci.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/pci.c @@ -117,6 +117,9 @@ static void mt7925e_unregister_device(struct mt792x_dev *dev) cancel_work_sync(&dev->init_work); dev->hw_init_done = false; + if (is_mt7928(&dev->mt76)) + cancel_delayed_work_sync(&dev->perf.work); + mt76_unregister_device(&dev->mt76); set_bit(MT76_REMOVED, &dev->mphy.state); cancel_work_sync(&dev->reset_work); @@ -779,6 +782,15 @@ static int mt7925_pci_probe(struct pci_dev *pdev, if (ret) goto err_free_dma; + /* PERF_IND is only supported on MT7928 in this family; + * MT7925 and MT7927 opt out. + * The periodic indication itself is started on association. + */ + if (is_mt7928(&dev->mt76)) { + dev->perf.enabled = true; + mt792x_perf_ind_init(dev); + } + return 0; err_free_dma: @@ -815,6 +827,8 @@ static int mt7925_pci_suspend(struct device *device) pm->suspended = true; dev->hif_resumed = false; flush_work(&dev->reset_work); + if (is_mt7928(&dev->mt76)) + cancel_delayed_work_sync(&dev->perf.work); cancel_delayed_work_sync(&pm->ps_work); cancel_delayed_work_sync(&dev->mlo_pm_work); cancel_work_sync(&pm->wake_work); @@ -950,6 +964,10 @@ static int _mt7925_pci_resume(struct device *device, bool restore) mt7925_mcu_set_deep_sleep(dev, false); mt7925_mcu_regd_update(dev, mdev->alpha2, dev->country_ie_env); + + /* re-arm the periodic performance indication if any bss is connected */ + if (is_mt7928(&dev->mt76)) + mt792x_perf_ind_resched(dev); failed: pm->suspended = false; diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c index 85da7645c8e2..31667c80ab74 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c @@ -24,6 +24,9 @@ int mt7925e_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, if (unlikely(tx_info->skb->len <= ETH_HLEN)) return -EINVAL; + if (is_mt7928(&dev->mt76)) + mt792x_perf_account_tx(dev, info->control.vif, tx_info->skb->len); + if (!wcid) wcid = &dev->mt76.global_wcid; diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h index cdaf07725598..860f4c9dc326 100644 --- a/drivers/net/wireless/mediatek/mt76/mt792x.h +++ b/drivers/net/wireless/mediatek/mt76/mt792x.h @@ -45,6 +45,9 @@ #define MT792x_WATCHDOG_TIME (HZ / 4) +#define MT792x_PERF_UPDATE_PERIOD 1000 /* ms */ +#define MT792x_PERF_IND_TIME (HZ) /* 1 second */ + #define MT792x_DRV_OWN_RETRY_COUNT 10 #define MT792x_MCU_INIT_RETRY_COUNT 10 #define MT792x_WFSYS_INIT_RETRY_COUNT 2 @@ -175,6 +178,12 @@ struct mt792x_bss_conf { /* For group-addressed frames that are sent outside a TXQ */ struct mt792x_link_sta bmc; bool bmc_valid; + + /* Tx/Rx statistics */ + atomic64_t perf_tx_bytes; + atomic64_t perf_rx_bytes; + u64 perf_last_tx_bytes; + u64 perf_last_rx_bytes; }; struct mt792x_nan_conf { @@ -433,6 +442,11 @@ struct mt792x_dev { u32 size; bool reused; } cached_cal; + + struct { + struct delayed_work work; + bool enabled; + } perf; }; static inline bool @@ -483,6 +497,39 @@ mt792x_sta_to_link(struct mt792x_sta *msta, u8 link_id) lockdep_is_held(&msta->vif->phy->dev->mt76.mutex)); } +/* accumulate TX bytes for the interface transmitting @len bytes */ +static inline void +mt792x_perf_account_tx(struct mt792x_dev *dev, struct ieee80211_vif *vif, + u32 len) +{ + struct mt792x_vif *mvif; + + if (!vif) + return; + + mvif = (struct mt792x_vif *)vif->drv_priv; + + atomic64_add(len, &mvif->bss_conf.perf_tx_bytes); +} + +/* accumulate RX bytes for the interface owning @wcid */ +static inline void +mt792x_perf_account_rx(struct mt792x_dev *dev, struct mt76_wcid *wcid, u32 len) +{ + struct mt792x_link_sta *link; + + // allow only real station link through + if (!wcid || !wcid->sta) + return; + + link = container_of(wcid, struct mt792x_link_sta, wcid); + + if (!link->sta || !link->sta->vif) + return; + + atomic64_add(len, &link->sta->vif->bss_conf.perf_rx_bytes); +} + static inline struct mt792x_link_sta * mt792x_sta_to_link_rcu(struct mt792x_sta *msta, u8 link_id) { @@ -671,6 +718,14 @@ void mt792x_mac_link_bss_remove(struct mt792x_dev *dev, void mt792x_config_mac_addr_list(struct mt792x_dev *dev); int mt792x_mcu_chip_config(struct mt792x_dev *dev, const char *cmd); int mt792x_mcu_set_dyn_pcie_gen(struct mt792x_dev *dev); +void mt792x_perf_ind_update(struct mt792x_dev *dev, struct ieee80211_vif *vif, + unsigned long delay); +void mt792x_perf_ind_init(struct mt792x_dev *dev); +void mt792x_perf_ind_resched(struct mt792x_dev *dev); +int mt792x_perf_ind_trigger(struct mt792x_dev *dev, u64 val); +int mt792x_perf_ind_trig(void *data, u64 val); +int mt792x_perf_ind_enable_get(void *data, u64 *val); +int mt792x_perf_ind_enable_set(void *data, u64 val); static inline char *mt792x_ram_name(struct mt792x_dev *dev) { diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_core.c b/drivers/net/wireless/mediatek/mt76/mt792x_core.c index 25408fcc8af3..c3f4bdc20e96 100644 --- a/drivers/net/wireless/mediatek/mt76/mt792x_core.c +++ b/drivers/net/wireless/mediatek/mt76/mt792x_core.c @@ -367,6 +367,175 @@ int mt792x_get_stats(struct ieee80211_hw *hw, } EXPORT_SYMBOL_GPL(mt792x_get_stats); +static int mt792x_mcu_set_perf_ind(struct mt792x_dev *dev, u32 valid_period, + const u64 *tx_bytes, const u64 *rx_bytes) +{ + struct mt76_connac_perf_ind req = {}; + + mt76_connac_perf_ind_v1_fill(&req, valid_period, tx_bytes, rx_bytes); + + return mt76_mcu_send_msg(&dev->mt76, MCU_CE_CMD(PERF_IND), + &req, sizeof(req), false); +} + +static int mt792x_mcu_perf_ind(struct mt792x_dev *dev, u32 valid_period, + const u64 *tx_bytes, const u64 *rx_bytes) +{ + if (is_connac3(&dev->mt76)) + return mt76_connac_mcu_uni_set_perf_ind(&dev->mt76, valid_period, + tx_bytes, rx_bytes); + + return mt792x_mcu_set_perf_ind(dev, valid_period, tx_bytes, rx_bytes); +} + +static bool mt792x_perf_vif_active(struct ieee80211_vif *vif) +{ + return vif->cfg.assoc; +} + +struct mt792x_perf_iter_data { + u64 tx_delta[MT792x_MAX_INTERFACES]; + u64 rx_delta[MT792x_MAX_INTERFACES]; + bool connected; +}; + +static void mt792x_perf_collect_iter(void *priv, u8 *mac, + struct ieee80211_vif *vif) +{ + struct mt792x_perf_iter_data *data = priv; + struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; + struct mt792x_bss_conf *mconf = &mvif->bss_conf; + u8 idx = mconf->mt76.idx; + u64 tx, rx, last_tx, last_rx; + + if (!mt792x_perf_vif_active(vif) || idx >= MT792x_MAX_INTERFACES) + return; + + data->connected = true; + + tx = atomic64_read(&mconf->perf_tx_bytes); + if (!tx) { + data->tx_delta[idx] = 0; + } else { + last_tx = mconf->perf_last_tx_bytes; + data->tx_delta[idx] = tx <= last_tx ? 0 : tx - last_tx; + mconf->perf_last_tx_bytes = tx; + } + + rx = atomic64_read(&mconf->perf_rx_bytes); + if (!rx) { + data->rx_delta[idx] = 0; + } else { + last_rx = mconf->perf_last_rx_bytes; + data->rx_delta[idx] = rx <= last_rx ? 0 : rx - last_rx; + mconf->perf_last_rx_bytes = rx; + } +} + +static void mt792x_perf_active_iter(void *priv, u8 *mac, + struct ieee80211_vif *vif) +{ + bool *active = priv; + + if (mt792x_perf_vif_active(vif)) + *active = true; +} + +static bool mt792x_perf_any_connected(struct mt792x_dev *dev) +{ + bool active = false; + + ieee80211_iterate_active_interfaces(dev->mphy.hw, + IEEE80211_IFACE_ITER_NORMAL, + mt792x_perf_active_iter, + &active); + return active; +} + +void mt792x_perf_ind_update(struct mt792x_dev *dev, struct ieee80211_vif *vif, + unsigned long delay) +{ + struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; + + /* Reset snapshots so a future re-association starts clean */ + if (!mt792x_perf_vif_active(vif)) { + atomic64_set(&mvif->bss_conf.perf_tx_bytes, 0); + atomic64_set(&mvif->bss_conf.perf_rx_bytes, 0); + mvif->bss_conf.perf_last_tx_bytes = 0; + mvif->bss_conf.perf_last_rx_bytes = 0; + } + + if (!mt76_is_mmio(&dev->mt76)) + return; + + if (mt792x_perf_any_connected(dev)) + queue_delayed_work(dev->mt76.wq, &dev->perf.work, delay); + else + cancel_delayed_work(&dev->perf.work); +} +EXPORT_SYMBOL_GPL(mt792x_perf_ind_update); + +static void mt792x_perf_work(struct work_struct *work) +{ + struct mt792x_dev *dev = container_of(work, struct mt792x_dev, + perf.work.work); + struct mt792x_perf_iter_data data = {}; + + /* not enabled */ + if (!dev->perf.enabled) + return; + + /* skip while asleep */ + if (!mt76_connac_pm_ref(&dev->mphy, &dev->pm)) + goto reschedule; + + ieee80211_iterate_active_interfaces(dev->mphy.hw, + IEEE80211_IFACE_ITER_NORMAL, + mt792x_perf_collect_iter, &data); + + if (data.connected) + mt792x_mcu_perf_ind(dev, MT792x_PERF_UPDATE_PERIOD, + data.tx_delta, data.rx_delta); + + mt76_connac_pm_unref(&dev->mphy, &dev->pm); + +reschedule: + if (mt792x_perf_any_connected(dev)) + queue_delayed_work(dev->mt76.wq, &dev->perf.work, + MT792x_PERF_IND_TIME); +} + +void mt792x_perf_ind_init(struct mt792x_dev *dev) +{ + INIT_DELAYED_WORK(&dev->perf.work, mt792x_perf_work); +} +EXPORT_SYMBOL_GPL(mt792x_perf_ind_init); + +void mt792x_perf_ind_resched(struct mt792x_dev *dev) +{ + if (mt792x_perf_any_connected(dev)) + queue_delayed_work(dev->mt76.wq, &dev->perf.work, + MT792x_PERF_IND_TIME); +} +EXPORT_SYMBOL_GPL(mt792x_perf_ind_resched); + +int mt792x_perf_ind_trigger(struct mt792x_dev *dev, u64 val) +{ + u64 bytes[MT792x_MAX_INTERFACES]; + int i; + + for (i = 0; i < MT792x_MAX_INTERFACES; i++) + bytes[i] = val; + + /* wake the chip and serialize against other MCU commands */ + mt792x_mutex_acquire(dev); + mt792x_mcu_perf_ind(dev, MT792x_PERF_UPDATE_PERIOD, bytes, bytes); + mt792x_mutex_release(dev); + + return 0; +} +EXPORT_SYMBOL_GPL(mt792x_perf_ind_trigger); + u64 mt792x_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_debugfs.c b/drivers/net/wireless/mediatek/mt76/mt792x_debugfs.c index 65c37e0cef8f..98683cdc7205 100644 --- a/drivers/net/wireless/mediatek/mt76/mt792x_debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt792x_debugfs.c @@ -166,3 +166,35 @@ int mt792x_pm_idle_timeout_get(void *data, u64 *val) return 0; } EXPORT_SYMBOL_GPL(mt792x_pm_idle_timeout_get); + +/* send one perf_ind carrying the written value in every tx/rx byte field */ +int mt792x_perf_ind_trig(void *data, u64 val) +{ + struct mt76_dev *mdev = data; + struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); + + return mt792x_perf_ind_trigger(dev, val); +} +EXPORT_SYMBOL_GPL(mt792x_perf_ind_trig); + +int mt792x_perf_ind_enable_get(void *data, u64 *val) +{ + struct mt76_dev *mdev = data; + struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); + + *val = dev->perf.enabled; + + return 0; +} +EXPORT_SYMBOL_GPL(mt792x_perf_ind_enable_get); + +int mt792x_perf_ind_enable_set(void *data, u64 val) +{ + struct mt76_dev *mdev = data; + struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); + + dev->perf.enabled = !!val; + + return 0; +} +EXPORT_SYMBOL_GPL(mt792x_perf_ind_enable_set); -- 2.45.2 ^ permalink raw reply related [flat|nested] 14+ messages in thread
end of thread, other threads:[~2026-11-27 9:11 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-02 7:17 [PATCH v4 5/5] [PATCH v4] [PATCH 05/05] wifi: mt76: mt7922/mt7928: send Tx/Rx statistics to FW for link tuning Anthony Liu (劉良棟) 2026-11-26 9:54 ` [PATCH v5 0/5] wifi: mt76: optimize mt7922/mt7928 T-put per Tx/Rx stats Anthony Liu 2026-11-26 9:54 ` [PATCH v5 1/5] wifi: mt76: refactor chip_config to accept generic commands Anthony Liu 2026-11-26 9:54 ` [PATCH v5 2/5] wifi: mt76: refactor chip_cfg commands to be a generic API Anthony Liu 2026-11-26 9:54 ` [PATCH v5 3/5] wifi: mt76: add ACPI MTFG option for bus configuration Anthony Liu 2026-11-26 9:54 ` [PATCH v5 4/5] wifi: mt76: add PCIe speed tuning for mt7922/mt7928 Anthony Liu 2026-11-26 9:54 ` [PATCH v5 5/5] wifi: mt76: mt7922/mt7928: send Tx/Rx statistics to FW for link tuning Anthony Liu 2026-11-26 16:03 ` [PATCH v5 0/5] wifi: mt76: optimize mt7922/mt7928 T-put per Tx/Rx stats Felix Fietkau 2026-11-27 9:11 ` [PATCH v6 " Anthony Liu 2026-11-27 9:11 ` [PATCH v6 1/5] wifi: mt76: refactor chip_config to accept generic commands Anthony Liu 2026-11-27 9:11 ` [PATCH v6 2/5] wifi: mt76: refactor chip_cfg commands to be a generic API Anthony Liu 2026-11-27 9:11 ` [PATCH v6 3/5] wifi: mt76: add ACPI MTFG option for bus configuration Anthony Liu 2026-11-27 9:11 ` [PATCH v6 4/5] wifi: mt76: add PCIe speed tuning for mt7922/mt7928 Anthony Liu 2026-11-27 9:11 ` [PATCH v6 5/5] wifi: mt76: mt7922/mt7928: send Tx/Rx statistics to FW for link tuning Anthony Liu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox