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