wifi: mt76: mt7996: refuse scan and ROC until the hardware restart is done
Subsystems (2)
Felix Fietkau
maintainerPATCH 1/9 wifi: mt76: mt7996: refuse scan and ROC until the hardware restart is done
mt7996_mac_restart() clears MT76_MCU_RESET before it loads the firmware again, and mac80211 adds the interfaces back only later, in ieee80211_reconfig() after ieee80211_restart_hw(). A scan or remain on channel that reaches mt76_hw_scan() or mt76_remain_on_channel() in between, for example a request that waited for dev->mutex during the reset, runs on a device that has no interfaces configured.
Mark a full reset with MT76_RESTART and refuse a scan or remain on channel while it is set. Clear the flag in .start: ieee80211_reconfig() adds the interfaces back before it releases the wiphy lock, so no request runs in between. .reconfig_complete is not suitable, because mac80211 skips it when no interface is open, and the flag would then stay set.
--- drivers/net/wireless/mediatek/mt76/channel.c | 3 ++- drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 1 + drivers/net/wireless/mediatek/mt76/mt7996/main.c | 2 ++ drivers/net/wireless/mediatek/mt76/scan.c | 3 ++- 4 files changed, 7 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/channel.c +2 -1
@@ -382,7 +382,8 @@ int mt76_remain_on_channel(struct ieee80211_hw *hw, struct ieee80211_vif *vif,mutex_lock (&dev->mutex);if (phy->roc_vif || dev->scan.phy == phy || -test_bit (MT76_MCU_RESET , &dev->phy.state)) { +test_bit (MT76_MCU_RESET , &dev->phy.state) || +test_bit (MT76_RESTART , &dev->phy.state)) { ret = -EBUSY ; goto out; }
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +1 -0
@@ -2467,6 +2467,7 @@ mt7996_mac_full_reset(struct mt7996_dev *dev) dev->recovery.hw_full_reset = true; +set_bit (MT76_RESTART , &dev->mphy.state);set_bit (MT76_MCU_RESET , &dev->mphy.state);wake_up (&dev->mt76.mcu.wait);ieee80211_stop_queues (hw);
drivers/net/wireless/mediatek/mt76/mt7996/main.c +2 -0
@@ -59,6 +59,8 @@ static int mt7996_start(struct ieee80211_hw *hw)flush_work (&dev->init_work); +clear_bit (MT76_RESTART , &dev->mphy.state); +mutex_lock (&dev->mt76.mutex); ret =mt7996_mcu_set_hdr_trans (dev, true);if (!ret && !is_mt7996 (&dev->mt76)) {
drivers/net/wireless/mediatek/mt76/scan.c +2 -1
@@ -216,7 +216,8 @@ int mt76_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,mutex_lock (&dev->mutex);if (dev->scan.req || phy->roc_vif || -test_bit (MT76_MCU_RESET , &dev->phy.state)) { +test_bit (MT76_MCU_RESET , &dev->phy.state) || +test_bit (MT76_RESTART , &dev->phy.state)) { ret = -EBUSY ; goto out; }
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 2/9 wifi: mt76: report an aborted scan or ROC to mac80211 during a reset
mt7996_mac_full_reset() and the L1 SER branch of mt7996_mac_reset_work() abort a running scan and remain on channel. mt76_scan_complete() and mt76_roc_complete() then skip ieee80211_scan_completed() and ieee80211_remain_on_channel_expired() while MT76_MCU_RESET is set. mac80211 clears a hardware scan only from the completion. After an L1 SER recovery, which does not restart the hardware, every later scan on the wiphy is then refused, and a remain on channel stays pending until userspace cancels it. After a full reset, ieee80211_restart_work() warns:
WARN(test_bit(SCAN_HW_SCANNING, &local->scanning),
"%s called with hardware scan in progress\n", __func__);
Report an aborted scan to mac80211 in a reset as well, and an aborted remain on channel unless a hardware restart follows. On a restart, ieee80211_reconfig_roc() restarts a remain on channel that had not begun and ends one that had. Since the scan is reported as aborted, mac80211 does not continue it on the next band during the reset.
--- drivers/net/wireless/mediatek/mt76/channel.c | 2 +- drivers/net/wireless/mediatek/mt76/scan.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/channel.c +1 -1
@@ -336,7 +336,7 @@ void mt76_roc_complete(struct mt76_phy *phy)mt76_put_vif_phy_link (phy, phy->roc_vif, phy->roc_link); phy->roc_vif =NULL ; phy->roc_link =NULL ; -if (!test_bit (MT76_MCU_RESET , &dev->phy.state)) +if (!test_bit (MT76_RESTART , &dev->phy.state))ieee80211_remain_on_channel_expired (phy->hw); }
drivers/net/wireless/mediatek/mt76/scan.c +1 -2
@@ -39,8 +39,7 @@ static void mt76_scan_complete(struct mt76_dev *dev, bool abort) }mt76_put_vif_phy_link (phy, dev->scan.vif, dev->scan.mlink);memset (&dev->scan,0 ,sizeof (dev->scan)); -if (!test_bit (MT76_MCU_RESET , &dev->phy.state)) -ieee80211_scan_completed (phy->hw, &info); +ieee80211_scan_completed (phy->hw, &info); }void mt76_abort_scan (struct mt76_dev *dev)
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 3/9 wifi: mt76: mt7921: fix of_node reference leaks in regd update
In reply to Felix Fietkaumt7921_regd_channel_update() and __mt7921_mcu_set_clc() never release the nodes returned by mt76_find_power_limits_node(), of_get_child_by_name() and mt76_find_channel_node(). Each regulatory domain change and each CLC update on a device with DT power limits leaks these references.
Release every node after use. This relies on mt76_find_power_limits_node() also returning a reference for the fallback node, which it does since commit 3a62c9f7ec3d ("wifi: mt76:
Fix of_node reference leak in mt76_get_rate_power_limits()").
--- .../net/wireless/mediatek/mt76/mt7921/mcu.c | 7 ++++- .../net/wireless/mediatek/mt76/mt7921/regd.c | 28 ++++++++++++++++--- 2 files changed, 30 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +6 -1
@@ -3,6 +3,7 @@#include <linux/fs.h> #include <linux/firmware.h> +#include <linux/of.h> #include "mt7921.h" #include "regd.h" #include "mcu.h"
@@ -1363,6 +1364,7 @@ int __mt7921_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2, .acpi_conf = mt792x_acpi_get_flags(&dev->phy), .mtcl_conf = mt792x_acpi_get_mtcl_conf(&dev->phy, alpha2), }; +struct device_node *np;int ret, valid_cnt =0 ;u32 buf_len =0 ;u8 *pos;
@@ -1372,8 +1374,11 @@ int __mt7921_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2,if (dev->phy.chip_cap & MT792x_CHIP_CAP_CLC_EVT_EN) req.cap |=CLC_CAP_EVT_EN ; -if (mt76_find_power_limits_node (&dev->mt76)) + + np =mt76_find_power_limits_node (&dev->mt76); +if (np) req.cap |=CLC_CAP_DTS_EN ; +of_node_put (np); buf_len =le32_to_cpu (clc->len) -sizeof (*clc); pos = clc->data;
drivers/net/wireless/mediatek/mt76/mt7921/regd.c +24 -4
@@ -28,6 +28,21 @@ bool mt7921_regd_clc_supported(struct mt792x_dev *dev)return true; } +static bool +mt7921_regd_dt_has_channel (struct device_node *band_np, +struct ieee80211_channel *ch) +{ +struct device_node *chan_np; + +if (!band_np) +return false; + + chan_np =mt76_find_channel_node (band_np, ch); +of_node_put (chan_np); + +return !!chan_np; +} +static void mt7921_regd_channel_update (struct wiphy *wiphy,struct mt792x_dev *dev) {
@@ -43,14 +58,14 @@ mt7921_regd_channel_update(struct wiphy *wiphy, struct mt792x_dev *dev) sband = wiphy->bands[NL80211_BAND_5GHZ ];if (!sband) -return ; + goto out; band_np = np ?of_get_child_by_name (np,"txpower-5g" ) :NULL ;for (i =0 ; i < sband->n_channels; i++) { ch = &sband->channels[i]; cfreq = ch->center_freq; -if (np && (!band_np || !mt76_find_channel_node (band_np, ch))) { +if (np && !mt7921_regd_dt_has_channel (band_np, ch)) { ch->flags |=IEEE80211_CHAN_DISABLED ;continue ; }
@@ -59,17 +74,18 @@ mt7921_regd_channel_update(struct wiphy *wiphy, struct mt792x_dev *dev)if (IS_UNII_INVALID (0 ,5845 ,5925 )) ch->flags |=IEEE80211_CHAN_DISABLED ; } +of_node_put (band_np); sband = wiphy->bands[NL80211_BAND_6GHZ ];if (!sband) -return ; + goto out; band_np = np ?of_get_child_by_name (np,"txpower-6g" ) :NULL ;for (i =0 ; i < sband->n_channels; i++) { ch = &sband->channels[i]; cfreq = ch->center_freq; -if (np && (!band_np || !mt76_find_channel_node (band_np, ch))) { +if (np && !mt7921_regd_dt_has_channel (band_np, ch)) { ch->flags |=IEEE80211_CHAN_DISABLED ;continue ; }
@@ -81,6 +97,10 @@ mt7921_regd_channel_update(struct wiphy *wiphy, struct mt792x_dev *dev) IS_UNII_INVALID(4, 6875, 7125)) ch->flags |=IEEE80211_CHAN_DISABLED ; } +of_node_put (band_np); + +out: +of_node_put (np); } int __mt7921_mcu_regd_update(struct mt792x_dev *dev, u8 *alpha2,
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 4/9 wifi: mt76: mt792x: compute the assoc RSSI from the chain signals
In reply to Felix Fietkaumt792x_mac_rssi_iter() adds status->signal of auth and assoc response frames to the BSS RSSI average, which mt7921_mcu_sta_update() and mt7925_mcu_sta_update() send to the firmware as the station RCPI. mt7925 never sets status->signal, since mt76_rx_convert() computes it from the chain values later. The average is thus fed 0 dBm on mt7925.
Compute the signal from the chain values, as mt76_rx_convert() and mt76_check_sta() do, and skip a frame without a valid chain signal. On mt7921, the average now follows the combined value instead of the strongest chain.
--- drivers/net/wireless/mediatek/mt76/mt792x_mac.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt792x_mac.c +4 -2
@@ -165,14 +165,16 @@ mt792x_mac_rssi_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;struct ieee80211_hdr *hdr =mt76_skb_get_hdr (skb); +int signal; -if (status->signal >0 ) + signal =mt76_rx_signal (status->chains, status->chain_signal); +if (signal >0 || signal <=-128 )return ;if (!ether_addr_equal (vif->addr, hdr->addr1))return ; -ewma_rssi_add (&mvif->bss_conf.rssi, -status->signal); +ewma_rssi_add (&mvif->bss_conf.rssi, -signal); }void mt792x_mac_assoc_rssi (struct mt792x_dev *dev,struct sk_buff *skb)
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 5/9 wifi: mt76: remove the unused signal field from struct mt76_rx_status
In reply to Felix Fietkaumt76_rx_convert() computes the signal for mac80211 from the chain signals and overwrites the value of the signal field of struct mt76_rx_status. Since mt792x_mac_rssi_iter() also uses the chain signals, no code reads the field. mt7921_mac_fill_rx() is the last driver that still sets it.
Remove the field and its computation in mt7921_mac_fill_rx().
--- drivers/net/wireless/mediatek/mt76/mac80211.c | 1 - drivers/net/wireless/mediatek/mt76/mt76.h | 1 - drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 11 +---------- 3 files changed, 1 insertion(+), 12 deletions(-)
drivers/net/wireless/mediatek/mt76/mac80211.c +0 -1
@@ -1297,7 +1297,6 @@ mt76_rx_convert(struct mt76_dev *dev, struct sk_buff *skb, status->rate_idx = mstat.rate_idx; status->nss = mstat.nss; status->band = mstat.band; - status->signal = mstat.signal; status->chains = mstat.chains; status->ampdu_reference = mstat.ampdu_ref; status->device_timestamp = mstat.timestamp;
drivers/net/wireless/mediatek/mt76/mt76.h +0 -1
@@ -767,7 +767,6 @@ struct mt76_rx_status { u8 amsdu:1, first_amsdu:1, last_amsdu:1;u8 rate_idx; u8 nss:5, band:3; -s8 signal;u8 chains;s8 chain_signal[IEEE80211_MAX_CHAINS ]; };
drivers/net/wireless/mediatek/mt76/mt7921/mac.c +1 -10
@@ -188,7 +188,7 @@ mt7921_mac_fill_rx(struct mt792x_dev *dev, struct sk_buff *skb)u16 seq_ctrl =0 ;__le16 fc =0 ;u8 mode =0 ; -int i, idx; +int idx;memset (status,0 ,sizeof (*status));
@@ -368,15 +368,6 @@ mt7921_mac_fill_rx(struct mt792x_dev *dev, struct sk_buff *skb) status->chain_signal[1 ] =to_rssi (MT_PRXV_RCPI1 , v1); status->chain_signal[2 ] =to_rssi (MT_PRXV_RCPI2 , v1); status->chain_signal[3 ] =to_rssi (MT_PRXV_RCPI3 , v1); - status->signal =-128 ; -for (i =0 ; i <hweight8 (mphy->antenna_mask); i++) { -if (!(status->chains &BIT (i)) || - status->chain_signal[i] >=0 ) -continue ; - - status->signal =max (status->signal, - status->chain_signal[i]); - } } amsdu_info =FIELD_GET (MT_RXD4_NORMAL_PAYLOAD_FORMAT , rxd4);
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 6/9 wifi: mt76: mt7996: take the offchannel link of a frame from its wcid
In reply to Felix Fietkaumt7996_mac_write_txwi() and mt7996_tx_prepare_skb() take the own MAC, WMM and band index of an offchannel frame from mvif->offchannel_link, which holds one link per vif. mac80211 runs one scan or remain on channel at a time, so a vif has at most one offchannel link today. A scan that runs on several radios at the same time needs one offchannel link per radio, and its frames would then be sent with the indexes of whichever link was added last.
Each offchannel link has its own wcid, and offchannel frames are sent on it, so take the link from the wcid of the frame. Drop offchannel_link, which has no other user.
--- drivers/net/wireless/mediatek/mt76/channel.c | 5 ----- drivers/net/wireless/mediatek/mt76/mt76.h | 1 - drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 4 ++-- drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h | 12 ++++++++++++ 4 files changed, 14 insertions(+), 8 deletions(-)
drivers/net/wireless/mediatek/mt76/channel.c +0 -5
@@ -295,7 +295,6 @@ struct mt76_vif_link *mt76_get_vif_phy_link(struct mt76_phy *phy,kfree (mlink);return ERR_PTR (ret); } -rcu_assign_pointer (mvif->offchannel_link, mlink);return mlink; }
@@ -304,14 +303,10 @@ void mt76_put_vif_phy_link(struct mt76_phy *phy, struct ieee80211_vif *vif, struct mt76_vif_link *mlink) {struct mt76_dev *dev = phy->dev; -struct mt76_vif_data *mvif;if (IS_ERR_OR_NULL (mlink) || !mlink->offchannel)return ; - mvif = mlink->mvif; - -rcu_assign_pointer (mvif->offchannel_link,NULL ); dev->drv->vif_link_remove (phy, vif, &vif->bss_conf, mlink);kfree_rcu (mlink, rcu_head); }
drivers/net/wireless/mediatek/mt76/mt76.h +0 -1
@@ -846,7 +846,6 @@ struct mt76_vif_link {struct mt76_vif_data {struct mt76_vif_link __rcu *link[IEEE80211_MLD_MAX_NUM_LINKS ]; -struct mt76_vif_link __rcu *offchannel_link;struct mt76_phy *roc_phy;u16 valid_links;
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +2 -2
@@ -915,7 +915,7 @@ void mt7996_mac_write_txwi(struct mt7996_dev *dev, __le32 *txwi, mvif = vif ? (struct mt7996_vif *)vif->drv_priv :NULL ;if (mvif) {if (wcid->offchannel) - mlink =rcu_dereference (mvif->mt76.offchannel_link); + mlink =mt7996_offchannel_link (wcid);if (!mlink && link_id !=IEEE80211_LINK_UNSPECIFIED ) mlink =rcu_dereference (mvif->mt76.link[link_id]); }
@@ -1196,7 +1196,7 @@ int mt7996_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,if (mvif) {if (wcid->offchannel) - mlink =rcu_dereference (mvif->mt76.offchannel_link); + mlink =mt7996_offchannel_link (wcid);if (!mlink) mlink =rcu_dereference (mvif->mt76.link[wcid->link_id]);
drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h +12 -0
@@ -659,6 +659,18 @@ mt7996_vif_conf_link(struct mt7996_dev *dev, struct ieee80211_vif *vif, link_conf); } +static inline struct mt76_vif_link * +mt7996_offchannel_link (struct mt76_wcid *wcid) +{ +struct mt7996_sta_link *msta_link; +struct mt7996_vif_link *link; + + msta_link = container_of(wcid, struct mt7996_sta_link, wcid); + link = container_of(msta_link, struct mt7996_vif_link, msta_link); + +return &link->mt76; +} +static inline struct mt7996_sta_link *mt7996_sta_link (struct mt7996_sta *msta,u8 link_id) {
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 7/9 wifi: mt76: scan all radios of a request at the same time
In reply to Felix FietkauFrom: John Crispin <[email protected]>
A device with several radios on one wiphy has one scan state for the whole device, and mt76_hw_scan() picks the radio from the band of the first channel. A scan therefore covers one radio, and mac80211 visits the bands one after another.
Run the scan on every radio that has a channel in the request, and let each radio visit only its own channels. Report the scan as complete once all radios are done, and as aborted if any of them aborted.
Build the probe request from the IEs of the band of the channel and the common IEs, because a request can now hold the IEs of several bands.
A driver can now set SINGLE_SCAN_ON_ALL_BANDS to scan all of its radios in parallel with one request.
--- drivers/net/wireless/mediatek/mt76/channel.c | 12 +- drivers/net/wireless/mediatek/mt76/mac80211.c | 4 +- drivers/net/wireless/mediatek/mt76/mt76.h | 27 ++- drivers/net/wireless/mediatek/mt76/scan.c | 215 ++++++++++++------ 4 files changed, 173 insertions(+), 85 deletions(-)
drivers/net/wireless/mediatek/mt76/channel.c +6 -6
@@ -41,7 +41,7 @@ int mt76_add_chanctx(struct ieee80211_hw *hw,if (WARN_ON_ONCE (!phy))return ret; -if (dev->scan.phy == phy) +if (mt76_phy_scanning (phy))mt76_abort_scan (dev);mutex_lock (&dev->mutex);
@@ -66,7 +66,7 @@ void mt76_remove_chanctx(struct ieee80211_hw *hw,if (WARN_ON_ONCE (!phy))return ; -if (dev->scan.phy == phy) +if (mt76_phy_scanning (phy))mt76_abort_scan (dev);mutex_lock (&dev->mutex);
@@ -114,7 +114,7 @@ int mt76_assign_vif_chanctx(struct ieee80211_hw *hw,bool mlink_alloc = false;int ret =0 ; -if (dev->scan.vif == vif && dev->scan.phy == phy) +if (dev->scan.vif == vif &&mt76_phy_scanning (phy))mt76_abort_scan (dev);mutex_lock (&dev->mutex);
@@ -161,7 +161,7 @@ void mt76_unassign_vif_chanctx(struct ieee80211_hw *hw,struct mt76_phy *phy = ctx->phy;struct mt76_dev *dev = phy->dev; -if (dev->scan.vif == vif && dev->scan.phy == phy) +if (dev->scan.vif == vif &&mt76_phy_scanning (phy))mt76_abort_scan (dev);mutex_lock (&dev->mutex);
@@ -209,7 +209,7 @@ int mt76_switch_vif_chanctx(struct ieee80211_hw *hw,continue ;if (phy->chanctx != new_ctx) { -if (dev->scan.phy == phy) +if (mt76_phy_scanning (phy))mt76_abort_scan (dev);cancel_delayed_work_sync (&phy->mac_work);
@@ -376,7 +376,7 @@ int mt76_remain_on_channel(struct ieee80211_hw *hw, struct ieee80211_vif *vif,mutex_lock (&dev->mutex); -if (phy->roc_vif || dev->scan.phy == phy || +if (phy->roc_vif ||mt76_phy_scanning (phy) ||test_bit (MT76_MCU_RESET , &dev->phy.state) ||test_bit (MT76_RESTART , &dev->phy.state)) { ret = -EBUSY ;
drivers/net/wireless/mediatek/mt76/mac80211.c +2 -2
@@ -432,6 +432,7 @@ mt76_phy_init(struct mt76_phy *phy, struct ieee80211_hw *hw)INIT_LIST_HEAD (&phy->tx_list);spin_lock_init (&phy->tx_lock);INIT_DELAYED_WORK (&phy->roc_work, mt76_roc_complete_work); +INIT_DELAYED_WORK (&phy->scan_work, mt76_scan_work);if ((void *)phy != hw->priv)return 0 ;
@@ -729,7 +730,6 @@ mt76_alloc_device(struct device *pdev, unsigned int size,INIT_LIST_HEAD (&dev->txwi_cache);INIT_LIST_HEAD (&dev->rxwi_cache); dev->token_size = dev->drv->token_size; -INIT_DELAYED_WORK (&dev->scan_work, mt76_scan_work);spin_lock_init (&dev->scan_lock);for (i =0 ; i <ARRAY_SIZE (dev->q_rx); i++)
@@ -2338,7 +2338,7 @@ void mt76_rx_beacon(struct mt76_phy *phy, struct sk_buff *skb) .bssid = hdr->addr3, }; -mt76_scan_rx_beacon (phy->dev, phy->chandef.chan); +mt76_scan_rx_beacon (phy, phy->chandef.chan);if (!phy->num_sta)return ;
drivers/net/wireless/mediatek/mt76/mt76.h +18 -9
@@ -877,6 +877,15 @@ struct mt76_phy {struct ieee80211_vif *roc_vif;struct mt76_vif_link *roc_link; +struct delayed_work scan_work; +struct { +struct ieee80211_channel *chan; +struct mt76_vif_link *mlink; +int chan_idx; +bool beacon_wait; +bool beacon_received; + } scan; +struct mt76_chanctx *chanctx;struct mt76_channel_state *chan_state;
@@ -1013,17 +1022,12 @@ struct mt76_dev {u32 rxfilter; -struct delayed_work scan_work;spinlock_t scan_lock;struct { -struct cfg80211_scan_request *req; -struct ieee80211_channel *chan; +struct ieee80211_scan_request *req;struct ieee80211_vif *vif; -struct mt76_vif_link *mlink; -struct mt76_phy *phy; -int chan_idx; -bool beacon_wait; -bool beacon_received; +unsigned long phy_mask; +bool aborted; } scan;#ifdef CONFIG_NL80211_TESTMODE
@@ -1396,6 +1400,11 @@ mt76_phy_hw(struct mt76_dev *dev, u8 phy_idx)return mt76_dev_phy (dev, phy_idx)->hw; } +static inline bool mt76_phy_scanning (struct mt76_phy *phy) +{ +return test_bit (phy->band_idx, &phy->dev->scan.phy_mask); +} +static inline u8 *mt76_get_txwi_ptr (struct mt76_dev *dev,struct mt76_txwi_cache *t) {
@@ -1623,7 +1632,7 @@ int mt76_get_rate(struct mt76_dev *dev,int mt76_hw_scan (struct ieee80211_hw *hw,struct ieee80211_vif *vif,struct ieee80211_scan_request *hw_req);void mt76_cancel_hw_scan (struct ieee80211_hw *hw,struct ieee80211_vif *vif); -void mt76_scan_rx_beacon (struct mt76_dev *dev,struct ieee80211_channel *chan); +void mt76_scan_rx_beacon (struct mt76_phy *phy,struct ieee80211_channel *chan);void mt76_rx_beacon (struct mt76_phy *phy,struct sk_buff *skb);void mt76_beacon_mon_check (struct mt76_phy *phy); void mt76_sw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
drivers/net/wireless/mediatek/mt76/scan.c +147 -68
336 lines not on this page · raw message
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 8/9 wifi: mt76: mt7996: scan all bands with one request
In reply to Felix FietkauFrom: John Crispin <[email protected]>
mt76 runs the channels of one scan request on all radios in parallel. Let mac80211 pass all bands in one request, so that a scan across the 2.4, 5 and 6 GHz radios takes as long as the slowest radio, not the sum of all three.
--- drivers/net/wireless/mediatek/mt76/mt7996/init.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/mediatek/mt76/mt7996/init.c +1 -0
@@ -541,6 +541,7 @@ mt7996_init_wiphy(struct ieee80211_hw *hw, struct mtk_wed_device *wed)ieee80211_hw_set (hw,SUPPORTS_MULTI_BSSID );ieee80211_hw_set (hw,CHANCTX_STA_CSA );ieee80211_hw_set (hw,CONNECTION_MONITOR ); +ieee80211_hw_set (hw,SINGLE_SCAN_ON_ALL_BANDS ); hw->max_tx_fragments =4 ; wiphy->txq_memory_limit =32 <<20 ;/* 32 MiB */
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 9/9 wifi: mt76: keep beacons from queueing the scan work during an abort
In reply to Felix Fietkaumt76_abort_scan() clears beacon_wait and then cancels the scan work. A scan work that runs at that time can set beacon_wait again when it moves to a NO_IR or radar channel. After the cancel, a beacon on that channel makes mt76_scan_rx_beacon() queue the work again. The work then runs without dev->mutex while mt76_scan_phy_complete() removes the scan link, so mt76_scan_send_probe() can use the removed link. Reachable via mac80211 cancel_hw_scan, chanctx changes, interface removal and the mt7996 reset work.
Disable the scan works instead of cancelling them, so that no beacon can queue them until the abort completes the scan. Enable them again with dev->mutex held, so that a scan that mt76_hw_scan() starts after the abort can always queue its work.
--- drivers/net/wireless/mediatek/mt76/scan.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/scan.c +6 -3
@@ -76,14 +76,17 @@ void mt76_abort_scan(struct mt76_dev *dev) phy->scan.beacon_wait = false;spin_unlock_bh (&dev->scan_lock); -cancel_delayed_work_sync (&phy->scan_work); +disable_delayed_work_sync (&phy->scan_work); }mutex_lock (&dev->mutex);for (i =0 ; i <ARRAY_SIZE (dev->phys); i++) { phy = dev->phys[i]; -if (phy) -mt76_scan_phy_complete (phy, true); +if (!phy) +continue ; + +mt76_scan_phy_complete (phy, true); +enable_delayed_work (&phy->scan_work); }mutex_unlock (&dev->mutex); }
Signature · 1 line
2.47.3