wifi: mt76: mt7996: remove redundant per-phy mac80211 calls during restart
Subsystems (2)
Felix Fietkau
maintainerPATCH 1/15 wifi: mt76: mt7996: remove redundant per-phy mac80211 calls during restart
There is only one wiphy, so extra calls must be removed. For calls that need to remain per-wiphy, use mt7996_for_each_phy
--- .../net/wireless/mediatek/mt76/mt7996/mac.c | 137 +++++------------- 1 file changed, 35 insertions(+), 102 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +35 -102
@@ -2220,13 +2220,10 @@ void mt7996_tx_token_put(struct mt7996_dev *dev)static int mt7996_mac_restart (struct mt7996_dev *dev) { -struct mt7996_phy *phy2, *phy3;struct mt76_dev *mdev = &dev->mt76; +struct mt7996_phy *phy;int i, ret; - phy2 =mt7996_phy2 (dev); - phy3 =mt7996_phy3 (dev); -if (dev->hif2) {mt76_wr (dev,MT_INT1_MASK_CSR ,0x0 );mt76_wr (dev,MT_INT1_SOURCE_CSR , ~0 );
@@ -2238,20 +2235,14 @@ mt7996_mac_restart(struct mt7996_dev *dev)mt76_wr (dev,MT_PCIE1_MAC_INT_ENABLE ,0x0 ); } -set_bit (MT76_RESET , &dev->mphy.state);set_bit (MT76_MCU_RESET , &dev->mphy.state); +mt7996_for_each_phy (dev, phy) +set_bit (MT76_RESET , &phy->mt76->state);wake_up (&dev->mt76.mcu.wait); -if (phy2) -set_bit (MT76_RESET , &phy2->mt76->state); -if (phy3) -set_bit (MT76_RESET , &phy3->mt76->state);/* lock/unlock all queues to ensure that no tx is pending */ -mt76_txq_schedule_all (&dev->mphy); -if (phy2) -mt76_txq_schedule_all (phy2->mt76); -if (phy3) -mt76_txq_schedule_all (phy3->mt76); +mt7996_for_each_phy (dev, phy) +mt76_txq_schedule_all (phy->mt76);/* disable all tx/rx napi */ mt76_worker_disable (&dev->mt76.tx_worker);
@@ -2335,36 +2326,25 @@ mt7996_mac_restart(struct mt7996_dev *dev) goto out;mt7996_mac_init (dev); -mt7996_init_txpower (&dev->phy); -mt7996_init_txpower (phy2); -mt7996_init_txpower (phy3); +mt7996_for_each_phy (dev, phy) +mt7996_init_txpower (phy); ret =mt7996_txbf_init (dev); +if (ret) + goto out; + +mt7996_for_each_phy (dev, phy) { +if (!test_bit (MT76_STATE_RUNNING , &phy->mt76->state)) +continue ; -if (test_bit (MT76_STATE_RUNNING , &dev->mphy.state)) { ret =mt7996_run (&dev->phy);if (ret) goto out; } -if (phy2 &&test_bit (MT76_STATE_RUNNING , &phy2->mt76->state)) { - ret =mt7996_run (phy2); -if (ret) - goto out; - } - -if (phy3 &&test_bit (MT76_STATE_RUNNING , &phy3->mt76->state)) { - ret =mt7996_run (phy3); -if (ret) - goto out; - } - out:/* reset done */ -clear_bit (MT76_RESET , &dev->mphy.state); -if (phy2) -clear_bit (MT76_RESET , &phy2->mt76->state); -if (phy3) -clear_bit (MT76_RESET , &phy3->mt76->state); +mt7996_for_each_phy (dev, phy) +clear_bit (MT76_RESET , &phy->mt76->state);napi_enable (&dev->mt76.tx_napi);local_bh_disable ();
@@ -2378,26 +2358,18 @@ mt7996_mac_restart(struct mt7996_dev *dev)static void mt7996_mac_full_reset (struct mt7996_dev *dev) { -struct mt7996_phy *phy2, *phy3; +struct ieee80211_hw *hw =mt76_hw (dev); +struct mt7996_phy *phy;int i; - phy2 =mt7996_phy2 (dev); - phy3 =mt7996_phy3 (dev); dev->recovery.hw_full_reset = true;wake_up (&dev->mt76.mcu.wait); -ieee80211_stop_queues (mt76_hw (dev)); -if (phy2) -ieee80211_stop_queues (phy2->mt76->hw); -if (phy3) -ieee80211_stop_queues (phy3->mt76->hw); +ieee80211_stop_queues (hw);cancel_work_sync (&dev->wed_rro.work); -cancel_delayed_work_sync (&dev->mphy.mac_work); -if (phy2) -cancel_delayed_work_sync (&phy2->mt76->mac_work); -if (phy3) -cancel_delayed_work_sync (&phy3->mt76->mac_work); +mt7996_for_each_phy (dev, phy) +cancel_delayed_work_sync (&phy->mt76->mac_work);mutex_lock (&dev->mt76.mutex);for (i =0 ; i <10 ; i++) {
@@ -2410,40 +2382,23 @@ mt7996_mac_full_reset(struct mt7996_dev *dev)dev_err (dev->mt76.dev,"chip full reset failed\n" );ieee80211_restart_hw (mt76_hw (dev)); -if (phy2) -ieee80211_restart_hw (phy2->mt76->hw); -if (phy3) -ieee80211_restart_hw (phy3->mt76->hw); -ieee80211_wake_queues (mt76_hw (dev)); -if (phy2) -ieee80211_wake_queues (phy2->mt76->hw); -if (phy3) -ieee80211_wake_queues (phy3->mt76->hw); dev->recovery.hw_full_reset = false; -ieee80211_queue_delayed_work (mt76_hw (dev), - &dev->mphy.mac_work, -MT7996_WATCHDOG_TIME ); -if (phy2) -ieee80211_queue_delayed_work (phy2->mt76->hw, - &phy2->mt76->mac_work, -MT7996_WATCHDOG_TIME ); -if (phy3) -ieee80211_queue_delayed_work (phy3->mt76->hw, - &phy3->mt76->mac_work, +mt7996_for_each_phy (dev, phy) +ieee80211_queue_delayed_work (hw, &phy->mt76->mac_work,MT7996_WATCHDOG_TIME ); }void mt7996_mac_reset_work (struct work_struct *work) { -struct mt7996_phy *phy2, *phy3; +struct ieee80211_hw *hw;struct mt7996_dev *dev; +struct mt7996_phy *phy;int i; dev = container_of(work, struct mt7996_dev, reset_work); - phy2 =mt7996_phy2 (dev); - phy3 =mt7996_phy3 (dev); + hw =mt76_hw (dev);/* chip full reset */ if (dev->recovery.restart) {
@@ -2474,7 +2429,7 @@ void mt7996_mac_reset_work(struct work_struct *work)return ;dev_info (dev->mt76.dev,"\n%s L1 SER recovery start." , -wiphy_name (dev->mt76.hw->wiphy)); +wiphy_name (hw->wiphy));if (mtk_wed_device_active (&dev->mt76.mmio.wed_hif2))mtk_wed_device_stop (&dev->mt76.mmio.wed_hif2);
@@ -2483,25 +2438,17 @@ void mt7996_mac_reset_work(struct work_struct *work)mtk_wed_device_stop (&dev->mt76.mmio.wed);ieee80211_stop_queues (mt76_hw (dev)); -if (phy2) -ieee80211_stop_queues (phy2->mt76->hw); -if (phy3) -ieee80211_stop_queues (phy3->mt76->hw);set_bit (MT76_RESET , &dev->mphy.state);set_bit (MT76_MCU_RESET , &dev->mphy.state);wake_up (&dev->mt76.mcu.wait);cancel_work_sync (&dev->wed_rro.work); -cancel_delayed_work_sync (&dev->mphy.mac_work); -if (phy2) { -set_bit (MT76_RESET , &phy2->mt76->state); -cancel_delayed_work_sync (&phy2->mt76->mac_work); - } -if (phy3) { -set_bit (MT76_RESET , &phy3->mt76->state); -cancel_delayed_work_sync (&phy3->mt76->mac_work); +mt7996_for_each_phy (dev, phy) { +set_bit (MT76_RESET , &phy->mt76->state); +cancel_delayed_work_sync (&phy->mt76->mac_work); } +mt76_worker_disable (&dev->mt76.tx_worker);mt76_for_each_q_rx (&dev->mt76, i) { if (mtk_wed_device_active(&dev->mt76.mmio.wed) &&
@@ -2553,11 +2500,8 @@ void mt7996_mac_reset_work(struct work_struct *work) }clear_bit (MT76_MCU_RESET , &dev->mphy.state); -clear_bit (MT76_RESET , &dev->mphy.state); -if (phy2) -clear_bit (MT76_RESET , &phy2->mt76->state); -if (phy3) -clear_bit (MT76_RESET , &phy3->mt76->state); +mt7996_for_each_phy (dev, phy) +clear_bit (MT76_RESET , &phy->mt76->state);mt76_for_each_q_rx (&dev->mt76, i) { if (mtk_wed_device_active(&dev->mt76.mmio.wed) &&
@@ -2579,25 +2523,14 @@ void mt7996_mac_reset_work(struct work_struct *work)napi_schedule (&dev->mt76.tx_napi);local_bh_enable (); -ieee80211_wake_queues (mt76_hw (dev)); -if (phy2) -ieee80211_wake_queues (phy2->mt76->hw); -if (phy3) -ieee80211_wake_queues (phy3->mt76->hw); +ieee80211_wake_queues (hw);mutex_unlock (&dev->mt76.mutex);mt7996_update_beacons (dev); -ieee80211_queue_delayed_work (mt76_hw (dev), &dev->mphy.mac_work, -MT7996_WATCHDOG_TIME ); -if (phy2) -ieee80211_queue_delayed_work (phy2->mt76->hw, - &phy2->mt76->mac_work, -MT7996_WATCHDOG_TIME ); -if (phy3) -ieee80211_queue_delayed_work (phy3->mt76->hw, - &phy3->mt76->mac_work, +mt7996_for_each_phy (dev, phy) +ieee80211_queue_delayed_work (hw, &phy->mt76->mac_work,MT7996_WATCHDOG_TIME );dev_info (dev->mt76.dev,"\n%s L1 SER recovery completed." ,wiphy_name (dev->mt76.hw->wiphy));
Signature · 1 line
2.51.0
Felix Fietkau
maintainerPATCH 2/15 wifi: mt76: mt7996: improve hardware restart reliability
Port latest version of similar changes from mt7915:
- use reconfig_complete to restart mac_work / queues
- clear wcid and vif mask to avoid leak
- fix sta poll list corruption
- reset station links
- reset interface links
- clear rro list
--- .../net/wireless/mediatek/mt76/mt7996/mac.c | 86 +++++++++++++++++-- .../net/wireless/mediatek/mt76/mt7996/main.c | 25 ++++-- .../wireless/mediatek/mt76/mt7996/mt7996.h | 2 + 3 files changed, 100 insertions(+), 13 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +79 -7
@@ -2355,11 +2355,59 @@ mt7996_mac_restart(struct mt7996_dev *dev)return ret; } +static void +mt7996_mac_reset_sta_iter (void *data,struct ieee80211_sta *sta) +{ +struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; +struct mt7996_dev *dev = data; +int i; + +for (i =0 ; i <ARRAY_SIZE (msta->link); i++) { +struct mt7996_sta_link *msta_link =NULL ; + + msta_link =rcu_replace_pointer (msta->link[i], msta_link, +lockdep_is_held (&dev->mt76.mutex)); +if (!msta_link) +continue ; + +mt7996_mac_sta_deinit_link (dev, msta_link); + +if (msta->deflink_id == i) { + msta->deflink_id =IEEE80211_LINK_UNSPECIFIED ; +continue ; + } + +kfree_rcu (msta_link, rcu_head); + } +} + +static void +mt7996_mac_reset_vif_iter (void *data,u8 *mac,struct ieee80211_vif *vif) +{ +struct mt76_vif_link *mlink = (struct mt76_vif_link *)vif->drv_priv; +struct mt76_vif_data *mvif = mlink->mvif; +struct mt7996_dev *dev = data; +int i; + +rcu_read_lock (); +for (i =0 ; i <ARRAY_SIZE (mvif->link); i++) { + + mlink =mt76_dereference (mvif->link[i], &dev->mt76); +if (!mlink || mlink == (struct mt76_vif_link *)vif->drv_priv) +continue ; + +rcu_assign_pointer (mvif->link[i],NULL ); +kfree_rcu (mlink, rcu_head); + } +rcu_read_unlock (); +} +static void mt7996_mac_full_reset (struct mt7996_dev *dev) {struct ieee80211_hw *hw =mt76_hw (dev);struct mt7996_phy *phy; +LIST_HEAD (list);int i; dev->recovery.hw_full_reset = true;
@@ -2376,18 +2424,42 @@ mt7996_mac_full_reset(struct mt7996_dev *dev)if (!mt7996_mac_restart (dev))break ; } -mutex_unlock (&dev->mt76.mutex);if (i ==10 )dev_err (dev->mt76.dev,"chip full reset failed\n" ); -ieee80211_restart_hw (mt76_hw (dev)); -ieee80211_wake_queues (mt76_hw (dev)); - - dev->recovery.hw_full_reset = false;mt7996_for_each_phy (dev, phy) -ieee80211_queue_delayed_work (hw, &phy->mt76->mac_work, -MT7996_WATCHDOG_TIME ); + phy->omac_mask =0 ; + +ieee80211_iterate_stations_atomic (hw, mt7996_mac_reset_sta_iter, dev); +ieee80211_iterate_active_interfaces_atomic (hw, +IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER , + mt7996_mac_reset_vif_iter, dev); +mt76_reset_device (&dev->mt76); + +INIT_LIST_HEAD (&dev->sta_rc_list); +INIT_LIST_HEAD (&dev->twt_list); + +spin_lock_bh (&dev->wed_rro.lock); +list_splice_init (&dev->wed_rro.poll_list, &list); +spin_unlock_bh (&dev->wed_rro.lock); + +while (!list_empty (&list)) { +struct mt7996_wed_rro_session_id *e; + + e = list_first_entry(&list, struct mt7996_wed_rro_session_id, + list); +list_del_init (&e->list); +kfree (e); + } + + i =mt76_wcid_alloc (dev->mt76.wcid_mask,MT7996_WTBL_STA ); + dev->mt76.global_wcid.idx = i; + dev->recovery.hw_full_reset = false; + +mutex_unlock (&dev->mt76.mutex); + +ieee80211_restart_hw (mt76_hw (dev)); }void mt7996_mac_reset_work (struct work_struct *work)
drivers/net/wireless/mediatek/mt76/mt7996/main.c +19 -6
@@ -986,13 +986,9 @@ mt7996_mac_sta_init_link(struct mt7996_dev *dev,return 0 ; } -static void -mt7996_mac_sta_deinit_link (struct mt7996_dev *dev, -struct mt7996_sta_link *msta_link) +void mt7996_mac_sta_deinit_link (struct mt7996_dev *dev, +struct mt7996_sta_link *msta_link) { -mt7996_mac_wtbl_update (dev, msta_link->wcid.idx, -MT_WTBL_UPDATE_ADM_COUNT_CLEAR ); -spin_lock_bh (&dev->mt76.sta_poll_lock);if (!list_empty (&msta_link->wcid.poll_list))list_del_init (&msta_link->wcid.poll_list);
@@ -1022,6 +1018,9 @@ mt7996_mac_sta_remove_links(struct mt7996_dev *dev, struct ieee80211_vif *vif,if (!msta_link)continue ; +mt7996_mac_wtbl_update (dev, msta_link->wcid.idx, +MT_WTBL_UPDATE_ADM_COUNT_CLEAR ); +mt7996_mac_sta_deinit_link (dev, msta_link); link =mt7996_vif_link (dev, vif, link_id);if (!link)
@@ -2206,6 +2205,19 @@ mt7996_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,return 0 ; } +static void +mt7996_reconfig_complete (struct ieee80211_hw *hw, +enum ieee80211_reconfig_type reconfig_type) +{ +struct mt7996_dev *dev =mt7996_hw_dev (hw); +struct mt7996_phy *phy; + +ieee80211_wake_queues (hw); +mt7996_for_each_phy (dev, phy) +ieee80211_queue_delayed_work (hw, &phy->mt76->mac_work, +MT7996_WATCHDOG_TIME ); +} +const struct ieee80211_ops mt7996_ops = { .add_chanctx = mt76_add_chanctx, .remove_chanctx = mt76_remove_chanctx,
@@ -2264,4 +2276,5 @@ const struct ieee80211_ops mt7996_ops = {#endif .change_vif_links = mt7996_change_vif_links, .change_sta_links = mt7996_mac_sta_change_links, + .reconfig_complete = mt7996_reconfig_complete, };
drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h +2 -0
@@ -817,6 +817,8 @@ void mt7996_mac_twt_teardown_flow(struct mt7996_dev *dev,struct mt7996_vif_link *link, struct mt7996_sta_link *msta_link, u8 flowid); +void mt7996_mac_sta_deinit_link (struct mt7996_dev *dev, +struct mt7996_sta_link *msta_link);void mt7996_mac_add_twt_setup (struct ieee80211_hw *hw,struct ieee80211_sta *sta,struct ieee80211_twt_setup *twt);
Signature · 1 line
2.51.0
Felix Fietkau
maintainerPATCH 3/15 wifi: mt76: mt7996: decrease timeout for commonly issued MCU commands
In reply to Felix FietkauThis allows faster recovery from firmware issues. Based on patch by Chad Monroe and ported from mt7915.
--- .../net/wireless/mediatek/mt76/mt7996/mcu.c | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c +25 -1
@@ -242,6 +242,30 @@ mt7996_mcu_parse_response(struct mt76_dev *mdev, int cmd,return ret; } +static void +mt7996_mcu_set_timeout (struct mt76_dev *mdev,int cmd) +{ + mdev->mcu.timeout =5 *HZ ; + +if (!(cmd & __MCU_CMD_FIELD_UNI)) +return ; + +switch (FIELD_GET (__MCU_CMD_FIELD_ID, cmd)) { +case MCU_UNI_CMD_THERMAL : +case MCU_UNI_CMD_TWT : +case MCU_UNI_CMD_GET_MIB_INFO : +case MCU_UNI_CMD_STA_REC_UPDATE : +case MCU_UNI_CMD_BSS_INFO_UPDATE : + mdev->mcu.timeout =2 *HZ ; +return ; +case MCU_UNI_CMD_EFUSE_CTRL : + mdev->mcu.timeout =20 *HZ ; +return ; +default : +break ; + } +} +static int mt7996_mcu_send_message (struct mt76_dev *mdev,struct sk_buff *skb,int cmd,int *wait_seq)
@@ -255,7 +279,7 @@ mt7996_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,u32 val;u8 seq; - mdev->mcu.timeout =20 *HZ ; +mt7996_mcu_set_timeout (mdev, cmd); seq = ++dev->mt76.mcu.msg_seq &0xf ;if (!seq)
Signature · 1 line
2.51.0
Felix Fietkau
maintainerPATCH 4/15 wifi: mt76: mt7996: fix setting beacon protection keys
In reply to Felix FietkauInclude beacon key information in the STA_REC_UPDATE call. Remove mt7996_mcu_get_pn - when installing a new key, we should not reuse any existing PN value.
--- .../net/wireless/mediatek/mt76/mt7996/main.c | 7 - .../net/wireless/mediatek/mt76/mt7996/mcu.c | 156 +++++------------- .../net/wireless/mediatek/mt76/mt7996/mcu.h | 14 +- 3 files changed, 45 insertions(+), 132 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/main.c +0 -7
@@ -262,13 +262,6 @@ mt7996_set_hw_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,mt76_wcid_key_setup (&dev->mt76, &msta_link->wcid, key); -if (key->keyidx ==6 || key->keyidx ==7 ) { - err =mt7996_mcu_bcn_prot_enable (dev, link, - msta_link, key); -if (err) -return err; - } - err =mt7996_mcu_add_key (&dev->mt76, vif, key,MCU_WMWA_UNI_CMD (STA_REC_UPDATE ), &msta_link->wcid, cmd);
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c +42 -114
178 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7996/mcu.h +3 -11
@@ -351,17 +351,6 @@ enum { BP_HW_MODE, }; -struct mt7996_mcu_bcn_prot_tlv { -__le16 tag; -__le16 len; -u8 pn[6 ]; -u8 enable; -u8 cipher_id; -u8 key[WLAN_MAX_KEY_LEN ]; -u8 key_id; -u8 __rsv[3 ]; -} __packed; -struct bss_ra_tlv {__le16 tag;__le16 len;
@@ -531,6 +520,9 @@ struct sec_key_uni {u8 key_len;u8 need_resp;u8 key[32 ]; +u8 pn[6 ]; +u8 bcn_mode; +u8 _rsv; } __packed;struct sta_rec_sec_uni {
Signature · 1 line
2.51.0
Felix Fietkau
maintainerPATCH 5/15 wifi: mt76: mt7996: fix memory leak on mt7996_mcu_sta_key_tlv error
In reply to Felix FietkauFree the allocated skb on error
--- drivers/net/wireless/mediatek/mt76/mt7996/mcu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c +3 -1
@@ -2614,8 +2614,10 @@ int mt7996_mcu_add_key(struct mt76_dev *dev, struct ieee80211_vif *vif,return PTR_ERR (skb); ret =mt7996_mcu_sta_key_tlv (wcid, skb, key, cmd); -if (ret) +if (ret) { +dev_kfree_skb (skb);return ret; + }return mt76_mcu_skb_send_msg (dev, skb, mcu_cmd, true); }
Signature · 1 line
2.51.0
Felix Fietkau
maintainerPATCH 6/15 wifi: mt76: mt7996: delete vif keys when requested
In reply to Felix FietkauWhile deleting sta keys can be omitted in order to fix race conditions, vif keys must be deleted before being replaced in order to prevent accidental reuse in firmware.
--- .../net/wireless/mediatek/mt76/mt7996/main.c | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/main.c +13 -7
@@ -252,13 +252,13 @@ mt7996_set_hw_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, &link->mt76, msta_link, true); } -if (cmd ==SET_KEY ) { +if (cmd ==SET_KEY ) *wcid_keyidx = idx; - }else { -if (idx == *wcid_keyidx) - *wcid_keyidx =-1 ; +else if (idx == *wcid_keyidx) + *wcid_keyidx =-1 ; + +if (cmd !=SET_KEY && sta)continue ; - }mt76_wcid_key_setup (&dev->mt76, &msta_link->wcid, key);
@@ -277,10 +277,12 @@ mt7996_key_iter(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta, struct ieee80211_key_conf *key, void *data) { + enum set_key_cmd *cmd = data; +if (sta)return ; -WARN_ON (mt7996_set_hw_key (hw ,SET_KEY ,vif ,NULL ,key )); +WARN_ON (mt7996_set_hw_key (hw, *cmd, vif,NULL , key)); } int mt7996_vif_link_add(struct mt76_phy *mphy, struct ieee80211_vif *vif,
@@ -291,6 +293,7 @@ int mt7996_vif_link_add(struct mt76_phy *mphy, struct ieee80211_vif *vif,struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;struct mt7996_sta_link *msta_link = &link->msta_link;struct mt7996_phy *phy = mphy->priv; +enum set_key_cmd key_cmd =SET_KEY ;struct mt7996_dev *dev = phy->dev;u8 band_idx = phy->mt76->band_idx;struct mt76_txq *mtxq;
@@ -370,7 +373,7 @@ int mt7996_vif_link_add(struct mt76_phy *mphy, struct ieee80211_vif *vif, CONN_STATE_PORT_SECURE, true);rcu_assign_pointer (dev->mt76.wcid[idx], &msta_link->wcid); -ieee80211_iter_keys (mphy->hw, vif, mt7996_key_iter,NULL ); +ieee80211_iter_keys (mphy->hw, vif, mt7996_key_iter, &key_cmd);if (mvif->mt76.deflink_id ==IEEE80211_LINK_UNSPECIFIED ) mvif->mt76.deflink_id = link_conf->link_id;
@@ -385,10 +388,13 @@ void mt7996_vif_link_remove(struct mt76_phy *mphy, struct ieee80211_vif *vif, struct mt7996_vif_link *link = container_of(mlink, struct mt7996_vif_link, mt76);struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;struct mt7996_sta_link *msta_link = &link->msta_link; +enum set_key_cmd key_cmd =DISABLE_KEY ;struct mt7996_phy *phy = mphy->priv;struct mt7996_dev *dev = phy->dev;int idx = msta_link->wcid.idx; +ieee80211_iter_keys (mphy->hw, vif, mt7996_key_iter, &key_cmd); +mt7996_mcu_add_sta (dev, link_conf,NULL , link,NULL ,CONN_STATE_DISCONNECT , false);mt7996_mcu_add_bss_info (phy, vif, link_conf, mlink, msta_link, false);
Signature · 1 line
2.51.0
Felix Fietkau
maintainerPATCH 7/15 wifi: mt76: mt7996: fix key add/remove imbalance
In reply to Felix FietkauEnsure that a key for a link is only added and removed once. When bringing up a link, only upload keys for that particular link, instead of iterating over all of them.
--- .../net/wireless/mediatek/mt76/mt7996/main.c | 183 +++++++++--------- 1 file changed, 95 insertions(+), 88 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/main.c +95 -88
@@ -182,107 +182,96 @@ mt7996_init_bitrate_mask(struct ieee80211_vif *vif, struct mt7996_vif_link *mlinstatic int mt7996_set_hw_key (struct ieee80211_hw *hw,enum set_key_cmd cmd,struct ieee80211_vif *vif,struct ieee80211_sta *sta, -struct ieee80211_key_conf *key) +unsigned int link_id,struct ieee80211_key_conf *key) {struct mt7996_dev *dev =mt7996_hw_dev (hw); +struct mt7996_sta_link *msta_link; +struct mt7996_vif_link *link;int idx = key->keyidx; -unsigned int link_id; -unsigned long links; +u8 *wcid_keyidx; -if (key->link_id >=0 ) - links =BIT (key->link_id); -else if (sta && sta->valid_links) - links = sta->valid_links; -else if (vif->valid_links) - links = vif->valid_links; -else - links =BIT (0 ); + link =mt7996_vif_link (dev, vif, link_id); +if (!link) +return 0 ; -for_each_set_bit (link_id, &links,IEEE80211_MLD_MAX_NUM_LINKS ) { -struct mt7996_sta_link *msta_link; -struct mt7996_vif_link *link; -u8 *wcid_keyidx; -int err; +if (!mt7996_vif_link_phy (link)) +return 0 ; - link =mt7996_vif_link (dev, vif, link_id); -if (!link) -continue ; +if (sta) { +struct mt7996_sta *msta; -if (sta) { -struct mt7996_sta *msta; + msta = (struct mt7996_sta *)sta->drv_priv; + msta_link =mt76_dereference (msta->link[link_id], + &dev->mt76); +if (!msta_link) +return 0 ; - msta = (struct mt7996_sta *)sta->drv_priv; - msta_link =mt76_dereference (msta->link[link_id], - &dev->mt76); -if (!msta_link) -continue ; +if (!msta_link->wcid.sta) +return -EOPNOTSUPP ; + }else { + msta_link = &link->msta_link; + } + wcid_keyidx = &msta_link->wcid.hw_key_idx; -if (!msta_link->wcid.sta) -return -EOPNOTSUPP ; - }else { - msta_link = &link->msta_link; +switch (key->cipher) { +case WLAN_CIPHER_SUITE_AES_CMAC : +case WLAN_CIPHER_SUITE_BIP_CMAC_256 : +case WLAN_CIPHER_SUITE_BIP_GMAC_128 : +case WLAN_CIPHER_SUITE_BIP_GMAC_256 : +if (key->keyidx ==6 || key->keyidx ==7 ) { + wcid_keyidx = &msta_link->wcid.hw_key_idx2; + key->flags |=IEEE80211_KEY_FLAG_GENERATE_MMIE ; } - wcid_keyidx = &msta_link->wcid.hw_key_idx; - -switch (key->cipher) { -case WLAN_CIPHER_SUITE_AES_CMAC : -case WLAN_CIPHER_SUITE_BIP_CMAC_256 : -case WLAN_CIPHER_SUITE_BIP_GMAC_128 : -case WLAN_CIPHER_SUITE_BIP_GMAC_256 : -if (key->keyidx ==6 || key->keyidx ==7 ) { - wcid_keyidx = &msta_link->wcid.hw_key_idx2; - key->flags |=IEEE80211_KEY_FLAG_GENERATE_MMIE ; - } -break ; -default : -break ; - } - -if (cmd ==SET_KEY && !sta && !link->mt76.cipher) { -struct ieee80211_bss_conf *link_conf; - - link_conf =link_conf_dereference_protected (vif, - link_id); -if (!link_conf) - link_conf = &vif->bss_conf; - - link->mt76.cipher = -mt76_connac_mcu_get_cipher (key->cipher); -mt7996_mcu_add_bss_info (link->phy, vif, link_conf, - &link->mt76, msta_link, true); - } - -if (cmd ==SET_KEY ) - *wcid_keyidx = idx; -else if (idx == *wcid_keyidx) - *wcid_keyidx =-1 ; - -if (cmd !=SET_KEY && sta) -continue ; - -mt76_wcid_key_setup (&dev->mt76, &msta_link->wcid, key); - - err =mt7996_mcu_add_key (&dev->mt76, vif, key, -MCU_WMWA_UNI_CMD (STA_REC_UPDATE ), - &msta_link->wcid, cmd); -if (err) -return err; +break ; +default : +break ; } -return 0 ; +if (cmd ==SET_KEY && !sta && !link->mt76.cipher) { +struct ieee80211_bss_conf *link_conf; + + link_conf =link_conf_dereference_protected (vif, + link_id); +if (!link_conf) + link_conf = &vif->bss_conf; + + link->mt76.cipher = +mt76_connac_mcu_get_cipher (key->cipher); +mt7996_mcu_add_bss_info (link->phy, vif, link_conf, + &link->mt76, msta_link, true); + } + +if (cmd ==SET_KEY ) + *wcid_keyidx = idx; +else if (idx == *wcid_keyidx) + *wcid_keyidx =-1 ; + +if (cmd !=SET_KEY && sta) +return 0 ; + +mt76_wcid_key_setup (&dev->mt76, &msta_link->wcid, key); + +return mt7996_mcu_add_key (&dev->mt76, vif, key, +MCU_WMWA_UNI_CMD (STA_REC_UPDATE ), + &msta_link->wcid, cmd); } +struct mt7996_key_iter_data { +enum set_key_cmd cmd; +unsigned int link_id; +}; +static void mt7996_key_iter (struct ieee80211_hw *hw,struct ieee80211_vif *vif,struct ieee80211_sta *sta,struct ieee80211_key_conf *key,void *data) { -enum set_key_cmd *cmd = data; +struct mt7996_key_iter_data *it = data;if (sta)return ; -WARN_ON (mt7996_set_hw_key (hw, *cmd, vif,NULL , key)); +WARN_ON (mt7996_set_hw_key (hw, it->cmd, vif,NULL , it->link_id, key)); } int mt7996_vif_link_add(struct mt76_phy *mphy, struct ieee80211_vif *vif,
@@ -293,9 +282,12 @@ int mt7996_vif_link_add(struct mt76_phy *mphy, struct ieee80211_vif *vif,struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;struct mt7996_sta_link *msta_link = &link->msta_link;struct mt7996_phy *phy = mphy->priv; -enum set_key_cmd key_cmd =SET_KEY ;struct mt7996_dev *dev = phy->dev;u8 band_idx = phy->mt76->band_idx; +struct mt7996_key_iter_data it = { + .cmd =SET_KEY , + .link_id = link_conf->link_id, + };struct mt76_txq *mtxq;int mld_idx, idx, ret;
@@ -373,7 +365,7 @@ int mt7996_vif_link_add(struct mt76_phy *mphy, struct ieee80211_vif *vif, CONN_STATE_PORT_SECURE, true);rcu_assign_pointer (dev->mt76.wcid[idx], &msta_link->wcid); -ieee80211_iter_keys (mphy->hw, vif, mt7996_key_iter, &key_cmd); +ieee80211_iter_keys (mphy->hw, vif, mt7996_key_iter, &it);if (mvif->mt76.deflink_id ==IEEE80211_LINK_UNSPECIFIED ) mvif->mt76.deflink_id = link_conf->link_id;
@@ -388,12 +380,15 @@ void mt7996_vif_link_remove(struct mt76_phy *mphy, struct ieee80211_vif *vif, struct mt7996_vif_link *link = container_of(mlink, struct mt7996_vif_link, mt76);struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;struct mt7996_sta_link *msta_link = &link->msta_link; -enum set_key_cmd key_cmd =DISABLE_KEY ;struct mt7996_phy *phy = mphy->priv;struct mt7996_dev *dev = phy->dev; +struct mt7996_key_iter_data it = { + .cmd =SET_KEY , + .link_id = link_conf->link_id, + };int idx = msta_link->wcid.idx; -ieee80211_iter_keys (mphy->hw, vif, mt7996_key_iter, &key_cmd); +ieee80211_iter_keys (mphy->hw, vif, mt7996_key_iter, &it);mt7996_mcu_add_sta (dev, link_conf,NULL , link,NULL ,CONN_STATE_DISCONNECT , false);
@@ -594,8 +589,9 @@ static int mt7996_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, struct ieee80211_key_conf *key) {struct mt7996_dev *dev =mt7996_hw_dev (hw); -struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; -int err; +unsigned int link_id; +unsigned long links; +int err =0 ;/* The hardware does not support per-STA RX GTK, fallback * to software mode for these.
@@ -629,11 +625,22 @@ static int mt7996_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,return -EOPNOTSUPP ; } -if (!mt7996_vif_link_phy (&mvif->deflink)) -return 0 ;/* defer until after link add */ -mutex_lock (&dev->mt76.mutex); - err =mt7996_set_hw_key (hw, cmd, vif, sta, key); + +if (key->link_id >=0 ) + links =BIT (key->link_id); +else if (sta && sta->valid_links) + links = sta->valid_links; +else if (vif->valid_links) + links = vif->valid_links; +else + links =BIT (0 ); + +for_each_set_bit (link_id, &links,IEEE80211_MLD_MAX_NUM_LINKS ) { + err =mt7996_set_hw_key (hw, cmd, vif, sta, link_id, key); +if (err) +break ; + }mutex_unlock (&dev->mt76.mutex);return err;
Signature · 1 line
2.51.0
Felix Fietkau
maintainerPATCH 8/15 wifi: mt76: mt7996: fix updating beacon protection with beacons enabled
In reply to Felix FietkauDisable and re-enable beacon after beacon protection key change, in order to fully apply the changes.
--- .../net/wireless/mediatek/mt76/mt7996/mac.c | 3 +- .../net/wireless/mediatek/mt76/mt7996/main.c | 35 ++++++++++++------- .../net/wireless/mediatek/mt76/mt7996/mcu.c | 3 +- .../wireless/mediatek/mt76/mt7996/mt7996.h | 2 +- 4 files changed, 26 insertions(+), 17 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +2 -1
@@ -2176,7 +2176,8 @@ mt7996_update_vif_beacon(void *priv, u8 *mac, struct ieee80211_vif *vif)if (!link || link->phy != phy)continue ; -mt7996_mcu_add_beacon (dev->mt76.hw, vif, link_conf); +mt7996_mcu_add_beacon (dev->mt76.hw, vif, link_conf, + link_conf->enable_beacon); } }
drivers/net/wireless/mediatek/mt76/mt7996/main.c +22 -13
@@ -185,10 +185,13 @@ mt7996_set_hw_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, unsigned int link_id, struct ieee80211_key_conf *key) { struct mt7996_dev *dev = mt7996_hw_dev(hw); +struct ieee80211_bss_conf *link_conf;struct mt7996_sta_link *msta_link;struct mt7996_vif_link *link;int idx = key->keyidx;u8 *wcid_keyidx; +bool is_bigtk; +int err; link =mt7996_vif_link (dev, vif, link_id);if (!link)
@@ -213,12 +216,13 @@ mt7996_set_hw_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, } wcid_keyidx = &msta_link->wcid.hw_key_idx; + is_bigtk = key->keyidx ==6 || key->keyidx ==7 ;switch (key->cipher) {case WLAN_CIPHER_SUITE_AES_CMAC :case WLAN_CIPHER_SUITE_BIP_CMAC_256 :case WLAN_CIPHER_SUITE_BIP_GMAC_128 :case WLAN_CIPHER_SUITE_BIP_GMAC_256 : -if (key->keyidx ==6 || key->keyidx ==7 ) { +if (is_bigtk) { wcid_keyidx = &msta_link->wcid.hw_key_idx2; key->flags |=IEEE80211_KEY_FLAG_GENERATE_MMIE ; }
@@ -227,14 +231,11 @@ mt7996_set_hw_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,break ; } + link_conf =link_conf_dereference_protected (vif, link_id); +if (!link_conf) + link_conf = &vif->bss_conf; +if (cmd ==SET_KEY && !sta && !link->mt76.cipher) { -struct ieee80211_bss_conf *link_conf; - - link_conf =link_conf_dereference_protected (vif, - link_id); -if (!link_conf) - link_conf = &vif->bss_conf; - link->mt76.cipher =mt76_connac_mcu_get_cipher (key->cipher); mt7996_mcu_add_bss_info(link->phy, vif, link_conf,
@@ -251,9 +252,17 @@ mt7996_set_hw_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,mt76_wcid_key_setup (&dev->mt76, &msta_link->wcid, key); -return mt7996_mcu_add_key (&dev->mt76, vif, key, -MCU_WMWA_UNI_CMD (STA_REC_UPDATE ), - &msta_link->wcid, cmd); + err =mt7996_mcu_add_key (&dev->mt76, vif, key, +MCU_WMWA_UNI_CMD (STA_REC_UPDATE ), + &msta_link->wcid, cmd); + +/* remove and add beacon in order to enable beacon protection */ +if (cmd ==SET_KEY && is_bigtk && link_conf->enable_beacon) { +mt7996_mcu_add_beacon (hw, vif, link_conf, false); +mt7996_mcu_add_beacon (hw, vif, link_conf, true); + } + +return err; }struct mt7996_key_iter_data {
@@ -900,7 +909,7 @@ mt7996_link_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, link->mt76.beacon_rates_idx =mt7996_get_rates_table (phy, info, true, false); -mt7996_mcu_add_beacon (hw, vif, info); +mt7996_mcu_add_beacon (hw, vif, info, info->enable_beacon); } if (changed & (BSS_CHANGED_UNSOL_BCAST_PROBE_RESP |
@@ -928,7 +937,7 @@ mt7996_channel_switch_beacon(struct ieee80211_hw *hw,struct mt7996_dev *dev =mt7996_hw_dev (hw);mutex_lock (&dev->mt76.mutex); -mt7996_mcu_add_beacon (hw, vif, &vif->bss_conf); +mt7996_mcu_add_beacon (hw, vif, &vif->bss_conf, vif->bss_conf.enable_beacon);mutex_unlock (&dev->mt76.mutex); }
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c +1 -2
@@ -2760,7 +2760,7 @@ mt7996_mcu_beacon_cont(struct mt7996_dev *dev, }int mt7996_mcu_add_beacon (struct ieee80211_hw *hw,struct ieee80211_vif *vif, -struct ieee80211_bss_conf *link_conf) +struct ieee80211_bss_conf *link_conf,bool enabled) {struct mt7996_dev *dev =mt7996_hw_dev (hw);struct mt7996_vif_link *link =mt7996_vif_conf_link (dev, vif, link_conf);
@@ -2771,7 +2771,6 @@ int mt7996_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif,struct tlv *tlv;struct bss_bcn_content_tlv *bcn;int len, extra_len =0 ; -bool enabled = link_conf->enable_beacon;if (link_conf->nontransmitted)return 0 ;
drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h +1 -1
@@ -682,7 +682,7 @@ int mt7996_mcu_update_bss_color(struct mt7996_dev *dev,struct mt76_vif_link *mlink, struct cfg80211_he_bss_color *he_bss_color);int mt7996_mcu_add_beacon (struct ieee80211_hw *hw,struct ieee80211_vif *vif, -struct ieee80211_bss_conf *link_conf); +struct ieee80211_bss_conf *link_conf,bool enabled);int mt7996_mcu_beacon_inband_discov (struct mt7996_dev *dev,struct ieee80211_bss_conf *link_conf,struct mt7996_vif_link *link,u32 changed);
Signature · 1 line
2.51.0
Felix Fietkau
maintainerPATCH 9/15 wifi: mt76: use altx queue for offchannel tx on connac+
In reply to Felix FietkauThis ensures that packets are sent out immediately and are not held by firmware internal buffering.
--- drivers/net/wireless/mediatek/mt76/tx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/tx.c +2 -1
@@ -618,7 +618,8 @@ mt76_txq_schedule_pending_wcid(struct mt76_phy *phy, struct mt76_wcid *wcid, !(info->flags &IEEE80211_TX_CTL_HW_80211_ENCAP ) && !ieee80211_is_data (hdr->frame_control) && (!ieee80211_is_bufferable_mmpdu (skb) || - ieee80211_is_deauth(hdr->frame_control))) +ieee80211_is_deauth (hdr->frame_control) || + head == &wcid->tx_offchannel)) qid = MT_TXQ_PSD; q = phy->q_tx[qid];
Signature · 1 line
2.51.0
Felix Fietkau
maintainerPATCH 10/15 wifi: mt76: mt7996: disable promiscuous mode by default
In reply to Felix FietkauFrom: Peter Chiu <[email protected]>
Set MT_WF_RFCR_DROP_OTHER_UC by default and disable this flag in mt7996_set_monitor only if monitor mode is enabled.
Without this patch, the MT_WF_RFCR_DROP_OTHER_UC would not be set so the driver would receive lots of packets meant for other devices.
--- drivers/net/wireless/mediatek/mt76/mt7996/init.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/mediatek/mt76/mt7996/init.c +1 -0
@@ -410,6 +410,7 @@ mt7996_init_wiphy_band(struct ieee80211_hw *hw, struct mt7996_phy *phy) phy->slottime =9 ; phy->beacon_rate =-1 ; + phy->rxfilter =MT_WF_RFCR_DROP_OTHER_UC ;if (phy->mt76->cap.has_2ghz) { phy->mt76->sband_2g.sband.ht_cap.cap |=
Signature · 1 line
2.51.0
Felix Fietkau
maintainerPATCH 11/15 wifi: mt76: mt7996: remove the mem_total field of STA_REC_BF command
In reply to Felix FietkauFrom: Howard Hsu <[email protected]>
It is not used by the firmware.
--- drivers/net/wireless/mediatek/mt76/mt7996/mcu.c | 13 ------------- 1 file changed, 13 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c +0 -13
@@ -1837,19 +1837,6 @@ mt7996_mcu_sta_bfer_tlv(struct mt7996_dev *dev, struct sk_buff *skb, bf->mem_20m = bf->nrow <BF_MAT_ORDER ? matrix[bf->nrow][bf->ncol] :0 ; } - -switch (link_sta->bandwidth) { -case IEEE80211_STA_RX_BW_160 : -case IEEE80211_STA_RX_BW_80 : - bf->mem_total = bf->mem_20m *2 ; -break ; -case IEEE80211_STA_RX_BW_40 : - bf->mem_total = bf->mem_20m; -break ; -case IEEE80211_STA_RX_BW_20 : -default : -break ; - } } static void
Signature · 1 line
2.51.0
Felix Fietkau
maintainerPATCH 12/15 wifi: mt76: mt7996: set VTA in txwi
In reply to Felix FietkauFrom: Peter Chiu <[email protected]>
Enable VTA flag in txwi to enable HQD in SPL which is needed by the PST. Without this patch, PST cannot get the correct delay of TxD and lead to a large latency.
--- drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +1 -1
@@ -968,7 +968,7 @@ void mt7996_mac_write_txwi(struct mt7996_dev *dev, __le32 *txwi, val |=MT_TXD5_TX_STATUS_HOST ; txwi[5 ] =cpu_to_le32 (val); - val =MT_TXD6_DAS ; + val =MT_TXD6_DAS |MT_TXD6_VTA ;if ((q_idx >=MT_LMAC_ALTX0 && q_idx <=MT_LMAC_BCN0 ) || skb->protocol ==cpu_to_be16 (ETH_P_PAE )) val |=MT_TXD6_DIS_MAT ;
Signature · 1 line
2.51.0
Felix Fietkau
maintainerPATCH 13/15 wifi: mt76: mt7996: fill User Priority in skb->priority for rx packets
In reply to Felix FietkauFrom: Howard Hsu <[email protected]>
Set UP in skb->priority to allow DSCP Learning at upper layers
--- drivers/net/wireless/mediatek/mt76/mac80211.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/mediatek/mt76/mac80211.c +2 -0
@@ -1235,6 +1235,8 @@ mt76_rx_convert(struct mt76_dev *dev, struct sk_buff *skb, mstat = *((struct mt76_rx_status *)skb->cb);memset (status,0 ,sizeof (*status)); + skb->priority = mstat.qos_ctl &IEEE80211_QOS_CTL_TID_MASK ; + status->flag = mstat.flag; status->freq = mstat.freq; status->enc_flags = mstat.enc_flags;
Signature · 1 line
2.51.0
Felix Fietkau
maintainerPATCH 14/15 wifi: mt76: improve phy reset on hw restart
In reply to Felix Fietkau- fix number of station accounting for scanning code.
- reset channel context
--- drivers/net/wireless/mediatek/mt76/mac80211.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/mediatek/mt76/mac80211.c +2 -0
@@ -824,6 +824,8 @@ static void mt76_reset_phy(struct mt76_phy *phy)return ;INIT_LIST_HEAD (&phy->tx_list); + phy->num_sta =0 ; + phy->chanctx =NULL ; }void mt76_reset_device (struct mt76_dev *dev)
Signature · 1 line
2.51.0
Felix Fietkau
maintainerPATCH 15/15 wifi: mt76: abort scan/roc on hw restart
In reply to Felix FietkauAvoid spurious channel changes and clean up allocated links
--- drivers/net/wireless/mediatek/mt76/channel.c | 13 +++++++++---- drivers/net/wireless/mediatek/mt76/mac80211.c | 3 +++ drivers/net/wireless/mediatek/mt76/mt76.h | 1 + drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 2 ++ drivers/net/wireless/mediatek/mt76/scan.c | 10 +++++++--- 5 files changed, 22 insertions(+), 7 deletions(-)
drivers/net/wireless/mediatek/mt76/channel.c +9 -4
@@ -314,21 +314,24 @@ void mt76_put_vif_phy_link(struct mt76_phy *phy, struct ieee80211_vif *vif,kfree (mlink); } -static void mt76_roc_complete (struct mt76_phy *phy) +void mt76_roc_complete (struct mt76_phy *phy) {struct mt76_vif_link *mlink = phy->roc_link; +struct mt76_dev *dev = phy->dev;if (!phy->roc_vif)return ;if (mlink) mlink->mvif->roc_phy =NULL ; -if (phy->main_chandef.chan) +if (phy->main_chandef.chan && + !test_bit (MT76_MCU_RESET , &dev->phy.state))mt76_set_channel (phy, &phy->main_chandef, false);mt76_put_vif_phy_link (phy, phy->roc_vif, phy->roc_link); phy->roc_vif =NULL ; phy->roc_link =NULL ; -ieee80211_remain_on_channel_expired (phy->hw); +if (!test_bit (MT76_MCU_RESET , &dev->phy.state)) +ieee80211_remain_on_channel_expired (phy->hw); }void mt76_roc_complete_work (struct work_struct *work)
@@ -351,6 +354,7 @@ void mt76_abort_roc(struct mt76_phy *phy)mt76_roc_complete (phy);mutex_unlock (&dev->mutex); } +EXPORT_SYMBOL_GPL (mt76_abort_roc); int mt76_remain_on_channel(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_channel *chan, int duration,
@@ -368,7 +372,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) { +if (phy->roc_vif || dev->scan.phy == phy || +test_bit (MT76_MCU_RESET , &dev->phy.state)) { ret = -EBUSY ; goto out; }
drivers/net/wireless/mediatek/mt76/mac80211.c +3 -0
@@ -826,6 +826,7 @@ static void mt76_reset_phy(struct mt76_phy *phy)INIT_LIST_HEAD (&phy->tx_list); phy->num_sta =0 ; phy->chanctx =NULL ; +mt76_roc_complete (phy); }void mt76_reset_device (struct mt76_dev *dev)
@@ -846,6 +847,8 @@ void mt76_reset_device(struct mt76_dev *dev) }rcu_read_unlock (); +mt76_abort_scan (dev); +INIT_LIST_HEAD (&dev->wcid_list);INIT_LIST_HEAD (&dev->sta_poll_list); dev->vif_mask =0 ;
drivers/net/wireless/mediatek/mt76/mt76.h +1 -0
@@ -1643,6 +1643,7 @@ int mt76_set_channel(struct mt76_phy *phy, struct cfg80211_chan_def *chandef,void mt76_scan_work (struct work_struct *work);void mt76_abort_scan (struct mt76_dev *dev);void mt76_roc_complete_work (struct work_struct *work); +void mt76_roc_complete (struct mt76_phy *phy);void mt76_abort_roc (struct mt76_phy *phy);struct mt76_vif_link *mt76_get_vif_phy_link (struct mt76_phy *phy,struct ieee80211_vif *vif);
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +2 -0
@@ -2514,10 +2514,12 @@ void mt7996_mac_reset_work(struct work_struct *work)set_bit (MT76_RESET , &dev->mphy.state);set_bit (MT76_MCU_RESET , &dev->mphy.state); +mt76_abort_scan (&dev->mt76);wake_up (&dev->mt76.mcu.wait);cancel_work_sync (&dev->wed_rro.work);mt7996_for_each_phy (dev, phy) { +mt76_abort_roc (phy->mt76);set_bit (MT76_RESET , &phy->mt76->state);cancel_delayed_work_sync (&phy->mt76->mac_work); }
drivers/net/wireless/mediatek/mt76/scan.c +7 -3
@@ -16,11 +16,13 @@ static void mt76_scan_complete(struct mt76_dev *dev, bool abort)clear_bit (MT76_SCANNING , &phy->state); -if (dev->scan.chan && phy->main_chandef.chan) +if (dev->scan.chan && phy->main_chandef.chan && + !test_bit (MT76_MCU_RESET , &dev->phy.state))mt76_set_channel (phy, &phy->main_chandef, false);mt76_put_vif_phy_link (phy, dev->scan.vif, dev->scan.mlink);memset (&dev->scan,0 ,sizeof (dev->scan)); -ieee80211_scan_completed (phy->hw, &info); +if (!test_bit (MT76_MCU_RESET , &dev->phy.state)) +ieee80211_scan_completed (phy->hw, &info); }void mt76_abort_scan (struct mt76_dev *dev)
@@ -28,6 +30,7 @@ void mt76_abort_scan(struct mt76_dev *dev)cancel_delayed_work_sync (&dev->scan_work);mt76_scan_complete (dev, true); } +EXPORT_SYMBOL_GPL (mt76_abort_scan);static void mt76_scan_send_probe (struct mt76_dev *dev,struct cfg80211_ssid *ssid)
@@ -136,7 +139,8 @@ int mt76_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,mutex_lock (&dev->mutex); -if (dev->scan.req || phy->roc_vif) { +if (dev->scan.req || phy->roc_vif || +test_bit (MT76_MCU_RESET , &dev->phy.state)) { ret = -EBUSY ; goto out; }
Signature · 1 line
2.51.0