[PATCH v3] wifi: mt76: connac: report per-phy tx and rx byte to tpt_led
Yi-Chia Hsieh
yi-chia.hsieh at mediatek.com
Thu Sep 21 14:05:35 PDT 2023
Fix the issue where the tx and rx byte count is not reported to mac80211
when H/W path is binded.
Signed-off-by: Yi-Chia Hsieh <yi-chia.hsieh at mediatek.com>
Signed-off-by: Money Wang <Money.Wang at mediatek.com>
Signed-off-by: Evelyn Tsai <evelyn.tsai at mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee at mediatek.com>
---
v2: split series
---
This patch is based on "wifi: mac80211: add exported tpt_led_trig function for softmac driver"
v3: rebase and update Signed-off-by
---
.../net/wireless/mediatek/mt76/mt76_connac_mac.c | 10 ++++++----
drivers/net/wireless/mediatek/mt76/mt7915/mmio.c | 5 +++++
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c | 15 +++++++++++----
3 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
index 93402d2c2538..158df5340d59 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
@@ -594,9 +594,15 @@ bool mt76_connac2_mac_fill_txs(struct mt76_dev *dev, struct mt76_wcid *wcid,
txs = le32_to_cpu(txs_data[0]);
+ mphy = mt76_dev_phy(dev, wcid->phy_idx);
+
/* PPDU based reporting */
if (mtk_wed_device_active(&dev->mmio.wed) &&
FIELD_GET(MT_TXS0_TXS_FORMAT, txs) > 1) {
+ __ieee80211_tpt_led_trig_trx(mphy->hw,
+ le32_get_bits(txs_data[5], MT_TXS5_MPDU_TX_BYTE) -
+ le32_get_bits(txs_data[7], MT_TXS7_MPDU_RETRY_BYTE), 0);
+
stats->tx_bytes +=
le32_get_bits(txs_data[5], MT_TXS5_MPDU_TX_BYTE) -
le32_get_bits(txs_data[7], MT_TXS7_MPDU_RETRY_BYTE);
@@ -637,10 +643,6 @@ bool mt76_connac2_mac_fill_txs(struct mt76_dev *dev, struct mt76_wcid *wcid,
cck = true;
fallthrough;
case MT_PHY_TYPE_OFDM:
- mphy = &dev->phy;
- if (wcid->phy_idx == MT_BAND1 && dev->phys[MT_BAND1])
- mphy = dev->phys[MT_BAND1];
-
if (mphy->chandef.chan->band == NL80211_BAND_5GHZ)
sband = &mphy->sband_5g.sband;
else if (mphy->chandef.chan->band == NL80211_BAND_6GHZ)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mmio.c b/drivers/net/wireless/mediatek/mt76/mt7915/mmio.c
index fc7ace638ce8..acb71c4293ea 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mmio.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mmio.c
@@ -657,6 +657,11 @@ static void mt7915_mmio_wed_update_rx_stats(struct mtk_wed_device *wed,
wcid = rcu_dereference(dev->mt76.wcid[idx]);
if (wcid) {
+ struct mt76_phy *mphy = mt76_dev_phy(&dev->mt76, wcid->phy_idx);
+
+ __ieee80211_tpt_led_trig_trx(mphy->hw, 0
+ le32_to_cpu(stats->rx_byte_cnt));
+
wcid->stats.rx_bytes += le32_to_cpu(stats->rx_byte_cnt);
wcid->stats.rx_packets += le32_to_cpu(stats->rx_pkt_cnt);
wcid->stats.rx_errors += le32_to_cpu(stats->rx_err_cnt);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
index bf917beb9439..974795dae1bd 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
@@ -463,6 +463,8 @@ mt7996_mcu_rx_all_sta_info_event(struct mt7996_dev *dev, struct sk_buff *skb)
u8 ac;
u16 wlan_idx;
struct mt76_wcid *wcid;
+ struct mt76_phy *mphy;
+ u32 tx_bytes, rx_bytes;
switch (le16_to_cpu(res->tag)) {
case UNI_ALL_STA_TXRX_ADM_STAT:
@@ -472,11 +474,16 @@ mt7996_mcu_rx_all_sta_info_event(struct mt7996_dev *dev, struct sk_buff *skb)
if (!wcid)
break;
+ mphy = mt76_dev_phy(&dev->mt76, wcid->phy_idx);
for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
- wcid->stats.tx_bytes +=
- le32_to_cpu(res->adm_stat[i].tx_bytes[ac]);
- wcid->stats.rx_bytes +=
- le32_to_cpu(res->adm_stat[i].rx_bytes[ac]);
+ tx_bytes = le32_to_cpu(res->adm_stat[i].tx_bytes[ac]);
+ rx_bytes = le32_to_cpu(res->adm_stat[i].rx_bytes[ac]);
+
+ wcid->stats.tx_bytes += tx_bytes;
+ wcid->stats.rx_bytes += rx_bytes;
+
+ __ieee80211_tpt_led_trig_trx(mphy->hw,
+ tx_bytes, rx_bytes);
}
break;
case UNI_ALL_STA_TXRX_MSDU_COUNT:
--
2.39.0
More information about the Linux-mediatek
mailing list