mac.c (78562b2cafc61a0c08dc949eacb942ac756aae37) | mac.c (975e122ddb7cd6f67bff974d2ea00c5568d2014c) |
---|---|
1// SPDX-License-Identifier: ISC 2/* Copyright (C) 2020 MediaTek Inc. */ 3 4#include <linux/devcoredump.h> 5#include <linux/etherdevice.h> 6#include <linux/timekeeping.h> 7#include "mt7921.h" 8#include "../dma.h" --- 6 unchanged lines hidden (view full) --- 15 16#define MT_WTBL_AC0_CTT_OFFSET 20 17 18static u32 mt7921_mac_wtbl_lmac_addr(int idx, u8 offset) 19{ 20 return MT_WTBL_LMAC_OFFS(idx, 0) + offset * 4; 21} 22 | 1// SPDX-License-Identifier: ISC 2/* Copyright (C) 2020 MediaTek Inc. */ 3 4#include <linux/devcoredump.h> 5#include <linux/etherdevice.h> 6#include <linux/timekeeping.h> 7#include "mt7921.h" 8#include "../dma.h" --- 6 unchanged lines hidden (view full) --- 15 16#define MT_WTBL_AC0_CTT_OFFSET 20 17 18static u32 mt7921_mac_wtbl_lmac_addr(int idx, u8 offset) 19{ 20 return MT_WTBL_LMAC_OFFS(idx, 0) + offset * 4; 21} 22 |
23static struct mt76_wcid *mt7921_rx_get_wcid(struct mt7921_dev *dev, | 23static struct mt76_wcid *mt7921_rx_get_wcid(struct mt792x_dev *dev, |
24 u16 idx, bool unicast) 25{ 26 struct mt792x_sta *sta; 27 struct mt76_wcid *wcid; 28 29 if (idx >= ARRAY_SIZE(dev->mt76.wcid)) 30 return NULL; 31 --- 6 unchanged lines hidden (view full) --- 38 39 sta = container_of(wcid, struct mt792x_sta, wcid); 40 if (!sta->vif) 41 return NULL; 42 43 return &sta->vif->sta.wcid; 44} 45 | 24 u16 idx, bool unicast) 25{ 26 struct mt792x_sta *sta; 27 struct mt76_wcid *wcid; 28 29 if (idx >= ARRAY_SIZE(dev->mt76.wcid)) 30 return NULL; 31 --- 6 unchanged lines hidden (view full) --- 38 39 sta = container_of(wcid, struct mt792x_sta, wcid); 40 if (!sta->vif) 41 return NULL; 42 43 return &sta->vif->sta.wcid; 44} 45 |
46bool mt7921_mac_wtbl_update(struct mt7921_dev *dev, int idx, u32 mask) | 46bool mt7921_mac_wtbl_update(struct mt792x_dev *dev, int idx, u32 mask) |
47{ 48 mt76_rmw(dev, MT_WTBL_UPDATE, MT_WTBL_UPDATE_WLAN_IDX, 49 FIELD_PREP(MT_WTBL_UPDATE_WLAN_IDX, idx) | mask); 50 51 return mt76_poll(dev, MT_WTBL_UPDATE, MT_WTBL_UPDATE_BUSY, 52 0, 5000); 53} 54 | 47{ 48 mt76_rmw(dev, MT_WTBL_UPDATE, MT_WTBL_UPDATE_WLAN_IDX, 49 FIELD_PREP(MT_WTBL_UPDATE_WLAN_IDX, idx) | mask); 50 51 return mt76_poll(dev, MT_WTBL_UPDATE, MT_WTBL_UPDATE_BUSY, 52 0, 5000); 53} 54 |
55static void mt7921_mac_sta_poll(struct mt7921_dev *dev) | 55static void mt7921_mac_sta_poll(struct mt792x_dev *dev) |
56{ 57 static const u8 ac_to_tid[] = { 58 [IEEE80211_AC_BE] = 0, 59 [IEEE80211_AC_BK] = 1, 60 [IEEE80211_AC_VI] = 4, 61 [IEEE80211_AC_VO] = 6 62 }; 63 struct ieee80211_sta *sta; --- 116 unchanged lines hidden (view full) --- 180 msta->ack_signal = 181 mt76_rx_signal(msta->vif->phy->mt76->antenna_mask, rssi); 182 183 ewma_avg_signal_add(&msta->avg_ack_signal, -msta->ack_signal); 184 } 185} 186 187static void | 56{ 57 static const u8 ac_to_tid[] = { 58 [IEEE80211_AC_BE] = 0, 59 [IEEE80211_AC_BK] = 1, 60 [IEEE80211_AC_VI] = 4, 61 [IEEE80211_AC_VO] = 6 62 }; 63 struct ieee80211_sta *sta; --- 116 unchanged lines hidden (view full) --- 180 msta->ack_signal = 181 mt76_rx_signal(msta->vif->phy->mt76->antenna_mask, rssi); 182 183 ewma_avg_signal_add(&msta->avg_ack_signal, -msta->ack_signal); 184 } 185} 186 187static void |
188mt7921_get_status_freq_info(struct mt7921_dev *dev, struct mt76_phy *mphy, | 188mt7921_get_status_freq_info(struct mt792x_dev *dev, struct mt76_phy *mphy, |
189 struct mt76_rx_status *status, u8 chfreq) 190{ 191 if (chfreq > 180) { 192 status->band = NL80211_BAND_6GHZ; 193 chfreq = (chfreq - 181) * 4 + 1; 194 } else if (chfreq > 14) { 195 status->band = NL80211_BAND_5GHZ; 196 } else { --- 15 unchanged lines hidden (view full) --- 212 213 if (!ether_addr_equal(vif->addr, hdr->addr1)) 214 return; 215 216 ewma_rssi_add(&mvif->rssi, -status->signal); 217} 218 219static void | 189 struct mt76_rx_status *status, u8 chfreq) 190{ 191 if (chfreq > 180) { 192 status->band = NL80211_BAND_6GHZ; 193 chfreq = (chfreq - 181) * 4 + 1; 194 } else if (chfreq > 14) { 195 status->band = NL80211_BAND_5GHZ; 196 } else { --- 15 unchanged lines hidden (view full) --- 212 213 if (!ether_addr_equal(vif->addr, hdr->addr1)) 214 return; 215 216 ewma_rssi_add(&mvif->rssi, -status->signal); 217} 218 219static void |
220mt7921_mac_assoc_rssi(struct mt7921_dev *dev, struct sk_buff *skb) | 220mt7921_mac_assoc_rssi(struct mt792x_dev *dev, struct sk_buff *skb) |
221{ 222 struct ieee80211_hdr *hdr = mt76_skb_get_hdr(skb); 223 224 if (!ieee80211_is_assoc_resp(hdr->frame_control) && 225 !ieee80211_is_auth(hdr->frame_control)) 226 return; 227 228 ieee80211_iterate_active_interfaces_atomic(mt76_hw(dev), 229 IEEE80211_IFACE_ITER_RESUME_ALL, 230 mt7921_mac_rssi_iter, skb); 231} 232 233static int | 221{ 222 struct ieee80211_hdr *hdr = mt76_skb_get_hdr(skb); 223 224 if (!ieee80211_is_assoc_resp(hdr->frame_control) && 225 !ieee80211_is_auth(hdr->frame_control)) 226 return; 227 228 ieee80211_iterate_active_interfaces_atomic(mt76_hw(dev), 229 IEEE80211_IFACE_ITER_RESUME_ALL, 230 mt7921_mac_rssi_iter, skb); 231} 232 233static int |
234mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb) | 234mt7921_mac_fill_rx(struct mt792x_dev *dev, struct sk_buff *skb) |
235{ 236 u32 csum_mask = MT_RXD0_NORMAL_IP_SUM | MT_RXD0_NORMAL_UDP_TCP_SUM; 237 struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; 238 bool hdr_trans, unicast, insert_ccmp_hdr = false; 239 u8 chfreq, qos_ctl = 0, remove_pad, amsdu_info; 240 u16 hdr_gap; 241 __le32 *rxv = NULL, *rxd = (__le32 *)skb->data; 242 struct mt76_phy *mphy = &dev->mt76.phy; --- 263 unchanged lines hidden (view full) --- 506 507 status->aggr = unicast && !ieee80211_is_qos_nullfunc(fc); 508 status->seqno = IEEE80211_SEQ_TO_SN(seq_ctrl); 509 status->qos_ctl = qos_ctl; 510 511 return 0; 512} 513 | 235{ 236 u32 csum_mask = MT_RXD0_NORMAL_IP_SUM | MT_RXD0_NORMAL_UDP_TCP_SUM; 237 struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; 238 bool hdr_trans, unicast, insert_ccmp_hdr = false; 239 u8 chfreq, qos_ctl = 0, remove_pad, amsdu_info; 240 u16 hdr_gap; 241 __le32 *rxv = NULL, *rxd = (__le32 *)skb->data; 242 struct mt76_phy *mphy = &dev->mt76.phy; --- 263 unchanged lines hidden (view full) --- 506 507 status->aggr = unicast && !ieee80211_is_qos_nullfunc(fc); 508 status->seqno = IEEE80211_SEQ_TO_SN(seq_ctrl); 509 status->qos_ctl = qos_ctl; 510 511 return 0; 512} 513 |
514void mt7921_mac_add_txs(struct mt7921_dev *dev, void *data) | 514void mt7921_mac_add_txs(struct mt792x_dev *dev, void *data) |
515{ 516 struct mt792x_sta *msta = NULL; 517 struct mt76_wcid *wcid; 518 __le32 *txs_data = data; 519 u16 wcidx; 520 u8 pid; 521 522 if (le32_get_bits(txs_data[0], MT_TXS0_TXS_FORMAT) > 1) --- 24 unchanged lines hidden (view full) --- 547 if (list_empty(&msta->wcid.poll_list)) 548 list_add_tail(&msta->wcid.poll_list, &dev->mt76.sta_poll_list); 549 spin_unlock_bh(&dev->mt76.sta_poll_lock); 550 551out: 552 rcu_read_unlock(); 553} 554 | 515{ 516 struct mt792x_sta *msta = NULL; 517 struct mt76_wcid *wcid; 518 __le32 *txs_data = data; 519 u16 wcidx; 520 u8 pid; 521 522 if (le32_get_bits(txs_data[0], MT_TXS0_TXS_FORMAT) > 1) --- 24 unchanged lines hidden (view full) --- 547 if (list_empty(&msta->wcid.poll_list)) 548 list_add_tail(&msta->wcid.poll_list, &dev->mt76.sta_poll_list); 549 spin_unlock_bh(&dev->mt76.sta_poll_lock); 550 551out: 552 rcu_read_unlock(); 553} 554 |
555static void mt7921_mac_tx_free(struct mt7921_dev *dev, void *data, int len) | 555static void mt7921_mac_tx_free(struct mt792x_dev *dev, void *data, int len) |
556{ 557 struct mt76_connac_tx_free *free = data; 558 __le32 *tx_info = (__le32 *)(data + sizeof(*free)); 559 struct mt76_dev *mdev = &dev->mt76; 560 struct mt76_txwi_cache *txwi; 561 struct ieee80211_sta *sta = NULL; 562 struct mt76_wcid *wcid = NULL; 563 struct sk_buff *skb, *tmp; --- 65 unchanged lines hidden (view full) --- 629 mt7921_mac_sta_poll(dev); 630 rcu_read_unlock(); 631 632 mt76_worker_schedule(&dev->mt76.tx_worker); 633} 634 635bool mt7921_rx_check(struct mt76_dev *mdev, void *data, int len) 636{ | 556{ 557 struct mt76_connac_tx_free *free = data; 558 __le32 *tx_info = (__le32 *)(data + sizeof(*free)); 559 struct mt76_dev *mdev = &dev->mt76; 560 struct mt76_txwi_cache *txwi; 561 struct ieee80211_sta *sta = NULL; 562 struct mt76_wcid *wcid = NULL; 563 struct sk_buff *skb, *tmp; --- 65 unchanged lines hidden (view full) --- 629 mt7921_mac_sta_poll(dev); 630 rcu_read_unlock(); 631 632 mt76_worker_schedule(&dev->mt76.tx_worker); 633} 634 635bool mt7921_rx_check(struct mt76_dev *mdev, void *data, int len) 636{ |
637 struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76); | 637 struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); |
638 __le32 *rxd = (__le32 *)data; 639 __le32 *end = (__le32 *)&rxd[len / 4]; 640 enum rx_pkt_type type; 641 642 type = le32_get_bits(rxd[0], MT_RXD0_PKT_TYPE); 643 644 switch (type) { 645 case PKT_TYPE_TXRX_NOTIFY: --- 8 unchanged lines hidden (view full) --- 654 return true; 655 } 656} 657EXPORT_SYMBOL_GPL(mt7921_rx_check); 658 659void mt7921_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, 660 struct sk_buff *skb, u32 *info) 661{ | 638 __le32 *rxd = (__le32 *)data; 639 __le32 *end = (__le32 *)&rxd[len / 4]; 640 enum rx_pkt_type type; 641 642 type = le32_get_bits(rxd[0], MT_RXD0_PKT_TYPE); 643 644 switch (type) { 645 case PKT_TYPE_TXRX_NOTIFY: --- 8 unchanged lines hidden (view full) --- 654 return true; 655 } 656} 657EXPORT_SYMBOL_GPL(mt7921_rx_check); 658 659void mt7921_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, 660 struct sk_buff *skb, u32 *info) 661{ |
662 struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76); | 662 struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); |
663 __le32 *rxd = (__le32 *)skb->data; 664 __le32 *end = (__le32 *)&skb->data[skb->len]; 665 enum rx_pkt_type type; 666 u16 flag; 667 668 type = le32_get_bits(rxd[0], MT_RXD0_PKT_TYPE); 669 flag = le32_get_bits(rxd[0], MT_RXD0_PKT_FLAG); 670 --- 25 unchanged lines hidden (view full) --- 696 dev_kfree_skb(skb); 697 break; 698 } 699} 700EXPORT_SYMBOL_GPL(mt7921_queue_rx_skb); 701 702void mt7921_mac_reset_counters(struct mt792x_phy *phy) 703{ | 663 __le32 *rxd = (__le32 *)skb->data; 664 __le32 *end = (__le32 *)&skb->data[skb->len]; 665 enum rx_pkt_type type; 666 u16 flag; 667 668 type = le32_get_bits(rxd[0], MT_RXD0_PKT_TYPE); 669 flag = le32_get_bits(rxd[0], MT_RXD0_PKT_FLAG); 670 --- 25 unchanged lines hidden (view full) --- 696 dev_kfree_skb(skb); 697 break; 698 } 699} 700EXPORT_SYMBOL_GPL(mt7921_queue_rx_skb); 701 702void mt7921_mac_reset_counters(struct mt792x_phy *phy) 703{ |
704 struct mt7921_dev *dev = phy->dev; | 704 struct mt792x_dev *dev = phy->dev; |
705 int i; 706 707 for (i = 0; i < 4; i++) { 708 mt76_rr(dev, MT_TX_AGG_CNT(0, i)); 709 mt76_rr(dev, MT_TX_AGG_CNT2(0, i)); 710 } 711 712 dev->mt76.phy.survey_time = ktime_get_boottime(); --- 6 unchanged lines hidden (view full) --- 719 720 mt76_set(dev, MT_WF_RMAC_MIB_TIME0(0), MT_WF_RMAC_MIB_RXTIME_CLR); 721 mt76_set(dev, MT_WF_RMAC_MIB_AIRTIME0(0), MT_WF_RMAC_MIB_RXTIME_CLR); 722} 723 724void mt7921_mac_set_timing(struct mt792x_phy *phy) 725{ 726 s16 coverage_class = phy->coverage_class; | 705 int i; 706 707 for (i = 0; i < 4; i++) { 708 mt76_rr(dev, MT_TX_AGG_CNT(0, i)); 709 mt76_rr(dev, MT_TX_AGG_CNT2(0, i)); 710 } 711 712 dev->mt76.phy.survey_time = ktime_get_boottime(); --- 6 unchanged lines hidden (view full) --- 719 720 mt76_set(dev, MT_WF_RMAC_MIB_TIME0(0), MT_WF_RMAC_MIB_RXTIME_CLR); 721 mt76_set(dev, MT_WF_RMAC_MIB_AIRTIME0(0), MT_WF_RMAC_MIB_RXTIME_CLR); 722} 723 724void mt7921_mac_set_timing(struct mt792x_phy *phy) 725{ 726 s16 coverage_class = phy->coverage_class; |
727 struct mt7921_dev *dev = phy->dev; | 727 struct mt792x_dev *dev = phy->dev; |
728 u32 val, reg_offset; 729 u32 cck = FIELD_PREP(MT_TIMEOUT_VAL_PLCP, 231) | 730 FIELD_PREP(MT_TIMEOUT_VAL_CCA, 48); 731 u32 ofdm = FIELD_PREP(MT_TIMEOUT_VAL_PLCP, 60) | 732 FIELD_PREP(MT_TIMEOUT_VAL_CCA, 28); 733 bool is_2ghz = phy->mt76->chandef.chan->band == NL80211_BAND_2GHZ; 734 int sifs = is_2ghz ? 10 : 16, offset; 735 --- 30 unchanged lines hidden (view full) --- 766mt7921_phy_get_nf(struct mt792x_phy *phy, int idx) 767{ 768 return 0; 769} 770 771static void 772mt7921_phy_update_channel(struct mt76_phy *mphy, int idx) 773{ | 728 u32 val, reg_offset; 729 u32 cck = FIELD_PREP(MT_TIMEOUT_VAL_PLCP, 231) | 730 FIELD_PREP(MT_TIMEOUT_VAL_CCA, 48); 731 u32 ofdm = FIELD_PREP(MT_TIMEOUT_VAL_PLCP, 60) | 732 FIELD_PREP(MT_TIMEOUT_VAL_CCA, 28); 733 bool is_2ghz = phy->mt76->chandef.chan->band == NL80211_BAND_2GHZ; 734 int sifs = is_2ghz ? 10 : 16, offset; 735 --- 30 unchanged lines hidden (view full) --- 766mt7921_phy_get_nf(struct mt792x_phy *phy, int idx) 767{ 768 return 0; 769} 770 771static void 772mt7921_phy_update_channel(struct mt76_phy *mphy, int idx) 773{ |
774 struct mt7921_dev *dev = container_of(mphy->dev, struct mt7921_dev, mt76); | 774 struct mt792x_dev *dev = container_of(mphy->dev, struct mt792x_dev, mt76); |
775 struct mt792x_phy *phy = (struct mt792x_phy *)mphy->priv; 776 struct mt76_channel_state *state; 777 u64 busy_time, tx_time, rx_time, obss_time; 778 int nf; 779 780 busy_time = mt76_get_field(dev, MT_MIB_SDR9(idx), 781 MT_MIB_SDR9_BUSY_MASK); 782 tx_time = mt76_get_field(dev, MT_MIB_SDR36(idx), --- 14 unchanged lines hidden (view full) --- 797 state->cc_tx += tx_time; 798 state->cc_rx += rx_time + obss_time; 799 state->cc_bss_rx += rx_time; 800 state->noise = -(phy->noise >> 4); 801} 802 803void mt7921_update_channel(struct mt76_phy *mphy) 804{ | 775 struct mt792x_phy *phy = (struct mt792x_phy *)mphy->priv; 776 struct mt76_channel_state *state; 777 u64 busy_time, tx_time, rx_time, obss_time; 778 int nf; 779 780 busy_time = mt76_get_field(dev, MT_MIB_SDR9(idx), 781 MT_MIB_SDR9_BUSY_MASK); 782 tx_time = mt76_get_field(dev, MT_MIB_SDR36(idx), --- 14 unchanged lines hidden (view full) --- 797 state->cc_tx += tx_time; 798 state->cc_rx += rx_time + obss_time; 799 state->cc_bss_rx += rx_time; 800 state->noise = -(phy->noise >> 4); 801} 802 803void mt7921_update_channel(struct mt76_phy *mphy) 804{ |
805 struct mt7921_dev *dev = container_of(mphy->dev, struct mt7921_dev, mt76); | 805 struct mt792x_dev *dev = container_of(mphy->dev, struct mt792x_dev, mt76); |
806 807 if (mt76_connac_pm_wake(mphy, &dev->pm)) 808 return; 809 810 mt7921_phy_update_channel(mphy, 0); 811 /* reset obss airtime */ 812 mt76_set(dev, MT_WF_RMAC_MIB_TIME0(0), MT_WF_RMAC_MIB_RXTIME_CLR); 813 814 mt76_connac_power_save_sched(mphy, &dev->pm); 815} 816EXPORT_SYMBOL_GPL(mt7921_update_channel); 817 818static void 819mt7921_vif_connect_iter(void *priv, u8 *mac, 820 struct ieee80211_vif *vif) 821{ 822 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; | 806 807 if (mt76_connac_pm_wake(mphy, &dev->pm)) 808 return; 809 810 mt7921_phy_update_channel(mphy, 0); 811 /* reset obss airtime */ 812 mt76_set(dev, MT_WF_RMAC_MIB_TIME0(0), MT_WF_RMAC_MIB_RXTIME_CLR); 813 814 mt76_connac_power_save_sched(mphy, &dev->pm); 815} 816EXPORT_SYMBOL_GPL(mt7921_update_channel); 817 818static void 819mt7921_vif_connect_iter(void *priv, u8 *mac, 820 struct ieee80211_vif *vif) 821{ 822 struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; |
823 struct mt7921_dev *dev = mvif->phy->dev; | 823 struct mt792x_dev *dev = mvif->phy->dev; |
824 struct ieee80211_hw *hw = mt76_hw(dev); 825 826 if (vif->type == NL80211_IFTYPE_STATION) 827 ieee80211_disconnect(vif, true); 828 829 mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.wcid, true); 830 mt7921_mcu_set_tx(dev, vif); 831 --- 4 unchanged lines hidden (view full) --- 836 MT76_STA_INFO_STATE_NONE); 837 mt7921_mcu_uni_add_beacon_offload(dev, hw, vif, true); 838 } 839} 840 841/* system error recovery */ 842void mt7921_mac_reset_work(struct work_struct *work) 843{ | 824 struct ieee80211_hw *hw = mt76_hw(dev); 825 826 if (vif->type == NL80211_IFTYPE_STATION) 827 ieee80211_disconnect(vif, true); 828 829 mt76_connac_mcu_uni_add_dev(&dev->mphy, vif, &mvif->sta.wcid, true); 830 mt7921_mcu_set_tx(dev, vif); 831 --- 4 unchanged lines hidden (view full) --- 836 MT76_STA_INFO_STATE_NONE); 837 mt7921_mcu_uni_add_beacon_offload(dev, hw, vif, true); 838 } 839} 840 841/* system error recovery */ 842void mt7921_mac_reset_work(struct work_struct *work) 843{ |
844 struct mt7921_dev *dev = container_of(work, struct mt7921_dev, | 844 struct mt792x_dev *dev = container_of(work, struct mt792x_dev, |
845 reset_work); 846 struct ieee80211_hw *hw = mt76_hw(dev); 847 struct mt76_connac_pm *pm = &dev->pm; 848 int i, ret; 849 850 dev_dbg(dev->mt76.dev, "chip reset\n"); 851 dev->hw_full_reset = true; 852 ieee80211_stop_queues(hw); --- 28 unchanged lines hidden (view full) --- 881 ieee80211_iterate_active_interfaces(hw, 882 IEEE80211_IFACE_ITER_RESUME_ALL, 883 mt7921_vif_connect_iter, NULL); 884 mt76_connac_power_save_sched(&dev->mt76.phy, pm); 885} 886 887void mt7921_reset(struct mt76_dev *mdev) 888{ | 845 reset_work); 846 struct ieee80211_hw *hw = mt76_hw(dev); 847 struct mt76_connac_pm *pm = &dev->pm; 848 int i, ret; 849 850 dev_dbg(dev->mt76.dev, "chip reset\n"); 851 dev->hw_full_reset = true; 852 ieee80211_stop_queues(hw); --- 28 unchanged lines hidden (view full) --- 881 ieee80211_iterate_active_interfaces(hw, 882 IEEE80211_IFACE_ITER_RESUME_ALL, 883 mt7921_vif_connect_iter, NULL); 884 mt76_connac_power_save_sched(&dev->mt76.phy, pm); 885} 886 887void mt7921_reset(struct mt76_dev *mdev) 888{ |
889 struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76); | 889 struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); |
890 struct mt76_connac_pm *pm = &dev->pm; 891 892 if (!dev->hw_init_done) 893 return; 894 895 if (dev->hw_full_reset) 896 return; 897 898 if (pm->suspended) 899 return; 900 901 queue_work(dev->mt76.wq, &dev->reset_work); 902} 903EXPORT_SYMBOL_GPL(mt7921_reset); 904 905void mt7921_mac_update_mib_stats(struct mt792x_phy *phy) 906{ 907 struct mt76_mib_stats *mib = &phy->mib; | 890 struct mt76_connac_pm *pm = &dev->pm; 891 892 if (!dev->hw_init_done) 893 return; 894 895 if (dev->hw_full_reset) 896 return; 897 898 if (pm->suspended) 899 return; 900 901 queue_work(dev->mt76.wq, &dev->reset_work); 902} 903EXPORT_SYMBOL_GPL(mt7921_reset); 904 905void mt7921_mac_update_mib_stats(struct mt792x_phy *phy) 906{ 907 struct mt76_mib_stats *mib = &phy->mib; |
908 struct mt7921_dev *dev = phy->dev; | 908 struct mt792x_dev *dev = phy->dev; |
909 int i, aggr0 = 0, aggr1; 910 u32 val; 911 912 mib->fcs_err_cnt += mt76_get_field(dev, MT_MIB_SDR3(0), 913 MT_MIB_SDR3_FCS_ERR_MASK); 914 mib->ack_fail_cnt += mt76_get_field(dev, MT_MIB_MB_BSDR3(0), 915 MT_MIB_ACK_FAIL_COUNT_MASK); 916 mib->ba_miss_cnt += mt76_get_field(dev, MT_MIB_MB_BSDR2(0), --- 67 unchanged lines hidden (view full) --- 984 985 mt76_tx_status_check(mphy->dev, false); 986 ieee80211_queue_delayed_work(phy->mt76->hw, &mphy->mac_work, 987 MT7921_WATCHDOG_TIME); 988} 989 990void mt7921_pm_wake_work(struct work_struct *work) 991{ | 909 int i, aggr0 = 0, aggr1; 910 u32 val; 911 912 mib->fcs_err_cnt += mt76_get_field(dev, MT_MIB_SDR3(0), 913 MT_MIB_SDR3_FCS_ERR_MASK); 914 mib->ack_fail_cnt += mt76_get_field(dev, MT_MIB_MB_BSDR3(0), 915 MT_MIB_ACK_FAIL_COUNT_MASK); 916 mib->ba_miss_cnt += mt76_get_field(dev, MT_MIB_MB_BSDR2(0), --- 67 unchanged lines hidden (view full) --- 984 985 mt76_tx_status_check(mphy->dev, false); 986 ieee80211_queue_delayed_work(phy->mt76->hw, &mphy->mac_work, 987 MT7921_WATCHDOG_TIME); 988} 989 990void mt7921_pm_wake_work(struct work_struct *work) 991{ |
992 struct mt7921_dev *dev; | 992 struct mt792x_dev *dev; |
993 struct mt76_phy *mphy; 994 | 993 struct mt76_phy *mphy; 994 |
995 dev = (struct mt7921_dev *)container_of(work, struct mt7921_dev, | 995 dev = (struct mt792x_dev *)container_of(work, struct mt792x_dev, |
996 pm.wake_work); 997 mphy = dev->phy.mt76; 998 999 if (!mt7921_mcu_drv_pmctrl(dev)) { 1000 struct mt76_dev *mdev = &dev->mt76; 1001 int i; 1002 1003 if (mt76_is_sdio(mdev)) { --- 13 unchanged lines hidden (view full) --- 1017 } 1018 1019 ieee80211_wake_queues(mphy->hw); 1020 wake_up(&dev->pm.wait); 1021} 1022 1023void mt7921_pm_power_save_work(struct work_struct *work) 1024{ | 996 pm.wake_work); 997 mphy = dev->phy.mt76; 998 999 if (!mt7921_mcu_drv_pmctrl(dev)) { 1000 struct mt76_dev *mdev = &dev->mt76; 1001 int i; 1002 1003 if (mt76_is_sdio(mdev)) { --- 13 unchanged lines hidden (view full) --- 1017 } 1018 1019 ieee80211_wake_queues(mphy->hw); 1020 wake_up(&dev->pm.wait); 1021} 1022 1023void mt7921_pm_power_save_work(struct work_struct *work) 1024{ |
1025 struct mt7921_dev *dev; | 1025 struct mt792x_dev *dev; |
1026 unsigned long delta; 1027 struct mt76_phy *mphy; 1028 | 1026 unsigned long delta; 1027 struct mt76_phy *mphy; 1028 |
1029 dev = (struct mt7921_dev *)container_of(work, struct mt7921_dev, | 1029 dev = (struct mt792x_dev *)container_of(work, struct mt792x_dev, |
1030 pm.ps_work.work); 1031 mphy = dev->phy.mt76; 1032 1033 delta = dev->pm.idle_timeout; 1034 if (test_bit(MT76_HW_SCANNING, &mphy->state) || 1035 test_bit(MT76_HW_SCHED_SCANNING, &mphy->state) || 1036 dev->fw_assert) 1037 goto out; --- 16 unchanged lines hidden (view full) --- 1054 return; 1055 } 1056out: 1057 queue_delayed_work(dev->mt76.wq, &dev->pm.ps_work, delta); 1058} 1059 1060void mt7921_coredump_work(struct work_struct *work) 1061{ | 1030 pm.ps_work.work); 1031 mphy = dev->phy.mt76; 1032 1033 delta = dev->pm.idle_timeout; 1034 if (test_bit(MT76_HW_SCANNING, &mphy->state) || 1035 test_bit(MT76_HW_SCHED_SCANNING, &mphy->state) || 1036 dev->fw_assert) 1037 goto out; --- 16 unchanged lines hidden (view full) --- 1054 return; 1055 } 1056out: 1057 queue_delayed_work(dev->mt76.wq, &dev->pm.ps_work, delta); 1058} 1059 1060void mt7921_coredump_work(struct work_struct *work) 1061{ |
1062 struct mt7921_dev *dev; | 1062 struct mt792x_dev *dev; |
1063 char *dump, *data; 1064 | 1063 char *dump, *data; 1064 |
1065 dev = (struct mt7921_dev *)container_of(work, struct mt7921_dev, | 1065 dev = (struct mt792x_dev *)container_of(work, struct mt792x_dev, |
1066 coredump.work.work); 1067 1068 if (time_is_after_jiffies(dev->coredump.last_activity + 1069 4 * MT76_CONNAC_COREDUMP_TIMEOUT)) { 1070 queue_delayed_work(dev->mt76.wq, &dev->coredump.work, 1071 MT76_CONNAC_COREDUMP_TIMEOUT); 1072 return; 1073 } --- 27 unchanged lines hidden (view full) --- 1101 dev_coredumpv(dev->mt76.dev, dump, MT76_CONNAC_COREDUMP_SZ, 1102 GFP_KERNEL); 1103 1104 mt7921_reset(&dev->mt76); 1105} 1106 1107/* usb_sdio */ 1108static void | 1066 coredump.work.work); 1067 1068 if (time_is_after_jiffies(dev->coredump.last_activity + 1069 4 * MT76_CONNAC_COREDUMP_TIMEOUT)) { 1070 queue_delayed_work(dev->mt76.wq, &dev->coredump.work, 1071 MT76_CONNAC_COREDUMP_TIMEOUT); 1072 return; 1073 } --- 27 unchanged lines hidden (view full) --- 1101 dev_coredumpv(dev->mt76.dev, dump, MT76_CONNAC_COREDUMP_SZ, 1102 GFP_KERNEL); 1103 1104 mt7921_reset(&dev->mt76); 1105} 1106 1107/* usb_sdio */ 1108static void |
1109mt7921_usb_sdio_write_txwi(struct mt7921_dev *dev, struct mt76_wcid *wcid, | 1109mt7921_usb_sdio_write_txwi(struct mt792x_dev *dev, struct mt76_wcid *wcid, |
1110 enum mt76_txq_id qid, struct ieee80211_sta *sta, 1111 struct ieee80211_key_conf *key, int pid, 1112 struct sk_buff *skb) 1113{ 1114 __le32 *txwi = (__le32 *)(skb->data - MT_SDIO_TXD_SIZE); 1115 1116 memset(txwi, 0, MT_SDIO_TXD_SIZE); 1117 mt76_connac2_mac_write_txwi(&dev->mt76, txwi, skb, wcid, key, pid, qid, 0); 1118 skb_push(skb, MT_SDIO_TXD_SIZE); 1119} 1120 1121int mt7921_usb_sdio_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, 1122 enum mt76_txq_id qid, struct mt76_wcid *wcid, 1123 struct ieee80211_sta *sta, 1124 struct mt76_tx_info *tx_info) 1125{ | 1110 enum mt76_txq_id qid, struct ieee80211_sta *sta, 1111 struct ieee80211_key_conf *key, int pid, 1112 struct sk_buff *skb) 1113{ 1114 __le32 *txwi = (__le32 *)(skb->data - MT_SDIO_TXD_SIZE); 1115 1116 memset(txwi, 0, MT_SDIO_TXD_SIZE); 1117 mt76_connac2_mac_write_txwi(&dev->mt76, txwi, skb, wcid, key, pid, qid, 0); 1118 skb_push(skb, MT_SDIO_TXD_SIZE); 1119} 1120 1121int mt7921_usb_sdio_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, 1122 enum mt76_txq_id qid, struct mt76_wcid *wcid, 1123 struct ieee80211_sta *sta, 1124 struct mt76_tx_info *tx_info) 1125{ |
1126 struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76); | 1126 struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); |
1127 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_info->skb); 1128 struct ieee80211_key_conf *key = info->control.hw_key; 1129 struct sk_buff *skb = tx_info->skb; 1130 int err, pad, pktid, type; 1131 1132 if (unlikely(tx_info->skb->len <= ETH_HLEN)) 1133 return -EINVAL; 1134 --- 49 unchanged lines hidden (view full) --- 1184 1185 skb_pull(e->skb, headroom); 1186 mt76_tx_complete_skb(mdev, e->wcid, e->skb); 1187} 1188EXPORT_SYMBOL_GPL(mt7921_usb_sdio_tx_complete_skb); 1189 1190bool mt7921_usb_sdio_tx_status_data(struct mt76_dev *mdev, u8 *update) 1191{ | 1127 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_info->skb); 1128 struct ieee80211_key_conf *key = info->control.hw_key; 1129 struct sk_buff *skb = tx_info->skb; 1130 int err, pad, pktid, type; 1131 1132 if (unlikely(tx_info->skb->len <= ETH_HLEN)) 1133 return -EINVAL; 1134 --- 49 unchanged lines hidden (view full) --- 1184 1185 skb_pull(e->skb, headroom); 1186 mt76_tx_complete_skb(mdev, e->wcid, e->skb); 1187} 1188EXPORT_SYMBOL_GPL(mt7921_usb_sdio_tx_complete_skb); 1189 1190bool mt7921_usb_sdio_tx_status_data(struct mt76_dev *mdev, u8 *update) 1191{ |
1192 struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76); | 1192 struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); |
1193 1194 mt7921_mutex_acquire(dev); 1195 mt7921_mac_sta_poll(dev); 1196 mt7921_mutex_release(dev); 1197 1198 return false; 1199} 1200EXPORT_SYMBOL_GPL(mt7921_usb_sdio_tx_status_data); 1201 1202#if IS_ENABLED(CONFIG_IPV6) 1203void mt7921_set_ipv6_ns_work(struct work_struct *work) 1204{ | 1193 1194 mt7921_mutex_acquire(dev); 1195 mt7921_mac_sta_poll(dev); 1196 mt7921_mutex_release(dev); 1197 1198 return false; 1199} 1200EXPORT_SYMBOL_GPL(mt7921_usb_sdio_tx_status_data); 1201 1202#if IS_ENABLED(CONFIG_IPV6) 1203void mt7921_set_ipv6_ns_work(struct work_struct *work) 1204{ |
1205 struct mt7921_dev *dev = container_of(work, struct mt7921_dev, 1206 ipv6_ns_work); | 1205 struct mt792x_dev *dev = container_of(work, struct mt792x_dev, 1206 ipv6_ns_work); |
1207 struct sk_buff *skb; 1208 int ret = 0; 1209 1210 do { 1211 skb = skb_dequeue(&dev->ipv6_ns_list); 1212 1213 if (!skb) 1214 break; --- 12 unchanged lines hidden --- | 1207 struct sk_buff *skb; 1208 int ret = 0; 1209 1210 do { 1211 skb = skb_dequeue(&dev->ipv6_ns_list); 1212 1213 if (!skb) 1214 break; --- 12 unchanged lines hidden --- |