| From bc5e57c30a65a64e74ef4d8c355a4a4c83673c73 Mon Sep 17 00:00:00 2001 |
| From: "Allen.Ye" <allen.ye@mediatek.com> |
| Date: Thu, 9 Nov 2023 11:37:37 +0800 |
| Subject: [PATCH 33/37] mtk: mac80211: Add cert mode to disable ba timeout |
| |
| Add a switch of certification mode in debugfs as cert_mode. In the case |
| we use it to disable BA timeout from STA to prevent crashing STA. |
| |
| Signed-off-by: Allen.Ye <allen.ye@mediatek.com> |
| --- |
| include/net/mac80211.h | 6 ++++++ |
| net/mac80211/agg-tx.c | 5 ++++- |
| net/mac80211/debugfs.c | 49 ++++++++++++++++++++++++++++++++++++++++++ |
| 3 files changed, 59 insertions(+), 1 deletion(-) |
| |
| diff --git a/include/net/mac80211.h b/include/net/mac80211.h |
| index d641b18..ba8343f 100644 |
| --- a/include/net/mac80211.h |
| +++ b/include/net/mac80211.h |
| @@ -2910,8 +2910,14 @@ struct ieee80211_hw { |
| u32 max_mtu; |
| const s8 *tx_power_levels; |
| u8 max_txpwr_levels_idx; |
| + bool cert_mode; |
| }; |
| |
| +static inline bool ieee80211_is_cert_mode(struct ieee80211_hw *hw) |
| +{ |
| + return hw->cert_mode; |
| +} |
| + |
| static inline bool _ieee80211_hw_check(struct ieee80211_hw *hw, |
| enum ieee80211_hw_flags flg) |
| { |
| diff --git a/net/mac80211/agg-tx.c b/net/mac80211/agg-tx.c |
| index 285433a..a2f1e14 100644 |
| --- a/net/mac80211/agg-tx.c |
| +++ b/net/mac80211/agg-tx.c |
| @@ -1108,7 +1108,10 @@ next: |
| tid_tx->timeout = |
| le16_to_cpu(mgmt->u.action.u.addba_resp.timeout); |
| |
| - if (tid_tx->timeout) { |
| + /* In the case of certification env, testbed STA cannot accept frequent DelBA. |
| + * Therefore, we remove the session timer check here to avoid crashing testbed STA. |
| + */ |
| + if (tid_tx->timeout && !ieee80211_is_cert_mode(&local->hw)) { |
| mod_timer(&tid_tx->session_timer, |
| TU_TO_EXP_TIME(tid_tx->timeout)); |
| tid_tx->last_tx = jiffies; |
| diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c |
| index 006b46d..8c29786 100644 |
| --- a/net/mac80211/debugfs.c |
| +++ b/net/mac80211/debugfs.c |
| @@ -449,6 +449,54 @@ static const struct file_operations reset_ops = { |
| }; |
| #endif |
| |
| +static ssize_t cert_mode_read(struct file *file, |
| + char __user *user_buf, |
| + size_t count, |
| + loff_t *ppos) |
| +{ |
| + struct ieee80211_local *local = file->private_data; |
| + char buf[32]; |
| + int len = 0; |
| + |
| + len = scnprintf(buf, sizeof(buf), "cert_mode: %d\n", |
| + local->hw.cert_mode); |
| + |
| + return simple_read_from_buffer(user_buf, count, ppos, |
| + buf, len); |
| +} |
| + |
| +static ssize_t cert_mode_write(struct file *file, |
| + const char __user *user_buf, |
| + size_t count, |
| + loff_t *ppos) |
| +{ |
| + struct ieee80211_local *local = file->private_data; |
| + char buf[16]; |
| + |
| + if (count >= sizeof(buf)) |
| + return -EINVAL; |
| + |
| + if (copy_from_user(buf, user_buf, count)) |
| + return -EFAULT; |
| + |
| + if (count && buf[count - 1] == '\n') |
| + buf[count - 1] = '\0'; |
| + else |
| + buf[count] = '\0'; |
| + |
| + if (kstrtobool(buf, &local->hw.cert_mode)) |
| + return -EINVAL; |
| + |
| + return count; |
| +} |
| + |
| +static const struct file_operations cert_mode_ops = { |
| + .write = cert_mode_write, |
| + .read = cert_mode_read, |
| + .open = simple_open, |
| + .llseek = noop_llseek, |
| +}; |
| + |
| static const char *hw_flag_names[] = { |
| #define FLAG(F) [IEEE80211_HW_##F] = #F |
| FLAG(HAS_RATE_CONTROL), |
| @@ -680,6 +728,7 @@ void debugfs_hw_add(struct ieee80211_local *local) |
| debugfs_create_u32("aql_threshold", 0600, |
| phyd, &local->aql_threshold); |
| |
| + DEBUGFS_ADD_MODE(cert_mode, 0644); |
| statsd = debugfs_create_dir("statistics", phyd); |
| |
| #ifdef CPTCFG_MAC80211_DEBUG_COUNTERS |
| -- |
| 2.18.0 |
| |