blob: 351cb740ac443993673f5c86e67f8944a5d873e1 [file] [log] [blame]
developer9237f442024-06-14 17:13:04 +08001From 81a4701e1fb249ce062c5d17e6c670265ef0f05e Mon Sep 17 00:00:00 2001
developerdad89a32024-04-29 14:17:17 +08002From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
3Date: Mon, 22 Apr 2024 16:49:48 +0800
developer9237f442024-06-14 17:13:04 +08004Subject: [PATCH 116/116] mtk: wifi: mt76: mt7996: remain multiple wiphy model
5 for testmode
developerdad89a32024-04-29 14:17:17 +08006
7Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
8---
9 mt7996/init.c | 13 ++++++++-----
10 mt7996/main.c | 14 ++++++++++----
11 mt7996/mt7996.h | 9 ++++-----
12 3 files changed, 22 insertions(+), 14 deletions(-)
13
14diff --git a/mt7996/init.c b/mt7996/init.c
developer9237f442024-06-14 17:13:04 +080015index ff72aab..58944c6 100644
developerdad89a32024-04-29 14:17:17 +080016--- a/mt7996/init.c
17+++ b/mt7996/init.c
18@@ -794,9 +794,11 @@ static int mt7996_register_phy(struct mt7996_dev *dev, struct mt7996_phy *phy,
19 mtk_wed_device_start(&dev->mt76.mmio.wed_hif2, MT_INT_TX_RX_DONE_EXT);
20 }
21
22- /* TODO: FIXME: force to use single wiphy, need to rework init flow */
23- phy->mt76->ori_hw = mphy->hw;
24- mphy->hw = dev->phy.mt76->hw;
25+ /* TODO: FIXME: force to use single wiphy for normal mode, need to rework init flow */
26+ if (!dev->testmode_enable) {
27+ phy->mt76->ori_hw = mphy->hw;
28+ mphy->hw = dev->phy.mt76->hw;
29+ }
30
31 return 0;
32
33@@ -832,8 +834,9 @@ mt7996_unregister_phy(struct mt7996_phy *phy, enum mt76_band_id band)
34 if (!phy)
35 return;
36
37- /* TODO: FIXME: temp for single wiphy support */
38- phy->mt76->hw = phy->mt76->ori_hw;
39+ /* TODO: FIXME: temp for normal mode single wiphy support */
40+ if (!phy->dev->testmode_enable)
41+ phy->mt76->hw = phy->mt76->ori_hw;
42
43 #ifdef CONFIG_MTK_VENDOR
44 mt7996_unregister_csi(phy);
45diff --git a/mt7996/main.c b/mt7996/main.c
developer9237f442024-06-14 17:13:04 +080046index 2cc0c32..9738e76 100644
developerdad89a32024-04-29 14:17:17 +080047--- a/mt7996/main.c
48+++ b/mt7996/main.c
49@@ -140,8 +140,8 @@ static int mt7996_start(struct ieee80211_hw *hw)
50 struct mt7996_dev *dev = mt7996_hw_dev(hw);
51 int ret;
52
53- /* only allow settings from hw0 */
54- if (hw != dev->phy.mt76->hw)
55+ /* only allow settings from hw0 for normal mode */
56+ if (!dev->testmode_enable && hw != dev->phy.mt76->hw)
57 return -1;
58
59 flush_work(&dev->init_work);
60@@ -158,8 +158,8 @@ static void mt7996_stop(struct ieee80211_hw *hw)
61 struct mt7996_dev *dev = mt7996_hw_dev(hw);
62 int band;
63
64- /* only allow settings from hw0 */
65- if (hw != dev->phy.mt76->hw)
66+ /* only allow settings from hw0 for normal mode */
67+ if (!dev->testmode_enable && hw != dev->phy.mt76->hw)
68 return;
69
70 cancel_delayed_work_sync(&dev->scs_work);
71@@ -453,6 +453,12 @@ static int mt7996_add_interface(struct ieee80211_hw *hw,
72 is_zero_ether_addr(vif->addr))
73 phy->monitor_vif = vif;
74
75+ if (dev->testmode_enable && vif->type != NL80211_IFTYPE_MONITOR) {
76+ mutex_unlock(&dev->mt76.mutex);
77+ dev_err(dev->mt76.dev, "Only monitor interface is allowed in testmode\n");
78+ return -EINVAL;
79+ }
80+
81 INIT_DELAYED_WORK(&mvif->beacon_mon_work, mt7996_beacon_mon_work);
82 mvif->dev = dev;
83 mvif->hw = hw;
84diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
developer9237f442024-06-14 17:13:04 +080085index de7cf1e..45f8af1 100644
developerdad89a32024-04-29 14:17:17 +080086--- a/mt7996/mt7996.h
87+++ b/mt7996/mt7996.h
developer9237f442024-06-14 17:13:04 +080088@@ -860,16 +860,15 @@ mt7996_get_background_radar_cap(struct mt7996_dev *dev)
developerdad89a32024-04-29 14:17:17 +080089 static inline struct mt7996_phy *
90 mt7996_band_phy(struct ieee80211_hw *hw, enum nl80211_band band)
91 {
92- struct mt76_dev *dev = hw->priv;
93- struct mt76_phy *phy;
94+ struct mt76_phy *phy = hw->priv;
95
96 /* TODO: mlo: temporarily hardcode */
97 if (band == NL80211_BAND_6GHZ)
98- phy = dev->phys[MT_BAND2];
99+ phy = phy->dev->phys[MT_BAND2];
100 else if (band == NL80211_BAND_5GHZ)
101- phy = dev->phys[MT_BAND1];
102+ phy = phy->dev->phys[MT_BAND1];
103 else
104- phy = dev->phys[MT_BAND0];
105+ phy = phy->dev->phys[MT_BAND0];
106
107 if (!phy)
108 return NULL;
109--
1102.18.0
111