blob: 4ac10cb52087bdba53ebeddb9a9a5208253a7ab8 [file] [log] [blame]
developerd0c89452024-10-11 16:53:27 +08001From 2437744f9744acc7ca65d991906a17f7f5d123d5 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
developerd0c89452024-10-11 16:53:27 +08004Subject: [PATCH 111/223] mtk: mt76: mt7996: remain multiple wiphy model for
developer05f3b2b2024-08-19 19:17:34 +08005 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
developerd0c89452024-10-11 16:53:27 +080015index 1d31e96a..c5c12ba0 100644
developerdad89a32024-04-29 14:17:17 +080016--- a/mt7996/init.c
17+++ b/mt7996/init.c
developer05f3b2b2024-08-19 19:17:34 +080018@@ -795,9 +795,11 @@ static int mt7996_register_phy(struct mt7996_dev *dev, struct mt7996_phy *phy,
developerdad89a32024-04-29 14:17:17 +080019 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
developer05f3b2b2024-08-19 19:17:34 +080033@@ -833,8 +835,9 @@ mt7996_unregister_phy(struct mt7996_phy *phy, enum mt76_band_id band)
developerdad89a32024-04-29 14:17:17 +080034 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
developerd0c89452024-10-11 16:53:27 +080046index 0c5ddda1..0b62858b 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);
developerd0c89452024-10-11 16:53:27 +080060@@ -158,8 +158,8 @@ static void mt7996_stop(struct ieee80211_hw *hw, bool suspend)
developerdad89a32024-04-29 14:17:17 +080061 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);
developer05f3b2b2024-08-19 19:17:34 +080071@@ -455,6 +455,12 @@ static int mt7996_add_interface(struct ieee80211_hw *hw,
developerdad89a32024-04-29 14:17:17 +080072 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
developerd0c89452024-10-11 16:53:27 +080085index e23ed8e7..b8699b65 100644
developerdad89a32024-04-29 14:17:17 +080086--- a/mt7996/mt7996.h
87+++ b/mt7996/mt7996.h
developerd0c89452024-10-11 16:53:27 +080088@@ -880,16 +880,15 @@ mt7996_has_background_radar(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--
developerd0c89452024-10-11 16:53:27 +08001102.45.2
developerdad89a32024-04-29 14:17:17 +0800111