brcmsmac: AP mode: update beacon when TIM changes
authorAli MJ Al-Nasrawy <alimjalnasrawy@gmail.com>
Wed, 3 Oct 2018 16:21:39 +0000 (19:21 +0300)
committerKalle Valo <kvalo@codeaurora.org>
Sat, 13 Oct 2018 17:00:42 +0000 (20:00 +0300)
Beacons are not updated to reflect TIM changes. This is not compliant with
power-saving client stations as the beacons do not have valid TIM and can
cause the network to stall at random occasions and to have highly variable
latencies.
Fix it by updating beacon templates on mac80211 set_tim callback.

Addresses an issue described in:
https://marc.info/?i=20180911163534.21312d08%20()%20manjaro

Signed-off-by: Ali MJ Al-Nasrawy <alimjalnasrawy@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c
drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.h

index 6255fb6d97a7087dfcbf11cc9182afafbd4c4982..81ff558046a8f9a51183d4471acc177823da08d8 100644 (file)
@@ -502,6 +502,7 @@ brcms_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
        }
 
        spin_lock_bh(&wl->lock);
+       wl->wlc->vif = vif;
        wl->mute_tx = false;
        brcms_c_mute(wl->wlc, false);
        if (vif->type == NL80211_IFTYPE_STATION)
@@ -519,6 +520,11 @@ brcms_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 static void
 brcms_ops_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 {
+       struct brcms_info *wl = hw->priv;
+
+       spin_lock_bh(&wl->lock);
+       wl->wlc->vif = NULL;
+       spin_unlock_bh(&wl->lock);
 }
 
 static int brcms_ops_config(struct ieee80211_hw *hw, u32 changed)
@@ -937,6 +943,25 @@ static void brcms_ops_set_tsf(struct ieee80211_hw *hw,
        spin_unlock_bh(&wl->lock);
 }
 
+static int brcms_ops_beacon_set_tim(struct ieee80211_hw *hw,
+                                struct ieee80211_sta *sta, bool set)
+{
+       struct brcms_info *wl = hw->priv;
+       struct sk_buff *beacon = NULL;
+       u16 tim_offset = 0;
+
+       spin_lock_bh(&wl->lock);
+       if (wl->wlc->vif)
+               beacon = ieee80211_beacon_get_tim(hw, wl->wlc->vif,
+                                                 &tim_offset, NULL);
+       if (beacon)
+               brcms_c_set_new_beacon(wl->wlc, beacon, tim_offset,
+                                      wl->wlc->vif->bss_conf.dtim_period);
+       spin_unlock_bh(&wl->lock);
+
+       return 0;
+}
+
 static const struct ieee80211_ops brcms_ops = {
        .tx = brcms_ops_tx,
        .start = brcms_ops_start,
@@ -955,6 +980,7 @@ static const struct ieee80211_ops brcms_ops = {
        .flush = brcms_ops_flush,
        .get_tsf = brcms_ops_get_tsf,
        .set_tsf = brcms_ops_set_tsf,
+       .set_tim = brcms_ops_beacon_set_tim,
 };
 
 void brcms_dpc(unsigned long data)
index c4d135cff04ad2f7883c783fb96244bbbabfa370..9f76b880814e8201744a83256f8a89af8e4f0ba7 100644 (file)
@@ -563,6 +563,7 @@ struct brcms_c_info {
 
        struct wiphy *wiphy;
        struct scb pri_scb;
+       struct ieee80211_vif *vif;
 
        struct sk_buff *beacon;
        u16 beacon_tim_offset;