wifi: mt76: mt7603: add MT7603U USB support
Subsystems (2)
cover wifi: mt76: mt7603: add MT7603U USB support
This series adds support for MT7603U USB 2.0 dongles (0e8d:7603) to the mt7603 driver. It follows the layout of mt7615/mt7663u: the core code moves into a new mt7603-common module, and the PCIe/SoC glue and the new USB driver become separate modules on top of it.
Patches 1-7 prepare the shared code. Apart from the module split, the changes that affect MT7603E and MT76x8 are:
- patch 4 only passes the TSSI enable flag to the firmware when the eFuse has a TSSI slope. The tested dongle sets the flag without any TSSI calibration, and the firmware stops transmitting in AP mode when TSSI is enabled.
- patch 5 adds set_antenna with separate TX and RX masks. The tested dongle loses about half of its two-stream frames on one TX chain; "iw phy phyX set antenna 1 3" keeps both RX chains and uses one TX stream.
Everything else that touches shared code only changes behaviour on non-MMIO buses: register access over USB sleeps, so WTBL updates that run in atomic context are deferred to work items, and PCIe-only setup is skipped.
Patch 8 adds the MT7603 queue mapping to mt76-usb, patch 9 adds the USB driver, and patch 10 adds AP mode, using an hrtimer computed from the TSF instead of the pre-TBTT interrupt to refill the hardware beacon and broadcast queues.
The device works with the existing mt7603_e2.bin firmware.
Tested on a 0e8d:7603 dongle on a Raspberry Pi 4, with the series backported to 6.18:
- station mode with WPA2 on 2.4 GHz
- AP mode with hostapd and WPA2, about 56 Mbit/s in each direction with a single client at MCS 7
MT7603E and MT76x8 are build tested only, as I do not have that hardware.
Claude Code was used throughout development of this series, for parts of the code and changelogs, and for debugging. I reviewed the patches and tested them on real hardware as described above.
---
Murad Dadashev (10):
wifi: mt76: mt7603: split core code into mt7603-common
wifi: mt76: mt7603: make mcu message helpers usable by other buses
wifi: mt76: mt7603: set beacon and CAB queue index in the TXD directly
wifi: mt76: mt7603: only enable TSSI with valid calibration data
wifi: mt76: mt7603: allow configuring TX and RX antennas separately
wifi: mt76: mt7603: defer WTBL updates when register access can sleep
wifi: mt76: mt7603: skip PCIe specific setup on non-MMIO buses
wifi: mt76: usb: add MT7603 queue mapping
wifi: mt76: mt7603: add MT7603U USB support
wifi: mt76: mt7603: add AP mode support for USB devices
drivers/net/wireless/mediatek/mt76/mt7603/Kconfig | 20 +- drivers/net/wireless/mediatek/mt76/mt7603/Makefile | 12 +- drivers/net/wireless/mediatek/mt76/mt7603/beacon.c | 217 +++++++++++-- drivers/net/wireless/mediatek/mt76/mt7603/core.c | 4 + drivers/net/wireless/mediatek/mt76/mt7603/dma.c | 1 + drivers/net/wireless/mediatek/mt76/mt7603/eeprom.c | 1 + drivers/net/wireless/mediatek/mt76/mt7603/eeprom.h | 2 + drivers/net/wireless/mediatek/mt76/mt7603/init.c | 40 ++- drivers/net/wireless/mediatek/mt76/mt7603/mac.c | 154 ++++++++- drivers/net/wireless/mediatek/mt76/mt7603/main.c | 103 ++++-- drivers/net/wireless/mediatek/mt76/mt7603/mcu.c | 37 ++- drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h | 33 +- drivers/net/wireless/mediatek/mt76/mt7603/pci.c | 28 ++ drivers/net/wireless/mediatek/mt76/mt7603/usb.c | 350 +++++++++++++++++++++ drivers/net/wireless/mediatek/mt76/usb.c | 17 + 15 files changed, 929 insertions(+), 90 deletions(-)
---
base-commit: 18d0bedbb5f0538396cb7f763ed9cd1dd69c5b23
change-id: 20261127-mt7603u-4fe6b9b85105
Best regards,
Signature · 1 line
Murad Dadashev <[email protected]>
PATCH 1/10 wifi: mt76: mt7603: split core code into mt7603-common
Move everything except the PCIe and SoC glue into a new mt7603-common module and export the symbols the glue uses. The PCIe/SoC module init moves from main.c to pci.c.
This prepares for adding a USB driver for MT7603U that shares the core code, in the same way mt7615-common is shared by the mt7615 and mt7663 bus drivers.
No functional change for MT7603E and MT76x8.
--- drivers/net/wireless/mediatek/mt76/mt7603/Kconfig | 6 ++++- drivers/net/wireless/mediatek/mt76/mt7603/Makefile | 10 +++++--- drivers/net/wireless/mediatek/mt76/mt7603/core.c | 1 + drivers/net/wireless/mediatek/mt76/mt7603/init.c | 3 +++ drivers/net/wireless/mediatek/mt76/mt7603/main.c | 30 ++-------------------- drivers/net/wireless/mediatek/mt76/mt7603/pci.c | 28 ++++++++++++++++++++ 6 files changed, 45 insertions(+), 33 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7603/Kconfig +5 -1
@@ -1,7 +1,11 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear +config MT7603_COMMON + tristate + select MT76_CORE + config MT7603E tristate "MediaTek MT7603E (PCIe) and MT76x8 WLAN support" - select MT76_CORE + select MT7603_COMMON depends on MAC80211 depends on PCI help
drivers/net/wireless/mediatek/mt76/mt7603/Makefile +6 -4
@@ -1,7 +1,9 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear +obj-$(CONFIG_MT7603_COMMON) += mt7603-common.o obj-$(CONFIG_MT7603E) += mt7603e.o -mt7603e-y := \ - pci.o soc.o main.o init.o mcu.o \ - core.o dma.o mac.o eeprom.o \ - beacon.o debugfs.o +mt7603-common-y := \ + main.o init.o mcu.o core.o dma.o mac.o \ + eeprom.o beacon.o debugfs.o + +mt7603e-y := pci.o soc.o
drivers/net/wireless/mediatek/mt76/mt7603/core.c +1 -0
@@ -55,6 +55,7 @@ irqreturn_t mt7603_irq_handler(int irq, void *dev_instance)return IRQ_HANDLED ; } +EXPORT_SYMBOL_GPL (mt7603_irq_handler);u32 mt7603_reg_map (struct mt7603_dev *dev,u32 addr) {
drivers/net/wireless/mediatek/mt76/mt7603/init.c +3 -0
@@ -20,6 +20,7 @@ const struct mt76_driver_ops mt7603_drv_ops = { .update_survey = mt7603_update_channel, .set_channel = mt7603_set_channel, }; +EXPORT_SYMBOL_GPL (mt7603_drv_ops);static void mt7603_set_tmac_template (struct mt7603_dev *dev)
@@ -561,6 +562,7 @@ int mt7603_register_device(struct mt7603_dev *dev)return 0 ; } +EXPORT_SYMBOL_GPL (mt7603_register_device);void mt7603_unregister_device (struct mt7603_dev *dev) {
@@ -570,3 +572,4 @@ void mt7603_unregister_device(struct mt7603_dev *dev)mt7603_dma_cleanup (dev);mt76_free_device (&dev->mt76); } +EXPORT_SYMBOL_GPL (mt7603_unregister_device);
drivers/net/wireless/mediatek/mt76/mt7603/main.c +2 -28
@@ -786,33 +786,7 @@ const struct ieee80211_ops mt7603_ops = { .get_antenna = mt76_get_antenna, .set_sar_specs = mt7603_set_sar_specs, }; +EXPORT_SYMBOL_GPL (mt7603_ops); -MODULE_DESCRIPTION ("MediaTek MT7603E and MT76x8 wireless driver" ); +MODULE_DESCRIPTION ("MediaTek MT7603 wireless core driver" );MODULE_LICENSE ("Dual BSD/GPL" ); - -static int __init mt7603_init (void ) -{ -int ret; - - ret =platform_driver_register (&mt76_wmac_driver); -if (ret) -return ret; - -#ifdef CONFIG_PCI - ret =pci_register_driver (&mt7603_pci_driver); -if (ret) -platform_driver_unregister (&mt76_wmac_driver); -#endif -return ret; -} - -static void __exit mt7603_exit(void) -{ -#ifdef CONFIG_PCI -pci_unregister_driver (&mt7603_pci_driver); -#endif -platform_driver_unregister (&mt76_wmac_driver); -} - -module_init (mt7603_init); -module_exit (mt7603_exit);
drivers/net/wireless/mediatek/mt76/mt7603/pci.c +28 -0
@@ -3,6 +3,7 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/pci.h> +#include <linux/platform_device.h> #include "mt7603.h"
@@ -81,3 +82,30 @@ struct pci_driver mt7603_pci_driver = { .probe = mt76pci_probe, .remove = mt76pci_remove, }; + +static int __init mt7603_init (void ) +{ +int ret; + + ret =platform_driver_register (&mt76_wmac_driver); +if (ret) +return ret; + + ret =pci_register_driver (&mt7603_pci_driver); +if (ret) +platform_driver_unregister (&mt76_wmac_driver); + +return ret; +} + +static void __exit mt7603_exit(void) +{ +pci_unregister_driver (&mt7603_pci_driver); +platform_driver_unregister (&mt76_wmac_driver); +} + +module_init (mt7603_init); +module_exit (mt7603_exit); + +MODULE_DESCRIPTION ("MediaTek MT7603E and MT76x8 wireless driver" ); +MODULE_LICENSE ("Dual BSD/GPL" );
Signature · 1 line
2.47.3
PATCH 2/10 wifi: mt76: mt7603: make mcu message helpers usable by other buses
In reply to Murad DadashevSplit filling in the MCU TXD out of mt7603_mcu_skb_send_msg() into mt7603_mcu_fill_msg(), and make mt7603_mcu_parse_response() and mt7603_load_firmware() non-static.
A USB driver needs to send the same MCU messages and download the same firmware, but over a bulk endpoint instead of the MCU DMA ring.
No functional change.
--- drivers/net/wireless/mediatek/mt76/mt7603/mcu.c | 23 ++++++++++++++-------- drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h | 5 +++++ 2 files changed, 20 insertions(+), 8 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7603/mcu.c +15 -8
@@ -13,9 +13,8 @@ struct mt7603_fw_trailer {__le32 dl_len; } __packed; -static int -mt7603_mcu_parse_response (struct mt76_dev *mdev,int cmd, -struct sk_buff *skb,int seq) +int mt7603_mcu_parse_response (struct mt76_dev *mdev,int cmd, +struct sk_buff *skb,int seq) { struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76);struct mt7603_mcu_rxd *rxd;
@@ -34,11 +33,10 @@ mt7603_mcu_parse_response(struct mt76_dev *mdev, int cmd,return 0 ; } -static int -mt7603_mcu_skb_send_msg (struct mt76_dev *mdev,struct sk_buff *skb, -int cmd,int *wait_seq) +void mt7603_mcu_fill_msg (struct mt7603_dev *dev,struct sk_buff *skb, +int cmd,int *wait_seq) { - struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76); +struct mt76_dev *mdev = &dev->mt76;int hdrlen = dev->mcu_running ?sizeof (struct mt7603_mcu_txd ) :12 ;struct mt7603_mcu_txd *txd;u8 seq;
@@ -71,6 +69,15 @@ mt7603_mcu_skb_send_msg(struct mt76_dev *mdev, struct sk_buff *skb,if (wait_seq) *wait_seq = seq; +} + +static int +mt7603_mcu_skb_send_msg (struct mt76_dev *mdev,struct sk_buff *skb, +int cmd,int *wait_seq) +{ + struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76); + +mt7603_mcu_fill_msg (dev, skb, cmd, wait_seq);return mt76_tx_queue_skb_raw (dev, mdev->q_mcu[MT_MCUQ_WM ], skb,0 ); }
@@ -113,7 +120,7 @@ mt7603_mcu_restart(struct mt76_dev *dev)return mt76_mcu_send_msg (dev, -MCU_CMD_RESTART_DL_REQ ,NULL ,0 , true); } -static int mt7603_load_firmware (struct mt7603_dev *dev) +int mt7603_load_firmware (struct mt7603_dev *dev) {const struct firmware *fw;const struct mt7603_fw_trailer *hdr;
drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h +5 -0
@@ -186,6 +186,11 @@ int mt7603_eeprom_init(struct mt7603_dev *dev);int mt7603_dma_init (struct mt7603_dev *dev);void mt7603_dma_cleanup (struct mt7603_dev *dev);int mt7603_mcu_init (struct mt7603_dev *dev); +int mt7603_load_firmware (struct mt7603_dev *dev); +void mt7603_mcu_fill_msg (struct mt7603_dev *dev,struct sk_buff *skb, +int cmd,int *wait_seq); +int mt7603_mcu_parse_response (struct mt76_dev *mdev,int cmd, +struct sk_buff *skb,int seq);void mt7603_init_debugfs (struct mt7603_dev *dev);static inline void mt7603_irq_enable (struct mt7603_dev *dev,u32 mask)
Signature · 1 line
2.47.3
PATCH 3/10 wifi: mt76: mt7603: set beacon and CAB queue index in the TXD directly
In reply to Murad Dadashevmt7603_mac_write_txwi() looks up the TX queue to get the hardware queue index for the TXD. Beacon and CAB frames always go to the BCN and BMC hardware queues, so use those indices directly for MT_TXQ_BEACON and MT_TXQ_CAB.
This lets a bus without dedicated beacon and CAB rings queue those frames on another ring while still targeting the right hardware queue.
No functional change for MT7603E and MT76x8.
--- drivers/net/wireless/mediatek/mt76/mt7603/mac.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7603/mac.c +9 -2
@@ -949,8 +949,8 @@ mt7603_mac_write_txwi(struct mt7603_dev *dev, __le32 *txwi,struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;struct ieee80211_bar *bar = (struct ieee80211_bar *)skb->data;struct ieee80211_vif *vif = info->control.vif; -struct mt76_queue *q = dev->mphy.q_tx[qid];struct mt7603_vif *mvif; +u8 q_idx;int wlan_idx;int hdr_len =ieee80211_get_hdrlen_from_skb (skb);int tx_count =8 ;
@@ -961,6 +961,13 @@ mt7603_mac_write_txwi(struct mt7603_dev *dev, __le32 *txwi,u32 val;u8 bw; +if (qid ==MT_TXQ_BEACON ) + q_idx =MT_TX_HW_QUEUE_BCN ; +else if (qid ==MT_TXQ_CAB ) + q_idx =MT_TX_HW_QUEUE_BMC ; +else + q_idx = dev->mphy.q_tx[qid]->hw_idx; +if (vif) { mvif = (struct mt7603_vif *)vif->drv_priv; vif_idx = mvif->idx;
@@ -983,7 +990,7 @@ mt7603_mac_write_txwi(struct mt7603_dev *dev, __le32 *txwi, frame_subtype = (fc &IEEE80211_FCTL_STYPE ) >>4 ; val =FIELD_PREP (MT_TXD0_TX_BYTES , skb->len +MT_TXD_SIZE ) | -FIELD_PREP (MT_TXD0_Q_IDX , q->hw_idx); +FIELD_PREP (MT_TXD0_Q_IDX , q_idx); txwi[0 ] =cpu_to_le32 (val); val = MT_TXD1_LONG_FORMAT |
Signature · 1 line
2.47.3
PATCH 4/10 wifi: mt76: mt7603: only enable TSSI with valid calibration data
In reply to Murad DadashevThe TSSI enable flag in NIC_CONF_1 is passed to the firmware as is in the TX power control command. Some devices set the flag without any TSSI calibration in the eFuse; one MT7603U dongle has NIC_CONF_1 set to 0x2000 with a TSSI slope of 0.
With TSSI enabled on such a device the firmware stops transmitting shortly after the first frames are sent in AP mode, and the device has to be power cycled.
Only keep TSSI enabled when a TSSI slope is programmed.
--- drivers/net/wireless/mediatek/mt76/mt7603/eeprom.h | 2 ++ drivers/net/wireless/mediatek/mt76/mt7603/mcu.c | 4 ++++ 2 files changed, 6 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7603/eeprom.h +2 -0
@@ -88,4 +88,6 @@ enum mt7603_eeprom_source {#define MT_EE_NIC_CONF_0_RX_PATH GENMASK(3, 0)#define MT_EE_NIC_CONF_0_TX_PATH GENMASK(7, 4) +#define MT_EE_NIC_CONF_1_TSSI_EN BIT(5) +#endif
drivers/net/wireless/mediatek/mt76/mt7603/mcu.c +4 -0
@@ -384,6 +384,10 @@ static int mt7603_mcu_set_tx_power(struct mt7603_dev *dev)memcpy (req.temp_comp_power, eep +MT_EE_STEP_NUM_NEG_6_7 ,sizeof (req.temp_comp_power)); +if (!eep[MT_EE_TX_POWER_0_GRP4_TSSI_SLOPE ] || + eep[MT_EE_TX_POWER_0_GRP4_TSSI_SLOPE ] ==0xff ) + req.tssi &= ~MT_EE_NIC_CONF_1_TSSI_EN ; +return mt76_mcu_send_msg (&dev->mt76,MCU_EXT_CMD_SET_TX_POWER_CTRL , &req,sizeof (req), true); }
Signature · 1 line
2.47.3
PATCH 5/10 wifi: mt76: mt7603: allow configuring TX and RX antennas separately
In reply to Murad DadashevAdd set_antenna support with independent TX and RX chain masks. When fewer TX than RX chains are used, keep the RX MCS set and advertise the lower TX stream count through IEEE80211_HT_MCS_TX_RX_DIFF, so rate control does not pick rates the hardware cannot send.
This is useful for devices where one TX chain is not usable, which otherwise lose a large share of two-stream frames.
--- drivers/net/wireless/mediatek/mt76/mt7603/eeprom.c | 1 + drivers/net/wireless/mediatek/mt76/mt7603/main.c | 56 +++++++++++++++++++++- drivers/net/wireless/mediatek/mt76/mt7603/mcu.c | 3 +- drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h | 2 + 4 files changed, 60 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7603/eeprom.c +1 -0
@@ -183,6 +183,7 @@ int mt7603_eeprom_init(struct mt7603_dev *dev) dev->mphy.antenna_mask =1 ; dev->mphy.chainmask = dev->mphy.antenna_mask; + dev->tx_ant = dev->mphy.antenna_mask;return mt76_eeprom_override (&dev->mphy); }
drivers/net/wireless/mediatek/mt76/mt7603/main.c +55 -1
68 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7603/mcu.c +2 -1
@@ -397,6 +397,7 @@ int mt7603_mcu_set_channel(struct mt7603_dev *dev)struct cfg80211_chan_def *chandef = &dev->mphy.chandef;struct ieee80211_hw *hw =mt76_hw (dev);int n_chains =hweight8 (dev->mphy.antenna_mask); +int n_tx =hweight8 (dev->tx_ant);struct {u8 control_chan;u8 center_chan;
@@ -410,7 +411,7 @@ int mt7603_mcu_set_channel(struct mt7603_dev *dev) .control_chan = chandef->chan->hw_value, .center_chan = chandef->chan->hw_value, .bw = MT_BW_20, - .tx_streams = n_chains, + .tx_streams = n_tx, .rx_streams = n_chains, };s8 tx_power = hw->conf.power_level *2 ;
drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h +2 -0
@@ -108,6 +108,8 @@ struct mt7603_dev {const struct mt76_bus_ops *bus_ops; +u8 tx_ant; +u32 rxfilter;struct mt7603_sta global_sta;
Signature · 1 line
2.47.3
PATCH 6/10 wifi: mt76: mt7603: defer WTBL updates when register access can sleep
In reply to Murad DadashevWTBL rate, SMPS and power save updates are issued from atomic context:
under mt76.lock and ps_lock, from the TX path and from mac80211's sta_rate_tbl_update callback. That is fine with MMIO, but register access over USB sleeps.
On non-MMIO buses, queue rate updates and apply them, together with the SMPS setting, from a work item. Record power save transitions per station and write them from a separate work item. In sta_remove, call mt7603_filter_tx() outside ps_lock on these buses.
No functional change for MT7603E and MT76x8.
--- drivers/net/wireless/mediatek/mt76/mt7603/init.c | 4 + drivers/net/wireless/mediatek/mt76/mt7603/mac.c | 136 ++++++++++++++++++++- drivers/net/wireless/mediatek/mt76/mt7603/main.c | 12 +- drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h | 13 ++ 4 files changed, 156 insertions(+), 9 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7603/init.c +4 -0
@@ -513,6 +513,10 @@ int mt7603_register_device(struct mt7603_dev *dev) dev->mt76.bus = bus_ops;spin_lock_init (&dev->ps_lock); +spin_lock_init (&dev->rate_lock); +INIT_LIST_HEAD (&dev->rate_list); +INIT_WORK (&dev->rate_work, mt7603_rate_work); +INIT_WORK (&dev->ps_work, mt7603_ps_work);INIT_DELAYED_WORK (&dev->mphy.mac_work, mt7603_mac_work);tasklet_setup (&dev->mt76.pre_tbtt_tasklet, mt7603_pre_tbtt_tasklet);
drivers/net/wireless/mediatek/mt76/mt7603/mac.c +130 -6
162 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7603/main.c +9 -3
@@ -379,9 +379,13 @@ mt7603_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,spin_lock_bh (&dev->ps_lock);__skb_queue_purge (&msta->psq); -mt7603_filter_tx (dev, mvif->idx, wcid->idx, true); +if (mt76_is_mmio (mdev)) +mt7603_filter_tx (dev, mvif->idx, wcid->idx, true);spin_unlock_bh (&dev->ps_lock); +if (!mt76_is_mmio (mdev)) +mt7603_filter_tx (dev, mvif->idx, wcid->idx, true); +spin_lock_bh (&mdev->sta_poll_lock);if (!list_empty (&msta->wcid.poll_list))list_del_init (&msta->wcid.poll_list);
@@ -714,8 +718,10 @@ mt7603_sta_rate_tbl_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif, msta->n_rates = i;mt7603_wtbl_set_rates (dev, msta,NULL , msta->rates); msta->rate_probe = false; -mt7603_wtbl_set_smps (dev, msta, - sta->deflink.smps_mode ==IEEE80211_SMPS_DYNAMIC ); +if (mt76_is_mmio (&dev->mt76)) +mt7603_wtbl_set_smps (dev, msta, + sta->deflink.smps_mode == +IEEE80211_SMPS_DYNAMIC );spin_unlock_bh (&dev->mt76.lock); }
drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h +13 -0
@@ -81,8 +81,13 @@ struct mt7603_sta {u8 ps;u8 ps_sleeping; + +unsigned long ps_pending; }; +#define MT7603_PS_PENDING 0 +#define MT7603_PS_FILTER 1 +struct mt7603_vif {struct mt7603_sta sta;/* must be first */
@@ -110,6 +115,12 @@ struct mt7603_dev {u8 tx_ant; +struct work_struct rate_work; +struct list_head rate_list; +spinlock_t rate_lock; + +struct work_struct ps_work; +u32 rxfilter;struct mt7603_sta global_sta;
@@ -189,6 +200,8 @@ int mt7603_dma_init(struct mt7603_dev *dev);void mt7603_dma_cleanup (struct mt7603_dev *dev);int mt7603_mcu_init (struct mt7603_dev *dev);int mt7603_load_firmware (struct mt7603_dev *dev); +void mt7603_rate_work (struct work_struct *work); +void mt7603_ps_work (struct work_struct *work);void mt7603_mcu_fill_msg (struct mt7603_dev *dev,struct sk_buff *skb,int cmd,int *wait_seq); int mt7603_mcu_parse_response(struct mt76_dev *mdev, int cmd,
Signature · 1 line
2.47.3
PATCH 7/10 wifi: mt76: mt7603: skip PCIe specific setup on non-MMIO buses
In reply to Murad DadashevPrepare the shared code for MT7603U:
- do not touch the PCIe interrupt, WPDMA and PCIe remap registers
- skip the DMA watchdog and reset in mac_work, which rely on the WPDMA registers
- skip the LED callbacks, which run in atomic context
- start the MAC without DMA setup and do not reload the firmware if the bus driver already loaded it
- USB takes physical addresses, so mt7603_reg_map() passes them through
- the firmware download bypass queue is 8 on USB
No functional change for MT7603E and MT76x8.
--- drivers/net/wireless/mediatek/mt76/mt7603/core.c | 3 +++ drivers/net/wireless/mediatek/mt76/mt7603/init.c | 30 ++++++++++++++-------- drivers/net/wireless/mediatek/mt76/mt7603/mac.c | 5 ++-- drivers/net/wireless/mediatek/mt76/mt7603/mcu.c | 4 ++- drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h | 6 +++-- 5 files changed, 32 insertions(+), 16 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7603/core.c +3 -0
@@ -62,6 +62,9 @@ u32 mt7603_reg_map(struct mt7603_dev *dev, u32 addr)u32 base = addr &MT_MCU_PCIE_REMAP_2_BASE ;u32 offset = addr &MT_MCU_PCIE_REMAP_2_OFFSET ; +if (mt76_is_usb (&dev->mt76)) +return addr; + dev->bus_ops->wr (&dev->mt76,MT_MCU_PCIE_REMAP_2 , base);return MT_PCIE_REMAP_BASE_2 + offset;
drivers/net/wireless/mediatek/mt76/mt7603/init.c +19 -11
@@ -224,7 +224,8 @@ mt7603_mac_init(struct mt7603_dev *dev)MT_DMA_TCFR_TXS_AGGR_COUNT |/* Maximum count */ MT_DMA_TCFR_TXS_BIT_MAP); -mt76_wr (dev,MT_MCU_PCIE_REMAP_1 ,MT_PSE_WTBL_2_PHYS_ADDR ); +if (mt76_is_mmio (&dev->mt76)) +mt76_wr (dev,MT_MCU_PCIE_REMAP_1 ,MT_PSE_WTBL_2_PHYS_ADDR );for (i =0 ; i <MT7603_WTBL_SIZE ; i++)mt7603_wtbl_clear (dev, i);
@@ -281,18 +282,23 @@ mt7603_init_hardware(struct mt7603_dev *dev) {int i, ret; -mt76_wr (dev,MT_INT_SOURCE_CSR , ~0 ); +if (mt76_is_mmio (&dev->mt76)) +mt76_wr (dev,MT_INT_SOURCE_CSR , ~0 ); ret =mt7603_eeprom_init (dev);if (ret <0 )return ret; - ret =mt7603_dma_init (dev); -if (ret) -return ret; +if (mt76_is_mmio (&dev->mt76)) { + ret =mt7603_dma_init (dev); +if (ret) +return ret; -mt76_wr (dev,MT_WPDMA_GLO_CFG ,0x52000850 ); -mt7603_mac_dma_start (dev); +mt76_wr (dev,MT_WPDMA_GLO_CFG ,0x52000850 ); +mt7603_mac_dma_start (dev); + }else { +mt7603_mac_start (dev); + } dev->rxfilter =mt76_rr (dev,MT_WF_RFCR );set_bit (MT76_STATE_INITIALIZED , &dev->mphy.state);
@@ -302,9 +308,11 @@ mt7603_init_hardware(struct mt7603_dev *dev)mt76_poll (dev,MT_PSE_RTA ,MT_PSE_RTA_BUSY ,0 ,5000 ); } - ret =mt7603_mcu_init (dev); -if (ret) -return ret; +if (!dev->mcu_running) { + ret =mt7603_mcu_init (dev); +if (ret) +return ret; + }mt7603_dma_sched_init (dev);mt7603_mcu_set_eeprom (dev);
@@ -549,7 +557,7 @@ int mt7603_register_device(struct mt7603_dev *dev)ieee80211_hw_set (hw,NEEDS_UNIQUE_STA_ADDR );/* init led callbacks */ -if (IS_ENABLED (CONFIG_MT76_LEDS )) { +if (IS_ENABLED (CONFIG_MT76_LEDS ) &&mt76_is_mmio (&dev->mt76)) { dev->mphy.leds.cdev.brightness_set = mt7603_led_set_brightness; dev->mphy.leds.cdev.blink_set = mt7603_led_set_blink; }
drivers/net/wireless/mediatek/mt76/mt7603/mac.c +3 -2
@@ -2033,7 +2033,8 @@ void mt7603_mac_work(struct work_struct *work)if (dev->mphy.mac_work_count ==10 )mt7603_false_cca_check (dev); -if (mt7603_watchdog_check (dev, &dev->rx_pse_check, + if (mt76_is_mmio(&dev->mt76) && + (mt7603_watchdog_check(dev, &dev->rx_pse_check, RESET_CAUSE_RX_PSE_BUSY, mt7603_rx_pse_busy) || mt7603_watchdog_check(dev, &dev->beacon_check,
@@ -2051,7 +2052,7 @@ void mt7603_mac_work(struct work_struct *work)mt7603_watchdog_check (dev, &dev->mcu_hang,RESET_CAUSE_MCU_HANG ,NULL ) || - dev->reset_cause[RESET_CAUSE_RESET_FAILED]) { + dev->reset_cause[RESET_CAUSE_RESET_FAILED])) { dev->beacon_check = 0; dev->tx_dma_check =0 ; dev->tx_hang_check =0 ;
drivers/net/wireless/mediatek/mt76/mt7603/mcu.c +3 -1
@@ -164,7 +164,9 @@ int mt7603_load_firmware(struct mt7603_dev *dev)/* switch to bypass mode */ mt76_rmw (dev,MT_SCH_4 ,MT_SCH_4_FORCE_QID , -MT_SCH_4_BYPASS |FIELD_PREP (MT_SCH_4_FORCE_QID ,5 )); +MT_SCH_4_BYPASS | +FIELD_PREP (MT_SCH_4_FORCE_QID , +mt76_is_usb (&dev->mt76) ?8 :5 )); val =mt76_rr (dev,MT_TOP_MISC2 );if (val &BIT (1 )) {
drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h +4 -2
@@ -210,12 +210,14 @@ void mt7603_init_debugfs(struct mt7603_dev *dev);static inline void mt7603_irq_enable (struct mt7603_dev *dev,u32 mask) { -mt76_set_irq_mask (&dev->mt76,MT_INT_MASK_CSR ,0 , mask); +if (mt76_is_mmio (&dev->mt76)) +mt76_set_irq_mask (&dev->mt76,MT_INT_MASK_CSR ,0 , mask); }static inline void mt7603_irq_disable (struct mt7603_dev *dev,u32 mask) { -mt76_set_irq_mask (&dev->mt76,MT_INT_MASK_CSR , mask,0 ); +if (mt76_is_mmio (&dev->mt76)) +mt76_set_irq_mask (&dev->mt76,MT_INT_MASK_CSR , mask,0 ); }void mt7603_mac_reset_counters (struct mt7603_dev *dev);
Signature · 1 line
2.47.3
PATCH 8/10 wifi: mt76: usb: add MT7603 queue mapping
In reply to Murad DadashevMT7603U uses hardware queues 0-3 for BK, BE, VI and VO, sent on the bulk out endpoints following the inband command endpoint, and hardware queue 4 for management frames, sent on the inband command endpoint.
--- drivers/net/wireless/mediatek/mt76/usb.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/net/wireless/mediatek/mt76/usb.c +17 -0
@@ -976,6 +976,23 @@ mt76u_ac_to_hwq(struct mt76_dev *dev, struct mt76_queue *q, u8 qid)u8 ac = qid <IEEE80211_NUM_ACS ? qid :IEEE80211_AC_BE ;switch (mt76_chip (dev)) { +case 0x7603 : { +static const u8 wmm_queue_map[] = { + [IEEE80211_AC_BK ] =0 , + [IEEE80211_AC_BE ] =1 , + [IEEE80211_AC_VI ] =2 , + [IEEE80211_AC_VO ] =3 , + }; + +if (qid ==MT_TXQ_PSD ) { + q->hw_idx =4 ; + q->ep =MT_EP_OUT_INBAND_CMD ; + }else { + q->hw_idx = wmm_queue_map[ac]; + q->ep = q->hw_idx +1 ; + } +break ; + }case 0x7663 : {static const u8 lmac_queue_map[] = { /* ac to lmac mapping */
Signature · 1 line
2.47.3
PATCH 9/10 wifi: mt76: mt7603: add MT7603U USB support
In reply to Murad DadashevAdd a driver for MT7603U based USB 2.0 dongles (0e8d:7603) using the shared mt7603 code.
Register access goes through the EXT vendor requests and needs the logical register offsets used by the shared code translated to the physical addresses of the chip. MCU commands and the firmware download use the inband command bulk endpoint. UDMA RX aggregation is left disabled since mt76-usb expects one frame per URB.
On TX, the TXD is placed in the skb headroom and the 802.11 header is padded to a 4 byte boundary, as the USB DMA engine expects.
The device works with the existing mt7603_e2.bin firmware.
Tested in station mode with WPA2 on a 0e8d:7603 dongle.
--- drivers/net/wireless/mediatek/mt76/mt7603/Kconfig | 14 + drivers/net/wireless/mediatek/mt76/mt7603/Makefile | 2 + drivers/net/wireless/mediatek/mt76/mt7603/dma.c | 1 + drivers/net/wireless/mediatek/mt76/mt7603/mac.c | 2 + drivers/net/wireless/mediatek/mt76/mt7603/main.c | 5 + drivers/net/wireless/mediatek/mt76/mt7603/mcu.c | 3 + drivers/net/wireless/mediatek/mt76/mt7603/usb.c | 349 +++++++++++++++++++++ 7 files changed, 376 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7603/Kconfig +14 -0
@@ -14,3 +14,17 @@ config MT7603E to 300Mbps PHY rate To compile this driver as a module, choose M here. + +config MT7603U + tristate "MediaTek MT7603U (USB) support" + select MT76_USB + select MT7603_COMMON + depends on MAC80211 + depends on USB + help + This adds support for MT7603U-based USB 2.0 wireless devices. + It shares the MAC, MCU and PHY code with the MT7603E driver and + supports station and AP mode. This family supports IEEE 802.11n + 2x2 up to 300Mbps PHY rate. + + To compile this driver as a module, choose M here.
drivers/net/wireless/mediatek/mt76/mt7603/Makefile +2 -0
@@ -1,9 +1,11 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear obj-$(CONFIG_MT7603_COMMON) += mt7603-common.o obj-$(CONFIG_MT7603E) += mt7603e.o +obj-$(CONFIG_MT7603U) += mt7603u.o mt7603-common-y := \ main.o init.o mcu.o core.o dma.o mac.o \ eeprom.o beacon.o debugfs.o mt7603e-y := pci.o soc.o +mt7603u-y := usb.o
drivers/net/wireless/mediatek/mt76/mt7603/dma.c +1 -0
@@ -146,6 +146,7 @@ void mt7603_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,break ; } } +EXPORT_SYMBOL_GPL (mt7603_queue_rx_skb); static int mt7603_init_rx_queue(struct mt7603_dev *dev, struct mt76_queue *q,
drivers/net/wireless/mediatek/mt76/mt7603/mac.c +2 -0
@@ -1239,6 +1239,7 @@ int mt7603_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,return 0 ; } +EXPORT_SYMBOL_GPL (mt7603_tx_prepare_skb); static bool mt7603_fill_txs(struct mt7603_dev *dev, struct mt7603_sta *sta,
@@ -1772,6 +1773,7 @@ void mt7603_update_channel(struct mt76_phy *mphy) state = mphy->chan_state; state->cc_busy +=mt76_rr (dev,MT_MIB_STAT_CCA ); } +EXPORT_SYMBOL_GPL (mt7603_update_channel);void mt7603_edcca_set_strict (struct mt7603_dev *dev,bool val)
drivers/net/wireless/mediatek/mt76/mt7603/main.c +5 -0
@@ -197,6 +197,7 @@ int mt7603_set_channel(struct mt76_phy *mphy)return ret; } +EXPORT_SYMBOL_GPL (mt7603_set_channel);static int mt7603_set_sar_specs (struct ieee80211_hw *hw,const struct cfg80211_sar_specs *sar)
@@ -352,6 +353,7 @@ mt7603_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,return ret; } +EXPORT_SYMBOL_GPL (mt7603_sta_add); int mt7603_sta_event(struct mt76_dev *mdev, struct ieee80211_vif *vif,
@@ -367,6 +369,7 @@ mt7603_sta_event(struct mt76_dev *mdev, struct ieee80211_vif *vif,return 0 ; } +EXPORT_SYMBOL_GPL (mt7603_sta_event); void mt7603_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
@@ -393,6 +396,7 @@ mt7603_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,mt7603_wtbl_clear (dev, wcid->idx); } +EXPORT_SYMBOL_GPL (mt7603_sta_remove);static void mt7603_ps_tx_list (struct mt7603_dev *dev,struct sk_buff_head *list)
@@ -426,6 +430,7 @@ mt7603_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta, bool ps)mt7603_ps_tx_list (dev, &list); } +EXPORT_SYMBOL_GPL (mt7603_sta_ps);static struct ieee80211_hdr *mt7603_ps_skb_hdr (struct sk_buff *skb)
drivers/net/wireless/mediatek/mt76/mt7603/mcu.c +3 -0
@@ -32,6 +32,7 @@ int mt7603_mcu_parse_response(struct mt76_dev *mdev, int cmd,return 0 ; } +EXPORT_SYMBOL_GPL (mt7603_mcu_parse_response);void mt7603_mcu_fill_msg (struct mt7603_dev *dev,struct sk_buff *skb,int cmd,int *wait_seq)
@@ -70,6 +71,7 @@ void mt7603_mcu_fill_msg(struct mt7603_dev *dev, struct sk_buff *skb,if (wait_seq) *wait_seq = seq; } +EXPORT_SYMBOL_GPL (mt7603_mcu_fill_msg); static int mt7603_mcu_skb_send_msg(struct mt76_dev *mdev, struct sk_buff *skb,
@@ -223,6 +225,7 @@ int mt7603_load_firmware(struct mt7603_dev *dev)return ret; } +EXPORT_SYMBOL_GPL (mt7603_load_firmware);int mt7603_mcu_init (struct mt7603_dev *dev) {
drivers/net/wireless/mediatek/mt76/mt7603/usb.c new file +349 -0
349 lines not on this page · raw message
Signature · 1 line
2.47.3
PATCH 10/10 wifi: mt76: mt7603: add AP mode support for USB devices
In reply to Murad DadashevUSB devices have no pre-TBTT interrupt and no beacon or CAB rings. Instead, arm an hrtimer from the TSF ahead of each TBTT. From a work item, flush the hardware BCN and BMC queues and queue the beacon and buffered broadcast frames on the management endpoint, with the target hardware queue set in the TXD.
Tested on a 0e8d:7603 dongle with hostapd and a WPA2 client at about 56 Mbit/s in each direction.
--- drivers/net/wireless/mediatek/mt76/mt7603/beacon.c | 217 +++++++++++++++++++-- drivers/net/wireless/mediatek/mt76/mt7603/init.c | 3 + drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h | 7 + drivers/net/wireless/mediatek/mt76/mt7603/usb.c | 1 + 4 files changed, 208 insertions(+), 20 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7603/beacon.c +197 -20
@@ -26,6 +26,28 @@ mt7603_mac_stuck_beacon_recovery(struct mt7603_dev *dev)mt76_clear (dev,MT_WF_CFG_OFF_WOCCR ,MT_WF_CFG_OFF_WOCCR_TMAC_GC_DIS ); } +static bool +mt7603_flush_bss_queues (struct mt7603_dev *dev,int idx) +{ +u32 om_idx = idx ? idx |0x10 :0 ; +u32 val; + + val =MT_DMA_FQCR0_BUSY |MT_DMA_FQCR0_MODE | +FIELD_PREP (MT_DMA_FQCR0_TARGET_BSS , om_idx) | +FIELD_PREP (MT_DMA_FQCR0_DEST_PORT_ID ,3 ) | +FIELD_PREP (MT_DMA_FQCR0_DEST_QUEUE_ID ,8 ); + +mt76_wr (dev,MT_DMA_FQCR0 , val | +FIELD_PREP (MT_DMA_FQCR0_TARGET_QID ,MT_TX_HW_QUEUE_BCN )); +if (!mt76_poll (dev,MT_DMA_FQCR0 ,MT_DMA_FQCR0_BUSY ,0 ,5000 )) +return false; + +mt76_wr (dev,MT_DMA_FQCR0 , val | +FIELD_PREP (MT_DMA_FQCR0_TARGET_QID ,MT_TX_HW_QUEUE_BMC )); + +return mt76_poll (dev,MT_DMA_FQCR0 ,MT_DMA_FQCR0_BUSY ,0 ,5000 ); +} +static void mt7603_update_beacon_iter (void *priv,u8 *mac,struct ieee80211_vif *vif) {
@@ -33,8 +55,6 @@ mt7603_update_beacon_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)struct mt76_dev *mdev = &dev->mt76;struct mt7603_vif *mvif = (struct mt7603_vif *)vif->drv_priv;struct sk_buff *skb =NULL ; -u32 om_idx = mvif->idx; -u32 val;if (!(mdev->beacon_mask &BIT (mvif->idx)))return ;
@@ -43,26 +63,9 @@ mt7603_update_beacon_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)if (!skb)return ; -if (om_idx) - om_idx |=0x10 ; - val =MT_DMA_FQCR0_BUSY |MT_DMA_FQCR0_MODE | -FIELD_PREP (MT_DMA_FQCR0_TARGET_BSS , om_idx) | -FIELD_PREP (MT_DMA_FQCR0_DEST_PORT_ID ,3 ) | -FIELD_PREP (MT_DMA_FQCR0_DEST_QUEUE_ID ,8 ); -spin_lock_bh (&dev->ps_lock); -mt76_wr (dev,MT_DMA_FQCR0 , val | -FIELD_PREP (MT_DMA_FQCR0_TARGET_QID ,MT_TX_HW_QUEUE_BCN )); -if (!mt76_poll (dev,MT_DMA_FQCR0 ,MT_DMA_FQCR0_BUSY ,0 ,5000 )) { - dev->beacon_check =MT7603_WATCHDOG_TIMEOUT ; -dev_kfree_skb (skb); - goto out; - } - -mt76_wr (dev,MT_DMA_FQCR0 , val | -FIELD_PREP (MT_DMA_FQCR0_TARGET_QID ,MT_TX_HW_QUEUE_BMC )); -if (!mt76_poll (dev,MT_DMA_FQCR0 ,MT_DMA_FQCR0_BUSY ,0 ,5000 )) { +if (!mt7603_flush_bss_queues (dev, mvif->idx)) { dev->beacon_check =MT7603_WATCHDOG_TIMEOUT ;dev_kfree_skb (skb); goto out;
@@ -179,6 +182,172 @@ void mt7603_pre_tbtt_tasklet(struct tasklet_struct *t) ((1 << (MT7603_MAX_INTERFACES - 1)) - 1))); } +static void +mt7603_get_beacon_iter (void *priv,u8 *mac,struct ieee80211_vif *vif) +{ +struct beacon_bc_data *data = priv; +struct mt7603_dev *dev = data->dev; +struct mt7603_vif *mvif = (struct mt7603_vif *)vif->drv_priv; +struct sk_buff *skb; + +if (!(dev->mt76.beacon_mask &BIT (mvif->idx))) +return ; + + skb =ieee80211_beacon_get (mt76_hw (dev), vif,0 ); +if (!skb) +return ; + +IEEE80211_SKB_CB (skb)->control.vif = vif; +__skb_queue_tail (&data->q, skb); +} + +static void +mt7603_queue_bss_frame (struct mt7603_dev *dev,struct sk_buff *skb, +enum mt76_txq_id qid) +{ +struct mt76_queue *q = dev->mphy.q_tx[MT_TXQ_PSD ]; +struct ieee80211_vif *vif =IEEE80211_SKB_CB (skb)->control.vif; +struct mt7603_vif *mvif = (struct mt7603_vif *)vif->drv_priv; + +spin_lock_bh (&q->lock); +mt76_tx_queue_skb (dev, q, qid, skb, &mvif->sta.wcid,NULL ); +spin_unlock_bh (&q->lock); +} + +static void +mt7603_kick_bss_queue (struct mt7603_dev *dev) +{ +struct mt76_queue *q = dev->mphy.q_tx[MT_TXQ_PSD ]; + +spin_lock_bh (&q->lock); +mt76_queue_kick (dev, q); +spin_unlock_bh (&q->lock); +} + +static void +mt7603_start_pre_tbtt_timer (struct mt7603_dev *dev) +{ +u32 period = dev->mt76.beacon_int *1024 ; +u32 lead =2 *MT7603_PRE_TBTT_TIME ; +s64 delay; +u64 tsf; +u32 rem; + +if (!period) +return ; + +mt76_set (dev,MT_LPON_T0CR ,MT_LPON_T0CR_MODE ); + tsf =mt76_rr (dev,MT_LPON_UTTR0 ); + tsf |= (u64 )mt76_rr (dev,MT_LPON_UTTR1 ) <<32 ; + rem =do_div (tsf, period); + + delay = (s64 )period - rem - lead; +if (delay < lead /2 ) + delay += period; + +hrtimer_start (&dev->pre_tbtt_timer,ns_to_ktime (delay *NSEC_PER_USEC ), +HRTIMER_MODE_REL ); +} + +void mt7603_stop_pre_tbtt_timer (struct mt7603_dev *dev) +{ +WRITE_ONCE (dev->pre_tbtt_enabled, false); +do { +hrtimer_cancel (&dev->pre_tbtt_timer); +cancel_work_sync (&dev->pre_tbtt_work); + }while (hrtimer_active (&dev->pre_tbtt_timer)); +} +EXPORT_SYMBOL_GPL (mt7603_stop_pre_tbtt_timer); + +enum hrtimer_restart mt7603_pre_tbtt_timer (struct hrtimer *timer) +{ + struct mt7603_dev *dev = container_of(timer, struct mt7603_dev, + pre_tbtt_timer); + +queue_work (system_highpri_wq, &dev->pre_tbtt_work); + +return HRTIMER_NORESTART ; +} + +void mt7603_pre_tbtt_work (struct work_struct *work) +{ + struct mt7603_dev *dev = container_of(work, struct mt7603_dev, + pre_tbtt_work); +struct beacon_bc_data data = {}; +struct sk_buff *skb; +int i, nframes; + +if (!READ_ONCE (dev->pre_tbtt_enabled) || !dev->mt76.beacon_mask) +return ; + +if (dev->mphy.offchannel) + goto out; + + data.dev = dev; +__skb_queue_head_init (&data.q); + +mt76_wr (dev,MT_WF_ARB_CAB_FLUSH ,GENMASK (30 ,16 ) |BIT (0 )); + +ieee80211_iterate_active_interfaces_atomic (mt76_hw (dev), +IEEE80211_IFACE_ITER_RESUME_ALL , + mt7603_get_beacon_iter, &data); + +while ((skb =__skb_dequeue (&data.q)) !=NULL ) { +struct ieee80211_vif *vif =IEEE80211_SKB_CB (skb)->control.vif; +struct mt7603_vif *mvif = (struct mt7603_vif *)vif->drv_priv; + +if (!mt7603_flush_bss_queues (dev, mvif->idx)) { +dev_kfree_skb (skb); +continue ; + } + +mt7603_queue_bss_frame (dev, skb,MT_TXQ_BEACON ); + } + +mt76_csa_check (&dev->mt76); +if (dev->mt76.csa_complete) { +mt76_csa_finish (&dev->mt76); + goto kick; + } + +do { + nframes =skb_queue_len (&data.q); +ieee80211_iterate_active_interfaces_atomic (mt76_hw (dev), +IEEE80211_IFACE_ITER_RESUME_ALL , + mt7603_add_buffered_bc, &data); + }while (nframes !=skb_queue_len (&data.q) && +skb_queue_len (&data.q) <8 ); + +if (skb_queue_empty (&data.q)) + goto kick; + +for (i =0 ; i <ARRAY_SIZE (data.tail); i++) { +if (data.tail[i]) +mt76_skb_set_moredata (data.tail[i], false); + } + +while ((skb =__skb_dequeue (&data.q)) !=NULL ) +mt7603_queue_bss_frame (dev, skb,MT_TXQ_CAB ); + +mt7603_kick_bss_queue (dev); + +for (i =0 ; i <ARRAY_SIZE (data.count); i++) +mt76_wr (dev,MT_WF_ARB_CAB_COUNT_B0_REG (i), + data.count[i] <<MT_WF_ARB_CAB_COUNT_B0_SHIFT (i)); + +mt76_wr (dev,MT_WF_ARB_CAB_START , +MT_WF_ARB_CAB_START_BSSn (0 ) | + (MT_WF_ARB_CAB_START_BSS0n (1 ) * + ((1 << (MT7603_MAX_INTERFACES -1 )) -1 ))); + goto out; + +kick: +mt7603_kick_bss_queue (dev); +out: +if (READ_ONCE (dev->pre_tbtt_enabled)) +mt7603_start_pre_tbtt_timer (dev); +} +void mt7603_beacon_set_timer (struct mt7603_dev *dev,int idx,int intval) {u32 pre_tbtt =MT7603_PRE_TBTT_TIME /64 ;
@@ -194,6 +363,8 @@ void mt7603_beacon_set_timer(struct mt7603_dev *dev, int idx, int intval)mt7603_irq_disable (dev,MT_INT_MAC_IRQ3 );mt76_clear (dev,MT_ARB_SCR ,MT_ARB_SCR_BCNQ_OPMODE_MASK );mt76_wr (dev,MT_HW_INT_MASK (3 ),0 ); +if (!mt76_is_mmio (&dev->mt76)) +mt7603_stop_pre_tbtt_timer (dev);return ; }
@@ -224,4 +395,10 @@ void mt7603_beacon_set_timer(struct mt7603_dev *dev, int idx, int intval)mt76_set (dev,MT_LPON_SBTOR (0 ),MT_LPON_SBTOR_SUB_BSS_EN ); else mt76_clear(dev, MT_LPON_SBTOR(0), MT_LPON_SBTOR_SUB_BSS_EN); + +if (!mt76_is_mmio (&dev->mt76)) { +WRITE_ONCE (dev->pre_tbtt_enabled, true); +if (!hrtimer_active (&dev->pre_tbtt_timer)) +mt7603_start_pre_tbtt_timer (dev); + } }
drivers/net/wireless/mediatek/mt76/mt7603/init.c +3 -0
@@ -528,6 +528,9 @@ int mt7603_register_device(struct mt7603_dev *dev)INIT_DELAYED_WORK (&dev->mphy.mac_work, mt7603_mac_work);tasklet_setup (&dev->mt76.pre_tbtt_tasklet, mt7603_pre_tbtt_tasklet); +INIT_WORK (&dev->pre_tbtt_work, mt7603_pre_tbtt_work); +hrtimer_setup (&dev->pre_tbtt_timer, mt7603_pre_tbtt_timer, +CLOCK_MONOTONIC ,HRTIMER_MODE_REL ); dev->slottime =9 ; dev->sensitivity_limit =28 ;
drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h +7 -0
@@ -121,6 +121,10 @@ struct mt7603_dev {struct work_struct ps_work; +struct hrtimer pre_tbtt_timer; +struct work_struct pre_tbtt_work; +bool pre_tbtt_enabled; +u32 rxfilter;struct mt7603_sta global_sta;
@@ -278,6 +282,9 @@ void mt7603_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, struct ieee80211_sta *sta);void mt7603_pre_tbtt_tasklet (struct tasklet_struct *t); +void mt7603_pre_tbtt_work (struct work_struct *work); +enum hrtimer_restart mt7603_pre_tbtt_timer (struct hrtimer *timer); +void mt7603_stop_pre_tbtt_timer (struct mt7603_dev *dev);void mt7603_update_channel (struct mt76_phy *mphy);
drivers/net/wireless/mediatek/mt76/mt7603/usb.c +1 -0
@@ -321,6 +321,7 @@ static void mt7603u_disconnect(struct usb_interface *usb_intf)if (test_bit (MT76_STATE_REGISTERED , &dev->mphy.state)) {mt76_unregister_device (&dev->mt76); +mt7603_stop_pre_tbtt_timer (dev);cancel_work_sync (&dev->rate_work);cancel_work_sync (&dev->ps_work); }
Signature · 1 line
2.47.3