mac.c (8910a4e5ba342ad661acb6f99fa14e0dd809465e) mac.c (48fab5bbef4092d925ab3214773ad12e68807223)
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"

--- 829 unchanged lines hidden (view full) ---

838 struct sk_buff *skb, struct mt76_wcid *wcid,
839 struct ieee80211_key_conf *key, int pid,
840 bool beacon)
841{
842 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
843 struct ieee80211_vif *vif = info->control.vif;
844 struct mt76_phy *mphy = &dev->mphy;
845 u8 p_fmt, q_idx, omac_idx = 0, wmm_idx = 0;
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"

--- 829 unchanged lines hidden (view full) ---

838 struct sk_buff *skb, struct mt76_wcid *wcid,
839 struct ieee80211_key_conf *key, int pid,
840 bool beacon)
841{
842 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
843 struct ieee80211_vif *vif = info->control.vif;
844 struct mt76_phy *mphy = &dev->mphy;
845 u8 p_fmt, q_idx, omac_idx = 0, wmm_idx = 0;
846 bool is_mmio = mt76_is_mmio(&dev->mt76);
847 u32 sz_txd = is_mmio ? MT_TXD_SIZE : MT_SDIO_TXD_SIZE;
846 bool is_8023 = info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP;
847 u16 tx_count = 15;
848 u32 val;
849
850 if (vif) {
851 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
852
853 omac_idx = mvif->omac_idx;
854 wmm_idx = mvif->wmm_idx;
855 }
856
857 if (beacon) {
858 p_fmt = MT_TX_TYPE_FW;
859 q_idx = MT_LMAC_BCN0;
860 } else if (skb_get_queue_mapping(skb) >= MT_TXQ_PSD) {
848 bool is_8023 = info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP;
849 u16 tx_count = 15;
850 u32 val;
851
852 if (vif) {
853 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
854
855 omac_idx = mvif->omac_idx;
856 wmm_idx = mvif->wmm_idx;
857 }
858
859 if (beacon) {
860 p_fmt = MT_TX_TYPE_FW;
861 q_idx = MT_LMAC_BCN0;
862 } else if (skb_get_queue_mapping(skb) >= MT_TXQ_PSD) {
861 p_fmt = MT_TX_TYPE_CT;
863 p_fmt = is_mmio ? MT_TX_TYPE_CT : MT_TX_TYPE_SF;
862 q_idx = MT_LMAC_ALTX0;
863 } else {
864 q_idx = MT_LMAC_ALTX0;
865 } else {
864 p_fmt = MT_TX_TYPE_CT;
866 p_fmt = is_mmio ? MT_TX_TYPE_CT : MT_TX_TYPE_SF;
865 q_idx = wmm_idx * MT7921_MAX_WMM_SETS +
866 mt7921_lmac_mapping(dev, skb_get_queue_mapping(skb));
867 }
868
867 q_idx = wmm_idx * MT7921_MAX_WMM_SETS +
868 mt7921_lmac_mapping(dev, skb_get_queue_mapping(skb));
869 }
870
869 val = FIELD_PREP(MT_TXD0_TX_BYTES, skb->len + MT_TXD_SIZE) |
871 val = FIELD_PREP(MT_TXD0_TX_BYTES, skb->len + sz_txd) |
870 FIELD_PREP(MT_TXD0_PKT_FMT, p_fmt) |
871 FIELD_PREP(MT_TXD0_Q_IDX, q_idx);
872 txwi[0] = cpu_to_le32(val);
873
874 val = MT_TXD1_LONG_FORMAT |
875 FIELD_PREP(MT_TXD1_WLAN_IDX, wcid->idx) |
876 FIELD_PREP(MT_TXD1_OWN_MAC, omac_idx);
877

--- 501 unchanged lines hidden (view full) ---

1379 struct mt7921_dev *dev;
1380 struct mt76_phy *mphy;
1381
1382 dev = (struct mt7921_dev *)container_of(work, struct mt7921_dev,
1383 pm.wake_work);
1384 mphy = dev->phy.mt76;
1385
1386 if (!mt7921_mcu_drv_pmctrl(dev)) {
872 FIELD_PREP(MT_TXD0_PKT_FMT, p_fmt) |
873 FIELD_PREP(MT_TXD0_Q_IDX, q_idx);
874 txwi[0] = cpu_to_le32(val);
875
876 val = MT_TXD1_LONG_FORMAT |
877 FIELD_PREP(MT_TXD1_WLAN_IDX, wcid->idx) |
878 FIELD_PREP(MT_TXD1_OWN_MAC, omac_idx);
879

--- 501 unchanged lines hidden (view full) ---

1381 struct mt7921_dev *dev;
1382 struct mt76_phy *mphy;
1383
1384 dev = (struct mt7921_dev *)container_of(work, struct mt7921_dev,
1385 pm.wake_work);
1386 mphy = dev->phy.mt76;
1387
1388 if (!mt7921_mcu_drv_pmctrl(dev)) {
1389 struct mt76_dev *mdev = &dev->mt76;
1387 int i;
1388
1390 int i;
1391
1389 mt76_for_each_q_rx(&dev->mt76, i)
1390 napi_schedule(&dev->mt76.napi[i]);
1391 mt76_connac_pm_dequeue_skbs(mphy, &dev->pm);
1392 mt7921_mcu_tx_cleanup(dev);
1392 if (mt76_is_sdio(mdev)) {
1393 mt76_connac_pm_dequeue_skbs(mphy, &dev->pm);
1394 mt76_worker_schedule(&mdev->sdio.txrx_worker);
1395 } else {
1396 mt76_for_each_q_rx(mdev, i)
1397 napi_schedule(&mdev->napi[i]);
1398 mt76_connac_pm_dequeue_skbs(mphy, &dev->pm);
1399 mt7921_mcu_tx_cleanup(dev);
1400 }
1393 if (test_bit(MT76_STATE_RUNNING, &mphy->state))
1394 ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work,
1395 MT7921_WATCHDOG_TIME);
1396 }
1397
1398 ieee80211_wake_queues(mphy->hw);
1399 wake_up(&dev->pm.wait);
1400}

--- 75 unchanged lines hidden ---
1401 if (test_bit(MT76_STATE_RUNNING, &mphy->state))
1402 ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work,
1403 MT7921_WATCHDOG_TIME);
1404 }
1405
1406 ieee80211_wake_queues(mphy->hw);
1407 wake_up(&dev->pm.wait);
1408}

--- 75 unchanged lines hidden ---