wifi: mt76: mt7915: rework testmode tx antenna setting
authorShayne Chen <shayne.chen@mediatek.com>
Fri, 30 Sep 2022 15:13:12 +0000 (23:13 +0800)
committerFelix Fietkau <nbd@nbd.name>
Thu, 1 Dec 2022 16:29:12 +0000 (17:29 +0100)
Let the configuration of testmode antenna mask on both band0 and band1
become antenna_mask rather than chainmask. This could simplify the
settings for user and get rid of the conversion when sending fw command.

Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
drivers/net/wireless/mediatek/mt76/mt7915/testmode.c

index b9ad24b1935a905ea7f4e712b87a32c9d4cfafb7..4a2196f9df61463a22c8ddbbe66ea77fac16168a 100644 (file)
@@ -2642,14 +2642,9 @@ int mt7915_mcu_set_chan_info(struct mt7915_phy *phy, int cmd)
 
 #ifdef CONFIG_NL80211_TESTMODE
        if (phy->mt76->test.tx_antenna_mask &&
-           (phy->mt76->test.state == MT76_TM_STATE_TX_FRAMES ||
-            phy->mt76->test.state == MT76_TM_STATE_RX_FRAMES ||
-            phy->mt76->test.state == MT76_TM_STATE_TX_CONT)) {
+           mt76_testmode_enabled(phy->mt76)) {
                req.tx_path_num = fls(phy->mt76->test.tx_antenna_mask);
                req.rx_path = phy->mt76->test.tx_antenna_mask;
-
-               if (phy != &dev->phy)
-                       req.rx_streams >>= dev->chainshift;
        }
 #endif
 
index efb9bb8231e27d584a5cc53080b436cdf08bb28d..e1838f046568b5edf6d40a979a1588099d547a9a 100644 (file)
@@ -447,15 +447,10 @@ mt7915_tm_set_tx_frames(struct mt7915_phy *phy, bool en)
        if (en) {
                mt7915_tm_update_channel(phy);
 
-               if (td->tx_spe_idx) {
+               if (td->tx_spe_idx)
                        phy->test.spe_idx = td->tx_spe_idx;
-               } else {
-                       u8 tx_ant = td->tx_antenna_mask;
-
-                       if (phy != &dev->phy)
-                               tx_ant >>= dev->chainshift;
-                       phy->test.spe_idx = spe_idx_map[tx_ant];
-               }
+               else
+                       phy->test.spe_idx = spe_idx_map[td->tx_antenna_mask];
        }
 
        mt7915_tm_set_tam_arb(phy, en,
@@ -696,7 +691,9 @@ mt7915_tm_set_params(struct mt76_phy *mphy, struct nlattr **tb,
 {
        struct mt76_testmode_data *td = &mphy->test;
        struct mt7915_phy *phy = mphy->priv;
-       u32 changed = 0;
+       struct mt7915_dev *dev = phy->dev;
+       u32 chainmask = mphy->chainmask, changed = 0;
+       bool ext_phy = phy != &dev->phy;
        int i;
 
        BUILD_BUG_ON(NUM_TM_CHANGED >= 32);
@@ -705,7 +702,8 @@ mt7915_tm_set_params(struct mt76_phy *mphy, struct nlattr **tb,
            td->state == MT76_TM_STATE_OFF)
                return 0;
 
-       if (td->tx_antenna_mask & ~mphy->chainmask)
+       chainmask = ext_phy ? chainmask >> dev->chainshift : chainmask;
+       if (td->tx_antenna_mask > chainmask)
                return -EINVAL;
 
        for (i = 0; i < ARRAY_SIZE(tm_change_map); i++) {