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

Merge tag 'mt76-for-kvalo-2021-10-23' of https://github.com/nbd168/wireless

mt76 patches for 5.16

* fix a compile error with !CONFIG_PM
* cleanups
* MT7915 DBDC fixes
* endian warning fixes

+414 -100
+4 -1
drivers/net/wireless/mediatek/mt76/eeprom.c
··· 65 65 offset = be32_to_cpup(list); 66 66 ret = mtd_read(mtd, offset, len, &retlen, eep); 67 67 put_mtd_device(mtd); 68 - if (ret) 68 + if (ret) { 69 + dev_err(dev->dev, "reading EEPROM from mtd %s failed: %i\n", 70 + part, ret); 69 71 goto out_put_node; 72 + } 70 73 71 74 if (retlen < len) { 72 75 ret = -EINVAL;
+20 -2
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
··· 1698 1698 sizeof(data), true); 1699 1699 } 1700 1700 1701 + static int mt7615_mcu_cal_cache_apply(struct mt7615_dev *dev) 1702 + { 1703 + struct { 1704 + bool cache_enable; 1705 + u8 pad[3]; 1706 + } data = { 1707 + .cache_enable = true 1708 + }; 1709 + 1710 + return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_CAL_CACHE, &data, 1711 + sizeof(data), false); 1712 + } 1713 + 1701 1714 static int mt7663_load_n9(struct mt7615_dev *dev, const char *name) 1702 1715 { 1703 1716 u32 offset = 0, override_addr = 0, flag = FW_START_DLYCAL; ··· 1919 1906 mt76_queue_tx_cleanup(dev, dev->mt76.q_mcu[MT_MCUQ_FWDL], false); 1920 1907 dev_dbg(dev->mt76.dev, "Firmware init done\n"); 1921 1908 set_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state); 1922 - mt7615_mcu_fw_log_2_host(dev, 0); 1923 1909 1924 - return 0; 1910 + if (dev->dbdc_support) { 1911 + ret = mt7615_mcu_cal_cache_apply(dev); 1912 + if (ret) 1913 + return ret; 1914 + } 1915 + 1916 + return mt7615_mcu_fw_log_2_host(dev, 0); 1925 1917 } 1926 1918 EXPORT_SYMBOL_GPL(mt7615_mcu_init); 1927 1919
+1 -1
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
··· 2477 2477 mt76_connac_mcu_set_wow_ctrl(phy, vif, suspend, wowlan); 2478 2478 } 2479 2479 EXPORT_SYMBOL_GPL(mt76_connac_mcu_set_suspend_iter); 2480 + #endif /* CONFIG_PM */ 2480 2481 2481 2482 u32 mt76_connac_mcu_reg_rr(struct mt76_dev *dev, u32 offset) 2482 2483 { ··· 2506 2505 mt76_mcu_send_msg(dev, MCU_CMD_REG_WRITE, &req, sizeof(req), false); 2507 2506 } 2508 2507 EXPORT_SYMBOL_GPL(mt76_connac_mcu_reg_wr); 2509 - #endif /* CONFIG_PM */ 2510 2508 2511 2509 MODULE_AUTHOR("Lorenzo Bianconi <lorenzo@kernel.org>"); 2512 2510 MODULE_LICENSE("Dual BSD/GPL");
+1
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
··· 531 531 MCU_EXT_CMD_TX_POWER_FEATURE_CTRL = 0x58, 532 532 MCU_EXT_CMD_RXDCOC_CAL = 0x59, 533 533 MCU_EXT_CMD_TXDPD_CAL = 0x60, 534 + MCU_EXT_CMD_CAL_CACHE = 0x67, 534 535 MCU_EXT_CMD_SET_RDD_TH = 0x7c, 535 536 MCU_EXT_CMD_SET_RDD_PATTERN = 0x7d, 536 537 };
+148 -17
drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
··· 82 82 mt7915_radar_trigger, "%lld\n"); 83 83 84 84 static int 85 - mt7915_fw_debug_set(void *data, u64 val) 85 + mt7915_fw_debug_wm_set(void *data, u64 val) 86 86 { 87 87 struct mt7915_dev *dev = data; 88 88 enum { ··· 92 92 DEBUG_SPL, 93 93 DEBUG_RPT_RX, 94 94 } debug; 95 + int ret; 95 96 96 - dev->fw_debug = !!val; 97 + dev->fw_debug_wm = val ? MCU_FW_LOG_TO_HOST : 0; 97 98 98 - mt7915_mcu_fw_log_2_host(dev, dev->fw_debug ? 2 : 0); 99 + ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WM, dev->fw_debug_wm); 100 + if (ret) 101 + return ret; 99 102 100 - for (debug = DEBUG_TXCMD; debug <= DEBUG_RPT_RX; debug++) 101 - mt7915_mcu_fw_dbg_ctrl(dev, debug, dev->fw_debug); 103 + for (debug = DEBUG_TXCMD; debug <= DEBUG_RPT_RX; debug++) { 104 + ret = mt7915_mcu_fw_dbg_ctrl(dev, debug, !!dev->fw_debug_wm); 105 + if (ret) 106 + return ret; 107 + } 108 + 109 + /* WM CPU info record control */ 110 + mt76_clear(dev, MT_CPU_UTIL_CTRL, BIT(0)); 111 + mt76_wr(dev, MT_DIC_CMD_REG_CMD, BIT(2) | BIT(13) | !dev->fw_debug_wm); 112 + mt76_wr(dev, MT_MCU_WM_CIRQ_IRQ_MASK_CLR_ADDR, BIT(5)); 113 + mt76_wr(dev, MT_MCU_WM_CIRQ_IRQ_SOFT_ADDR, BIT(5)); 102 114 103 115 return 0; 104 116 } 105 117 106 118 static int 107 - mt7915_fw_debug_get(void *data, u64 *val) 119 + mt7915_fw_debug_wm_get(void *data, u64 *val) 108 120 { 109 121 struct mt7915_dev *dev = data; 110 122 111 - *val = dev->fw_debug; 123 + *val = dev->fw_debug_wm; 112 124 113 125 return 0; 114 126 } 115 127 116 - DEFINE_DEBUGFS_ATTRIBUTE(fops_fw_debug, mt7915_fw_debug_get, 117 - mt7915_fw_debug_set, "%lld\n"); 128 + DEFINE_DEBUGFS_ATTRIBUTE(fops_fw_debug_wm, mt7915_fw_debug_wm_get, 129 + mt7915_fw_debug_wm_set, "%lld\n"); 130 + 131 + static int 132 + mt7915_fw_debug_wa_set(void *data, u64 val) 133 + { 134 + struct mt7915_dev *dev = data; 135 + int ret; 136 + 137 + dev->fw_debug_wa = val ? MCU_FW_LOG_TO_HOST : 0; 138 + 139 + ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WA, dev->fw_debug_wa); 140 + if (ret) 141 + return ret; 142 + 143 + return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), MCU_WA_PARAM_PDMA_RX, 144 + !!dev->fw_debug_wa, 0); 145 + } 146 + 147 + static int 148 + mt7915_fw_debug_wa_get(void *data, u64 *val) 149 + { 150 + struct mt7915_dev *dev = data; 151 + 152 + *val = dev->fw_debug_wa; 153 + 154 + return 0; 155 + } 156 + 157 + DEFINE_DEBUGFS_ATTRIBUTE(fops_fw_debug_wa, mt7915_fw_debug_wa_get, 158 + mt7915_fw_debug_wa_set, "%lld\n"); 159 + 160 + static int 161 + mt7915_fw_util_wm_show(struct seq_file *file, void *data) 162 + { 163 + struct mt7915_dev *dev = file->private; 164 + 165 + if (dev->fw_debug_wm) { 166 + seq_printf(file, "Busy: %u%% Peak busy: %u%%\n", 167 + mt76_rr(dev, MT_CPU_UTIL_BUSY_PCT), 168 + mt76_rr(dev, MT_CPU_UTIL_PEAK_BUSY_PCT)); 169 + seq_printf(file, "Idle count: %u Peak idle count: %u\n", 170 + mt76_rr(dev, MT_CPU_UTIL_IDLE_CNT), 171 + mt76_rr(dev, MT_CPU_UTIL_PEAK_IDLE_CNT)); 172 + } 173 + 174 + return 0; 175 + } 176 + 177 + DEFINE_SHOW_ATTRIBUTE(mt7915_fw_util_wm); 178 + 179 + static int 180 + mt7915_fw_util_wa_show(struct seq_file *file, void *data) 181 + { 182 + struct mt7915_dev *dev = file->private; 183 + 184 + if (dev->fw_debug_wa) 185 + return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(QUERY), 186 + MCU_WA_PARAM_CPU_UTIL, 0, 0); 187 + 188 + return 0; 189 + } 190 + 191 + DEFINE_SHOW_ATTRIBUTE(mt7915_fw_util_wa); 118 192 119 193 static void 120 194 mt7915_ampdu_stat_read_phy(struct mt7915_phy *phy, ··· 534 460 debugfs_create_file("xmit-queues", 0400, dir, phy, 535 461 &mt7915_xmit_queues_fops); 536 462 debugfs_create_file("tx_stats", 0400, dir, phy, &mt7915_tx_stats_fops); 537 - debugfs_create_file("fw_debug", 0600, dir, dev, &fops_fw_debug); 463 + debugfs_create_file("fw_debug_wm", 0600, dir, dev, &fops_fw_debug_wm); 464 + debugfs_create_file("fw_debug_wa", 0600, dir, dev, &fops_fw_debug_wa); 465 + debugfs_create_file("fw_util_wm", 0400, dir, dev, 466 + &mt7915_fw_util_wm_fops); 467 + debugfs_create_file("fw_util_wa", 0400, dir, dev, 468 + &mt7915_fw_util_wa_fops); 538 469 debugfs_create_file("implicit_txbf", 0600, dir, dev, 539 470 &fops_implicit_txbf); 540 471 debugfs_create_file("txpower_sku", 0400, dir, phy, ··· 560 481 #ifdef CONFIG_MAC80211_DEBUGFS 561 482 /** per-station debugfs **/ 562 483 563 - static int mt7915_sta_fixed_rate_set(void *data, u64 rate) 484 + static ssize_t mt7915_sta_fixed_rate_set(struct file *file, 485 + const char __user *user_buf, 486 + size_t count, loff_t *ppos) 564 487 { 565 - struct ieee80211_sta *sta = data; 488 + struct ieee80211_sta *sta = file->private_data; 566 489 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; 490 + struct mt7915_dev *dev = msta->vif->phy->dev; 491 + struct ieee80211_vif *vif; 492 + struct sta_phy phy = {}; 493 + char buf[100]; 494 + int ret; 495 + u32 field; 496 + u8 i, gi, he_ltf; 567 497 568 - /* usage: <he ltf> <tx mode> <ldpc> <stbc> <bw> <gi> <nss> <mcs> 569 - * <tx mode>: see enum mt76_phy_type 498 + if (count >= sizeof(buf)) 499 + return -EINVAL; 500 + 501 + if (copy_from_user(buf, user_buf, count)) 502 + return -EFAULT; 503 + 504 + if (count && buf[count - 1] == '\n') 505 + buf[count - 1] = '\0'; 506 + else 507 + buf[count] = '\0'; 508 + 509 + /* mode - cck: 0, ofdm: 1, ht: 2, gf: 3, vht: 4, he_su: 8, he_er: 9 510 + * bw - bw20: 0, bw40: 1, bw80: 2, bw160: 3 511 + * nss - vht: 1~4, he: 1~4, others: ignore 512 + * mcs - cck: 0~4, ofdm: 0~7, ht: 0~32, vht: 0~9, he_su: 0~11, he_er: 0~2 513 + * gi - (ht/vht) lgi: 0, sgi: 1; (he) 0.8us: 0, 1.6us: 1, 3.2us: 2 514 + * ldpc - off: 0, on: 1 515 + * stbc - off: 0, on: 1 516 + * he_ltf - 1xltf: 0, 2xltf: 1, 4xltf: 2 570 517 */ 571 - return mt7915_mcu_set_fixed_rate(msta->vif->phy->dev, sta, rate); 518 + if (sscanf(buf, "%hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu", 519 + &phy.type, &phy.bw, &phy.nss, &phy.mcs, &gi, 520 + &phy.ldpc, &phy.stbc, &he_ltf) != 8) { 521 + dev_warn(dev->mt76.dev, 522 + "format: Mode BW NSS MCS (HE)GI LDPC STBC HE_LTF\n"); 523 + field = RATE_PARAM_AUTO; 524 + goto out; 525 + } 526 + 527 + phy.ldpc = (phy.bw || phy.ldpc) * GENMASK(2, 0); 528 + for (i = 0; i <= phy.bw; i++) { 529 + phy.sgi |= gi << (i << sta->he_cap.has_he); 530 + phy.he_ltf |= he_ltf << (i << sta->he_cap.has_he); 531 + } 532 + field = RATE_PARAM_FIXED; 533 + 534 + out: 535 + vif = container_of((void *)msta->vif, struct ieee80211_vif, drv_priv); 536 + ret = mt7915_mcu_set_fixed_rate_ctrl(dev, vif, sta, &phy, field); 537 + if (ret) 538 + return -EFAULT; 539 + 540 + return count; 572 541 } 573 542 574 - DEFINE_DEBUGFS_ATTRIBUTE(fops_fixed_rate, NULL, 575 - mt7915_sta_fixed_rate_set, "%llx\n"); 543 + static const struct file_operations fops_fixed_rate = { 544 + .write = mt7915_sta_fixed_rate_set, 545 + .open = simple_open, 546 + .owner = THIS_MODULE, 547 + .llseek = default_llseek, 548 + }; 576 549 577 550 static int 578 551 mt7915_queues_show(struct seq_file *s, void *data)
+3 -5
drivers/net/wireless/mediatek/mt76/mt7915/mac.c
··· 89 89 0, 5000); 90 90 } 91 91 92 - static u32 mt7915_mac_wtbl_lmac_addr(struct mt7915_dev *dev, u16 wcid, u8 dw) 92 + u32 mt7915_mac_wtbl_lmac_addr(struct mt7915_dev *dev, u16 wcid, u8 dw) 93 93 { 94 94 mt76_wr(dev, MT_WTBLON_TOP_WDUCR, 95 95 FIELD_PREP(MT_WTBLON_TOP_WDUCR_GROUP, (wcid >> 7))); ··· 2077 2077 2078 2078 if (changed & (IEEE80211_RC_SUPP_RATES_CHANGED | 2079 2079 IEEE80211_RC_NSS_CHANGED | 2080 - IEEE80211_RC_BW_CHANGED)) { 2081 - mt7915_mcu_add_he(dev, vif, sta); 2082 - mt7915_mcu_add_rate_ctrl(dev, vif, sta); 2083 - } 2080 + IEEE80211_RC_BW_CHANGED)) 2081 + mt7915_mcu_add_rate_ctrl(dev, vif, sta, true); 2084 2082 2085 2083 if (changed & IEEE80211_RC_SMPS_CHANGED) 2086 2084 mt7915_mcu_add_smps(dev, vif, sta);
+19 -15
drivers/net/wireless/mediatek/mt76/mt7915/main.c
··· 172 172 int i; 173 173 174 174 for (i = 0; i < ARRAY_SIZE(mvif->bitrate_mask.control); i++) { 175 + mvif->bitrate_mask.control[i].gi = NL80211_TXRATE_DEFAULT_GI; 176 + mvif->bitrate_mask.control[i].he_gi = GENMASK(7, 0); 177 + mvif->bitrate_mask.control[i].he_ltf = GENMASK(7, 0); 175 178 mvif->bitrate_mask.control[i].legacy = GENMASK(31, 0); 176 179 memset(mvif->bitrate_mask.control[i].ht_mcs, GENMASK(7, 0), 177 180 sizeof(mvif->bitrate_mask.control[i].ht_mcs)); ··· 666 663 if (ret) 667 664 return ret; 668 665 669 - return mt7915_mcu_add_rate_ctrl(dev, vif, sta); 666 + return mt7915_mcu_add_rate_ctrl(dev, vif, sta, false); 670 667 } 671 668 672 669 void mt7915_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, ··· 997 994 { 998 995 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; 999 996 struct mt7915_dev *dev = msta->vif->phy->dev; 1000 - struct ieee80211_hw *hw = msta->vif->phy->mt76->hw; 1001 997 u32 *changed = data; 1002 998 1003 999 spin_lock_bh(&dev->sta_poll_lock); ··· 1004 1002 if (list_empty(&msta->rc_list)) 1005 1003 list_add_tail(&msta->rc_list, &dev->sta_rc_list); 1006 1004 spin_unlock_bh(&dev->sta_poll_lock); 1007 - 1008 - ieee80211_queue_work(hw, &dev->rc_work); 1009 1005 } 1010 1006 1011 1007 static void mt7915_sta_rc_update(struct ieee80211_hw *hw, ··· 1011 1011 struct ieee80211_sta *sta, 1012 1012 u32 changed) 1013 1013 { 1014 + struct mt7915_phy *phy = mt7915_hw_phy(hw); 1015 + struct mt7915_dev *dev = phy->dev; 1016 + 1014 1017 mt7915_sta_rc_work(&changed, sta); 1018 + ieee80211_queue_work(hw, &dev->rc_work); 1015 1019 } 1016 1020 1017 1021 static int ··· 1023 1019 const struct cfg80211_bitrate_mask *mask) 1024 1020 { 1025 1021 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; 1026 - enum nl80211_band band = mvif->phy->mt76->chandef.chan->band; 1027 - u32 changed; 1022 + struct mt7915_phy *phy = mt7915_hw_phy(hw); 1023 + struct mt7915_dev *dev = phy->dev; 1024 + u32 changed = IEEE80211_RC_SUPP_RATES_CHANGED; 1028 1025 1029 - if (mask->control[band].gi == NL80211_TXRATE_FORCE_LGI) 1030 - return -EINVAL; 1031 - 1032 - changed = IEEE80211_RC_SUPP_RATES_CHANGED; 1033 1026 mvif->bitrate_mask = *mask; 1034 1027 1035 - /* Update firmware rate control to add a boundary on top of table 1036 - * to limit the rate selection for each peer, so when set bitrates 1037 - * vht-mcs-5 1:9, which actually means nss = 1 mcs = 0~9. This only 1038 - * applies to data frames as for the other mgmt, mcast, bcast still 1039 - * use legacy rates as it is. 1028 + /* if multiple rates across different preambles are given we can 1029 + * reconfigure this info with all peers using sta_rec command with 1030 + * the below exception cases. 1031 + * - single rate : if a rate is passed along with different preambles, 1032 + * we select the highest one as fixed rate. i.e VHT MCS for VHT peers. 1033 + * - multiple rates: if it's not in range format i.e 0-{7,8,9} for VHT 1034 + * then multiple MCS setting (MCS 4,5,6) is not supported. 1040 1035 */ 1041 1036 ieee80211_iterate_stations_atomic(hw, mt7915_sta_rc_work, &changed); 1037 + ieee80211_queue_work(hw, &dev->rc_work); 1042 1038 1043 1039 return 0; 1044 1040 }
+164 -40
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
··· 416 416 return mt76_tx_queue_skb_raw(dev, mdev->q_mcu[qid], skb, 0); 417 417 } 418 418 419 - static int 420 - mt7915_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3) 419 + int mt7915_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3) 421 420 { 422 421 struct { 423 422 __le32 args[3]; ··· 428 429 }, 429 430 }; 430 431 431 - return mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), true); 432 + return mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), false); 432 433 } 433 434 434 435 static void ··· 2049 2050 bfee->fb_identity_matrix = (nrow == 1 && tx_ant == 2); 2050 2051 } 2051 2052 2053 + int mt7915_mcu_set_fixed_rate_ctrl(struct mt7915_dev *dev, 2054 + struct ieee80211_vif *vif, 2055 + struct ieee80211_sta *sta, 2056 + void *data, u32 field) 2057 + { 2058 + struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; 2059 + struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; 2060 + struct sta_phy *phy = data; 2061 + struct sta_rec_ra_fixed *ra; 2062 + struct sk_buff *skb; 2063 + struct tlv *tlv; 2064 + int len = sizeof(struct sta_req_hdr) + sizeof(*ra); 2065 + 2066 + skb = mt7915_mcu_alloc_sta_req(dev, mvif, msta, len); 2067 + if (IS_ERR(skb)) 2068 + return PTR_ERR(skb); 2069 + 2070 + tlv = mt7915_mcu_add_tlv(skb, STA_REC_RA_UPDATE, sizeof(*ra)); 2071 + ra = (struct sta_rec_ra_fixed *)tlv; 2072 + 2073 + switch (field) { 2074 + case RATE_PARAM_AUTO: 2075 + break; 2076 + case RATE_PARAM_FIXED: 2077 + case RATE_PARAM_FIXED_MCS: 2078 + case RATE_PARAM_FIXED_GI: 2079 + case RATE_PARAM_FIXED_HE_LTF: 2080 + ra->phy = *phy; 2081 + break; 2082 + default: 2083 + break; 2084 + } 2085 + ra->field = cpu_to_le32(field); 2086 + 2087 + return mt76_mcu_skb_send_msg(&dev->mt76, skb, 2088 + MCU_EXT_CMD(STA_REC_UPDATE), true); 2089 + } 2090 + 2091 + static int 2092 + mt7915_mcu_add_rate_ctrl_fixed(struct mt7915_dev *dev, 2093 + struct ieee80211_vif *vif, 2094 + struct ieee80211_sta *sta) 2095 + { 2096 + struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; 2097 + struct cfg80211_chan_def *chandef = &mvif->phy->mt76->chandef; 2098 + struct cfg80211_bitrate_mask *mask = &mvif->bitrate_mask; 2099 + enum nl80211_band band = chandef->chan->band; 2100 + struct sta_phy phy = {}; 2101 + int ret, nrates = 0; 2102 + 2103 + #define __sta_phy_bitrate_mask_check(_mcs, _gi, _he) \ 2104 + do { \ 2105 + u8 i, gi = mask->control[band]._gi; \ 2106 + gi = (_he) ? gi : gi == NL80211_TXRATE_FORCE_SGI; \ 2107 + for (i = 0; i <= sta->bandwidth; i++) { \ 2108 + phy.sgi |= gi << (i << (_he)); \ 2109 + phy.he_ltf |= mask->control[band].he_ltf << (i << (_he));\ 2110 + } \ 2111 + for (i = 0; i < ARRAY_SIZE(mask->control[band]._mcs); i++) \ 2112 + nrates += hweight16(mask->control[band]._mcs[i]); \ 2113 + phy.mcs = ffs(mask->control[band]._mcs[0]) - 1; \ 2114 + } while (0) 2115 + 2116 + if (sta->he_cap.has_he) { 2117 + __sta_phy_bitrate_mask_check(he_mcs, he_gi, 1); 2118 + } else if (sta->vht_cap.vht_supported) { 2119 + __sta_phy_bitrate_mask_check(vht_mcs, gi, 0); 2120 + } else if (sta->ht_cap.ht_supported) { 2121 + __sta_phy_bitrate_mask_check(ht_mcs, gi, 0); 2122 + } else { 2123 + nrates = hweight32(mask->control[band].legacy); 2124 + phy.mcs = ffs(mask->control[band].legacy) - 1; 2125 + } 2126 + #undef __sta_phy_bitrate_mask_check 2127 + 2128 + /* fall back to auto rate control */ 2129 + if (mask->control[band].gi == NL80211_TXRATE_DEFAULT_GI && 2130 + mask->control[band].he_gi == GENMASK(7, 0) && 2131 + mask->control[band].he_ltf == GENMASK(7, 0) && 2132 + nrates != 1) 2133 + return 0; 2134 + 2135 + /* fixed single rate */ 2136 + if (nrates == 1) { 2137 + ret = mt7915_mcu_set_fixed_rate_ctrl(dev, vif, sta, &phy, 2138 + RATE_PARAM_FIXED_MCS); 2139 + if (ret) 2140 + return ret; 2141 + } 2142 + 2143 + /* fixed GI */ 2144 + if (mask->control[band].gi != NL80211_TXRATE_DEFAULT_GI || 2145 + mask->control[band].he_gi != GENMASK(7, 0)) { 2146 + struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; 2147 + u32 addr; 2148 + 2149 + /* firmware updates only TXCMD but doesn't take WTBL into 2150 + * account, so driver should update here to reflect the 2151 + * actual txrate hardware sends out. 2152 + */ 2153 + addr = mt7915_mac_wtbl_lmac_addr(dev, msta->wcid.idx, 7); 2154 + if (sta->he_cap.has_he) 2155 + mt76_rmw_field(dev, addr, GENMASK(31, 24), phy.sgi); 2156 + else 2157 + mt76_rmw_field(dev, addr, GENMASK(15, 12), phy.sgi); 2158 + 2159 + ret = mt7915_mcu_set_fixed_rate_ctrl(dev, vif, sta, &phy, 2160 + RATE_PARAM_FIXED_GI); 2161 + if (ret) 2162 + return ret; 2163 + } 2164 + 2165 + /* fixed HE_LTF */ 2166 + if (mask->control[band].he_ltf != GENMASK(7, 0)) { 2167 + ret = mt7915_mcu_set_fixed_rate_ctrl(dev, vif, sta, &phy, 2168 + RATE_PARAM_FIXED_HE_LTF); 2169 + if (ret) 2170 + return ret; 2171 + } 2172 + 2173 + return 0; 2174 + } 2175 + 2052 2176 static void 2053 2177 mt7915_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, struct mt7915_dev *dev, 2054 2178 struct ieee80211_vif *vif, struct ieee80211_sta *sta) ··· 2214 2092 } 2215 2093 2216 2094 if (sta->ht_cap.ht_supported) { 2217 - const u8 *mcs_mask = mask->control[band].ht_mcs; 2218 - 2219 2095 ra->supp_mode |= MODE_HT; 2220 2096 ra->af = sta->ht_cap.ampdu_factor; 2221 2097 ra->ht_gf = !!(sta->ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD); ··· 2231 2111 (sta->ht_cap.cap & IEEE80211_HT_CAP_LDPC_CODING)) 2232 2112 cap |= STA_CAP_LDPC; 2233 2113 2234 - mt7915_mcu_set_sta_ht_mcs(sta, ra->ht_mcs, mcs_mask); 2114 + mt7915_mcu_set_sta_ht_mcs(sta, ra->ht_mcs, 2115 + mask->control[band].ht_mcs); 2235 2116 ra->supp_ht_mcs = *(__le32 *)ra->ht_mcs; 2236 2117 } 2237 2118 2238 2119 if (sta->vht_cap.vht_supported) { 2239 - const u16 *mcs_mask = mask->control[band].vht_mcs; 2240 2120 u8 af; 2241 2121 2242 2122 ra->supp_mode |= MODE_VHT; ··· 2257 2137 (sta->vht_cap.cap & IEEE80211_VHT_CAP_RXLDPC)) 2258 2138 cap |= STA_CAP_VHT_LDPC; 2259 2139 2260 - mt7915_mcu_set_sta_vht_mcs(sta, ra->supp_vht_mcs, mcs_mask); 2140 + mt7915_mcu_set_sta_vht_mcs(sta, ra->supp_vht_mcs, 2141 + mask->control[band].vht_mcs); 2261 2142 } 2262 2143 2263 2144 if (sta->he_cap.has_he) { ··· 2270 2149 } 2271 2150 2272 2151 int mt7915_mcu_add_rate_ctrl(struct mt7915_dev *dev, struct ieee80211_vif *vif, 2273 - struct ieee80211_sta *sta) 2152 + struct ieee80211_sta *sta, bool changed) 2274 2153 { 2275 2154 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; 2276 2155 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; 2277 2156 struct sk_buff *skb; 2278 - int len = sizeof(struct sta_req_hdr) + sizeof(struct sta_rec_ra); 2157 + int ret; 2279 2158 2280 - skb = mt7915_mcu_alloc_sta_req(dev, mvif, msta, len); 2159 + skb = mt7915_mcu_alloc_sta_req(dev, mvif, msta, 2160 + MT7915_STA_UPDATE_MAX_SIZE); 2281 2161 if (IS_ERR(skb)) 2282 2162 return PTR_ERR(skb); 2283 2163 2164 + /* firmware rc algorithm refers to sta_rec_he for HE control. 2165 + * once dev->rc_work changes the settings driver should also 2166 + * update sta_rec_he here. 2167 + */ 2168 + if (sta->he_cap.has_he && changed) 2169 + mt7915_mcu_sta_he_tlv(skb, sta, vif); 2170 + 2171 + /* sta_rec_ra accommodates BW, NSS and only MCS range format 2172 + * i.e 0-{7,8,9} for VHT. 2173 + */ 2284 2174 mt7915_mcu_sta_rate_ctrl_tlv(skb, dev, vif, sta); 2285 2175 2286 - return mt76_mcu_skb_send_msg(&dev->mt76, skb, 2287 - MCU_EXT_CMD(STA_REC_UPDATE), true); 2288 - } 2176 + ret = mt76_mcu_skb_send_msg(&dev->mt76, skb, 2177 + MCU_EXT_CMD(STA_REC_UPDATE), true); 2178 + if (ret) 2179 + return ret; 2289 2180 2290 - int mt7915_mcu_add_he(struct mt7915_dev *dev, struct ieee80211_vif *vif, 2291 - struct ieee80211_sta *sta) 2292 - { 2293 - struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; 2294 - struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; 2295 - struct sk_buff *skb; 2296 - int len; 2297 - 2298 - if (!sta->he_cap.has_he) 2299 - return 0; 2300 - 2301 - len = sizeof(struct sta_req_hdr) + sizeof(struct sta_rec_he); 2302 - 2303 - skb = mt7915_mcu_alloc_sta_req(dev, mvif, msta, len); 2304 - if (IS_ERR(skb)) 2305 - return PTR_ERR(skb); 2306 - 2307 - mt7915_mcu_sta_he_tlv(skb, sta, vif); 2308 - 2309 - return mt76_mcu_skb_send_msg(&dev->mt76, skb, 2310 - MCU_EXT_CMD(STA_REC_UPDATE), true); 2181 + /* sta_rec_ra_fixed accommodates single rate, (HE)GI and HE_LTE, 2182 + * and updates as peer fixed rate parameters, which overrides 2183 + * sta_rec_ra and firmware rate control algorithm. 2184 + */ 2185 + return mt7915_mcu_add_rate_ctrl_fixed(dev, vif, sta); 2311 2186 } 2312 2187 2313 2188 static int ··· 2560 2443 len); 2561 2444 if (ie && ie[1] >= sizeof(*ht)) { 2562 2445 ht = (void *)(ie + 2); 2563 - bc = le32_to_cpu(ht->cap_info); 2564 - 2565 - vc->ldpc |= !!(bc & IEEE80211_HT_CAP_LDPC_CODING); 2446 + vc->ldpc |= !!(le16_to_cpu(ht->cap_info) & 2447 + IEEE80211_HT_CAP_LDPC_CODING); 2566 2448 } 2567 2449 2568 2450 ie = cfg80211_find_ie(WLAN_EID_VHT_CAPABILITY, mgmt->u.beacon.variable, ··· 2979 2863 return 0; 2980 2864 } 2981 2865 2982 - int mt7915_mcu_fw_log_2_host(struct mt7915_dev *dev, u8 ctrl) 2866 + int mt7915_mcu_fw_log_2_host(struct mt7915_dev *dev, u8 type, u8 ctrl) 2983 2867 { 2984 2868 struct { 2985 2869 u8 ctrl_val; ··· 2987 2871 } data = { 2988 2872 .ctrl_val = ctrl 2989 2873 }; 2874 + 2875 + if (type == MCU_FW_LOG_WA) 2876 + return mt76_mcu_send_msg(&dev->mt76, MCU_WA_EXT_CMD(FW_LOG_2_HOST), 2877 + &data, sizeof(data), true); 2990 2878 2991 2879 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(FW_LOG_2_HOST), &data, 2992 2880 sizeof(data), true); ··· 3104 2984 return ret; 3105 2985 3106 2986 set_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state); 3107 - ret = mt7915_mcu_fw_log_2_host(dev, 0); 2987 + ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WM, 0); 2988 + if (ret) 2989 + return ret; 2990 + 2991 + ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WA, 0); 3108 2992 if (ret) 3109 2993 return ret; 3110 2994
+18 -5
drivers/net/wireless/mediatek/mt76/mt7915/mcu.h
··· 229 229 MCU_S2D_H2CN 230 230 }; 231 231 232 + enum { 233 + MCU_FW_LOG_WM, 234 + MCU_FW_LOG_WA, 235 + MCU_FW_LOG_TO_HOST, 236 + }; 232 237 233 238 #define __MCU_CMD_FIELD_ID GENMASK(7, 0) 234 239 #define __MCU_CMD_FIELD_EXT_ID GENMASK(15, 8) ··· 309 304 }; 310 305 311 306 enum { 307 + MCU_WA_PARAM_PDMA_RX = 0x04, 308 + MCU_WA_PARAM_CPU_UTIL = 0x0b, 312 309 MCU_WA_PARAM_RED = 0x0e, 313 310 }; 314 311 ··· 893 886 struct sec_key key[2]; 894 887 } __packed; 895 888 896 - struct ra_phy { 889 + struct sta_phy { 897 890 u8 type; 898 891 u8 flag; 899 892 u8 stbc; ··· 937 930 938 931 __le32 sta_cap; 939 932 940 - struct ra_phy phy; 933 + struct sta_phy phy; 941 934 } __packed; 942 935 943 936 struct sta_rec_ra_fixed { ··· 950 943 u8 op_vht_rx_nss; 951 944 u8 op_vht_rx_nss_type; 952 945 953 - struct ra_phy phy; 946 + struct sta_phy phy; 954 947 955 948 u8 spe_en; 956 949 u8 short_preamble; ··· 958 951 u8 mmps_mode; 959 952 } __packed; 960 953 961 - #define RATE_PARAM_FIXED 3 962 - #define RATE_PARAM_AUTO 20 954 + enum { 955 + RATE_PARAM_FIXED = 3, 956 + RATE_PARAM_FIXED_HE_LTF = 7, 957 + RATE_PARAM_FIXED_MCS, 958 + RATE_PARAM_FIXED_GI = 11, 959 + RATE_PARAM_AUTO = 20, 960 + }; 961 + 963 962 #define RATE_CFG_MCS GENMASK(3, 0) 964 963 #define RATE_CFG_NSS GENMASK(7, 4) 965 964 #define RATE_CFG_GI GENMASK(11, 8)
+3
drivers/net/wireless/mediatek/mt76/mt7915/mmio.c
··· 34 34 u32 mapped; 35 35 u32 size; 36 36 } fixed_map[] = { 37 + { 0x00400000, 0x80000, 0x10000 }, /* WF_MCU_SYSRAM */ 38 + { 0x00410000, 0x90000, 0x10000 }, /* WF_MCU_SYSRAM (configure regs) */ 39 + { 0x40000000, 0x70000, 0x10000 }, /* WF_UMAC_SYSRAM */ 37 40 { 0x54000000, 0x02000, 0x1000 }, /* WFDMA PCIE0 MCU DMA0 */ 38 41 { 0x55000000, 0x03000, 0x1000 }, /* WFDMA PCIE0 MCU DMA1 */ 39 42 { 0x58000000, 0x06000, 0x1000 }, /* WFDMA PCIE1 MCU DMA0 (MEM_DMA) */
+10 -7
drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
··· 270 270 271 271 bool dbdc_support; 272 272 bool flash_mode; 273 - bool fw_debug; 274 273 bool ibf; 274 + u8 fw_debug_wm; 275 + u8 fw_debug_wa; 275 276 276 277 void *cal; 277 278 ··· 410 409 int mt7915_mcu_add_obss_spr(struct mt7915_dev *dev, struct ieee80211_vif *vif, 411 410 bool enable); 412 411 int mt7915_mcu_add_rate_ctrl(struct mt7915_dev *dev, struct ieee80211_vif *vif, 413 - struct ieee80211_sta *sta); 414 - int mt7915_mcu_add_he(struct mt7915_dev *dev, struct ieee80211_vif *vif, 415 - struct ieee80211_sta *sta); 412 + struct ieee80211_sta *sta, bool changed); 416 413 int mt7915_mcu_add_smps(struct mt7915_dev *dev, struct ieee80211_vif *vif, 417 414 struct ieee80211_sta *sta); 418 415 int mt7915_set_channel(struct mt7915_phy *phy); 419 416 int mt7915_mcu_set_chan_info(struct mt7915_phy *phy, int cmd); 420 417 int mt7915_mcu_set_tx(struct mt7915_dev *dev, struct ieee80211_vif *vif); 421 418 int mt7915_mcu_update_edca(struct mt7915_dev *dev, void *req); 422 - int mt7915_mcu_set_fixed_rate(struct mt7915_dev *dev, 423 - struct ieee80211_sta *sta, u32 rate); 419 + int mt7915_mcu_set_fixed_rate_ctrl(struct mt7915_dev *dev, 420 + struct ieee80211_vif *vif, 421 + struct ieee80211_sta *sta, 422 + void *data, u32 field); 424 423 int mt7915_mcu_set_eeprom(struct mt7915_dev *dev); 425 424 int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset); 426 425 int mt7915_mcu_set_mac(struct mt7915_dev *dev, int band, bool enable, ··· 450 449 struct ieee80211_sta *sta, struct rate_info *rate); 451 450 int mt7915_mcu_rdd_cmd(struct mt7915_dev *dev, enum mt7915_rdd_cmd cmd, 452 451 u8 index, u8 rx_sel, u8 val); 453 - int mt7915_mcu_fw_log_2_host(struct mt7915_dev *dev, u8 ctrl); 452 + int mt7915_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3); 453 + int mt7915_mcu_fw_log_2_host(struct mt7915_dev *dev, u8 type, u8 ctrl); 454 454 int mt7915_mcu_fw_dbg_ctrl(struct mt7915_dev *dev, u32 module, u8 level); 455 455 void mt7915_mcu_rx_event(struct mt7915_dev *dev, struct sk_buff *skb); 456 456 void mt7915_mcu_exit(struct mt7915_dev *dev); ··· 482 480 mt76_set_irq_mask(&dev->mt76, MT_INT_MASK_CSR, mask, 0); 483 481 } 484 482 483 + u32 mt7915_mac_wtbl_lmac_addr(struct mt7915_dev *dev, u16 wcid, u8 dw); 485 484 bool mt7915_mac_wtbl_update(struct mt7915_dev *dev, int idx, u32 mask); 486 485 void mt7915_mac_reset_counters(struct mt7915_phy *phy); 487 486 void mt7915_mac_cca_stats_reset(struct mt7915_phy *phy);
+17
drivers/net/wireless/mediatek/mt76/mt7915/regs.h
··· 528 528 #define MT_HIF_REMAP_L2_BASE GENMASK(31, 12) 529 529 #define MT_HIF_REMAP_BASE_L2 0x00000 530 530 531 + #define MT_DIC_CMD_REG_BASE 0x41f000 532 + #define MT_DIC_CMD_REG(ofs) (MT_DIC_CMD_REG_BASE + (ofs)) 533 + #define MT_DIC_CMD_REG_CMD MT_DIC_CMD_REG(0x10) 534 + 535 + #define MT_CPU_UTIL_BASE 0x41f030 536 + #define MT_CPU_UTIL(ofs) (MT_CPU_UTIL_BASE + (ofs)) 537 + #define MT_CPU_UTIL_BUSY_PCT MT_CPU_UTIL(0x00) 538 + #define MT_CPU_UTIL_PEAK_BUSY_PCT MT_CPU_UTIL(0x04) 539 + #define MT_CPU_UTIL_IDLE_CNT MT_CPU_UTIL(0x08) 540 + #define MT_CPU_UTIL_PEAK_IDLE_CNT MT_CPU_UTIL(0x0c) 541 + #define MT_CPU_UTIL_CTRL MT_CPU_UTIL(0x1c) 542 + 531 543 #define MT_SWDEF_BASE 0x41f200 532 544 #define MT_SWDEF(ofs) (MT_SWDEF_BASE + (ofs)) 533 545 #define MT_SWDEF_MODE MT_SWDEF(0x3c) ··· 601 589 #define MT_WF_PHY_RXTD12(_phy) MT_WF_PHY(0x8230 + ((_phy) << 16)) 602 590 #define MT_WF_PHY_RXTD12_IRPI_SW_CLR_ONLY BIT(18) 603 591 #define MT_WF_PHY_RXTD12_IRPI_SW_CLR BIT(29) 592 + 593 + #define MT_MCU_WM_CIRQ_BASE 0x89010000 594 + #define MT_MCU_WM_CIRQ(ofs) (MT_MCU_WM_CIRQ_BASE + (ofs)) 595 + #define MT_MCU_WM_CIRQ_IRQ_MASK_CLR_ADDR MT_MCU_WM_CIRQ(0x80) 596 + #define MT_MCU_WM_CIRQ_IRQ_SOFT_ADDR MT_MCU_WM_CIRQ(0xc0) 604 597 605 598 #endif
+2 -1
drivers/net/wireless/mediatek/mt76/mt7921/init.c
··· 62 62 hw->vif_data_size = sizeof(struct mt7921_vif); 63 63 64 64 wiphy->iface_combinations = if_comb; 65 - wiphy->flags &= ~WIPHY_FLAG_IBSS_RSN; 65 + wiphy->flags &= ~(WIPHY_FLAG_IBSS_RSN | WIPHY_FLAG_4ADDR_AP | 66 + WIPHY_FLAG_4ADDR_STATION); 66 67 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); 67 68 wiphy->n_iface_combinations = ARRAY_SIZE(if_comb); 68 69 wiphy->max_scan_ie_len = MT76_CONNAC_SCAN_IE_LEN;
+4 -6
drivers/net/wireless/mediatek/mt76/util.h
··· 70 70 71 71 if (fn) 72 72 w->fn = fn; 73 - w->task = kthread_create(__mt76_worker_fn, w, "mt76-%s %s", 74 - name, dev_name); 73 + w->task = kthread_run(__mt76_worker_fn, w, 74 + "mt76-%s %s", name, dev_name); 75 75 76 - ret = PTR_ERR_OR_ZERO(w->task); 77 - if (ret) { 76 + if (IS_ERR(w->task)) { 77 + ret = PTR_ERR(w->task); 78 78 w->task = NULL; 79 79 return ret; 80 80 } 81 - 82 - wake_up_process(w->task); 83 81 84 82 return 0; 85 83 }