developer | c9eaf90 | 2023-03-13 05:45:10 +0800 | [diff] [blame] | 1 | From 96d0335462d6762924800c7d90e378eebe590385 Mon Sep 17 00:00:00 2001 |
| 2 | From: Yi-Chia Hsieh <yi-chia.hsieh@mediatek.com> |
| 3 | Date: Mon, 13 Mar 2023 05:36:59 +0800 |
| 4 | Subject: [PATCH 2/2] mac80211: mtk: ageout color bitmap |
| 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 + |
| 10 | net/mac80211/cfg.c | 26 ++++++++++++++++++++++++++ |
| 11 | net/mac80211/ieee80211_i.h | 6 ++++++ |
| 12 | net/mac80211/iface.c | 5 +++++ |
| 13 | net/mac80211/rx.c | 1 + |
| 14 | 5 files changed, 39 insertions(+) |
| 15 | |
| 16 | diff --git a/include/net/mac80211.h b/include/net/mac80211.h |
| 17 | index 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; |
| 28 | diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c |
| 29 | index 5c9dda1..4bcb1d4 100644 |
| 30 | --- a/net/mac80211/cfg.c |
| 31 | +++ b/net/mac80211/cfg.c |
| 32 | @@ -4755,6 +4755,32 @@ out: |
| 33 | 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 | + |
| 47 | + for (i = 0; i < IEEE80211_BSS_COLOR_MAX; i++) { |
| 48 | + /* ageout if not seen for a period */ |
| 49 | + if ((bss_conf->used_color_bitmap & BIT_ULL(i)) && |
| 50 | + time_before(bss_conf->color_last_seen[i], |
| 51 | + jiffies - IEEE80211_BSS_COLOR_AGEOUT_TIME * HZ)) { |
| 52 | + bss_conf->used_color_bitmap &= ~BIT_ULL(i); |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | + ieee80211_queue_delayed_work(&sdata->local->hw, |
| 57 | + &sdata->color_aging_work, HZ); |
| 58 | + |
| 59 | + sdata_unlock(sdata); |
| 60 | +} |
| 61 | + |
| 62 | static int |
| 63 | ieee80211_set_radar_background(struct wiphy *wiphy, |
| 64 | struct cfg80211_chan_def *chandef) |
| 65 | diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h |
| 66 | index a10ef29..295f45b 100644 |
| 67 | --- a/net/mac80211/ieee80211_i.h |
| 68 | +++ b/net/mac80211/ieee80211_i.h |
| 69 | @@ -1111,6 +1111,8 @@ struct ieee80211_sub_if_data { |
| 70 | } debugfs; |
| 71 | #endif |
| 72 | |
| 73 | + struct delayed_work color_aging_work; |
| 74 | + |
| 75 | /* must be last, dynamically sized area in this! */ |
| 76 | struct ieee80211_vif vif; |
| 77 | }; |
| 78 | @@ -1930,8 +1932,12 @@ void ieee80211_csa_finalize_work(struct work_struct *work); |
| 79 | int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, |
| 80 | struct cfg80211_csa_settings *params); |
| 81 | |
| 82 | +#define IEEE80211_BSS_COLOR_AGEOUT_TIME 10 |
| 83 | +#define IEEE80211_BSS_COLOR_MAX 64 |
| 84 | + |
| 85 | /* color change handling */ |
| 86 | void ieee80211_color_change_finalize_work(struct work_struct *work); |
| 87 | +void ieee80211_color_aging_work(struct work_struct *work); |
| 88 | |
| 89 | /* interface handling */ |
| 90 | #define MAC80211_SUPPORTED_FEATURES_TX (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | \ |
| 91 | diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c |
| 92 | index b80fb66..6d37adb 100644 |
| 93 | --- a/net/mac80211/iface.c |
| 94 | +++ b/net/mac80211/iface.c |
| 95 | @@ -541,6 +541,8 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do |
| 96 | cancel_work_sync(&sdata->deflink.color_change_finalize_work); |
| 97 | |
| 98 | cancel_delayed_work_sync(&sdata->deflink.dfs_cac_timer_work); |
| 99 | + if (sdata->vif.type == NL80211_IFTYPE_AP) |
| 100 | + cancel_delayed_work_sync(&sdata->color_aging_work); |
| 101 | |
| 102 | if (sdata->wdev.cac_started) { |
| 103 | chandef = sdata->vif.bss_conf.chandef; |
| 104 | @@ -1787,6 +1789,9 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata, |
| 105 | skb_queue_head_init(&sdata->u.ap.ps.bc_buf); |
| 106 | INIT_LIST_HEAD(&sdata->u.ap.vlans); |
| 107 | sdata->vif.bss_conf.bssid = sdata->vif.addr; |
| 108 | + INIT_DELAYED_WORK(&sdata->color_aging_work, ieee80211_color_aging_work); |
| 109 | + ieee80211_queue_delayed_work(&sdata->local->hw, |
| 110 | + &sdata->color_aging_work, 0); |
| 111 | break; |
| 112 | case NL80211_IFTYPE_P2P_CLIENT: |
| 113 | type = NL80211_IFTYPE_STATION; |
| 114 | diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c |
| 115 | index fd2f650..67c768c 100644 |
| 116 | --- a/net/mac80211/rx.c |
| 117 | +++ b/net/mac80211/rx.c |
| 118 | @@ -3340,6 +3340,7 @@ ieee80211_rx_check_bss_color_collision(struct ieee80211_rx_data *rx) |
| 119 | IEEE80211_HE_OPERATION_BSS_COLOR_MASK); |
| 120 | |
| 121 | bss_conf->used_color_bitmap |= BIT_ULL(color); |
| 122 | + bss_conf->color_last_seen[color] = jiffies; |
| 123 | |
| 124 | trace_bss_color_bitmap(color, bss_conf->used_color_bitmap); |
| 125 | |
| 126 | -- |
| 127 | 2.39.0 |
| 128 | |