blob: 6b7aeb52eaebd2dc9d023daf54661b19018255fd [file] [log] [blame]
developerebda9012024-02-22 13:42:45 +08001From 97b952fe3531f8cbdcd0ac0612d04547e254a0c4 Mon Sep 17 00:00:00 2001
developer33907d42022-09-19 14:33:58 +08002From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
3Date: Mon, 12 Sep 2022 18:16:54 +0800
developerebda9012024-02-22 13:42:45 +08004Subject: [PATCH 1011/1048] wifi: mt76: testmode: add iBF command mode support
developer33907d42022-09-19 14:33:58 +08005
6Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
developer33907d42022-09-19 14:33:58 +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
developerd243af02023-12-21 14:49:33 +080015index 4b34430..453319e 100644
developer33907d42022-09-19 14:33:58 +080016--- a/mt7915/testmode.c
17+++ b/mt7915/testmode.c
developerd243af02023-12-21 14:49:33 +080018@@ -722,6 +722,7 @@ mt7915_tm_txbf_profile_update(struct mt7915_phy *phy, u16 *val, bool ebf)
developer33907d42022-09-19 14:33:58 +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)
developerd243af02023-12-21 14:49:33 +080026@@ -769,7 +770,7 @@ mt7915_tm_txbf_profile_update(struct mt7915_phy *phy, u16 *val, bool ebf)
developer33907d42022-09-19 14:33:58 +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;
developerd243af02023-12-21 14:49:33 +080035@@ -796,7 +797,7 @@ mt7915_tm_txbf_phase_cal(struct mt7915_phy *phy, u16 *val)
developer33907d42022-09-19 14:33:58 +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;
developerd243af02023-12-21 14:49:33 +080044@@ -835,6 +836,8 @@ int mt7915_tm_txbf_status_read(struct mt7915_dev *dev, struct sk_buff *skb)
developer33907d42022-09-19 14:33:58 +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:
developerd243af02023-12-21 14:49:33 +080053@@ -887,7 +890,6 @@ mt7915_tm_txbf_profile_update_all(struct mt7915_phy *phy, u16 *val)
developer33907d42022-09-19 14:33:58 +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 {
developerd243af02023-12-21 14:49:33 +080061@@ -945,8 +947,8 @@ mt7915_tm_set_txbf(struct mt7915_phy *phy)
developer33907d42022-09-19 14:33:58 +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:
developerd243af02023-12-21 14:49:33 +080072@@ -964,10 +966,17 @@ mt7915_tm_set_txbf(struct mt7915_phy *phy)
developer33907d42022-09-19 14:33:58 +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 };
developerd243af02023-12-21 14:49:33 +080090@@ -1094,7 +1103,6 @@ mt7915_tm_set_tx_len(struct mt7915_phy *phy, u32 tx_time)
developer33907d42022-09-19 14:33:58 +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)
developerd243af02023-12-21 14:49:33 +080098@@ -1461,7 +1469,6 @@ mt7915_tm_set_tx_frames(struct mt7915_phy *phy, bool en)
developer33907d42022-09-19 14:33:58 +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
developerd243af02023-12-21 14:49:33 +0800107index 3f108e4..898ef3a 100644
developer33907d42022-09-19 14:33:58 +0800108--- a/testmode.c
109+++ b/testmode.c
developerd243af02023-12-21 14:49:33 +0800110@@ -535,6 +535,42 @@ out:
developer33907d42022-09-19 14:33:58 +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 {
developerd243af02023-12-21 14:49:33 +0800153@@ -676,6 +712,11 @@ int mt76_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
developer281084d2023-06-19 12:03:50 +0800154 0, MT76_TM_TXBF_ACT_MAX))
developer33907d42022-09-19 14:33:58 +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
developerd243af02023-12-21 14:49:33 +0800166index e4c1b52..1d7aef8 100644
developer33907d42022-09-19 14:33:58 +0800167--- a/testmode.h
168+++ b/testmode.h
developerd243af02023-12-21 14:49:33 +0800169@@ -285,8 +285,10 @@ enum mt76_testmode_txbf_act {
developer33907d42022-09-19 14:33:58 +0800170 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
developerd243af02023-12-21 14:49:33 +0800181index 27801db..b0ee84d 100644
developer33907d42022-09-19 14:33:58 +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 {
developerd243af02023-12-21 14:49:33 +0800223@@ -387,6 +412,8 @@ static const struct tm_field testdata_fields[NUM_MT76_TM_ATTRS] = {
developer33907d42022-09-19 14:33:58 +0800224 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),
developerd243af02023-12-21 14:49:33 +0800232@@ -418,6 +445,7 @@ static struct nla_policy testdata_policy[NUM_MT76_TM_ATTRS] = {
developer33907d42022-09-19 14:33:58 +0800233 [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--
developere35b8e42023-10-16 11:04:00 +08002412.18.0
developer33907d42022-09-19 14:33:58 +0800242