developer | 43a264f | 2024-03-26 14:09:54 +0800 | [diff] [blame^] | 1 | From bc5e57c30a65a64e74ef4d8c355a4a4c83673c73 Mon Sep 17 00:00:00 2001 |
developer | d243af0 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 2 | From: "Allen.Ye" <allen.ye@mediatek.com> |
| 3 | Date: Thu, 9 Nov 2023 11:37:37 +0800 |
| 4 | Subject: [PATCH 33/37] mtk: mac80211: Add cert mode to disable ba timeout |
| 5 | |
| 6 | Add a switch of certification mode in debugfs as cert_mode. In the case |
| 7 | we use it to disable BA timeout from STA to prevent crashing STA. |
| 8 | |
| 9 | Signed-off-by: Allen.Ye <allen.ye@mediatek.com> |
| 10 | --- |
| 11 | include/net/mac80211.h | 6 ++++++ |
| 12 | net/mac80211/agg-tx.c | 5 ++++- |
| 13 | net/mac80211/debugfs.c | 49 ++++++++++++++++++++++++++++++++++++++++++ |
| 14 | 3 files changed, 59 insertions(+), 1 deletion(-) |
| 15 | |
| 16 | diff --git a/include/net/mac80211.h b/include/net/mac80211.h |
developer | 43a264f | 2024-03-26 14:09:54 +0800 | [diff] [blame^] | 17 | index d641b18..ba8343f 100644 |
developer | d243af0 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 18 | --- a/include/net/mac80211.h |
| 19 | +++ b/include/net/mac80211.h |
developer | 43a264f | 2024-03-26 14:09:54 +0800 | [diff] [blame^] | 20 | @@ -2910,8 +2910,14 @@ struct ieee80211_hw { |
developer | d243af0 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 21 | u32 max_mtu; |
| 22 | const s8 *tx_power_levels; |
| 23 | u8 max_txpwr_levels_idx; |
| 24 | + bool cert_mode; |
| 25 | }; |
| 26 | |
| 27 | +static inline bool ieee80211_is_cert_mode(struct ieee80211_hw *hw) |
| 28 | +{ |
| 29 | + return hw->cert_mode; |
| 30 | +} |
| 31 | + |
| 32 | static inline bool _ieee80211_hw_check(struct ieee80211_hw *hw, |
| 33 | enum ieee80211_hw_flags flg) |
| 34 | { |
| 35 | diff --git a/net/mac80211/agg-tx.c b/net/mac80211/agg-tx.c |
| 36 | index 285433a..a2f1e14 100644 |
| 37 | --- a/net/mac80211/agg-tx.c |
| 38 | +++ b/net/mac80211/agg-tx.c |
| 39 | @@ -1108,7 +1108,10 @@ next: |
| 40 | tid_tx->timeout = |
| 41 | le16_to_cpu(mgmt->u.action.u.addba_resp.timeout); |
| 42 | |
| 43 | - if (tid_tx->timeout) { |
| 44 | + /* In the case of certification env, testbed STA cannot accept frequent DelBA. |
| 45 | + * Therefore, we remove the session timer check here to avoid crashing testbed STA. |
| 46 | + */ |
| 47 | + if (tid_tx->timeout && !ieee80211_is_cert_mode(&local->hw)) { |
| 48 | mod_timer(&tid_tx->session_timer, |
| 49 | TU_TO_EXP_TIME(tid_tx->timeout)); |
| 50 | tid_tx->last_tx = jiffies; |
| 51 | diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c |
developer | 43a264f | 2024-03-26 14:09:54 +0800 | [diff] [blame^] | 52 | index 006b46d..8c29786 100644 |
developer | d243af0 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 53 | --- a/net/mac80211/debugfs.c |
| 54 | +++ b/net/mac80211/debugfs.c |
developer | 43a264f | 2024-03-26 14:09:54 +0800 | [diff] [blame^] | 55 | @@ -449,6 +449,54 @@ static const struct file_operations reset_ops = { |
developer | d243af0 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 56 | }; |
| 57 | #endif |
| 58 | |
| 59 | +static ssize_t cert_mode_read(struct file *file, |
| 60 | + char __user *user_buf, |
| 61 | + size_t count, |
| 62 | + loff_t *ppos) |
| 63 | +{ |
| 64 | + struct ieee80211_local *local = file->private_data; |
| 65 | + char buf[32]; |
| 66 | + int len = 0; |
| 67 | + |
| 68 | + len = scnprintf(buf, sizeof(buf), "cert_mode: %d\n", |
| 69 | + local->hw.cert_mode); |
| 70 | + |
| 71 | + return simple_read_from_buffer(user_buf, count, ppos, |
| 72 | + buf, len); |
| 73 | +} |
| 74 | + |
| 75 | +static ssize_t cert_mode_write(struct file *file, |
| 76 | + const char __user *user_buf, |
| 77 | + size_t count, |
| 78 | + loff_t *ppos) |
| 79 | +{ |
| 80 | + struct ieee80211_local *local = file->private_data; |
| 81 | + char buf[16]; |
| 82 | + |
| 83 | + if (count >= sizeof(buf)) |
| 84 | + return -EINVAL; |
| 85 | + |
| 86 | + if (copy_from_user(buf, user_buf, count)) |
| 87 | + return -EFAULT; |
| 88 | + |
| 89 | + if (count && buf[count - 1] == '\n') |
| 90 | + buf[count - 1] = '\0'; |
| 91 | + else |
| 92 | + buf[count] = '\0'; |
| 93 | + |
| 94 | + if (kstrtobool(buf, &local->hw.cert_mode)) |
| 95 | + return -EINVAL; |
| 96 | + |
| 97 | + return count; |
| 98 | +} |
| 99 | + |
| 100 | +static const struct file_operations cert_mode_ops = { |
| 101 | + .write = cert_mode_write, |
| 102 | + .read = cert_mode_read, |
| 103 | + .open = simple_open, |
| 104 | + .llseek = noop_llseek, |
| 105 | +}; |
| 106 | + |
| 107 | static const char *hw_flag_names[] = { |
| 108 | #define FLAG(F) [IEEE80211_HW_##F] = #F |
| 109 | FLAG(HAS_RATE_CONTROL), |
developer | 43a264f | 2024-03-26 14:09:54 +0800 | [diff] [blame^] | 110 | @@ -680,6 +728,7 @@ void debugfs_hw_add(struct ieee80211_local *local) |
developer | d243af0 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 111 | debugfs_create_u32("aql_threshold", 0600, |
| 112 | phyd, &local->aql_threshold); |
| 113 | |
| 114 | + DEBUGFS_ADD_MODE(cert_mode, 0644); |
| 115 | statsd = debugfs_create_dir("statistics", phyd); |
| 116 | |
| 117 | #ifdef CPTCFG_MAC80211_DEBUG_COUNTERS |
| 118 | -- |
| 119 | 2.18.0 |
| 120 | |