blob: b530b3bb1772e4c3dd1dbef8bc595a271ce19f78 [file] [log] [blame]
developered151932023-03-24 02:06:28 +08001From 84d68e0b64f56564560fc96b6e3ce10078462a01 Mon Sep 17 00:00:00 2001
developer983d9492023-02-17 07:31:03 +08002From: Yi-Chia Hsieh <yi-chia.hsieh@mediatek.com>
developer14bd31c2023-03-08 06:38:53 +08003Date: Wed, 8 Mar 2023 06:32:42 +0800
developer983d9492023-02-17 07:31:03 +08004Subject: [PATCH] mac80211: mtk: ageout color bitmap
5
6Adding a periodic work which runs once per second to check BSS color.
7OBSS BSS Color will be ageout if not seen for 10 seconds.
8---
developer14bd31c2023-03-08 06:38:53 +08009 include/net/mac80211.h | 1 +
developer63e4dfd2023-03-22 09:11:04 +080010 net/mac80211/cfg.c | 29 +++++++++++++++++++++++++++++
developer14bd31c2023-03-08 06:38:53 +080011 net/mac80211/ieee80211_i.h | 5 +++++
developered151932023-03-24 02:06:28 +080012 net/mac80211/iface.c | 7 +++++++
developer983d9492023-02-17 07:31:03 +080013 net/mac80211/rx.c | 1 +
developered151932023-03-24 02:06:28 +080014 5 files changed, 43 insertions(+)
developer983d9492023-02-17 07:31:03 +080015
developer14bd31c2023-03-08 06:38:53 +080016diff --git a/include/net/mac80211.h b/include/net/mac80211.h
17index c6cadf7..6f8c661 100644
18--- a/include/net/mac80211.h
19+++ b/include/net/mac80211.h
20@@ -700,6 +700,7 @@ struct ieee80211_bss_conf {
21 struct ieee80211_he_obss_pd he_obss_pd;
22 struct cfg80211_he_bss_color he_bss_color;
developer983d9492023-02-17 07:31:03 +080023 u64 used_color_bitmap;
24+ u64 color_last_seen[64];
developer14bd31c2023-03-08 06:38:53 +080025 struct ieee80211_fils_discovery fils_discovery;
26 u32 unsol_bcast_probe_resp_interval;
27 bool s1g;
developer983d9492023-02-17 07:31:03 +080028diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
developer63e4dfd2023-03-22 09:11:04 +080029index 86d231b..7449777 100644
developer983d9492023-02-17 07:31:03 +080030--- a/net/mac80211/cfg.c
31+++ b/net/mac80211/cfg.c
developer63e4dfd2023-03-22 09:11:04 +080032@@ -4425,6 +4425,35 @@ unlock:
developer983d9492023-02-17 07:31:03 +080033 sdata_unlock(sdata);
34 }
35
36+void ieee80211_color_aging_work(struct work_struct *work)
37+{
38+ struct ieee80211_sub_if_data *sdata =
39+ container_of(work, struct ieee80211_sub_if_data,
40+ color_aging_work.work);
developer14bd31c2023-03-08 06:38:53 +080041+ struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf;
developer983d9492023-02-17 07:31:03 +080042+ int i = 0;
43+
44+ sdata_lock(sdata);
45+
developer63e4dfd2023-03-22 09:11:04 +080046+ if (!ieee80211_sdata_running(sdata))
47+ goto unlock;
48+
developer983d9492023-02-17 07:31:03 +080049+ for (i = 0; i < IEEE80211_BSS_COLOR_MAX; i++) {
50+ /* ageout if not seen for a period */
developer14bd31c2023-03-08 06:38:53 +080051+ if ((bss_conf->used_color_bitmap & BIT_ULL(i)) &&
52+ time_before(bss_conf->color_last_seen[i],
developer983d9492023-02-17 07:31:03 +080053+ jiffies - IEEE80211_BSS_COLOR_AGEOUT_TIME * HZ)) {
developer14bd31c2023-03-08 06:38:53 +080054+ bss_conf->used_color_bitmap &= ~BIT_ULL(i);
developer983d9492023-02-17 07:31:03 +080055+ }
56+ }
57+
58+ ieee80211_queue_delayed_work(&sdata->local->hw,
59+ &sdata->color_aging_work, HZ);
60+
developer63e4dfd2023-03-22 09:11:04 +080061+unlock:
developer983d9492023-02-17 07:31:03 +080062+ sdata_unlock(sdata);
63+}
64+
65 void ieee80211_color_change_finish(struct ieee80211_vif *vif)
66 {
67 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
68diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
developer14bd31c2023-03-08 06:38:53 +080069index 6edabd8..2519c14 100644
developer983d9492023-02-17 07:31:03 +080070--- a/net/mac80211/ieee80211_i.h
71+++ b/net/mac80211/ieee80211_i.h
72@@ -1033,6 +1033,8 @@ struct ieee80211_sub_if_data {
73 } debugfs;
74 #endif
75
76+ struct delayed_work color_aging_work;
77+
78 /* must be last, dynamically sized area in this! */
79 struct ieee80211_vif vif;
80 };
81@@ -1811,8 +1813,11 @@ void ieee80211_csa_finalize_work(struct work_struct *work);
82 int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
83 struct cfg80211_csa_settings *params);
84
85+#define IEEE80211_BSS_COLOR_AGEOUT_TIME 10
86+#define IEEE80211_BSS_COLOR_MAX 64
87 /* color change handling */
88 void ieee80211_color_change_finalize_work(struct work_struct *work);
89+void ieee80211_color_aging_work(struct work_struct *work);
90
91 /* interface handling */
92 #define MAC80211_SUPPORTED_FEATURES_TX (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | \
93diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
developered151932023-03-24 02:06:28 +080094index d314f39..00b0443 100644
developer983d9492023-02-17 07:31:03 +080095--- a/net/mac80211/iface.c
96+++ b/net/mac80211/iface.c
developer63e4dfd2023-03-22 09:11:04 +080097@@ -466,6 +466,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do
developer983d9492023-02-17 07:31:03 +080098 cancel_work_sync(&sdata->color_change_finalize_work);
99
100 cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
developer63e4dfd2023-03-22 09:11:04 +0800101+ cancel_delayed_work_sync(&sdata->color_aging_work);
developer983d9492023-02-17 07:31:03 +0800102
103 if (sdata->wdev.cac_started) {
104 chandef = sdata->vif.bss_conf.chandef;
developered151932023-03-24 02:06:28 +0800105@@ -1391,6 +1392,10 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
106 set_bit(SDATA_STATE_RUNNING, &sdata->state);
107
108 switch (sdata->vif.type) {
109+ case NL80211_IFTYPE_AP:
developer983d9492023-02-17 07:31:03 +0800110+ ieee80211_queue_delayed_work(&sdata->local->hw,
developered151932023-03-24 02:06:28 +0800111+ &sdata->color_aging_work, HZ);
112+ break;
113 case NL80211_IFTYPE_P2P_DEVICE:
114 rcu_assign_pointer(local->p2p_sdata, sdata);
developer983d9492023-02-17 07:31:03 +0800115 break;
developered151932023-03-24 02:06:28 +0800116@@ -2166,6 +2171,8 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
developer63e4dfd2023-03-22 09:11:04 +0800117 ieee80211_dfs_cac_timer_work);
118 INIT_DELAYED_WORK(&sdata->dec_tailroom_needed_wk,
119 ieee80211_delayed_tailroom_dec);
120+ INIT_DELAYED_WORK(&sdata->color_aging_work,
121+ ieee80211_color_aging_work);
122
123 for (i = 0; i < NUM_NL80211_BANDS; i++) {
124 struct ieee80211_supported_band *sband;
developer983d9492023-02-17 07:31:03 +0800125diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
developer63e4dfd2023-03-22 09:11:04 +0800126index 36fcf97..838085f 100644
developer983d9492023-02-17 07:31:03 +0800127--- a/net/mac80211/rx.c
128+++ b/net/mac80211/rx.c
129@@ -3221,6 +3221,7 @@ ieee80211_rx_check_bss_color_collision(struct ieee80211_rx_data *rx)
130 IEEE80211_HE_OPERATION_BSS_COLOR_MASK);
131
developer14bd31c2023-03-08 06:38:53 +0800132 bss_conf->used_color_bitmap |= BIT_ULL(color);
133+ bss_conf->color_last_seen[color] = jiffies;
134
135 trace_bss_color_bitmap(color, bss_conf->used_color_bitmap);
developer983d9492023-02-17 07:31:03 +0800136
developer983d9492023-02-17 07:31:03 +0800137--
1382.39.0
139