Skip to content

Commit 4540568

Browse files
committed
wifi: mac80211: handle TPE element during CSA
Handle the transmit power envelope (TPE) element during channel switch, applying it when the channel switch is done. Reviewed-by: Miriam Rachel Korenblit <[email protected]> Link: https://msgid.link/20240506215543.486c33157d18.Idf971ad801b6961c177bdf42cc323fd1a4ca8165@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent f81747a commit 4540568

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

net/mac80211/ieee80211_i.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,8 @@ struct ieee80211_link_data_managed {
977977

978978
struct {
979979
struct wiphy_delayed_work switch_work;
980+
struct cfg80211_chan_def ap_chandef;
981+
struct ieee80211_parsed_tpe tpe;
980982
unsigned long time;
981983
bool waiting_bcn;
982984
bool ignored_same_chan;
@@ -1754,6 +1756,7 @@ struct ieee802_11_elems {
17541756

17551757
/* not the order in the psd values is per element, not per chandef */
17561758
struct ieee80211_parsed_tpe tpe;
1759+
struct ieee80211_parsed_tpe csa_tpe;
17571760

17581761
/* length of them, respectively */
17591762
u8 ext_capab_len;

net/mac80211/mlme.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,6 +2129,20 @@ static void ieee80211_csa_switch_work(struct wiphy *wiphy,
21292129

21302130
link->u.mgd.csa.waiting_bcn = true;
21312131

2132+
/* apply new TPE restrictions immediately on the new channel */
2133+
if (link->u.mgd.csa.ap_chandef.chan->band == NL80211_BAND_6GHZ &&
2134+
link->u.mgd.conn.mode >= IEEE80211_CONN_MODE_HE) {
2135+
ieee80211_rearrange_tpe(&link->u.mgd.csa.tpe,
2136+
&link->u.mgd.csa.ap_chandef,
2137+
&link->conf->chanreq.oper);
2138+
if (memcmp(&link->conf->tpe, &link->u.mgd.csa.tpe,
2139+
sizeof(link->u.mgd.csa.tpe))) {
2140+
link->conf->tpe = link->u.mgd.csa.tpe;
2141+
ieee80211_link_info_change_notify(sdata, link,
2142+
BSS_CHANGED_TPE);
2143+
}
2144+
}
2145+
21322146
ieee80211_sta_reset_beacon_monitor(sdata);
21332147
ieee80211_sta_reset_conn_monitor(sdata);
21342148
}
@@ -2379,6 +2393,8 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link,
23792393
ch_switch.count = csa_ie.count;
23802394
ch_switch.delay = csa_ie.max_switch_time;
23812395
}
2396+
2397+
link->u.mgd.csa.tpe = csa_elems->csa_tpe;
23822398
} else {
23832399
/*
23842400
* If there was no per-STA profile for this link, we
@@ -2517,6 +2533,8 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link,
25172533
goto drop_connection;
25182534
}
25192535

2536+
link->u.mgd.csa.ap_chandef = csa_ie.chanreq.ap;
2537+
25202538
link->csa.chanreq = csa_ie.chanreq;
25212539
if (link->u.mgd.conn.mode < IEEE80211_CONN_MODE_EHT ||
25222540
sdata->vif.driver_flags & IEEE80211_VIF_IGNORE_OFDMA_WIDER_BW)

net/mac80211/parse.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,13 @@ _ieee802_11_parse_elems_full(struct ieee80211_elems_parse_params *params,
607607
elem_parse_failed =
608608
IEEE80211_PARSE_ERR_BAD_ELEM_SIZE;
609609
}
610+
611+
subelem = cfg80211_find_ext_elem(WLAN_EID_TX_POWER_ENVELOPE,
612+
pos, elen);
613+
if (subelem)
614+
ieee80211_parse_tpe(&elems->csa_tpe,
615+
subelem->data + 1,
616+
subelem->datalen - 1);
610617
break;
611618
case WLAN_EID_COUNTRY:
612619
elems->country_elem = pos;
@@ -962,6 +969,7 @@ ieee802_11_parse_elems_full(struct ieee80211_elems_parse_params *params)
962969

963970
/* set all TPE entries to unlimited (but invalid) */
964971
ieee80211_clear_tpe(&elems->tpe);
972+
ieee80211_clear_tpe(&elems->csa_tpe);
965973

966974
nontransmitted_profile = elems_parse->scratch_pos;
967975
nontransmitted_profile_len =

0 commit comments

Comments
 (0)