developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 1 | From f93eece806a777bea73ab2fcca1869b1b4b87b5c Mon Sep 17 00:00:00 2001 |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 2 | From: Shayne Chen <shayne.chen@mediatek.com> |
| 3 | Date: Wed, 13 Jul 2022 10:43:16 +0800 |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 6/7] mt76: mt7915: add spatial extension index support |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 5 | |
| 6 | Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> |
| 7 | --- |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 8 | mt76_connac.h | 11 +++++++++++ |
| 9 | mt76_connac_mac.c | 11 ++++++++--- |
| 10 | mt76_connac_mcu.h | 2 +- |
| 11 | mt7915/main.c | 3 --- |
| 12 | mt7915/mcu.c | 20 +++++++++++++++++++- |
| 13 | mt7915/mcu.h | 1 + |
| 14 | mt7915/testmode.c | 9 +++------ |
developer | c29985c | 2022-07-19 17:01:17 +0800 | [diff] [blame] | 15 | 7 files changed, 43 insertions(+), 14 deletions(-) |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 16 | |
| 17 | diff --git a/mt76_connac.h b/mt76_connac.h |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 18 | index 635192c8..0915eb57 100644 |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 19 | --- a/mt76_connac.h |
| 20 | +++ b/mt76_connac.h |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 21 | @@ -261,6 +261,17 @@ mt76_connac_txwi_to_txp(struct mt76_dev *dev, struct mt76_txwi_cache *t) |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 22 | return (void *)(txwi + MT_TXD_SIZE); |
| 23 | } |
| 24 | |
| 25 | +static inline u8 mt76_connac_spe_idx(u8 antenna_mask) |
| 26 | +{ |
| 27 | + static const u8 ant_to_spe[] = {0, 0, 1, 0, 3, 2, 4, 0, |
| 28 | + 9, 8, 6, 10, 16, 12, 18, 0}; |
| 29 | + |
| 30 | + if (antenna_mask >= sizeof(ant_to_spe)) |
| 31 | + return 0; |
| 32 | + |
| 33 | + return ant_to_spe[antenna_mask]; |
| 34 | +} |
| 35 | + |
| 36 | int mt76_connac_pm_wake(struct mt76_phy *phy, struct mt76_connac_pm *pm); |
| 37 | void mt76_connac_power_save_sched(struct mt76_phy *phy, |
| 38 | struct mt76_connac_pm *pm); |
| 39 | diff --git a/mt76_connac_mac.c b/mt76_connac_mac.c |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 40 | index 34ac3d81..8b7ec64a 100644 |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 41 | --- a/mt76_connac_mac.c |
| 42 | +++ b/mt76_connac_mac.c |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 43 | @@ -417,9 +417,6 @@ mt76_connac2_mac_write_txwi_80211(struct mt76_dev *dev, __le32 *txwi, |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 44 | if (ieee80211_is_beacon(fc)) { |
| 45 | txwi[3] &= ~cpu_to_le32(MT_TXD3_SW_POWER_MGMT); |
| 46 | txwi[3] |= cpu_to_le32(MT_TXD3_REM_TX_COUNT); |
| 47 | - if (!is_mt7921(dev)) |
| 48 | - txwi[7] |= cpu_to_le32(FIELD_PREP(MT_TXD7_SPE_IDX, |
| 49 | - 0x18)); |
| 50 | } |
| 51 | |
| 52 | if (info->flags & IEEE80211_TX_CTL_INJECTED) { |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 53 | @@ -550,6 +547,14 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi, |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 54 | val |= FIELD_PREP(MT_TXD6_TX_RATE, rate); |
| 55 | txwi[6] |= cpu_to_le32(val); |
| 56 | txwi[3] |= cpu_to_le32(MT_TXD3_BA_DISABLE); |
| 57 | + |
| 58 | + if (!is_mt7921(dev)) { |
| 59 | + u8 spe_idx = mt76_connac_spe_idx(mphy->antenna_mask); |
| 60 | + |
| 61 | + if (!spe_idx) |
developer | 4df64ba | 2022-09-01 14:44:55 +0800 | [diff] [blame] | 62 | + spe_idx = 24 + phy_idx; |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 63 | + txwi[7] |= cpu_to_le32(FIELD_PREP(MT_TXD7_SPE_IDX, spe_idx)); |
| 64 | + } |
| 65 | } |
| 66 | } |
| 67 | EXPORT_SYMBOL_GPL(mt76_connac2_mac_write_txwi); |
| 68 | diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 69 | index f62af7a8..31017218 100644 |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 70 | --- a/mt76_connac_mcu.h |
| 71 | +++ b/mt76_connac_mcu.h |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 72 | @@ -580,7 +580,7 @@ struct sta_rec_ra_fixed { |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 73 | |
| 74 | struct sta_phy phy; |
| 75 | |
| 76 | - u8 spe_en; |
| 77 | + u8 spe_idx; |
| 78 | u8 short_preamble; |
| 79 | u8 is_5g; |
| 80 | u8 mmps_mode; |
| 81 | diff --git a/mt7915/main.c b/mt7915/main.c |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 82 | index 2557fe08..edd678ce 100644 |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 83 | --- a/mt7915/main.c |
| 84 | +++ b/mt7915/main.c |
| 85 | @@ -957,9 +957,6 @@ mt7915_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant) |
| 86 | if (!tx_ant || tx_ant != rx_ant || ffs(tx_ant) > max_nss) |
| 87 | return -EINVAL; |
| 88 | |
| 89 | - if ((BIT(hweight8(tx_ant)) - 1) != tx_ant) |
| 90 | - tx_ant = BIT(ffs(tx_ant) - 1) - 1; |
| 91 | - |
| 92 | mutex_lock(&dev->mt76.mutex); |
| 93 | |
| 94 | phy->mt76->antenna_mask = tx_ant; |
| 95 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 96 | index 2d6642e6..19a33120 100644 |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 97 | --- a/mt7915/mcu.c |
| 98 | +++ b/mt7915/mcu.c |
| 99 | @@ -1306,6 +1306,9 @@ int mt7915_mcu_set_fixed_rate_ctrl(struct mt7915_dev *dev, |
| 100 | case RATE_PARAM_MMPS_UPDATE: |
| 101 | ra->mmps_mode = mt7915_mcu_get_mmps_mode(sta->smps_mode); |
| 102 | break; |
| 103 | + case RATE_PARAM_SPE_UPDATE: |
| 104 | + ra->spe_idx = *(u8 *)data; |
| 105 | + break; |
| 106 | default: |
| 107 | break; |
| 108 | } |
developer | c29985c | 2022-07-19 17:01:17 +0800 | [diff] [blame] | 109 | @@ -1348,6 +1351,18 @@ int mt7915_mcu_add_smps(struct mt7915_dev *dev, struct ieee80211_vif *vif, |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 110 | RATE_PARAM_MMPS_UPDATE); |
| 111 | } |
| 112 | |
| 113 | +static int |
| 114 | +mt7915_mcu_set_spe_idx(struct mt7915_dev *dev, struct ieee80211_vif *vif, |
developer | c29985c | 2022-07-19 17:01:17 +0800 | [diff] [blame] | 115 | + struct ieee80211_sta *sta) |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 116 | +{ |
| 117 | + struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; |
| 118 | + struct mt76_phy *mphy = mvif->phy->mt76; |
| 119 | + u8 spe_idx = mt76_connac_spe_idx(mphy->antenna_mask); |
| 120 | + |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 121 | + return mt7915_mcu_set_fixed_rate_ctrl(dev, vif, sta, &spe_idx, |
| 122 | + RATE_PARAM_SPE_UPDATE); |
| 123 | +} |
| 124 | + |
| 125 | static int |
| 126 | mt7915_mcu_add_rate_ctrl_fixed(struct mt7915_dev *dev, |
| 127 | struct ieee80211_vif *vif, |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 128 | @@ -1435,7 +1450,7 @@ mt7915_mcu_add_rate_ctrl_fixed(struct mt7915_dev *dev, |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 129 | return ret; |
| 130 | } |
| 131 | |
| 132 | - return 0; |
developer | c29985c | 2022-07-19 17:01:17 +0800 | [diff] [blame] | 133 | + return mt7915_mcu_set_spe_idx(dev, vif, sta); |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | static void |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 137 | @@ -2648,6 +2663,9 @@ int mt7915_mcu_set_chan_info(struct mt7915_phy *phy, int cmd) |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 138 | } |
| 139 | #endif |
| 140 | |
| 141 | + if (mt76_connac_spe_idx(phy->mt76->antenna_mask)) |
| 142 | + req.tx_streams_num = fls(phy->mt76->antenna_mask); |
| 143 | + |
| 144 | if (cmd == MCU_EXT_CMD(SET_RX_PATH) || |
| 145 | dev->mt76.hw->conf.flags & IEEE80211_CONF_MONITOR) |
| 146 | req.switch_reason = CH_SWITCH_NORMAL; |
| 147 | diff --git a/mt7915/mcu.h b/mt7915/mcu.h |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 148 | index 110e4f36..ed949802 100644 |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 149 | --- a/mt7915/mcu.h |
| 150 | +++ b/mt7915/mcu.h |
| 151 | @@ -395,6 +395,7 @@ enum { |
| 152 | RATE_PARAM_FIXED_MCS, |
| 153 | RATE_PARAM_FIXED_GI = 11, |
| 154 | RATE_PARAM_AUTO = 20, |
| 155 | + RATE_PARAM_SPE_UPDATE = 22, |
| 156 | }; |
| 157 | |
| 158 | #define RATE_CFG_MCS GENMASK(3, 0) |
| 159 | diff --git a/mt7915/testmode.c b/mt7915/testmode.c |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 160 | index 6c05dfab..35345d35 100644 |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 161 | --- a/mt7915/testmode.c |
| 162 | +++ b/mt7915/testmode.c |
| 163 | @@ -473,8 +473,6 @@ mt7915_tm_update_channel(struct mt7915_phy *phy) |
| 164 | static void |
| 165 | mt7915_tm_set_tx_frames(struct mt7915_phy *phy, bool en) |
| 166 | { |
| 167 | - static const u8 spe_idx_map[] = {0, 0, 1, 0, 3, 2, 4, 0, |
| 168 | - 9, 8, 6, 10, 16, 12, 18, 0}; |
| 169 | struct mt76_testmode_data *td = &phy->mt76->test; |
| 170 | struct mt7915_dev *dev = phy->dev; |
| 171 | struct ieee80211_tx_info *info; |
| 172 | @@ -488,11 +486,10 @@ mt7915_tm_set_tx_frames(struct mt7915_phy *phy, bool en) |
| 173 | if (en) { |
| 174 | mt7915_tm_update_channel(phy); |
| 175 | |
| 176 | - if (td->tx_spe_idx) { |
| 177 | + if (td->tx_spe_idx) |
| 178 | phy->test.spe_idx = td->tx_spe_idx; |
| 179 | - } else { |
| 180 | - phy->test.spe_idx = spe_idx_map[td->tx_antenna_mask]; |
| 181 | - } |
| 182 | + else |
| 183 | + phy->test.spe_idx = mt76_connac_spe_idx(td->tx_antenna_mask); |
| 184 | } |
| 185 | |
| 186 | mt7915_tm_set_tam_arb(phy, en, |
| 187 | -- |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 188 | 2.25.1 |
developer | d497569 | 2022-07-15 18:30:03 +0800 | [diff] [blame] | 189 | |