Lines Matching refs:dev
53 static struct mt76_wcid *mt7915_rx_get_wcid(struct mt7915_dev *dev, in mt7915_rx_get_wcid() argument
59 if (idx >= ARRAY_SIZE(dev->mt76.wcid)) in mt7915_rx_get_wcid()
62 wcid = rcu_dereference(dev->mt76.wcid[idx]); in mt7915_rx_get_wcid()
76 bool mt7915_mac_wtbl_update(struct mt7915_dev *dev, int idx, u32 mask) in mt7915_mac_wtbl_update() argument
78 mt76_rmw(dev, MT_WTBL_UPDATE, MT_WTBL_UPDATE_WLAN_IDX, in mt7915_mac_wtbl_update()
81 return mt76_poll(dev, MT_WTBL_UPDATE, MT_WTBL_UPDATE_BUSY, in mt7915_mac_wtbl_update()
85 u32 mt7915_mac_wtbl_lmac_addr(struct mt7915_dev *dev, u16 wcid, u8 dw) in mt7915_mac_wtbl_lmac_addr() argument
87 mt76_wr(dev, MT_WTBLON_TOP_WDUCR, in mt7915_mac_wtbl_lmac_addr()
93 static void mt7915_mac_sta_poll(struct mt7915_dev *dev) in mt7915_mac_sta_poll() argument
108 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_sta_poll()
109 list_splice_init(&dev->mt76.sta_poll_list, &sta_poll_list); in mt7915_mac_sta_poll()
110 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_sta_poll()
121 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_sta_poll()
123 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_sta_poll()
129 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_sta_poll()
134 addr = mt7915_mac_wtbl_lmac_addr(dev, idx, 20); in mt7915_mac_sta_poll()
140 msta->airtime_ac[i] = mt76_rr(dev, addr); in mt7915_mac_sta_poll()
141 msta->airtime_ac[i + 4] = mt76_rr(dev, addr + 4); in mt7915_mac_sta_poll()
153 mt7915_mac_wtbl_update(dev, idx, in mt7915_mac_sta_poll()
183 addr = mt7915_mac_wtbl_lmac_addr(dev, idx, 7); in mt7915_mac_sta_poll()
184 val = mt76_rr(dev, addr); in mt7915_mac_sta_poll()
214 addr = mt7915_mac_wtbl_lmac_addr(dev, idx, 30); in mt7915_mac_sta_poll()
215 val = mt76_rr(dev, addr); in mt7915_mac_sta_poll()
231 void mt7915_mac_enable_rtscts(struct mt7915_dev *dev, in mt7915_mac_enable_rtscts() argument
237 addr = mt7915_mac_wtbl_lmac_addr(dev, mvif->sta.wcid.idx, 5); in mt7915_mac_enable_rtscts()
239 mt76_set(dev, addr, BIT(5)); in mt7915_mac_enable_rtscts()
241 mt76_clear(dev, addr, BIT(5)); in mt7915_mac_enable_rtscts()
245 mt7915_wed_check_ppe(struct mt7915_dev *dev, struct mt76_queue *q, in mt7915_wed_check_ppe() argument
264 skb->dev = wdev->netdev; in mt7915_wed_check_ppe()
266 mtk_wed_device_ppe_check(&dev->mt76.mmio.wed, skb, in mt7915_wed_check_ppe()
272 mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb, in mt7915_mac_fill_rx() argument
276 struct mt76_phy *mphy = &dev->mt76.phy; in mt7915_mac_fill_rx()
277 struct mt7915_phy *phy = &dev->phy; in mt7915_mac_fill_rx()
301 mphy = dev->mt76.phys[MT_BAND1]; in mt7915_mac_fill_rx()
325 status->wcid = mt7915_rx_get_wcid(dev, idx, unicast); in mt7915_mac_fill_rx()
329 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_fill_rx()
332 &dev->mt76.sta_poll_list); in mt7915_mac_fill_rx()
333 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_fill_rx()
466 if (!is_mt7915(&dev->mt76) || (rxd1 & MT_RXD1_NORMAL_GROUP_5)) { in mt7915_mac_fill_rx()
467 ret = mt76_connac2_mac_fill_rx_rate(&dev->mt76, status, in mt7915_mac_fill_rx()
541 mt7915_wed_check_ppe(dev, &dev->mt76.q_rx[q], msta, skb, in mt7915_mac_fill_rx()
546 mt76_connac2_mac_decode_he_radiotap(&dev->mt76, skb, rxv, mode); in mt7915_mac_fill_rx()
560 mt7915_mac_fill_rx_vector(struct mt7915_dev *dev, struct sk_buff *skb) in mt7915_mac_fill_rx_vector() argument
563 struct mt7915_phy *phy = &dev->phy; in mt7915_mac_fill_rx_vector()
575 phy = mt7915_ext_phy(dev); in mt7915_mac_fill_rx_vector()
723 void mt7915_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi, in mt7915_mac_write_txwi() argument
730 struct mt76_phy *mphy = &dev->phy; in mt7915_mac_write_txwi()
732 if (phy_idx && dev->phys[MT_BAND1]) in mt7915_mac_write_txwi()
733 mphy = dev->phys[MT_BAND1]; in mt7915_mac_write_txwi()
735 mt76_connac2_mac_write_txwi(dev, txwi, skb, wcid, key, pid, qid, changed); in mt7915_mac_write_txwi()
747 struct mt7915_dev *dev = container_of(mdev, struct mt7915_dev, mt76); in mt7915_tx_prepare_skb() local
761 wcid = &dev->mt76.global_wcid; in mt7915_tx_prepare_skb()
846 mt7915_mac_tx_free_prepare(struct mt7915_dev *dev) in mt7915_mac_tx_free_prepare() argument
848 struct mt76_dev *mdev = &dev->mt76; in mt7915_mac_tx_free_prepare()
852 mt76_queue_tx_cleanup(dev, dev->mphy.q_tx[MT_TXQ_PSD], false); in mt7915_mac_tx_free_prepare()
853 mt76_queue_tx_cleanup(dev, dev->mphy.q_tx[MT_TXQ_BE], false); in mt7915_mac_tx_free_prepare()
855 mt76_queue_tx_cleanup(dev, mphy_ext->q_tx[MT_TXQ_PSD], false); in mt7915_mac_tx_free_prepare()
856 mt76_queue_tx_cleanup(dev, mphy_ext->q_tx[MT_TXQ_BE], false); in mt7915_mac_tx_free_prepare()
861 mt7915_mac_tx_free_done(struct mt7915_dev *dev, in mt7915_mac_tx_free_done() argument
866 mt7915_mac_sta_poll(dev); in mt7915_mac_tx_free_done()
869 mt76_set_tx_blocked(&dev->mt76, false); in mt7915_mac_tx_free_done()
871 mt76_worker_schedule(&dev->mt76.tx_worker); in mt7915_mac_tx_free_done()
880 mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len) in mt7915_mac_tx_free() argument
884 struct mt76_dev *mdev = &dev->mt76; in mt7915_mac_tx_free()
895 mt7915_mac_tx_free_prepare(dev); in mt7915_mac_tx_free()
917 wcid = rcu_dereference(dev->mt76.wcid[idx]); in mt7915_mac_tx_free()
969 mt7915_mac_tx_free_done(dev, &free_list, wake); in mt7915_mac_tx_free()
973 mt7915_mac_tx_free_v0(struct mt7915_dev *dev, void *data, int len) in mt7915_mac_tx_free_v0() argument
977 struct mt76_dev *mdev = &dev->mt76; in mt7915_mac_tx_free_v0()
983 mt7915_mac_tx_free_prepare(dev); in mt7915_mac_tx_free_v0()
1000 mt7915_mac_tx_free_done(dev, &free_list, wake); in mt7915_mac_tx_free_v0()
1003 static void mt7915_mac_add_txs(struct mt7915_dev *dev, void *data) in mt7915_mac_add_txs() argument
1017 if (wcidx >= mt7915_wtbl_size(dev)) in mt7915_mac_add_txs()
1022 wcid = rcu_dereference(dev->mt76.wcid[wcidx]); in mt7915_mac_add_txs()
1029 mt76_connac2_mac_fill_txs(&dev->mt76, wcid, txs_data); in mt7915_mac_add_txs()
1031 mt76_connac2_mac_add_txs_skb(&dev->mt76, wcid, pid, txs_data); in mt7915_mac_add_txs()
1036 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_add_txs()
1038 list_add_tail(&msta->wcid.poll_list, &dev->mt76.sta_poll_list); in mt7915_mac_add_txs()
1039 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_add_txs()
1047 struct mt7915_dev *dev = container_of(mdev, struct mt7915_dev, mt76); in mt7915_rx_check() local
1056 mt7915_mac_tx_free(dev, data, len); in mt7915_rx_check()
1059 mt7915_mac_tx_free_v0(dev, data, len); in mt7915_rx_check()
1063 mt7915_mac_add_txs(dev, rxd); in mt7915_rx_check()
1066 mt7915_debugfs_rx_fw_monitor(dev, data, len); in mt7915_rx_check()
1076 struct mt7915_dev *dev = container_of(mdev, struct mt7915_dev, mt76); in mt7915_queue_rx_skb() local
1085 mt7915_mac_tx_free(dev, skb->data, skb->len); in mt7915_queue_rx_skb()
1089 mt7915_mac_tx_free_v0(dev, skb->data, skb->len); in mt7915_queue_rx_skb()
1093 mt7915_mcu_rx_event(dev, skb); in mt7915_queue_rx_skb()
1096 mt7915_mac_fill_rx_vector(dev, skb); in mt7915_queue_rx_skb()
1100 mt7915_mac_add_txs(dev, rxd); in mt7915_queue_rx_skb()
1104 mt7915_debugfs_rx_fw_monitor(dev, skb->data, skb->len); in mt7915_queue_rx_skb()
1108 if (!mt7915_mac_fill_rx(dev, skb, q, info)) { in mt7915_queue_rx_skb()
1109 mt76_rx(&dev->mt76, q, skb); in mt7915_queue_rx_skb()
1121 struct mt7915_dev *dev = phy->dev; in mt7915_mac_cca_stats_reset() local
1124 mt76_clear(dev, reg, MT_WF_PHY_RX_CTRL1_STSCNT_EN); in mt7915_mac_cca_stats_reset()
1125 mt76_set(dev, reg, BIT(11) | BIT(9)); in mt7915_mac_cca_stats_reset()
1130 struct mt7915_dev *dev = phy->dev; in mt7915_mac_reset_counters() local
1134 mt76_rr(dev, MT_TX_AGG_CNT(phy->mt76->band_idx, i)); in mt7915_mac_reset_counters()
1135 mt76_rr(dev, MT_TX_AGG_CNT2(phy->mt76->band_idx, i)); in mt7915_mac_reset_counters()
1142 mt76_set(dev, MT_WF_RMAC_MIB_AIRTIME0(phy->mt76->band_idx), in mt7915_mac_reset_counters()
1151 struct mt7915_dev *dev = phy->dev; in mt7915_mac_set_timing() local
1152 struct mt7915_phy *ext_phy = mt7915_ext_phy(dev); in mt7915_mac_set_timing()
1166 coverage_class = max_t(s16, dev->phy.coverage_class, in mt7915_mac_set_timing()
1169 mt76_set(dev, MT_ARB_SCR(band), in mt7915_mac_set_timing()
1177 if (!is_mt7915(&dev->mt76)) { in mt7915_mac_set_timing()
1179 mt76_wr(dev, MT_TMAC_ICR1(band), in mt7915_mac_set_timing()
1189 mt76_wr(dev, MT_TMAC_CDTR(band), cck + reg_offset); in mt7915_mac_set_timing()
1190 mt76_wr(dev, MT_TMAC_ODTR(band), ofdm + reg_offset); in mt7915_mac_set_timing()
1191 mt76_wr(dev, MT_TMAC_ICR0(band), in mt7915_mac_set_timing()
1202 mt76_rmw_field(dev, MT_AGG_ACR0(band), MT_AGG_ACR_CFEND_RATE, val); in mt7915_mac_set_timing()
1203 mt76_clear(dev, MT_ARB_SCR(band), in mt7915_mac_set_timing()
1207 void mt7915_mac_enable_nf(struct mt7915_dev *dev, bool band) in mt7915_mac_enable_nf() argument
1211 reg = is_mt7915(&dev->mt76) ? MT_WF_PHY_RXTD12(band) : in mt7915_mac_enable_nf()
1213 mt76_set(dev, reg, in mt7915_mac_enable_nf()
1217 reg = is_mt7915(&dev->mt76) ? MT_WF_PHY_RX_CTRL1(band) : in mt7915_mac_enable_nf()
1219 mt76_set(dev, reg, FIELD_PREP(MT_WF_PHY_RX_CTRL1_IPI_EN, 0x5)); in mt7915_mac_enable_nf()
1226 struct mt7915_dev *dev = phy->dev; in mt7915_phy_get_nf() local
1231 u32 reg = is_mt7915(&dev->mt76) ? in mt7915_phy_get_nf()
1232 MT_WF_IRPI_NSS(0, nss + (idx << dev->dbdc_support)) : in mt7915_phy_get_nf()
1236 val = mt76_rr(dev, reg); in mt7915_phy_get_nf()
1266 mt7915_wait_reset_state(struct mt7915_dev *dev, u32 state) in mt7915_wait_reset_state() argument
1270 ret = wait_event_timeout(dev->reset_wait, in mt7915_wait_reset_state()
1271 (READ_ONCE(dev->recovery.state) & state), in mt7915_wait_reset_state()
1296 mt7915_update_beacons(struct mt7915_dev *dev) in mt7915_update_beacons() argument
1298 struct mt76_phy *mphy_ext = dev->mt76.phys[MT_BAND1]; in mt7915_update_beacons()
1300 ieee80211_iterate_active_interfaces(dev->mt76.hw, in mt7915_update_beacons()
1302 mt7915_update_vif_beacon, dev->mt76.hw); in mt7915_update_beacons()
1313 mt7915_mac_restart(struct mt7915_dev *dev) in mt7915_mac_restart() argument
1317 struct mt76_dev *mdev = &dev->mt76; in mt7915_mac_restart()
1320 ext_phy = dev->mt76.phys[MT_BAND1]; in mt7915_mac_restart()
1323 if (dev->hif2) { in mt7915_mac_restart()
1324 mt76_wr(dev, MT_INT1_MASK_CSR, 0x0); in mt7915_mac_restart()
1325 mt76_wr(dev, MT_INT1_SOURCE_CSR, ~0); in mt7915_mac_restart()
1328 if (dev_is_pci(mdev->dev)) { in mt7915_mac_restart()
1329 mt76_wr(dev, MT_PCIE_MAC_INT_ENABLE, 0x0); in mt7915_mac_restart()
1330 if (dev->hif2) { in mt7915_mac_restart()
1332 mt76_wr(dev, MT_PCIE1_MAC_INT_ENABLE, 0x0); in mt7915_mac_restart()
1334 mt76_wr(dev, MT_PCIE1_MAC_INT_ENABLE_MT7916, 0x0); in mt7915_mac_restart()
1338 set_bit(MT76_RESET, &dev->mphy.state); in mt7915_mac_restart()
1339 set_bit(MT76_MCU_RESET, &dev->mphy.state); in mt7915_mac_restart()
1340 wake_up(&dev->mt76.mcu.wait); in mt7915_mac_restart()
1347 mt76_txq_schedule_all(&dev->mphy); in mt7915_mac_restart()
1352 mt76_worker_disable(&dev->mt76.tx_worker); in mt7915_mac_restart()
1355 napi_disable(&dev->mt76.napi[i]); in mt7915_mac_restart()
1357 napi_disable(&dev->mt76.tx_napi); in mt7915_mac_restart()
1360 mt76_connac2_tx_token_put(&dev->mt76); in mt7915_mac_restart()
1361 idr_init(&dev->mt76.token); in mt7915_mac_restart()
1363 mt7915_dma_reset(dev, true); in mt7915_mac_restart()
1368 napi_enable(&dev->mt76.napi[i]); in mt7915_mac_restart()
1369 napi_schedule(&dev->mt76.napi[i]); in mt7915_mac_restart()
1373 clear_bit(MT76_MCU_RESET, &dev->mphy.state); in mt7915_mac_restart()
1374 clear_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state); in mt7915_mac_restart()
1376 mt76_wr(dev, MT_INT_MASK_CSR, dev->mt76.mmio.irqmask); in mt7915_mac_restart()
1377 mt76_wr(dev, MT_INT_SOURCE_CSR, ~0); in mt7915_mac_restart()
1379 if (dev->hif2) { in mt7915_mac_restart()
1380 mt76_wr(dev, MT_INT1_MASK_CSR, dev->mt76.mmio.irqmask); in mt7915_mac_restart()
1381 mt76_wr(dev, MT_INT1_SOURCE_CSR, ~0); in mt7915_mac_restart()
1383 if (dev_is_pci(mdev->dev)) { in mt7915_mac_restart()
1384 mt76_wr(dev, MT_PCIE_MAC_INT_ENABLE, 0xff); in mt7915_mac_restart()
1385 if (dev->hif2) { in mt7915_mac_restart()
1387 mt76_wr(dev, MT_PCIE1_MAC_INT_ENABLE, 0xff); in mt7915_mac_restart()
1389 mt76_wr(dev, MT_PCIE1_MAC_INT_ENABLE_MT7916, 0xff); in mt7915_mac_restart()
1394 ret = mt7915_mcu_init_firmware(dev); in mt7915_mac_restart()
1399 ret = mt7915_mcu_set_eeprom(dev); in mt7915_mac_restart()
1403 mt7915_mac_init(dev); in mt7915_mac_restart()
1404 mt7915_init_txpower(dev, &dev->mphy.sband_2g.sband); in mt7915_mac_restart()
1405 mt7915_init_txpower(dev, &dev->mphy.sband_5g.sband); in mt7915_mac_restart()
1406 ret = mt7915_txbf_init(dev); in mt7915_mac_restart()
1408 if (test_bit(MT76_STATE_RUNNING, &dev->mphy.state)) { in mt7915_mac_restart()
1409 ret = mt7915_run(dev->mphy.hw); in mt7915_mac_restart()
1422 clear_bit(MT76_RESET, &dev->mphy.state); in mt7915_mac_restart()
1427 napi_enable(&dev->mt76.tx_napi); in mt7915_mac_restart()
1428 napi_schedule(&dev->mt76.tx_napi); in mt7915_mac_restart()
1431 mt76_worker_enable(&dev->mt76.tx_worker); in mt7915_mac_restart()
1437 mt7915_mac_full_reset(struct mt7915_dev *dev) in mt7915_mac_full_reset() argument
1442 ext_phy = dev->mt76.phys[MT_BAND1]; in mt7915_mac_full_reset()
1444 dev->recovery.hw_full_reset = true; in mt7915_mac_full_reset()
1446 wake_up(&dev->mt76.mcu.wait); in mt7915_mac_full_reset()
1447 ieee80211_stop_queues(mt76_hw(dev)); in mt7915_mac_full_reset()
1451 cancel_delayed_work_sync(&dev->mphy.mac_work); in mt7915_mac_full_reset()
1455 mutex_lock(&dev->mt76.mutex); in mt7915_mac_full_reset()
1457 if (!mt7915_mac_restart(dev)) in mt7915_mac_full_reset()
1460 mutex_unlock(&dev->mt76.mutex); in mt7915_mac_full_reset()
1463 dev_err(dev->mt76.dev, "chip full reset failed\n"); in mt7915_mac_full_reset()
1465 ieee80211_restart_hw(mt76_hw(dev)); in mt7915_mac_full_reset()
1469 ieee80211_wake_queues(mt76_hw(dev)); in mt7915_mac_full_reset()
1473 dev->recovery.hw_full_reset = false; in mt7915_mac_full_reset()
1474 ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mphy.mac_work, in mt7915_mac_full_reset()
1487 struct mt7915_dev *dev; in mt7915_mac_reset_work() local
1490 dev = container_of(work, struct mt7915_dev, reset_work); in mt7915_mac_reset_work()
1491 ext_phy = dev->mt76.phys[MT_BAND1]; in mt7915_mac_reset_work()
1495 if (dev->recovery.restart) { in mt7915_mac_reset_work()
1497 mt76_clear(dev, MT_WFDMA0_MCU_HOST_INT_ENA, in mt7915_mac_reset_work()
1500 if (READ_ONCE(dev->recovery.state) & MT_MCU_CMD_WA_WDT) in mt7915_mac_reset_work()
1501 dev->recovery.wa_reset_count++; in mt7915_mac_reset_work()
1503 dev->recovery.wm_reset_count++; in mt7915_mac_reset_work()
1505 mt7915_mac_full_reset(dev); in mt7915_mac_reset_work()
1508 mt7915_irq_enable(dev, MT_INT_MCU_CMD); in mt7915_mac_reset_work()
1509 mt7915_irq_disable(dev, 0); in mt7915_mac_reset_work()
1512 mt76_set(dev, MT_WFDMA0_MCU_HOST_INT_ENA, MT_MCU_CMD_WDT_MASK); in mt7915_mac_reset_work()
1514 dev->recovery.state = MT_MCU_CMD_NORMAL_STATE; in mt7915_mac_reset_work()
1515 dev->recovery.restart = false; in mt7915_mac_reset_work()
1520 if (!(READ_ONCE(dev->recovery.state) & MT_MCU_CMD_STOP_DMA)) in mt7915_mac_reset_work()
1523 if (mtk_wed_device_active(&dev->mt76.mmio.wed)) { in mt7915_mac_reset_work()
1524 mtk_wed_device_stop(&dev->mt76.mmio.wed); in mt7915_mac_reset_work()
1525 if (!is_mt798x(&dev->mt76)) in mt7915_mac_reset_work()
1526 mt76_wr(dev, MT_INT_WED_MASK_CSR, 0); in mt7915_mac_reset_work()
1529 ieee80211_stop_queues(mt76_hw(dev)); in mt7915_mac_reset_work()
1533 set_bit(MT76_RESET, &dev->mphy.state); in mt7915_mac_reset_work()
1534 set_bit(MT76_MCU_RESET, &dev->mphy.state); in mt7915_mac_reset_work()
1535 wake_up(&dev->mt76.mcu.wait); in mt7915_mac_reset_work()
1536 cancel_delayed_work_sync(&dev->mphy.mac_work); in mt7915_mac_reset_work()
1542 mutex_lock(&dev->mt76.mutex); in mt7915_mac_reset_work()
1544 mt76_worker_disable(&dev->mt76.tx_worker); in mt7915_mac_reset_work()
1545 mt76_for_each_q_rx(&dev->mt76, i) in mt7915_mac_reset_work()
1546 napi_disable(&dev->mt76.napi[i]); in mt7915_mac_reset_work()
1547 napi_disable(&dev->mt76.tx_napi); in mt7915_mac_reset_work()
1550 mt76_wr(dev, MT_MCU_INT_EVENT, MT_MCU_INT_EVENT_DMA_STOPPED); in mt7915_mac_reset_work()
1552 if (mt7915_wait_reset_state(dev, MT_MCU_CMD_RESET_DONE)) { in mt7915_mac_reset_work()
1553 mt7915_dma_reset(dev, false); in mt7915_mac_reset_work()
1555 mt76_connac2_tx_token_put(&dev->mt76); in mt7915_mac_reset_work()
1556 idr_init(&dev->mt76.token); in mt7915_mac_reset_work()
1558 mt76_wr(dev, MT_MCU_INT_EVENT, MT_MCU_INT_EVENT_DMA_INIT); in mt7915_mac_reset_work()
1559 mt7915_wait_reset_state(dev, MT_MCU_CMD_RECOVERY_DONE); in mt7915_mac_reset_work()
1562 mt76_wr(dev, MT_MCU_INT_EVENT, MT_MCU_INT_EVENT_RESET_DONE); in mt7915_mac_reset_work()
1563 mt7915_wait_reset_state(dev, MT_MCU_CMD_NORMAL_STATE); in mt7915_mac_reset_work()
1566 mt7915_dma_start(dev, false, false); in mt7915_mac_reset_work()
1568 clear_bit(MT76_MCU_RESET, &dev->mphy.state); in mt7915_mac_reset_work()
1569 clear_bit(MT76_RESET, &dev->mphy.state); in mt7915_mac_reset_work()
1574 mt76_for_each_q_rx(&dev->mt76, i) { in mt7915_mac_reset_work()
1575 napi_enable(&dev->mt76.napi[i]); in mt7915_mac_reset_work()
1576 napi_schedule(&dev->mt76.napi[i]); in mt7915_mac_reset_work()
1580 tasklet_schedule(&dev->mt76.irq_tasklet); in mt7915_mac_reset_work()
1582 mt76_worker_enable(&dev->mt76.tx_worker); in mt7915_mac_reset_work()
1585 napi_enable(&dev->mt76.tx_napi); in mt7915_mac_reset_work()
1586 napi_schedule(&dev->mt76.tx_napi); in mt7915_mac_reset_work()
1589 ieee80211_wake_queues(mt76_hw(dev)); in mt7915_mac_reset_work()
1593 mutex_unlock(&dev->mt76.mutex); in mt7915_mac_reset_work()
1595 mt7915_update_beacons(dev); in mt7915_mac_reset_work()
1597 ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mphy.mac_work, in mt7915_mac_reset_work()
1610 struct mt7915_dev *dev; in mt7915_mac_dump_work() local
1617 dev = container_of(work, struct mt7915_dev, dump_work); in mt7915_mac_dump_work()
1619 mutex_lock(&dev->dump_mutex); in mt7915_mac_dump_work()
1621 crash_data = mt7915_coredump_new(dev); in mt7915_mac_dump_work()
1623 mutex_unlock(&dev->dump_mutex); in mt7915_mac_dump_work()
1627 mem_region = mt7915_coredump_get_mem_layout(dev, &num); in mt7915_mac_dump_work()
1629 mutex_unlock(&dev->dump_mutex); in mt7915_mac_dump_work()
1640 dev_warn(dev->mt76.dev, "%s len %lu is too large\n", in mt7915_mac_dump_work()
1651 mt7915_memcpy_fromio(dev, buf, mem_region->start, in mt7915_mac_dump_work()
1667 mutex_unlock(&dev->dump_mutex); in mt7915_mac_dump_work()
1670 mt7915_coredump_submit(dev); in mt7915_mac_dump_work()
1672 queue_work(dev->mt76.wq, &dev->reset_work); in mt7915_mac_dump_work()
1675 void mt7915_reset(struct mt7915_dev *dev) in mt7915_reset() argument
1677 if (!dev->recovery.hw_init_done) in mt7915_reset()
1680 if (dev->recovery.hw_full_reset) in mt7915_reset()
1684 if (READ_ONCE(dev->recovery.state) & MT_MCU_CMD_WDT_MASK) { in mt7915_reset()
1685 dev->recovery.restart = true; in mt7915_reset()
1686 dev_info(dev->mt76.dev, in mt7915_reset()
1688 wiphy_name(dev->mt76.hw->wiphy)); in mt7915_reset()
1690 mt7915_irq_disable(dev, MT_INT_MCU_CMD); in mt7915_reset()
1691 queue_work(dev->mt76.wq, &dev->dump_work); in mt7915_reset()
1695 queue_work(dev->mt76.wq, &dev->reset_work); in mt7915_reset()
1696 wake_up(&dev->reset_wait); in mt7915_reset()
1702 struct mt7915_dev *dev = phy->dev; in mt7915_mac_update_stats() local
1707 cnt = mt76_rr(dev, MT_MIB_SDR3(band)); in mt7915_mac_update_stats()
1708 mib->fcs_err_cnt += is_mt7915(&dev->mt76) ? in mt7915_mac_update_stats()
1712 cnt = mt76_rr(dev, MT_MIB_SDR4(band)); in mt7915_mac_update_stats()
1715 cnt = mt76_rr(dev, MT_MIB_SDR5(band)); in mt7915_mac_update_stats()
1718 cnt = mt76_rr(dev, MT_MIB_SDR6(band)); in mt7915_mac_update_stats()
1721 cnt = mt76_rr(dev, MT_MIB_SDR7(band)); in mt7915_mac_update_stats()
1725 cnt = mt76_rr(dev, MT_MIB_SDR8(band)); in mt7915_mac_update_stats()
1729 cnt = mt76_rr(dev, MT_MIB_SDR10(band)); in mt7915_mac_update_stats()
1730 mib->rx_mrdy_cnt += is_mt7915(&dev->mt76) ? in mt7915_mac_update_stats()
1734 cnt = mt76_rr(dev, MT_MIB_SDR11(band)); in mt7915_mac_update_stats()
1738 cnt = mt76_rr(dev, MT_MIB_SDR12(band)); in mt7915_mac_update_stats()
1741 cnt = mt76_rr(dev, MT_MIB_SDR13(band)); in mt7915_mac_update_stats()
1745 cnt = mt76_rr(dev, MT_MIB_SDR14(band)); in mt7915_mac_update_stats()
1746 mib->tx_mpdu_attempts_cnt += is_mt7915(&dev->mt76) ? in mt7915_mac_update_stats()
1750 cnt = mt76_rr(dev, MT_MIB_SDR15(band)); in mt7915_mac_update_stats()
1751 mib->tx_mpdu_success_cnt += is_mt7915(&dev->mt76) ? in mt7915_mac_update_stats()
1755 cnt = mt76_rr(dev, MT_MIB_SDR16(band)); in mt7915_mac_update_stats()
1759 cnt = mt76_rr(dev, MT_MIB_SDR17(band)); in mt7915_mac_update_stats()
1763 cnt = mt76_rr(dev, MT_MIB_SDR18(band)); in mt7915_mac_update_stats()
1767 cnt = mt76_rr(dev, MT_MIB_SDR19(band)); in mt7915_mac_update_stats()
1770 cnt = mt76_rr(dev, MT_MIB_SDR20(band)); in mt7915_mac_update_stats()
1774 cnt = mt76_rr(dev, MT_MIB_SDR21(band)); in mt7915_mac_update_stats()
1778 cnt = mt76_rr(dev, MT_MIB_SDR22(band)); in mt7915_mac_update_stats()
1781 cnt = mt76_rr(dev, MT_MIB_SDR23(band)); in mt7915_mac_update_stats()
1784 cnt = mt76_rr(dev, MT_MIB_SDR24(band)); in mt7915_mac_update_stats()
1785 mib->rx_ampdu_valid_subframe_cnt += is_mt7915(&dev->mt76) ? in mt7915_mac_update_stats()
1789 cnt = mt76_rr(dev, MT_MIB_SDR25(band)); in mt7915_mac_update_stats()
1792 cnt = mt76_rr(dev, MT_MIB_SDR27(band)); in mt7915_mac_update_stats()
1796 cnt = mt76_rr(dev, MT_MIB_SDR28(band)); in mt7915_mac_update_stats()
1800 cnt = mt76_rr(dev, MT_MIB_SDR29(band)); in mt7915_mac_update_stats()
1801 mib->rx_pfdrop_cnt += is_mt7915(&dev->mt76) ? in mt7915_mac_update_stats()
1805 cnt = mt76_rr(dev, MT_MIB_SDRVEC(band)); in mt7915_mac_update_stats()
1806 mib->rx_vec_queue_overflow_drop_cnt += is_mt7915(&dev->mt76) ? in mt7915_mac_update_stats()
1810 cnt = mt76_rr(dev, MT_MIB_SDR31(band)); in mt7915_mac_update_stats()
1813 cnt = mt76_rr(dev, MT_MIB_SDRMUBF(band)); in mt7915_mac_update_stats()
1816 cnt = mt76_rr(dev, MT_MIB_DR8(band)); in mt7915_mac_update_stats()
1819 cnt = mt76_rr(dev, MT_MIB_DR9(band)); in mt7915_mac_update_stats()
1822 cnt = mt76_rr(dev, MT_MIB_DR11(band)); in mt7915_mac_update_stats()
1825 cnt = mt76_rr(dev, MT_ETBF_PAR_RPT0(band)); in mt7915_mac_update_stats()
1831 cnt = mt76_rr(dev, MT_PLE_AMSDU_PACK_MSDU_CNT(i)); in mt7915_mac_update_stats()
1836 if (is_mt7915(&dev->mt76)) { in mt7915_mac_update_stats()
1838 val = mt76_rr(dev, MT_MIB_MB_SDR1(band, (i << 4))); in mt7915_mac_update_stats()
1844 val = mt76_rr(dev, MT_MIB_MB_SDR0(band, (i << 4))); in mt7915_mac_update_stats()
1849 val = mt76_rr(dev, MT_TX_AGG_CNT(band, i)); in mt7915_mac_update_stats()
1853 val = mt76_rr(dev, MT_TX_AGG_CNT2(band, i)); in mt7915_mac_update_stats()
1858 cnt = mt76_rr(dev, MT_MIB_SDR32(band)); in mt7915_mac_update_stats()
1861 cnt = mt76_rr(dev, MT_MIB_SDR33(band)); in mt7915_mac_update_stats()
1864 cnt = mt76_rr(dev, MT_ETBF_TX_APP_CNT(band)); in mt7915_mac_update_stats()
1868 cnt = mt76_rr(dev, MT_ETBF_TX_NDP_BFRP(band)); in mt7915_mac_update_stats()
1872 cnt = mt76_rr(dev, MT_ETBF_RX_FB_CNT(band)); in mt7915_mac_update_stats()
1880 val = mt76_rr(dev, MT_MIB_MB_SDR0(band, (i << 2))); in mt7915_mac_update_stats()
1885 val = mt76_rr(dev, MT_MIB_MB_SDR1(band, (i << 2))); in mt7915_mac_update_stats()
1890 val = mt76_rr(dev, MT_MIB_MB_SDR2(band, (i << 2))); in mt7915_mac_update_stats()
1895 val = mt76_rr(dev, MT_MIB_MB_BFTF(band, (i << 2))); in mt7915_mac_update_stats()
1901 val = mt76_rr(dev, MT_TX_AGG_CNT(band, i)); in mt7915_mac_update_stats()
1906 cnt = mt76_rr(dev, MT_MIB_SDR32(band)); in mt7915_mac_update_stats()
1912 cnt = mt76_rr(dev, MT_MIB_BFCR7(band)); in mt7915_mac_update_stats()
1915 cnt = mt76_rr(dev, MT_MIB_BFCR2(band)); in mt7915_mac_update_stats()
1918 cnt = mt76_rr(dev, MT_MIB_BFCR0(band)); in mt7915_mac_update_stats()
1924 cnt = mt76_rr(dev, MT_MIB_BFCR1(band)); in mt7915_mac_update_stats()
1932 struct mt7915_dev *dev = phy->dev; in mt7915_mac_severe_check() local
1942 trb = mt76_rr(dev, MT_TRB_RXPSR0(phy->mt76->band_idx)); in mt7915_mac_severe_check()
1949 mt7915_mcu_set_ser(dev, SER_RECOVER, SER_SET_RECOVER_L3_RX_ABORT, in mt7915_mac_severe_check()
1957 struct mt7915_dev *dev = container_of(work, struct mt7915_dev, rc_work); in mt7915_mac_sta_rc_work() local
1964 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_sta_rc_work()
1965 list_splice_init(&dev->sta_rc_list, &list); in mt7915_mac_sta_rc_work()
1972 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_sta_rc_work()
1980 mt7915_mcu_add_rate_ctrl(dev, vif, sta, true); in mt7915_mac_sta_rc_work()
1983 mt7915_mcu_add_smps(dev, vif, sta); in mt7915_mac_sta_rc_work()
1985 spin_lock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_sta_rc_work()
1988 spin_unlock_bh(&dev->mt76.sta_poll_lock); in mt7915_mac_sta_rc_work()
2000 mutex_lock(&mphy->dev->mutex); in mt7915_mac_work()
2009 if (phy->dev->muru_debug) in mt7915_mac_work()
2013 mutex_unlock(&mphy->dev->mutex); in mt7915_mac_work()
2015 mt76_tx_status_check(mphy->dev, false); in mt7915_mac_work()
2023 struct mt7915_dev *dev = phy->dev; in mt7915_dfs_stop_radar_detector() local
2026 mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_STOP, 0, in mt7915_dfs_stop_radar_detector()
2029 mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_STOP, 1, in mt7915_dfs_stop_radar_detector()
2033 static int mt7915_dfs_start_rdd(struct mt7915_dev *dev, int chain) in mt7915_dfs_start_rdd() argument
2037 switch (dev->mt76.region) { in mt7915_dfs_start_rdd()
2050 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_START, chain, in mt7915_dfs_start_rdd()
2055 if (is_mt7915(&dev->mt76)) { in mt7915_dfs_start_rdd()
2056 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_SET_WF_ANT, chain, in mt7915_dfs_start_rdd()
2057 0, dev->dbdc_support ? 2 : 0); in mt7915_dfs_start_rdd()
2062 return mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_DET_MODE, chain, in mt7915_dfs_start_rdd()
2069 struct mt7915_dev *dev = phy->dev; in mt7915_dfs_start_radar_detector() local
2073 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_CAC_START, in mt7915_dfs_start_radar_detector()
2078 err = mt7915_dfs_start_rdd(dev, phy->mt76->band_idx); in mt7915_dfs_start_radar_detector()
2084 if (!is_mt7915(&dev->mt76)) in mt7915_dfs_start_radar_detector()
2089 err = mt7915_dfs_start_rdd(dev, 1); in mt7915_dfs_start_radar_detector()
2103 struct mt7915_dev *dev = phy->dev; in mt7915_dfs_init_radar_specs() local
2106 switch (dev->mt76.region) { in mt7915_dfs_init_radar_specs()
2109 err = mt7915_mcu_set_fcc5_lpn(dev, 8); in mt7915_dfs_init_radar_specs()
2124 err = mt7915_mcu_set_radar_th(dev, i, in mt7915_dfs_init_radar_specs()
2130 return mt7915_mcu_set_pulse_th(dev, &radar_specs->pulse_th); in mt7915_dfs_init_radar_specs()
2135 struct mt7915_dev *dev = phy->dev; in mt7915_dfs_init_radar_detector() local
2166 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_CAC_END, in mt7915_dfs_init_radar_detector()
2177 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_NORMAL_START, in mt7915_dfs_init_radar_detector()
2182 if (is_mt7915(&dev->mt76)) { in mt7915_dfs_init_radar_detector()
2183 err = mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_SET_WF_ANT, in mt7915_dfs_init_radar_detector()
2185 dev->dbdc_support ? 2 : 0); in mt7915_dfs_init_radar_detector()
2203 mt7915_mac_twt_sched_list_add(struct mt7915_dev *dev, in mt7915_mac_twt_sched_list_add() argument
2210 iter = list_first_entry_or_null(&dev->twt_list, in mt7915_mac_twt_sched_list_add()
2214 list_add(&flow->list, &dev->twt_list); in mt7915_mac_twt_sched_list_add()
2218 list_for_each_entry_safe(iter, iter_next, &dev->twt_list, list) { in mt7915_mac_twt_sched_list_add()
2221 if (list_is_last(&iter->list, &dev->twt_list)) in mt7915_mac_twt_sched_list_add()
2232 list_add_tail(&flow->list, &dev->twt_list); in mt7915_mac_twt_sched_list_add()
2307 struct mt7915_dev *dev = mt7915_hw_dev(hw); in mt7915_mac_add_twt_setup() local
2315 mutex_lock(&dev->mt76.mutex); in mt7915_mac_add_twt_setup()
2317 if (dev->twt.n_agrt == MT7915_MAX_TWT_AGRT) in mt7915_mac_add_twt_setup()
2334 table_id = ffs(~dev->twt.table_mask) - 1; in mt7915_mac_add_twt_setup()
2361 flow->start_tsf = mt7915_mac_twt_sched_list_add(dev, flow); in mt7915_mac_add_twt_setup()
2367 list_add_tail(&flow->list, &dev->twt_list); in mt7915_mac_add_twt_setup()
2371 if (mt7915_mcu_twt_agrt_update(dev, msta->vif, flow, MCU_TWT_AGRT_ADD)) in mt7915_mac_add_twt_setup()
2375 dev->twt.table_mask |= BIT(table_id); in mt7915_mac_add_twt_setup()
2377 dev->twt.n_agrt++; in mt7915_mac_add_twt_setup()
2380 mutex_unlock(&dev->mt76.mutex); in mt7915_mac_add_twt_setup()
2389 void mt7915_mac_twt_teardown_flow(struct mt7915_dev *dev, in mt7915_mac_twt_teardown_flow() argument
2395 lockdep_assert_held(&dev->mt76.mutex); in mt7915_mac_twt_teardown_flow()
2404 if (mt7915_mcu_twt_agrt_update(dev, msta->vif, flow, in mt7915_mac_twt_teardown_flow()
2410 dev->twt.table_mask &= ~BIT(flow->table_id); in mt7915_mac_twt_teardown_flow()
2411 dev->twt.n_agrt--; in mt7915_mac_twt_teardown_flow()