developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1 | From d46a2b30adcdc8bca0f2a5012cd7bd4a3d59051b Mon Sep 17 00:00:00 2001 |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 2 | From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 3 | Date: Thu, 15 Dec 2022 19:45:18 +0800 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 1012/1052] wifi: mt76: testmode: add iBF/eBF cal and cert |
| 5 | commands with golden |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 6 | |
| 7 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 8 | --- |
| 9 | mt76.h | 4 + |
| 10 | mt76_connac_mcu.c | 3 + |
| 11 | mt7915/mac.c | 4 +- |
| 12 | mt7915/main.c | 54 ++--- |
| 13 | mt7915/mcu.c | 29 ++- |
| 14 | mt7915/mcu.h | 172 ++++++++++++++++ |
| 15 | mt7915/mmio.c | 2 + |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 16 | mt7915/mt7915.h | 16 +- |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 17 | mt7915/mtk_debugfs.c | 35 ++++ |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 18 | mt7915/mtk_mcu.c | 247 ++++++++++++++++++++++- |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 19 | mt7915/regs.h | 4 + |
developer | f0fd705 | 2023-08-14 20:23:42 +0800 | [diff] [blame] | 20 | mt7915/testmode.c | 461 ++++++++++++++++++++++++++++--------------- |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 21 | mt7915/testmode.h | 134 +------------ |
| 22 | testmode.c | 1 + |
| 23 | testmode.h | 9 + |
| 24 | tools/fields.c | 9 + |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 25 | 16 files changed, 859 insertions(+), 325 deletions(-) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 26 | |
| 27 | diff --git a/mt76.h b/mt76.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 28 | index 15106812..9597f564 100644 |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 29 | --- a/mt76.h |
| 30 | +++ b/mt76.h |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 31 | @@ -755,6 +755,7 @@ struct mt76_testmode_data { |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 32 | |
| 33 | struct list_head tm_entry_list; |
| 34 | struct mt76_wcid *cur_entry; |
| 35 | + struct ieee80211_vif *second_vif; |
| 36 | u8 entry_num; |
| 37 | union { |
| 38 | struct mt76_testmode_entry_data ed; |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 39 | @@ -783,6 +784,9 @@ struct mt76_testmode_data { |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 40 | |
| 41 | u8 txbf_act; |
| 42 | u16 txbf_param[8]; |
| 43 | + bool is_txbf_dut; |
| 44 | + bool bf_en; |
| 45 | + bool ebf; |
| 46 | |
| 47 | u32 tx_pending; |
| 48 | u32 tx_queued; |
| 49 | diff --git a/mt76_connac_mcu.c b/mt76_connac_mcu.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 50 | index 2acd7efb..0ce7ecdc 100644 |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 51 | --- a/mt76_connac_mcu.c |
| 52 | +++ b/mt76_connac_mcu.c |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 53 | @@ -2688,6 +2688,7 @@ int mt76_connac_mcu_bss_basic_tlv(struct sk_buff *skb, |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 54 | u32 type = vif->p2p ? NETWORK_P2P : NETWORK_INFRA; |
| 55 | struct bss_info_basic *bss; |
| 56 | struct tlv *tlv; |
| 57 | + struct mt76_testmode_data *td = &phy->test; |
| 58 | |
| 59 | tlv = mt76_connac_mcu_add_tlv(skb, BSS_INFO_BASIC, sizeof(*bss)); |
| 60 | bss = (struct bss_info_basic *)tlv; |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 61 | @@ -2747,6 +2748,8 @@ int mt76_connac_mcu_bss_basic_tlv(struct sk_buff *skb, |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 62 | bss->dtim_period = vif->bss_conf.dtim_period; |
| 63 | bss->phy_mode = mt76_connac_get_phy_mode(phy, vif, |
| 64 | chandef->chan->band, NULL); |
| 65 | + } else if (td->bf_en) { |
| 66 | + memcpy(bss->bssid, vif->addr, ETH_ALEN); |
| 67 | } else { |
| 68 | memcpy(bss->bssid, phy->macaddr, ETH_ALEN); |
| 69 | } |
| 70 | diff --git a/mt7915/mac.c b/mt7915/mac.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 71 | index b05e1630..dc75ff1f 100644 |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 72 | --- a/mt7915/mac.c |
| 73 | +++ b/mt7915/mac.c |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 74 | @@ -737,8 +737,10 @@ mt7915_mac_write_txwi_tm(struct mt7915_phy *phy, __le32 *txwi, |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 75 | val |= MT_TXD6_LDPC; |
| 76 | |
| 77 | txwi[3] &= ~cpu_to_le32(MT_TXD3_SN_VALID); |
| 78 | - if (phy->test.bf_en) |
| 79 | + if (td->bf_en && !td->ebf) |
| 80 | val |= MT_TXD6_TX_IBF | MT_TXD6_TX_EBF; |
| 81 | + else if (td->bf_en && td->ebf) |
| 82 | + val |= MT_TXD6_TX_EBF; |
| 83 | |
| 84 | txwi[6] |= cpu_to_le32(val); |
| 85 | #endif |
| 86 | diff --git a/mt7915/main.c b/mt7915/main.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 87 | index 2e566710..4a541188 100644 |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 88 | --- a/mt7915/main.c |
| 89 | +++ b/mt7915/main.c |
| 90 | @@ -205,46 +205,37 @@ static void mt7915_init_bitrate_mask(struct ieee80211_vif *vif) |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | -static int mt7915_add_interface(struct ieee80211_hw *hw, |
| 95 | - struct ieee80211_vif *vif) |
| 96 | +int mt7915_init_vif(struct mt7915_phy *phy, struct ieee80211_vif *vif, bool bf_en) |
| 97 | { |
| 98 | struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; |
| 99 | - struct mt7915_dev *dev = mt7915_hw_dev(hw); |
| 100 | - struct mt7915_phy *phy = mt7915_hw_phy(hw); |
| 101 | + struct mt7915_dev *dev = phy->dev; |
| 102 | struct mt76_txq *mtxq; |
| 103 | bool ext_phy = phy != &dev->phy; |
| 104 | int idx, ret = 0; |
| 105 | |
| 106 | - mutex_lock(&dev->mt76.mutex); |
| 107 | - |
| 108 | - mt76_testmode_reset(phy->mt76, true); |
| 109 | - |
| 110 | - if (vif->type == NL80211_IFTYPE_MONITOR && |
| 111 | - is_zero_ether_addr(vif->addr)) |
| 112 | - phy->monitor_vif = vif; |
| 113 | + /* To differentiate the mac address of TXD and TXCMD interface */ |
| 114 | + vif->addr[0] |= bf_en; |
| 115 | |
| 116 | mvif->mt76.idx = __ffs64(~dev->mt76.vif_mask); |
| 117 | - if (mvif->mt76.idx >= (MT7915_MAX_INTERFACES << dev->dbdc_support)) { |
| 118 | - ret = -ENOSPC; |
| 119 | - goto out; |
| 120 | - } |
| 121 | + if (mvif->mt76.idx >= (MT7915_MAX_INTERFACES << dev->dbdc_support)) |
| 122 | + return -ENOSPC; |
| 123 | |
| 124 | idx = get_omac_idx(vif->type, phy->omac_mask); |
| 125 | - if (idx < 0) { |
| 126 | - ret = -ENOSPC; |
| 127 | - goto out; |
| 128 | - } |
| 129 | + if (idx < 0) |
| 130 | + return -ENOSPC; |
| 131 | + |
| 132 | mvif->mt76.omac_idx = idx; |
| 133 | mvif->phy = phy; |
| 134 | mvif->mt76.band_idx = phy->mt76->band_idx; |
| 135 | |
| 136 | - mvif->mt76.wmm_idx = (vif->type != NL80211_IFTYPE_AP && vif->type != NL80211_IFTYPE_MONITOR); |
| 137 | + mvif->mt76.wmm_idx = (vif->type != NL80211_IFTYPE_AP && |
| 138 | + vif->type != NL80211_IFTYPE_MONITOR) || bf_en; |
| 139 | if (ext_phy) |
| 140 | mvif->mt76.wmm_idx += 2; |
| 141 | |
| 142 | ret = mt7915_mcu_add_dev_info(phy, vif, true); |
| 143 | if (ret) |
| 144 | - goto out; |
| 145 | + return ret; |
| 146 | |
| 147 | dev->mt76.vif_mask |= BIT_ULL(mvif->mt76.idx); |
| 148 | phy->omac_mask |= BIT_ULL(mvif->mt76.omac_idx); |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 149 | @@ -280,7 +271,26 @@ static int mt7915_add_interface(struct ieee80211_hw *hw, |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 150 | mt7915_mcu_add_sta(dev, vif, NULL, true); |
| 151 | rcu_assign_pointer(dev->mt76.wcid[idx], &mvif->sta.wcid); |
| 152 | |
| 153 | -out: |
| 154 | + return ret; |
| 155 | +} |
| 156 | + |
| 157 | +static int mt7915_add_interface(struct ieee80211_hw *hw, |
| 158 | + struct ieee80211_vif *vif) |
| 159 | +{ |
| 160 | + struct mt7915_dev *dev = mt7915_hw_dev(hw); |
| 161 | + struct mt7915_phy *phy = mt7915_hw_phy(hw); |
| 162 | + int ret = 0; |
| 163 | + |
| 164 | + mutex_lock(&dev->mt76.mutex); |
| 165 | + |
| 166 | + mt76_testmode_reset(phy->mt76, true); |
| 167 | + |
| 168 | + if (vif->type == NL80211_IFTYPE_MONITOR && |
| 169 | + is_zero_ether_addr(vif->addr)) |
| 170 | + phy->monitor_vif = vif; |
| 171 | + |
| 172 | + ret = mt7915_init_vif(phy, vif, false); |
| 173 | + |
| 174 | mutex_unlock(&dev->mt76.mutex); |
| 175 | |
| 176 | return ret; |
| 177 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 178 | index 500ecbbb..6f05a081 100644 |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 179 | --- a/mt7915/mcu.c |
| 180 | +++ b/mt7915/mcu.c |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 181 | @@ -199,6 +199,7 @@ mt7915_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb, |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 182 | int ret; |
| 183 | |
| 184 | ret = mt76_connac2_mcu_fill_message(mdev, skb, cmd, wait_seq); |
| 185 | + |
| 186 | if (ret) |
| 187 | return ret; |
| 188 | |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 189 | @@ -478,10 +479,12 @@ mt7915_mcu_rx_ext_event(struct mt7915_dev *dev, struct sk_buff *skb) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 190 | case MCU_EXT_EVENT_BCC_NOTIFY: |
| 191 | mt7915_mcu_rx_bcc_notify(dev, skb); |
| 192 | break; |
| 193 | -#ifdef CONFIG_NL80211_TESTMODE |
| 194 | +#if defined CONFIG_NL80211_TESTMODE || defined MTK_DEBUG |
| 195 | case MCU_EXT_EVENT_BF_STATUS_READ: |
| 196 | - mt7915_tm_txbf_status_read(dev, skb); |
| 197 | + mt7915_mcu_txbf_status_read(dev, skb); |
| 198 | break; |
| 199 | +#endif |
| 200 | +#ifdef CONFIG_NL80211_TESTMODE |
| 201 | case MCU_EXT_EVENT_RF_TEST: |
| 202 | mt7915_tm_rf_test_event(dev, skb); |
| 203 | break; |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 204 | @@ -773,11 +776,22 @@ int mt7915_mcu_add_bss_info(struct mt7915_phy *phy, |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 205 | if (enable) |
| 206 | mt76_connac_mcu_bss_omac_tlv(skb, vif); |
| 207 | |
| 208 | - mt76_connac_mcu_bss_basic_tlv(skb, vif, NULL, phy->mt76, |
| 209 | - mvif->sta.wcid.idx, enable); |
| 210 | + if (vif->type == NL80211_IFTYPE_MONITOR) { |
| 211 | + struct mt76_testmode_data *td = &phy->mt76->test; |
| 212 | + struct mt76_wcid *wcid; |
| 213 | + |
| 214 | + if (!td->aid || list_empty(&td->tm_entry_list)) |
| 215 | + wcid = &mvif->sta.wcid; |
| 216 | + else |
| 217 | + wcid = list_first_entry(&td->tm_entry_list, struct mt76_wcid, list); |
| 218 | |
| 219 | - if (vif->type == NL80211_IFTYPE_MONITOR) |
| 220 | + mt76_connac_mcu_bss_basic_tlv(skb, vif, NULL, phy->mt76, |
| 221 | + wcid->idx, enable); |
| 222 | goto out; |
| 223 | + } |
| 224 | + |
| 225 | + mt76_connac_mcu_bss_basic_tlv(skb, vif, NULL, phy->mt76, |
| 226 | + mvif->sta.wcid.idx, enable); |
| 227 | |
| 228 | if (enable) { |
| 229 | mt7915_mcu_bss_rfch_tlv(skb, vif, phy); |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 230 | @@ -3582,6 +3596,7 @@ int mt7915_mcu_set_ser(struct mt7915_dev *dev, u8 action, u8 set, u8 band) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 231 | |
| 232 | int mt7915_mcu_set_txbf(struct mt7915_dev *dev, u8 action) |
| 233 | { |
| 234 | +#define MT_BF_PROCESSING 4 |
| 235 | struct { |
| 236 | u8 action; |
| 237 | union { |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 238 | @@ -3608,7 +3623,6 @@ int mt7915_mcu_set_txbf(struct mt7915_dev *dev, u8 action) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 239 | .action = action, |
| 240 | }; |
| 241 | |
| 242 | -#define MT_BF_PROCESSING 4 |
| 243 | switch (action) { |
| 244 | case MT_BF_SOUNDING_ON: |
| 245 | req.snd.snd_mode = MT_BF_PROCESSING; |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 246 | @@ -4847,6 +4861,9 @@ int mt7915_mcu_set_txbf_sound_info(struct mt7915_phy *phy, u8 action, |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 247 | req.he_opt = v2; |
| 248 | req.glo_opt = v3; |
| 249 | break; |
| 250 | + case BF_SND_CFG_INF: |
| 251 | + req.inf = v1; |
| 252 | + break; |
| 253 | default: |
| 254 | return -EINVAL; |
| 255 | } |
| 256 | diff --git a/mt7915/mcu.h b/mt7915/mcu.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 257 | index 066246bb..de17c579 100644 |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 258 | --- a/mt7915/mcu.h |
| 259 | +++ b/mt7915/mcu.h |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 260 | @@ -546,10 +546,12 @@ enum { |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 261 | }; |
| 262 | |
| 263 | enum { |
| 264 | + MT_BF_SOUNDING_OFF = 0, |
| 265 | MT_BF_SOUNDING_ON = 1, |
| 266 | MT_BF_DATA_PACKET_APPLY = 2, |
| 267 | MT_BF_PFMU_TAG_READ = 5, |
| 268 | MT_BF_PFMU_TAG_WRITE = 6, |
| 269 | + MT_BF_STA_REC_READ = 13, |
| 270 | MT_BF_PHASE_CAL = 14, |
| 271 | MT_BF_IBF_PHASE_COMP = 15, |
| 272 | MT_BF_PROFILE_WRITE_ALL = 17, |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 273 | @@ -557,6 +559,176 @@ enum { |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 274 | MT_BF_MODULE_UPDATE = 25 |
| 275 | }; |
| 276 | |
| 277 | +#if defined CONFIG_NL80211_TESTMODE || defined MTK_DEBUG |
| 278 | +struct mt7915_pfmu_tag1 { |
| 279 | + __le32 pfmu_idx:10; |
| 280 | + __le32 ebf:1; |
| 281 | + __le32 data_bw:2; |
| 282 | + __le32 lm:2; |
| 283 | + __le32 is_mu:1; |
| 284 | + __le32 nr:3, nc:3; |
| 285 | + __le32 codebook:2; |
| 286 | + __le32 ngroup:2; |
| 287 | + __le32 _rsv:2; |
| 288 | + __le32 invalid_prof:1; |
| 289 | + __le32 rmsd:3; |
| 290 | + |
| 291 | + __le32 col_id1:6, row_id1:10; |
| 292 | + __le32 col_id2:6, row_id2:10; |
| 293 | + __le32 col_id3:6, row_id3:10; |
| 294 | + __le32 col_id4:6, row_id4:10; |
| 295 | + |
| 296 | + __le32 ru_start_id:7; |
| 297 | + __le32 _rsv1:1; |
| 298 | + __le32 ru_end_id:7; |
| 299 | + __le32 _rsv2:1; |
| 300 | + __le32 mob_cal_en:1; |
| 301 | + __le32 _rsv3:15; |
| 302 | + |
| 303 | + __le32 snr_sts0:8, snr_sts1:8, snr_sts2:8, snr_sts3:8; |
| 304 | + __le32 snr_sts4:8, snr_sts5:8, snr_sts6:8, snr_sts7:8; |
| 305 | + |
| 306 | + __le32 _rsv4; |
| 307 | +} __packed; |
| 308 | + |
| 309 | +struct mt7915_pfmu_tag2 { |
| 310 | + __le32 smart_ant:24; |
| 311 | + __le32 se_idx:5; |
| 312 | + __le32 _rsv:3; |
| 313 | + |
| 314 | + __le32 _rsv1:8; |
| 315 | + __le32 rmsd_thres:3; |
| 316 | + __le32 _rsv2:5; |
| 317 | + __le32 ibf_timeout:8; |
| 318 | + __le32 _rsv3:8; |
| 319 | + |
| 320 | + __le32 _rsv4:16; |
| 321 | + __le32 ibf_data_bw:2; |
| 322 | + __le32 ibf_nc:3; |
| 323 | + __le32 ibf_nr:3; |
| 324 | + __le32 ibf_ru:8; |
| 325 | + |
| 326 | + __le32 mob_delta_t:8; |
| 327 | + __le32 mob_lq_result:7; |
| 328 | + __le32 _rsv5:1; |
| 329 | + __le32 _rsv6:16; |
| 330 | + |
| 331 | + __le32 _rsv7; |
| 332 | +} __packed; |
| 333 | + |
| 334 | +struct mt7915_pfmu_tag { |
| 335 | + struct mt7915_pfmu_tag1 t1; |
| 336 | + struct mt7915_pfmu_tag2 t2; |
| 337 | +}; |
| 338 | + |
| 339 | +struct mt7915_bf_status_hdr { |
| 340 | + u8 format_id; |
| 341 | + u8 bw; |
| 342 | + u16 subcarrier_idx; |
| 343 | + bool bfer; |
| 344 | + u8 rsv[3]; |
| 345 | +} __packed; |
| 346 | + |
| 347 | +struct mt7915_bf_status { |
| 348 | + struct mt7915_bf_status_hdr hdr; |
| 349 | + u8 buf[1000]; |
| 350 | +} __packed; |
| 351 | + |
| 352 | +struct mt7915_txbf_phase_out { |
| 353 | + u8 c0_l; |
| 354 | + u8 c1_l; |
| 355 | + u8 c2_l; |
| 356 | + u8 c3_l; |
| 357 | + u8 c0_m; |
| 358 | + u8 c1_m; |
| 359 | + u8 c2_m; |
| 360 | + u8 c3_m; |
| 361 | + u8 c0_h; |
| 362 | + u8 c1_h; |
| 363 | + u8 c2_h; |
| 364 | + u8 c3_h; |
| 365 | + u8 c0_uh; |
| 366 | + u8 c1_uh; |
| 367 | + u8 c2_uh; |
| 368 | + u8 c3_uh; |
| 369 | +}; |
| 370 | + |
| 371 | +struct mt7915_txbf_phase { |
| 372 | + u8 status; |
| 373 | + struct { |
| 374 | + u8 r0_uh; |
| 375 | + u8 r0_h; |
| 376 | + u8 r0_m; |
| 377 | + u8 r0_l; |
| 378 | + u8 r0_ul; |
| 379 | + u8 r1_uh; |
| 380 | + u8 r1_h; |
| 381 | + u8 r1_m; |
| 382 | + u8 r1_l; |
| 383 | + u8 r1_ul; |
| 384 | + u8 r2_uh; |
| 385 | + u8 r2_h; |
| 386 | + u8 r2_m; |
| 387 | + u8 r2_l; |
| 388 | + u8 r2_ul; |
| 389 | + u8 r3_uh; |
| 390 | + u8 r3_h; |
| 391 | + u8 r3_m; |
| 392 | + u8 r3_l; |
| 393 | + u8 r3_ul; |
| 394 | + u8 r2_uh_sx2; |
| 395 | + u8 r2_h_sx2; |
| 396 | + u8 r2_m_sx2; |
| 397 | + u8 r2_l_sx2; |
| 398 | + u8 r2_ul_sx2; |
| 399 | + u8 r3_uh_sx2; |
| 400 | + u8 r3_h_sx2; |
| 401 | + u8 r3_m_sx2; |
| 402 | + u8 r3_l_sx2; |
| 403 | + u8 r3_ul_sx2; |
| 404 | + u8 m_t0_h; |
| 405 | + u8 m_t1_h; |
| 406 | + u8 m_t2_h; |
| 407 | + u8 m_t2_h_sx2; |
| 408 | + u8 r0_reserved; |
| 409 | + u8 r1_reserved; |
| 410 | + u8 r2_reserved; |
| 411 | + u8 r3_reserved; |
| 412 | + u8 r2_sx2_reserved; |
| 413 | + u8 r3_sx2_reserved; |
| 414 | + } phase; |
| 415 | +}; |
| 416 | + |
| 417 | +struct mt7915_pfmu_data { |
| 418 | + __le16 subc_idx; |
| 419 | + __le16 phi11; |
| 420 | + __le16 phi21; |
| 421 | + __le16 phi31; |
| 422 | +}; |
| 423 | + |
| 424 | +struct mt7915_ibf_cal_info { |
| 425 | + u8 format_id; |
| 426 | + u8 group_l_m_n; |
| 427 | + u8 group; |
| 428 | + bool sx2; |
| 429 | + u8 status; |
| 430 | + u8 cal_type; |
| 431 | + u8 _rsv[2]; |
| 432 | + u8 buf[1000]; |
| 433 | +} __packed; |
| 434 | + |
| 435 | +enum { |
| 436 | + IBF_PHASE_CAL_UNSPEC, |
| 437 | + IBF_PHASE_CAL_NORMAL, |
| 438 | + IBF_PHASE_CAL_VERIFY, |
| 439 | + IBF_PHASE_CAL_NORMAL_INSTRUMENT, |
| 440 | + IBF_PHASE_CAL_VERIFY_INSTRUMENT, |
| 441 | +}; |
| 442 | + |
| 443 | +#define MT7915_TXBF_SUBCAR_NUM 64 |
| 444 | + |
| 445 | +#endif |
| 446 | + |
| 447 | enum { |
| 448 | MURU_SET_ARB_OP_MODE = 14, |
| 449 | MURU_SET_PLATFORM_TYPE = 25, |
| 450 | diff --git a/mt7915/mmio.c b/mt7915/mmio.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 451 | index 730cd338..ed15d711 100644 |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 452 | --- a/mt7915/mmio.c |
| 453 | +++ b/mt7915/mmio.c |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 454 | @@ -133,6 +133,7 @@ static const u32 mt7915_offs[] = { |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 455 | [MDP_BNRCFR1] = 0x074, |
| 456 | [ARB_DRNGR0] = 0x194, |
| 457 | [ARB_SCR] = 0x080, |
| 458 | + [ARB_TQSAXM0] = 0x030, |
| 459 | [RMAC_MIB_AIRTIME14] = 0x3b8, |
| 460 | [AGG_AALCR0] = 0x048, |
| 461 | [AGG_AWSCR0] = 0x05c, |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 462 | @@ -209,6 +210,7 @@ static const u32 mt7916_offs[] = { |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 463 | [MDP_BNRCFR1] = 0x094, |
| 464 | [ARB_DRNGR0] = 0x1e0, |
| 465 | [ARB_SCR] = 0x000, |
| 466 | + [ARB_TQSAXM0] = 0x180, |
| 467 | [RMAC_MIB_AIRTIME14] = 0x0398, |
| 468 | [AGG_AALCR0] = 0x028, |
| 469 | [AGG_AWSCR0] = 0x030, |
| 470 | diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 471 | index 00f55443..ef92b2ea 100644 |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 472 | --- a/mt7915/mt7915.h |
| 473 | +++ b/mt7915/mt7915.h |
developer | 42c7a43 | 2024-07-12 14:39:29 +0800 | [diff] [blame] | 474 | @@ -325,7 +325,6 @@ struct mt7915_phy { |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 475 | |
| 476 | u8 spe_idx; |
| 477 | |
| 478 | - bool bf_en; |
| 479 | bool bf_ever_en; |
| 480 | } test; |
| 481 | #endif |
developer | 42c7a43 | 2024-07-12 14:39:29 +0800 | [diff] [blame] | 482 | @@ -443,7 +442,7 @@ struct mt7915_dev { |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 483 | void __iomem *dcm; |
| 484 | void __iomem *sku; |
| 485 | |
| 486 | -#ifdef CONFIG_NL80211_TESTMODE |
| 487 | +#if defined CONFIG_NL80211_TESTMODE || defined MTK_DEBUG |
| 488 | struct { |
| 489 | void *txbf_phase_cal; |
| 490 | void *txbf_pfmu_data; |
developer | 42c7a43 | 2024-07-12 14:39:29 +0800 | [diff] [blame] | 491 | @@ -591,6 +590,7 @@ int mt7915_dma_reset(struct mt7915_dev *dev, bool force); |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 492 | int mt7915_dma_start(struct mt7915_dev *dev, bool reset, bool wed_reset); |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 493 | int mt7915_txbf_init(struct mt7915_dev *dev); |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 494 | void mt7915_init_txpower(struct mt7915_phy *phy); |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 495 | +int mt7915_init_vif(struct mt7915_phy *phy, struct ieee80211_vif *vif, bool bf_en); |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 496 | void mt7915_reset(struct mt7915_dev *dev); |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 497 | int mt7915_run(struct ieee80211_hw *hw); |
| 498 | int mt7915_mcu_init(struct mt7915_dev *dev); |
developer | 42c7a43 | 2024-07-12 14:39:29 +0800 | [diff] [blame] | 499 | @@ -671,10 +671,12 @@ int mt7915_mcu_fw_log_2_host(struct mt7915_dev *dev, u8 type, u8 ctrl); |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 500 | int mt7915_mcu_fw_dbg_ctrl(struct mt7915_dev *dev, u32 module, u8 level); |
| 501 | void mt7915_mcu_rx_event(struct mt7915_dev *dev, struct sk_buff *skb); |
| 502 | void mt7915_mcu_exit(struct mt7915_dev *dev); |
| 503 | -int mt7915_tm_txbf_status_read(struct mt7915_dev *dev, struct sk_buff *skb); |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 504 | -void mt7915_tm_rf_test_event(struct mt7915_dev *dev, struct sk_buff *skb); |
| 505 | void mt7915_mcu_wmm_pbc_work(struct work_struct *work); |
| 506 | |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 507 | +#ifdef CONFIG_NL80211_TESTMODE |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 508 | +void mt7915_tm_rf_test_event(struct mt7915_dev *dev, struct sk_buff *skb); |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 509 | +#endif |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 510 | + |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 511 | static inline u16 mt7915_wtbl_size(struct mt7915_dev *dev) |
| 512 | { |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 513 | return is_mt7915(&dev->mt76) ? MT7915_WTBL_SIZE : MT7916_WTBL_SIZE; |
developer | 42c7a43 | 2024-07-12 14:39:29 +0800 | [diff] [blame] | 514 | @@ -810,4 +812,10 @@ enum { |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 515 | |
| 516 | #endif |
| 517 | |
| 518 | +#if defined CONFIG_NL80211_TESTMODE || defined MTK_DEBUG |
| 519 | +int mt7915_mcu_txbf_status_read(struct mt7915_dev *dev, struct sk_buff *skb); |
| 520 | +int mt7915_mcu_txbf_profile_tag_read(struct mt7915_phy *phy, u8 pfmu_idx, bool bfer); |
| 521 | +int mt7915_mcu_txbf_sta_rec_read(struct mt7915_dev *dev, u16 wlan_idx); |
| 522 | +#endif |
| 523 | + |
| 524 | #endif |
| 525 | diff --git a/mt7915/mtk_debugfs.c b/mt7915/mtk_debugfs.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 526 | index 54daa736..02fe61a3 100644 |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 527 | --- a/mt7915/mtk_debugfs.c |
| 528 | +++ b/mt7915/mtk_debugfs.c |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 529 | @@ -2888,6 +2888,36 @@ mt7915_txpower_level_set(void *data, u64 val) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 530 | DEFINE_DEBUGFS_ATTRIBUTE(fops_txpower_level, NULL, |
| 531 | mt7915_txpower_level_set, "%lld\n"); |
| 532 | |
| 533 | +static int |
| 534 | +mt7915_txbf_pfmu_tag_read(void *data, u64 val) |
| 535 | +{ |
| 536 | + struct mt7915_phy *phy = data; |
| 537 | + u8 pfmu_idx = (u8)val; |
| 538 | + |
| 539 | + pr_info("%s: %d pfmu_tag cmd sent out ---\n", __func__, __LINE__); |
| 540 | + mt7915_mcu_txbf_profile_tag_read(phy, pfmu_idx, true); |
| 541 | + |
| 542 | + return 0; |
| 543 | +} |
| 544 | + |
| 545 | +DEFINE_DEBUGFS_ATTRIBUTE(fops_txbf_pfmu_tag_idx, NULL, |
| 546 | + mt7915_txbf_pfmu_tag_read, "%llx\n"); |
| 547 | + |
| 548 | +static int |
| 549 | +mt7915_txbf_sta_rec_read(void *data, u64 val) |
| 550 | +{ |
| 551 | + struct mt7915_dev *dev = data; |
| 552 | + u16 wlan_idx = (u16)val; |
| 553 | + |
| 554 | + pr_info("%s: %d sta_rec cmd sent out ---\n", __func__, __LINE__); |
| 555 | + mt7915_mcu_txbf_sta_rec_read(dev, wlan_idx); |
| 556 | + |
| 557 | + return 0; |
| 558 | +} |
| 559 | + |
| 560 | +DEFINE_DEBUGFS_ATTRIBUTE(fops_txbf_sta_rec, NULL, |
| 561 | + mt7915_txbf_sta_rec_read, "%llx\n"); |
| 562 | + |
| 563 | /* usage: echo 0x[arg3][arg2][arg1] > fw_wa_set */ |
| 564 | static int |
| 565 | mt7915_wa_set(void *data, u64 val) |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 566 | @@ -3777,6 +3807,11 @@ int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 567 | debugfs_create_file("txpower_level", 0400, dir, dev, |
| 568 | &fops_txpower_level); |
| 569 | |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 570 | + debugfs_create_file("pfmu_tag_read", 0600, dir, phy, |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 571 | + &fops_txbf_pfmu_tag_idx); |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 572 | + debugfs_create_file("bf_starec_read", 0600, dir, dev, |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 573 | + &fops_txbf_sta_rec); |
| 574 | + |
| 575 | debugfs_create_u8("sku_disable", 0600, dir, &dev->dbg.sku_disable); |
| 576 | |
developer | 6770571 | 2023-05-30 11:58:00 +0800 | [diff] [blame] | 577 | return 0; |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 578 | diff --git a/mt7915/mtk_mcu.c b/mt7915/mtk_mcu.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 579 | index 143dae26..7a2d28c7 100644 |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 580 | --- a/mt7915/mtk_mcu.c |
| 581 | +++ b/mt7915/mtk_mcu.c |
| 582 | @@ -1,9 +1,10 @@ |
| 583 | #include <linux/firmware.h> |
| 584 | #include <linux/fs.h> |
| 585 | -#include<linux/inet.h> |
| 586 | +#include <linux/inet.h> |
| 587 | #include "mt7915.h" |
| 588 | #include "mcu.h" |
| 589 | #include "mac.h" |
| 590 | +#include "testmode.h" |
| 591 | |
| 592 | int mt7915_mcu_set_txpower_level(struct mt7915_phy *phy, u8 drop_level) |
| 593 | { |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 594 | @@ -49,3 +50,247 @@ int mt7915_mcu_set_txpower_level(struct mt7915_phy *phy, u8 drop_level) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 595 | MCU_EXT_CMD(TX_POWER_FEATURE_CTRL), &req, |
| 596 | sizeof(req), true); |
| 597 | } |
| 598 | + |
| 599 | +#if defined CONFIG_NL80211_TESTMODE || defined MTK_DEBUG |
| 600 | +static void mt7915_txbf_dump_pfmu_tag(struct mt7915_dev *dev, struct mt7915_pfmu_tag *tag) |
| 601 | +{ |
| 602 | + u32 *raw_t1 = (u32 *)&tag->t1; |
| 603 | + u32 *raw_t2 = (u32 *)&tag->t2; |
| 604 | + |
| 605 | + dev_info(dev->mt76.dev, "=================== TXBf Profile Tag1 Info ==================\n"); |
| 606 | + dev_info(dev->mt76.dev, |
| 607 | + "DW0 = 0x%08x, DW1 = 0x%08x, DW2 = 0x%08x\n", |
| 608 | + raw_t1[0], raw_t1[1], raw_t1[2]); |
| 609 | + dev_info(dev->mt76.dev, |
| 610 | + "DW4 = 0x%08x, DW5 = 0x%08x, DW6 = 0x%08x\n\n", |
| 611 | + raw_t1[3], raw_t1[4], raw_t1[5]); |
| 612 | + dev_info(dev->mt76.dev, "PFMU ID = %d Invalid status = %d\n", |
| 613 | + tag->t1.pfmu_idx, tag->t1.invalid_prof); |
| 614 | + dev_info(dev->mt76.dev, "iBf/eBf = %d\n\n", tag->t1.ebf); |
| 615 | + dev_info(dev->mt76.dev, "DBW = %d\n", tag->t1.data_bw); |
| 616 | + dev_info(dev->mt76.dev, "SU/MU = %d\n", tag->t1.is_mu); |
| 617 | + dev_info(dev->mt76.dev, "RMSD = %d\n", tag->t1.rmsd); |
| 618 | + dev_info(dev->mt76.dev, |
| 619 | + "nrow = %d, ncol = %d, ng = %d, LM = %d, CodeBook = %d MobCalEn = %d\n", |
| 620 | + tag->t1.nr, tag->t1.nc, tag->t1.ngroup, tag->t1.lm, tag->t1.codebook, |
| 621 | + tag->t1.mob_cal_en); |
| 622 | + dev_info(dev->mt76.dev, "RU start = %d, RU end = %d\n", |
| 623 | + tag->t1.ru_start_id, tag->t1.ru_end_id); |
| 624 | + dev_info(dev->mt76.dev, "Mem Col1 = %d, Mem Row1 = %d, Mem Col2 = %d, Mem Row2 = %d\n", |
| 625 | + tag->t1.col_id1, tag->t1.row_id1, tag->t1.col_id2, tag->t1.row_id2); |
| 626 | + dev_info(dev->mt76.dev, "Mem Col3 = %d, Mem Row3 = %d, Mem Col4 = %d, Mem Row4 = %d\n\n", |
| 627 | + tag->t1.col_id3, tag->t1.row_id3, tag->t1.col_id4, tag->t1.row_id4); |
| 628 | + dev_info(dev->mt76.dev, |
| 629 | + "STS0_SNR = 0x%02x, STS1_SNR = 0x%02x, STS2_SNR = 0x%02x, STS3_SNR = 0x%02x\n", |
| 630 | + tag->t1.snr_sts0, tag->t1.snr_sts1, tag->t1.snr_sts2, tag->t1.snr_sts3); |
| 631 | + dev_info(dev->mt76.dev, |
| 632 | + "STS4_SNR = 0x%02x, STS5_SNR = 0x%02x, STS6_SNR = 0x%02x, STS7_SNR = 0x%02x\n", |
| 633 | + tag->t1.snr_sts4, tag->t1.snr_sts5, tag->t1.snr_sts6, tag->t1.snr_sts7); |
| 634 | + dev_info(dev->mt76.dev, "=============================================================\n"); |
| 635 | + |
| 636 | + dev_info(dev->mt76.dev, "=================== TXBf Profile Tag2 Info ==================\n"); |
| 637 | + dev_info(dev->mt76.dev, |
| 638 | + "DW0 = 0x%08x, DW1 = 0x%08x, DW2 = 0x%08x\n", |
| 639 | + raw_t2[0], raw_t2[1], raw_t2[2]); |
| 640 | + dev_info(dev->mt76.dev, |
| 641 | + "DW3 = 0x%08x, DW4 = 0x%08x, DW5 = 0x%08x\n\n", |
| 642 | + raw_t2[3], raw_t2[4], raw_t2[5]); |
| 643 | + dev_info(dev->mt76.dev, "Smart antenna ID = 0x%x, SE index = %d\n", |
| 644 | + tag->t2.smart_ant, tag->t2.se_idx); |
| 645 | + dev_info(dev->mt76.dev, "RMSD threshold = %d\n", tag->t2.rmsd_thres); |
| 646 | + dev_info(dev->mt76.dev, "Timeout = 0x%x\n", tag->t2.ibf_timeout); |
| 647 | + dev_info(dev->mt76.dev, "Desired BW = %d, Desired Ncol = %d, Desired Nrow = %d\n", |
| 648 | + tag->t2.ibf_data_bw, tag->t2.ibf_nc, tag->t2.ibf_nr); |
| 649 | + dev_info(dev->mt76.dev, "Desired RU Allocation = %d\n", tag->t2.ibf_ru); |
| 650 | + dev_info(dev->mt76.dev, "Mobility DeltaT = %d, Mobility LQ = %d\n", |
| 651 | + tag->t2.mob_delta_t, tag->t2.mob_lq_result); |
| 652 | + dev_info(dev->mt76.dev, "=============================================================\n"); |
| 653 | +} |
| 654 | + |
| 655 | +static void mt7915_txbf_dump_sta_rec(struct mt7915_dev *dev, struct sta_rec_bf *sta_info) |
| 656 | +{ |
| 657 | + dev_info(dev->mt76.dev, "===================== BF Station Record =====================\n"); |
| 658 | + dev_info(dev->mt76.dev, "pfmu = %d\n", sta_info->pfmu); |
| 659 | + dev_info(dev->mt76.dev, "su_mu = %d\n", sta_info->su_mu); |
| 660 | + dev_info(dev->mt76.dev, "bf_cap = %d\n", sta_info->bf_cap); |
| 661 | + dev_info(dev->mt76.dev, "sounding_phy = %d\n", sta_info->sounding_phy); |
| 662 | + dev_info(dev->mt76.dev, "ndpa_rate = %d\n", sta_info->ndpa_rate); |
| 663 | + dev_info(dev->mt76.dev, "ndp_rate = %d\n", sta_info->ndp_rate); |
| 664 | + dev_info(dev->mt76.dev, "rept_poll_rate = %d\n", sta_info->rept_poll_rate); |
| 665 | + dev_info(dev->mt76.dev, "tx_mode = %d\n", sta_info->tx_mode); |
| 666 | + dev_info(dev->mt76.dev, "ncol = %d\n", sta_info->ncol); |
| 667 | + dev_info(dev->mt76.dev, "nrow = %d\n", sta_info->nrow); |
| 668 | + dev_info(dev->mt76.dev, "bw = %d\n", sta_info->bw); |
| 669 | + dev_info(dev->mt76.dev, "mem_total = %d\n", sta_info->mem_total); |
| 670 | + dev_info(dev->mt76.dev, "mem_20m = %d\n", sta_info->mem_20m); |
| 671 | + dev_info(dev->mt76.dev, "mem_row0 = %d\n", sta_info->mem[0].row); |
| 672 | + dev_info(dev->mt76.dev, "mem_col0 = %d\n", sta_info->mem[0].col); |
| 673 | + dev_info(dev->mt76.dev, "mem_row1 = %d\n", sta_info->mem[1].row); |
| 674 | + dev_info(dev->mt76.dev, "mem_col1 = %d\n", sta_info->mem[1].col); |
| 675 | + dev_info(dev->mt76.dev, "mem_row2 = %d\n", sta_info->mem[2].row); |
| 676 | + dev_info(dev->mt76.dev, "mem_col2 = %d\n", sta_info->mem[2].col); |
| 677 | + dev_info(dev->mt76.dev, "mem_row3 = %d\n", sta_info->mem[3].row); |
| 678 | + dev_info(dev->mt76.dev, "mem_col3 = %d\n", sta_info->mem[3].col); |
| 679 | + dev_info(dev->mt76.dev, "smart_ant = 0x%x\n", sta_info->smart_ant); |
| 680 | + dev_info(dev->mt76.dev, "se_idx = %d\n", sta_info->se_idx); |
| 681 | + dev_info(dev->mt76.dev, "auto_sounding = %d\n", sta_info->auto_sounding); |
| 682 | + dev_info(dev->mt76.dev, "ibf_timeout = 0x%x\n", sta_info->ibf_timeout); |
| 683 | + dev_info(dev->mt76.dev, "ibf_dbw = %d\n", sta_info->ibf_dbw); |
| 684 | + dev_info(dev->mt76.dev, "ibf_ncol = %d\n", sta_info->ibf_ncol); |
| 685 | + dev_info(dev->mt76.dev, "ibf_nrow = %d\n", sta_info->ibf_nrow); |
| 686 | + dev_info(dev->mt76.dev, "nrow_gt_bw80 = %d\n", sta_info->nrow_gt_bw80); |
| 687 | + dev_info(dev->mt76.dev, "ncol_gt_bw80 = %d\n", sta_info->ncol_gt_bw80); |
| 688 | + dev_info(dev->mt76.dev, "ru_start_idx = %d\n", sta_info->ru_start_idx); |
| 689 | + dev_info(dev->mt76.dev, "trigger_su = %d\n", sta_info->trigger_su); |
| 690 | + dev_info(dev->mt76.dev, "trigger_mu = %d\n", sta_info->trigger_mu); |
| 691 | + dev_info(dev->mt76.dev, "ng16_su = %d\n", sta_info->ng16_su); |
| 692 | + dev_info(dev->mt76.dev, "ng16_mu = %d\n", sta_info->ng16_mu); |
| 693 | + dev_info(dev->mt76.dev, "codebook42_su = %d\n", sta_info->codebook42_su); |
| 694 | + dev_info(dev->mt76.dev, "codebook75_mu = %d\n", sta_info->codebook75_mu); |
| 695 | + dev_info(dev->mt76.dev, "he_ltf = %d\n", sta_info->he_ltf); |
| 696 | + dev_info(dev->mt76.dev, "=============================================================\n"); |
| 697 | +} |
| 698 | + |
| 699 | +static void mt7915_txbf_dump_cal_phase(struct mt7915_dev *dev, |
| 700 | + struct mt7915_txbf_phase *phase, int group) |
| 701 | +{ |
| 702 | + dev_info(dev->mt76.dev, "Group %d and Group M\n", group); |
| 703 | + dev_info(dev->mt76.dev, "m_t0_h = %d\n", phase->phase.m_t0_h); |
| 704 | + dev_info(dev->mt76.dev, "m_t1_h = %d\n", phase->phase.m_t1_h); |
| 705 | + dev_info(dev->mt76.dev, "m_t2_h = %d\n", phase->phase.m_t2_h); |
| 706 | + |
| 707 | + dev_info(dev->mt76.dev, "r0_uh = %d\n", phase->phase.r0_uh); |
| 708 | + dev_info(dev->mt76.dev, "r0_h = %d\n", phase->phase.r0_h); |
| 709 | + dev_info(dev->mt76.dev, "r0_m = %d\n", phase->phase.r0_m); |
| 710 | + dev_info(dev->mt76.dev, "r0_l = %d\n", phase->phase.r0_l); |
| 711 | + |
| 712 | + dev_info(dev->mt76.dev, "r1_uh = %d\n", phase->phase.r1_uh); |
| 713 | + dev_info(dev->mt76.dev, "r1_h = %d\n", phase->phase.r1_h); |
| 714 | + dev_info(dev->mt76.dev, "r1_m = %d\n", phase->phase.r1_m); |
| 715 | + dev_info(dev->mt76.dev, "r1_l = %d\n", phase->phase.r1_l); |
| 716 | + |
| 717 | + dev_info(dev->mt76.dev, "r2_uh = %d\n", phase->phase.r2_uh); |
| 718 | + dev_info(dev->mt76.dev, "r2_h = %d\n", phase->phase.r2_h); |
| 719 | + dev_info(dev->mt76.dev, "r2_m = %d\n", phase->phase.r2_m); |
| 720 | + dev_info(dev->mt76.dev, "r2_l = %d\n", phase->phase.r2_l); |
| 721 | + |
| 722 | + dev_info(dev->mt76.dev, "r3_uh = %d\n", phase->phase.r3_uh); |
| 723 | + dev_info(dev->mt76.dev, "r3_h = %d\n", phase->phase.r3_h); |
| 724 | + dev_info(dev->mt76.dev, "r3_m = %d\n", phase->phase.r3_m); |
| 725 | + dev_info(dev->mt76.dev, "r3_l = %d\n", phase->phase.r3_l); |
| 726 | + dev_info(dev->mt76.dev, "r3_ul = %d\n", phase->phase.r3_ul); |
| 727 | +} |
| 728 | + |
| 729 | +int mt7915_mcu_txbf_status_read(struct mt7915_dev *dev, struct sk_buff *skb) |
| 730 | +{ |
| 731 | +#define BF_PFMU_TAG 16 |
| 732 | +#define BF_STA_REC 20 |
| 733 | +#define BF_CAL_PHASE 21 |
| 734 | +#define GROUP_M 1 |
| 735 | + u8 format_id; |
| 736 | + |
| 737 | + skb_pull(skb, sizeof(struct mt76_connac2_mcu_rxd)); |
| 738 | + format_id = *(u8 *)skb->data; |
| 739 | + |
| 740 | + if (format_id == BF_PFMU_TAG) { |
| 741 | + struct mt7915_pfmu_tag *pfmu_tag; |
| 742 | + |
| 743 | + skb_pull(skb, 8); |
| 744 | + pfmu_tag = (struct mt7915_pfmu_tag *)skb->data; |
| 745 | + mt7915_txbf_dump_pfmu_tag(dev, pfmu_tag); |
| 746 | + if (dev->test.txbf_pfmu_tag) |
| 747 | + memcpy(dev->test.txbf_pfmu_tag, pfmu_tag, sizeof(struct mt7915_pfmu_tag)); |
| 748 | + } else if (format_id == BF_STA_REC) { |
| 749 | + struct sta_rec_bf *sta_rec; |
| 750 | + |
| 751 | + skb_pull(skb, sizeof(struct mt7915_bf_status_hdr)); |
| 752 | + /* padding 4 byte since bf_status->buf does not contain tag & len */ |
| 753 | + skb_push(skb, 4); |
| 754 | + sta_rec = (struct sta_rec_bf *)skb->data; |
| 755 | + |
| 756 | + mt7915_txbf_dump_sta_rec(dev, sta_rec); |
| 757 | + } else if (format_id == BF_CAL_PHASE) { |
| 758 | + u8 phase_out_len = sizeof(struct mt7915_txbf_phase_out); |
| 759 | + struct mt7915_ibf_cal_info *cal; |
| 760 | + struct mt7915_txbf_phase_out phase_out; |
| 761 | + struct mt7915_txbf_phase *phase = |
| 762 | + (struct mt7915_txbf_phase *)dev->test.txbf_phase_cal; |
| 763 | + |
| 764 | + cal = (struct mt7915_ibf_cal_info *)skb->data; |
| 765 | + memcpy(&phase_out, cal->buf, phase_out_len); |
| 766 | + switch (cal->cal_type) { |
| 767 | + case IBF_PHASE_CAL_NORMAL: |
| 768 | + case IBF_PHASE_CAL_NORMAL_INSTRUMENT: |
| 769 | + /* Only calibrate group M */ |
| 770 | + if (cal->group_l_m_n != GROUP_M) |
| 771 | + break; |
| 772 | + phase = &phase[cal->group]; |
| 773 | + memcpy(&phase->phase, cal->buf + phase_out_len, sizeof(phase->phase)); |
| 774 | + phase->status = cal->status; |
| 775 | + |
| 776 | + dev_info(dev->mt76.dev, "Calibrated result = %d\n", phase->status); |
| 777 | + mt7915_txbf_dump_cal_phase(dev, phase, cal->group); |
| 778 | + break; |
| 779 | + case IBF_PHASE_CAL_VERIFY: |
| 780 | + case IBF_PHASE_CAL_VERIFY_INSTRUMENT: |
| 781 | + dev_info(dev->mt76.dev, "Verification result = %d\n", cal->status); |
| 782 | + break; |
| 783 | + default: |
| 784 | + break; |
| 785 | + } |
| 786 | + |
| 787 | + dev_info(dev->mt76.dev, "c0_h = %d, c1_h = %d, c2_h = %d\n", |
| 788 | + phase_out.c0_h, phase_out.c1_h, phase_out.c2_h); |
| 789 | + dev_info(dev->mt76.dev, "c0_m = %d, c1_m = %d, c2_m = %d\n", |
| 790 | + phase_out.c0_m, phase_out.c1_m, phase_out.c2_m); |
| 791 | + dev_info(dev->mt76.dev, "c0_l = %d, c1_l = %d, c2_l = %d\n", |
| 792 | + phase_out.c0_l, phase_out.c1_l, phase_out.c2_l); |
| 793 | + dev_info(dev->mt76.dev, "c3_m = %d, c3_h = %d\n", phase_out.c3_m, phase_out.c3_h); |
| 794 | + } |
| 795 | + |
| 796 | + wake_up(&dev->mt76.tx_wait); |
| 797 | + |
| 798 | + return 0; |
| 799 | +} |
| 800 | + |
| 801 | +int mt7915_mcu_txbf_profile_tag_read(struct mt7915_phy *phy, u8 pfmu_idx, bool bfer) |
| 802 | +{ |
| 803 | + struct mt7915_dev *dev = phy->dev; |
| 804 | + struct { |
| 805 | + u8 format_id; |
| 806 | + u8 pfmu_idx; |
| 807 | + bool bfer; |
| 808 | + u8 dbdc_idx; |
| 809 | + } __packed req = { |
| 810 | + .format_id = MT_BF_PFMU_TAG_READ, |
| 811 | + .pfmu_idx = pfmu_idx, |
| 812 | + .bfer = bfer, |
| 813 | + .dbdc_idx = phy->mt76->band_idx, |
| 814 | + }; |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 815 | + struct mt7915_pfmu_tag *tag = dev->test.txbf_pfmu_tag; |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 816 | + |
| 817 | + /* Reset to 0 for mt7915_tm_txbf_profile_tag_write wait_event */ |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 818 | + if (tag) |
| 819 | + tag->t1.pfmu_idx = 0; |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 820 | + |
| 821 | + return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(TXBF_ACTION), &req, |
| 822 | + sizeof(req), true); |
| 823 | +} |
| 824 | + |
| 825 | +int mt7915_mcu_txbf_sta_rec_read(struct mt7915_dev *dev, u16 wlan_idx) |
| 826 | +{ |
| 827 | + struct { |
| 828 | + u8 action; |
| 829 | + u8 wlan_idx_lo; |
| 830 | + u8 wlan_idx_hi; |
| 831 | + u8 rsv[5]; |
| 832 | + } __packed req = { |
| 833 | + .action = MT_BF_STA_REC_READ, |
| 834 | + .wlan_idx_lo = to_wcid_lo(wlan_idx), |
| 835 | + .wlan_idx_hi = to_wcid_hi(wlan_idx), |
| 836 | + }; |
| 837 | + |
| 838 | + return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(TXBF_ACTION), &req, |
| 839 | + sizeof(req), true); |
| 840 | +} |
| 841 | +#endif |
| 842 | diff --git a/mt7915/regs.h b/mt7915/regs.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 843 | index 7e9b76b0..4d05e391 100644 |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 844 | --- a/mt7915/regs.h |
| 845 | +++ b/mt7915/regs.h |
| 846 | @@ -61,6 +61,7 @@ enum offs_rev { |
| 847 | MDP_BNRCFR1, |
| 848 | ARB_DRNGR0, |
| 849 | ARB_SCR, |
| 850 | + ARB_TQSAXM0, |
| 851 | RMAC_MIB_AIRTIME14, |
| 852 | AGG_AALCR0, |
| 853 | AGG_AWSCR0, |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 854 | @@ -534,6 +535,9 @@ enum offs_rev { |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 855 | #define MT_ARB_DRNGR0(_band, _n) MT_WF_ARB(_band, (__OFFS(ARB_DRNGR0) + \ |
| 856 | (_n) * 4)) |
| 857 | |
| 858 | +#define MT_ARB_TQSAXM0(_band) MT_WF_ARB(_band, __OFFS(ARB_TQSAXM0)) |
| 859 | +#define MT_ARB_TQSAXM_ALTX_START_MASK GENMASK(12, 8) |
| 860 | + |
| 861 | /* RMAC: band 0(0x820e5000), band 1(0x820f5000) */ |
| 862 | #define MT_WF_RMAC_BASE(_band) ((_band) ? 0x820f5000 : 0x820e5000) |
| 863 | #define MT_WF_RMAC(_band, ofs) (MT_WF_RMAC_BASE(_band) + (ofs)) |
| 864 | diff --git a/mt7915/testmode.c b/mt7915/testmode.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 865 | index caa35906..faf60146 100644 |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 866 | --- a/mt7915/testmode.c |
| 867 | +++ b/mt7915/testmode.c |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 868 | @@ -55,6 +55,8 @@ struct reg_band { |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 869 | static struct reg_band reg_backup_list[TM_REG_MAX_ID]; |
| 870 | |
| 871 | static void mt7915_tm_update_entry(struct mt7915_phy *phy); |
| 872 | +static int mt7915_tm_set_ipg_params(struct mt7915_phy *phy, u32 ipg, u8 mode, bool bf_sounding); |
| 873 | +static int mt7915_tm_txbf_set_rate(struct mt7915_phy *phy, struct mt76_wcid *wcid); |
| 874 | |
| 875 | static u8 mt7915_tm_chan_bw(enum nl80211_chan_width width) |
| 876 | { |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 877 | @@ -94,6 +96,25 @@ mt7915_tm_check_antenna(struct mt7915_phy *phy) |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 878 | return 0; |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 879 | } |
| 880 | |
| 881 | +static u8 mt7915_tm_rate_to_phy(u8 tx_rate_mode) |
| 882 | +{ |
| 883 | + static const u8 rate_to_phy[] = { |
| 884 | + [MT76_TM_TX_MODE_CCK] = MT_PHY_TYPE_CCK, |
| 885 | + [MT76_TM_TX_MODE_OFDM] = MT_PHY_TYPE_OFDM, |
| 886 | + [MT76_TM_TX_MODE_HT] = MT_PHY_TYPE_HT, |
| 887 | + [MT76_TM_TX_MODE_VHT] = MT_PHY_TYPE_VHT, |
| 888 | + [MT76_TM_TX_MODE_HE_SU] = MT_PHY_TYPE_HE_SU, |
| 889 | + [MT76_TM_TX_MODE_HE_EXT_SU] = MT_PHY_TYPE_HE_EXT_SU, |
| 890 | + [MT76_TM_TX_MODE_HE_TB] = MT_PHY_TYPE_HE_TB, |
| 891 | + [MT76_TM_TX_MODE_HE_MU] = MT_PHY_TYPE_HE_MU, |
| 892 | + }; |
| 893 | + |
| 894 | + if (tx_rate_mode > MT76_TM_TX_MODE_MAX) |
| 895 | + return -EINVAL; |
| 896 | + |
| 897 | + return rate_to_phy[tx_rate_mode]; |
| 898 | +} |
| 899 | + |
| 900 | static void |
| 901 | mt7915_tm_update_channel(struct mt7915_phy *phy) |
| 902 | { |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 903 | @@ -294,17 +315,33 @@ mt7915_tm_add_txbf(struct mt7915_phy *phy, struct ieee80211_vif *vif, |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 904 | struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; |
| 905 | struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; |
| 906 | struct mt7915_dev *dev = phy->dev; |
| 907 | + struct mt76_testmode_data *td = &phy->mt76->test; |
| 908 | struct sk_buff *skb; |
| 909 | struct sta_rec_bf *bf; |
| 910 | struct tlv *tlv; |
| 911 | - u8 ndp_rate; |
| 912 | + u8 ndp_rate, ndpa_rate, rept_poll_rate, bf_bw; |
| 913 | + |
| 914 | + if (td->tx_rate_mode == MT76_TM_TX_MODE_HE_SU) { |
| 915 | + rept_poll_rate = 0x49; |
| 916 | + ndpa_rate = 0x49; |
| 917 | + ndp_rate = 0; |
| 918 | + } else if (td->tx_rate_mode == MT76_TM_TX_MODE_VHT) { |
| 919 | + rept_poll_rate = 0x9; |
| 920 | + ndpa_rate = 0x9; |
| 921 | + ndp_rate = 0; |
| 922 | + } else { |
| 923 | + rept_poll_rate = 0; |
| 924 | + ndpa_rate = 0; |
| 925 | + if (nr == 1) |
| 926 | + ndp_rate = 8; |
| 927 | + else if (nr == 2) |
| 928 | + ndp_rate = 16; |
| 929 | + else |
| 930 | + ndp_rate = 24; |
| 931 | + } |
| 932 | |
| 933 | - if (nr == 1) |
| 934 | - ndp_rate = 8; |
| 935 | - else if (nr == 2) |
| 936 | - ndp_rate = 16; |
| 937 | - else |
| 938 | - ndp_rate = 24; |
developer | dad04b1 | 2022-12-22 16:47:31 +0800 | [diff] [blame] | 939 | + /* BF use CMD_CBW instead of TM_CBW */ |
| 940 | + bf_bw = mt76_connac_chan_bw(&phy->mt76->chandef); |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 941 | |
| 942 | skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, |
| 943 | &msta->wcid); |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 944 | @@ -320,8 +357,11 @@ mt7915_tm_add_txbf(struct mt7915_phy *phy, struct ieee80211_vif *vif, |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 945 | bf->ncol = nc; |
| 946 | bf->nrow = nr; |
| 947 | bf->ndp_rate = ndp_rate; |
| 948 | + bf->ndpa_rate = ndpa_rate; |
| 949 | + bf->rept_poll_rate = rept_poll_rate; |
| 950 | + bf->bw = bf_bw; |
| 951 | bf->ibf_timeout = 0xff; |
| 952 | - bf->tx_mode = MT_PHY_TYPE_HT; |
| 953 | + bf->tx_mode = mt7915_tm_rate_to_phy(td->tx_rate_mode); |
| 954 | |
| 955 | if (ebf) { |
| 956 | bf->mem[0].row = 0; |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 957 | @@ -374,11 +414,8 @@ mt7915_tm_entry_add(struct mt7915_phy *phy, u8 aid) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 958 | } |
| 959 | |
| 960 | memcpy(sta->addr, ed->addr[0], ETH_ALEN); |
| 961 | - if (phy->test.bf_en) { |
| 962 | - u8 addr[ETH_ALEN] = {0x00, 0x11, 0x11, 0x11, 0x11, 0x11}; |
| 963 | - |
| 964 | - memcpy(sta->addr, addr, ETH_ALEN); |
| 965 | - } |
| 966 | + if (td->bf_en) |
| 967 | + memcpy(sta->addr, td->addr[0], ETH_ALEN); |
| 968 | |
| 969 | if (td->tx_rate_mode >= MT76_TM_TX_MODE_HT) |
| 970 | memcpy(&sta->deflink.ht_cap, &sband->ht_cap, sizeof(sta->deflink.ht_cap)); |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 971 | @@ -403,6 +440,14 @@ mt7915_tm_entry_add(struct mt7915_phy *phy, u8 aid) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 972 | list_add_tail(&msta->wcid.list, &td->tm_entry_list); |
| 973 | td->entry_num++; |
| 974 | |
| 975 | + mt7915_mcu_add_bss_info(phy, phy->monitor_vif, true); |
| 976 | + |
| 977 | + if (td->bf_en) { |
| 978 | + mt7915_tm_set_ipg_params(phy, td->tx_ipg, td->tx_rate_mode, true); |
| 979 | + mt7915_tm_set_tam_arb(phy, td->bf_en, 0); |
| 980 | + mt7915_tm_txbf_set_rate(phy, &msta->wcid); |
| 981 | + } |
| 982 | + |
| 983 | return 0; |
| 984 | } |
| 985 | |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 986 | @@ -472,7 +517,7 @@ mt7915_tm_update_entry(struct mt7915_phy *phy) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 987 | struct mt76_testmode_entry_data *ed, tmp; |
| 988 | struct mt76_wcid *wcid, *last; |
| 989 | |
| 990 | - if (!td->aid || phy->test.bf_en) |
| 991 | + if (!td->aid || td->bf_en) |
| 992 | return; |
| 993 | |
| 994 | memcpy(&tmp, &td->ed, sizeof(tmp)); |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 995 | @@ -493,20 +538,30 @@ mt7915_tm_update_entry(struct mt7915_phy *phy) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 996 | static int |
| 997 | mt7915_tm_txbf_init(struct mt7915_phy *phy, u16 *val) |
| 998 | { |
| 999 | +#define EBF_BBP_RX_OFFSET 0x10280 |
| 1000 | +#define EBF_BBP_RX_ENABLE (BIT(0) | BIT(15)) |
developer | dad04b1 | 2022-12-22 16:47:31 +0800 | [diff] [blame] | 1001 | +#define WF1 1 |
| 1002 | +#define WF2 2 |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1003 | struct mt76_testmode_data *td = &phy->mt76->test; |
| 1004 | struct mt7915_dev *dev = phy->dev; |
| 1005 | + struct mt76_phy *mphy = phy->mt76; |
| 1006 | bool enable = val[0]; |
| 1007 | void *phase_cal, *pfmu_data, *pfmu_tag; |
| 1008 | - u8 addr[ETH_ALEN] = {0x00, 0x22, 0x22, 0x22, 0x22, 0x22}; |
| 1009 | + u8 sub_addr = td->is_txbf_dut ? TXBF_DUT_MAC_SUBADDR : TXBF_GOLDEN_MAC_SUBADDR; |
| 1010 | + u8 peer_addr = td->is_txbf_dut ? TXBF_GOLDEN_MAC_SUBADDR : TXBF_DUT_MAC_SUBADDR; |
| 1011 | + u8 bss_addr = TXBF_DUT_MAC_SUBADDR; |
| 1012 | + u8 addr[ETH_ALEN] = {0x00, sub_addr, sub_addr, sub_addr, sub_addr, sub_addr}; |
| 1013 | + u8 bssid[ETH_ALEN] = {0x00, bss_addr, bss_addr, bss_addr, bss_addr, bss_addr}; |
| 1014 | + u8 peer_addrs[ETH_ALEN] = {0x00, peer_addr, peer_addr, peer_addr, peer_addr, peer_addr}; |
| 1015 | |
| 1016 | if (!enable) { |
| 1017 | - phy->test.bf_en = 0; |
| 1018 | + td->bf_en = 0; |
| 1019 | return 0; |
| 1020 | } |
| 1021 | |
| 1022 | if (!dev->test.txbf_phase_cal) { |
| 1023 | phase_cal = devm_kzalloc(dev->mt76.dev, |
| 1024 | - sizeof(struct mt7915_tm_txbf_phase) * |
| 1025 | + sizeof(struct mt7915_txbf_phase) * |
| 1026 | MAX_PHASE_GROUP_NUM, |
| 1027 | GFP_KERNEL); |
| 1028 | if (!phase_cal) |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1029 | @@ -516,7 +571,10 @@ mt7915_tm_txbf_init(struct mt7915_phy *phy, u16 *val) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1030 | } |
| 1031 | |
| 1032 | if (!dev->test.txbf_pfmu_data) { |
| 1033 | - pfmu_data = devm_kzalloc(dev->mt76.dev, 512, GFP_KERNEL); |
| 1034 | + pfmu_data = devm_kzalloc(dev->mt76.dev, |
| 1035 | + sizeof(struct mt7915_pfmu_data) * |
| 1036 | + MT7915_TXBF_SUBCAR_NUM, |
| 1037 | + GFP_KERNEL); |
| 1038 | if (!pfmu_data) |
| 1039 | return -ENOMEM; |
| 1040 | |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1041 | @@ -525,21 +583,77 @@ mt7915_tm_txbf_init(struct mt7915_phy *phy, u16 *val) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1042 | |
| 1043 | if (!dev->test.txbf_pfmu_tag) { |
| 1044 | pfmu_tag = devm_kzalloc(dev->mt76.dev, |
| 1045 | - sizeof(struct mt7915_tm_pfmu_tag), GFP_KERNEL); |
| 1046 | + sizeof(struct mt7915_pfmu_tag), GFP_KERNEL); |
| 1047 | if (!pfmu_tag) |
| 1048 | return -ENOMEM; |
| 1049 | |
| 1050 | dev->test.txbf_pfmu_tag = pfmu_tag; |
| 1051 | } |
| 1052 | |
| 1053 | + td->bf_en = 1; |
| 1054 | + memcpy(td->addr[0], peer_addrs, ETH_ALEN); |
| 1055 | + memcpy(td->addr[1], addr, ETH_ALEN); |
| 1056 | + memcpy(td->addr[2], bssid, ETH_ALEN); |
| 1057 | memcpy(phy->monitor_vif->addr, addr, ETH_ALEN); |
| 1058 | mt7915_mcu_add_dev_info(phy, phy->monitor_vif, true); |
| 1059 | |
| 1060 | - td->tx_rate_mode = MT76_TM_TX_MODE_HT; |
| 1061 | - td->tx_mpdu_len = 1024; |
| 1062 | - td->tx_rate_sgi = 0; |
| 1063 | - td->tx_ipg = 100; |
| 1064 | - phy->test.bf_en = 1; |
| 1065 | + /* Add second interface in wtbl for using TXCMD to transmit sounding */ |
| 1066 | + td->second_vif = kzalloc(sizeof(*td->second_vif) + sizeof(struct mt7915_vif), GFP_KERNEL); |
| 1067 | + memcpy(td->second_vif, phy->monitor_vif, sizeof(*td->second_vif)); |
| 1068 | + mt7915_init_vif(phy, td->second_vif, td->bf_en); |
| 1069 | + |
| 1070 | + if (td->ebf && !td->is_txbf_dut) { |
developer | dad04b1 | 2022-12-22 16:47:31 +0800 | [diff] [blame] | 1071 | + u8 is_160hz = val[1]; |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1072 | + |
| 1073 | + /* Turn On BBP CR for RX */ |
| 1074 | + mt76_set(dev, EBF_BBP_RX_OFFSET, EBF_BBP_RX_ENABLE); |
| 1075 | + dev_info(dev->mt76.dev, "Set BBP RX CR = %x\n", mt76_rr(dev, EBF_BBP_RX_OFFSET)); |
| 1076 | + |
| 1077 | + /* Set TX antenna mask of golden: default use WF0 only */ |
| 1078 | + td->tx_antenna_mask = 1; |
| 1079 | + if (is_mt7915(&dev->mt76)) { |
| 1080 | + /* Add WF1/WF2 for dbdc/single band in BW 160 */ |
developer | dad04b1 | 2022-12-22 16:47:31 +0800 | [diff] [blame] | 1081 | + td->tx_antenna_mask |= is_160hz << (dev->dbdc_support ? WF1 : WF2); |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1082 | + /* Shift to WF2/WF3 for dbdc band 1 */ |
| 1083 | + td->tx_antenna_mask <<= 2 * phy->mt76->band_idx; |
| 1084 | + } |
| 1085 | + } else if (td->ebf && td->is_txbf_dut) { |
| 1086 | + /* Enable ETxBF Capability */ |
| 1087 | + dev->ibf = false; |
| 1088 | + mt7915_mcu_set_txbf(dev, MT_BF_TYPE_UPDATE); |
| 1089 | + /* Set TX antenna mask of DUT */ |
| 1090 | + td->tx_antenna_mask = mphy->chainmask >> (dev->chainshift * phy->mt76->band_idx); |
| 1091 | + td->tx_spe_idx = phy->mt76->band_idx ? 25 : 24; |
| 1092 | + /* Shift to WF2/WF3 for dbdc band 1, Nss = 2 */ |
| 1093 | + if ((hweight8(td->tx_antenna_mask) == 2) && phy->mt76->band_idx) |
| 1094 | + td->tx_antenna_mask <<= 2; |
| 1095 | + } else { |
| 1096 | + if (td->is_txbf_dut) { |
| 1097 | + int nss; |
| 1098 | + |
| 1099 | + /* Enable ITxBF Capability */ |
| 1100 | + dev->ibf = true; |
| 1101 | + mt7915_mcu_set_txbf(dev, MT_BF_TYPE_UPDATE); |
| 1102 | + td->tx_antenna_mask = mphy->chainmask >> (dev->chainshift * |
| 1103 | + phy->mt76->band_idx); |
| 1104 | + nss = hweight8(td->tx_antenna_mask); |
| 1105 | + if (nss > 1 && nss <= 4) |
| 1106 | + td->tx_rate_idx = 15 + 8 * (nss - 2); |
| 1107 | + else |
| 1108 | + td->tx_rate_idx = 31; |
| 1109 | + } else { |
| 1110 | + td->tx_antenna_mask = 1; |
| 1111 | + mt76_set(dev, EBF_BBP_RX_OFFSET, EBF_BBP_RX_ENABLE); |
| 1112 | + dev_info(dev->mt76.dev, "Set BBP RX CR = %x\n", |
| 1113 | + mt76_rr(dev, EBF_BBP_RX_OFFSET)); |
| 1114 | + } |
| 1115 | + td->tx_rate_mode = MT76_TM_TX_MODE_HT; |
| 1116 | + td->tx_mpdu_len = 1024; |
| 1117 | + td->tx_rate_sgi = 0; |
| 1118 | + td->tx_ipg = 100; |
| 1119 | + } |
| 1120 | + |
| 1121 | + mt7915_mcu_add_bss_info(phy, phy->monitor_vif, true); |
| 1122 | |
| 1123 | return mt7915_tm_set_trx(phy, TM_MAC_TX, true); |
| 1124 | } |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1125 | @@ -566,8 +680,7 @@ mt7915_tm_txbf_phase_comp(struct mt7915_phy *phy, u16 *val) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1126 | .read_from_e2p = val[3], |
| 1127 | .disable = val[4], |
| 1128 | }; |
| 1129 | - struct mt7915_tm_txbf_phase *phase = |
| 1130 | - (struct mt7915_tm_txbf_phase *)dev->test.txbf_phase_cal; |
| 1131 | + struct mt7915_txbf_phase *phase = (struct mt7915_txbf_phase *)dev->test.txbf_phase_cal; |
| 1132 | |
| 1133 | wait_event_timeout(dev->mt76.tx_wait, phase[val[2]].status != 0, HZ); |
| 1134 | memcpy(req.buf, &phase[val[2]].phase, sizeof(req.buf)); |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1135 | @@ -580,32 +693,9 @@ mt7915_tm_txbf_phase_comp(struct mt7915_phy *phy, u16 *val) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1136 | sizeof(req), true); |
| 1137 | } |
| 1138 | |
| 1139 | -static int |
| 1140 | -mt7915_tm_txbf_profile_tag_read(struct mt7915_phy *phy, u8 pfmu_idx) |
| 1141 | -{ |
| 1142 | - struct mt7915_dev *dev = phy->dev; |
| 1143 | - struct { |
| 1144 | - u8 format_id; |
| 1145 | - u8 pfmu_idx; |
| 1146 | - bool bfer; |
| 1147 | - u8 dbdc_idx; |
| 1148 | - } __packed req = { |
| 1149 | - .format_id = MT_BF_PFMU_TAG_READ, |
| 1150 | - .pfmu_idx = pfmu_idx, |
| 1151 | - .bfer = 1, |
| 1152 | - .dbdc_idx = phy != &dev->phy, |
| 1153 | - }; |
| 1154 | - struct mt7915_tm_pfmu_tag *tag = phy->dev->test.txbf_pfmu_tag; |
| 1155 | - |
| 1156 | - tag->t1.pfmu_idx = 0; |
| 1157 | - |
| 1158 | - return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(TXBF_ACTION), &req, |
| 1159 | - sizeof(req), true); |
| 1160 | -} |
| 1161 | - |
| 1162 | static int |
| 1163 | mt7915_tm_txbf_profile_tag_write(struct mt7915_phy *phy, u8 pfmu_idx, |
| 1164 | - struct mt7915_tm_pfmu_tag *tag) |
| 1165 | + struct mt7915_pfmu_tag *tag) |
| 1166 | { |
| 1167 | struct mt7915_dev *dev = phy->dev; |
| 1168 | struct { |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1169 | @@ -632,8 +722,6 @@ static int |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1170 | mt7915_tm_txbf_apply_tx(struct mt7915_phy *phy, u16 wlan_idx, bool ebf, |
| 1171 | bool ibf, bool phase_cal) |
| 1172 | { |
| 1173 | -#define to_wcid_lo(id) FIELD_GET(GENMASK(7, 0), (u16)id) |
| 1174 | -#define to_wcid_hi(id) FIELD_GET(GENMASK(9, 8), (u16)id) |
| 1175 | struct mt7915_dev *dev = phy->dev; |
| 1176 | struct { |
| 1177 | u8 category; |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1178 | @@ -662,14 +750,15 @@ static int mt7915_tm_txbf_set_rate(struct mt7915_phy *phy, |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1179 | { |
| 1180 | struct mt7915_dev *dev = phy->dev; |
| 1181 | struct mt76_testmode_entry_data *ed = mt76_testmode_entry_data(phy->mt76, wcid); |
| 1182 | + struct mt76_testmode_data *td = &phy->mt76->test; |
| 1183 | struct ieee80211_sta *sta = wcid_to_sta(wcid); |
| 1184 | struct sta_phy rate = {}; |
| 1185 | |
| 1186 | if (!sta) |
| 1187 | return 0; |
| 1188 | |
| 1189 | - rate.type = MT_PHY_TYPE_HT; |
| 1190 | - rate.bw = mt7915_tm_chan_bw(phy->mt76->chandef.width); |
| 1191 | + rate.type = mt7915_tm_rate_to_phy(td->tx_rate_mode); |
developer | dad04b1 | 2022-12-22 16:47:31 +0800 | [diff] [blame] | 1192 | + rate.bw = mt76_connac_chan_bw(&phy->mt76->chandef); |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1193 | rate.nss = ed->tx_rate_nss; |
| 1194 | rate.mcs = ed->tx_rate_idx; |
| 1195 | rate.ldpc = (rate.bw || ed->tx_rate_ldpc) * GENMASK(2, 0); |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1196 | @@ -683,13 +772,14 @@ mt7915_tm_txbf_set_tx(struct mt7915_phy *phy, u16 *val) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1197 | { |
| 1198 | bool bf_on = val[0], update = val[3]; |
| 1199 | /* u16 wlan_idx = val[2]; */ |
| 1200 | - struct mt7915_tm_pfmu_tag *tag = phy->dev->test.txbf_pfmu_tag; |
| 1201 | + struct mt7915_dev *dev = phy->dev; |
| 1202 | + struct mt7915_pfmu_tag *tag = dev->test.txbf_pfmu_tag; |
| 1203 | struct mt76_testmode_data *td = &phy->mt76->test; |
| 1204 | struct mt76_wcid *wcid; |
| 1205 | |
| 1206 | if (bf_on) { |
| 1207 | mt7915_tm_set_trx(phy, TM_MAC_RX_RXV, false); |
| 1208 | - mt7915_tm_txbf_profile_tag_read(phy, 2); |
| 1209 | + mt7915_mcu_txbf_profile_tag_read(phy, 2, true); |
| 1210 | tag->t1.invalid_prof = false; |
| 1211 | mt7915_tm_txbf_profile_tag_write(phy, 2, tag); |
| 1212 | |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1213 | @@ -704,7 +794,7 @@ mt7915_tm_txbf_set_tx(struct mt7915_phy *phy, u16 *val) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1214 | } else { |
| 1215 | phy->test.bf_ever_en = false; |
| 1216 | |
| 1217 | - mt7915_tm_txbf_profile_tag_read(phy, 2); |
| 1218 | + mt7915_mcu_txbf_profile_tag_read(phy, 2, true); |
| 1219 | tag->t1.invalid_prof = true; |
| 1220 | mt7915_tm_txbf_profile_tag_write(phy, 2, tag); |
| 1221 | } |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1222 | @@ -719,6 +809,7 @@ mt7915_tm_txbf_set_tx(struct mt7915_phy *phy, u16 *val) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1223 | static int |
| 1224 | mt7915_tm_txbf_profile_update(struct mt7915_phy *phy, u16 *val, bool ebf) |
| 1225 | { |
| 1226 | +#define MT_ARB_IBF_ENABLE (BIT(0) | GENMASK(9, 8)) |
| 1227 | static const u8 mode_to_lm[] = { |
| 1228 | [MT76_TM_TX_MODE_CCK] = 0, |
| 1229 | [MT76_TM_TX_MODE_OFDM] = 0, |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1230 | @@ -732,7 +823,8 @@ mt7915_tm_txbf_profile_update(struct mt7915_phy *phy, u16 *val, bool ebf) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1231 | struct mt76_testmode_data *td = &phy->mt76->test; |
| 1232 | struct mt76_wcid *wcid; |
| 1233 | struct ieee80211_vif *vif = phy->monitor_vif; |
| 1234 | - struct mt7915_tm_pfmu_tag *tag = phy->dev->test.txbf_pfmu_tag; |
| 1235 | + struct mt7915_dev *dev = phy->dev; |
| 1236 | + struct mt7915_pfmu_tag *tag = dev->test.txbf_pfmu_tag; |
| 1237 | u8 pfmu_idx = val[0], nc = val[2], nr; |
| 1238 | bool is_atenl = val[6]; |
| 1239 | int ret; |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1240 | @@ -750,18 +842,22 @@ mt7915_tm_txbf_profile_update(struct mt7915_phy *phy, u16 *val, bool ebf) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1241 | tag->t1.nr = nr; |
| 1242 | tag->t1.nc = nc; |
| 1243 | tag->t1.invalid_prof = true; |
| 1244 | - |
| 1245 | - tag->t1.snr_sts4 = 0xc0; |
| 1246 | - tag->t1.snr_sts5 = 0xff; |
| 1247 | - tag->t1.snr_sts6 = 0xff; |
| 1248 | - tag->t1.snr_sts7 = 0xff; |
developer | dad04b1 | 2022-12-22 16:47:31 +0800 | [diff] [blame] | 1249 | + tag->t1.data_bw = mt76_connac_chan_bw(&phy->mt76->chandef); |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1250 | + tag->t2.se_idx = td->tx_spe_idx; |
| 1251 | + |
| 1252 | + if (is_atenl) { |
| 1253 | + tag->t1.snr_sts4 = 0xc0; |
| 1254 | + tag->t1.snr_sts5 = 0xff; |
| 1255 | + tag->t1.snr_sts6 = 0xff; |
| 1256 | + tag->t1.snr_sts7 = 0xff; |
| 1257 | + } |
| 1258 | |
| 1259 | if (ebf) { |
| 1260 | tag->t1.row_id1 = 0; |
developer | dad04b1 | 2022-12-22 16:47:31 +0800 | [diff] [blame] | 1261 | tag->t1.row_id2 = 1; |
| 1262 | tag->t1.row_id3 = 2; |
| 1263 | tag->t1.row_id4 = 3; |
| 1264 | - tag->t1.lm = mode_to_lm[MT76_TM_TX_MODE_HT]; |
| 1265 | + tag->t1.lm = mode_to_lm[td->tx_rate_mode]; |
| 1266 | } else { |
| 1267 | tag->t1.row_id1 = 4; |
| 1268 | tag->t1.row_id2 = 5; |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1269 | @@ -782,6 +878,20 @@ mt7915_tm_txbf_profile_update(struct mt7915_phy *phy, u16 *val, bool ebf) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1270 | if (ret) |
| 1271 | return ret; |
| 1272 | |
| 1273 | + if (td->ebf) { |
| 1274 | + mt76_set(dev, MT_ARB_TQSAXM0(phy->mt76->band_idx), MT_ARB_TQSAXM_ALTX_START_MASK); |
| 1275 | + dev_info(dev->mt76.dev, "Set TX queue start CR for AX management (0x%x) = 0x%x\n", |
| 1276 | + MT_ARB_TQSAXM0(phy->mt76->band_idx), |
| 1277 | + mt76_rr(dev, MT_ARB_TQSAXM0(phy->mt76->band_idx))); |
| 1278 | + } else if (!td->ebf && ebf) { |
| 1279 | + /* iBF's ebf profile update */ |
developer | f0fd705 | 2023-08-14 20:23:42 +0800 | [diff] [blame] | 1280 | + if (!is_mt7915(&dev->mt76) || !dev->dbdc_support) |
| 1281 | + mt76_set(dev, MT_ARB_TQSAXM0(phy->mt76->band_idx), MT_ARB_IBF_ENABLE); |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1282 | + dev_info(dev->mt76.dev, "Set TX queue start CR for AX management (0x%x) = 0x%x\n", |
| 1283 | + MT_ARB_TQSAXM0(phy->mt76->band_idx), |
| 1284 | + mt76_rr(dev, MT_ARB_TQSAXM0(phy->mt76->band_idx))); |
| 1285 | + } |
| 1286 | + |
| 1287 | if (!ebf && is_atenl) |
| 1288 | return mt7915_tm_txbf_apply_tx(phy, 1, false, true, true); |
| 1289 | |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1290 | @@ -799,7 +909,7 @@ mt7915_tm_txbf_phase_cal(struct mt7915_phy *phy, u16 *val) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1291 | u8 category; |
| 1292 | u8 group_l_m_n; |
| 1293 | u8 group; |
| 1294 | - bool sx2; |
| 1295 | + bool dbdc_idx; |
| 1296 | u8 cal_type; |
| 1297 | u8 lna_gain_level; |
| 1298 | u8 _rsv[2]; |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1299 | @@ -807,12 +917,12 @@ mt7915_tm_txbf_phase_cal(struct mt7915_phy *phy, u16 *val) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1300 | .category = MT_BF_PHASE_CAL, |
| 1301 | .group = val[0], |
| 1302 | .group_l_m_n = val[1], |
| 1303 | - .sx2 = val[2], |
| 1304 | + .dbdc_idx = phy->mt76->band_idx, |
| 1305 | .cal_type = val[3], |
| 1306 | .lna_gain_level = val[4], |
| 1307 | }; |
| 1308 | - struct mt7915_tm_txbf_phase *phase = |
| 1309 | - (struct mt7915_tm_txbf_phase *)dev->test.txbf_phase_cal; |
| 1310 | + struct mt7915_txbf_phase *phase = |
| 1311 | + (struct mt7915_txbf_phase *)dev->test.txbf_phase_cal; |
| 1312 | |
| 1313 | phase[req.group].status = 0; |
| 1314 | |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1315 | @@ -820,53 +930,10 @@ mt7915_tm_txbf_phase_cal(struct mt7915_phy *phy, u16 *val) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1316 | sizeof(req), true); |
| 1317 | } |
| 1318 | |
| 1319 | -int mt7915_tm_txbf_status_read(struct mt7915_dev *dev, struct sk_buff *skb) |
| 1320 | -{ |
| 1321 | -#define BF_PFMU_TAG 16 |
| 1322 | -#define BF_CAL_PHASE 21 |
| 1323 | - u8 format_id; |
| 1324 | - |
| 1325 | - skb_pull(skb, sizeof(struct mt76_connac2_mcu_rxd)); |
| 1326 | - format_id = *(u8 *)skb->data; |
| 1327 | - |
| 1328 | - if (format_id == BF_PFMU_TAG) { |
| 1329 | - struct mt7915_tm_pfmu_tag *tag = dev->test.txbf_pfmu_tag; |
| 1330 | - |
| 1331 | - skb_pull(skb, 8); |
| 1332 | - memcpy(tag, skb->data, sizeof(struct mt7915_tm_pfmu_tag)); |
| 1333 | - } else if (format_id == BF_CAL_PHASE) { |
| 1334 | - struct mt7915_tm_ibf_cal_info *cal; |
| 1335 | - struct mt7915_tm_txbf_phase *phase = |
| 1336 | - (struct mt7915_tm_txbf_phase *)dev->test.txbf_phase_cal; |
| 1337 | - |
| 1338 | - cal = (struct mt7915_tm_ibf_cal_info *)skb->data; |
| 1339 | - switch (cal->cal_type) { |
| 1340 | - case IBF_PHASE_CAL_NORMAL: |
| 1341 | - case IBF_PHASE_CAL_NORMAL_INSTRUMENT: |
| 1342 | - if (cal->group_l_m_n != GROUP_M) |
| 1343 | - break; |
| 1344 | - phase = &phase[cal->group]; |
| 1345 | - memcpy(&phase->phase, cal->buf + 16, sizeof(phase->phase)); |
| 1346 | - phase->status = cal->status; |
| 1347 | - /* for passing iTest script */ |
| 1348 | - dev_info(dev->mt76.dev, "Calibrated result = %d\n", phase->status); |
| 1349 | - break; |
| 1350 | - case IBF_PHASE_CAL_VERIFY: |
| 1351 | - case IBF_PHASE_CAL_VERIFY_INSTRUMENT: |
| 1352 | - break; |
| 1353 | - default: |
| 1354 | - break; |
| 1355 | - } |
| 1356 | - } |
| 1357 | - |
| 1358 | - wake_up(&dev->mt76.tx_wait); |
| 1359 | - |
| 1360 | - return 0; |
| 1361 | -} |
| 1362 | - |
| 1363 | static int |
| 1364 | mt7915_tm_txbf_profile_update_all(struct mt7915_phy *phy, u16 *val) |
| 1365 | { |
| 1366 | +#define MT7915_TXBF_PFMU_DATA_LEN (MT7915_TXBF_SUBCAR_NUM * sizeof(struct mt7915_pfmu_data)) |
| 1367 | struct mt76_testmode_data *td = &phy->mt76->test; |
developer | f0fd705 | 2023-08-14 20:23:42 +0800 | [diff] [blame] | 1368 | u8 nss = hweight8(td->tx_antenna_mask); |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1369 | u16 pfmu_idx = val[0]; |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1370 | @@ -876,9 +943,9 @@ mt7915_tm_txbf_profile_update_all(struct mt7915_phy *phy, u16 *val) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1371 | u16 angle31 = val[4]; |
| 1372 | u16 angle41 = val[5]; |
| 1373 | s16 phi11 = 0, phi21 = 0, phi31 = 0; |
| 1374 | - struct mt7915_tm_pfmu_data *pfmu_data; |
| 1375 | + struct mt7915_pfmu_data *pfmu_data; |
| 1376 | |
| 1377 | - if (subc_id > 63) |
| 1378 | + if (subc_id > MT7915_TXBF_SUBCAR_NUM - 1) |
| 1379 | return -EINVAL; |
| 1380 | |
developer | f0fd705 | 2023-08-14 20:23:42 +0800 | [diff] [blame] | 1381 | if (nss == 2) { |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1382 | @@ -892,7 +959,7 @@ mt7915_tm_txbf_profile_update_all(struct mt7915_phy *phy, u16 *val) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1383 | phi31 = (s16)(angle41 - angle31); |
| 1384 | } |
| 1385 | |
| 1386 | - pfmu_data = (struct mt7915_tm_pfmu_data *)phy->dev->test.txbf_pfmu_data; |
| 1387 | + pfmu_data = (struct mt7915_pfmu_data *)phy->dev->test.txbf_pfmu_data; |
| 1388 | pfmu_data = &pfmu_data[subc_id]; |
| 1389 | |
| 1390 | if (subc_id < 32) |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1391 | @@ -902,21 +969,21 @@ mt7915_tm_txbf_profile_update_all(struct mt7915_phy *phy, u16 *val) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1392 | pfmu_data->phi11 = cpu_to_le16(phi11); |
| 1393 | pfmu_data->phi21 = cpu_to_le16(phi21); |
| 1394 | pfmu_data->phi31 = cpu_to_le16(phi31); |
| 1395 | - if (subc_id == 63) { |
| 1396 | + if (subc_id == MT7915_TXBF_SUBCAR_NUM - 1) { |
| 1397 | struct mt7915_dev *dev = phy->dev; |
| 1398 | struct { |
| 1399 | u8 format_id; |
| 1400 | u8 pfmu_idx; |
| 1401 | u8 dbdc_idx; |
| 1402 | u8 _rsv; |
| 1403 | - u8 buf[512]; |
| 1404 | + u8 buf[MT7915_TXBF_PFMU_DATA_LEN]; |
| 1405 | } __packed req = { |
| 1406 | .format_id = MT_BF_PROFILE_WRITE_ALL, |
| 1407 | .pfmu_idx = pfmu_idx, |
| 1408 | .dbdc_idx = phy != &dev->phy, |
| 1409 | }; |
| 1410 | |
| 1411 | - memcpy(req.buf, dev->test.txbf_pfmu_data, 512); |
| 1412 | + memcpy(req.buf, dev->test.txbf_pfmu_data, MT7915_TXBF_PFMU_DATA_LEN); |
| 1413 | |
| 1414 | return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(TXBF_ACTION), |
| 1415 | &req, sizeof(req), true); |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1416 | @@ -928,7 +995,7 @@ mt7915_tm_txbf_profile_update_all(struct mt7915_phy *phy, u16 *val) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1417 | static int |
| 1418 | mt7915_tm_txbf_e2p_update(struct mt7915_phy *phy) |
| 1419 | { |
| 1420 | - struct mt7915_tm_txbf_phase *phase, *p; |
| 1421 | + struct mt7915_txbf_phase *phase, *p; |
| 1422 | struct mt7915_dev *dev = phy->dev; |
| 1423 | u8 *eeprom = dev->mt76.eeprom.data; |
| 1424 | u16 offset; |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1425 | @@ -938,7 +1005,7 @@ mt7915_tm_txbf_e2p_update(struct mt7915_phy *phy) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1426 | is_7976 = mt7915_check_adie(dev, false) || is_mt7916(&dev->mt76); |
| 1427 | offset = is_7976 ? 0x60a : 0x651; |
| 1428 | |
| 1429 | - phase = (struct mt7915_tm_txbf_phase *)dev->test.txbf_phase_cal; |
| 1430 | + phase = (struct mt7915_txbf_phase *)dev->test.txbf_phase_cal; |
| 1431 | for (i = 0; i < MAX_PHASE_GROUP_NUM; i++) { |
| 1432 | p = &phase[i]; |
| 1433 | |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1434 | @@ -953,17 +1020,75 @@ mt7915_tm_txbf_e2p_update(struct mt7915_phy *phy) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1435 | return 0; |
| 1436 | } |
| 1437 | |
| 1438 | +static int |
| 1439 | +mt7915_tm_trigger_sounding(struct mt7915_phy *phy, u16 *val, bool en) |
| 1440 | +{ |
| 1441 | + struct mt7915_dev *dev = phy->dev; |
| 1442 | + u8 sounding_mode = val[0]; |
| 1443 | + u8 MU_num = val[1]; |
| 1444 | + u32 sounding_interval = (u32)val[2] << 2; /* input unit: 4ms */ |
| 1445 | + enum sounding_mode { |
| 1446 | + SU_SOUNDING, |
| 1447 | + MU_SOUNDING, |
| 1448 | + SU_PERIODIC_SOUNDING, |
| 1449 | + MU_PERIODIC_SOUNDING, |
| 1450 | + BF_PROCESSING, |
| 1451 | + TXCMD_NONTB_SU_SOUNDING, |
| 1452 | + TXCMD_VHT_MU_SOUNDING, |
| 1453 | + TXCMD_TB_PER_BRP_SOUNDING, |
| 1454 | + TXCMD_TB_SOUNDING, |
| 1455 | + |
| 1456 | + /* keep last */ |
| 1457 | + NUM_SOUNDING_MODE, |
| 1458 | + SOUNDING_MODE_MAX = NUM_SOUNDING_MODE - 1, |
| 1459 | + }; |
| 1460 | + struct { |
| 1461 | + u8 cmd_category_id; |
| 1462 | + u8 sounding_mode; |
| 1463 | + u8 MU_num; |
| 1464 | + u8 rsv; |
| 1465 | + u8 wlan_idx[4]; |
| 1466 | + u32 sounding_interval; /* unit: ms */ |
| 1467 | + } __packed req = { |
| 1468 | + .cmd_category_id = en ? MT_BF_SOUNDING_ON : MT_BF_SOUNDING_OFF, |
| 1469 | + .sounding_mode = sounding_mode, |
| 1470 | + .MU_num = MU_num, |
| 1471 | + .sounding_interval = cpu_to_le32(sounding_interval), |
| 1472 | + .wlan_idx[0] = val[3], |
| 1473 | + .wlan_idx[1] = val[4], |
| 1474 | + .wlan_idx[2] = val[5], |
| 1475 | + .wlan_idx[3] = val[6], |
| 1476 | + }; |
| 1477 | + |
| 1478 | + if (sounding_mode > SOUNDING_MODE_MAX) |
| 1479 | + return -EINVAL; |
| 1480 | + |
| 1481 | + /* Enable Tx MAC HW before trigger sounding */ |
| 1482 | + if (en) |
| 1483 | + mt7915_tm_set_trx(phy, TM_MAC_TX, true); |
| 1484 | + |
| 1485 | + return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(TXBF_ACTION), |
| 1486 | + &req, sizeof(req), true); |
| 1487 | +} |
| 1488 | + |
| 1489 | static int |
| 1490 | mt7915_tm_set_txbf(struct mt7915_phy *phy) |
| 1491 | { |
| 1492 | +#define TXBF_IS_DUT_MASK BIT(0) |
| 1493 | +#define TXBF_EBF_MASK BIT(1) |
| 1494 | struct mt76_testmode_data *td = &phy->mt76->test; |
| 1495 | u16 *val = td->txbf_param; |
| 1496 | |
| 1497 | - pr_info("ibf cal process: act = %u, val = %u, %u, %u, %u, %u, %u\n", |
| 1498 | - td->txbf_act, val[0], val[1], val[2], val[3], val[4], val[5]); |
developer | 692ed9b | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 1499 | + dev_info(phy->dev->mt76.dev, "ibf cal process: act = %u, val = %u, %u, %u, %u, %u, %u, %u\n", |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1500 | + td->txbf_act, val[0], val[1], val[2], val[3], val[4], val[5], val[6]); |
| 1501 | |
| 1502 | switch (td->txbf_act) { |
| 1503 | + case MT76_TM_TXBF_ACT_GOLDEN_INIT: |
| 1504 | case MT76_TM_TXBF_ACT_INIT: |
| 1505 | + case MT76_TM_TX_EBF_ACT_GOLDEN_INIT: |
| 1506 | + case MT76_TM_TX_EBF_ACT_INIT: |
| 1507 | + td->ebf = !!u32_get_bits(td->txbf_act, TXBF_EBF_MASK); |
| 1508 | + td->is_txbf_dut = !!u32_get_bits(td->txbf_act, TXBF_IS_DUT_MASK); |
| 1509 | return mt7915_tm_txbf_init(phy, val); |
| 1510 | case MT76_TM_TXBF_ACT_UPDATE_CH: |
| 1511 | mt7915_tm_update_channel(phy); |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1512 | @@ -989,6 +1114,36 @@ mt7915_tm_set_txbf(struct mt7915_phy *phy) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1513 | |
| 1514 | return mt7915_tm_txbf_apply_tx(phy, wlan_idx, ebf, ibf, phase_cal); |
| 1515 | } |
| 1516 | + case MT76_TM_TXBF_ACT_TRIGGER_SOUNDING: |
| 1517 | + return mt7915_tm_trigger_sounding(phy, val, true); |
| 1518 | + case MT76_TM_TXBF_ACT_STOP_SOUNDING: |
| 1519 | + memset(val, 0, sizeof(td->txbf_param)); |
| 1520 | + return mt7915_tm_trigger_sounding(phy, val, false); |
| 1521 | + case MT76_TM_TXBF_ACT_PROFILE_TAG_READ: |
| 1522 | + case MT76_TM_TXBF_ACT_PROFILE_TAG_WRITE: |
| 1523 | + case MT76_TM_TXBF_ACT_PROFILE_TAG_INVALID: { |
| 1524 | + u8 pfmu_idx = val[0]; |
| 1525 | + bool bfer = !!val[1]; |
| 1526 | + struct mt7915_dev *dev = phy->dev; |
| 1527 | + struct mt7915_pfmu_tag *tag = dev->test.txbf_pfmu_tag; |
| 1528 | + |
| 1529 | + if (!tag) { |
| 1530 | + dev_err(dev->mt76.dev, |
| 1531 | + "pfmu tag is not initialized!\n"); |
| 1532 | + return 0; |
| 1533 | + } |
| 1534 | + |
| 1535 | + if (td->txbf_act == MT76_TM_TXBF_ACT_PROFILE_TAG_WRITE) |
| 1536 | + return mt7915_tm_txbf_profile_tag_write(phy, pfmu_idx, tag); |
| 1537 | + else if (td->txbf_act == MT76_TM_TXBF_ACT_PROFILE_TAG_READ) |
| 1538 | + return mt7915_mcu_txbf_profile_tag_read(phy, pfmu_idx, bfer); |
| 1539 | + |
| 1540 | + tag->t1.invalid_prof = !!val[0]; |
| 1541 | + |
| 1542 | + return 0; |
| 1543 | + } |
| 1544 | + case MT76_TM_TXBF_ACT_STA_REC_READ: |
| 1545 | + return mt7915_mcu_txbf_sta_rec_read(phy->dev, val[0]); |
| 1546 | default: |
| 1547 | break; |
| 1548 | }; |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1549 | @@ -1264,9 +1419,10 @@ mt7915_tm_set_ipi(struct mt7915_phy *phy) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1550 | |
| 1551 | static int |
| 1552 | mt7915_tm_set_wmm_qid(struct mt7915_phy *phy, u8 qid, u8 aifs, u8 cw_min, |
| 1553 | - u16 cw_max, u16 txop, u8 tx_cmd) |
| 1554 | + u16 cw_max, u16 txop, u8 tx_cmd, bool bf_sounding) |
| 1555 | { |
| 1556 | - struct mt7915_vif *mvif = (struct mt7915_vif *)phy->monitor_vif->drv_priv; |
| 1557 | + struct mt76_testmode_data *td = &phy->mt76->test; |
| 1558 | + struct mt7915_vif *mvif; |
| 1559 | struct mt7915_mcu_tx req = { |
| 1560 | .valid = true, |
| 1561 | .mode = tx_cmd, |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1562 | @@ -1274,6 +1430,9 @@ mt7915_tm_set_wmm_qid(struct mt7915_phy *phy, u8 qid, u8 aifs, u8 cw_min, |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1563 | }; |
| 1564 | struct edca *e = &req.edca[0]; |
| 1565 | |
| 1566 | + mvif = bf_sounding ? (struct mt7915_vif *)td->second_vif->drv_priv : |
| 1567 | + (struct mt7915_vif *)phy->monitor_vif->drv_priv; |
| 1568 | + |
| 1569 | e->queue = qid + mvif->mt76.wmm_idx * MT76_CONNAC_MAX_WMM_SETS; |
| 1570 | e->set = WMM_PARAM_SET; |
| 1571 | |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1572 | @@ -1286,17 +1445,19 @@ mt7915_tm_set_wmm_qid(struct mt7915_phy *phy, u8 qid, u8 aifs, u8 cw_min, |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1573 | } |
| 1574 | |
| 1575 | static int |
| 1576 | -mt7915_tm_set_ipg_params(struct mt7915_phy *phy, u32 ipg, u8 mode) |
| 1577 | +mt7915_tm_set_ipg_params(struct mt7915_phy *phy, u32 ipg, u8 mode, bool bf_sounding) |
| 1578 | { |
| 1579 | #define TM_DEFAULT_SIFS 10 |
| 1580 | #define TM_MAX_SIFS 127 |
| 1581 | #define TM_MAX_AIFSN 0xf |
| 1582 | #define TM_MIN_AIFSN 0x1 |
| 1583 | #define BBP_PROC_TIME 1500 |
| 1584 | +#define TM_DEFAULT_CW 1 |
| 1585 | struct mt7915_dev *dev = phy->dev; |
| 1586 | u8 sig_ext = (mode == MT76_TM_TX_MODE_CCK) ? 0 : 6; |
| 1587 | u8 slot_time = 9, sifs = TM_DEFAULT_SIFS; |
| 1588 | u8 aifsn = TM_MIN_AIFSN; |
| 1589 | + bool tx_cmd; |
| 1590 | u8 band = phy->mt76->band_idx; |
| 1591 | u32 i2t_time, tr2t_time, txv_time; |
| 1592 | u16 cw = 0; |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1593 | @@ -1310,6 +1471,7 @@ mt7915_tm_set_ipg_params(struct mt7915_phy *phy, u32 ipg, u8 mode) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1594 | ipg -= sig_ext; |
| 1595 | |
| 1596 | if (ipg <= (TM_MAX_SIFS + slot_time)) { |
| 1597 | + cw = TM_DEFAULT_CW; |
| 1598 | sifs = ipg - slot_time; |
| 1599 | } else { |
| 1600 | u32 val = (ipg + slot_time) / slot_time; |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1601 | @@ -1345,10 +1507,12 @@ done: |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1602 | |
| 1603 | mt7915_tm_set_slot_time(phy, slot_time, sifs); |
| 1604 | |
| 1605 | + /* HE MU data and iBF/eBF sounding packet use TXCMD */ |
| 1606 | + tx_cmd = (mode == MT76_TM_TX_MODE_HE_MU) || bf_sounding; |
| 1607 | + |
| 1608 | return mt7915_tm_set_wmm_qid(phy, |
| 1609 | mt76_connac_lmac_mapping(IEEE80211_AC_BE), |
| 1610 | - aifsn, cw, cw, 0, |
| 1611 | - mode == MT76_TM_TX_MODE_HE_MU); |
| 1612 | + aifsn, cw, cw, 0, tx_cmd, bf_sounding); |
| 1613 | } |
| 1614 | |
| 1615 | static int |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 1616 | @@ -1549,7 +1713,7 @@ mt7915_tm_init(struct mt7915_phy *phy, bool en) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1617 | |
| 1618 | phy->mt76->test.aid = 0; |
| 1619 | phy->mt76->test.tx_mpdu_len = 0; |
| 1620 | - phy->test.bf_en = 0; |
| 1621 | + phy->mt76->test.bf_en = 0; |
| 1622 | mt7915_tm_set_entry(phy); |
| 1623 | } else { |
| 1624 | INIT_DELAYED_WORK(&phy->ipi_work, mt7915_tm_ipi_work); |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 1625 | @@ -1734,7 +1898,7 @@ mt7915_tm_set_tx_frames(struct mt7915_phy *phy, bool en) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1626 | u32 tx_time = td->tx_time, ipg = td->tx_ipg; |
| 1627 | u8 duty_cycle = td->tx_duty_cycle; |
| 1628 | |
| 1629 | - if (!phy->test.bf_en) |
| 1630 | + if (!td->bf_en) |
| 1631 | mt7915_tm_update_channel(phy); |
| 1632 | |
| 1633 | if (td->tx_spe_idx) |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 1634 | @@ -1749,7 +1913,7 @@ mt7915_tm_set_tx_frames(struct mt7915_phy *phy, bool en) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1635 | if (duty_cycle < 100) |
| 1636 | tx_time = duty_cycle * ipg / (100 - duty_cycle); |
| 1637 | } |
| 1638 | - mt7915_tm_set_ipg_params(phy, ipg, td->tx_rate_mode); |
| 1639 | + mt7915_tm_set_ipg_params(phy, ipg, td->tx_rate_mode, false); |
| 1640 | mt7915_tm_set_tx_len(phy, tx_time); |
| 1641 | |
| 1642 | if (ipg) |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 1643 | @@ -1768,6 +1932,9 @@ mt7915_tm_set_tx_frames(struct mt7915_phy *phy, bool en) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1644 | mt7915_tm_tx_frames_mu(phy, en); |
| 1645 | |
| 1646 | mt7915_tm_set_trx(phy, TM_MAC_TX, en); |
| 1647 | + |
| 1648 | + if (td->bf_en) |
| 1649 | + mt7915_tm_set_trx(phy, TM_MAC_RX_RXV, en); |
| 1650 | } |
| 1651 | |
| 1652 | static int |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 1653 | @@ -1859,7 +2026,7 @@ mt7915_tm_set_rx_frames(struct mt7915_phy *phy, bool en) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1654 | mt7915_tm_set_trx(phy, TM_MAC_RX_RXV, false); |
| 1655 | |
| 1656 | if (en) { |
| 1657 | - if (!phy->test.bf_en) |
| 1658 | + if (!td->bf_en || !td->is_txbf_dut) |
| 1659 | mt7915_tm_update_channel(phy); |
| 1660 | if (td->aid) |
| 1661 | mt7915_tm_set_rx_user_idx(phy, td->aid); |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 1662 | @@ -1876,6 +2043,9 @@ mt7915_tm_set_rx_frames(struct mt7915_phy *phy, bool en) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1663 | mt7915_tm_set_muru_aid(phy, en ? td->aid : 0xf800); |
| 1664 | |
| 1665 | mt7915_tm_set_trx(phy, TM_MAC_RX_RXV, en); |
| 1666 | + |
| 1667 | + if (td->bf_en) |
| 1668 | + mt7915_tm_set_trx(phy, TM_MAC_TX, en); |
| 1669 | } |
| 1670 | |
| 1671 | static int |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 1672 | @@ -1935,34 +2105,7 @@ mt7915_tm_set_tx_cont(struct mt7915_phy *phy, bool en) |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1673 | rate_idx = sband->bitrates[idx].hw_value & 0xff; |
| 1674 | } |
| 1675 | |
| 1676 | - switch (td->tx_rate_mode) { |
| 1677 | - case MT76_TM_TX_MODE_CCK: |
| 1678 | - mode = MT_PHY_TYPE_CCK; |
| 1679 | - break; |
| 1680 | - case MT76_TM_TX_MODE_OFDM: |
| 1681 | - mode = MT_PHY_TYPE_OFDM; |
| 1682 | - break; |
| 1683 | - case MT76_TM_TX_MODE_HT: |
| 1684 | - mode = MT_PHY_TYPE_HT; |
| 1685 | - break; |
| 1686 | - case MT76_TM_TX_MODE_VHT: |
| 1687 | - mode = MT_PHY_TYPE_VHT; |
| 1688 | - break; |
| 1689 | - case MT76_TM_TX_MODE_HE_SU: |
| 1690 | - mode = MT_PHY_TYPE_HE_SU; |
| 1691 | - break; |
| 1692 | - case MT76_TM_TX_MODE_HE_EXT_SU: |
| 1693 | - mode = MT_PHY_TYPE_HE_EXT_SU; |
| 1694 | - break; |
| 1695 | - case MT76_TM_TX_MODE_HE_TB: |
| 1696 | - mode = MT_PHY_TYPE_HE_TB; |
| 1697 | - break; |
| 1698 | - case MT76_TM_TX_MODE_HE_MU: |
| 1699 | - mode = MT_PHY_TYPE_HE_MU; |
| 1700 | - break; |
| 1701 | - default: |
| 1702 | - return -EINVAL; |
| 1703 | - } |
| 1704 | + mode = mt7915_tm_rate_to_phy(td->tx_rate_mode); |
| 1705 | |
| 1706 | rateval = mode << 6 | rate_idx; |
| 1707 | tx_cont->rateval = cpu_to_le16(rateval); |
| 1708 | diff --git a/mt7915/testmode.h b/mt7915/testmode.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1709 | index 75698261..5aba13cf 100644 |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1710 | --- a/mt7915/testmode.h |
| 1711 | +++ b/mt7915/testmode.h |
| 1712 | @@ -311,137 +311,7 @@ struct mt7915_tm_muru { |
| 1713 | |
| 1714 | #define MAX_PHASE_GROUP_NUM 9 |
| 1715 | |
| 1716 | -struct mt7915_tm_txbf_phase { |
| 1717 | - u8 status; |
| 1718 | - struct { |
| 1719 | - u8 r0_uh; |
| 1720 | - u8 r0_h; |
| 1721 | - u8 r0_m; |
| 1722 | - u8 r0_l; |
| 1723 | - u8 r0_ul; |
| 1724 | - u8 r1_uh; |
| 1725 | - u8 r1_h; |
| 1726 | - u8 r1_m; |
| 1727 | - u8 r1_l; |
| 1728 | - u8 r1_ul; |
| 1729 | - u8 r2_uh; |
| 1730 | - u8 r2_h; |
| 1731 | - u8 r2_m; |
| 1732 | - u8 r2_l; |
| 1733 | - u8 r2_ul; |
| 1734 | - u8 r3_uh; |
| 1735 | - u8 r3_h; |
| 1736 | - u8 r3_m; |
| 1737 | - u8 r3_l; |
| 1738 | - u8 r3_ul; |
| 1739 | - u8 r2_uh_sx2; |
| 1740 | - u8 r2_h_sx2; |
| 1741 | - u8 r2_m_sx2; |
| 1742 | - u8 r2_l_sx2; |
| 1743 | - u8 r2_ul_sx2; |
| 1744 | - u8 r3_uh_sx2; |
| 1745 | - u8 r3_h_sx2; |
| 1746 | - u8 r3_m_sx2; |
| 1747 | - u8 r3_l_sx2; |
| 1748 | - u8 r3_ul_sx2; |
| 1749 | - u8 m_t0_h; |
| 1750 | - u8 m_t1_h; |
| 1751 | - u8 m_t2_h; |
| 1752 | - u8 m_t2_h_sx2; |
| 1753 | - u8 r0_reserved; |
| 1754 | - u8 r1_reserved; |
| 1755 | - u8 r2_reserved; |
| 1756 | - u8 r3_reserved; |
| 1757 | - u8 r2_sx2_reserved; |
| 1758 | - u8 r3_sx2_reserved; |
| 1759 | - } phase; |
| 1760 | -}; |
| 1761 | - |
| 1762 | -struct mt7915_tm_pfmu_tag1 { |
| 1763 | - __le32 pfmu_idx:10; |
| 1764 | - __le32 ebf:1; |
| 1765 | - __le32 data_bw:2; |
| 1766 | - __le32 lm:2; |
| 1767 | - __le32 is_mu:1; |
| 1768 | - __le32 nr:3, nc:3; |
| 1769 | - __le32 codebook:2; |
| 1770 | - __le32 ngroup:2; |
| 1771 | - __le32 _rsv:2; |
| 1772 | - __le32 invalid_prof:1; |
| 1773 | - __le32 rmsd:3; |
| 1774 | - |
| 1775 | - __le32 col_id1:6, row_id1:10; |
| 1776 | - __le32 col_id2:6, row_id2:10; |
| 1777 | - __le32 col_id3:6, row_id3:10; |
| 1778 | - __le32 col_id4:6, row_id4:10; |
| 1779 | - |
| 1780 | - __le32 ru_start_id:7; |
| 1781 | - __le32 _rsv1:1; |
| 1782 | - __le32 ru_end_id:7; |
| 1783 | - __le32 _rsv2:1; |
| 1784 | - __le32 mob_cal_en:1; |
| 1785 | - __le32 _rsv3:15; |
| 1786 | - |
| 1787 | - __le32 snr_sts0:8, snr_sts1:8, snr_sts2:8, snr_sts3:8; |
| 1788 | - __le32 snr_sts4:8, snr_sts5:8, snr_sts6:8, snr_sts7:8; |
| 1789 | - |
| 1790 | - __le32 _rsv4; |
| 1791 | -} __packed; |
| 1792 | - |
| 1793 | -struct mt7915_tm_pfmu_tag2 { |
| 1794 | - __le32 smart_ant:24; |
| 1795 | - __le32 se_idx:5; |
| 1796 | - __le32 _rsv:3; |
| 1797 | - |
| 1798 | - __le32 _rsv1:8; |
| 1799 | - __le32 rmsd_thres:3; |
| 1800 | - __le32 _rsv2:5; |
| 1801 | - __le32 ibf_timeout:8; |
| 1802 | - __le32 _rsv3:8; |
| 1803 | - |
| 1804 | - __le32 _rsv4:16; |
| 1805 | - __le32 ibf_data_bw:2; |
| 1806 | - __le32 ibf_nc:3; |
| 1807 | - __le32 ibf_nr:3; |
| 1808 | - __le32 ibf_ru:8; |
| 1809 | - |
| 1810 | - __le32 mob_delta_t:8; |
| 1811 | - __le32 mob_lq_result:7; |
| 1812 | - __le32 _rsv5:1; |
| 1813 | - __le32 _rsv6:16; |
| 1814 | - |
| 1815 | - __le32 _rsv7; |
| 1816 | -} __packed; |
| 1817 | - |
| 1818 | -struct mt7915_tm_pfmu_tag { |
| 1819 | - struct mt7915_tm_pfmu_tag1 t1; |
| 1820 | - struct mt7915_tm_pfmu_tag2 t2; |
| 1821 | -}; |
| 1822 | - |
| 1823 | -struct mt7915_tm_pfmu_data { |
| 1824 | - __le16 subc_idx; |
| 1825 | - __le16 phi11; |
| 1826 | - __le16 phi21; |
| 1827 | - __le16 phi31; |
| 1828 | -}; |
| 1829 | - |
| 1830 | -struct mt7915_tm_ibf_cal_info { |
| 1831 | - u8 format_id; |
| 1832 | - u8 group_l_m_n; |
| 1833 | - u8 group; |
| 1834 | - bool sx2; |
| 1835 | - u8 status; |
| 1836 | - u8 cal_type; |
| 1837 | - u8 _rsv[2]; |
| 1838 | - u8 buf[1000]; |
| 1839 | -} __packed; |
| 1840 | - |
| 1841 | -enum { |
| 1842 | - IBF_PHASE_CAL_UNSPEC, |
| 1843 | - IBF_PHASE_CAL_NORMAL, |
| 1844 | - IBF_PHASE_CAL_VERIFY, |
| 1845 | - IBF_PHASE_CAL_NORMAL_INSTRUMENT, |
| 1846 | - IBF_PHASE_CAL_VERIFY_INSTRUMENT, |
| 1847 | -}; |
| 1848 | +#define TXBF_DUT_MAC_SUBADDR 0x22 |
| 1849 | +#define TXBF_GOLDEN_MAC_SUBADDR 0x11 |
| 1850 | |
| 1851 | #endif |
| 1852 | diff --git a/testmode.c b/testmode.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1853 | index d8fc5d6f..56b92059 100644 |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1854 | --- a/testmode.c |
| 1855 | +++ b/testmode.c |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1856 | @@ -196,6 +196,7 @@ mt76_testmode_alloc_skb(struct mt76_phy *phy, u32 len, |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1857 | |
| 1858 | hdr = __skb_put_zero(head, sizeof(*hdr)); |
| 1859 | hdr->frame_control = cpu_to_le16(fc); |
| 1860 | + |
| 1861 | memcpy(hdr->addr1, addr[0], ETH_ALEN); |
| 1862 | memcpy(hdr->addr2, addr[1], ETH_ALEN); |
| 1863 | memcpy(hdr->addr3, addr[2], ETH_ALEN); |
| 1864 | diff --git a/testmode.h b/testmode.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1865 | index b39cf511..20fab3ec 100644 |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1866 | --- a/testmode.h |
| 1867 | +++ b/testmode.h |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1868 | @@ -303,7 +303,10 @@ enum mt76_testmode_cfg { |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1869 | }; |
| 1870 | |
| 1871 | enum mt76_testmode_txbf_act { |
| 1872 | + MT76_TM_TXBF_ACT_GOLDEN_INIT, |
| 1873 | MT76_TM_TXBF_ACT_INIT, |
| 1874 | + MT76_TM_TX_EBF_ACT_GOLDEN_INIT, |
| 1875 | + MT76_TM_TX_EBF_ACT_INIT, |
| 1876 | MT76_TM_TXBF_ACT_UPDATE_CH, |
| 1877 | MT76_TM_TXBF_ACT_PHASE_COMP, |
| 1878 | MT76_TM_TXBF_ACT_TX_PREP, |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 1879 | @@ -314,6 +317,12 @@ enum mt76_testmode_txbf_act { |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1880 | MT76_TM_TXBF_ACT_PROF_UPDATE_ALL, |
| 1881 | MT76_TM_TXBF_ACT_PROF_UPDATE_ALL_CMD, |
| 1882 | MT76_TM_TXBF_ACT_E2P_UPDATE, |
| 1883 | + MT76_TM_TXBF_ACT_TRIGGER_SOUNDING, |
| 1884 | + MT76_TM_TXBF_ACT_STOP_SOUNDING, |
| 1885 | + MT76_TM_TXBF_ACT_PROFILE_TAG_READ, |
| 1886 | + MT76_TM_TXBF_ACT_PROFILE_TAG_WRITE, |
| 1887 | + MT76_TM_TXBF_ACT_PROFILE_TAG_INVALID, |
| 1888 | + MT76_TM_TXBF_ACT_STA_REC_READ, |
| 1889 | |
| 1890 | /* keep last */ |
| 1891 | NUM_MT76_TM_TXBF_ACT, |
| 1892 | diff --git a/tools/fields.c b/tools/fields.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1893 | index e2cf4b92..027b8cdb 100644 |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1894 | --- a/tools/fields.c |
| 1895 | +++ b/tools/fields.c |
| 1896 | @@ -33,7 +33,10 @@ static const char * const testmode_tx_mode[] = { |
| 1897 | }; |
| 1898 | |
| 1899 | static const char * const testmode_txbf_act[] = { |
| 1900 | + [MT76_TM_TXBF_ACT_GOLDEN_INIT] = "golden_init", |
| 1901 | [MT76_TM_TXBF_ACT_INIT] = "init", |
| 1902 | + [MT76_TM_TX_EBF_ACT_GOLDEN_INIT] = "ebf_golden_init", |
| 1903 | + [MT76_TM_TX_EBF_ACT_INIT] = "ebf_init", |
| 1904 | [MT76_TM_TXBF_ACT_UPDATE_CH] = "update_ch", |
| 1905 | [MT76_TM_TXBF_ACT_PHASE_COMP] = "phase_comp", |
| 1906 | [MT76_TM_TXBF_ACT_TX_PREP] = "tx_prep", |
| 1907 | @@ -44,6 +47,12 @@ static const char * const testmode_txbf_act[] = { |
| 1908 | [MT76_TM_TXBF_ACT_PROF_UPDATE_ALL] = "prof_update", |
| 1909 | [MT76_TM_TXBF_ACT_PROF_UPDATE_ALL_CMD] = "prof_update_all", |
| 1910 | [MT76_TM_TXBF_ACT_E2P_UPDATE] = "e2p_update", |
| 1911 | + [MT76_TM_TXBF_ACT_TRIGGER_SOUNDING] = "trigger_sounding", |
| 1912 | + [MT76_TM_TXBF_ACT_STOP_SOUNDING] = "stop_sounding", |
| 1913 | + [MT76_TM_TXBF_ACT_PROFILE_TAG_READ] = "pfmu_tag_read", |
| 1914 | + [MT76_TM_TXBF_ACT_PROFILE_TAG_WRITE] = "pfmu_tag_write", |
| 1915 | + [MT76_TM_TXBF_ACT_PROFILE_TAG_INVALID] = "set_invalid_prof", |
| 1916 | + [MT76_TM_TXBF_ACT_STA_REC_READ] = "sta_rec_read", |
| 1917 | }; |
| 1918 | |
| 1919 | static const char * const testmode_offchan_bw[] = { |
| 1920 | -- |
developer | f0fd705 | 2023-08-14 20:23:42 +0800 | [diff] [blame] | 1921 | 2.18.0 |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 1922 | |