developer | 5eddc51 | 2023-02-13 16:01:56 +0800 | [diff] [blame^] | 1 | From 8af0601319706314171a8f9ed9117dd3fada484f Mon Sep 17 00:00:00 2001 |
| 2 | From: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 3 | Date: Wed, 18 Jan 2023 11:50:38 +0800 |
| 4 | Subject: [PATCH 3012/3015] wifi: mt76: mt7915: enable PPDU-TxS to host when |
| 5 | wed enable |
| 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 --------------------- |
| 12 | tx.c | 6 ++++++ |
| 13 | 4 files changed, 12 insertions(+), 23 deletions(-) |
| 14 | |
| 15 | diff --git a/mt76_connac_mac.c b/mt76_connac_mac.c |
| 16 | index 05a7a215..d7cca351 100644 |
| 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 |
| 29 | index 92977b98..f24c45f6 100644 |
| 30 | --- a/mt7915/init.c |
| 31 | +++ b/mt7915/init.c |
| 32 | @@ -489,6 +489,12 @@ mt7915_mac_init_band(struct mt7915_dev *dev, u8 band) |
| 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 |
| 46 | index 6dec9d60..87cff5d4 100644 |
| 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 |
| 97 | index a72b7779..36b0f486 100644 |
| 98 | --- a/tx.c |
| 99 | +++ b/tx.c |
| 100 | @@ -120,6 +120,7 @@ mt76_tx_status_skb_add(struct mt76_dev *dev, struct mt76_wcid *wcid, |
| 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 | |
| 108 | @@ -131,6 +132,11 @@ mt76_tx_status_skb_add(struct mt76_dev *dev, struct mt76_wcid *wcid, |
| 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; |
| 120 | -- |
| 121 | 2.18.0 |
| 122 | |