developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame^] | 1 | From 475282f29cf4364626cf6146d78da23640ea7dfd 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 | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 3008/3012] 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 | 22eedcc | 2023-05-03 22:59:35 +0800 | [diff] [blame] | 12 | tx.c | 21 +++++++++++++++++++++ |
| 13 | 4 files changed, 27 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 | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame^] | 16 | index 6cd8c27..8b77e93 100644 |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 17 | --- a/mt76_connac_mac.c |
| 18 | +++ b/mt76_connac_mac.c |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame^] | 19 | @@ -522,8 +522,6 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi, |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 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 | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame^] | 29 | index 8684d7a..9036f44 100644 |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 30 | --- a/mt7915/init.c |
| 31 | +++ b/mt7915/init.c |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame^] | 32 | @@ -507,6 +507,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 | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame^] | 46 | index 1c416bc..bbaaa33 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 | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame^] | 97 | index a87e361..335ddb5 100644 |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 98 | --- a/tx.c |
| 99 | +++ b/tx.c |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame^] | 100 | @@ -122,6 +122,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 | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame^] | 108 | @@ -133,6 +134,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 | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame^] | 120 | @@ -262,8 +268,23 @@ void __mt76_tx_complete_skb(struct mt76_dev *dev, u16 wcid_idx, struct sk_buff * |
developer | 22eedcc | 2023-05-03 22:59:35 +0800 | [diff] [blame] | 121 | #endif |
| 122 | |
developer | 7ce8c7d | 2023-04-10 11:29:30 +0800 | [diff] [blame] | 123 | if (cb->pktid < MT_PACKET_ID_FIRST) { |
developer | 22eedcc | 2023-05-03 22:59:35 +0800 | [diff] [blame] | 124 | + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
| 125 | + struct ieee80211_rate_status rs = {}; |
| 126 | + |
developer | 7ce8c7d | 2023-04-10 11:29:30 +0800 | [diff] [blame] | 127 | hw = mt76_tx_status_get_hw(dev, skb); |
| 128 | status.sta = wcid_to_sta(wcid); |
| 129 | + if (mtk_wed_device_active(&dev->mmio.wed) && |
| 130 | + (info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS)) { |
developer | 22eedcc | 2023-05-03 22:59:35 +0800 | [diff] [blame] | 131 | + info->status.rates[0].idx = -1; |
| 132 | + |
| 133 | + if (status.sta && (wcid->rate.flags || wcid->rate.legacy)) { |
| 134 | + rs.rate_idx = wcid->rate; |
| 135 | + status.rates = &rs; |
| 136 | + status.n_rates = 1; |
| 137 | + } else { |
| 138 | + status.n_rates = 0; |
developer | 7ce8c7d | 2023-04-10 11:29:30 +0800 | [diff] [blame] | 139 | + } |
| 140 | + } |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame^] | 141 | spin_lock_bh(&dev->rx_lock); |
developer | 7ce8c7d | 2023-04-10 11:29:30 +0800 | [diff] [blame] | 142 | ieee80211_tx_status_ext(hw, &status); |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame^] | 143 | spin_unlock_bh(&dev->rx_lock); |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 144 | -- |
developer | 7ce8c7d | 2023-04-10 11:29:30 +0800 | [diff] [blame] | 145 | 2.18.0 |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 146 | |