developer | 1d9da7d | 2023-04-15 12:45:34 +0800 | [diff] [blame] | 1 | From c7800e4fd168a7b2eba45098ba3bc2bb3772859c Mon Sep 17 00:00:00 2001 |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 2 | From: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 3 | Date: Wed, 18 Jan 2023 11:50:38 +0800 |
developer | 2324aa2 | 2023-04-12 11:30:15 +0800 | [diff] [blame] | 4 | Subject: [PATCH 3009/3013] wifi: mt76: mt7915: enable PPDU-TxS to host when |
| 5 | wed enable |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 6 | |
| 7 | Calculate tx bytes and tx retries from PPDU-TxS |
| 8 | --- |
| 9 | mt76_connac_mac.c | 2 -- |
| 10 | mt7915/init.c | 6 ++++++ |
| 11 | mt7915/mmio.c | 21 --------------------- |
developer | 7ce8c7d | 2023-04-10 11:29:30 +0800 | [diff] [blame] | 12 | tx.c | 14 ++++++++++++++ |
| 13 | 4 files changed, 20 insertions(+), 23 deletions(-) |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 14 | |
| 15 | diff --git a/mt76_connac_mac.c b/mt76_connac_mac.c |
developer | 1d9da7d | 2023-04-15 12:45:34 +0800 | [diff] [blame] | 16 | index abcb9a2..5a5861a 100644 |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 17 | --- a/mt76_connac_mac.c |
| 18 | +++ b/mt76_connac_mac.c |
| 19 | @@ -490,8 +490,6 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi, |
| 20 | mt76_connac_lmac_mapping(skb_get_queue_mapping(skb)); |
| 21 | |
| 22 | /* counting non-offloading skbs */ |
| 23 | - wcid->stats.tx_bytes += skb->len; |
| 24 | - |
| 25 | if (is_mt7915(dev)) |
| 26 | wcid->stats.tx_packets++; |
| 27 | } |
| 28 | diff --git a/mt7915/init.c b/mt7915/init.c |
developer | 1d9da7d | 2023-04-15 12:45:34 +0800 | [diff] [blame] | 29 | index 21286a6..6f309d0 100644 |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 30 | --- a/mt7915/init.c |
| 31 | +++ b/mt7915/init.c |
developer | 4f0d84b | 2023-03-03 14:21:44 +0800 | [diff] [blame] | 32 | @@ -503,6 +503,12 @@ mt7915_mac_init_band(struct mt7915_dev *dev, u8 band) |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 33 | set = FIELD_PREP(MT_WTBLOFF_TOP_RSCR_RCPI_MODE, 0) | |
| 34 | FIELD_PREP(MT_WTBLOFF_TOP_RSCR_RCPI_PARAM, 0x3); |
| 35 | mt76_rmw(dev, MT_WTBLOFF_TOP_RSCR(band), mask, set); |
| 36 | + |
| 37 | + /* MT_TXD5_TX_STATUS_HOST (MPDU format) has higher priority than |
| 38 | + * MT_AGG_ACR_PPDU_TXS2H (PPDU format) even though ACR bit is set. |
| 39 | + */ |
| 40 | + if (mtk_wed_device_active(&dev->mt76.mmio.wed)) |
| 41 | + mt76_set(dev, MT_AGG_ACR4(band), MT_AGG_ACR_PPDU_TXS2H); |
| 42 | } |
| 43 | |
| 44 | static void |
| 45 | diff --git a/mt7915/mmio.c b/mt7915/mmio.c |
developer | 1d9da7d | 2023-04-15 12:45:34 +0800 | [diff] [blame] | 46 | index fc9aadb..65ee2af 100644 |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 47 | --- a/mt7915/mmio.c |
| 48 | +++ b/mt7915/mmio.c |
| 49 | @@ -551,7 +551,6 @@ static u32 mt7915_rmw(struct mt76_dev *mdev, u32 offset, u32 mask, u32 val) |
| 50 | static int mt7915_mmio_wed_offload_enable(struct mtk_wed_device *wed) |
| 51 | { |
| 52 | struct mt7915_dev *dev; |
| 53 | - struct mt7915_phy *phy; |
| 54 | int ret; |
| 55 | |
| 56 | dev = container_of(wed, struct mt7915_dev, mt76.mmio.wed); |
| 57 | @@ -565,38 +564,18 @@ static int mt7915_mmio_wed_offload_enable(struct mtk_wed_device *wed) |
| 58 | if (!ret) |
| 59 | return -EAGAIN; |
| 60 | |
| 61 | - phy = &dev->phy; |
| 62 | - mt76_set(dev, MT_AGG_ACR4(phy->mt76->band_idx), MT_AGG_ACR_PPDU_TXS2H); |
| 63 | - |
| 64 | - phy = dev->mt76.phys[MT_BAND1] ? dev->mt76.phys[MT_BAND1]->priv : NULL; |
| 65 | - if (phy) |
| 66 | - mt76_set(dev, MT_AGG_ACR4(phy->mt76->band_idx), |
| 67 | - MT_AGG_ACR_PPDU_TXS2H); |
| 68 | - |
| 69 | return 0; |
| 70 | } |
| 71 | |
| 72 | static void mt7915_mmio_wed_offload_disable(struct mtk_wed_device *wed) |
| 73 | { |
| 74 | struct mt7915_dev *dev; |
| 75 | - struct mt7915_phy *phy; |
| 76 | |
| 77 | dev = container_of(wed, struct mt7915_dev, mt76.mmio.wed); |
| 78 | |
| 79 | spin_lock_bh(&dev->mt76.token_lock); |
| 80 | dev->mt76.token_size = wed->wlan.token_start;//MT7915_TOKEN_SIZE |
| 81 | spin_unlock_bh(&dev->mt76.token_lock); |
| 82 | - |
| 83 | - /* MT_TXD5_TX_STATUS_HOST (MPDU format) has higher priority than |
| 84 | - * MT_AGG_ACR_PPDU_TXS2H (PPDU format) even though ACR bit is set. |
| 85 | - */ |
| 86 | - phy = &dev->phy; |
| 87 | - mt76_clear(dev, MT_AGG_ACR4(phy->mt76->band_idx), MT_AGG_ACR_PPDU_TXS2H); |
| 88 | - |
| 89 | - phy = dev->mt76.phys[MT_BAND1] ? dev->mt76.phys[MT_BAND1]->priv : NULL; |
| 90 | - if (phy) |
| 91 | - mt76_clear(dev, MT_AGG_ACR4(phy->mt76->band_idx), |
| 92 | - MT_AGG_ACR_PPDU_TXS2H); |
| 93 | } |
| 94 | |
| 95 | static void mt7915_mmio_wed_release_rx_buf(struct mtk_wed_device *wed) |
| 96 | diff --git a/tx.c b/tx.c |
developer | 1d9da7d | 2023-04-15 12:45:34 +0800 | [diff] [blame] | 97 | index a72b777..c3c7eb5 100644 |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 98 | --- a/tx.c |
| 99 | +++ b/tx.c |
developer | 6100db2 | 2023-04-05 13:22:26 +0800 | [diff] [blame] | 100 | @@ -120,6 +120,7 @@ mt76_tx_status_skb_add(struct mt76_dev *dev, struct mt76_wcid *wcid, |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 101 | struct sk_buff *skb) |
| 102 | { |
| 103 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
| 104 | + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
| 105 | struct mt76_tx_cb *cb = mt76_tx_skb_cb(skb); |
| 106 | int pid; |
| 107 | |
developer | 6100db2 | 2023-04-05 13:22:26 +0800 | [diff] [blame] | 108 | @@ -131,6 +132,11 @@ mt76_tx_status_skb_add(struct mt76_dev *dev, struct mt76_wcid *wcid, |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 109 | if (info->flags & IEEE80211_TX_CTL_NO_ACK) |
| 110 | return MT_PACKET_ID_NO_ACK; |
| 111 | |
| 112 | + if (mtk_wed_device_active(&dev->mmio.wed) && |
| 113 | + ((info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) || |
| 114 | + ieee80211_is_data(hdr->frame_control))) |
| 115 | + return MT_PACKET_ID_WED; |
| 116 | + |
| 117 | if (!(info->flags & (IEEE80211_TX_CTL_REQ_TX_STATUS | |
| 118 | IEEE80211_TX_CTL_RATE_CTRL_PROBE))) |
| 119 | return MT_PACKET_ID_NO_SKB; |
developer | 7ce8c7d | 2023-04-10 11:29:30 +0800 | [diff] [blame] | 120 | @@ -230,6 +236,7 @@ mt76_tx_check_non_aql(struct mt76_dev *dev, struct mt76_wcid *wcid, |
| 121 | void __mt76_tx_complete_skb(struct mt76_dev *dev, u16 wcid_idx, struct sk_buff *skb, |
| 122 | struct list_head *free_list) |
| 123 | { |
| 124 | + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
| 125 | struct mt76_tx_cb *cb = mt76_tx_skb_cb(skb); |
| 126 | struct ieee80211_tx_status status = { |
| 127 | .skb = skb, |
| 128 | @@ -262,6 +269,13 @@ void __mt76_tx_complete_skb(struct mt76_dev *dev, u16 wcid_idx, struct sk_buff * |
| 129 | if (cb->pktid < MT_PACKET_ID_FIRST) { |
| 130 | hw = mt76_tx_status_get_hw(dev, skb); |
| 131 | status.sta = wcid_to_sta(wcid); |
| 132 | + if (mtk_wed_device_active(&dev->mmio.wed) && |
| 133 | + (info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS)) { |
| 134 | + if (status.sta) { |
| 135 | + info->status.rates[0].idx = -1; |
| 136 | + status.rate = &wcid->rate; |
| 137 | + } |
| 138 | + } |
| 139 | ieee80211_tx_status_ext(hw, &status); |
| 140 | goto out; |
| 141 | } |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 142 | -- |
developer | 7ce8c7d | 2023-04-10 11:29:30 +0800 | [diff] [blame] | 143 | 2.18.0 |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 144 | |