developer | bcc85ca | 2022-12-05 11:29:56 +0800 | [diff] [blame] | 1 | From 62514b545ba99ba75fbed0ece763009b583473dc Mon Sep 17 00:00:00 2001 |
| 2 | From: Shayne Chen <shayne.chen@mediatek.com> |
| 3 | Date: Mon, 6 Jun 2022 19:46:26 +0800 |
| 4 | Subject: [PATCH 1111/1128] mt76: mt7915: rework testmode init registers |
| 5 | |
| 6 | --- |
| 7 | mac80211.c | 3 +- |
| 8 | mt76.h | 5 ++ |
| 9 | mt76_connac_mcu.h | 1 + |
| 10 | mt7915/mcu.h | 1 + |
| 11 | mt7915/mmio.c | 2 + |
| 12 | mt7915/regs.h | 16 +++++- |
| 13 | mt7915/testmode.c | 134 +++++++++++++++++++++++++++++++++++----------- |
| 14 | mt7915/testmode.h | 28 ++++++++++ |
| 15 | testmode.c | 6 ++- |
| 16 | testmode.h | 3 ++ |
| 17 | 10 files changed, 164 insertions(+), 35 deletions(-) |
| 18 | |
| 19 | diff --git a/mac80211.c b/mac80211.c |
| 20 | index acac04ef..9a908c9a 100644 |
| 21 | --- a/mac80211.c |
| 22 | +++ b/mac80211.c |
| 23 | @@ -761,7 +761,8 @@ void mt76_rx(struct mt76_dev *dev, enum mt76_rxq_id q, struct sk_buff *skb) |
| 24 | } |
| 25 | |
| 26 | #ifdef CONFIG_NL80211_TESTMODE |
| 27 | - if (phy->test.state == MT76_TM_STATE_RX_FRAMES) { |
| 28 | + if (!(phy->test.flag & MT_TM_FW_RX_COUNT) && |
| 29 | + phy->test.state == MT76_TM_STATE_RX_FRAMES) { |
| 30 | phy->test.rx_stats.packets[q]++; |
| 31 | if (status->flag & RX_FLAG_FAILED_FCS_CRC) |
| 32 | phy->test.rx_stats.fcs_error[q]++; |
| 33 | diff --git a/mt76.h b/mt76.h |
| 34 | index 84d49c2b..0d87f135 100644 |
| 35 | --- a/mt76.h |
| 36 | +++ b/mt76.h |
| 37 | @@ -637,6 +637,8 @@ struct mt76_testmode_ops { |
| 38 | int (*dump_stats)(struct mt76_phy *phy, struct sk_buff *msg); |
| 39 | }; |
| 40 | |
| 41 | +#define MT_TM_FW_RX_COUNT BIT(0) |
| 42 | + |
| 43 | struct mt76_testmode_data { |
| 44 | enum mt76_testmode_state state; |
| 45 | |
| 46 | @@ -668,6 +670,8 @@ struct mt76_testmode_data { |
| 47 | |
| 48 | u8 addr[3][ETH_ALEN]; |
| 49 | |
| 50 | + u8 flag; |
| 51 | + |
| 52 | u32 tx_pending; |
| 53 | u32 tx_queued; |
| 54 | u16 tx_queued_limit; |
| 55 | @@ -675,6 +679,7 @@ struct mt76_testmode_data { |
| 56 | struct { |
| 57 | u64 packets[__MT_RXQ_MAX]; |
| 58 | u64 fcs_error[__MT_RXQ_MAX]; |
| 59 | + u64 len_mismatch; |
| 60 | } rx_stats; |
| 61 | }; |
| 62 | |
| 63 | diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h |
| 64 | index 0d4d466f..172a926a 100644 |
| 65 | --- a/mt76_connac_mcu.h |
| 66 | +++ b/mt76_connac_mcu.h |
| 67 | @@ -1177,6 +1177,7 @@ enum { |
| 68 | MCU_EXT_CMD_OFFCH_SCAN_CTRL = 0x9a, |
| 69 | MCU_EXT_CMD_SET_RDD_TH = 0x9d, |
| 70 | MCU_EXT_CMD_MURU_CTRL = 0x9f, |
| 71 | + MCU_EXT_CMD_RX_STAT = 0xa4, |
| 72 | MCU_EXT_CMD_SET_SPR = 0xa8, |
| 73 | MCU_EXT_CMD_GROUP_PRE_CAL_INFO = 0xab, |
| 74 | MCU_EXT_CMD_DPD_PRE_CAL_INFO = 0xac, |
| 75 | diff --git a/mt7915/mcu.h b/mt7915/mcu.h |
| 76 | index e7ad0560..6a145aef 100644 |
| 77 | --- a/mt7915/mcu.h |
| 78 | +++ b/mt7915/mcu.h |
| 79 | @@ -9,6 +9,7 @@ |
| 80 | enum { |
| 81 | MCU_ATE_SET_TRX = 0x1, |
| 82 | MCU_ATE_SET_FREQ_OFFSET = 0xa, |
| 83 | + MCU_ATE_SET_PHY_COUNT = 0x11, |
| 84 | MCU_ATE_SET_SLOT_TIME = 0x13, |
| 85 | MCU_ATE_CLEAN_TXQUEUE = 0x1c, |
| 86 | }; |
| 87 | diff --git a/mt7915/mmio.c b/mt7915/mmio.c |
| 88 | index 3b4ede3b..19518cb5 100644 |
| 89 | --- a/mt7915/mmio.c |
| 90 | +++ b/mt7915/mmio.c |
| 91 | @@ -118,6 +118,7 @@ static const u32 mt7986_reg[] = { |
| 92 | }; |
| 93 | |
| 94 | static const u32 mt7915_offs[] = { |
| 95 | + [TMAC_TCR2] = 0x05c, |
| 96 | [TMAC_CDTR] = 0x090, |
| 97 | [TMAC_ODTR] = 0x094, |
| 98 | [TMAC_ATCR] = 0x098, |
| 99 | @@ -192,6 +193,7 @@ static const u32 mt7915_offs[] = { |
| 100 | }; |
| 101 | |
| 102 | static const u32 mt7916_offs[] = { |
| 103 | + [TMAC_TCR2] = 0x004, |
| 104 | [TMAC_CDTR] = 0x0c8, |
| 105 | [TMAC_ODTR] = 0x0cc, |
| 106 | [TMAC_ATCR] = 0x00c, |
| 107 | diff --git a/mt7915/regs.h b/mt7915/regs.h |
| 108 | index aca1b2f1..688f7dee 100644 |
| 109 | --- a/mt7915/regs.h |
| 110 | +++ b/mt7915/regs.h |
| 111 | @@ -48,6 +48,7 @@ enum reg_rev { |
| 112 | }; |
| 113 | |
| 114 | enum offs_rev { |
| 115 | + TMAC_TCR2, |
| 116 | TMAC_CDTR, |
| 117 | TMAC_ODTR, |
| 118 | TMAC_ATCR, |
| 119 | @@ -198,6 +199,12 @@ enum offs_rev { |
| 120 | #define MT_TRB_RXPSR0_RX_WTBL_PTR GENMASK(25, 16) |
| 121 | #define MT_TRB_RXPSR0_RX_RMAC_PTR GENMASK(9, 0) |
| 122 | |
| 123 | +#define MT_MDP_TOP_DBG_WDT_CTRL MT_MDP(0x0d0) |
| 124 | +#define MT_MDP_TOP_DBG_WDT_CTRL_TDP_DIS_BLK BIT(7) |
| 125 | + |
| 126 | +#define MT_MDP_TOP_DBG_CTRL MT_MDP(0x0dc) |
| 127 | +#define MT_MDP_TOP_DBG_CTRL_ENQ_MODE BIT(30) |
| 128 | + |
| 129 | /* TMAC: band 0(0x820e4000), band 1(0x820f4000) */ |
| 130 | #define MT_WF_TMAC_BASE(_band) ((_band) ? 0x820f4000 : 0x820e4000) |
| 131 | #define MT_WF_TMAC(_band, ofs) (MT_WF_TMAC_BASE(_band) + (ofs)) |
| 132 | @@ -206,6 +213,9 @@ enum offs_rev { |
| 133 | #define MT_TMAC_TCR0_TX_BLINK GENMASK(7, 6) |
| 134 | #define MT_TMAC_TCR0_TBTT_STOP_CTRL BIT(25) |
| 135 | |
| 136 | +#define MT_TMAC_TCR2(_band) MT_WF_TMAC(_band, __OFFS(TMAC_TCR2)) |
| 137 | +#define MT_TMAC_TCR2_SCH_DET_DIS BIT(19) |
| 138 | + |
| 139 | #define MT_TMAC_CDTR(_band) MT_WF_TMAC(_band, __OFFS(TMAC_CDTR)) |
| 140 | #define MT_TMAC_ODTR(_band) MT_WF_TMAC(_band, __OFFS(TMAC_ODTR)) |
| 141 | #define MT_TIMEOUT_VAL_PLCP GENMASK(15, 0) |
| 142 | @@ -485,8 +495,10 @@ enum offs_rev { |
| 143 | #define MT_AGG_PCR0_VHT_PROT BIT(13) |
| 144 | #define MT_AGG_PCR0_PTA_WIN_DIS BIT(15) |
| 145 | |
| 146 | -#define MT_AGG_PCR1_RTS0_NUM_THRES GENMASK(31, 23) |
| 147 | -#define MT_AGG_PCR1_RTS0_LEN_THRES GENMASK(19, 0) |
| 148 | +#define MT_AGG_PCR1_RTS0_NUM_THRES GENMASK(31, 23) |
| 149 | +#define MT_AGG_PCR1_RTS0_LEN_THRES GENMASK(19, 0) |
| 150 | +#define MT_AGG_PCR1_RTS0_NUM_THRES_MT7916 GENMASK(29, 24) |
| 151 | +#define MT_AGG_PCR1_RTS0_LEN_THRES_MT7916 GENMASK(22, 0) |
| 152 | |
| 153 | #define MT_AGG_ACR0(_band) MT_WF_AGG(_band, __OFFS(AGG_ACR0)) |
| 154 | #define MT_AGG_ACR_CFEND_RATE GENMASK(13, 0) |
| 155 | diff --git a/mt7915/testmode.c b/mt7915/testmode.c |
| 156 | index 7ace05e0..931d1db2 100644 |
| 157 | --- a/mt7915/testmode.c |
| 158 | +++ b/mt7915/testmode.c |
| 159 | @@ -30,7 +30,7 @@ struct reg_band { |
| 160 | { _list.band[0] = MT_##_reg(0, _idx); \ |
| 161 | _list.band[1] = MT_##_reg(1, _idx); } |
| 162 | |
| 163 | -#define TM_REG_MAX_ID 17 |
| 164 | +#define TM_REG_MAX_ID 20 |
| 165 | static struct reg_band reg_backup_list[TM_REG_MAX_ID]; |
| 166 | |
| 167 | |
| 168 | @@ -133,6 +133,21 @@ mt7915_tm_clean_hwq(struct mt7915_phy *phy, u8 wcid) |
| 169 | sizeof(req), false); |
| 170 | } |
| 171 | |
| 172 | +static int |
| 173 | +mt7915_tm_set_phy_count(struct mt7915_phy *phy, u8 control) |
| 174 | +{ |
| 175 | + struct mt7915_dev *dev = phy->dev; |
| 176 | + struct mt7915_tm_cmd req = { |
| 177 | + .testmode_en = 1, |
| 178 | + .param_idx = MCU_ATE_SET_PHY_COUNT, |
| 179 | + .param.cfg.enable = control, |
| 180 | + .param.cfg.band = phy != &dev->phy, |
| 181 | + }; |
| 182 | + |
| 183 | + return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(ATE_CTRL), &req, |
| 184 | + sizeof(req), false); |
| 185 | +} |
| 186 | + |
| 187 | static int |
| 188 | mt7915_tm_set_slot_time(struct mt7915_phy *phy, u8 slot_time, u8 sifs) |
| 189 | { |
| 190 | @@ -335,7 +350,7 @@ mt7915_tm_reg_backup_restore(struct mt7915_phy *phy) |
| 191 | { |
| 192 | int n_regs = ARRAY_SIZE(reg_backup_list); |
| 193 | struct mt7915_dev *dev = phy->dev; |
| 194 | - u32 *b = phy->test.reg_backup; |
| 195 | + u32 *b = phy->test.reg_backup, val; |
| 196 | int i; |
| 197 | |
| 198 | REG_BAND_IDX(reg_backup_list[0], AGG_PCR0, 0); |
| 199 | @@ -347,18 +362,28 @@ mt7915_tm_reg_backup_restore(struct mt7915_phy *phy) |
| 200 | REG_BAND(reg_backup_list[6], AGG_MRCR); |
| 201 | REG_BAND(reg_backup_list[7], TMAC_TFCR0); |
| 202 | REG_BAND(reg_backup_list[8], TMAC_TCR0); |
| 203 | - REG_BAND(reg_backup_list[9], AGG_ATCR1); |
| 204 | - REG_BAND(reg_backup_list[10], AGG_ATCR3); |
| 205 | - REG_BAND(reg_backup_list[11], TMAC_TRCR0); |
| 206 | - REG_BAND(reg_backup_list[12], TMAC_ICR0); |
| 207 | - REG_BAND_IDX(reg_backup_list[13], ARB_DRNGR0, 0); |
| 208 | - REG_BAND_IDX(reg_backup_list[14], ARB_DRNGR0, 1); |
| 209 | - REG_BAND(reg_backup_list[15], WF_RFCR); |
| 210 | - REG_BAND(reg_backup_list[16], WF_RFCR1); |
| 211 | + REG_BAND(reg_backup_list[9], TMAC_TCR2); |
| 212 | + REG_BAND(reg_backup_list[10], AGG_ATCR1); |
| 213 | + REG_BAND(reg_backup_list[11], AGG_ATCR3); |
| 214 | + REG_BAND(reg_backup_list[12], TMAC_TRCR0); |
| 215 | + REG_BAND(reg_backup_list[13], TMAC_ICR0); |
| 216 | + REG_BAND_IDX(reg_backup_list[14], ARB_DRNGR0, 0); |
| 217 | + REG_BAND_IDX(reg_backup_list[15], ARB_DRNGR0, 1); |
| 218 | + REG_BAND(reg_backup_list[16], WF_RFCR); |
| 219 | + REG_BAND(reg_backup_list[17], WF_RFCR1); |
| 220 | + |
| 221 | + if (is_mt7916(&dev->mt76)) { |
| 222 | + reg_backup_list[18].band[phy->band_idx] = MT_MDP_TOP_DBG_WDT_CTRL; |
| 223 | + reg_backup_list[19].band[phy->band_idx] = MT_MDP_TOP_DBG_CTRL; |
| 224 | + } |
| 225 | |
| 226 | if (phy->mt76->test.state == MT76_TM_STATE_OFF) { |
| 227 | - for (i = 0; i < n_regs; i++) |
| 228 | - mt76_wr(dev, reg_backup_list[i].band[phy->band_idx], b[i]); |
| 229 | + for (i = 0; i < n_regs; i++) { |
| 230 | + u8 reg = reg_backup_list[i].band[phy->band_idx]; |
| 231 | + |
| 232 | + if (reg) |
| 233 | + mt76_wr(dev, reg, b[i]); |
| 234 | + } |
| 235 | return; |
| 236 | } |
| 237 | |
| 238 | @@ -378,8 +403,13 @@ mt7915_tm_reg_backup_restore(struct mt7915_phy *phy) |
| 239 | MT_AGG_PCR0_BW40_PROT | MT_AGG_PCR0_BW80_PROT); |
| 240 | mt76_set(dev, MT_AGG_PCR0(phy->band_idx, 0), MT_AGG_PCR0_PTA_WIN_DIS); |
| 241 | |
| 242 | - mt76_wr(dev, MT_AGG_PCR0(phy->band_idx, 1), MT_AGG_PCR1_RTS0_NUM_THRES | |
| 243 | - MT_AGG_PCR1_RTS0_LEN_THRES); |
| 244 | + if (is_mt7915(&dev->mt76)) |
| 245 | + val = MT_AGG_PCR1_RTS0_NUM_THRES | MT_AGG_PCR1_RTS0_LEN_THRES; |
| 246 | + else |
| 247 | + val = MT_AGG_PCR1_RTS0_NUM_THRES_MT7916 | |
| 248 | + MT_AGG_PCR1_RTS0_LEN_THRES_MT7916; |
| 249 | + |
| 250 | + mt76_wr(dev, MT_AGG_PCR0(phy->band_idx, 1), val); |
| 251 | |
| 252 | mt76_clear(dev, MT_AGG_MRCR(phy->band_idx), MT_AGG_MRCR_BAR_CNT_LIMIT | |
| 253 | MT_AGG_MRCR_LAST_RTS_CTS_RN | MT_AGG_MRCR_RTS_FAIL_LIMIT | |
| 254 | @@ -392,10 +422,19 @@ mt7915_tm_reg_backup_restore(struct mt7915_phy *phy) |
| 255 | |
| 256 | mt76_wr(dev, MT_TMAC_TFCR0(phy->band_idx), 0); |
| 257 | mt76_clear(dev, MT_TMAC_TCR0(phy->band_idx), MT_TMAC_TCR0_TBTT_STOP_CTRL); |
| 258 | + mt76_set(dev, MT_TMAC_TCR2(phy->band_idx), MT_TMAC_TCR2_SCH_DET_DIS); |
| 259 | |
| 260 | /* config rx filter for testmode rx */ |
| 261 | mt76_wr(dev, MT_WF_RFCR(phy->band_idx), 0xcf70a); |
| 262 | mt76_wr(dev, MT_WF_RFCR1(phy->band_idx), 0); |
| 263 | + |
| 264 | + if (is_mt7916(&dev->mt76)) { |
| 265 | + /* enable MDP Tx block mode */ |
| 266 | + mt76_clear(dev, MT_MDP_TOP_DBG_WDT_CTRL, |
| 267 | + MT_MDP_TOP_DBG_WDT_CTRL_TDP_DIS_BLK); |
| 268 | + mt76_clear(dev, MT_MDP_TOP_DBG_CTRL, |
| 269 | + MT_MDP_TOP_DBG_CTRL_ENQ_MODE); |
| 270 | + } |
| 271 | } |
| 272 | |
| 273 | static void |
| 274 | @@ -415,6 +454,8 @@ mt7915_tm_init(struct mt7915_phy *phy, bool en) |
| 275 | mt7915_mcu_add_bss_info(phy, phy->monitor_vif, en); |
| 276 | mt7915_mcu_add_sta(dev, phy->monitor_vif, NULL, en); |
| 277 | |
| 278 | + phy->mt76->test.flag |= MT_TM_FW_RX_COUNT; |
| 279 | + |
| 280 | if (!en) |
| 281 | mt7915_tm_set_tam_arb(phy, en, 0); |
| 282 | } |
| 283 | @@ -477,18 +518,63 @@ mt7915_tm_set_tx_frames(struct mt7915_phy *phy, bool en) |
| 284 | mt7915_tm_set_trx(phy, TM_MAC_TX, en); |
| 285 | } |
| 286 | |
| 287 | +static int |
| 288 | +mt7915_tm_get_rx_stats(struct mt7915_phy *phy, bool clear) |
| 289 | +{ |
| 290 | +#define CMD_RX_STAT_BAND 0x3 |
| 291 | + struct mt76_testmode_data *td = &phy->mt76->test; |
| 292 | + struct mt7915_tm_rx_stat_band *rs_band; |
| 293 | + struct mt7915_dev *dev = phy->dev; |
| 294 | + struct sk_buff *skb; |
| 295 | + struct { |
| 296 | + u8 format_id; |
| 297 | + u8 band; |
| 298 | + u8 _rsv[2]; |
| 299 | + } __packed req = { |
| 300 | + .format_id = CMD_RX_STAT_BAND, |
| 301 | + .band = phy != &dev->phy, |
| 302 | + }; |
| 303 | + int ret; |
| 304 | + |
| 305 | + ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_CMD(RX_STAT), |
| 306 | + &req, sizeof(req), true, &skb); |
| 307 | + if (ret) |
| 308 | + return ret; |
| 309 | + |
| 310 | + rs_band = (struct mt7915_tm_rx_stat_band *)skb->data; |
| 311 | + /* pr_info("mdrdy_cnt = %d\n", le32_to_cpu(rs_band->mdrdy_cnt)); */ |
| 312 | + /* pr_info("fcs_err = %d\n", le16_to_cpu(rs_band->fcs_err)); */ |
| 313 | + /* pr_info("len_mismatch = %d\n", le16_to_cpu(rs_band->len_mismatch)); */ |
| 314 | + /* pr_info("fcs_ok = %d\n", le16_to_cpu(rs_band->fcs_succ)); */ |
| 315 | + |
| 316 | + if (!clear) { |
| 317 | + enum mt76_rxq_id q = req.band ? MT_RXQ_BAND1 : MT_RXQ_MAIN; |
| 318 | + |
| 319 | + td->rx_stats.packets[q] += le32_to_cpu(rs_band->mdrdy_cnt); |
| 320 | + td->rx_stats.fcs_error[q] += le16_to_cpu(rs_band->fcs_err); |
| 321 | + td->rx_stats.len_mismatch += le16_to_cpu(rs_band->len_mismatch); |
| 322 | + } |
| 323 | + |
| 324 | + dev_kfree_skb(skb); |
| 325 | + |
| 326 | + return 0; |
| 327 | +} |
| 328 | + |
| 329 | static void |
| 330 | mt7915_tm_set_rx_frames(struct mt7915_phy *phy, bool en) |
| 331 | { |
| 332 | mt7915_tm_set_trx(phy, TM_MAC_RX_RXV, false); |
| 333 | |
| 334 | if (en) { |
| 335 | - struct mt7915_dev *dev = phy->dev; |
| 336 | - |
| 337 | mt7915_tm_update_channel(phy); |
| 338 | |
| 339 | /* read-clear */ |
| 340 | - mt76_rr(dev, MT_MIB_SDR3(phy->band_idx)); |
| 341 | + mt7915_tm_get_rx_stats(phy, true); |
| 342 | + |
| 343 | + /* clear fw count */ |
| 344 | + mt7915_tm_set_phy_count(phy, 0); |
| 345 | + mt7915_tm_set_phy_count(phy, 1); |
| 346 | + |
| 347 | mt7915_tm_set_trx(phy, TM_MAC_RX_RXV, en); |
| 348 | } |
| 349 | } |
| 350 | @@ -718,12 +804,8 @@ static int |
| 351 | mt7915_tm_dump_stats(struct mt76_phy *mphy, struct sk_buff *msg) |
| 352 | { |
| 353 | struct mt7915_phy *phy = mphy->priv; |
| 354 | - struct mt7915_dev *dev = phy->dev; |
| 355 | - enum mt76_rxq_id q; |
| 356 | void *rx, *rssi; |
| 357 | - u16 fcs_err; |
| 358 | int i; |
| 359 | - u32 cnt; |
| 360 | |
| 361 | rx = nla_nest_start(msg, MT76_TM_STATS_ATTR_LAST_RX); |
| 362 | if (!rx) |
| 363 | @@ -767,15 +849,7 @@ mt7915_tm_dump_stats(struct mt76_phy *mphy, struct sk_buff *msg) |
| 364 | |
| 365 | nla_nest_end(msg, rx); |
| 366 | |
| 367 | - cnt = mt76_rr(dev, MT_MIB_SDR3(phy->band_idx)); |
| 368 | - fcs_err = is_mt7915(&dev->mt76) ? FIELD_GET(MT_MIB_SDR3_FCS_ERR_MASK, cnt) : |
| 369 | - FIELD_GET(MT_MIB_SDR3_FCS_ERR_MASK_MT7916, cnt); |
| 370 | - |
| 371 | - q = phy->band_idx ? MT_RXQ_BAND1 : MT_RXQ_MAIN; |
| 372 | - mphy->test.rx_stats.packets[q] += fcs_err; |
| 373 | - mphy->test.rx_stats.fcs_error[q] += fcs_err; |
| 374 | - |
| 375 | - return 0; |
| 376 | + return mt7915_tm_get_rx_stats(phy, false); |
| 377 | } |
| 378 | |
| 379 | const struct mt76_testmode_ops mt7915_testmode_ops = { |
| 380 | diff --git a/mt7915/testmode.h b/mt7915/testmode.h |
| 381 | index 5573ac30..a1c54c89 100644 |
| 382 | --- a/mt7915/testmode.h |
| 383 | +++ b/mt7915/testmode.h |
| 384 | @@ -33,6 +33,12 @@ struct mt7915_tm_clean_txq { |
| 385 | u8 rsv; |
| 386 | }; |
| 387 | |
| 388 | +struct mt7915_tm_cfg { |
| 389 | + u8 enable; |
| 390 | + u8 band; |
| 391 | + u8 _rsv[2]; |
| 392 | +}; |
| 393 | + |
| 394 | struct mt7915_tm_cmd { |
| 395 | u8 testmode_en; |
| 396 | u8 param_idx; |
| 397 | @@ -43,6 +49,7 @@ struct mt7915_tm_cmd { |
| 398 | struct mt7915_tm_freq_offset freq; |
| 399 | struct mt7915_tm_slot_time slot; |
| 400 | struct mt7915_tm_clean_txq clean; |
| 401 | + struct mt7915_tm_cfg cfg; |
| 402 | u8 test[72]; |
| 403 | } param; |
| 404 | } __packed; |
| 405 | @@ -102,4 +109,25 @@ enum { |
| 406 | TAM_ARB_OP_MODE_FORCE_SU = 5, |
| 407 | }; |
| 408 | |
| 409 | +struct mt7915_tm_rx_stat_band { |
| 410 | + u8 category; |
| 411 | + |
| 412 | + /* mac */ |
| 413 | + __le16 fcs_err; |
| 414 | + __le16 len_mismatch; |
| 415 | + __le16 fcs_succ; |
| 416 | + __le32 mdrdy_cnt; |
| 417 | + /* phy */ |
| 418 | + __le16 fcs_err_cck; |
| 419 | + __le16 fcs_err_ofdm; |
| 420 | + __le16 pd_cck; |
| 421 | + __le16 pd_ofdm; |
| 422 | + __le16 sig_err_cck; |
| 423 | + __le16 sfd_err_cck; |
| 424 | + __le16 sig_err_ofdm; |
| 425 | + __le16 tag_err_ofdm; |
| 426 | + __le16 mdrdy_cnt_cck; |
| 427 | + __le16 mdrdy_cnt_ofdm; |
| 428 | +}; |
| 429 | + |
| 430 | #endif |
| 431 | diff --git a/testmode.c b/testmode.c |
| 432 | index 0accc71a..1d0d5d30 100644 |
| 433 | --- a/testmode.c |
| 434 | +++ b/testmode.c |
| 435 | @@ -447,8 +447,7 @@ int mt76_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 436 | mt76_tm_get_u8(tb[MT76_TM_ATTR_TX_RATE_LDPC], &td->tx_rate_ldpc, 0, 1) || |
| 437 | mt76_tm_get_u8(tb[MT76_TM_ATTR_TX_RATE_STBC], &td->tx_rate_stbc, 0, 1) || |
| 438 | mt76_tm_get_u8(tb[MT76_TM_ATTR_TX_LTF], &td->tx_ltf, 0, 2) || |
| 439 | - mt76_tm_get_u8(tb[MT76_TM_ATTR_TX_ANTENNA], |
| 440 | - &td->tx_antenna_mask, 0, 0xff) || |
| 441 | + mt76_tm_get_u8(tb[MT76_TM_ATTR_TX_ANTENNA], &td->tx_antenna_mask, 1, 0xff) || |
| 442 | mt76_tm_get_u8(tb[MT76_TM_ATTR_TX_SPE_IDX], &td->tx_spe_idx, 0, 27) || |
| 443 | mt76_tm_get_u8(tb[MT76_TM_ATTR_TX_DUTY_CYCLE], |
| 444 | &td->tx_duty_cycle, 0, 99) || |
| 445 | @@ -560,6 +559,9 @@ mt76_testmode_dump_stats(struct mt76_phy *phy, struct sk_buff *msg) |
| 446 | nla_put_u64_64bit(msg, MT76_TM_STATS_ATTR_RX_PACKETS, rx_packets, |
| 447 | MT76_TM_STATS_ATTR_PAD) || |
| 448 | nla_put_u64_64bit(msg, MT76_TM_STATS_ATTR_RX_FCS_ERROR, rx_fcs_error, |
| 449 | + MT76_TM_STATS_ATTR_PAD) || |
| 450 | + nla_put_u64_64bit(msg, MT76_TM_STATS_ATTR_RX_LEN_MISMATCH, |
| 451 | + td->rx_stats.len_mismatch, |
| 452 | MT76_TM_STATS_ATTR_PAD)) |
| 453 | return -EMSGSIZE; |
| 454 | |
| 455 | diff --git a/testmode.h b/testmode.h |
| 456 | index 5e2792d8..89613266 100644 |
| 457 | --- a/testmode.h |
| 458 | +++ b/testmode.h |
| 459 | @@ -101,6 +101,8 @@ enum mt76_testmode_attr { |
| 460 | * @MT76_TM_STATS_ATTR_RX_FCS_ERROR: number of rx packets with FCS error (u64) |
| 461 | * @MT76_TM_STATS_ATTR_LAST_RX: information about the last received packet |
| 462 | * see &enum mt76_testmode_rx_attr |
| 463 | + * @MT76_TM_STATS_ATTR_RX_LEN_MISMATCH: number of rx packets with length |
| 464 | + * mismatch error (u64) |
| 465 | */ |
| 466 | enum mt76_testmode_stats_attr { |
| 467 | MT76_TM_STATS_ATTR_UNSPEC, |
| 468 | @@ -113,6 +115,7 @@ enum mt76_testmode_stats_attr { |
| 469 | MT76_TM_STATS_ATTR_RX_PACKETS, |
| 470 | MT76_TM_STATS_ATTR_RX_FCS_ERROR, |
| 471 | MT76_TM_STATS_ATTR_LAST_RX, |
| 472 | + MT76_TM_STATS_ATTR_RX_LEN_MISMATCH, |
| 473 | |
| 474 | /* keep last */ |
| 475 | NUM_MT76_TM_STATS_ATTRS, |
| 476 | -- |
| 477 | 2.36.1 |
| 478 | |