| From 1519b6ddc0a4256bddcaaeb8fc43db7fd7c6ee8f 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 43/89] 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> |
| |
| Move the variable 'cert_mode' from ieee80211_local to ieee80211_hw |
| |
| Signed-off-by: Michael-CY Lee <michael-cy.lee@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 215d499..98678c8 100644 |
| --- a/include/net/mac80211.h |
| +++ b/include/net/mac80211.h |
| @@ -3059,8 +3059,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 0abc77b..2f351a7 100644 |
| --- a/net/mac80211/agg-tx.c |
| +++ b/net/mac80211/agg-tx.c |
| @@ -1092,7 +1092,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 ce8eb40..376abfc 100644 |
| --- a/net/mac80211/debugfs.c |
| +++ b/net/mac80211/debugfs.c |
| @@ -450,6 +450,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), |
| @@ -683,6 +731,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 |
| |