blob: 612ed69d977f7aded661b17fa541fa354576eb19 [file] [log] [blame]
developer05f3b2b2024-08-19 19:17:34 +08001From 1519b6ddc0a4256bddcaaeb8fc43db7fd7c6ee8f Mon Sep 17 00:00:00 2001
developer66e89bc2024-04-23 14:50:01 +08002From: "Allen.Ye" <allen.ye@mediatek.com>
3Date: Thu, 9 Nov 2023 11:37:37 +0800
developer05f3b2b2024-08-19 19:17:34 +08004Subject: [PATCH 43/89] mtk: mac80211: Add cert mode to disable ba timeout
developer66e89bc2024-04-23 14:50:01 +08005
6Add a switch of certification mode in debugfs as cert_mode. In the case
7we use it to disable BA timeout from STA to prevent crashing STA.
8
developer66e89bc2024-04-23 14:50:01 +08009Signed-off-by: Allen.Ye <allen.ye@mediatek.com>
10
11Move the variable 'cert_mode' from ieee80211_local to ieee80211_hw
12
developer66e89bc2024-04-23 14:50:01 +080013Signed-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
20diff --git a/include/net/mac80211.h b/include/net/mac80211.h
developer05f3b2b2024-08-19 19:17:34 +080021index 215d499..98678c8 100644
developer66e89bc2024-04-23 14:50:01 +080022--- a/include/net/mac80211.h
23+++ b/include/net/mac80211.h
developer05f3b2b2024-08-19 19:17:34 +080024@@ -3059,8 +3059,14 @@ struct ieee80211_hw {
developer66e89bc2024-04-23 14:50:01 +080025 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 {
39diff --git a/net/mac80211/agg-tx.c b/net/mac80211/agg-tx.c
developer05f3b2b2024-08-19 19:17:34 +080040index 0abc77b..2f351a7 100644
developer66e89bc2024-04-23 14:50:01 +080041--- a/net/mac80211/agg-tx.c
42+++ b/net/mac80211/agg-tx.c
developer05f3b2b2024-08-19 19:17:34 +080043@@ -1092,7 +1092,10 @@ next:
developer66e89bc2024-04-23 14:50:01 +080044 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;
55diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
developer05f3b2b2024-08-19 19:17:34 +080056index ce8eb40..376abfc 100644
developer66e89bc2024-04-23 14:50:01 +080057--- 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),
developer05f3b2b2024-08-19 19:17:34 +0800114@@ -683,6 +731,7 @@ void debugfs_hw_add(struct ieee80211_local *local)
developer66e89bc2024-04-23 14:50:01 +0800115 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--
developer05f3b2b2024-08-19 19:17:34 +08001232.18.0
developer66e89bc2024-04-23 14:50:01 +0800124