developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 1 | From a78a0de5858eba651ca9630dc8970c947b190b28 Mon Sep 17 00:00:00 2001 |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 2 | From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 3 | Date: Mon, 12 Sep 2022 18:16:54 +0800 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 4 | Subject: [PATCH 1010/1052] wifi: mt76: testmode: add iBF command mode support |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 5 | |
| 6 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 7 | --- |
| 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 | |
| 14 | diff --git a/mt7915/testmode.c b/mt7915/testmode.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 15 | index 4b344303..453319e1 100644 |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 16 | --- a/mt7915/testmode.c |
| 17 | +++ b/mt7915/testmode.c |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 18 | @@ -722,6 +722,7 @@ mt7915_tm_txbf_profile_update(struct mt7915_phy *phy, u16 *val, bool ebf) |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 19 | 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) |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 26 | @@ -769,7 +770,7 @@ mt7915_tm_txbf_profile_update(struct mt7915_phy *phy, u16 *val, bool ebf) |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 27 | 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; |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 35 | @@ -796,7 +797,7 @@ mt7915_tm_txbf_phase_cal(struct mt7915_phy *phy, u16 *val) |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 36 | .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; |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 44 | @@ -835,6 +836,8 @@ int mt7915_tm_txbf_status_read(struct mt7915_dev *dev, struct sk_buff *skb) |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 45 | 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: |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 53 | @@ -887,7 +890,6 @@ mt7915_tm_txbf_profile_update_all(struct mt7915_phy *phy, u16 *val) |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 54 | 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 { |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 61 | @@ -945,8 +947,8 @@ mt7915_tm_set_txbf(struct mt7915_phy *phy) |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 62 | 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: |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 72 | @@ -964,10 +966,17 @@ mt7915_tm_set_txbf(struct mt7915_phy *phy) |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 73 | 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 | }; |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 90 | @@ -1094,7 +1103,6 @@ mt7915_tm_set_tx_len(struct mt7915_phy *phy, u32 tx_time) |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 91 | 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) |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 98 | @@ -1461,7 +1469,6 @@ mt7915_tm_set_tx_frames(struct mt7915_phy *phy, bool en) |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 99 | 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 | |
| 106 | diff --git a/testmode.c b/testmode.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 107 | index 132267eb..06b10a36 100644 |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 108 | --- a/testmode.c |
| 109 | +++ b/testmode.c |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 110 | @@ -535,6 +535,42 @@ out: |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 111 | 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 | { |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 153 | @@ -676,6 +712,11 @@ int mt76_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
developer | 692ed9b | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 154 | 0, MT76_TM_TXBF_ACT_MAX)) |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 155 | 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 || |
| 165 | diff --git a/testmode.h b/testmode.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 166 | index e4c1b521..1d7aef86 100644 |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 167 | --- a/testmode.h |
| 168 | +++ b/testmode.h |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 169 | @@ -285,8 +285,10 @@ enum mt76_testmode_txbf_act { |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 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 */ |
| 180 | diff --git a/tools/fields.c b/tools/fields.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 181 | index 27801dbe..b0ee84d2 100644 |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 182 | --- 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 | { |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 223 | @@ -387,6 +412,8 @@ static const struct tm_field testdata_fields[NUM_MT76_TM_ATTRS] = { |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 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), |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 232 | @@ -418,6 +445,7 @@ static struct nla_policy testdata_policy[NUM_MT76_TM_ATTRS] = { |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 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 | -- |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 241 | 2.18.0 |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 242 | |