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