developer | ed7222c | 2023-04-14 07:19:52 +0800 | [diff] [blame^] | 1 | From c481f3323ae0e44feeba59851258b1612b2808a0 Mon Sep 17 00:00:00 2001 |
developer | c9eaf90 | 2023-03-13 05:45:10 +0800 | [diff] [blame] | 2 | From: Yi-Chia Hsieh <yi-chia.hsieh@mediatek.com> |
| 3 | Date: Mon, 13 Mar 2023 05:36:59 +0800 |
developer | ed7222c | 2023-04-14 07:19:52 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 15/16] mac80211: mtk: ageout color bitmap |
developer | c9eaf90 | 2023-03-13 05:45:10 +0800 | [diff] [blame] | 5 | |
| 6 | Adding a periodic work which runs once per second to check BSS color. |
| 7 | OBSS BSS Color will be ageout if not seen for 10 seconds. |
| 8 | --- |
| 9 | include/net/mac80211.h | 1 + |
developer | 63e4dfd | 2023-03-22 09:11:04 +0800 | [diff] [blame] | 10 | net/mac80211/cfg.c | 30 ++++++++++++++++++++++++++++++ |
developer | ed15193 | 2023-03-24 02:06:28 +0800 | [diff] [blame] | 11 | net/mac80211/ieee80211_i.h | 5 +++++ |
developer | c9eaf90 | 2023-03-13 05:45:10 +0800 | [diff] [blame] | 12 | net/mac80211/iface.c | 5 +++++ |
developer | ed15193 | 2023-03-24 02:06:28 +0800 | [diff] [blame] | 13 | net/mac80211/link.c | 2 ++ |
developer | c9eaf90 | 2023-03-13 05:45:10 +0800 | [diff] [blame] | 14 | net/mac80211/rx.c | 1 + |
developer | ed15193 | 2023-03-24 02:06:28 +0800 | [diff] [blame] | 15 | 6 files changed, 44 insertions(+) |
developer | c9eaf90 | 2023-03-13 05:45:10 +0800 | [diff] [blame] | 16 | |
| 17 | diff --git a/include/net/mac80211.h b/include/net/mac80211.h |
developer | ed7222c | 2023-04-14 07:19:52 +0800 | [diff] [blame^] | 18 | index ef95cc7..323d57f 100644 |
developer | c9eaf90 | 2023-03-13 05:45:10 +0800 | [diff] [blame] | 19 | --- a/include/net/mac80211.h |
| 20 | +++ b/include/net/mac80211.h |
| 21 | @@ -730,6 +730,7 @@ struct ieee80211_bss_conf { |
| 22 | struct ieee80211_he_obss_pd he_obss_pd; |
| 23 | struct cfg80211_he_bss_color he_bss_color; |
| 24 | u64 used_color_bitmap; |
| 25 | + u64 color_last_seen[64]; |
| 26 | struct ieee80211_fils_discovery fils_discovery; |
| 27 | u32 unsol_bcast_probe_resp_interval; |
| 28 | struct cfg80211_bitrate_mask beacon_tx_rate; |
| 29 | diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c |
developer | ed15193 | 2023-03-24 02:06:28 +0800 | [diff] [blame] | 30 | index 5c9dda1..343ce2b 100644 |
developer | c9eaf90 | 2023-03-13 05:45:10 +0800 | [diff] [blame] | 31 | --- a/net/mac80211/cfg.c |
| 32 | +++ b/net/mac80211/cfg.c |
developer | 63e4dfd | 2023-03-22 09:11:04 +0800 | [diff] [blame] | 33 | @@ -4755,6 +4755,36 @@ out: |
developer | c9eaf90 | 2023-03-13 05:45:10 +0800 | [diff] [blame] | 34 | return err; |
| 35 | } |
| 36 | |
| 37 | +void |
| 38 | +ieee80211_color_aging_work(struct work_struct *work) |
| 39 | +{ |
| 40 | + struct ieee80211_sub_if_data *sdata = |
| 41 | + container_of(work, struct ieee80211_sub_if_data, |
developer | ed15193 | 2023-03-24 02:06:28 +0800 | [diff] [blame] | 42 | + deflink.color_aging_work.work); |
developer | c9eaf90 | 2023-03-13 05:45:10 +0800 | [diff] [blame] | 43 | + struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; |
| 44 | + int i = 0; |
| 45 | + |
| 46 | + sdata_lock(sdata); |
| 47 | + |
developer | 63e4dfd | 2023-03-22 09:11:04 +0800 | [diff] [blame] | 48 | + if (!ieee80211_sdata_running(sdata)) |
| 49 | + goto unlock; |
| 50 | + |
developer | c9eaf90 | 2023-03-13 05:45:10 +0800 | [diff] [blame] | 51 | + for (i = 0; i < IEEE80211_BSS_COLOR_MAX; i++) { |
| 52 | + /* ageout if not seen for a period */ |
| 53 | + if ((bss_conf->used_color_bitmap & BIT_ULL(i)) && |
| 54 | + time_before(bss_conf->color_last_seen[i], |
| 55 | + jiffies - IEEE80211_BSS_COLOR_AGEOUT_TIME * HZ)) { |
| 56 | + bss_conf->used_color_bitmap &= ~BIT_ULL(i); |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + ieee80211_queue_delayed_work(&sdata->local->hw, |
developer | ed15193 | 2023-03-24 02:06:28 +0800 | [diff] [blame] | 61 | + &sdata->deflink.color_aging_work, HZ); |
developer | c9eaf90 | 2023-03-13 05:45:10 +0800 | [diff] [blame] | 62 | + |
developer | 63e4dfd | 2023-03-22 09:11:04 +0800 | [diff] [blame] | 63 | +unlock: |
developer | c9eaf90 | 2023-03-13 05:45:10 +0800 | [diff] [blame] | 64 | + sdata_unlock(sdata); |
| 65 | +} |
| 66 | + |
| 67 | static int |
| 68 | ieee80211_set_radar_background(struct wiphy *wiphy, |
| 69 | struct cfg80211_chan_def *chandef) |
| 70 | diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h |
developer | 8eb72a3 | 2023-03-30 08:32:07 +0800 | [diff] [blame] | 71 | index f7da92b..bc3f133 100644 |
developer | c9eaf90 | 2023-03-13 05:45:10 +0800 | [diff] [blame] | 72 | --- a/net/mac80211/ieee80211_i.h |
| 73 | +++ b/net/mac80211/ieee80211_i.h |
developer | ed15193 | 2023-03-24 02:06:28 +0800 | [diff] [blame] | 74 | @@ -987,6 +987,7 @@ struct ieee80211_link_data { |
| 75 | struct cfg80211_chan_def csa_chandef; |
developer | c9eaf90 | 2023-03-13 05:45:10 +0800 | [diff] [blame] | 76 | |
developer | ed15193 | 2023-03-24 02:06:28 +0800 | [diff] [blame] | 77 | struct work_struct color_change_finalize_work; |
developer | c9eaf90 | 2023-03-13 05:45:10 +0800 | [diff] [blame] | 78 | + struct delayed_work color_aging_work; |
developer | ed15193 | 2023-03-24 02:06:28 +0800 | [diff] [blame] | 79 | |
| 80 | /* context reservation -- protected with chanctx_mtx */ |
| 81 | struct ieee80211_chanctx *reserved_chanctx; |
| 82 | @@ -1930,8 +1931,12 @@ void ieee80211_csa_finalize_work(struct work_struct *work); |
developer | c9eaf90 | 2023-03-13 05:45:10 +0800 | [diff] [blame] | 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 | \ |
| 95 | diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c |
developer | 8eb72a3 | 2023-03-30 08:32:07 +0800 | [diff] [blame] | 96 | index b82065c..6a300ab 100644 |
developer | c9eaf90 | 2023-03-13 05:45:10 +0800 | [diff] [blame] | 97 | --- a/net/mac80211/iface.c |
| 98 | +++ b/net/mac80211/iface.c |
developer | 63e4dfd | 2023-03-22 09:11:04 +0800 | [diff] [blame] | 99 | @@ -541,6 +541,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do |
developer | c9eaf90 | 2023-03-13 05:45:10 +0800 | [diff] [blame] | 100 | cancel_work_sync(&sdata->deflink.color_change_finalize_work); |
| 101 | |
| 102 | cancel_delayed_work_sync(&sdata->deflink.dfs_cac_timer_work); |
developer | ed15193 | 2023-03-24 02:06:28 +0800 | [diff] [blame] | 103 | + cancel_delayed_work_sync(&sdata->deflink.color_aging_work); |
developer | c9eaf90 | 2023-03-13 05:45:10 +0800 | [diff] [blame] | 104 | |
| 105 | if (sdata->wdev.cac_started) { |
| 106 | chandef = sdata->vif.bss_conf.chandef; |
developer | 6ca1756 | 2023-03-24 17:07:44 +0800 | [diff] [blame] | 107 | @@ -1470,6 +1471,10 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up) |
developer | 63e4dfd | 2023-03-22 09:11:04 +0800 | [diff] [blame] | 108 | |
developer | ed15193 | 2023-03-24 02:06:28 +0800 | [diff] [blame] | 109 | set_bit(SDATA_STATE_RUNNING, &sdata->state); |
| 110 | |
| 111 | + if (sdata->vif.type == NL80211_IFTYPE_AP) |
| 112 | + ieee80211_queue_delayed_work(&sdata->local->hw, |
| 113 | + &sdata->deflink.color_aging_work, HZ); |
| 114 | + |
| 115 | return 0; |
| 116 | err_del_interface: |
| 117 | drv_remove_interface(local, sdata); |
| 118 | diff --git a/net/mac80211/link.c b/net/mac80211/link.c |
| 119 | index e309708..d34cdc2 100644 |
| 120 | --- a/net/mac80211/link.c |
| 121 | +++ b/net/mac80211/link.c |
| 122 | @@ -43,6 +43,8 @@ void ieee80211_link_init(struct ieee80211_sub_if_data *sdata, |
| 123 | INIT_LIST_HEAD(&link->reserved_chanctx_list); |
| 124 | INIT_DELAYED_WORK(&link->dfs_cac_timer_work, |
| 125 | ieee80211_dfs_cac_timer_work); |
| 126 | + INIT_DELAYED_WORK(&link->color_aging_work, |
developer | 63e4dfd | 2023-03-22 09:11:04 +0800 | [diff] [blame] | 127 | + ieee80211_color_aging_work); |
| 128 | |
developer | ed15193 | 2023-03-24 02:06:28 +0800 | [diff] [blame] | 129 | if (!deflink) { |
| 130 | switch (sdata->vif.type) { |
developer | c9eaf90 | 2023-03-13 05:45:10 +0800 | [diff] [blame] | 131 | diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c |
developer | 8eb72a3 | 2023-03-30 08:32:07 +0800 | [diff] [blame] | 132 | index bc5b471..b96eb7c 100644 |
developer | c9eaf90 | 2023-03-13 05:45:10 +0800 | [diff] [blame] | 133 | --- a/net/mac80211/rx.c |
| 134 | +++ b/net/mac80211/rx.c |
| 135 | @@ -3340,6 +3340,7 @@ ieee80211_rx_check_bss_color_collision(struct ieee80211_rx_data *rx) |
| 136 | IEEE80211_HE_OPERATION_BSS_COLOR_MASK); |
| 137 | |
| 138 | bss_conf->used_color_bitmap |= BIT_ULL(color); |
| 139 | + bss_conf->color_last_seen[color] = jiffies; |
| 140 | |
| 141 | trace_bss_color_bitmap(color, bss_conf->used_color_bitmap); |
| 142 | |
| 143 | -- |
developer | 8eb72a3 | 2023-03-30 08:32:07 +0800 | [diff] [blame] | 144 | 2.18.0 |
developer | c9eaf90 | 2023-03-13 05:45:10 +0800 | [diff] [blame] | 145 | |