1 // SPDX-License-Identifier: ISC
2 /* Copyright (C) 2020 MediaTek Inc. */
4 #include <linux/etherdevice.h>
5 #include <linux/platform_device.h>
7 #include <linux/module.h>
11 static bool mt7915_dev_running(struct mt7915_dev *dev)
13 struct mt7915_phy *phy;
15 if (test_bit(MT76_STATE_RUNNING, &dev->mphy.state))
18 phy = mt7915_ext_phy(dev);
20 return phy && test_bit(MT76_STATE_RUNNING, &phy->mt76->state);
23 static int mt7915_start(struct ieee80211_hw *hw)
25 struct mt7915_dev *dev = mt7915_hw_dev(hw);
26 struct mt7915_phy *phy = mt7915_hw_phy(hw);
30 flush_work(&dev->init_work);
32 mutex_lock(&dev->mt76.mutex);
34 running = mt7915_dev_running(dev);
37 ret = mt76_connac_mcu_set_pm(&dev->mt76, 0, 0);
41 ret = mt7915_mcu_set_mac(dev, 0, true, true);
45 mt7915_mac_enable_nf(dev, 0);
48 if (phy != &dev->phy || phy->band_idx) {
49 ret = mt76_connac_mcu_set_pm(&dev->mt76, 1, 0);
53 ret = mt7915_mcu_set_mac(dev, 1, true, true);
57 mt7915_mac_enable_nf(dev, 1);
60 ret = mt76_connac_mcu_set_rts_thresh(&dev->mt76, 0x92b,
65 ret = mt7915_mcu_set_sku_en(phy, true);
69 ret = mt7915_mcu_set_chan_info(phy, MCU_EXT_CMD(SET_RX_PATH));
73 set_bit(MT76_STATE_RUNNING, &phy->mt76->state);
75 if (!mt76_testmode_enabled(phy->mt76))
76 ieee80211_queue_delayed_work(hw, &phy->mt76->mac_work,
77 MT7915_WATCHDOG_TIME);
80 mt7915_mac_reset_counters(phy);
83 mutex_unlock(&dev->mt76.mutex);
88 static void mt7915_stop(struct ieee80211_hw *hw)
90 struct mt7915_dev *dev = mt7915_hw_dev(hw);
91 struct mt7915_phy *phy = mt7915_hw_phy(hw);
93 cancel_delayed_work_sync(&phy->mt76->mac_work);
95 mutex_lock(&dev->mt76.mutex);
97 mt76_testmode_reset(phy->mt76, true);
99 clear_bit(MT76_STATE_RUNNING, &phy->mt76->state);
101 if (phy != &dev->phy) {
102 mt76_connac_mcu_set_pm(&dev->mt76, 1, 1);
103 mt7915_mcu_set_mac(dev, 1, false, false);
106 if (!mt7915_dev_running(dev)) {
107 mt76_connac_mcu_set_pm(&dev->mt76, 0, 1);
108 mt7915_mcu_set_mac(dev, 0, false, false);
111 mutex_unlock(&dev->mt76.mutex);
114 static inline int get_free_idx(u32 mask, u8 start, u8 end)
116 return ffs(~mask & GENMASK(end, start));
119 static int get_omac_idx(enum nl80211_iftype type, u64 mask)
124 case NL80211_IFTYPE_MESH_POINT:
125 case NL80211_IFTYPE_ADHOC:
126 case NL80211_IFTYPE_STATION:
127 /* prefer hw bssid slot 1-3 */
128 i = get_free_idx(mask, HW_BSSID_1, HW_BSSID_3);
132 if (type != NL80211_IFTYPE_STATION)
135 i = get_free_idx(mask, EXT_BSSID_1, EXT_BSSID_MAX);
139 if (~mask & BIT(HW_BSSID_0))
143 case NL80211_IFTYPE_MONITOR:
144 case NL80211_IFTYPE_AP:
145 /* ap uses hw bssid 0 and ext bssid */
146 if (~mask & BIT(HW_BSSID_0))
149 i = get_free_idx(mask, EXT_BSSID_1, EXT_BSSID_MAX);
162 static void mt7915_init_bitrate_mask(struct ieee80211_vif *vif)
164 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
167 for (i = 0; i < ARRAY_SIZE(mvif->bitrate_mask.control); i++) {
168 mvif->bitrate_mask.control[i].gi = NL80211_TXRATE_DEFAULT_GI;
169 mvif->bitrate_mask.control[i].he_gi = 0xff;
170 mvif->bitrate_mask.control[i].he_ltf = 0xff;
171 mvif->bitrate_mask.control[i].legacy = GENMASK(31, 0);
172 memset(mvif->bitrate_mask.control[i].ht_mcs, 0xff,
173 sizeof(mvif->bitrate_mask.control[i].ht_mcs));
174 memset(mvif->bitrate_mask.control[i].vht_mcs, 0xff,
175 sizeof(mvif->bitrate_mask.control[i].vht_mcs));
176 memset(mvif->bitrate_mask.control[i].he_mcs, 0xff,
177 sizeof(mvif->bitrate_mask.control[i].he_mcs));
181 static int mt7915_add_interface(struct ieee80211_hw *hw,
182 struct ieee80211_vif *vif)
184 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
185 struct mt7915_dev *dev = mt7915_hw_dev(hw);
186 struct mt7915_phy *phy = mt7915_hw_phy(hw);
187 struct mt76_txq *mtxq;
188 bool ext_phy = phy != &dev->phy;
191 mutex_lock(&dev->mt76.mutex);
193 mt76_testmode_reset(phy->mt76, true);
195 if (vif->type == NL80211_IFTYPE_MONITOR &&
196 is_zero_ether_addr(vif->addr))
197 phy->monitor_vif = vif;
199 mvif->mt76.idx = __ffs64(~dev->mt76.vif_mask);
200 if (mvif->mt76.idx >= (MT7915_MAX_INTERFACES << dev->dbdc_support)) {
205 idx = get_omac_idx(vif->type, phy->omac_mask);
210 mvif->mt76.omac_idx = idx;
212 mvif->mt76.band_idx = phy->band_idx;
214 mvif->mt76.wmm_idx = vif->type != NL80211_IFTYPE_AP;
216 mvif->mt76.wmm_idx += 2;
218 ret = mt7915_mcu_add_dev_info(phy, vif, true);
222 dev->mt76.vif_mask |= BIT_ULL(mvif->mt76.idx);
223 phy->omac_mask |= BIT_ULL(mvif->mt76.omac_idx);
225 idx = MT7915_WTBL_RESERVED - mvif->mt76.idx;
227 INIT_LIST_HEAD(&mvif->sta.rc_list);
228 INIT_LIST_HEAD(&mvif->sta.poll_list);
229 mvif->sta.wcid.idx = idx;
230 mvif->sta.wcid.ext_phy = ext_phy;
231 mvif->sta.wcid.hw_key_idx = -1;
232 mvif->sta.wcid.tx_info |= MT_WCID_TX_INFO_SET;
233 mt76_packet_id_init(&mvif->sta.wcid);
235 mt7915_mac_wtbl_update(dev, idx,
236 MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
238 rcu_assign_pointer(dev->mt76.wcid[idx], &mvif->sta.wcid);
240 mtxq = (struct mt76_txq *)vif->txq->drv_priv;
244 if (vif->type != NL80211_IFTYPE_AP &&
245 (!mvif->mt76.omac_idx || mvif->mt76.omac_idx > 3))
246 vif->offload_flags = 0;
247 vif->offload_flags |= IEEE80211_OFFLOAD_ENCAP_4ADDR;
249 mt7915_init_bitrate_mask(vif);
250 memset(&mvif->cap, -1, sizeof(mvif->cap));
252 mt7915_mcu_add_bss_info(phy, vif, true);
253 mt7915_mcu_add_sta(dev, vif, NULL, true);
256 mutex_unlock(&dev->mt76.mutex);
261 static void mt7915_remove_interface(struct ieee80211_hw *hw,
262 struct ieee80211_vif *vif)
264 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
265 struct mt7915_sta *msta = &mvif->sta;
266 struct mt7915_dev *dev = mt7915_hw_dev(hw);
267 struct mt7915_phy *phy = mt7915_hw_phy(hw);
268 int idx = msta->wcid.idx;
270 mt7915_mcu_add_bss_info(phy, vif, false);
271 mt7915_mcu_add_sta(dev, vif, NULL, false);
273 mutex_lock(&dev->mt76.mutex);
274 mt76_testmode_reset(phy->mt76, true);
275 mutex_unlock(&dev->mt76.mutex);
277 if (vif == phy->monitor_vif)
278 phy->monitor_vif = NULL;
280 mt7915_mcu_add_dev_info(phy, vif, false);
282 rcu_assign_pointer(dev->mt76.wcid[idx], NULL);
284 mutex_lock(&dev->mt76.mutex);
285 dev->mt76.vif_mask &= ~BIT_ULL(mvif->mt76.idx);
286 phy->omac_mask &= ~BIT_ULL(mvif->mt76.omac_idx);
287 mutex_unlock(&dev->mt76.mutex);
289 spin_lock_bh(&dev->sta_poll_lock);
290 if (!list_empty(&msta->poll_list))
291 list_del_init(&msta->poll_list);
292 spin_unlock_bh(&dev->sta_poll_lock);
294 mt76_packet_id_flush(&dev->mt76, &msta->wcid);
297 int mt7915_set_channel(struct mt7915_phy *phy)
299 struct mt7915_dev *dev = phy->dev;
302 cancel_delayed_work_sync(&phy->mt76->mac_work);
304 mutex_lock(&dev->mt76.mutex);
305 set_bit(MT76_RESET, &phy->mt76->state);
307 mt76_set_channel(phy->mt76);
309 if (dev->flash_mode) {
310 ret = mt7915_mcu_apply_tx_dpd(phy);
315 ret = mt7915_mcu_set_chan_info(phy, MCU_EXT_CMD(CHANNEL_SWITCH));
319 mt7915_mac_set_timing(phy);
320 ret = mt7915_dfs_init_radar_detector(phy);
321 mt7915_mac_cca_stats_reset(phy);
323 mt7915_mac_reset_counters(phy);
327 clear_bit(MT76_RESET, &phy->mt76->state);
328 mutex_unlock(&dev->mt76.mutex);
330 mt76_txq_schedule_all(phy->mt76);
332 if (!mt76_testmode_enabled(phy->mt76))
333 ieee80211_queue_delayed_work(phy->mt76->hw,
334 &phy->mt76->mac_work,
335 MT7915_WATCHDOG_TIME);
340 static int mt7915_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
341 struct ieee80211_vif *vif, struct ieee80211_sta *sta,
342 struct ieee80211_key_conf *key)
344 struct mt7915_dev *dev = mt7915_hw_dev(hw);
345 struct mt7915_phy *phy = mt7915_hw_phy(hw);
346 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
347 struct mt7915_sta *msta = sta ? (struct mt7915_sta *)sta->drv_priv :
349 struct mt76_wcid *wcid = &msta->wcid;
350 u8 *wcid_keyidx = &wcid->hw_key_idx;
351 int idx = key->keyidx;
354 /* The hardware does not support per-STA RX GTK, fallback
355 * to software mode for these.
357 if ((vif->type == NL80211_IFTYPE_ADHOC ||
358 vif->type == NL80211_IFTYPE_MESH_POINT) &&
359 (key->cipher == WLAN_CIPHER_SUITE_TKIP ||
360 key->cipher == WLAN_CIPHER_SUITE_CCMP) &&
361 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE))
364 /* fall back to sw encryption for unsupported ciphers */
365 switch (key->cipher) {
366 case WLAN_CIPHER_SUITE_AES_CMAC:
367 wcid_keyidx = &wcid->hw_key_idx2;
368 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIE;
370 case WLAN_CIPHER_SUITE_TKIP:
371 case WLAN_CIPHER_SUITE_CCMP:
372 case WLAN_CIPHER_SUITE_CCMP_256:
373 case WLAN_CIPHER_SUITE_GCMP:
374 case WLAN_CIPHER_SUITE_GCMP_256:
375 case WLAN_CIPHER_SUITE_SMS4:
377 case WLAN_CIPHER_SUITE_WEP40:
378 case WLAN_CIPHER_SUITE_WEP104:
383 mutex_lock(&dev->mt76.mutex);
385 if (cmd == SET_KEY && !sta && !mvif->mt76.cipher) {
386 mvif->mt76.cipher = mt76_connac_mcu_get_cipher(key->cipher);
387 mt7915_mcu_add_bss_info(phy, vif, true);
392 else if (idx == *wcid_keyidx)
397 mt76_wcid_key_setup(&dev->mt76, wcid,
398 cmd == SET_KEY ? key : NULL);
400 err = mt76_connac_mcu_add_key(&dev->mt76, vif, &msta->bip,
401 key, MCU_EXT_CMD(STA_REC_UPDATE),
404 mutex_unlock(&dev->mt76.mutex);
409 static int mt7915_set_sar_specs(struct ieee80211_hw *hw,
410 const struct cfg80211_sar_specs *sar)
412 struct mt7915_phy *phy = mt7915_hw_phy(hw);
413 struct mt7915_dev *dev = mt7915_hw_dev(hw);
416 mutex_lock(&dev->mt76.mutex);
417 if (!cfg80211_chandef_valid(&phy->mt76->chandef))
420 err = mt76_init_sar_power(hw, sar);
424 err = mt7915_mcu_set_txpower_sku(phy);
426 mutex_unlock(&dev->mt76.mutex);
431 static int mt7915_config(struct ieee80211_hw *hw, u32 changed)
433 struct mt7915_dev *dev = mt7915_hw_dev(hw);
434 struct mt7915_phy *phy = mt7915_hw_phy(hw);
435 bool band = phy != &dev->phy;
438 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
439 #ifdef CONFIG_NL80211_TESTMODE
440 if (phy->mt76->test.state != MT76_TM_STATE_OFF) {
441 mutex_lock(&dev->mt76.mutex);
442 mt76_testmode_reset(phy->mt76, false);
443 mutex_unlock(&dev->mt76.mutex);
446 ieee80211_stop_queues(hw);
447 ret = mt7915_set_channel(phy);
450 ieee80211_wake_queues(hw);
453 if (changed & IEEE80211_CONF_CHANGE_POWER) {
454 ret = mt7915_mcu_set_txpower_sku(phy);
459 mutex_lock(&dev->mt76.mutex);
461 if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
462 bool enabled = !!(hw->conf.flags & IEEE80211_CONF_MONITOR);
465 phy->rxfilter |= MT_WF_RFCR_DROP_OTHER_UC;
467 phy->rxfilter &= ~MT_WF_RFCR_DROP_OTHER_UC;
469 mt76_rmw_field(dev, MT_DMA_DCR0(band), MT_DMA_DCR0_RXD_G5_EN,
471 mt76_testmode_reset(phy->mt76, true);
472 mt76_wr(dev, MT_WF_RFCR(band), phy->rxfilter);
475 mutex_unlock(&dev->mt76.mutex);
481 mt7915_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue,
482 const struct ieee80211_tx_queue_params *params)
484 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
486 /* no need to update right away, we'll get BSS_CHANGED_QOS */
487 queue = mt76_connac_lmac_mapping(queue);
488 mvif->queue_params[queue] = *params;
493 static void mt7915_configure_filter(struct ieee80211_hw *hw,
494 unsigned int changed_flags,
495 unsigned int *total_flags,
498 struct mt7915_dev *dev = mt7915_hw_dev(hw);
499 struct mt7915_phy *phy = mt7915_hw_phy(hw);
500 bool band = phy != &dev->phy;
501 u32 ctl_flags = MT_WF_RFCR1_DROP_ACK |
502 MT_WF_RFCR1_DROP_BF_POLL |
503 MT_WF_RFCR1_DROP_BA |
504 MT_WF_RFCR1_DROP_CFEND |
505 MT_WF_RFCR1_DROP_CFACK;
508 #define MT76_FILTER(_flag, _hw) do { \
509 flags |= *total_flags & FIF_##_flag; \
510 phy->rxfilter &= ~(_hw); \
511 phy->rxfilter |= !(flags & FIF_##_flag) * (_hw); \
514 mutex_lock(&dev->mt76.mutex);
516 phy->rxfilter &= ~(MT_WF_RFCR_DROP_OTHER_BSS |
517 MT_WF_RFCR_DROP_OTHER_BEACON |
518 MT_WF_RFCR_DROP_FRAME_REPORT |
519 MT_WF_RFCR_DROP_PROBEREQ |
520 MT_WF_RFCR_DROP_MCAST_FILTERED |
521 MT_WF_RFCR_DROP_MCAST |
522 MT_WF_RFCR_DROP_BCAST |
523 MT_WF_RFCR_DROP_DUPLICATE |
524 MT_WF_RFCR_DROP_A2_BSSID |
525 MT_WF_RFCR_DROP_UNWANTED_CTL |
526 MT_WF_RFCR_DROP_STBC_MULTI);
528 MT76_FILTER(OTHER_BSS, MT_WF_RFCR_DROP_OTHER_TIM |
529 MT_WF_RFCR_DROP_A3_MAC |
530 MT_WF_RFCR_DROP_A3_BSSID);
532 MT76_FILTER(FCSFAIL, MT_WF_RFCR_DROP_FCSFAIL);
534 MT76_FILTER(CONTROL, MT_WF_RFCR_DROP_CTS |
535 MT_WF_RFCR_DROP_RTS |
536 MT_WF_RFCR_DROP_CTL_RSV |
537 MT_WF_RFCR_DROP_NDPA);
539 *total_flags = flags;
540 mt76_wr(dev, MT_WF_RFCR(band), phy->rxfilter);
542 if (*total_flags & FIF_CONTROL)
543 mt76_clear(dev, MT_WF_RFCR1(band), ctl_flags);
545 mt76_set(dev, MT_WF_RFCR1(band), ctl_flags);
547 mutex_unlock(&dev->mt76.mutex);
551 mt7915_update_bss_color(struct ieee80211_hw *hw,
552 struct ieee80211_vif *vif,
553 struct cfg80211_he_bss_color *bss_color)
555 struct mt7915_dev *dev = mt7915_hw_dev(hw);
558 case NL80211_IFTYPE_AP: {
559 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
561 if (mvif->mt76.omac_idx > HW_BSSID_MAX)
565 case NL80211_IFTYPE_STATION:
566 mt7915_mcu_update_bss_color(dev, vif, bss_color);
573 static void mt7915_bss_info_changed(struct ieee80211_hw *hw,
574 struct ieee80211_vif *vif,
575 struct ieee80211_bss_conf *info,
578 struct mt7915_phy *phy = mt7915_hw_phy(hw);
579 struct mt7915_dev *dev = mt7915_hw_dev(hw);
581 mutex_lock(&dev->mt76.mutex);
584 * station mode uses BSSID to map the wlan entry to a peer,
585 * and then peer references bss_info_rfch to set bandwidth cap.
587 if (changed & BSS_CHANGED_BSSID &&
588 vif->type == NL80211_IFTYPE_STATION) {
589 bool join = !is_zero_ether_addr(info->bssid);
591 mt7915_mcu_add_bss_info(phy, vif, join);
592 mt7915_mcu_add_sta(dev, vif, NULL, join);
595 if (changed & BSS_CHANGED_ASSOC) {
596 mt7915_mcu_add_bss_info(phy, vif, info->assoc);
597 mt7915_mcu_add_obss_spr(dev, vif, info->he_obss_pd.enable);
600 if (changed & BSS_CHANGED_ERP_SLOT) {
601 int slottime = info->use_short_slot ? 9 : 20;
603 if (slottime != phy->slottime) {
604 phy->slottime = slottime;
605 mt7915_mac_set_timing(phy);
609 if (changed & BSS_CHANGED_BEACON_ENABLED && info->enable_beacon) {
610 mt7915_mcu_add_bss_info(phy, vif, true);
611 mt7915_mcu_add_sta(dev, vif, NULL, true);
614 /* ensure that enable txcmd_mode after bss_info */
615 if (changed & (BSS_CHANGED_QOS | BSS_CHANGED_BEACON_ENABLED))
616 mt7915_mcu_set_tx(dev, vif);
618 if (changed & BSS_CHANGED_HE_OBSS_PD)
619 mt7915_mcu_add_obss_spr(dev, vif, info->he_obss_pd.enable);
621 if (changed & BSS_CHANGED_HE_BSS_COLOR)
622 mt7915_update_bss_color(hw, vif, &info->he_bss_color);
624 if (changed & (BSS_CHANGED_BEACON |
625 BSS_CHANGED_BEACON_ENABLED |
626 BSS_CHANGED_UNSOL_BCAST_PROBE_RESP |
627 BSS_CHANGED_FILS_DISCOVERY))
628 mt7915_mcu_add_beacon(hw, vif, info->enable_beacon, changed);
630 mutex_unlock(&dev->mt76.mutex);
634 mt7915_channel_switch_beacon(struct ieee80211_hw *hw,
635 struct ieee80211_vif *vif,
636 struct cfg80211_chan_def *chandef)
638 struct mt7915_dev *dev = mt7915_hw_dev(hw);
640 mutex_lock(&dev->mt76.mutex);
641 mt7915_mcu_add_beacon(hw, vif, true, BSS_CHANGED_BEACON);
642 mutex_unlock(&dev->mt76.mutex);
645 int mt7915_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
646 struct ieee80211_sta *sta)
648 struct mt7915_dev *dev = container_of(mdev, struct mt7915_dev, mt76);
649 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
650 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
651 bool ext_phy = mvif->phy != &dev->phy;
654 idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7915_WTBL_STA);
658 INIT_LIST_HEAD(&msta->rc_list);
659 INIT_LIST_HEAD(&msta->poll_list);
662 msta->wcid.idx = idx;
663 msta->wcid.ext_phy = ext_phy;
664 msta->wcid.tx_info |= MT_WCID_TX_INFO_SET;
665 msta->jiffies = jiffies;
667 mt7915_mac_wtbl_update(dev, idx,
668 MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
670 ret = mt7915_mcu_add_sta(dev, vif, sta, true);
674 return mt7915_mcu_add_rate_ctrl(dev, vif, sta, false);
677 void mt7915_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
678 struct ieee80211_sta *sta)
680 struct mt7915_dev *dev = container_of(mdev, struct mt7915_dev, mt76);
681 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
684 mt7915_mcu_add_sta(dev, vif, sta, false);
686 mt7915_mac_wtbl_update(dev, msta->wcid.idx,
687 MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
689 for (i = 0; i < ARRAY_SIZE(msta->twt.flow); i++)
690 mt7915_mac_twt_teardown_flow(dev, msta, i);
692 spin_lock_bh(&dev->sta_poll_lock);
693 if (!list_empty(&msta->poll_list))
694 list_del_init(&msta->poll_list);
695 if (!list_empty(&msta->rc_list))
696 list_del_init(&msta->rc_list);
697 spin_unlock_bh(&dev->sta_poll_lock);
700 static void mt7915_tx(struct ieee80211_hw *hw,
701 struct ieee80211_tx_control *control,
704 struct mt7915_dev *dev = mt7915_hw_dev(hw);
705 struct mt76_phy *mphy = hw->priv;
706 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
707 struct ieee80211_vif *vif = info->control.vif;
708 struct mt76_wcid *wcid = &dev->mt76.global_wcid;
711 struct mt7915_sta *sta;
713 sta = (struct mt7915_sta *)control->sta->drv_priv;
717 if (vif && !control->sta) {
718 struct mt7915_vif *mvif;
720 mvif = (struct mt7915_vif *)vif->drv_priv;
721 wcid = &mvif->sta.wcid;
724 mt76_tx(mphy, control->sta, wcid, skb);
727 static int mt7915_set_rts_threshold(struct ieee80211_hw *hw, u32 val)
729 struct mt7915_dev *dev = mt7915_hw_dev(hw);
730 struct mt7915_phy *phy = mt7915_hw_phy(hw);
733 mutex_lock(&dev->mt76.mutex);
734 ret = mt76_connac_mcu_set_rts_thresh(&dev->mt76, val, phy != &dev->phy);
735 mutex_unlock(&dev->mt76.mutex);
741 mt7915_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
742 struct ieee80211_ampdu_params *params)
744 enum ieee80211_ampdu_mlme_action action = params->action;
745 struct mt7915_dev *dev = mt7915_hw_dev(hw);
746 struct ieee80211_sta *sta = params->sta;
747 struct ieee80211_txq *txq = sta->txq[params->tid];
748 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
749 u16 tid = params->tid;
750 u16 ssn = params->ssn;
751 struct mt76_txq *mtxq;
757 mtxq = (struct mt76_txq *)txq->drv_priv;
759 mutex_lock(&dev->mt76.mutex);
761 case IEEE80211_AMPDU_RX_START:
762 mt76_rx_aggr_start(&dev->mt76, &msta->wcid, tid, ssn,
764 ret = mt7915_mcu_add_rx_ba(dev, params, true);
766 case IEEE80211_AMPDU_RX_STOP:
767 mt76_rx_aggr_stop(&dev->mt76, &msta->wcid, tid);
768 ret = mt7915_mcu_add_rx_ba(dev, params, false);
770 case IEEE80211_AMPDU_TX_OPERATIONAL:
772 mtxq->send_bar = false;
773 ret = mt7915_mcu_add_tx_ba(dev, params, true);
775 case IEEE80211_AMPDU_TX_STOP_FLUSH:
776 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
778 clear_bit(tid, &msta->ampdu_state);
779 ret = mt7915_mcu_add_tx_ba(dev, params, false);
781 case IEEE80211_AMPDU_TX_START:
782 set_bit(tid, &msta->ampdu_state);
783 ret = IEEE80211_AMPDU_TX_START_IMMEDIATE;
785 case IEEE80211_AMPDU_TX_STOP_CONT:
787 clear_bit(tid, &msta->ampdu_state);
788 ret = mt7915_mcu_add_tx_ba(dev, params, false);
789 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
792 mutex_unlock(&dev->mt76.mutex);
798 mt7915_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
799 struct ieee80211_sta *sta)
801 return mt76_sta_state(hw, vif, sta, IEEE80211_STA_NOTEXIST,
806 mt7915_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
807 struct ieee80211_sta *sta)
809 return mt76_sta_state(hw, vif, sta, IEEE80211_STA_NONE,
810 IEEE80211_STA_NOTEXIST);
814 mt7915_get_stats(struct ieee80211_hw *hw,
815 struct ieee80211_low_level_stats *stats)
817 struct mt7915_phy *phy = mt7915_hw_phy(hw);
818 struct mt7915_dev *dev = mt7915_hw_dev(hw);
819 struct mib_stats *mib = &phy->mib;
821 mutex_lock(&dev->mt76.mutex);
823 stats->dot11RTSSuccessCount = mib->rts_cnt;
824 stats->dot11RTSFailureCount = mib->rts_retries_cnt;
825 stats->dot11FCSErrorCount = mib->fcs_err_cnt;
826 stats->dot11ACKFailureCount = mib->ack_fail_cnt;
828 mutex_unlock(&dev->mt76.mutex);
833 u64 __mt7915_get_tsf(struct ieee80211_hw *hw, struct mt7915_vif *mvif)
835 struct mt7915_dev *dev = mt7915_hw_dev(hw);
836 struct mt7915_phy *phy = mt7915_hw_phy(hw);
837 bool band = phy != &dev->phy;
844 lockdep_assert_held(&dev->mt76.mutex);
846 n = mvif->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0
847 : mvif->mt76.omac_idx;
848 /* TSF software read */
849 if (is_mt7915(&dev->mt76))
850 mt76_rmw(dev, MT_LPON_TCR(band, n), MT_LPON_TCR_SW_MODE,
851 MT_LPON_TCR_SW_READ);
853 mt76_rmw(dev, MT_LPON_TCR_MT7916(band, n), MT_LPON_TCR_SW_MODE,
854 MT_LPON_TCR_SW_READ);
855 tsf.t32[0] = mt76_rr(dev, MT_LPON_UTTR0(band));
856 tsf.t32[1] = mt76_rr(dev, MT_LPON_UTTR1(band));
862 mt7915_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
864 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
865 struct mt7915_dev *dev = mt7915_hw_dev(hw);
868 mutex_lock(&dev->mt76.mutex);
869 ret = __mt7915_get_tsf(hw, mvif);
870 mutex_unlock(&dev->mt76.mutex);
876 mt7915_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
879 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
880 struct mt7915_dev *dev = mt7915_hw_dev(hw);
881 struct mt7915_phy *phy = mt7915_hw_phy(hw);
882 bool band = phy != &dev->phy;
886 } tsf = { .t64 = timestamp, };
889 mutex_lock(&dev->mt76.mutex);
891 n = mvif->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0
892 : mvif->mt76.omac_idx;
893 mt76_wr(dev, MT_LPON_UTTR0(band), tsf.t32[0]);
894 mt76_wr(dev, MT_LPON_UTTR1(band), tsf.t32[1]);
895 /* TSF software overwrite */
896 if (is_mt7915(&dev->mt76))
897 mt76_rmw(dev, MT_LPON_TCR(band, n), MT_LPON_TCR_SW_MODE,
898 MT_LPON_TCR_SW_WRITE);
900 mt76_rmw(dev, MT_LPON_TCR_MT7916(band, n), MT_LPON_TCR_SW_MODE,
901 MT_LPON_TCR_SW_WRITE);
903 mutex_unlock(&dev->mt76.mutex);
907 mt7915_offset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
910 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
911 struct mt7915_dev *dev = mt7915_hw_dev(hw);
912 struct mt7915_phy *phy = mt7915_hw_phy(hw);
913 bool band = phy != &dev->phy;
917 } tsf = { .t64 = timestamp, };
920 mutex_lock(&dev->mt76.mutex);
922 n = mvif->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0
923 : mvif->mt76.omac_idx;
924 mt76_wr(dev, MT_LPON_UTTR0(band), tsf.t32[0]);
925 mt76_wr(dev, MT_LPON_UTTR1(band), tsf.t32[1]);
926 /* TSF software adjust*/
927 if (is_mt7915(&dev->mt76))
928 mt76_rmw(dev, MT_LPON_TCR(band, n), MT_LPON_TCR_SW_MODE,
929 MT_LPON_TCR_SW_ADJUST);
931 mt76_rmw(dev, MT_LPON_TCR_MT7916(band, n), MT_LPON_TCR_SW_MODE,
932 MT_LPON_TCR_SW_ADJUST);
934 mutex_unlock(&dev->mt76.mutex);
938 mt7915_set_coverage_class(struct ieee80211_hw *hw, s16 coverage_class)
940 struct mt7915_phy *phy = mt7915_hw_phy(hw);
941 struct mt7915_dev *dev = phy->dev;
943 mutex_lock(&dev->mt76.mutex);
944 phy->coverage_class = max_t(s16, coverage_class, 0);
945 mt7915_mac_set_timing(phy);
946 mutex_unlock(&dev->mt76.mutex);
950 mt7915_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
952 struct mt7915_dev *dev = mt7915_hw_dev(hw);
953 struct mt7915_phy *phy = mt7915_hw_phy(hw);
954 int max_nss = hweight8(hw->wiphy->available_antennas_tx);
955 bool ext_phy = phy != &dev->phy;
957 if (!tx_ant || tx_ant != rx_ant || ffs(tx_ant) > max_nss)
960 if ((BIT(hweight8(tx_ant)) - 1) != tx_ant)
961 tx_ant = BIT(ffs(tx_ant) - 1) - 1;
963 mutex_lock(&dev->mt76.mutex);
965 phy->mt76->antenna_mask = tx_ant;
968 tx_ant <<= dev->chainshift;
970 phy->mt76->chainmask = tx_ant;
972 mt76_set_stream_caps(phy->mt76, true);
973 mt7915_set_stream_vht_txbf_caps(phy);
974 mt7915_set_stream_he_caps(phy);
976 mutex_unlock(&dev->mt76.mutex);
981 static void mt7915_sta_statistics(struct ieee80211_hw *hw,
982 struct ieee80211_vif *vif,
983 struct ieee80211_sta *sta,
984 struct station_info *sinfo)
986 struct mt7915_phy *phy = mt7915_hw_phy(hw);
987 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
988 struct rate_info *txrate = &msta->wcid.rate;
989 struct rate_info rxrate = {};
991 if (is_mt7915(&phy->dev->mt76) &&
992 !mt7915_mcu_get_rx_rate(phy, vif, sta, &rxrate)) {
993 sinfo->rxrate = rxrate;
994 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BITRATE);
997 if (!txrate->legacy && !txrate->flags)
1000 if (txrate->legacy) {
1001 sinfo->txrate.legacy = txrate->legacy;
1003 sinfo->txrate.mcs = txrate->mcs;
1004 sinfo->txrate.nss = txrate->nss;
1005 sinfo->txrate.bw = txrate->bw;
1006 sinfo->txrate.he_gi = txrate->he_gi;
1007 sinfo->txrate.he_dcm = txrate->he_dcm;
1008 sinfo->txrate.he_ru_alloc = txrate->he_ru_alloc;
1010 sinfo->txrate.flags = txrate->flags;
1011 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE);
1014 static void mt7915_sta_rc_work(void *data, struct ieee80211_sta *sta)
1016 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
1017 struct mt7915_dev *dev = msta->vif->phy->dev;
1018 u32 *changed = data;
1020 spin_lock_bh(&dev->sta_poll_lock);
1021 msta->changed |= *changed;
1022 if (list_empty(&msta->rc_list))
1023 list_add_tail(&msta->rc_list, &dev->sta_rc_list);
1024 spin_unlock_bh(&dev->sta_poll_lock);
1027 static void mt7915_sta_rc_update(struct ieee80211_hw *hw,
1028 struct ieee80211_vif *vif,
1029 struct ieee80211_sta *sta,
1032 struct mt7915_phy *phy = mt7915_hw_phy(hw);
1033 struct mt7915_dev *dev = phy->dev;
1035 mt7915_sta_rc_work(&changed, sta);
1036 ieee80211_queue_work(hw, &dev->rc_work);
1040 mt7915_set_bitrate_mask(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1041 const struct cfg80211_bitrate_mask *mask)
1043 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
1044 struct mt7915_phy *phy = mt7915_hw_phy(hw);
1045 struct mt7915_dev *dev = phy->dev;
1046 u32 changed = IEEE80211_RC_SUPP_RATES_CHANGED;
1048 mvif->bitrate_mask = *mask;
1050 /* if multiple rates across different preambles are given we can
1051 * reconfigure this info with all peers using sta_rec command with
1052 * the below exception cases.
1053 * - single rate : if a rate is passed along with different preambles,
1054 * we select the highest one as fixed rate. i.e VHT MCS for VHT peers.
1055 * - multiple rates: if it's not in range format i.e 0-{7,8,9} for VHT
1056 * then multiple MCS setting (MCS 4,5,6) is not supported.
1058 ieee80211_iterate_stations_atomic(hw, mt7915_sta_rc_work, &changed);
1059 ieee80211_queue_work(hw, &dev->rc_work);
1064 static void mt7915_sta_set_4addr(struct ieee80211_hw *hw,
1065 struct ieee80211_vif *vif,
1066 struct ieee80211_sta *sta,
1069 struct mt7915_dev *dev = mt7915_hw_dev(hw);
1070 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
1073 set_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags);
1075 clear_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags);
1077 mt76_connac_mcu_wtbl_update_hdr_trans(&dev->mt76, vif, sta);
1080 static void mt7915_sta_set_decap_offload(struct ieee80211_hw *hw,
1081 struct ieee80211_vif *vif,
1082 struct ieee80211_sta *sta,
1085 struct mt7915_dev *dev = mt7915_hw_dev(hw);
1086 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
1089 set_bit(MT_WCID_FLAG_HDR_TRANS, &msta->wcid.flags);
1091 clear_bit(MT_WCID_FLAG_HDR_TRANS, &msta->wcid.flags);
1093 mt76_connac_mcu_wtbl_update_hdr_trans(&dev->mt76, vif, sta);
1096 static const char mt7915_gstrings_stats[][ETH_GSTRING_LEN] = {
1098 "tx_stop_q_empty_cnt",
1106 "tx_ampdu_len:2-10",
1107 "tx_ampdu_len:11-19",
1108 "tx_ampdu_len:20-28",
1109 "tx_ampdu_len:29-37",
1110 "tx_ampdu_len:38-46",
1111 "tx_ampdu_len:47-55",
1112 "tx_ampdu_len:56-79",
1113 "tx_ampdu_len:80-103",
1114 "tx_ampdu_len:104-127",
1115 "tx_ampdu_len:128-151",
1116 "tx_ampdu_len:152-175",
1117 "tx_ampdu_len:176-199",
1118 "tx_ampdu_len:200-223",
1119 "tx_ampdu_len:224-247",
1121 "tx_beamformer_ppdu_iBF",
1122 "tx_beamformer_ppdu_eBF",
1123 "tx_beamformer_rx_feedback_all",
1124 "tx_beamformer_rx_feedback_he",
1125 "tx_beamformer_rx_feedback_vht",
1126 "tx_beamformer_rx_feedback_ht",
1127 "tx_beamformer_rx_feedback_bw", /* zero based idx: 20, 40, 80, 160 */
1128 "tx_beamformer_rx_feedback_nc",
1129 "tx_beamformer_rx_feedback_nr",
1130 "tx_beamformee_ok_feedback_pkts",
1131 "tx_beamformee_feedback_trig",
1132 "tx_mu_beamforming",
1134 "tx_mu_successful_mpdu",
1135 "tx_su_successful_mpdu",
1149 "rx_vector_mismatch_cnt",
1150 "rx_delimiter_fail_cnt",
1151 "rx_len_mismatch_cnt",
1153 "rx_ampdu_bytes_cnt",
1154 "rx_ampdu_valid_subframe_cnt",
1155 "rx_ampdu_valid_subframe_b_cnt",
1157 "rx_vec_queue_overflow_drop_cnt",
1160 /* per vif counters */
1167 "v_tx_mode_he_ext_su",
1188 #define MT7915_SSTATS_LEN ARRAY_SIZE(mt7915_gstrings_stats)
1190 /* Ethtool related API */
1192 void mt7915_get_et_strings(struct ieee80211_hw *hw,
1193 struct ieee80211_vif *vif,
1196 if (sset == ETH_SS_STATS)
1197 memcpy(data, *mt7915_gstrings_stats,
1198 sizeof(mt7915_gstrings_stats));
1202 int mt7915_get_et_sset_count(struct ieee80211_hw *hw,
1203 struct ieee80211_vif *vif, int sset)
1205 if (sset == ETH_SS_STATS)
1206 return MT7915_SSTATS_LEN;
1211 static void mt7915_ethtool_worker(void *wi_data, struct ieee80211_sta *sta)
1213 struct mt76_ethtool_worker_info *wi = wi_data;
1214 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
1216 if (msta->vif->mt76.idx != wi->idx)
1219 mt76_ethtool_worker(wi, &msta->stats);
1223 void mt7915_get_et_stats(struct ieee80211_hw *hw,
1224 struct ieee80211_vif *vif,
1225 struct ethtool_stats *stats, u64 *data)
1227 struct mt7915_dev *dev = mt7915_hw_dev(hw);
1228 struct mt7915_phy *phy = mt7915_hw_phy(hw);
1229 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
1230 struct mt76_ethtool_worker_info wi = {
1232 .idx = mvif->mt76.idx,
1234 struct mib_stats *mib = &phy->mib;
1235 /* See mt7915_ampdu_stat_read_phy, etc */
1238 mutex_lock(&dev->mt76.mutex);
1240 mt7915_mac_update_stats(phy);
1242 data[ei++] = mib->tx_ampdu_cnt;
1243 data[ei++] = mib->tx_stop_q_empty_cnt;
1244 data[ei++] = mib->tx_mpdu_attempts_cnt;
1245 data[ei++] = mib->tx_mpdu_success_cnt;
1246 data[ei++] = mib->tx_rwp_fail_cnt;
1247 data[ei++] = mib->tx_rwp_need_cnt;
1248 data[ei++] = mib->tx_pkt_ebf_cnt;
1249 data[ei++] = mib->tx_pkt_ibf_cnt;
1252 n = phy->band_idx ? ARRAY_SIZE(dev->mt76.aggr_stats) / 2 : 0;
1253 for (i = 0; i < 15 /*ARRAY_SIZE(bound)*/; i++)
1254 data[ei++] = dev->mt76.aggr_stats[i + n];
1256 data[ei++] = phy->mib.ba_miss_cnt;
1258 /* Tx Beamformer monitor */
1259 data[ei++] = mib->tx_bf_ibf_ppdu_cnt;
1260 data[ei++] = mib->tx_bf_ebf_ppdu_cnt;
1262 /* Tx Beamformer Rx feedback monitor */
1263 data[ei++] = mib->tx_bf_rx_fb_all_cnt;
1264 data[ei++] = mib->tx_bf_rx_fb_he_cnt;
1265 data[ei++] = mib->tx_bf_rx_fb_vht_cnt;
1266 data[ei++] = mib->tx_bf_rx_fb_ht_cnt;
1268 data[ei++] = mib->tx_bf_rx_fb_bw;
1269 data[ei++] = mib->tx_bf_rx_fb_nc_cnt;
1270 data[ei++] = mib->tx_bf_rx_fb_nr_cnt;
1272 /* Tx Beamformee Rx NDPA & Tx feedback report */
1273 data[ei++] = mib->tx_bf_fb_cpl_cnt;
1274 data[ei++] = mib->tx_bf_fb_trig_cnt;
1276 /* Tx SU & MU counters */
1277 data[ei++] = mib->tx_bf_cnt;
1278 data[ei++] = mib->tx_mu_mpdu_cnt;
1279 data[ei++] = mib->tx_mu_acked_mpdu_cnt;
1280 data[ei++] = mib->tx_su_acked_mpdu_cnt;
1282 /* Tx amsdu info (pack-count histogram) */
1283 for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++)
1284 data[ei++] = mib->tx_amsdu[i];
1287 data[ei++] = mib->rx_fifo_full_cnt;
1288 data[ei++] = mib->rx_mpdu_cnt;
1289 data[ei++] = mib->channel_idle_cnt;
1290 data[ei++] = mib->rx_vector_mismatch_cnt;
1291 data[ei++] = mib->rx_delimiter_fail_cnt;
1292 data[ei++] = mib->rx_len_mismatch_cnt;
1293 data[ei++] = mib->rx_ampdu_cnt;
1294 data[ei++] = mib->rx_ampdu_bytes_cnt;
1295 data[ei++] = mib->rx_ampdu_valid_subframe_cnt;
1296 data[ei++] = mib->rx_ampdu_valid_subframe_bytes_cnt;
1297 data[ei++] = mib->rx_pfdrop_cnt;
1298 data[ei++] = mib->rx_vec_queue_overflow_drop_cnt;
1299 data[ei++] = mib->rx_ba_cnt;
1301 /* Add values for all stations owned by this vif */
1302 wi.initial_stat_idx = ei;
1303 ieee80211_iterate_stations_atomic(hw, mt7915_ethtool_worker, &wi);
1305 mutex_unlock(&dev->mt76.mutex);
1307 if (wi.sta_count == 0)
1310 ei += wi.worker_stat_count;
1311 if (ei != MT7915_SSTATS_LEN)
1312 dev_err(dev->mt76.dev, "ei: %d MT7915_SSTATS_LEN: %d",
1313 ei, (int)MT7915_SSTATS_LEN);
1317 mt7915_twt_teardown_request(struct ieee80211_hw *hw,
1318 struct ieee80211_sta *sta,
1321 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
1322 struct mt7915_dev *dev = mt7915_hw_dev(hw);
1324 mutex_lock(&dev->mt76.mutex);
1325 mt7915_mac_twt_teardown_flow(dev, msta, flowid);
1326 mutex_unlock(&dev->mt76.mutex);
1330 mt7915_set_radar_background(struct ieee80211_hw *hw,
1331 struct cfg80211_chan_def *chandef)
1333 struct mt7915_phy *phy = mt7915_hw_phy(hw);
1334 struct mt7915_dev *dev = phy->dev;
1338 mutex_lock(&dev->mt76.mutex);
1340 if (dev->mt76.region == NL80211_DFS_UNSET)
1343 if (dev->rdd2_phy && dev->rdd2_phy != phy) {
1344 /* rdd2 is already locked */
1349 /* rdd2 already configured on a radar channel */
1350 running = dev->rdd2_phy &&
1351 cfg80211_chandef_valid(&dev->rdd2_chandef) &&
1352 !!(dev->rdd2_chandef.chan->flags & IEEE80211_CHAN_RADAR);
1354 if (!chandef || running ||
1355 !(chandef->chan->flags & IEEE80211_CHAN_RADAR)) {
1356 ret = mt7915_mcu_rdd_background_enable(phy, NULL);
1364 ret = mt7915_mcu_rdd_background_enable(phy, chandef);
1369 dev->rdd2_phy = chandef ? phy : NULL;
1371 dev->rdd2_chandef = *chandef;
1373 mutex_unlock(&dev->mt76.mutex);
1378 #ifdef CONFIG_NET_MEDIATEK_SOC_WED
1380 mt7915_net_fill_forward_path(struct ieee80211_hw *hw,
1381 struct ieee80211_vif *vif,
1382 struct ieee80211_sta *sta,
1383 struct net_device_path_ctx *ctx,
1384 struct net_device_path *path)
1386 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
1387 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
1388 struct mt7915_dev *dev = mt7915_hw_dev(hw);
1389 struct mt7915_phy *phy = mt7915_hw_phy(hw);
1390 struct mtk_wed_device *wed = &dev->mt76.mmio.wed;
1392 if (!mtk_wed_device_active(wed))
1395 if (msta->wcid.idx > 0xff)
1398 path->type = DEV_PATH_MTK_WDMA;
1399 path->dev = ctx->dev;
1400 path->mtk_wdma.wdma_idx = wed->wdma_idx;
1401 path->mtk_wdma.bss = mvif->mt76.idx;
1402 path->mtk_wdma.wcid = msta->wcid.idx;
1403 path->mtk_wdma.queue = phy != &dev->phy;
1411 const struct ieee80211_ops mt7915_ops = {
1413 .start = mt7915_start,
1414 .stop = mt7915_stop,
1415 .add_interface = mt7915_add_interface,
1416 .remove_interface = mt7915_remove_interface,
1417 .config = mt7915_config,
1418 .conf_tx = mt7915_conf_tx,
1419 .configure_filter = mt7915_configure_filter,
1420 .bss_info_changed = mt7915_bss_info_changed,
1421 .sta_add = mt7915_sta_add,
1422 .sta_remove = mt7915_sta_remove,
1423 .sta_pre_rcu_remove = mt76_sta_pre_rcu_remove,
1424 .sta_rc_update = mt7915_sta_rc_update,
1425 .set_key = mt7915_set_key,
1426 .ampdu_action = mt7915_ampdu_action,
1427 .set_rts_threshold = mt7915_set_rts_threshold,
1428 .wake_tx_queue = mt76_wake_tx_queue,
1429 .sw_scan_start = mt76_sw_scan,
1430 .sw_scan_complete = mt76_sw_scan_complete,
1431 .release_buffered_frames = mt76_release_buffered_frames,
1432 .get_txpower = mt76_get_txpower,
1433 .set_sar_specs = mt7915_set_sar_specs,
1434 .channel_switch_beacon = mt7915_channel_switch_beacon,
1435 .get_stats = mt7915_get_stats,
1436 .get_et_sset_count = mt7915_get_et_sset_count,
1437 .get_et_stats = mt7915_get_et_stats,
1438 .get_et_strings = mt7915_get_et_strings,
1439 .get_tsf = mt7915_get_tsf,
1440 .set_tsf = mt7915_set_tsf,
1441 .offset_tsf = mt7915_offset_tsf,
1442 .get_survey = mt76_get_survey,
1443 .get_antenna = mt76_get_antenna,
1444 .set_antenna = mt7915_set_antenna,
1445 .set_bitrate_mask = mt7915_set_bitrate_mask,
1446 .set_coverage_class = mt7915_set_coverage_class,
1447 .sta_statistics = mt7915_sta_statistics,
1448 .sta_set_4addr = mt7915_sta_set_4addr,
1449 .sta_set_decap_offload = mt7915_sta_set_decap_offload,
1450 .add_twt_setup = mt7915_mac_add_twt_setup,
1451 .twt_teardown_request = mt7915_twt_teardown_request,
1452 CFG80211_TESTMODE_CMD(mt76_testmode_cmd)
1453 CFG80211_TESTMODE_DUMP(mt76_testmode_dump)
1454 #ifdef CONFIG_MAC80211_DEBUGFS
1455 .sta_add_debugfs = mt7915_sta_add_debugfs,
1457 .set_radar_background = mt7915_set_radar_background,
1458 #ifdef CONFIG_NET_MEDIATEK_SOC_WED
1459 .net_fill_forward_path = mt7915_net_fill_forward_path,