blob: 5d323beb3d1fb897a345c5e5f18006bea0e6d35d [file] [log] [blame]
developer63e4dfd2023-03-22 09:11:04 +08001From 2b96a2bd30821f7db9a5f29392e5652f0426de29 Mon Sep 17 00:00:00 2001
developerc9eaf902023-03-13 05:45:10 +08002From: Yi-Chia Hsieh <yi-chia.hsieh@mediatek.com>
3Date: Mon, 13 Mar 2023 05:36:59 +0800
developer63e4dfd2023-03-22 09:11:04 +08004Subject: [PATCH] mac80211: mtk: ageout color bitmap
developerc9eaf902023-03-13 05:45:10 +08005
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---
9 include/net/mac80211.h | 1 +
developer63e4dfd2023-03-22 09:11:04 +080010 net/mac80211/cfg.c | 30 ++++++++++++++++++++++++++++++
developerc9eaf902023-03-13 05:45:10 +080011 net/mac80211/ieee80211_i.h | 6 ++++++
12 net/mac80211/iface.c | 5 +++++
13 net/mac80211/rx.c | 1 +
developer63e4dfd2023-03-22 09:11:04 +080014 5 files changed, 43 insertions(+)
developerc9eaf902023-03-13 05:45:10 +080015
16diff --git a/include/net/mac80211.h b/include/net/mac80211.h
17index 3cf1745..d044be5 100644
18--- a/include/net/mac80211.h
19+++ b/include/net/mac80211.h
20@@ -730,6 +730,7 @@ struct ieee80211_bss_conf {
21 struct ieee80211_he_obss_pd he_obss_pd;
22 struct cfg80211_he_bss_color he_bss_color;
23 u64 used_color_bitmap;
24+ u64 color_last_seen[64];
25 struct ieee80211_fils_discovery fils_discovery;
26 u32 unsol_bcast_probe_resp_interval;
27 struct cfg80211_bitrate_mask beacon_tx_rate;
28diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
developer63e4dfd2023-03-22 09:11:04 +080029index 5c9dda1..b792d7e 100644
developerc9eaf902023-03-13 05:45:10 +080030--- a/net/mac80211/cfg.c
31+++ b/net/mac80211/cfg.c
developer63e4dfd2023-03-22 09:11:04 +080032@@ -4755,6 +4755,36 @@ out:
developerc9eaf902023-03-13 05:45:10 +080033 return err;
34 }
35
36+void
37+ieee80211_color_aging_work(struct work_struct *work)
38+{
39+ struct ieee80211_sub_if_data *sdata =
40+ container_of(work, struct ieee80211_sub_if_data,
41+ color_aging_work.work);
42+ struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf;
43+ int i = 0;
44+
45+ sdata_lock(sdata);
46+
developer63e4dfd2023-03-22 09:11:04 +080047+ if (!ieee80211_sdata_running(sdata))
48+ goto unlock;
49+
developerc9eaf902023-03-13 05:45:10 +080050+ for (i = 0; i < IEEE80211_BSS_COLOR_MAX; i++) {
51+ /* ageout if not seen for a period */
52+ if ((bss_conf->used_color_bitmap & BIT_ULL(i)) &&
53+ time_before(bss_conf->color_last_seen[i],
54+ jiffies - IEEE80211_BSS_COLOR_AGEOUT_TIME * HZ)) {
55+ bss_conf->used_color_bitmap &= ~BIT_ULL(i);
56+ }
57+ }
58+
59+ ieee80211_queue_delayed_work(&sdata->local->hw,
60+ &sdata->color_aging_work, HZ);
61+
developer63e4dfd2023-03-22 09:11:04 +080062+unlock:
developerc9eaf902023-03-13 05:45:10 +080063+ sdata_unlock(sdata);
64+}
65+
66 static int
67 ieee80211_set_radar_background(struct wiphy *wiphy,
68 struct cfg80211_chan_def *chandef)
69diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
70index a10ef29..295f45b 100644
71--- a/net/mac80211/ieee80211_i.h
72+++ b/net/mac80211/ieee80211_i.h
73@@ -1111,6 +1111,8 @@ struct ieee80211_sub_if_data {
74 } debugfs;
75 #endif
76
77+ struct delayed_work color_aging_work;
78+
79 /* must be last, dynamically sized area in this! */
80 struct ieee80211_vif vif;
81 };
82@@ -1930,8 +1932,12 @@ void ieee80211_csa_finalize_work(struct work_struct *work);
83 int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
84 struct cfg80211_csa_settings *params);
85
86+#define IEEE80211_BSS_COLOR_AGEOUT_TIME 10
87+#define IEEE80211_BSS_COLOR_MAX 64
88+
89 /* color change handling */
90 void ieee80211_color_change_finalize_work(struct work_struct *work);
91+void ieee80211_color_aging_work(struct work_struct *work);
92
93 /* interface handling */
94 #define MAC80211_SUPPORTED_FEATURES_TX (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | \
95diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
developer63e4dfd2023-03-22 09:11:04 +080096index b80fb66..91ac7b0 100644
developerc9eaf902023-03-13 05:45:10 +080097--- a/net/mac80211/iface.c
98+++ b/net/mac80211/iface.c
developer63e4dfd2023-03-22 09:11:04 +080099@@ -541,6 +541,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do
developerc9eaf902023-03-13 05:45:10 +0800100 cancel_work_sync(&sdata->deflink.color_change_finalize_work);
101
102 cancel_delayed_work_sync(&sdata->deflink.dfs_cac_timer_work);
developer63e4dfd2023-03-22 09:11:04 +0800103+ cancel_delayed_work_sync(&sdata->color_aging_work);
developerc9eaf902023-03-13 05:45:10 +0800104
105 if (sdata->wdev.cac_started) {
106 chandef = sdata->vif.bss_conf.chandef;
developer63e4dfd2023-03-22 09:11:04 +0800107@@ -1787,6 +1788,8 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
developerc9eaf902023-03-13 05:45:10 +0800108 skb_queue_head_init(&sdata->u.ap.ps.bc_buf);
109 INIT_LIST_HEAD(&sdata->u.ap.vlans);
110 sdata->vif.bss_conf.bssid = sdata->vif.addr;
developerc9eaf902023-03-13 05:45:10 +0800111+ ieee80211_queue_delayed_work(&sdata->local->hw,
112+ &sdata->color_aging_work, 0);
113 break;
114 case NL80211_IFTYPE_P2P_CLIENT:
115 type = NL80211_IFTYPE_STATION;
developer63e4dfd2023-03-22 09:11:04 +0800116@@ -2189,6 +2192,8 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
117
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;
developerc9eaf902023-03-13 05:45:10 +0800125diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
126index fd2f650..67c768c 100644
127--- a/net/mac80211/rx.c
128+++ b/net/mac80211/rx.c
129@@ -3340,6 +3340,7 @@ ieee80211_rx_check_bss_color_collision(struct ieee80211_rx_data *rx)
130 IEEE80211_HE_OPERATION_BSS_COLOR_MASK);
131
132 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);
136
137--
1382.39.0
139