1 // SPDX-License-Identifier: ISC 2 /* Copyright (C) 2020 MediaTek Inc. */ 3 4 #include <linux/etherdevice.h> 5 #include <linux/platform_device.h> 6 #include <linux/pci.h> 7 #include <linux/module.h> 8 #include "mt7915.h" 9 #include "mcu.h" 10 11 static bool mt7915_dev_running(struct mt7915_dev *dev) 12 { 13 struct mt7915_phy *phy; 14 15 if (test_bit(MT76_STATE_RUNNING, &dev->mphy.state)) 16 return true; 17 18 phy = mt7915_ext_phy(dev); 19 20 return phy && test_bit(MT76_STATE_RUNNING, &phy->mt76->state); 21 } 22 23 int mt7915_run(struct ieee80211_hw *hw) 24 { 25 struct mt7915_dev *dev = mt7915_hw_dev(hw); 26 struct mt7915_phy *phy = mt7915_hw_phy(hw); 27 bool running; 28 int ret; 29 30 running = mt7915_dev_running(dev); 31 32 if (!running) { 33 ret = mt76_connac_mcu_set_pm(&dev->mt76, 34 dev->phy.mt76->band_idx, 0); 35 if (ret) 36 goto out; 37 38 ret = mt7915_mcu_set_mac(dev, dev->phy.mt76->band_idx, 39 true, true); 40 if (ret) 41 goto out; 42 43 mt7915_mac_enable_nf(dev, dev->phy.mt76->band_idx); 44 } 45 46 if (phy != &dev->phy) { 47 ret = mt76_connac_mcu_set_pm(&dev->mt76, 48 phy->mt76->band_idx, 0); 49 if (ret) 50 goto out; 51 52 ret = mt7915_mcu_set_mac(dev, phy->mt76->band_idx, 53 true, true); 54 if (ret) 55 goto out; 56 57 mt7915_mac_enable_nf(dev, phy->mt76->band_idx); 58 } 59 60 ret = mt7915_mcu_set_thermal_throttling(phy, 61 MT7915_THERMAL_THROTTLE_MAX); 62 63 if (ret) 64 goto out; 65 66 ret = mt7915_mcu_set_thermal_protect(phy); 67 68 if (ret) 69 goto out; 70 71 ret = mt76_connac_mcu_set_rts_thresh(&dev->mt76, 0x92b, 72 phy->mt76->band_idx); 73 if (ret) 74 goto out; 75 76 ret = mt7915_mcu_set_sku_en(phy, true); 77 if (ret) 78 goto out; 79 80 ret = mt7915_mcu_set_chan_info(phy, MCU_EXT_CMD(SET_RX_PATH)); 81 if (ret) 82 goto out; 83 84 set_bit(MT76_STATE_RUNNING, &phy->mt76->state); 85 86 if (!mt76_testmode_enabled(phy->mt76)) 87 ieee80211_queue_delayed_work(hw, &phy->mt76->mac_work, 88 MT7915_WATCHDOG_TIME); 89 90 if (!running) 91 mt7915_mac_reset_counters(phy); 92 93 out: 94 return ret; 95 } 96 97 static int mt7915_start(struct ieee80211_hw *hw) 98 { 99 struct mt7915_dev *dev = mt7915_hw_dev(hw); 100 int ret; 101 102 flush_work(&dev->init_work); 103 104 mutex_lock(&dev->mt76.mutex); 105 ret = mt7915_run(hw); 106 mutex_unlock(&dev->mt76.mutex); 107 108 return ret; 109 } 110 111 static void mt7915_stop(struct ieee80211_hw *hw, bool suspend) 112 { 113 struct mt7915_dev *dev = mt7915_hw_dev(hw); 114 struct mt7915_phy *phy = mt7915_hw_phy(hw); 115 116 cancel_delayed_work_sync(&phy->mt76->mac_work); 117 118 mutex_lock(&dev->mt76.mutex); 119 120 mt76_testmode_reset(phy->mt76, true); 121 122 clear_bit(MT76_STATE_RUNNING, &phy->mt76->state); 123 124 if (phy != &dev->phy) { 125 mt76_connac_mcu_set_pm(&dev->mt76, phy->mt76->band_idx, 1); 126 mt7915_mcu_set_mac(dev, phy->mt76->band_idx, false, false); 127 } 128 129 if (!mt7915_dev_running(dev)) { 130 mt76_connac_mcu_set_pm(&dev->mt76, dev->phy.mt76->band_idx, 1); 131 mt7915_mcu_set_mac(dev, dev->phy.mt76->band_idx, false, false); 132 } 133 134 mutex_unlock(&dev->mt76.mutex); 135 } 136 137 static inline int get_free_idx(u32 mask, u8 start, u8 end) 138 { 139 return ffs(~mask & GENMASK(end, start)); 140 } 141 142 static int get_omac_idx(enum nl80211_iftype type, u64 mask) 143 { 144 int i; 145 146 switch (type) { 147 case NL80211_IFTYPE_MESH_POINT: 148 case NL80211_IFTYPE_ADHOC: 149 case NL80211_IFTYPE_STATION: 150 /* prefer hw bssid slot 1-3 */ 151 i = get_free_idx(mask, HW_BSSID_1, HW_BSSID_3); 152 if (i) 153 return i - 1; 154 155 if (type != NL80211_IFTYPE_STATION) 156 break; 157 158 i = get_free_idx(mask, EXT_BSSID_1, EXT_BSSID_MAX); 159 if (i) 160 return i - 1; 161 162 if (~mask & BIT(HW_BSSID_0)) 163 return HW_BSSID_0; 164 165 break; 166 case NL80211_IFTYPE_MONITOR: 167 case NL80211_IFTYPE_AP: 168 /* ap uses hw bssid 0 and ext bssid */ 169 if (~mask & BIT(HW_BSSID_0)) 170 return HW_BSSID_0; 171 172 i = get_free_idx(mask, EXT_BSSID_1, EXT_BSSID_MAX); 173 if (i) 174 return i - 1; 175 176 break; 177 default: 178 WARN_ON(1); 179 break; 180 } 181 182 return -1; 183 } 184 185 static void mt7915_init_bitrate_mask(struct ieee80211_vif *vif) 186 { 187 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; 188 int i; 189 190 for (i = 0; i < ARRAY_SIZE(mvif->bitrate_mask.control); i++) { 191 mvif->bitrate_mask.control[i].gi = NL80211_TXRATE_DEFAULT_GI; 192 mvif->bitrate_mask.control[i].he_gi = 0xff; 193 mvif->bitrate_mask.control[i].he_ltf = 0xff; 194 mvif->bitrate_mask.control[i].legacy = GENMASK(31, 0); 195 memset(mvif->bitrate_mask.control[i].ht_mcs, 0xff, 196 sizeof(mvif->bitrate_mask.control[i].ht_mcs)); 197 memset(mvif->bitrate_mask.control[i].vht_mcs, 0xff, 198 sizeof(mvif->bitrate_mask.control[i].vht_mcs)); 199 memset(mvif->bitrate_mask.control[i].he_mcs, 0xff, 200 sizeof(mvif->bitrate_mask.control[i].he_mcs)); 201 } 202 } 203 204 static int mt7915_add_interface(struct ieee80211_hw *hw, 205 struct ieee80211_vif *vif) 206 { 207 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; 208 struct mt7915_dev *dev = mt7915_hw_dev(hw); 209 struct mt7915_phy *phy = mt7915_hw_phy(hw); 210 struct mt76_txq *mtxq; 211 bool ext_phy = phy != &dev->phy; 212 int idx, ret = 0; 213 214 mutex_lock(&dev->mt76.mutex); 215 216 mt76_testmode_reset(phy->mt76, true); 217 218 if (vif->type == NL80211_IFTYPE_MONITOR && 219 is_zero_ether_addr(vif->addr)) 220 phy->monitor_vif = vif; 221 222 mvif->mt76.idx = __ffs64(~dev->mt76.vif_mask); 223 if (mvif->mt76.idx >= (MT7915_MAX_INTERFACES << dev->dbdc_support)) { 224 ret = -ENOSPC; 225 goto out; 226 } 227 228 idx = get_omac_idx(vif->type, phy->omac_mask); 229 if (idx < 0) { 230 ret = -ENOSPC; 231 goto out; 232 } 233 mvif->mt76.omac_idx = idx; 234 mvif->phy = phy; 235 mvif->mt76.band_idx = phy->mt76->band_idx; 236 237 mvif->mt76.wmm_idx = vif->type != NL80211_IFTYPE_AP; 238 if (ext_phy) 239 mvif->mt76.wmm_idx += 2; 240 241 ret = mt7915_mcu_add_dev_info(phy, vif, true); 242 if (ret) 243 goto out; 244 245 dev->mt76.vif_mask |= BIT_ULL(mvif->mt76.idx); 246 phy->omac_mask |= BIT_ULL(mvif->mt76.omac_idx); 247 248 idx = MT7915_WTBL_RESERVED - mvif->mt76.idx; 249 250 INIT_LIST_HEAD(&mvif->sta.rc_list); 251 INIT_LIST_HEAD(&mvif->sta.wcid.poll_list); 252 mvif->sta.wcid.idx = idx; 253 mvif->sta.wcid.phy_idx = ext_phy; 254 mvif->sta.wcid.hw_key_idx = -1; 255 mvif->sta.wcid.tx_info |= MT_WCID_TX_INFO_SET; 256 mt76_wcid_init(&mvif->sta.wcid); 257 258 mt7915_mac_wtbl_update(dev, idx, 259 MT_WTBL_UPDATE_ADM_COUNT_CLEAR); 260 261 if (vif->txq) { 262 mtxq = (struct mt76_txq *)vif->txq->drv_priv; 263 mtxq->wcid = idx; 264 } 265 266 if (vif->type != NL80211_IFTYPE_AP && 267 (!mvif->mt76.omac_idx || mvif->mt76.omac_idx > 3)) 268 vif->offload_flags = 0; 269 vif->offload_flags |= IEEE80211_OFFLOAD_ENCAP_4ADDR; 270 271 mt7915_init_bitrate_mask(vif); 272 memset(&mvif->cap, -1, sizeof(mvif->cap)); 273 274 mt7915_mcu_add_bss_info(phy, vif, true); 275 mt7915_mcu_add_sta(dev, vif, NULL, true); 276 rcu_assign_pointer(dev->mt76.wcid[idx], &mvif->sta.wcid); 277 278 out: 279 mutex_unlock(&dev->mt76.mutex); 280 281 return ret; 282 } 283 284 static void mt7915_remove_interface(struct ieee80211_hw *hw, 285 struct ieee80211_vif *vif) 286 { 287 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; 288 struct mt7915_sta *msta = &mvif->sta; 289 struct mt7915_dev *dev = mt7915_hw_dev(hw); 290 struct mt7915_phy *phy = mt7915_hw_phy(hw); 291 int idx = msta->wcid.idx; 292 293 mt7915_mcu_add_bss_info(phy, vif, false); 294 mt7915_mcu_add_sta(dev, vif, NULL, false); 295 296 mutex_lock(&dev->mt76.mutex); 297 mt76_testmode_reset(phy->mt76, true); 298 mutex_unlock(&dev->mt76.mutex); 299 300 if (vif == phy->monitor_vif) 301 phy->monitor_vif = NULL; 302 303 mt7915_mcu_add_dev_info(phy, vif, false); 304 305 rcu_assign_pointer(dev->mt76.wcid[idx], NULL); 306 307 mutex_lock(&dev->mt76.mutex); 308 dev->mt76.vif_mask &= ~BIT_ULL(mvif->mt76.idx); 309 phy->omac_mask &= ~BIT_ULL(mvif->mt76.omac_idx); 310 mutex_unlock(&dev->mt76.mutex); 311 312 spin_lock_bh(&dev->mt76.sta_poll_lock); 313 if (!list_empty(&msta->wcid.poll_list)) 314 list_del_init(&msta->wcid.poll_list); 315 spin_unlock_bh(&dev->mt76.sta_poll_lock); 316 317 mt76_wcid_cleanup(&dev->mt76, &msta->wcid); 318 } 319 320 int mt7915_set_channel(struct mt7915_phy *phy) 321 { 322 struct mt7915_dev *dev = phy->dev; 323 int ret; 324 325 cancel_delayed_work_sync(&phy->mt76->mac_work); 326 327 mutex_lock(&dev->mt76.mutex); 328 set_bit(MT76_RESET, &phy->mt76->state); 329 330 mt76_set_channel(phy->mt76); 331 332 if (dev->cal) { 333 ret = mt7915_mcu_apply_tx_dpd(phy); 334 if (ret) 335 goto out; 336 } 337 338 ret = mt7915_mcu_set_chan_info(phy, MCU_EXT_CMD(CHANNEL_SWITCH)); 339 if (ret) 340 goto out; 341 342 mt7915_mac_set_timing(phy); 343 ret = mt7915_dfs_init_radar_detector(phy); 344 mt7915_mac_cca_stats_reset(phy); 345 346 mt7915_mac_reset_counters(phy); 347 phy->noise = 0; 348 349 out: 350 clear_bit(MT76_RESET, &phy->mt76->state); 351 mutex_unlock(&dev->mt76.mutex); 352 353 mt76_txq_schedule_all(phy->mt76); 354 355 if (!mt76_testmode_enabled(phy->mt76)) 356 ieee80211_queue_delayed_work(phy->mt76->hw, 357 &phy->mt76->mac_work, 358 MT7915_WATCHDOG_TIME); 359 360 return ret; 361 } 362 363 static int mt7915_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, 364 struct ieee80211_vif *vif, struct ieee80211_sta *sta, 365 struct ieee80211_key_conf *key) 366 { 367 struct mt7915_dev *dev = mt7915_hw_dev(hw); 368 struct mt7915_phy *phy = mt7915_hw_phy(hw); 369 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; 370 struct mt7915_sta *msta = sta ? (struct mt7915_sta *)sta->drv_priv : 371 &mvif->sta; 372 struct mt76_wcid *wcid = &msta->wcid; 373 u8 *wcid_keyidx = &wcid->hw_key_idx; 374 int idx = key->keyidx; 375 int err = 0; 376 377 /* The hardware does not support per-STA RX GTK, fallback 378 * to software mode for these. 379 */ 380 if ((vif->type == NL80211_IFTYPE_ADHOC || 381 vif->type == NL80211_IFTYPE_MESH_POINT) && 382 (key->cipher == WLAN_CIPHER_SUITE_TKIP || 383 key->cipher == WLAN_CIPHER_SUITE_CCMP) && 384 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) 385 return -EOPNOTSUPP; 386 387 /* fall back to sw encryption for unsupported ciphers */ 388 switch (key->cipher) { 389 case WLAN_CIPHER_SUITE_AES_CMAC: 390 wcid_keyidx = &wcid->hw_key_idx2; 391 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIE; 392 break; 393 case WLAN_CIPHER_SUITE_TKIP: 394 case WLAN_CIPHER_SUITE_CCMP: 395 case WLAN_CIPHER_SUITE_CCMP_256: 396 case WLAN_CIPHER_SUITE_GCMP: 397 case WLAN_CIPHER_SUITE_GCMP_256: 398 case WLAN_CIPHER_SUITE_SMS4: 399 break; 400 case WLAN_CIPHER_SUITE_WEP40: 401 case WLAN_CIPHER_SUITE_WEP104: 402 default: 403 return -EOPNOTSUPP; 404 } 405 406 mutex_lock(&dev->mt76.mutex); 407 408 if (cmd == SET_KEY && !sta && !mvif->mt76.cipher) { 409 mvif->mt76.cipher = mt76_connac_mcu_get_cipher(key->cipher); 410 mt7915_mcu_add_bss_info(phy, vif, true); 411 } 412 413 if (cmd == SET_KEY) { 414 *wcid_keyidx = idx; 415 } else { 416 if (idx == *wcid_keyidx) 417 *wcid_keyidx = -1; 418 goto out; 419 } 420 421 mt76_wcid_key_setup(&dev->mt76, wcid, key); 422 err = mt76_connac_mcu_add_key(&dev->mt76, vif, &msta->bip, 423 key, MCU_EXT_CMD(STA_REC_UPDATE), 424 &msta->wcid, cmd); 425 out: 426 mutex_unlock(&dev->mt76.mutex); 427 428 return err; 429 } 430 431 static int mt7915_set_sar_specs(struct ieee80211_hw *hw, 432 const struct cfg80211_sar_specs *sar) 433 { 434 struct mt7915_phy *phy = mt7915_hw_phy(hw); 435 struct mt7915_dev *dev = mt7915_hw_dev(hw); 436 int err = -EINVAL; 437 438 mutex_lock(&dev->mt76.mutex); 439 if (!cfg80211_chandef_valid(&phy->mt76->chandef)) 440 goto out; 441 442 err = mt76_init_sar_power(hw, sar); 443 if (err) 444 goto out; 445 446 err = mt7915_mcu_set_txpower_sku(phy); 447 out: 448 mutex_unlock(&dev->mt76.mutex); 449 450 return err; 451 } 452 453 static int mt7915_config(struct ieee80211_hw *hw, u32 changed) 454 { 455 struct mt7915_dev *dev = mt7915_hw_dev(hw); 456 struct mt7915_phy *phy = mt7915_hw_phy(hw); 457 int ret; 458 459 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { 460 #ifdef CONFIG_NL80211_TESTMODE 461 if (phy->mt76->test.state != MT76_TM_STATE_OFF) { 462 mutex_lock(&dev->mt76.mutex); 463 mt76_testmode_reset(phy->mt76, false); 464 mutex_unlock(&dev->mt76.mutex); 465 } 466 #endif 467 ieee80211_stop_queues(hw); 468 ret = mt7915_set_channel(phy); 469 if (ret) 470 return ret; 471 ieee80211_wake_queues(hw); 472 } 473 474 if (changed & (IEEE80211_CONF_CHANGE_POWER | 475 IEEE80211_CONF_CHANGE_CHANNEL)) { 476 ret = mt7915_mcu_set_txpower_sku(phy); 477 if (ret) 478 return ret; 479 } 480 481 mutex_lock(&dev->mt76.mutex); 482 483 if (changed & IEEE80211_CONF_CHANGE_MONITOR) { 484 bool enabled = !!(hw->conf.flags & IEEE80211_CONF_MONITOR); 485 bool band = phy->mt76->band_idx; 486 u32 rxfilter = phy->rxfilter; 487 488 if (!enabled) { 489 rxfilter |= MT_WF_RFCR_DROP_OTHER_UC; 490 dev->monitor_mask &= ~BIT(band); 491 } else { 492 rxfilter &= ~MT_WF_RFCR_DROP_OTHER_UC; 493 dev->monitor_mask |= BIT(band); 494 } 495 496 mt76_rmw_field(dev, MT_DMA_DCR0(band), MT_DMA_DCR0_RXD_G5_EN, 497 enabled); 498 mt76_rmw_field(dev, MT_DMA_DCR0(band), MT_MDP_DCR0_RX_HDR_TRANS_EN, 499 !dev->monitor_mask); 500 mt76_testmode_reset(phy->mt76, true); 501 mt76_wr(dev, MT_WF_RFCR(band), rxfilter); 502 } 503 504 mutex_unlock(&dev->mt76.mutex); 505 506 return 0; 507 } 508 509 static int 510 mt7915_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 511 unsigned int link_id, u16 queue, 512 const struct ieee80211_tx_queue_params *params) 513 { 514 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; 515 516 /* no need to update right away, we'll get BSS_CHANGED_QOS */ 517 queue = mt76_connac_lmac_mapping(queue); 518 mvif->queue_params[queue] = *params; 519 520 return 0; 521 } 522 523 static void mt7915_configure_filter(struct ieee80211_hw *hw, 524 unsigned int changed_flags, 525 unsigned int *total_flags, 526 u64 multicast) 527 { 528 struct mt7915_dev *dev = mt7915_hw_dev(hw); 529 struct mt7915_phy *phy = mt7915_hw_phy(hw); 530 bool band = phy->mt76->band_idx; 531 u32 ctl_flags = MT_WF_RFCR1_DROP_ACK | 532 MT_WF_RFCR1_DROP_BF_POLL | 533 MT_WF_RFCR1_DROP_BA | 534 MT_WF_RFCR1_DROP_CFEND | 535 MT_WF_RFCR1_DROP_CFACK; 536 u32 rxfilter; 537 u32 flags = 0; 538 539 #define MT76_FILTER(_flag, _hw) do { \ 540 flags |= *total_flags & FIF_##_flag; \ 541 phy->rxfilter &= ~(_hw); \ 542 phy->rxfilter |= !(flags & FIF_##_flag) * (_hw); \ 543 } while (0) 544 545 mutex_lock(&dev->mt76.mutex); 546 547 phy->rxfilter &= ~(MT_WF_RFCR_DROP_OTHER_BSS | 548 MT_WF_RFCR_DROP_OTHER_BEACON | 549 MT_WF_RFCR_DROP_FRAME_REPORT | 550 MT_WF_RFCR_DROP_PROBEREQ | 551 MT_WF_RFCR_DROP_MCAST_FILTERED | 552 MT_WF_RFCR_DROP_MCAST | 553 MT_WF_RFCR_DROP_BCAST | 554 MT_WF_RFCR_DROP_DUPLICATE | 555 MT_WF_RFCR_DROP_A2_BSSID | 556 MT_WF_RFCR_DROP_UNWANTED_CTL | 557 MT_WF_RFCR_DROP_STBC_MULTI); 558 559 MT76_FILTER(OTHER_BSS, MT_WF_RFCR_DROP_OTHER_TIM | 560 MT_WF_RFCR_DROP_A3_MAC | 561 MT_WF_RFCR_DROP_A3_BSSID); 562 563 MT76_FILTER(FCSFAIL, MT_WF_RFCR_DROP_FCSFAIL); 564 565 MT76_FILTER(CONTROL, MT_WF_RFCR_DROP_CTS | 566 MT_WF_RFCR_DROP_RTS | 567 MT_WF_RFCR_DROP_CTL_RSV | 568 MT_WF_RFCR_DROP_NDPA); 569 570 *total_flags = flags; 571 rxfilter = phy->rxfilter; 572 if (hw->conf.flags & IEEE80211_CONF_MONITOR) 573 rxfilter &= ~MT_WF_RFCR_DROP_OTHER_UC; 574 else 575 rxfilter |= MT_WF_RFCR_DROP_OTHER_UC; 576 mt76_wr(dev, MT_WF_RFCR(band), rxfilter); 577 578 if (*total_flags & FIF_CONTROL) 579 mt76_clear(dev, MT_WF_RFCR1(band), ctl_flags); 580 else 581 mt76_set(dev, MT_WF_RFCR1(band), ctl_flags); 582 583 mutex_unlock(&dev->mt76.mutex); 584 } 585 586 static void 587 mt7915_update_bss_color(struct ieee80211_hw *hw, 588 struct ieee80211_vif *vif, 589 struct cfg80211_he_bss_color *bss_color) 590 { 591 struct mt7915_dev *dev = mt7915_hw_dev(hw); 592 593 switch (vif->type) { 594 case NL80211_IFTYPE_AP: { 595 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; 596 597 if (mvif->mt76.omac_idx > HW_BSSID_MAX) 598 return; 599 fallthrough; 600 } 601 case NL80211_IFTYPE_STATION: 602 mt7915_mcu_update_bss_color(dev, vif, bss_color); 603 break; 604 default: 605 break; 606 } 607 } 608 609 static void mt7915_bss_info_changed(struct ieee80211_hw *hw, 610 struct ieee80211_vif *vif, 611 struct ieee80211_bss_conf *info, 612 u64 changed) 613 { 614 struct mt7915_phy *phy = mt7915_hw_phy(hw); 615 struct mt7915_dev *dev = mt7915_hw_dev(hw); 616 int set_bss_info = -1, set_sta = -1; 617 618 mutex_lock(&dev->mt76.mutex); 619 620 /* 621 * station mode uses BSSID to map the wlan entry to a peer, 622 * and then peer references bss_info_rfch to set bandwidth cap. 623 */ 624 if (changed & BSS_CHANGED_BSSID && 625 vif->type == NL80211_IFTYPE_STATION) 626 set_bss_info = set_sta = !is_zero_ether_addr(info->bssid); 627 if (changed & BSS_CHANGED_ASSOC) 628 set_bss_info = vif->cfg.assoc; 629 if (changed & BSS_CHANGED_BEACON_ENABLED && 630 vif->type != NL80211_IFTYPE_AP) 631 set_bss_info = set_sta = info->enable_beacon; 632 633 if (set_bss_info == 1) 634 mt7915_mcu_add_bss_info(phy, vif, true); 635 if (set_sta == 1) 636 mt7915_mcu_add_sta(dev, vif, NULL, true); 637 638 if (changed & BSS_CHANGED_ERP_CTS_PROT) 639 mt7915_mac_enable_rtscts(dev, vif, info->use_cts_prot); 640 641 if (changed & BSS_CHANGED_ERP_SLOT) { 642 int slottime = info->use_short_slot ? 9 : 20; 643 644 if (slottime != phy->slottime) { 645 phy->slottime = slottime; 646 mt7915_mac_set_timing(phy); 647 } 648 } 649 650 /* ensure that enable txcmd_mode after bss_info */ 651 if (changed & (BSS_CHANGED_QOS | BSS_CHANGED_BEACON_ENABLED)) 652 mt7915_mcu_set_tx(dev, vif); 653 654 if (changed & BSS_CHANGED_HE_OBSS_PD) 655 mt7915_mcu_add_obss_spr(phy, vif, &info->he_obss_pd); 656 657 if (changed & BSS_CHANGED_HE_BSS_COLOR) 658 mt7915_update_bss_color(hw, vif, &info->he_bss_color); 659 660 if (changed & (BSS_CHANGED_BEACON | 661 BSS_CHANGED_BEACON_ENABLED)) 662 mt7915_mcu_add_beacon(hw, vif, info->enable_beacon, changed); 663 664 if (changed & (BSS_CHANGED_UNSOL_BCAST_PROBE_RESP | 665 BSS_CHANGED_FILS_DISCOVERY)) 666 mt7915_mcu_add_inband_discov(dev, vif, changed); 667 668 if (set_bss_info == 0) 669 mt7915_mcu_add_bss_info(phy, vif, false); 670 if (set_sta == 0) 671 mt7915_mcu_add_sta(dev, vif, NULL, false); 672 673 mutex_unlock(&dev->mt76.mutex); 674 } 675 676 static void 677 mt7915_vif_check_caps(struct mt7915_phy *phy, struct ieee80211_vif *vif) 678 { 679 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; 680 struct mt7915_vif_cap *vc = &mvif->cap; 681 682 vc->ht_ldpc = vif->bss_conf.ht_ldpc; 683 vc->vht_ldpc = vif->bss_conf.vht_ldpc; 684 vc->vht_su_ebfer = vif->bss_conf.vht_su_beamformer; 685 vc->vht_su_ebfee = vif->bss_conf.vht_su_beamformee; 686 vc->vht_mu_ebfer = vif->bss_conf.vht_mu_beamformer; 687 vc->vht_mu_ebfee = vif->bss_conf.vht_mu_beamformee; 688 vc->he_ldpc = vif->bss_conf.he_ldpc; 689 vc->he_su_ebfer = vif->bss_conf.he_su_beamformer; 690 vc->he_su_ebfee = vif->bss_conf.he_su_beamformee; 691 vc->he_mu_ebfer = vif->bss_conf.he_mu_beamformer; 692 } 693 694 static int 695 mt7915_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 696 struct ieee80211_bss_conf *link_conf) 697 { 698 struct mt7915_phy *phy = mt7915_hw_phy(hw); 699 struct mt7915_dev *dev = mt7915_hw_dev(hw); 700 int err; 701 702 mutex_lock(&dev->mt76.mutex); 703 704 mt7915_vif_check_caps(phy, vif); 705 706 err = mt7915_mcu_add_bss_info(phy, vif, true); 707 if (err) 708 goto out; 709 err = mt7915_mcu_add_sta(dev, vif, NULL, true); 710 out: 711 mutex_unlock(&dev->mt76.mutex); 712 713 return err; 714 } 715 716 static void 717 mt7915_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 718 struct ieee80211_bss_conf *link_conf) 719 { 720 struct mt7915_dev *dev = mt7915_hw_dev(hw); 721 722 mutex_lock(&dev->mt76.mutex); 723 mt7915_mcu_add_sta(dev, vif, NULL, false); 724 mutex_unlock(&dev->mt76.mutex); 725 } 726 727 static void 728 mt7915_channel_switch_beacon(struct ieee80211_hw *hw, 729 struct ieee80211_vif *vif, 730 struct cfg80211_chan_def *chandef) 731 { 732 struct mt7915_dev *dev = mt7915_hw_dev(hw); 733 734 mutex_lock(&dev->mt76.mutex); 735 mt7915_mcu_add_beacon(hw, vif, true, BSS_CHANGED_BEACON); 736 mutex_unlock(&dev->mt76.mutex); 737 } 738 739 int mt7915_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, 740 struct ieee80211_sta *sta) 741 { 742 struct mt7915_dev *dev = container_of(mdev, struct mt7915_dev, mt76); 743 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; 744 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; 745 bool ext_phy = mvif->phy != &dev->phy; 746 int ret, idx; 747 u32 addr; 748 749 idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7915_WTBL_STA); 750 if (idx < 0) 751 return -ENOSPC; 752 753 INIT_LIST_HEAD(&msta->rc_list); 754 INIT_LIST_HEAD(&msta->wcid.poll_list); 755 msta->vif = mvif; 756 msta->wcid.sta = 1; 757 msta->wcid.idx = idx; 758 msta->wcid.phy_idx = ext_phy; 759 msta->wcid.tx_info |= MT_WCID_TX_INFO_SET; 760 msta->jiffies = jiffies; 761 762 ewma_avg_signal_init(&msta->avg_ack_signal); 763 764 mt7915_mac_wtbl_update(dev, idx, 765 MT_WTBL_UPDATE_ADM_COUNT_CLEAR); 766 767 ret = mt7915_mcu_add_sta(dev, vif, sta, true); 768 if (ret) 769 return ret; 770 771 addr = mt7915_mac_wtbl_lmac_addr(dev, msta->wcid.idx, 30); 772 mt76_rmw_field(dev, addr, GENMASK(7, 0), 0xa0); 773 774 return mt7915_mcu_add_rate_ctrl(dev, vif, sta, false); 775 } 776 777 void mt7915_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, 778 struct ieee80211_sta *sta) 779 { 780 struct mt7915_dev *dev = container_of(mdev, struct mt7915_dev, mt76); 781 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; 782 int i; 783 784 mt7915_mcu_add_sta(dev, vif, sta, false); 785 786 mt7915_mac_wtbl_update(dev, msta->wcid.idx, 787 MT_WTBL_UPDATE_ADM_COUNT_CLEAR); 788 789 for (i = 0; i < ARRAY_SIZE(msta->twt.flow); i++) 790 mt7915_mac_twt_teardown_flow(dev, msta, i); 791 792 spin_lock_bh(&mdev->sta_poll_lock); 793 if (!list_empty(&msta->wcid.poll_list)) 794 list_del_init(&msta->wcid.poll_list); 795 if (!list_empty(&msta->rc_list)) 796 list_del_init(&msta->rc_list); 797 spin_unlock_bh(&mdev->sta_poll_lock); 798 } 799 800 static void mt7915_tx(struct ieee80211_hw *hw, 801 struct ieee80211_tx_control *control, 802 struct sk_buff *skb) 803 { 804 struct mt7915_dev *dev = mt7915_hw_dev(hw); 805 struct mt76_phy *mphy = hw->priv; 806 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 807 struct ieee80211_vif *vif = info->control.vif; 808 struct mt76_wcid *wcid = &dev->mt76.global_wcid; 809 810 if (control->sta) { 811 struct mt7915_sta *sta; 812 813 sta = (struct mt7915_sta *)control->sta->drv_priv; 814 wcid = &sta->wcid; 815 } 816 817 if (vif && !control->sta) { 818 struct mt7915_vif *mvif; 819 820 mvif = (struct mt7915_vif *)vif->drv_priv; 821 wcid = &mvif->sta.wcid; 822 } 823 824 mt76_tx(mphy, control->sta, wcid, skb); 825 } 826 827 static int mt7915_set_rts_threshold(struct ieee80211_hw *hw, u32 val) 828 { 829 struct mt7915_dev *dev = mt7915_hw_dev(hw); 830 struct mt7915_phy *phy = mt7915_hw_phy(hw); 831 int ret; 832 833 mutex_lock(&dev->mt76.mutex); 834 ret = mt76_connac_mcu_set_rts_thresh(&dev->mt76, val, 835 phy->mt76->band_idx); 836 mutex_unlock(&dev->mt76.mutex); 837 838 return ret; 839 } 840 841 static int 842 mt7915_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 843 struct ieee80211_ampdu_params *params) 844 { 845 enum ieee80211_ampdu_mlme_action action = params->action; 846 struct mt7915_dev *dev = mt7915_hw_dev(hw); 847 struct ieee80211_sta *sta = params->sta; 848 struct ieee80211_txq *txq = sta->txq[params->tid]; 849 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; 850 u16 tid = params->tid; 851 u16 ssn = params->ssn; 852 struct mt76_txq *mtxq; 853 int ret = 0; 854 855 if (!txq) 856 return -EINVAL; 857 858 mtxq = (struct mt76_txq *)txq->drv_priv; 859 860 mutex_lock(&dev->mt76.mutex); 861 switch (action) { 862 case IEEE80211_AMPDU_RX_START: 863 mt76_rx_aggr_start(&dev->mt76, &msta->wcid, tid, ssn, 864 params->buf_size); 865 ret = mt7915_mcu_add_rx_ba(dev, params, true); 866 break; 867 case IEEE80211_AMPDU_RX_STOP: 868 mt76_rx_aggr_stop(&dev->mt76, &msta->wcid, tid); 869 ret = mt7915_mcu_add_rx_ba(dev, params, false); 870 break; 871 case IEEE80211_AMPDU_TX_OPERATIONAL: 872 mtxq->aggr = true; 873 mtxq->send_bar = false; 874 ret = mt7915_mcu_add_tx_ba(dev, params, true); 875 break; 876 case IEEE80211_AMPDU_TX_STOP_FLUSH: 877 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: 878 mtxq->aggr = false; 879 clear_bit(tid, &msta->wcid.ampdu_state); 880 ret = mt7915_mcu_add_tx_ba(dev, params, false); 881 break; 882 case IEEE80211_AMPDU_TX_START: 883 set_bit(tid, &msta->wcid.ampdu_state); 884 ret = IEEE80211_AMPDU_TX_START_IMMEDIATE; 885 break; 886 case IEEE80211_AMPDU_TX_STOP_CONT: 887 mtxq->aggr = false; 888 clear_bit(tid, &msta->wcid.ampdu_state); 889 ret = mt7915_mcu_add_tx_ba(dev, params, false); 890 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); 891 break; 892 } 893 mutex_unlock(&dev->mt76.mutex); 894 895 return ret; 896 } 897 898 static int 899 mt7915_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 900 struct ieee80211_sta *sta) 901 { 902 return mt76_sta_state(hw, vif, sta, IEEE80211_STA_NOTEXIST, 903 IEEE80211_STA_NONE); 904 } 905 906 static int 907 mt7915_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 908 struct ieee80211_sta *sta) 909 { 910 return mt76_sta_state(hw, vif, sta, IEEE80211_STA_NONE, 911 IEEE80211_STA_NOTEXIST); 912 } 913 914 static int 915 mt7915_get_stats(struct ieee80211_hw *hw, 916 struct ieee80211_low_level_stats *stats) 917 { 918 struct mt7915_phy *phy = mt7915_hw_phy(hw); 919 struct mt7915_dev *dev = mt7915_hw_dev(hw); 920 struct mt76_mib_stats *mib = &phy->mib; 921 922 mutex_lock(&dev->mt76.mutex); 923 924 stats->dot11RTSSuccessCount = mib->rts_cnt; 925 stats->dot11RTSFailureCount = mib->rts_retries_cnt; 926 stats->dot11FCSErrorCount = mib->fcs_err_cnt; 927 stats->dot11ACKFailureCount = mib->ack_fail_cnt; 928 929 mutex_unlock(&dev->mt76.mutex); 930 931 return 0; 932 } 933 934 u64 __mt7915_get_tsf(struct ieee80211_hw *hw, struct mt7915_vif *mvif) 935 { 936 struct mt7915_dev *dev = mt7915_hw_dev(hw); 937 struct mt7915_phy *phy = mt7915_hw_phy(hw); 938 bool band = phy->mt76->band_idx; 939 union { 940 u64 t64; 941 u32 t32[2]; 942 } tsf; 943 u16 n; 944 945 lockdep_assert_held(&dev->mt76.mutex); 946 947 n = mvif->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0 948 : mvif->mt76.omac_idx; 949 /* TSF software read */ 950 if (is_mt7915(&dev->mt76)) 951 mt76_rmw(dev, MT_LPON_TCR(band, n), MT_LPON_TCR_SW_MODE, 952 MT_LPON_TCR_SW_READ); 953 else 954 mt76_rmw(dev, MT_LPON_TCR_MT7916(band, n), MT_LPON_TCR_SW_MODE, 955 MT_LPON_TCR_SW_READ); 956 tsf.t32[0] = mt76_rr(dev, MT_LPON_UTTR0(band)); 957 tsf.t32[1] = mt76_rr(dev, MT_LPON_UTTR1(band)); 958 959 return tsf.t64; 960 } 961 962 static u64 963 mt7915_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) 964 { 965 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; 966 struct mt7915_dev *dev = mt7915_hw_dev(hw); 967 u64 ret; 968 969 mutex_lock(&dev->mt76.mutex); 970 ret = __mt7915_get_tsf(hw, mvif); 971 mutex_unlock(&dev->mt76.mutex); 972 973 return ret; 974 } 975 976 static void 977 mt7915_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 978 u64 timestamp) 979 { 980 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; 981 struct mt7915_dev *dev = mt7915_hw_dev(hw); 982 struct mt7915_phy *phy = mt7915_hw_phy(hw); 983 bool band = phy->mt76->band_idx; 984 union { 985 u64 t64; 986 u32 t32[2]; 987 } tsf = { .t64 = timestamp, }; 988 u16 n; 989 990 mutex_lock(&dev->mt76.mutex); 991 992 n = mvif->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0 993 : mvif->mt76.omac_idx; 994 mt76_wr(dev, MT_LPON_UTTR0(band), tsf.t32[0]); 995 mt76_wr(dev, MT_LPON_UTTR1(band), tsf.t32[1]); 996 /* TSF software overwrite */ 997 if (is_mt7915(&dev->mt76)) 998 mt76_rmw(dev, MT_LPON_TCR(band, n), MT_LPON_TCR_SW_MODE, 999 MT_LPON_TCR_SW_WRITE); 1000 else 1001 mt76_rmw(dev, MT_LPON_TCR_MT7916(band, n), MT_LPON_TCR_SW_MODE, 1002 MT_LPON_TCR_SW_WRITE); 1003 1004 mutex_unlock(&dev->mt76.mutex); 1005 } 1006 1007 static void 1008 mt7915_offset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 1009 s64 timestamp) 1010 { 1011 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; 1012 struct mt7915_dev *dev = mt7915_hw_dev(hw); 1013 struct mt7915_phy *phy = mt7915_hw_phy(hw); 1014 bool band = phy->mt76->band_idx; 1015 union { 1016 u64 t64; 1017 u32 t32[2]; 1018 } tsf = { .t64 = timestamp, }; 1019 u16 n; 1020 1021 mutex_lock(&dev->mt76.mutex); 1022 1023 n = mvif->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0 1024 : mvif->mt76.omac_idx; 1025 mt76_wr(dev, MT_LPON_UTTR0(band), tsf.t32[0]); 1026 mt76_wr(dev, MT_LPON_UTTR1(band), tsf.t32[1]); 1027 /* TSF software adjust*/ 1028 if (is_mt7915(&dev->mt76)) 1029 mt76_rmw(dev, MT_LPON_TCR(band, n), MT_LPON_TCR_SW_MODE, 1030 MT_LPON_TCR_SW_ADJUST); 1031 else 1032 mt76_rmw(dev, MT_LPON_TCR_MT7916(band, n), MT_LPON_TCR_SW_MODE, 1033 MT_LPON_TCR_SW_ADJUST); 1034 1035 mutex_unlock(&dev->mt76.mutex); 1036 } 1037 1038 static void 1039 mt7915_set_coverage_class(struct ieee80211_hw *hw, s16 coverage_class) 1040 { 1041 struct mt7915_phy *phy = mt7915_hw_phy(hw); 1042 struct mt7915_dev *dev = phy->dev; 1043 1044 mutex_lock(&dev->mt76.mutex); 1045 phy->coverage_class = max_t(s16, coverage_class, 0); 1046 mt7915_mac_set_timing(phy); 1047 mutex_unlock(&dev->mt76.mutex); 1048 } 1049 1050 static int 1051 mt7915_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant) 1052 { 1053 struct mt7915_dev *dev = mt7915_hw_dev(hw); 1054 struct mt7915_phy *phy = mt7915_hw_phy(hw); 1055 int max_nss = hweight8(hw->wiphy->available_antennas_tx); 1056 u8 chainshift = dev->chainshift; 1057 u8 band = phy->mt76->band_idx; 1058 1059 if (!tx_ant || tx_ant != rx_ant || ffs(tx_ant) > max_nss) 1060 return -EINVAL; 1061 1062 mutex_lock(&dev->mt76.mutex); 1063 1064 phy->mt76->antenna_mask = tx_ant; 1065 1066 /* handle a variant of mt7916/mt7981 which has 3T3R but nss2 on 5 GHz band */ 1067 if ((is_mt7916(&dev->mt76) || is_mt7981(&dev->mt76)) && 1068 band && hweight8(tx_ant) == max_nss) 1069 phy->mt76->chainmask = (dev->chainmask >> chainshift) << chainshift; 1070 else 1071 phy->mt76->chainmask = tx_ant << (chainshift * band); 1072 1073 mt76_set_stream_caps(phy->mt76, true); 1074 mt7915_set_stream_vht_txbf_caps(phy); 1075 mt7915_set_stream_he_caps(phy); 1076 1077 mutex_unlock(&dev->mt76.mutex); 1078 1079 return 0; 1080 } 1081 1082 static void mt7915_sta_statistics(struct ieee80211_hw *hw, 1083 struct ieee80211_vif *vif, 1084 struct ieee80211_sta *sta, 1085 struct station_info *sinfo) 1086 { 1087 struct mt7915_phy *phy = mt7915_hw_phy(hw); 1088 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; 1089 struct rate_info *txrate = &msta->wcid.rate; 1090 struct rate_info rxrate = {}; 1091 1092 if (is_mt7915(&phy->dev->mt76) && 1093 !mt7915_mcu_get_rx_rate(phy, vif, sta, &rxrate)) { 1094 sinfo->rxrate = rxrate; 1095 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BITRATE); 1096 } 1097 1098 if (txrate->legacy || txrate->flags) { 1099 if (txrate->legacy) { 1100 sinfo->txrate.legacy = txrate->legacy; 1101 } else { 1102 sinfo->txrate.mcs = txrate->mcs; 1103 sinfo->txrate.nss = txrate->nss; 1104 sinfo->txrate.bw = txrate->bw; 1105 sinfo->txrate.he_gi = txrate->he_gi; 1106 sinfo->txrate.he_dcm = txrate->he_dcm; 1107 sinfo->txrate.he_ru_alloc = txrate->he_ru_alloc; 1108 } 1109 sinfo->txrate.flags = txrate->flags; 1110 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE); 1111 } 1112 1113 /* offloading flows bypass networking stack, so driver counts and 1114 * reports sta statistics via NL80211_STA_INFO when WED is active. 1115 */ 1116 if (mtk_wed_device_active(&phy->dev->mt76.mmio.wed)) { 1117 sinfo->tx_bytes = msta->wcid.stats.tx_bytes; 1118 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BYTES64); 1119 1120 if (!mt7915_mcu_wed_wa_tx_stats(phy->dev, msta->wcid.idx)) { 1121 sinfo->tx_packets = msta->wcid.stats.tx_packets; 1122 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_PACKETS); 1123 } 1124 1125 if (mtk_wed_get_rx_capa(&phy->dev->mt76.mmio.wed)) { 1126 sinfo->rx_bytes = msta->wcid.stats.rx_bytes; 1127 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BYTES64); 1128 1129 sinfo->rx_packets = msta->wcid.stats.rx_packets; 1130 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_PACKETS); 1131 } 1132 } 1133 1134 sinfo->tx_failed = msta->wcid.stats.tx_failed; 1135 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_FAILED); 1136 1137 sinfo->tx_retries = msta->wcid.stats.tx_retries; 1138 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES); 1139 1140 sinfo->ack_signal = (s8)msta->ack_signal; 1141 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL); 1142 1143 sinfo->avg_ack_signal = -(s8)ewma_avg_signal_read(&msta->avg_ack_signal); 1144 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL_AVG); 1145 } 1146 1147 static void mt7915_sta_rc_work(void *data, struct ieee80211_sta *sta) 1148 { 1149 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; 1150 struct mt7915_dev *dev = msta->vif->phy->dev; 1151 u32 *changed = data; 1152 1153 spin_lock_bh(&dev->mt76.sta_poll_lock); 1154 msta->changed |= *changed; 1155 if (list_empty(&msta->rc_list)) 1156 list_add_tail(&msta->rc_list, &dev->sta_rc_list); 1157 spin_unlock_bh(&dev->mt76.sta_poll_lock); 1158 } 1159 1160 static void mt7915_sta_rc_update(struct ieee80211_hw *hw, 1161 struct ieee80211_vif *vif, 1162 struct ieee80211_sta *sta, 1163 u32 changed) 1164 { 1165 struct mt7915_phy *phy = mt7915_hw_phy(hw); 1166 struct mt7915_dev *dev = phy->dev; 1167 1168 mt7915_sta_rc_work(&changed, sta); 1169 ieee80211_queue_work(hw, &dev->rc_work); 1170 } 1171 1172 static int 1173 mt7915_set_bitrate_mask(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 1174 const struct cfg80211_bitrate_mask *mask) 1175 { 1176 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; 1177 struct mt7915_phy *phy = mt7915_hw_phy(hw); 1178 struct mt7915_dev *dev = phy->dev; 1179 u32 changed = IEEE80211_RC_SUPP_RATES_CHANGED; 1180 1181 mvif->bitrate_mask = *mask; 1182 1183 /* if multiple rates across different preambles are given we can 1184 * reconfigure this info with all peers using sta_rec command with 1185 * the below exception cases. 1186 * - single rate : if a rate is passed along with different preambles, 1187 * we select the highest one as fixed rate. i.e VHT MCS for VHT peers. 1188 * - multiple rates: if it's not in range format i.e 0-{7,8,9} for VHT 1189 * then multiple MCS setting (MCS 4,5,6) is not supported. 1190 */ 1191 ieee80211_iterate_stations_atomic(hw, mt7915_sta_rc_work, &changed); 1192 ieee80211_queue_work(hw, &dev->rc_work); 1193 1194 return 0; 1195 } 1196 1197 static void mt7915_sta_set_4addr(struct ieee80211_hw *hw, 1198 struct ieee80211_vif *vif, 1199 struct ieee80211_sta *sta, 1200 bool enabled) 1201 { 1202 struct mt7915_dev *dev = mt7915_hw_dev(hw); 1203 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; 1204 1205 if (enabled) 1206 set_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags); 1207 else 1208 clear_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags); 1209 1210 mt76_connac_mcu_wtbl_update_hdr_trans(&dev->mt76, vif, sta); 1211 } 1212 1213 static void mt7915_sta_set_decap_offload(struct ieee80211_hw *hw, 1214 struct ieee80211_vif *vif, 1215 struct ieee80211_sta *sta, 1216 bool enabled) 1217 { 1218 struct mt7915_dev *dev = mt7915_hw_dev(hw); 1219 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; 1220 1221 if (enabled) 1222 set_bit(MT_WCID_FLAG_HDR_TRANS, &msta->wcid.flags); 1223 else 1224 clear_bit(MT_WCID_FLAG_HDR_TRANS, &msta->wcid.flags); 1225 1226 mt76_connac_mcu_wtbl_update_hdr_trans(&dev->mt76, vif, sta); 1227 } 1228 1229 static int mt7915_sta_set_txpwr(struct ieee80211_hw *hw, 1230 struct ieee80211_vif *vif, 1231 struct ieee80211_sta *sta) 1232 { 1233 struct mt7915_phy *phy = mt7915_hw_phy(hw); 1234 struct mt7915_dev *dev = mt7915_hw_dev(hw); 1235 s16 txpower = sta->deflink.txpwr.power; 1236 int ret; 1237 1238 if (sta->deflink.txpwr.type == NL80211_TX_POWER_AUTOMATIC) 1239 txpower = 0; 1240 1241 mutex_lock(&dev->mt76.mutex); 1242 1243 /* NOTE: temporarily use 0 as minimum limit, which is a 1244 * global setting and will be applied to all stations. 1245 */ 1246 ret = mt7915_mcu_set_txpower_frame_min(phy, 0); 1247 if (ret) 1248 goto out; 1249 1250 /* This only applies to data frames while pushing traffic, 1251 * whereas the management frames or other packets that are 1252 * using fixed rate can be configured via TxD. 1253 */ 1254 ret = mt7915_mcu_set_txpower_frame(phy, vif, sta, txpower); 1255 1256 out: 1257 mutex_unlock(&dev->mt76.mutex); 1258 1259 return ret; 1260 } 1261 1262 static const char mt7915_gstrings_stats[][ETH_GSTRING_LEN] = { 1263 "tx_ampdu_cnt", 1264 "tx_stop_q_empty_cnt", 1265 "tx_mpdu_attempts", 1266 "tx_mpdu_success", 1267 "tx_rwp_fail_cnt", 1268 "tx_rwp_need_cnt", 1269 "tx_pkt_ebf_cnt", 1270 "tx_pkt_ibf_cnt", 1271 "tx_ampdu_len:0-1", 1272 "tx_ampdu_len:2-10", 1273 "tx_ampdu_len:11-19", 1274 "tx_ampdu_len:20-28", 1275 "tx_ampdu_len:29-37", 1276 "tx_ampdu_len:38-46", 1277 "tx_ampdu_len:47-55", 1278 "tx_ampdu_len:56-79", 1279 "tx_ampdu_len:80-103", 1280 "tx_ampdu_len:104-127", 1281 "tx_ampdu_len:128-151", 1282 "tx_ampdu_len:152-175", 1283 "tx_ampdu_len:176-199", 1284 "tx_ampdu_len:200-223", 1285 "tx_ampdu_len:224-247", 1286 "ba_miss_count", 1287 "tx_beamformer_ppdu_iBF", 1288 "tx_beamformer_ppdu_eBF", 1289 "tx_beamformer_rx_feedback_all", 1290 "tx_beamformer_rx_feedback_he", 1291 "tx_beamformer_rx_feedback_vht", 1292 "tx_beamformer_rx_feedback_ht", 1293 "tx_beamformer_rx_feedback_bw", /* zero based idx: 20, 40, 80, 160 */ 1294 "tx_beamformer_rx_feedback_nc", 1295 "tx_beamformer_rx_feedback_nr", 1296 "tx_beamformee_ok_feedback_pkts", 1297 "tx_beamformee_feedback_trig", 1298 "tx_mu_beamforming", 1299 "tx_mu_mpdu", 1300 "tx_mu_successful_mpdu", 1301 "tx_su_successful_mpdu", 1302 "tx_msdu_pack_1", 1303 "tx_msdu_pack_2", 1304 "tx_msdu_pack_3", 1305 "tx_msdu_pack_4", 1306 "tx_msdu_pack_5", 1307 "tx_msdu_pack_6", 1308 "tx_msdu_pack_7", 1309 "tx_msdu_pack_8", 1310 1311 /* rx counters */ 1312 "rx_fifo_full_cnt", 1313 "rx_mpdu_cnt", 1314 "channel_idle_cnt", 1315 "primary_cca_busy_time", 1316 "secondary_cca_busy_time", 1317 "primary_energy_detect_time", 1318 "cck_mdrdy_time", 1319 "ofdm_mdrdy_time", 1320 "green_mdrdy_time", 1321 "rx_vector_mismatch_cnt", 1322 "rx_delimiter_fail_cnt", 1323 "rx_mrdy_cnt", 1324 "rx_len_mismatch_cnt", 1325 "rx_ampdu_cnt", 1326 "rx_ampdu_bytes_cnt", 1327 "rx_ampdu_valid_subframe_cnt", 1328 "rx_ampdu_valid_subframe_b_cnt", 1329 "rx_pfdrop_cnt", 1330 "rx_vec_queue_overflow_drop_cnt", 1331 "rx_ba_cnt", 1332 1333 /* muru mu-mimo and ofdma related stats */ 1334 "dl_cck_cnt", 1335 "dl_ofdm_cnt", 1336 "dl_htmix_cnt", 1337 "dl_htgf_cnt", 1338 "dl_vht_su_cnt", 1339 "dl_vht_2mu_cnt", 1340 "dl_vht_3mu_cnt", 1341 "dl_vht_4mu_cnt", 1342 "dl_he_su_cnt", 1343 "dl_he_ext_su_cnt", 1344 "dl_he_2ru_cnt", 1345 "dl_he_2mu_cnt", 1346 "dl_he_3ru_cnt", 1347 "dl_he_3mu_cnt", 1348 "dl_he_4ru_cnt", 1349 "dl_he_4mu_cnt", 1350 "dl_he_5to8ru_cnt", 1351 "dl_he_9to16ru_cnt", 1352 "dl_he_gtr16ru_cnt", 1353 1354 "ul_hetrig_su_cnt", 1355 "ul_hetrig_2ru_cnt", 1356 "ul_hetrig_3ru_cnt", 1357 "ul_hetrig_4ru_cnt", 1358 "ul_hetrig_5to8ru_cnt", 1359 "ul_hetrig_9to16ru_cnt", 1360 "ul_hetrig_gtr16ru_cnt", 1361 "ul_hetrig_2mu_cnt", 1362 "ul_hetrig_3mu_cnt", 1363 "ul_hetrig_4mu_cnt", 1364 1365 /* per vif counters */ 1366 "v_tx_mode_cck", 1367 "v_tx_mode_ofdm", 1368 "v_tx_mode_ht", 1369 "v_tx_mode_ht_gf", 1370 "v_tx_mode_vht", 1371 "v_tx_mode_he_su", 1372 "v_tx_mode_he_ext_su", 1373 "v_tx_mode_he_tb", 1374 "v_tx_mode_he_mu", 1375 "v_tx_bw_20", 1376 "v_tx_bw_40", 1377 "v_tx_bw_80", 1378 "v_tx_bw_160", 1379 "v_tx_mcs_0", 1380 "v_tx_mcs_1", 1381 "v_tx_mcs_2", 1382 "v_tx_mcs_3", 1383 "v_tx_mcs_4", 1384 "v_tx_mcs_5", 1385 "v_tx_mcs_6", 1386 "v_tx_mcs_7", 1387 "v_tx_mcs_8", 1388 "v_tx_mcs_9", 1389 "v_tx_mcs_10", 1390 "v_tx_mcs_11", 1391 "v_tx_nss_1", 1392 "v_tx_nss_2", 1393 "v_tx_nss_3", 1394 "v_tx_nss_4", 1395 }; 1396 1397 #define MT7915_SSTATS_LEN ARRAY_SIZE(mt7915_gstrings_stats) 1398 1399 /* Ethtool related API */ 1400 static 1401 void mt7915_get_et_strings(struct ieee80211_hw *hw, 1402 struct ieee80211_vif *vif, 1403 u32 sset, u8 *data) 1404 { 1405 if (sset != ETH_SS_STATS) 1406 return; 1407 1408 memcpy(data, mt7915_gstrings_stats, sizeof(mt7915_gstrings_stats)); 1409 data += sizeof(mt7915_gstrings_stats); 1410 page_pool_ethtool_stats_get_strings(data); 1411 } 1412 1413 static 1414 int mt7915_get_et_sset_count(struct ieee80211_hw *hw, 1415 struct ieee80211_vif *vif, int sset) 1416 { 1417 if (sset != ETH_SS_STATS) 1418 return 0; 1419 1420 return MT7915_SSTATS_LEN + page_pool_ethtool_stats_get_count(); 1421 } 1422 1423 static void mt7915_ethtool_worker(void *wi_data, struct ieee80211_sta *sta) 1424 { 1425 struct mt76_ethtool_worker_info *wi = wi_data; 1426 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; 1427 1428 if (msta->vif->mt76.idx != wi->idx) 1429 return; 1430 1431 mt76_ethtool_worker(wi, &msta->wcid.stats, false); 1432 } 1433 1434 static 1435 void mt7915_get_et_stats(struct ieee80211_hw *hw, 1436 struct ieee80211_vif *vif, 1437 struct ethtool_stats *stats, u64 *data) 1438 { 1439 struct mt7915_dev *dev = mt7915_hw_dev(hw); 1440 struct mt7915_phy *phy = mt7915_hw_phy(hw); 1441 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; 1442 struct mt76_mib_stats *mib = &phy->mib; 1443 struct mt76_ethtool_worker_info wi = { 1444 .data = data, 1445 .idx = mvif->mt76.idx, 1446 }; 1447 /* See mt7915_ampdu_stat_read_phy, etc */ 1448 int i, ei = 0, stats_size; 1449 1450 mutex_lock(&dev->mt76.mutex); 1451 1452 mt7915_mac_update_stats(phy); 1453 1454 data[ei++] = mib->tx_ampdu_cnt; 1455 data[ei++] = mib->tx_stop_q_empty_cnt; 1456 data[ei++] = mib->tx_mpdu_attempts_cnt; 1457 data[ei++] = mib->tx_mpdu_success_cnt; 1458 data[ei++] = mib->tx_rwp_fail_cnt; 1459 data[ei++] = mib->tx_rwp_need_cnt; 1460 data[ei++] = mib->tx_pkt_ebf_cnt; 1461 data[ei++] = mib->tx_pkt_ibf_cnt; 1462 1463 /* Tx ampdu stat */ 1464 for (i = 0; i < 15 /*ARRAY_SIZE(bound)*/; i++) 1465 data[ei++] = phy->mt76->aggr_stats[i]; 1466 1467 data[ei++] = phy->mib.ba_miss_cnt; 1468 1469 /* Tx Beamformer monitor */ 1470 data[ei++] = mib->tx_bf_ibf_ppdu_cnt; 1471 data[ei++] = mib->tx_bf_ebf_ppdu_cnt; 1472 1473 /* Tx Beamformer Rx feedback monitor */ 1474 data[ei++] = mib->tx_bf_rx_fb_all_cnt; 1475 data[ei++] = mib->tx_bf_rx_fb_he_cnt; 1476 data[ei++] = mib->tx_bf_rx_fb_vht_cnt; 1477 data[ei++] = mib->tx_bf_rx_fb_ht_cnt; 1478 1479 data[ei++] = mib->tx_bf_rx_fb_bw; 1480 data[ei++] = mib->tx_bf_rx_fb_nc_cnt; 1481 data[ei++] = mib->tx_bf_rx_fb_nr_cnt; 1482 1483 /* Tx Beamformee Rx NDPA & Tx feedback report */ 1484 data[ei++] = mib->tx_bf_fb_cpl_cnt; 1485 data[ei++] = mib->tx_bf_fb_trig_cnt; 1486 1487 /* Tx SU & MU counters */ 1488 data[ei++] = mib->tx_bf_cnt; 1489 data[ei++] = mib->tx_mu_mpdu_cnt; 1490 data[ei++] = mib->tx_mu_acked_mpdu_cnt; 1491 data[ei++] = mib->tx_su_acked_mpdu_cnt; 1492 1493 /* Tx amsdu info (pack-count histogram) */ 1494 for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) 1495 data[ei++] = mib->tx_amsdu[i]; 1496 1497 /* rx counters */ 1498 data[ei++] = mib->rx_fifo_full_cnt; 1499 data[ei++] = mib->rx_mpdu_cnt; 1500 data[ei++] = mib->channel_idle_cnt; 1501 data[ei++] = mib->primary_cca_busy_time; 1502 data[ei++] = mib->secondary_cca_busy_time; 1503 data[ei++] = mib->primary_energy_detect_time; 1504 data[ei++] = mib->cck_mdrdy_time; 1505 data[ei++] = mib->ofdm_mdrdy_time; 1506 data[ei++] = mib->green_mdrdy_time; 1507 data[ei++] = mib->rx_vector_mismatch_cnt; 1508 data[ei++] = mib->rx_delimiter_fail_cnt; 1509 data[ei++] = mib->rx_mrdy_cnt; 1510 data[ei++] = mib->rx_len_mismatch_cnt; 1511 data[ei++] = mib->rx_ampdu_cnt; 1512 data[ei++] = mib->rx_ampdu_bytes_cnt; 1513 data[ei++] = mib->rx_ampdu_valid_subframe_cnt; 1514 data[ei++] = mib->rx_ampdu_valid_subframe_bytes_cnt; 1515 data[ei++] = mib->rx_pfdrop_cnt; 1516 data[ei++] = mib->rx_vec_queue_overflow_drop_cnt; 1517 data[ei++] = mib->rx_ba_cnt; 1518 1519 data[ei++] = mib->dl_cck_cnt; 1520 data[ei++] = mib->dl_ofdm_cnt; 1521 data[ei++] = mib->dl_htmix_cnt; 1522 data[ei++] = mib->dl_htgf_cnt; 1523 data[ei++] = mib->dl_vht_su_cnt; 1524 data[ei++] = mib->dl_vht_2mu_cnt; 1525 data[ei++] = mib->dl_vht_3mu_cnt; 1526 data[ei++] = mib->dl_vht_4mu_cnt; 1527 data[ei++] = mib->dl_he_su_cnt; 1528 data[ei++] = mib->dl_he_ext_su_cnt; 1529 data[ei++] = mib->dl_he_2ru_cnt; 1530 data[ei++] = mib->dl_he_2mu_cnt; 1531 data[ei++] = mib->dl_he_3ru_cnt; 1532 data[ei++] = mib->dl_he_3mu_cnt; 1533 data[ei++] = mib->dl_he_4ru_cnt; 1534 data[ei++] = mib->dl_he_4mu_cnt; 1535 data[ei++] = mib->dl_he_5to8ru_cnt; 1536 data[ei++] = mib->dl_he_9to16ru_cnt; 1537 data[ei++] = mib->dl_he_gtr16ru_cnt; 1538 1539 data[ei++] = mib->ul_hetrig_su_cnt; 1540 data[ei++] = mib->ul_hetrig_2ru_cnt; 1541 data[ei++] = mib->ul_hetrig_3ru_cnt; 1542 data[ei++] = mib->ul_hetrig_4ru_cnt; 1543 data[ei++] = mib->ul_hetrig_5to8ru_cnt; 1544 data[ei++] = mib->ul_hetrig_9to16ru_cnt; 1545 data[ei++] = mib->ul_hetrig_gtr16ru_cnt; 1546 data[ei++] = mib->ul_hetrig_2mu_cnt; 1547 data[ei++] = mib->ul_hetrig_3mu_cnt; 1548 data[ei++] = mib->ul_hetrig_4mu_cnt; 1549 1550 /* Add values for all stations owned by this vif */ 1551 wi.initial_stat_idx = ei; 1552 ieee80211_iterate_stations_atomic(hw, mt7915_ethtool_worker, &wi); 1553 1554 mutex_unlock(&dev->mt76.mutex); 1555 1556 if (wi.sta_count == 0) 1557 return; 1558 1559 ei += wi.worker_stat_count; 1560 1561 mt76_ethtool_page_pool_stats(&dev->mt76, &data[ei], &ei); 1562 1563 stats_size = MT7915_SSTATS_LEN + page_pool_ethtool_stats_get_count(); 1564 if (ei != stats_size) 1565 dev_err(dev->mt76.dev, "ei: %d size: %d", ei, stats_size); 1566 } 1567 1568 static void 1569 mt7915_twt_teardown_request(struct ieee80211_hw *hw, 1570 struct ieee80211_sta *sta, 1571 u8 flowid) 1572 { 1573 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; 1574 struct mt7915_dev *dev = mt7915_hw_dev(hw); 1575 1576 mutex_lock(&dev->mt76.mutex); 1577 mt7915_mac_twt_teardown_flow(dev, msta, flowid); 1578 mutex_unlock(&dev->mt76.mutex); 1579 } 1580 1581 static int 1582 mt7915_set_radar_background(struct ieee80211_hw *hw, 1583 struct cfg80211_chan_def *chandef) 1584 { 1585 struct mt7915_phy *phy = mt7915_hw_phy(hw); 1586 struct mt7915_dev *dev = phy->dev; 1587 int ret = -EINVAL; 1588 bool running; 1589 1590 mutex_lock(&dev->mt76.mutex); 1591 1592 if (dev->mt76.region == NL80211_DFS_UNSET) 1593 goto out; 1594 1595 if (dev->rdd2_phy && dev->rdd2_phy != phy) { 1596 /* rdd2 is already locked */ 1597 ret = -EBUSY; 1598 goto out; 1599 } 1600 1601 /* rdd2 already configured on a radar channel */ 1602 running = dev->rdd2_phy && 1603 cfg80211_chandef_valid(&dev->rdd2_chandef) && 1604 !!(dev->rdd2_chandef.chan->flags & IEEE80211_CHAN_RADAR); 1605 1606 if (!chandef || running || 1607 !(chandef->chan->flags & IEEE80211_CHAN_RADAR)) { 1608 ret = mt7915_mcu_rdd_background_enable(phy, NULL); 1609 if (ret) 1610 goto out; 1611 1612 if (!running) 1613 goto update_phy; 1614 } 1615 1616 ret = mt7915_mcu_rdd_background_enable(phy, chandef); 1617 if (ret) 1618 goto out; 1619 1620 update_phy: 1621 dev->rdd2_phy = chandef ? phy : NULL; 1622 if (chandef) 1623 dev->rdd2_chandef = *chandef; 1624 out: 1625 mutex_unlock(&dev->mt76.mutex); 1626 1627 return ret; 1628 } 1629 1630 #ifdef CONFIG_NET_MEDIATEK_SOC_WED 1631 static int 1632 mt7915_net_fill_forward_path(struct ieee80211_hw *hw, 1633 struct ieee80211_vif *vif, 1634 struct ieee80211_sta *sta, 1635 struct net_device_path_ctx *ctx, 1636 struct net_device_path *path) 1637 { 1638 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; 1639 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; 1640 struct mt7915_dev *dev = mt7915_hw_dev(hw); 1641 struct mt7915_phy *phy = mt7915_hw_phy(hw); 1642 struct mtk_wed_device *wed = &dev->mt76.mmio.wed; 1643 1644 if (!mtk_wed_device_active(wed)) 1645 return -ENODEV; 1646 1647 if (msta->wcid.idx > 0xff) 1648 return -EIO; 1649 1650 path->type = DEV_PATH_MTK_WDMA; 1651 path->dev = ctx->dev; 1652 path->mtk_wdma.wdma_idx = wed->wdma_idx; 1653 path->mtk_wdma.bss = mvif->mt76.idx; 1654 path->mtk_wdma.wcid = is_mt7915(&dev->mt76) ? msta->wcid.idx : 0x3ff; 1655 path->mtk_wdma.queue = phy != &dev->phy; 1656 1657 ctx->dev = NULL; 1658 1659 return 0; 1660 } 1661 #endif 1662 1663 const struct ieee80211_ops mt7915_ops = { 1664 .add_chanctx = ieee80211_emulate_add_chanctx, 1665 .remove_chanctx = ieee80211_emulate_remove_chanctx, 1666 .change_chanctx = ieee80211_emulate_change_chanctx, 1667 .switch_vif_chanctx = ieee80211_emulate_switch_vif_chanctx, 1668 .tx = mt7915_tx, 1669 .start = mt7915_start, 1670 .stop = mt7915_stop, 1671 .add_interface = mt7915_add_interface, 1672 .remove_interface = mt7915_remove_interface, 1673 .config = mt7915_config, 1674 .conf_tx = mt7915_conf_tx, 1675 .configure_filter = mt7915_configure_filter, 1676 .bss_info_changed = mt7915_bss_info_changed, 1677 .start_ap = mt7915_start_ap, 1678 .stop_ap = mt7915_stop_ap, 1679 .sta_add = mt7915_sta_add, 1680 .sta_remove = mt7915_sta_remove, 1681 .sta_pre_rcu_remove = mt76_sta_pre_rcu_remove, 1682 .sta_rc_update = mt7915_sta_rc_update, 1683 .set_key = mt7915_set_key, 1684 .ampdu_action = mt7915_ampdu_action, 1685 .set_rts_threshold = mt7915_set_rts_threshold, 1686 .wake_tx_queue = mt76_wake_tx_queue, 1687 .sw_scan_start = mt76_sw_scan, 1688 .sw_scan_complete = mt76_sw_scan_complete, 1689 .release_buffered_frames = mt76_release_buffered_frames, 1690 .get_txpower = mt76_get_txpower, 1691 .set_sar_specs = mt7915_set_sar_specs, 1692 .channel_switch_beacon = mt7915_channel_switch_beacon, 1693 .get_stats = mt7915_get_stats, 1694 .get_et_sset_count = mt7915_get_et_sset_count, 1695 .get_et_stats = mt7915_get_et_stats, 1696 .get_et_strings = mt7915_get_et_strings, 1697 .get_tsf = mt7915_get_tsf, 1698 .set_tsf = mt7915_set_tsf, 1699 .offset_tsf = mt7915_offset_tsf, 1700 .get_survey = mt76_get_survey, 1701 .get_antenna = mt76_get_antenna, 1702 .set_antenna = mt7915_set_antenna, 1703 .set_bitrate_mask = mt7915_set_bitrate_mask, 1704 .set_coverage_class = mt7915_set_coverage_class, 1705 .sta_statistics = mt7915_sta_statistics, 1706 .sta_set_txpwr = mt7915_sta_set_txpwr, 1707 .sta_set_4addr = mt7915_sta_set_4addr, 1708 .sta_set_decap_offload = mt7915_sta_set_decap_offload, 1709 .add_twt_setup = mt7915_mac_add_twt_setup, 1710 .twt_teardown_request = mt7915_twt_teardown_request, 1711 CFG80211_TESTMODE_CMD(mt76_testmode_cmd) 1712 CFG80211_TESTMODE_DUMP(mt76_testmode_dump) 1713 #ifdef CONFIG_MAC80211_DEBUGFS 1714 .sta_add_debugfs = mt7915_sta_add_debugfs, 1715 #endif 1716 .set_radar_background = mt7915_set_radar_background, 1717 #ifdef CONFIG_NET_MEDIATEK_SOC_WED 1718 .net_fill_forward_path = mt7915_net_fill_forward_path, 1719 .net_setup_tc = mt76_wed_net_setup_tc, 1720 #endif 1721 }; 1722