developer | 983d949 | 2023-02-17 07:31:03 +0800 | [diff] [blame^] | 1 | From f6cd955e1c042a00691fa80d231495024cfcf7a5 Mon Sep 17 00:00:00 2001 |
| 2 | From: Yi-Chia Hsieh <yi-chia.hsieh@mediatek.com> |
| 3 | Date: Tue, 15 Nov 2022 11:03:22 +0800 |
| 4 | Subject: [PATCH] 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/cfg80211.h | 1 + |
| 10 | net/mac80211/cfg.c | 25 +++++++++++++++++++++++++ |
| 11 | net/mac80211/ieee80211_i.h | 4 ++++ |
| 12 | net/mac80211/iface.c | 5 +++++ |
| 13 | net/mac80211/rx.c | 1 + |
| 14 | 5 files changed, 36 insertions(+) |
| 15 | |
| 16 | diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h |
| 17 | index e5175c2..3e826f0 100644 |
| 18 | --- a/include/net/cfg80211.h |
| 19 | +++ b/include/net/cfg80211.h |
| 20 | @@ -308,6 +308,7 @@ struct cfg80211_he_bss_color { |
| 21 | bool enabled; |
| 22 | bool partial; |
| 23 | u64 used_color_bitmap; |
| 24 | + u64 color_last_seen[64]; |
| 25 | }; |
| 26 | |
| 27 | /** |
| 28 | diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c |
| 29 | index a7b6284..f084912 100644 |
| 30 | --- 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); |
| 41 | + struct cfg80211_he_bss_color *he_bss_color = &sdata->vif.bss_conf.he_bss_color; |
| 42 | + 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 */ |
| 48 | + if ((he_bss_color->used_color_bitmap & BIT_ULL(i)) && |
| 49 | + time_before(he_bss_color->color_last_seen[i], |
| 50 | + jiffies - IEEE80211_BSS_COLOR_AGEOUT_TIME * HZ)) { |
| 51 | + he_bss_color->used_color_bitmap &= ~BIT_ULL(i); |
| 52 | + } |
| 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); |
| 64 | diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h |
| 65 | index 6edabd8..415f202 100644 |
| 66 | --- 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 | \ |
| 89 | diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c |
| 90 | index 43f6cb0..7f26828 100644 |
| 91 | --- 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; |
| 102 | @@ -1804,6 +1806,9 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata, |
| 103 | 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; |
| 112 | diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c |
| 113 | index 789a41b..4a6491c 100644 |
| 114 | --- 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 | |
| 119 | bss_conf->he_bss_color.used_color_bitmap |= BIT_ULL(color); |
| 120 | + bss_conf->he_bss_color.color_last_seen[color] = jiffies; |
| 121 | |
| 122 | trace_bss_color_bitmap(color, |
| 123 | bss_conf->he_bss_color.used_color_bitmap); |
| 124 | -- |
| 125 | 2.39.0 |
| 126 | |