Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

wifi: mt76: mt76x02: simplify struct mt76x02_rate_power

- remove stbc, because mt76x0 doesn't support it and mt76x2 uses the same
values as HT/VHT
- reduce vht array to 2 elements, because VHT MCS0-7 are the same as HT

Signed-off-by: Felix Fietkau <nbd@nbd.name>

+17 -46
+6 -18
drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c
··· 179 179 /* ht-vht mcs 1ss 0, 1, 2, 3 */ 180 180 addr = is_2ghz ? MT_EE_TX_POWER_BYRATE_BASE + 6 : 0x124; 181 181 val = mt76x02_eeprom_get(dev, addr); 182 - t->ht[0] = t->ht[1] = t->vht[0] = t->vht[1] = s6_to_s8(val); 183 - t->ht[2] = t->ht[3] = t->vht[2] = t->vht[3] = s6_to_s8(val >> 8); 182 + t->ht[0] = t->ht[1] = s6_to_s8(val); 183 + t->ht[2] = t->ht[3] = s6_to_s8(val >> 8); 184 184 185 185 /* ht-vht mcs 1ss 4, 5, 6 */ 186 186 addr = is_2ghz ? MT_EE_TX_POWER_BYRATE_BASE + 8 : 0x126; 187 187 val = mt76x02_eeprom_get(dev, addr); 188 - t->ht[4] = t->ht[5] = t->vht[4] = t->vht[5] = s6_to_s8(val); 189 - t->ht[6] = t->ht[7] = t->vht[6] = t->vht[7] = s6_to_s8(val >> 8); 190 - 191 - /* ht-vht mcs 1ss 0, 1, 2, 3 stbc */ 192 - addr = is_2ghz ? MT_EE_TX_POWER_BYRATE_BASE + 14 : 0xec; 193 - val = mt76x02_eeprom_get(dev, addr); 194 - t->stbc[0] = t->stbc[1] = s6_to_s8(val); 195 - t->stbc[2] = t->stbc[3] = s6_to_s8(val >> 8); 196 - 197 - /* ht-vht mcs 1ss 4, 5, 6 stbc */ 198 - addr = is_2ghz ? MT_EE_TX_POWER_BYRATE_BASE + 16 : 0xee; 199 - val = mt76x02_eeprom_get(dev, addr); 200 - t->stbc[4] = t->stbc[5] = s6_to_s8(val); 201 - t->stbc[6] = t->stbc[7] = s6_to_s8(val >> 8); 188 + t->ht[4] = t->ht[5] = s6_to_s8(val); 189 + t->ht[6] = t->ht[7] = s6_to_s8(val >> 8); 202 190 203 191 /* vht mcs 8, 9 5GHz */ 204 192 val = mt76x02_eeprom_get(dev, 0x12c); 205 - t->vht[8] = s6_to_s8(val); 206 - t->vht[9] = s6_to_s8(val >> 8); 193 + t->vht[0] = s6_to_s8(val); 194 + t->vht[1] = s6_to_s8(val >> 8); 207 195 208 196 delta = mt76x0_tssi_enabled(dev) ? 0 : mt76x0_get_delta(dev); 209 197 mt76x02_add_rate_power_offset(t, delta);
+2 -3
drivers/net/wireless/mediatek/mt76/mt76x02.h
··· 77 77 struct { 78 78 s8 cck[4]; 79 79 s8 ofdm[8]; 80 - s8 stbc[10]; 81 80 s8 ht[16]; 82 - s8 vht[10]; 81 + s8 vht[2]; 83 82 }; 84 - s8 all[48]; 83 + s8 all[30]; 85 84 }; 86 85 }; 87 86
-2
drivers/net/wireless/mediatek/mt76/mt76x02_debugfs.c
··· 122 122 ARRAY_SIZE(dev->rate_power.cck)); 123 123 mt76_seq_puts_array(s, "OFDM", dev->rate_power.ofdm, 124 124 ARRAY_SIZE(dev->rate_power.ofdm)); 125 - mt76_seq_puts_array(s, "STBC", dev->rate_power.stbc, 126 - ARRAY_SIZE(dev->rate_power.stbc)); 127 125 mt76_seq_puts_array(s, "HT", dev->rate_power.ht, 128 126 ARRAY_SIZE(dev->rate_power.ht)); 129 127 mt76_seq_puts_array(s, "VHT", dev->rate_power.vht,
-2
drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h
··· 62 62 MT_EE_TX_POWER_HT_MCS4 = 0x0a8, 63 63 MT_EE_TX_POWER_HT_MCS8 = 0x0aa, 64 64 MT_EE_TX_POWER_HT_MCS12 = 0x0ac, 65 - MT_EE_TX_POWER_VHT_MCS0 = 0x0ba, 66 - MT_EE_TX_POWER_VHT_MCS4 = 0x0bc, 67 65 MT_EE_TX_POWER_VHT_MCS8 = 0x0be, 68 66 69 67 MT_EE_2G_TARGET_POWER = 0x0d0,
+7 -7
drivers/net/wireless/mediatek/mt76/mt76x02_phy.c
··· 107 107 mt76x02_tx_power_mask(t->ht[4], t->ht[6], t->ht[8], 108 108 t->ht[10])); 109 109 mt76_wr(dev, MT_TX_PWR_CFG_3, 110 - mt76x02_tx_power_mask(t->ht[12], t->ht[14], t->stbc[0], 111 - t->stbc[2])); 110 + mt76x02_tx_power_mask(t->ht[12], t->ht[14], t->ht[0], 111 + t->ht[2])); 112 112 mt76_wr(dev, MT_TX_PWR_CFG_4, 113 - mt76x02_tx_power_mask(t->stbc[4], t->stbc[6], 0, 0)); 113 + mt76x02_tx_power_mask(t->ht[4], t->ht[6], 0, 0)); 114 114 mt76_wr(dev, MT_TX_PWR_CFG_7, 115 - mt76x02_tx_power_mask(t->ofdm[7], t->vht[8], t->ht[7], 116 - t->vht[9])); 115 + mt76x02_tx_power_mask(t->ofdm[7], t->vht[0], t->ht[7], 116 + t->vht[1])); 117 117 mt76_wr(dev, MT_TX_PWR_CFG_8, 118 - mt76x02_tx_power_mask(t->ht[14], 0, t->vht[8], t->vht[9])); 118 + mt76x02_tx_power_mask(t->ht[14], 0, t->vht[0], t->vht[1])); 119 119 mt76_wr(dev, MT_TX_PWR_CFG_9, 120 - mt76x02_tx_power_mask(t->ht[7], 0, t->stbc[8], t->stbc[9])); 120 + mt76x02_tx_power_mask(t->ht[7], 0, t->vht[0], t->vht[1])); 121 121 } 122 122 EXPORT_SYMBOL_GPL(mt76x02_phy_set_txpower); 123 123
+1 -1
drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c
··· 62 62 u8 mcs = ieee80211_rate_get_vht_mcs(rate); 63 63 64 64 if (mcs == 8 || mcs == 9) { 65 - max_txpwr = dev->rate_power.vht[8]; 65 + max_txpwr = dev->rate_power.vht[0]; 66 66 } else { 67 67 u8 nss, idx; 68 68
+1 -13
drivers/net/wireless/mediatek/mt76/mt76x2/eeprom.c
··· 324 324 t->ht[12] = t->ht[13] = mt76x02_rate_power_val(val); 325 325 t->ht[14] = t->ht[15] = mt76x02_rate_power_val(val >> 8); 326 326 327 - val = mt76x02_eeprom_get(dev, MT_EE_TX_POWER_VHT_MCS0); 328 - t->vht[0] = t->vht[1] = mt76x02_rate_power_val(val); 329 - t->vht[2] = t->vht[3] = mt76x02_rate_power_val(val >> 8); 330 - 331 - val = mt76x02_eeprom_get(dev, MT_EE_TX_POWER_VHT_MCS4); 332 - t->vht[4] = t->vht[5] = mt76x02_rate_power_val(val); 333 - t->vht[6] = t->vht[7] = mt76x02_rate_power_val(val >> 8); 334 - 335 327 val = mt76x02_eeprom_get(dev, MT_EE_TX_POWER_VHT_MCS8); 336 328 if (!is_5ghz) 337 329 val >>= 8; 338 - t->vht[8] = t->vht[9] = mt76x02_rate_power_val(val >> 8); 339 - 340 - memcpy(t->stbc, t->ht, sizeof(t->stbc[0]) * 8); 341 - t->stbc[8] = t->vht[8]; 342 - t->stbc[9] = t->vht[9]; 330 + t->vht[0] = t->vht[1] = mt76x02_rate_power_val(val >> 8); 343 331 } 344 332 EXPORT_SYMBOL_GPL(mt76x2_get_rate_power); 345 333