]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - net/mac80211/sta_info.c
mac80211: Dynamically set CoDel parameters per station
[karo-tx-linux.git] / net / mac80211 / sta_info.c
index 7cdf7a835bb01e8fade3b9d9bb6efaa19158f72b..f59434ac385df7fa68eba438070ef335ef6c9d86 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/timer.h>
 #include <linux/rtnetlink.h>
 
+#include <net/codel.h>
 #include <net/mac80211.h>
 #include "ieee80211_i.h"
 #include "driver-ops.h"
@@ -425,6 +426,11 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
 
        sta->sta.max_rc_amsdu_len = IEEE80211_MAX_MPDU_LEN_HT_BA;
 
+       sta->cparams.ce_threshold = CODEL_DISABLED_THRESHOLD;
+       sta->cparams.target = MS2TIME(20);
+       sta->cparams.interval = MS2TIME(100);
+       sta->cparams.ecn = true;
+
        sta_dbg(sdata, "Allocated STA %pM\n", sta->sta.addr);
 
        return sta;
@@ -2310,3 +2316,27 @@ unsigned long ieee80211_sta_last_active(struct sta_info *sta)
                return stats->last_rx;
        return sta->status_stats.last_ack;
 }
+
+static void sta_update_codel_params(struct sta_info *sta, u32 thr)
+{
+       if (!sta->sdata->local->ops->wake_tx_queue)
+               return;
+
+       if (thr && thr < STA_SLOW_THRESHOLD * sta->local->num_sta) {
+               sta->cparams.target = MS2TIME(50);
+               sta->cparams.interval = MS2TIME(300);
+               sta->cparams.ecn = false;
+       } else {
+               sta->cparams.target = MS2TIME(20);
+               sta->cparams.interval = MS2TIME(100);
+               sta->cparams.ecn = true;
+       }
+}
+
+void ieee80211_sta_set_expected_throughput(struct ieee80211_sta *pubsta,
+                                          u32 thr)
+{
+       struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
+
+       sta_update_codel_params(sta, thr);
+}