blob: 3318c2000f38dfba7055abf31b84a6fadda4b44d [file] [log] [blame]
developer617abbd2024-04-23 14:50:01 +08001From e564e83652ae93e37f624eac45f98d3ee17cb811 Mon Sep 17 00:00:00 2001
2From: Allen Ye <allen.ye@mediatek.com>
3Date: Thu, 22 Feb 2024 15:21:49 +0800
4Subject: [PATCH 53/61] mtk: mac80211: workaround for configuring txpower in
5 mld ap
6
7As for mt76 design, we expect to set txpower per link. So, we add
8another parameter to ieee80211_recalc_txpower function to set
9txpower to per link. For the functions that mac80211 don't pass link
10id to which, we specify to use the FIRST link as the parameter.
11
12Apply the patch will make uci and iw set txpower commamd only effect
13the link which id is 0 when we enable mld AP.
14
15CR-Id: WCNCR00259302
16---
17 net/mac80211/cfg.c | 15 ++++++++++++---
18 net/mac80211/chan.c | 4 ++--
19 net/mac80211/ieee80211_i.h | 5 +++--
20 net/mac80211/iface.c | 15 ++++++++-------
21 net/mac80211/mlme.c | 2 +-
22 5 files changed, 26 insertions(+), 15 deletions(-)
23
24diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
25index c3b9d10..cca3e08 100644
26--- a/net/mac80211/cfg.c
27+++ b/net/mac80211/cfg.c
28@@ -3059,7 +3059,11 @@ static int ieee80211_set_tx_power(struct wiphy *wiphy,
29 sdata->vif.bss_conf.txpower_type = txp_type;
30 }
31
32- ieee80211_recalc_txpower(sdata, update_txp_type);
33+ /* Due to mac80211 not pass link id to here, use first link for now */
34+ if (ieee80211_vif_is_mld(&sdata->vif))
35+ ieee80211_recalc_txpower(sdata, update_txp_type, sdata->link[0]);
36+ else
37+ ieee80211_recalc_txpower(sdata, update_txp_type, &sdata->deflink);
38
39 return 0;
40 }
41@@ -3090,7 +3094,12 @@ static int ieee80211_set_tx_power(struct wiphy *wiphy,
42 list_for_each_entry(sdata, &local->interfaces, list) {
43 if (sdata->vif.type == NL80211_IFTYPE_MONITOR)
44 continue;
45- ieee80211_recalc_txpower(sdata, update_txp_type);
46+ /* Due to mac80211 not pass link id to here, use first link for now */
47+ if (ieee80211_vif_is_mld(&sdata->vif))
48+ ieee80211_recalc_txpower(sdata, update_txp_type, sdata->link[0]);
49+ else
50+ ieee80211_recalc_txpower(sdata, update_txp_type, &sdata->deflink);
51+
52 }
53
54 if (has_monitor) {
55@@ -3102,7 +3111,7 @@ static int ieee80211_set_tx_power(struct wiphy *wiphy,
56 update_txp_type = true;
57 sdata->vif.bss_conf.txpower_type = txp_type;
58
59- ieee80211_recalc_txpower(sdata, update_txp_type);
60+ ieee80211_recalc_txpower(sdata, update_txp_type, &sdata->deflink);
61 }
62 }
63
64diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
65index ac22524..f09cac4 100644
66--- a/net/mac80211/chan.c
67+++ b/net/mac80211/chan.c
68@@ -842,7 +842,7 @@ out:
69 }
70
71 if (new_ctx && ieee80211_chanctx_num_assigned(local, new_ctx) > 0) {
72- ieee80211_recalc_txpower(sdata, false);
73+ ieee80211_recalc_txpower(sdata, false, link);
74 ieee80211_recalc_chanctx_min_def(local, new_ctx, NULL);
75 }
76
77@@ -1570,7 +1570,7 @@ static int ieee80211_vif_use_reserved_switch(struct ieee80211_local *local)
78 link,
79 changed);
80
81- ieee80211_recalc_txpower(sdata, false);
82+ ieee80211_recalc_txpower(sdata, false, link);
83 }
84
85 ieee80211_recalc_chanctx_chantype(local, ctx);
86diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
87index 608e442..6f1b783 100644
88--- a/net/mac80211/ieee80211_i.h
89+++ b/net/mac80211/ieee80211_i.h
90@@ -2023,9 +2023,10 @@ void ieee80211_sdata_stop(struct ieee80211_sub_if_data *sdata);
91 int ieee80211_add_virtual_monitor(struct ieee80211_local *local);
92 void ieee80211_del_virtual_monitor(struct ieee80211_local *local);
93
94-bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata);
95+bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata,
96+ struct ieee80211_link_data *link);
97 void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata,
98- bool update_bss);
99+ bool update_bss, struct ieee80211_link_data *link);
100 void ieee80211_recalc_offload(struct ieee80211_local *local);
101
102 static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata)
103diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
104index 026436e..3400811 100644
105--- a/net/mac80211/iface.c
106+++ b/net/mac80211/iface.c
107@@ -44,13 +44,14 @@
108
109 static void ieee80211_iface_work(struct wiphy *wiphy, struct wiphy_work *work);
110
111-bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata)
112+bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata,
113+ struct ieee80211_link_data *link)
114 {
115 struct ieee80211_chanctx_conf *chanctx_conf;
116 int power;
117
118 rcu_read_lock();
119- chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf);
120+ chanctx_conf = rcu_dereference(link->conf->chanctx_conf);
121 if (!chanctx_conf) {
122 rcu_read_unlock();
123 return false;
124@@ -65,8 +66,8 @@ bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata)
125 if (sdata->deflink.ap_power_level != IEEE80211_UNSET_POWER_LEVEL)
126 power = min(power, sdata->deflink.ap_power_level);
127
128- if (power != sdata->vif.bss_conf.txpower) {
129- sdata->vif.bss_conf.txpower = power;
130+ if (power != link->conf->txpower) {
131+ link->conf->txpower = power;
132 ieee80211_hw_config(sdata->local, 0);
133 return true;
134 }
135@@ -75,11 +76,11 @@ bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata)
136 }
137
138 void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata,
139- bool update_bss)
140+ bool update_bss, struct ieee80211_link_data *link)
141 {
142- if (__ieee80211_recalc_txpower(sdata) ||
143+ if (__ieee80211_recalc_txpower(sdata, link) ||
144 (update_bss && ieee80211_sdata_running(sdata)))
145- ieee80211_link_info_change_notify(sdata, &sdata->deflink,
146+ ieee80211_link_info_change_notify(sdata, link,
147 BSS_CHANGED_TXPOWER);
148 }
149
150diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
151index b9d10e9..2efd98e 100644
152--- a/net/mac80211/mlme.c
153+++ b/net/mac80211/mlme.c
154@@ -2362,7 +2362,7 @@ static u64 ieee80211_handle_pwr_constr(struct ieee80211_link_data *link,
155 }
156
157 link->ap_power_level = new_ap_level;
158- if (__ieee80211_recalc_txpower(sdata))
159+ if (__ieee80211_recalc_txpower(sdata, link))
160 return BSS_CHANGED_TXPOWER;
161 return 0;
162 }
163--
1642.39.2
165