developer | 1d9da7d | 2023-04-15 12:45:34 +0800 | [diff] [blame] | 1 | From 61d499cf2de7201642cd7175b5c067b1e17309c2 Mon Sep 17 00:00:00 2001 |
developer | 983d949 | 2023-02-17 07:31:03 +0800 | [diff] [blame] | 2 | From: Yi-Chia Hsieh <yi-chia.hsieh@mediatek.com> |
developer | 14bd31c | 2023-03-08 06:38:53 +0800 | [diff] [blame] | 3 | Date: Wed, 8 Mar 2023 06:32:42 +0800 |
developer | ed7222c | 2023-04-14 07:19:52 +0800 | [diff] [blame] | 4 | Subject: [PATCH 16/17] mac80211: mtk: ageout color bitmap |
developer | 983d949 | 2023-02-17 07:31:03 +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 | --- |
developer | 14bd31c | 2023-03-08 06:38:53 +0800 | [diff] [blame] | 9 | include/net/mac80211.h | 1 + |
developer | 63e4dfd | 2023-03-22 09:11:04 +0800 | [diff] [blame] | 10 | net/mac80211/cfg.c | 29 +++++++++++++++++++++++++++++ |
developer | 14bd31c | 2023-03-08 06:38:53 +0800 | [diff] [blame] | 11 | net/mac80211/ieee80211_i.h | 5 +++++ |
developer | ed15193 | 2023-03-24 02:06:28 +0800 | [diff] [blame] | 12 | net/mac80211/iface.c | 7 +++++++ |
developer | 983d949 | 2023-02-17 07:31:03 +0800 | [diff] [blame] | 13 | net/mac80211/rx.c | 1 + |
developer | ed15193 | 2023-03-24 02:06:28 +0800 | [diff] [blame] | 14 | 5 files changed, 43 insertions(+) |
developer | 983d949 | 2023-02-17 07:31:03 +0800 | [diff] [blame] | 15 | |
developer | 14bd31c | 2023-03-08 06:38:53 +0800 | [diff] [blame] | 16 | diff --git a/include/net/mac80211.h b/include/net/mac80211.h |
developer | ed7222c | 2023-04-14 07:19:52 +0800 | [diff] [blame] | 17 | index 1a26ccd..28ec7e8 100644 |
developer | 14bd31c | 2023-03-08 06:38:53 +0800 | [diff] [blame] | 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; |
developer | 983d949 | 2023-02-17 07:31:03 +0800 | [diff] [blame] | 23 | u64 used_color_bitmap; |
| 24 | + u64 color_last_seen[64]; |
developer | 14bd31c | 2023-03-08 06:38:53 +0800 | [diff] [blame] | 25 | struct ieee80211_fils_discovery fils_discovery; |
| 26 | u32 unsol_bcast_probe_resp_interval; |
| 27 | bool s1g; |
developer | 983d949 | 2023-02-17 07:31:03 +0800 | [diff] [blame] | 28 | diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c |
developer | 63e4dfd | 2023-03-22 09:11:04 +0800 | [diff] [blame] | 29 | index 86d231b..7449777 100644 |
developer | 983d949 | 2023-02-17 07:31:03 +0800 | [diff] [blame] | 30 | --- a/net/mac80211/cfg.c |
| 31 | +++ b/net/mac80211/cfg.c |
developer | 63e4dfd | 2023-03-22 09:11:04 +0800 | [diff] [blame] | 32 | @@ -4425,6 +4425,35 @@ unlock: |
developer | 983d949 | 2023-02-17 07:31:03 +0800 | [diff] [blame] | 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); |
developer | 14bd31c | 2023-03-08 06:38:53 +0800 | [diff] [blame] | 41 | + struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; |
developer | 983d949 | 2023-02-17 07:31:03 +0800 | [diff] [blame] | 42 | + int i = 0; |
| 43 | + |
| 44 | + sdata_lock(sdata); |
| 45 | + |
developer | 63e4dfd | 2023-03-22 09:11:04 +0800 | [diff] [blame] | 46 | + if (!ieee80211_sdata_running(sdata)) |
| 47 | + goto unlock; |
| 48 | + |
developer | 983d949 | 2023-02-17 07:31:03 +0800 | [diff] [blame] | 49 | + for (i = 0; i < IEEE80211_BSS_COLOR_MAX; i++) { |
| 50 | + /* ageout if not seen for a period */ |
developer | 14bd31c | 2023-03-08 06:38:53 +0800 | [diff] [blame] | 51 | + if ((bss_conf->used_color_bitmap & BIT_ULL(i)) && |
| 52 | + time_before(bss_conf->color_last_seen[i], |
developer | 983d949 | 2023-02-17 07:31:03 +0800 | [diff] [blame] | 53 | + jiffies - IEEE80211_BSS_COLOR_AGEOUT_TIME * HZ)) { |
developer | 14bd31c | 2023-03-08 06:38:53 +0800 | [diff] [blame] | 54 | + bss_conf->used_color_bitmap &= ~BIT_ULL(i); |
developer | 983d949 | 2023-02-17 07:31:03 +0800 | [diff] [blame] | 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + ieee80211_queue_delayed_work(&sdata->local->hw, |
| 59 | + &sdata->color_aging_work, HZ); |
| 60 | + |
developer | 63e4dfd | 2023-03-22 09:11:04 +0800 | [diff] [blame] | 61 | +unlock: |
developer | 983d949 | 2023-02-17 07:31:03 +0800 | [diff] [blame] | 62 | + sdata_unlock(sdata); |
| 63 | +} |
| 64 | + |
| 65 | void ieee80211_color_change_finish(struct ieee80211_vif *vif) |
| 66 | { |
| 67 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); |
| 68 | diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h |
developer | 14bd31c | 2023-03-08 06:38:53 +0800 | [diff] [blame] | 69 | index 6edabd8..2519c14 100644 |
developer | 983d949 | 2023-02-17 07:31:03 +0800 | [diff] [blame] | 70 | --- a/net/mac80211/ieee80211_i.h |
| 71 | +++ b/net/mac80211/ieee80211_i.h |
| 72 | @@ -1033,6 +1033,8 @@ struct ieee80211_sub_if_data { |
| 73 | } debugfs; |
| 74 | #endif |
| 75 | |
| 76 | + struct delayed_work color_aging_work; |
| 77 | + |
| 78 | /* must be last, dynamically sized area in this! */ |
| 79 | struct ieee80211_vif vif; |
| 80 | }; |
| 81 | @@ -1811,8 +1813,11 @@ void ieee80211_csa_finalize_work(struct work_struct *work); |
| 82 | int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, |
| 83 | struct cfg80211_csa_settings *params); |
| 84 | |
| 85 | +#define IEEE80211_BSS_COLOR_AGEOUT_TIME 10 |
| 86 | +#define IEEE80211_BSS_COLOR_MAX 64 |
| 87 | /* color change handling */ |
| 88 | void ieee80211_color_change_finalize_work(struct work_struct *work); |
| 89 | +void ieee80211_color_aging_work(struct work_struct *work); |
| 90 | |
| 91 | /* interface handling */ |
| 92 | #define MAC80211_SUPPORTED_FEATURES_TX (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | \ |
| 93 | diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c |
developer | ed15193 | 2023-03-24 02:06:28 +0800 | [diff] [blame] | 94 | index d314f39..00b0443 100644 |
developer | 983d949 | 2023-02-17 07:31:03 +0800 | [diff] [blame] | 95 | --- a/net/mac80211/iface.c |
| 96 | +++ b/net/mac80211/iface.c |
developer | 63e4dfd | 2023-03-22 09:11:04 +0800 | [diff] [blame] | 97 | @@ -466,6 +466,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do |
developer | 983d949 | 2023-02-17 07:31:03 +0800 | [diff] [blame] | 98 | cancel_work_sync(&sdata->color_change_finalize_work); |
| 99 | |
| 100 | cancel_delayed_work_sync(&sdata->dfs_cac_timer_work); |
developer | 63e4dfd | 2023-03-22 09:11:04 +0800 | [diff] [blame] | 101 | + cancel_delayed_work_sync(&sdata->color_aging_work); |
developer | 983d949 | 2023-02-17 07:31:03 +0800 | [diff] [blame] | 102 | |
| 103 | if (sdata->wdev.cac_started) { |
| 104 | chandef = sdata->vif.bss_conf.chandef; |
developer | ed15193 | 2023-03-24 02:06:28 +0800 | [diff] [blame] | 105 | @@ -1391,6 +1392,10 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up) |
| 106 | set_bit(SDATA_STATE_RUNNING, &sdata->state); |
| 107 | |
| 108 | switch (sdata->vif.type) { |
| 109 | + case NL80211_IFTYPE_AP: |
developer | 983d949 | 2023-02-17 07:31:03 +0800 | [diff] [blame] | 110 | + ieee80211_queue_delayed_work(&sdata->local->hw, |
developer | ed15193 | 2023-03-24 02:06:28 +0800 | [diff] [blame] | 111 | + &sdata->color_aging_work, HZ); |
| 112 | + break; |
| 113 | case NL80211_IFTYPE_P2P_DEVICE: |
| 114 | rcu_assign_pointer(local->p2p_sdata, sdata); |
developer | 983d949 | 2023-02-17 07:31:03 +0800 | [diff] [blame] | 115 | break; |
developer | ed15193 | 2023-03-24 02:06:28 +0800 | [diff] [blame] | 116 | @@ -2166,6 +2171,8 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name, |
developer | 63e4dfd | 2023-03-22 09:11:04 +0800 | [diff] [blame] | 117 | ieee80211_dfs_cac_timer_work); |
| 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; |
developer | 983d949 | 2023-02-17 07:31:03 +0800 | [diff] [blame] | 125 | diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c |
developer | 63e4dfd | 2023-03-22 09:11:04 +0800 | [diff] [blame] | 126 | index 36fcf97..838085f 100644 |
developer | 983d949 | 2023-02-17 07:31:03 +0800 | [diff] [blame] | 127 | --- a/net/mac80211/rx.c |
| 128 | +++ b/net/mac80211/rx.c |
| 129 | @@ -3221,6 +3221,7 @@ ieee80211_rx_check_bss_color_collision(struct ieee80211_rx_data *rx) |
| 130 | IEEE80211_HE_OPERATION_BSS_COLOR_MASK); |
| 131 | |
developer | 14bd31c | 2023-03-08 06:38:53 +0800 | [diff] [blame] | 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); |
developer | 983d949 | 2023-02-17 07:31:03 +0800 | [diff] [blame] | 136 | |
developer | 983d949 | 2023-02-17 07:31:03 +0800 | [diff] [blame] | 137 | -- |
developer | ed7222c | 2023-04-14 07:19:52 +0800 | [diff] [blame] | 138 | 2.18.0 |
developer | 983d949 | 2023-02-17 07:31:03 +0800 | [diff] [blame] | 139 | |