blob: 3577abd438d50d1814e4a05deee6fa346c7bdc3e [file] [log] [blame]
developer14bd31c2023-03-08 06:38:53 +08001From 13c1f52aa61fe71335711e16216ba6abb33a8ead 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 +
developer983d9492023-02-17 07:31:03 +080010 net/mac80211/cfg.c | 25 +++++++++++++++++++++++++
developer14bd31c2023-03-08 06:38:53 +080011 net/mac80211/ieee80211_i.h | 5 +++++
developer983d9492023-02-17 07:31:03 +080012 net/mac80211/iface.c | 5 +++++
13 net/mac80211/rx.c | 1 +
developer14bd31c2023-03-08 06:38:53 +080014 5 files changed, 37 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
developer14bd31c2023-03-08 06:38:53 +080029index 86d231b..82e44d2 100644
developer983d9492023-02-17 07:31:03 +080030--- a/net/mac80211/cfg.c
31+++ b/net/mac80211/cfg.c
32@@ -4425,6 +4425,31 @@ unlock:
33 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+
46+ for (i = 0; i < IEEE80211_BSS_COLOR_MAX; i++) {
47+ /* ageout if not seen for a period */
developer14bd31c2023-03-08 06:38:53 +080048+ if ((bss_conf->used_color_bitmap & BIT_ULL(i)) &&
49+ time_before(bss_conf->color_last_seen[i],
developer983d9492023-02-17 07:31:03 +080050+ jiffies - IEEE80211_BSS_COLOR_AGEOUT_TIME * HZ)) {
developer14bd31c2023-03-08 06:38:53 +080051+ bss_conf->used_color_bitmap &= ~BIT_ULL(i);
developer983d9492023-02-17 07:31:03 +080052+ }
53+ }
54+
55+ ieee80211_queue_delayed_work(&sdata->local->hw,
56+ &sdata->color_aging_work, HZ);
57+
58+ sdata_unlock(sdata);
59+}
60+
61 void ieee80211_color_change_finish(struct ieee80211_vif *vif)
62 {
63 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
64diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
developer14bd31c2023-03-08 06:38:53 +080065index 6edabd8..2519c14 100644
developer983d9492023-02-17 07:31:03 +080066--- a/net/mac80211/ieee80211_i.h
67+++ b/net/mac80211/ieee80211_i.h
68@@ -1033,6 +1033,8 @@ struct ieee80211_sub_if_data {
69 } debugfs;
70 #endif
71
72+ struct delayed_work color_aging_work;
73+
74 /* must be last, dynamically sized area in this! */
75 struct ieee80211_vif vif;
76 };
77@@ -1811,8 +1813,11 @@ void ieee80211_csa_finalize_work(struct work_struct *work);
78 int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
79 struct cfg80211_csa_settings *params);
80
81+#define IEEE80211_BSS_COLOR_AGEOUT_TIME 10
82+#define IEEE80211_BSS_COLOR_MAX 64
83 /* color change handling */
84 void ieee80211_color_change_finalize_work(struct work_struct *work);
85+void ieee80211_color_aging_work(struct work_struct *work);
86
87 /* interface handling */
88 #define MAC80211_SUPPORTED_FEATURES_TX (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | \
89diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
developer14bd31c2023-03-08 06:38:53 +080090index d314f39..ba25327 100644
developer983d9492023-02-17 07:31:03 +080091--- a/net/mac80211/iface.c
92+++ b/net/mac80211/iface.c
93@@ -466,6 +466,8 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do
94 cancel_work_sync(&sdata->color_change_finalize_work);
95
96 cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
97+ if (sdata->vif.type == NL80211_IFTYPE_AP)
98+ cancel_delayed_work_sync(&sdata->color_aging_work);
99
100 if (sdata->wdev.cac_started) {
101 chandef = sdata->vif.bss_conf.chandef;
developer14bd31c2023-03-08 06:38:53 +0800102@@ -1758,6 +1760,9 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
developer983d9492023-02-17 07:31:03 +0800103 skb_queue_head_init(&sdata->u.ap.ps.bc_buf);
104 INIT_LIST_HEAD(&sdata->u.ap.vlans);
105 sdata->vif.bss_conf.bssid = sdata->vif.addr;
106+ INIT_DELAYED_WORK(&sdata->color_aging_work, ieee80211_color_aging_work);
107+ ieee80211_queue_delayed_work(&sdata->local->hw,
108+ &sdata->color_aging_work, 0);
109 break;
110 case NL80211_IFTYPE_P2P_CLIENT:
111 type = NL80211_IFTYPE_STATION;
112diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
developer14bd31c2023-03-08 06:38:53 +0800113index 36fcf97..31d3bb4 100644
developer983d9492023-02-17 07:31:03 +0800114--- a/net/mac80211/rx.c
115+++ b/net/mac80211/rx.c
116@@ -3221,6 +3221,7 @@ ieee80211_rx_check_bss_color_collision(struct ieee80211_rx_data *rx)
117 IEEE80211_HE_OPERATION_BSS_COLOR_MASK);
118
developer14bd31c2023-03-08 06:38:53 +0800119 bss_conf->used_color_bitmap |= BIT_ULL(color);
120+ bss_conf->color_last_seen[color] = jiffies;
121
122 trace_bss_color_bitmap(color, bss_conf->used_color_bitmap);
developer983d9492023-02-17 07:31:03 +0800123
developer983d9492023-02-17 07:31:03 +0800124--
1252.39.0
126