blob: 98b1d7b95a70fccc5cb85004c770827ef4fe959a [file] [log] [blame]
developerec4ebe42022-04-12 11:17:45 +08001From c11cb393f5d03ff73809510a1056f7aef1799de9 Mon Sep 17 00:00:00 2001
2From: Shayne Chen <shayne.chen@mediatek.com>
3Date: Mon, 28 Jun 2021 10:46:14 +0800
4Subject: [PATCH 1104/1112] mt76: testmode: add attributes to support off
5 channel scan
6
7Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
8---
9 drivers/net/wireless/mediatek/mt76/mt76.h | 5 +++++
10 drivers/net/wireless/mediatek/mt76/testmode.c | 21 +++++++++++++++++++
11 drivers/net/wireless/mediatek/mt76/testmode.h | 10 +++++++++
12 3 files changed, 36 insertions(+)
13
14diff --git a/mt76.h b/mt76.h
15index 157fd6d..ab9482c 100644
16--- a/mt76.h
17+++ b/mt76.h
18@@ -624,6 +624,11 @@ struct mt76_testmode_data {
19 u8 enable;
20 } cfg;
21
22+ u8 off_ch_scan_ch;
23+ u8 off_ch_scan_center_ch;
24+ u8 off_ch_scan_bw;
25+ u8 off_ch_scan_path;
26+
27 u32 tx_pending;
28 u32 tx_queued;
29 u16 tx_queued_limit;
30diff --git a/testmode.c b/testmode.c
31index f31e124..2376e00 100644
32--- a/testmode.c
33+++ b/testmode.c
34@@ -567,6 +567,27 @@ int mt76_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
35 }
36 }
37
38+ if (tb[MT76_TM_ATTR_OFF_CH_SCAN_CH]) {
39+ u8 ch = nla_get_u8(tb[MT76_TM_ATTR_OFF_CH_SCAN_CH]);
40+ struct ieee80211_supported_band *sband;
41+
42+ sband = ch > 14 ? &phy->sband_5g.sband :
43+ &phy->sband_2g.sband;
44+ if (ch && (ch < sband->channels[0].hw_value ||
45+ ch > sband->channels[sband->n_channels - 1].hw_value))
46+ goto out;
47+
48+ td->off_ch_scan_ch = ch;
49+
50+ if (mt76_tm_get_u8(tb[MT76_TM_ATTR_OFF_CH_SCAN_CENTER_CH],
51+ &td->off_ch_scan_center_ch, ch - 6, ch + 6) ||
52+ mt76_tm_get_u8(tb[MT76_TM_ATTR_OFF_CH_SCAN_BW],
53+ &td->off_ch_scan_bw, 0, 6) ||
54+ mt76_tm_get_u8(tb[MT76_TM_ATTR_OFF_CH_SCAN_PATH],
55+ &td->off_ch_scan_path, 1, 0xff))
56+ goto out;
57+ }
58+
59 if (dev->test_ops->set_params) {
60 err = dev->test_ops->set_params(phy, tb, state);
61 if (err)
62diff --git a/testmode.h b/testmode.h
63index c469ce6..0fc0ddd 100644
64--- a/testmode.h
65+++ b/testmode.h
66@@ -57,6 +57,11 @@
67 *
68 * @MT76_TM_ATTR_CFG: config testmode rf feature (nested, see &mt76_testmode_cfg)
69 *
70+ * @MT76_TM_ATTR_OFF_CH_SCAN_CH: monitored channel for off channel scan (u8)
71+ * @MT76_TM_ATTR_OFF_CH_SCAN_CENTER_CH: monitored channel for off channel scan (u8)
72+ * @MT76_TM_ATTR_OFF_CH_SCAN_BW: monitored bw for off channel scan (u8)
73+ * @MT76_TM_ATTR_OFF_CH_SCAN_PATH: monitored rx path for off channel scan (u8)
74+ *
75 */
76 enum mt76_testmode_attr {
77 MT76_TM_ATTR_UNSPEC,
78@@ -101,6 +106,11 @@ enum mt76_testmode_attr {
79
80 MT76_TM_ATTR_CFG,
81
82+ MT76_TM_ATTR_OFF_CH_SCAN_CH,
83+ MT76_TM_ATTR_OFF_CH_SCAN_CENTER_CH,
84+ MT76_TM_ATTR_OFF_CH_SCAN_BW,
85+ MT76_TM_ATTR_OFF_CH_SCAN_PATH,
86+
87 /* keep last */
88 NUM_MT76_TM_ATTRS,
89 MT76_TM_ATTR_MAX = NUM_MT76_TM_ATTRS - 1,
90--
912.25.1
92