developer | efb40c1 | 2022-12-21 18:05:47 +0800 | [diff] [blame] | 1 | From 66bc9f6b11a2d1bb5da592400984337bb0d077b9 Mon Sep 17 00:00:00 2001 |
developer | 33907d4 | 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 | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 4 | Subject: [PATCH 1114/1131] mt76: testmode: add iBF command mode support |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 5 | |
| 6 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 7 | Change-Id: I7eea1d6412563f889e5774e787e58ce9eba001bd |
| 8 | --- |
| 9 | mt7915/testmode.c | 21 ++++++++++++++------- |
| 10 | testmode.c | 41 +++++++++++++++++++++++++++++++++++++++++ |
| 11 | testmode.h | 2 ++ |
| 12 | tools/fields.c | 28 ++++++++++++++++++++++++++++ |
| 13 | 4 files changed, 85 insertions(+), 7 deletions(-) |
| 14 | |
| 15 | diff --git a/mt7915/testmode.c b/mt7915/testmode.c |
developer | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 16 | index a9e57e4..99582d9 100644 |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 17 | --- a/mt7915/testmode.c |
| 18 | +++ b/mt7915/testmode.c |
| 19 | @@ -701,6 +701,7 @@ mt7915_tm_txbf_profile_update(struct mt7915_phy *phy, u16 *val, bool ebf) |
| 20 | struct ieee80211_vif *vif = phy->monitor_vif; |
| 21 | struct mt7915_tm_pfmu_tag *tag = phy->dev->test.txbf_pfmu_tag; |
| 22 | u8 pfmu_idx = val[0], nc = val[2], nr; |
| 23 | + bool is_atenl = val[6]; |
| 24 | int ret; |
| 25 | |
| 26 | if (td->tx_antenna_mask == 3) |
| 27 | @@ -748,7 +749,7 @@ mt7915_tm_txbf_profile_update(struct mt7915_phy *phy, u16 *val, bool ebf) |
| 28 | if (ret) |
| 29 | return ret; |
| 30 | |
| 31 | - if (!ebf) |
| 32 | + if (!ebf && is_atenl) |
| 33 | return mt7915_tm_txbf_apply_tx(phy, 1, false, true, true); |
| 34 | |
| 35 | return 0; |
| 36 | @@ -775,7 +776,7 @@ mt7915_tm_txbf_phase_cal(struct mt7915_phy *phy, u16 *val) |
| 37 | .group_l_m_n = val[1], |
| 38 | .sx2 = val[2], |
| 39 | .cal_type = val[3], |
| 40 | - .lna_gain_level = 0, /* for test purpose */ |
| 41 | + .lna_gain_level = val[4], |
| 42 | }; |
| 43 | struct mt7915_tm_txbf_phase *phase = |
| 44 | (struct mt7915_tm_txbf_phase *)dev->test.txbf_phase_cal; |
| 45 | @@ -814,6 +815,8 @@ int mt7915_tm_txbf_status_read(struct mt7915_dev *dev, struct sk_buff *skb) |
| 46 | phase = &phase[cal->group]; |
| 47 | memcpy(&phase->phase, cal->buf + 16, sizeof(phase->phase)); |
| 48 | phase->status = cal->status; |
| 49 | + /* for passing iTest script */ |
| 50 | + dev_info(dev->mt76.dev, "Calibrated result = %d\n", phase->status); |
| 51 | break; |
| 52 | case IBF_PHASE_CAL_VERIFY: |
| 53 | case IBF_PHASE_CAL_VERIFY_INSTRUMENT: |
| 54 | @@ -865,7 +868,6 @@ mt7915_tm_txbf_profile_update_all(struct mt7915_phy *phy, u16 *val) |
| 55 | pfmu_data->phi11 = cpu_to_le16(phi11); |
| 56 | pfmu_data->phi21 = cpu_to_le16(phi21); |
| 57 | pfmu_data->phi31 = cpu_to_le16(phi31); |
| 58 | - |
| 59 | if (subc_id == 63) { |
| 60 | struct mt7915_dev *dev = phy->dev; |
| 61 | struct { |
| 62 | @@ -923,8 +925,8 @@ mt7915_tm_set_txbf(struct mt7915_phy *phy) |
| 63 | struct mt76_testmode_data *td = &phy->mt76->test; |
| 64 | u16 *val = td->txbf_param; |
| 65 | |
| 66 | - pr_info("ibf cal process: act = %u, val = %u, %u, %u, %u, %u\n", |
| 67 | - td->txbf_act, val[0], val[1], val[2], val[3], val[4]); |
| 68 | + pr_info("ibf cal process: act = %u, val = %u, %u, %u, %u, %u, %u\n", |
| 69 | + td->txbf_act, val[0], val[1], val[2], val[3], val[4], val[5]); |
| 70 | |
| 71 | switch (td->txbf_act) { |
| 72 | case MT76_TM_TXBF_ACT_INIT: |
| 73 | @@ -942,10 +944,17 @@ mt7915_tm_set_txbf(struct mt7915_phy *phy) |
| 74 | return mt7915_tm_txbf_profile_update(phy, val, true); |
| 75 | case MT76_TM_TXBF_ACT_PHASE_CAL: |
| 76 | return mt7915_tm_txbf_phase_cal(phy, val); |
| 77 | + case MT76_TM_TXBF_ACT_PROF_UPDATE_ALL_CMD: |
| 78 | case MT76_TM_TXBF_ACT_PROF_UPDATE_ALL: |
| 79 | return mt7915_tm_txbf_profile_update_all(phy, val); |
| 80 | case MT76_TM_TXBF_ACT_E2P_UPDATE: |
| 81 | return mt7915_tm_txbf_e2p_update(phy); |
| 82 | + case MT76_TM_TXBF_ACT_APPLY_TX: { |
| 83 | + u16 wlan_idx = val[0]; |
| 84 | + bool ebf = !!val[1], ibf = !!val[2], phase_cal = !!val[4]; |
| 85 | + |
| 86 | + return mt7915_tm_txbf_apply_tx(phy, wlan_idx, ebf, ibf, phase_cal); |
| 87 | + } |
| 88 | default: |
| 89 | break; |
| 90 | }; |
developer | 2458e70 | 2022-12-13 15:52:04 +0800 | [diff] [blame] | 91 | @@ -1072,7 +1081,6 @@ mt7915_tm_set_tx_len(struct mt7915_phy *phy, u32 tx_time) |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 92 | rate.legacy = sband->bitrates[rate.mcs].bitrate; |
| 93 | break; |
| 94 | case MT76_TM_TX_MODE_HT: |
| 95 | - rate.mcs += rate.nss * 8; |
| 96 | flags |= RATE_INFO_FLAGS_MCS; |
| 97 | |
| 98 | if (td->tx_rate_sgi) |
developer | 2458e70 | 2022-12-13 15:52:04 +0800 | [diff] [blame] | 99 | @@ -1437,7 +1445,6 @@ mt7915_tm_set_tx_frames(struct mt7915_phy *phy, bool en) |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 100 | if (duty_cycle < 100) |
| 101 | tx_time = duty_cycle * ipg / (100 - duty_cycle); |
| 102 | } |
| 103 | - |
| 104 | mt7915_tm_set_ipg_params(phy, ipg, td->tx_rate_mode); |
| 105 | mt7915_tm_set_tx_len(phy, tx_time); |
| 106 | |
| 107 | diff --git a/testmode.c b/testmode.c |
developer | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 108 | index 82b8e98..aa874a8 100644 |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 109 | --- a/testmode.c |
| 110 | +++ b/testmode.c |
| 111 | @@ -530,6 +530,42 @@ out: |
| 112 | return err; |
| 113 | } |
| 114 | |
| 115 | +static int |
| 116 | +mt76_testmode_txbf_profile_update_all_cmd(struct mt76_phy *phy, struct nlattr **tb, u32 state) |
| 117 | +{ |
| 118 | +#define PARAM_UNIT 5 |
| 119 | + static u8 pfmu_idx; |
| 120 | + struct mt76_testmode_data *td = &phy->test; |
| 121 | + struct mt76_dev *dev = phy->dev; |
| 122 | + struct nlattr *cur; |
| 123 | + u16 tmp_val[PARAM_UNIT], *val = td->txbf_param; |
| 124 | + int idx, rem, ret, i = 0; |
| 125 | + |
| 126 | + memset(td->txbf_param, 0, sizeof(td->txbf_param)); |
| 127 | + nla_for_each_nested(cur, tb[MT76_TM_ATTR_TXBF_PARAM], rem) { |
| 128 | + if (nla_len(cur) != 2) |
| 129 | + return -EINVAL; |
| 130 | + idx = i % PARAM_UNIT; |
| 131 | + tmp_val[idx] = nla_get_u16(cur); |
| 132 | + if (idx == 1 && (tmp_val[idx] == 0xf0 || tmp_val[idx] == 0xff)) { |
| 133 | + pfmu_idx = tmp_val[0]; |
| 134 | + return 0; |
| 135 | + } |
| 136 | + if (idx == PARAM_UNIT - 1) { |
| 137 | + val[0] = pfmu_idx; |
| 138 | + memcpy(val + 1, tmp_val, sizeof(tmp_val)); |
| 139 | + if (dev->test_ops->set_params) { |
| 140 | + ret = dev->test_ops->set_params(phy, tb, state); |
| 141 | + if (ret) |
| 142 | + return ret; |
| 143 | + } |
| 144 | + } |
| 145 | + i++; |
| 146 | + } |
| 147 | + |
| 148 | + return 0; |
| 149 | +} |
| 150 | + |
| 151 | int mt76_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 152 | void *data, int len) |
| 153 | { |
| 154 | @@ -668,6 +704,11 @@ int mt76_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 155 | 0, MT76_TM_TXBF_ACT_MAX)) |
| 156 | goto out; |
| 157 | |
| 158 | + if (td->txbf_act == MT76_TM_TXBF_ACT_PROF_UPDATE_ALL_CMD) { |
| 159 | + err = mt76_testmode_txbf_profile_update_all_cmd(phy, tb, state); |
| 160 | + goto out; |
| 161 | + } |
| 162 | + |
| 163 | memset(td->txbf_param, 0, sizeof(td->txbf_param)); |
| 164 | nla_for_each_nested(cur, tb[MT76_TM_ATTR_TXBF_PARAM], rem) { |
| 165 | if (nla_len(cur) != 2 || |
| 166 | diff --git a/testmode.h b/testmode.h |
developer | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 167 | index e2190e7..5d1fe79 100644 |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 168 | --- a/testmode.h |
| 169 | +++ b/testmode.h |
| 170 | @@ -281,8 +281,10 @@ enum mt76_testmode_txbf_act { |
| 171 | MT76_TM_TXBF_ACT_TX_PREP, |
| 172 | MT76_TM_TXBF_ACT_IBF_PROF_UPDATE, |
| 173 | MT76_TM_TXBF_ACT_EBF_PROF_UPDATE, |
| 174 | + MT76_TM_TXBF_ACT_APPLY_TX, |
| 175 | MT76_TM_TXBF_ACT_PHASE_CAL, |
| 176 | MT76_TM_TXBF_ACT_PROF_UPDATE_ALL, |
| 177 | + MT76_TM_TXBF_ACT_PROF_UPDATE_ALL_CMD, |
| 178 | MT76_TM_TXBF_ACT_E2P_UPDATE, |
| 179 | |
| 180 | /* keep last */ |
| 181 | diff --git a/tools/fields.c b/tools/fields.c |
developer | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 182 | index 1be1ffd..47fc69f 100644 |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 183 | --- a/tools/fields.c |
| 184 | +++ b/tools/fields.c |
| 185 | @@ -32,6 +32,20 @@ static const char * const testmode_tx_mode[] = { |
| 186 | [MT76_TM_TX_MODE_HE_MU] = "he_mu", |
| 187 | }; |
| 188 | |
| 189 | +static const char * const testmode_txbf_act[] = { |
| 190 | + [MT76_TM_TXBF_ACT_INIT] = "init", |
| 191 | + [MT76_TM_TXBF_ACT_UPDATE_CH] = "update_ch", |
| 192 | + [MT76_TM_TXBF_ACT_PHASE_COMP] = "phase_comp", |
| 193 | + [MT76_TM_TXBF_ACT_TX_PREP] = "tx_prep", |
| 194 | + [MT76_TM_TXBF_ACT_IBF_PROF_UPDATE] = "ibf_prof_update", |
| 195 | + [MT76_TM_TXBF_ACT_EBF_PROF_UPDATE] = "ebf_prof_update", |
| 196 | + [MT76_TM_TXBF_ACT_APPLY_TX] = "apply_tx", |
| 197 | + [MT76_TM_TXBF_ACT_PHASE_CAL] = "phase_cal", |
| 198 | + [MT76_TM_TXBF_ACT_PROF_UPDATE_ALL] = "prof_update", |
| 199 | + [MT76_TM_TXBF_ACT_PROF_UPDATE_ALL_CMD] = "prof_update_all", |
| 200 | + [MT76_TM_TXBF_ACT_E2P_UPDATE] = "e2p_update", |
| 201 | +}; |
| 202 | + |
| 203 | static void print_enum(const struct tm_field *field, struct nlattr *attr) |
| 204 | { |
| 205 | unsigned int i = nla_get_u8(attr); |
| 206 | @@ -82,6 +96,17 @@ static void print_s8(const struct tm_field *field, struct nlattr *attr) |
| 207 | printf("%d", (int8_t)nla_get_u8(attr)); |
| 208 | } |
| 209 | |
| 210 | +static bool parse_u16_hex(const struct tm_field *field, int idx, |
| 211 | + struct nl_msg *msg, const char *val) |
| 212 | +{ |
| 213 | + return !nla_put_u16(msg, idx, strtoul(val, NULL, 16)); |
| 214 | +} |
| 215 | + |
| 216 | +static void print_u16_hex(const struct tm_field *field, struct nlattr *attr) |
| 217 | +{ |
| 218 | + printf("%d", nla_get_u16(attr)); |
| 219 | +} |
| 220 | + |
| 221 | static bool parse_u32(const struct tm_field *field, int idx, |
| 222 | struct nl_msg *msg, const char *val) |
| 223 | { |
| 224 | @@ -384,6 +409,8 @@ static const struct tm_field testdata_fields[NUM_MT76_TM_ATTRS] = { |
| 225 | FIELD(u8, AID, "aid"), |
| 226 | FIELD(u8, RU_ALLOC, "ru_alloc"), |
| 227 | FIELD(u8, RU_IDX, "ru_idx"), |
| 228 | + FIELD_ENUM(TXBF_ACT, "txbf_act", testmode_txbf_act), |
| 229 | + FIELD_ARRAY(u16_hex, TXBF_PARAM, "txbf_param"), |
| 230 | FIELD_MAC(MAC_ADDRS, "mac_addrs"), |
| 231 | FIELD_NESTED_RO(STATS, stats, "", |
| 232 | .print_extra = print_extra_stats), |
| 233 | @@ -414,6 +441,7 @@ static struct nla_policy testdata_policy[NUM_MT76_TM_ATTRS] = { |
| 234 | [MT76_TM_ATTR_RU_ALLOC] = { .type = NLA_U8 }, |
| 235 | [MT76_TM_ATTR_RU_IDX] = { .type = NLA_U8 }, |
| 236 | [MT76_TM_ATTR_STATS] = { .type = NLA_NESTED }, |
| 237 | + [MT76_TM_ATTR_TXBF_ACT] = { .type = NLA_U8 }, |
| 238 | }; |
| 239 | |
| 240 | const struct tm_field msg_field = { |
| 241 | -- |
developer | 2aa1e64 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 242 | 2.36.1 |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 243 | |