blob: b476e79c75243a526b387b639c1335ef6c48e7f3 [file] [log] [blame]
developer0443cd32023-09-19 14:11:49 +08001From bc3169129e2978e3ec2e1a630023a30e78d18237 Mon Sep 17 00:00:00 2001
developerf9843e22022-09-13 10:57:15 +08002From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
3Date: Mon, 12 Sep 2022 18:16:54 +0800
developer0443cd32023-09-19 14:11:49 +08004Subject: [PATCH 1011/1040] wifi: mt76: testmode: add iBF command mode support
developerf9843e22022-09-13 10:57:15 +08005
6Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
developerf9843e22022-09-13 10:57:15 +08007---
8 mt7915/testmode.c | 21 ++++++++++++++-------
9 testmode.c | 41 +++++++++++++++++++++++++++++++++++++++++
10 testmode.h | 2 ++
11 tools/fields.c | 28 ++++++++++++++++++++++++++++
12 4 files changed, 85 insertions(+), 7 deletions(-)
13
14diff --git a/mt7915/testmode.c b/mt7915/testmode.c
developer0443cd32023-09-19 14:11:49 +080015index 5ff183a..86deae6 100644
developerf9843e22022-09-13 10:57:15 +080016--- a/mt7915/testmode.c
17+++ b/mt7915/testmode.c
developer24c44312023-06-07 17:40:12 +080018@@ -720,6 +720,7 @@ mt7915_tm_txbf_profile_update(struct mt7915_phy *phy, u16 *val, bool ebf)
developerf9843e22022-09-13 10:57:15 +080019 struct ieee80211_vif *vif = phy->monitor_vif;
20 struct mt7915_tm_pfmu_tag *tag = phy->dev->test.txbf_pfmu_tag;
21 u8 pfmu_idx = val[0], nc = val[2], nr;
22+ bool is_atenl = val[6];
23 int ret;
24
25 if (td->tx_antenna_mask == 3)
developer24c44312023-06-07 17:40:12 +080026@@ -767,7 +768,7 @@ mt7915_tm_txbf_profile_update(struct mt7915_phy *phy, u16 *val, bool ebf)
developerf9843e22022-09-13 10:57:15 +080027 if (ret)
28 return ret;
29
30- if (!ebf)
31+ if (!ebf && is_atenl)
32 return mt7915_tm_txbf_apply_tx(phy, 1, false, true, true);
33
34 return 0;
developer24c44312023-06-07 17:40:12 +080035@@ -794,7 +795,7 @@ mt7915_tm_txbf_phase_cal(struct mt7915_phy *phy, u16 *val)
developerf9843e22022-09-13 10:57:15 +080036 .group_l_m_n = val[1],
37 .sx2 = val[2],
38 .cal_type = val[3],
39- .lna_gain_level = 0, /* for test purpose */
40+ .lna_gain_level = val[4],
41 };
42 struct mt7915_tm_txbf_phase *phase =
43 (struct mt7915_tm_txbf_phase *)dev->test.txbf_phase_cal;
developer24c44312023-06-07 17:40:12 +080044@@ -833,6 +834,8 @@ int mt7915_tm_txbf_status_read(struct mt7915_dev *dev, struct sk_buff *skb)
developerf9843e22022-09-13 10:57:15 +080045 phase = &phase[cal->group];
46 memcpy(&phase->phase, cal->buf + 16, sizeof(phase->phase));
47 phase->status = cal->status;
48+ /* for passing iTest script */
49+ dev_info(dev->mt76.dev, "Calibrated result = %d\n", phase->status);
50 break;
51 case IBF_PHASE_CAL_VERIFY:
52 case IBF_PHASE_CAL_VERIFY_INSTRUMENT:
developer0443cd32023-09-19 14:11:49 +080053@@ -885,7 +888,6 @@ mt7915_tm_txbf_profile_update_all(struct mt7915_phy *phy, u16 *val)
developerf9843e22022-09-13 10:57:15 +080054 pfmu_data->phi11 = cpu_to_le16(phi11);
55 pfmu_data->phi21 = cpu_to_le16(phi21);
56 pfmu_data->phi31 = cpu_to_le16(phi31);
57-
58 if (subc_id == 63) {
59 struct mt7915_dev *dev = phy->dev;
60 struct {
developer0443cd32023-09-19 14:11:49 +080061@@ -943,8 +945,8 @@ mt7915_tm_set_txbf(struct mt7915_phy *phy)
developerf9843e22022-09-13 10:57:15 +080062 struct mt76_testmode_data *td = &phy->mt76->test;
63 u16 *val = td->txbf_param;
64
65- pr_info("ibf cal process: act = %u, val = %u, %u, %u, %u, %u\n",
66- td->txbf_act, val[0], val[1], val[2], val[3], val[4]);
67+ pr_info("ibf cal process: act = %u, val = %u, %u, %u, %u, %u, %u\n",
68+ td->txbf_act, val[0], val[1], val[2], val[3], val[4], val[5]);
69
70 switch (td->txbf_act) {
71 case MT76_TM_TXBF_ACT_INIT:
developer0443cd32023-09-19 14:11:49 +080072@@ -962,10 +964,17 @@ mt7915_tm_set_txbf(struct mt7915_phy *phy)
developerf9843e22022-09-13 10:57:15 +080073 return mt7915_tm_txbf_profile_update(phy, val, true);
74 case MT76_TM_TXBF_ACT_PHASE_CAL:
75 return mt7915_tm_txbf_phase_cal(phy, val);
76+ case MT76_TM_TXBF_ACT_PROF_UPDATE_ALL_CMD:
77 case MT76_TM_TXBF_ACT_PROF_UPDATE_ALL:
78 return mt7915_tm_txbf_profile_update_all(phy, val);
79 case MT76_TM_TXBF_ACT_E2P_UPDATE:
80 return mt7915_tm_txbf_e2p_update(phy);
81+ case MT76_TM_TXBF_ACT_APPLY_TX: {
82+ u16 wlan_idx = val[0];
83+ bool ebf = !!val[1], ibf = !!val[2], phase_cal = !!val[4];
84+
85+ return mt7915_tm_txbf_apply_tx(phy, wlan_idx, ebf, ibf, phase_cal);
86+ }
87 default:
88 break;
89 };
developer0443cd32023-09-19 14:11:49 +080090@@ -1092,7 +1101,6 @@ mt7915_tm_set_tx_len(struct mt7915_phy *phy, u32 tx_time)
developerf9843e22022-09-13 10:57:15 +080091 rate.legacy = sband->bitrates[rate.mcs].bitrate;
92 break;
93 case MT76_TM_TX_MODE_HT:
94- rate.mcs += rate.nss * 8;
95 flags |= RATE_INFO_FLAGS_MCS;
96
97 if (td->tx_rate_sgi)
developer0443cd32023-09-19 14:11:49 +080098@@ -1457,7 +1465,6 @@ mt7915_tm_set_tx_frames(struct mt7915_phy *phy, bool en)
developerf9843e22022-09-13 10:57:15 +080099 if (duty_cycle < 100)
100 tx_time = duty_cycle * ipg / (100 - duty_cycle);
101 }
102-
103 mt7915_tm_set_ipg_params(phy, ipg, td->tx_rate_mode);
104 mt7915_tm_set_tx_len(phy, tx_time);
105
106diff --git a/testmode.c b/testmode.c
developer0443cd32023-09-19 14:11:49 +0800107index b1b643c..f415bec 100644
developerf9843e22022-09-13 10:57:15 +0800108--- a/testmode.c
109+++ b/testmode.c
developer849549c2023-08-02 17:26:48 +0800110@@ -534,6 +534,42 @@ out:
developerf9843e22022-09-13 10:57:15 +0800111 return err;
112 }
113
114+static int
115+mt76_testmode_txbf_profile_update_all_cmd(struct mt76_phy *phy, struct nlattr **tb, u32 state)
116+{
117+#define PARAM_UNIT 5
118+ static u8 pfmu_idx;
119+ struct mt76_testmode_data *td = &phy->test;
120+ struct mt76_dev *dev = phy->dev;
121+ struct nlattr *cur;
122+ u16 tmp_val[PARAM_UNIT], *val = td->txbf_param;
123+ int idx, rem, ret, i = 0;
124+
125+ memset(td->txbf_param, 0, sizeof(td->txbf_param));
126+ nla_for_each_nested(cur, tb[MT76_TM_ATTR_TXBF_PARAM], rem) {
127+ if (nla_len(cur) != 2)
128+ return -EINVAL;
129+ idx = i % PARAM_UNIT;
130+ tmp_val[idx] = nla_get_u16(cur);
131+ if (idx == 1 && (tmp_val[idx] == 0xf0 || tmp_val[idx] == 0xff)) {
132+ pfmu_idx = tmp_val[0];
133+ return 0;
134+ }
135+ if (idx == PARAM_UNIT - 1) {
136+ val[0] = pfmu_idx;
137+ memcpy(val + 1, tmp_val, sizeof(tmp_val));
138+ if (dev->test_ops->set_params) {
139+ ret = dev->test_ops->set_params(phy, tb, state);
140+ if (ret)
141+ return ret;
142+ }
143+ }
144+ i++;
145+ }
146+
147+ return 0;
148+}
149+
150 int mt76_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
151 void *data, int len)
152 {
developer849549c2023-08-02 17:26:48 +0800153@@ -672,6 +708,11 @@ int mt76_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
developer24c44312023-06-07 17:40:12 +0800154 0, MT76_TM_TXBF_ACT_MAX))
developerf9843e22022-09-13 10:57:15 +0800155 goto out;
156
157+ if (td->txbf_act == MT76_TM_TXBF_ACT_PROF_UPDATE_ALL_CMD) {
158+ err = mt76_testmode_txbf_profile_update_all_cmd(phy, tb, state);
159+ goto out;
160+ }
161+
162 memset(td->txbf_param, 0, sizeof(td->txbf_param));
163 nla_for_each_nested(cur, tb[MT76_TM_ATTR_TXBF_PARAM], rem) {
164 if (nla_len(cur) != 2 ||
165diff --git a/testmode.h b/testmode.h
developer0443cd32023-09-19 14:11:49 +0800166index 109a556..d2675dd 100644
developerf9843e22022-09-13 10:57:15 +0800167--- a/testmode.h
168+++ b/testmode.h
169@@ -281,8 +281,10 @@ enum mt76_testmode_txbf_act {
170 MT76_TM_TXBF_ACT_TX_PREP,
171 MT76_TM_TXBF_ACT_IBF_PROF_UPDATE,
172 MT76_TM_TXBF_ACT_EBF_PROF_UPDATE,
173+ MT76_TM_TXBF_ACT_APPLY_TX,
174 MT76_TM_TXBF_ACT_PHASE_CAL,
175 MT76_TM_TXBF_ACT_PROF_UPDATE_ALL,
176+ MT76_TM_TXBF_ACT_PROF_UPDATE_ALL_CMD,
177 MT76_TM_TXBF_ACT_E2P_UPDATE,
178
179 /* keep last */
180diff --git a/tools/fields.c b/tools/fields.c
developer0443cd32023-09-19 14:11:49 +0800181index 3ca5cd1..6bf4c04 100644
developerf9843e22022-09-13 10:57:15 +0800182--- a/tools/fields.c
183+++ b/tools/fields.c
184@@ -32,6 +32,20 @@ static const char * const testmode_tx_mode[] = {
185 [MT76_TM_TX_MODE_HE_MU] = "he_mu",
186 };
187
188+static const char * const testmode_txbf_act[] = {
189+ [MT76_TM_TXBF_ACT_INIT] = "init",
190+ [MT76_TM_TXBF_ACT_UPDATE_CH] = "update_ch",
191+ [MT76_TM_TXBF_ACT_PHASE_COMP] = "phase_comp",
192+ [MT76_TM_TXBF_ACT_TX_PREP] = "tx_prep",
193+ [MT76_TM_TXBF_ACT_IBF_PROF_UPDATE] = "ibf_prof_update",
194+ [MT76_TM_TXBF_ACT_EBF_PROF_UPDATE] = "ebf_prof_update",
195+ [MT76_TM_TXBF_ACT_APPLY_TX] = "apply_tx",
196+ [MT76_TM_TXBF_ACT_PHASE_CAL] = "phase_cal",
197+ [MT76_TM_TXBF_ACT_PROF_UPDATE_ALL] = "prof_update",
198+ [MT76_TM_TXBF_ACT_PROF_UPDATE_ALL_CMD] = "prof_update_all",
199+ [MT76_TM_TXBF_ACT_E2P_UPDATE] = "e2p_update",
200+};
201+
202 static void print_enum(const struct tm_field *field, struct nlattr *attr)
203 {
204 unsigned int i = nla_get_u8(attr);
205@@ -82,6 +96,17 @@ static void print_s8(const struct tm_field *field, struct nlattr *attr)
206 printf("%d", (int8_t)nla_get_u8(attr));
207 }
208
209+static bool parse_u16_hex(const struct tm_field *field, int idx,
210+ struct nl_msg *msg, const char *val)
211+{
212+ return !nla_put_u16(msg, idx, strtoul(val, NULL, 16));
213+}
214+
215+static void print_u16_hex(const struct tm_field *field, struct nlattr *attr)
216+{
217+ printf("%d", nla_get_u16(attr));
218+}
219+
220 static bool parse_u32(const struct tm_field *field, int idx,
221 struct nl_msg *msg, const char *val)
222 {
223@@ -384,6 +409,8 @@ static const struct tm_field testdata_fields[NUM_MT76_TM_ATTRS] = {
224 FIELD(u8, AID, "aid"),
225 FIELD(u8, RU_ALLOC, "ru_alloc"),
226 FIELD(u8, RU_IDX, "ru_idx"),
227+ FIELD_ENUM(TXBF_ACT, "txbf_act", testmode_txbf_act),
228+ FIELD_ARRAY(u16_hex, TXBF_PARAM, "txbf_param"),
229 FIELD_MAC(MAC_ADDRS, "mac_addrs"),
230 FIELD_NESTED_RO(STATS, stats, "",
231 .print_extra = print_extra_stats),
232@@ -414,6 +441,7 @@ static struct nla_policy testdata_policy[NUM_MT76_TM_ATTRS] = {
233 [MT76_TM_ATTR_RU_ALLOC] = { .type = NLA_U8 },
234 [MT76_TM_ATTR_RU_IDX] = { .type = NLA_U8 },
235 [MT76_TM_ATTR_STATS] = { .type = NLA_NESTED },
236+ [MT76_TM_ATTR_TXBF_ACT] = { .type = NLA_U8 },
237 };
238
239 const struct tm_field msg_field = {
240--
developer0443cd32023-09-19 14:11:49 +08002412.18.0
developerf9843e22022-09-13 10:57:15 +0800242