Skip to content

Commit b1a23f8

Browse files
AyalaBkrjmberg-intel
authored andcommitted
wifi: mac80211: fix advertised TTLM scheduling
Handle a case of time overflow, where the switch time might be smaller than the partial TSF in the beacon. Additionally, apply advertised TTLM earlier in order to be ready on time on the newly activated links. Fixes: 702e804 ("wifi: mac80211: support handling of advertised TID-to-link mapping") Signed-off-by: Ayala Beker <[email protected]> Reviewed-by: Johannes Berg <[email protected]> Signed-off-by: Miri Korenblit <[email protected]> Link: https://msgid.link/20231220133549.15079c34e5c8.I0dd50bcceff5953080cdd7aee5118b72c78c6507@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent acc44cb commit b1a23f8

File tree

1 file changed

+40
-9
lines changed

1 file changed

+40
-9
lines changed

net/mac80211/mlme.c

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
#define IEEE80211_ASSOC_TIMEOUT_SHORT (HZ / 10)
4444
#define IEEE80211_ASSOC_MAX_TRIES 3
4545

46+
#define IEEE80211_ADV_TTLM_SAFETY_BUFFER_MS msecs_to_jiffies(100)
47+
#define IEEE80211_ADV_TTLM_ST_UNDERFLOW 0xff00
48+
4649
static int max_nullfunc_tries = 2;
4750
module_param(max_nullfunc_tries, int, 0644);
4851
MODULE_PARM_DESC(max_nullfunc_tries,
@@ -5964,6 +5967,13 @@ ieee80211_parse_adv_t2l(struct ieee80211_sub_if_data *sdata,
59645967
pos++;
59655968

59665969
ttlm_info->switch_time = get_unaligned_le16(pos);
5970+
5971+
/* Since ttlm_info->switch_time == 0 means no switch time, bump it
5972+
* by 1.
5973+
*/
5974+
if (!ttlm_info->switch_time)
5975+
ttlm_info->switch_time = 1;
5976+
59675977
pos += 2;
59685978

59695979
if (control & IEEE80211_TTLM_CONTROL_EXPECTED_DUR_PRESENT) {
@@ -6058,25 +6068,46 @@ static void ieee80211_process_adv_ttlm(struct ieee80211_sub_if_data *sdata,
60586068
}
60596069

60606070
if (ttlm_info.switch_time) {
6061-
u32 st_us, delay = 0;
6062-
u32 ts_l26 = beacon_ts & GENMASK(25, 0);
6071+
u16 beacon_ts_tu, st_tu, delay;
6072+
u32 delay_jiffies;
6073+
u64 mask;
60636074

60646075
/* The t2l map switch time is indicated with a partial
6065-
* TSF value, convert it to TSF and calc the delay
6066-
* to the start time.
6076+
* TSF value (bits 10 to 25), get the partial beacon TS
6077+
* as well, and calc the delay to the start time.
6078+
*/
6079+
mask = GENMASK_ULL(25, 10);
6080+
beacon_ts_tu = (beacon_ts & mask) >> 10;
6081+
st_tu = ttlm_info.switch_time;
6082+
delay = st_tu - beacon_ts_tu;
6083+
6084+
/*
6085+
* If the switch time is far in the future, then it
6086+
* could also be the previous switch still being
6087+
* announced.
6088+
* We can simply ignore it for now, if it is a future
6089+
* switch the AP will continue to announce it anyway.
6090+
*/
6091+
if (delay > IEEE80211_ADV_TTLM_ST_UNDERFLOW)
6092+
return;
6093+
6094+
delay_jiffies = TU_TO_JIFFIES(delay);
6095+
6096+
/* Link switching can take time, so schedule it
6097+
* 100ms before to be ready on time
60676098
*/
6068-
st_us = ieee80211_tu_to_usec(ttlm_info.switch_time);
6069-
if (st_us > ts_l26)
6070-
delay = st_us - ts_l26;
6099+
if (delay_jiffies > IEEE80211_ADV_TTLM_SAFETY_BUFFER_MS)
6100+
delay_jiffies -=
6101+
IEEE80211_ADV_TTLM_SAFETY_BUFFER_MS;
60716102
else
6072-
continue;
6103+
delay_jiffies = 0;
60736104

60746105
sdata->u.mgd.ttlm_info = ttlm_info;
60756106
wiphy_delayed_work_cancel(sdata->local->hw.wiphy,
60766107
&sdata->u.mgd.ttlm_work);
60776108
wiphy_delayed_work_queue(sdata->local->hw.wiphy,
60786109
&sdata->u.mgd.ttlm_work,
6079-
usecs_to_jiffies(delay));
6110+
delay_jiffies);
60806111
return;
60816112
}
60826113
}

0 commit comments

Comments
 (0)