wifi: mt76: mt7922/mt7928: send Tx/Rx statistics to FW for link tuning
Subsystems (2)
Hi, Felix,
Thanks for reviewing.
Quoted 5 lines · Felix Fietkau
Hi,
Quoted 2 lines · Anthony Liu
Update Tx/Rx statistics to FW for link speed tuning in FW.
Quoted 7 lines
Quoted 1 line
Signed-off-by Anthony Liu <[email protected]>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 indebugfs.c
4.mt792x_mcu_set_perf_indcould be static
5. Check if the pointer derefs inmt792x_perf_account_rxare 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?
Quoted 5 lines
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
Quoted 3 lines
Thanks,
- Felix
v5 cover wifi: mt76: optimize mt7922/mt7928 T-put per Tx/Rx stats
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
Signature · 5 lines
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.
PATCH v5 1/5 wifi: mt76: refactor chip_config to accept generic commands
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().
--- 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(-)
drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c +1 -1
@@ -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;
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +2 -2
@@ -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);
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +1 -1
@@ -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);
drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c +1 -1
@@ -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 ; }
Signature · 1 line
2.45.2
PATCH v5 2/5 wifi: mt76: refactor chip_cfg commands to be a generic API
In reply to Anthony LiuNew 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.
--- .../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(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +35 -0
@@ -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 = {
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +5 -0
@@ -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);
drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c +1 -1
@@ -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 ; }
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +3 -3
@@ -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; }
drivers/net/wireless/mediatek/mt76/mt7925/mcu.h +0 -1
@@ -115,7 +115,6 @@ enum { };enum { -UNI_CHIP_CONFIG_CHIP_CFG =0x2 ,UNI_CHIP_CONFIG_NIC_CAPA =0x3 , };
drivers/net/wireless/mediatek/mt76/mt792x.h +1 -0
@@ -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) {
drivers/net/wireless/mediatek/mt76/mt792x_core.c +13 -0
@@ -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 <[email protected]>" );
Signature · 1 line
2.45.2
PATCH v5 3/5 wifi: mt76: add ACPI MTFG option for bus configuration
In reply to Anthony LiuExtend ACPI MTFG table parsing to support an additional MTFG bus configuration option.
--- drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c +1 -0
@@ -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;
Signature · 1 line
2.45.2
PATCH v5 4/5 wifi: mt76: add PCIe speed tuning for mt7922/mt7928
In reply to Anthony LiuSome 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.
--- .../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(+)
drivers/net/wireless/mediatek/mt76/mt7921/init.c +5 -0
@@ -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; }
drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c +6 -0
@@ -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:
drivers/net/wireless/mediatek/mt76/mt7925/init.c +2 -0
@@ -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; }
drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c +6 -0
@@ -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);
drivers/net/wireless/mediatek/mt76/mt792x.h +4 -0
@@ -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);
drivers/net/wireless/mediatek/mt76/mt792x_core.c +28 -0
@@ -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 <[email protected]>" );
Signature · 1 line
2.45.2
PATCH v5 5/5 wifi: mt76: mt7922/mt7928: send Tx/Rx statistics to FW for link tuning
In reply to Anthony LiuUpdate Tx/Rx statistics to FW for link speed tuning in FW.
--- .../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(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +15 -0
@@ -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) {
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +53 -0
83 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c +14 -0
@@ -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 ; }
drivers/net/wireless/mediatek/mt76/mt7921/mac.c +6 -0
@@ -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 ; }
drivers/net/wireless/mediatek/mt76/mt7921/main.c +4 -0
@@ -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 ) {
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +12 -0
@@ -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;
drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c +3 -0
@@ -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;
drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c +13 -0
@@ -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 ; }
drivers/net/wireless/mediatek/mt76/mt7925/mac.c +4 -1
@@ -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 ; }
drivers/net/wireless/mediatek/mt76/mt7925/main.c +4 -0
@@ -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 ) {
drivers/net/wireless/mediatek/mt76/mt7925/pci.c +15 -0
@@ -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;
drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c +3 -0
@@ -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;
drivers/net/wireless/mediatek/mt76/mt792x.h +55 -0
85 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt792x_core.c +169 -0
175 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt792x_debugfs.c +32 -0
@@ -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);
Signature · 1 line
2.45.2
Felix Fietkau
maintainerRe: [PATCH v5 0/5] wifi: mt76: optimize mt7922/mt7928 T-put per Tx/Rx stats
In reply to Anthony LiuHi Anthony,
Quoted 4 lines · Anthony Liu
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
v6 cover wifi: mt76: optimize mt7922/mt7928 T-put per Tx/Rx stats
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(-)
Signature · 7 lines
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.
PATCH v6 1/5 wifi: mt76: refactor chip_config to accept generic commands
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().
--- 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(-)
drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c +1 -1
@@ -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;
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +2 -2
@@ -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);
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +1 -1
@@ -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);
drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c +1 -1
@@ -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 ; }
Signature · 1 line
2.45.2
PATCH v6 2/5 wifi: mt76: refactor chip_cfg commands to be a generic API
In reply to Anthony LiuNew 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.
--- .../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(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +35 -0
@@ -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 = {
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +5 -0
@@ -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);
drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c +1 -1
@@ -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 ; }
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +3 -3
@@ -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; }
drivers/net/wireless/mediatek/mt76/mt7925/mcu.h +0 -1
@@ -115,7 +115,6 @@ enum { };enum { -UNI_CHIP_CONFIG_CHIP_CFG =0x2 ,UNI_CHIP_CONFIG_NIC_CAPA =0x3 , };
drivers/net/wireless/mediatek/mt76/mt792x.h +1 -0
@@ -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) {
drivers/net/wireless/mediatek/mt76/mt792x_core.c +13 -0
@@ -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 <[email protected]>" );
Signature · 1 line
2.45.2
PATCH v6 3/5 wifi: mt76: add ACPI MTFG option for bus configuration
In reply to Anthony LiuExtend ACPI MTFG table parsing to support an additional MTFG bus configuration option.
--- drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c +1 -0
@@ -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;
Signature · 1 line
2.45.2
PATCH v6 4/5 wifi: mt76: add PCIe speed tuning for mt7922/mt7928
In reply to Anthony LiuSome 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.
--- .../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(+)
drivers/net/wireless/mediatek/mt76/mt7921/init.c +5 -0
@@ -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; }
drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c +6 -0
@@ -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:
drivers/net/wireless/mediatek/mt76/mt7925/init.c +2 -0
@@ -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; }
drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c +6 -0
@@ -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);
drivers/net/wireless/mediatek/mt76/mt792x.h +4 -0
@@ -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);
drivers/net/wireless/mediatek/mt76/mt792x_core.c +28 -0
@@ -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 <[email protected]>" );
Signature · 1 line
2.45.2
PATCH v6 5/5 wifi: mt76: mt7922/mt7928: send Tx/Rx statistics to FW for link tuning
In reply to Anthony LiuUpdate Tx/Rx statistics to FW for link speed tuning in FW.
--- .../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(+)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +15 -0
@@ -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) {
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +53 -0
83 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c +14 -0
@@ -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 ; }
drivers/net/wireless/mediatek/mt76/mt7921/mac.c +6 -0
@@ -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 ; }
drivers/net/wireless/mediatek/mt76/mt7921/main.c +4 -0
@@ -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 ) {
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +17 -0
@@ -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;
drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c +3 -0
@@ -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;
drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c +13 -0
@@ -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 ; }
drivers/net/wireless/mediatek/mt76/mt7925/mac.c +3 -0
@@ -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 ; }
drivers/net/wireless/mediatek/mt76/mt7925/main.c +4 -0
@@ -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 ) {
drivers/net/wireless/mediatek/mt76/mt7925/pci.c +18 -0
@@ -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;
drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c +3 -0
@@ -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;
drivers/net/wireless/mediatek/mt76/mt792x.h +55 -0
85 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt792x_core.c +169 -0
175 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt792x_debugfs.c +32 -0
@@ -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);
Signature · 1 line
2.45.2