From patchwork Mon Oct 18 12:14:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 12566239 X-Patchwork-Delegate: nbd@nbd.name Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B107BC433F5 for ; Mon, 18 Oct 2021 12:14:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9EA0361260 for ; Mon, 18 Oct 2021 12:14:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231634AbhJRMQ3 (ORCPT ); Mon, 18 Oct 2021 08:16:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:60996 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231590AbhJRMQ2 (ORCPT ); Mon, 18 Oct 2021 08:16:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C60B8610A3; Mon, 18 Oct 2021 12:14:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634559257; bh=SFAD+EEahY6Ac97fEjAO1MDrUGhiio/uQ67UyBf4ur4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vHPosw6OuwUb8wsvac3i5P6tIP50mTCqN+TVmBOGithnAW/AwlhvaAt6OVi/pCVVD 94inZ9wS/BmY03OLxKha6Bo4FQDLHv8gBQ864DAmMJAz1/bDwunAjTCj7Yz12FUao8 XyaxEX3SkNfPnGeGmrNrwJNBIm0wgvzq7R+4i6C0DDQuRiR6uCeY4BemP5RCmSYDyK N90lnPcM7entfa+6jYNLVPtSgJ5yGwW8ZHklK9B5l864PSOrwjiBy+6yYaVnMXsKbk 71qUfon60h4ZJrnPJ+mo4TJtpP8YK0QA72G8gmUpO+Ie1q01y2dq27N2uevJLVeVk2 3MWzEat2MTzrw== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com, sean.wang@mediatek.com, greearb@candelatech.com Subject: [PATCH 01/10] mt76: move mt76_sta_stats in mt76.h Date: Mon, 18 Oct 2021 14:14:00 +0200 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This is a preliminary patch to add ethtool stats to mt7921 driver. Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt76.h | 7 +++++++ drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 2 +- drivers/net/wireless/mediatek/mt76/mt7915/main.c | 2 +- drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h | 9 +-------- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 0b8f3b7c7a38..efb25fe36d4a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -773,6 +773,13 @@ enum mt76_phy_type { __MT_PHY_TYPE_HE_MAX, }; +struct mt76_sta_stats { + u64 tx_mode[__MT_PHY_TYPE_HE_MAX]; + u64 tx_bw[4]; /* 20, 40, 80, 160 */ + u64 tx_nss[4]; /* 1, 2, 3, 4 */ + u64 tx_mcs[16]; /* mcs idx */ +}; + #define CCK_RATE(_idx, _rate) { \ .bitrate = _rate, \ .flags = IEEE80211_RATE_SHORT_PREAMBLE, \ diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index b992fdd338e2..edf62e0a7ff0 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -1347,7 +1347,7 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, struct sk_buff *skb) static bool mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, - __le32 *txs_data, struct mt7915_sta_stats *stats) + __le32 *txs_data, struct mt76_sta_stats *stats) { struct ieee80211_supported_band *sband; struct mt76_dev *mdev = &dev->mt76; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c index de9bd122e891..b60f5adab6ae 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c @@ -1199,10 +1199,10 @@ static void mt7915_ethtool_worker(void *wi_data, struct ieee80211_sta *sta) { struct mt7915_ethtool_worker_info *wi = wi_data; struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; + struct mt76_sta_stats *mstats = &msta->stats; int ei = wi->initial_stat_idx; int q; u64 *data = wi->data; - struct mt7915_sta_stats *mstats = &msta->stats; if (msta->vif != wi->mvif) return; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h index b09d2c758218..2acede0d5bf2 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -65,13 +65,6 @@ enum mt7915_rxq_id { MT7915_RXQ_MCU_WA_EXT, }; -struct mt7915_sta_stats { - unsigned long tx_mode[__MT_PHY_TYPE_HE_MAX]; /* See mt76_phy_type */ - unsigned long tx_bw[4]; /* 20, 40, 80, 160 */ - unsigned long tx_nss[4]; /* 1, 2, 3, 4 */ - unsigned long tx_mcs[16]; /* mcs idx */ -}; - struct mt7915_sta_key_conf { s8 keyidx; u8 key[16]; @@ -106,7 +99,7 @@ struct mt7915_sta { unsigned long jiffies; unsigned long ampdu_state; - struct mt7915_sta_stats stats; + struct mt76_sta_stats stats; struct mt7915_sta_key_conf bip; From patchwork Mon Oct 18 12:14:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 12566241 X-Patchwork-Delegate: nbd@nbd.name Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1F0EC433FE for ; Mon, 18 Oct 2021 12:14:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B4F686128A for ; Mon, 18 Oct 2021 12:14:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231646AbhJRMQa (ORCPT ); Mon, 18 Oct 2021 08:16:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:32796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231640AbhJRMQa (ORCPT ); Mon, 18 Oct 2021 08:16:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 339E061077; Mon, 18 Oct 2021 12:14:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634559259; bh=D4aJIL8OKCrnpvuEFjyVJubEFoG19VTcRRgPnOLoyLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C6gaWS1PzUS2pLcTkTqtjk33KALyHQPLlFulWTmTVMcy/ymKFHHAMjcD4eNkB4BLf 7Jk2J4woxM9ELOEop1fCE444gF3ubodeOFSp3EY1VvogFCmAVcAGz922SQUhZBOHoC WbJNQNq2tf4wKJNM1HRYR+MslHjddIi+COrQqgx7ew2DrpRdUnCIyYF+ly/mD7TXvX 4vFeYDQNnm52wcjTW+irdIjc77n9t7Ky/YOkUtyUwgsIscMk/Jm3D2tVexP7VOgW1z usTr5YYq33KxjzV1xPWmi+JuNSEJYmjSalzYtoEh2z70kTaHv0zzLGv5VuMdZC+Lgb L/CkfOoM5Aybg== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com, sean.wang@mediatek.com, greearb@candelatech.com Subject: [PATCH 02/10] mt76: mt7921: add sta stats accounting in mt7921_mac_add_txs_skb Date: Mon, 18 Oct 2021 14:14:01 +0200 Message-Id: <4284f5579ab00f3fb591953fc2ac4c90393781cf.1634558817.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This is a preliminary patch to add ethtool stats to mt7921 driver. Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 17 +++++++++++++++-- .../net/wireless/mediatek/mt76/mt7921/mt7921.h | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c index 0659ff290af9..5380e91c5886 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c @@ -1165,14 +1165,16 @@ static bool mt7921_mac_add_txs_skb(struct mt7921_dev *dev, struct mt76_wcid *wcid, int pid, __le32 *txs_data) { + struct mt7921_sta *msta = container_of(wcid, struct mt7921_sta, wcid); + struct mt76_sta_stats *stats = &msta->stats; struct ieee80211_supported_band *sband; struct mt76_dev *mdev = &dev->mt76; struct ieee80211_tx_info *info; struct rate_info rate = {}; struct sk_buff_head list; + u32 txrate, txs, mode; struct sk_buff *skb; bool cck = false; - u32 txrate, txs; mt76_tx_status_lock(mdev, &list); skb = mt76_tx_status_skb_get(mdev, wcid, pid, &list); @@ -1198,7 +1200,13 @@ mt7921_mac_add_txs_skb(struct mt7921_dev *dev, struct mt76_wcid *wcid, int pid, rate.mcs = FIELD_GET(MT_TX_RATE_IDX, txrate); rate.nss = FIELD_GET(MT_TX_RATE_NSS, txrate) + 1; - switch (FIELD_GET(MT_TX_RATE_MODE, txrate)) { + if (rate.nss - 1 < ARRAY_SIZE(stats->tx_nss)) + stats->tx_nss[rate.nss - 1]++; + if (rate.mcs < ARRAY_SIZE(stats->tx_mcs)) + stats->tx_mcs[rate.mcs]++; + + mode = FIELD_GET(MT_TX_RATE_MODE, txrate); + switch (mode) { case MT_PHY_TYPE_CCK: cck = true; fallthrough; @@ -1241,19 +1249,24 @@ mt7921_mac_add_txs_skb(struct mt7921_dev *dev, struct mt76_wcid *wcid, int pid, default: goto out; } + stats->tx_mode[mode]++; switch (FIELD_GET(MT_TXS0_BW, txs)) { case IEEE80211_STA_RX_BW_160: rate.bw = RATE_INFO_BW_160; + stats->tx_bw[3]++; break; case IEEE80211_STA_RX_BW_80: rate.bw = RATE_INFO_BW_80; + stats->tx_bw[2]++; break; case IEEE80211_STA_RX_BW_40: rate.bw = RATE_INFO_BW_40; + stats->tx_bw[1]++; break; default: rate.bw = RATE_INFO_BW_20; + stats->tx_bw[0]++; break; } wcid->rate = rate; diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h index e14b86b1c6d1..be9da985d129 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h @@ -81,6 +81,7 @@ struct mt7921_sta { unsigned long last_txs; unsigned long ampdu_state; + struct mt76_sta_stats stats; struct mt7921_sta_key_conf bip; }; From patchwork Mon Oct 18 12:14:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 12566243 X-Patchwork-Delegate: nbd@nbd.name Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D4DDC433EF for ; Mon, 18 Oct 2021 12:14:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2937F6128B for ; Mon, 18 Oct 2021 12:14:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231640AbhJRMQc (ORCPT ); Mon, 18 Oct 2021 08:16:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:32812 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231590AbhJRMQb (ORCPT ); Mon, 18 Oct 2021 08:16:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 95B0560FC3; Mon, 18 Oct 2021 12:14:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634559260; bh=kIFsICiYIMMZqothnYWoJoywfwoJtIP7v5L+4FE5g7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UX1i/tnaTs/d8BPKeJlfmieb1jobUT4YzgdvT0fDXw4/bTSkU6b0EqVR32IzmNdDO stiWI5QgRi9oHxXV7eS+WXxhtyqbCXaNuIzaHI47ZEjUXF6gGzxhrYO5oAYSUZilJq m9MctqrYxGXIX0KvxirzXiNjeBExog8aN/DIzkPbmlr3mwNGuJjeCa/RJ6vzPaWA33 OKrTO1x9ELIptqr4hXf7cp4HytvdPjhfjok6i9f7dRQN+Ghdcr+QBdIi0zZfpNQBtm kryhZs1AMOcjtB/hdlHF3Swyvh/DC/7ImRRc1FvTj32m/sU9TghsdBIjNYgzJaiDUX KmxwDyYzZD3+A== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com, sean.wang@mediatek.com, greearb@candelatech.com Subject: [PATCH 03/10] mt76: mt7921: add some more MIB counters Date: Mon, 18 Oct 2021 14:14:02 +0200 Message-Id: <3473b16000edd7cd44bf468f7d32d0f9b5c27ca7.1634558817.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This is a preliminary patch to introduce ethtool stats support to mt7921 driver. Signed-off-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt7921/mac.c | 26 ++++++++++++++++- .../wireless/mediatek/mt76/mt7921/mt7921.h | 18 ++++++++++++ .../net/wireless/mediatek/mt76/mt7921/regs.h | 28 +++++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c index 5380e91c5886..f9b2b17be454 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c @@ -1662,6 +1662,7 @@ void mt7921_mac_update_mib_stats(struct mt7921_phy *phy) struct mt7921_dev *dev = phy->dev; struct mib_stats *mib = &phy->mib; int i, aggr0 = 0, aggr1; + u32 val; mib->fcs_err_cnt += mt76_get_field(dev, MT_MIB_SDR3(0), MT_MIB_SDR3_FCS_ERR_MASK); @@ -1674,8 +1675,31 @@ void mt7921_mac_update_mib_stats(struct mt7921_phy *phy) mib->rts_retries_cnt += mt76_get_field(dev, MT_MIB_MB_BSDR1(0), MT_MIB_RTS_FAIL_COUNT_MASK); + mib->tx_ampdu_cnt += mt76_rr(dev, MT_MIB_SDR12(0)); + mib->tx_mpdu_attempts_cnt += mt76_rr(dev, MT_MIB_SDR14(0)); + mib->tx_mpdu_success_cnt += mt76_rr(dev, MT_MIB_SDR15(0)); + + val = mt76_rr(dev, MT_MIB_SDR32(0)); + mib->tx_pkt_ebf_cnt += FIELD_GET(MT_MIB_SDR9_EBF_CNT_MASK, val); + mib->tx_pkt_ibf_cnt += FIELD_GET(MT_MIB_SDR9_IBF_CNT_MASK, val); + + val = mt76_rr(dev, MT_ETBF_TX_APP_CNT(0)); + mib->tx_bf_ibf_ppdu_cnt += FIELD_GET(MT_ETBF_TX_IBF_CNT, val); + mib->tx_bf_ebf_ppdu_cnt += FIELD_GET(MT_ETBF_TX_EBF_CNT, val); + + val = mt76_rr(dev, MT_ETBF_RX_FB_CNT(0)); + mib->tx_bf_rx_fb_all_cnt += FIELD_GET(MT_ETBF_RX_FB_ALL, val); + mib->tx_bf_rx_fb_he_cnt += FIELD_GET(MT_ETBF_RX_FB_HE, val); + mib->tx_bf_rx_fb_vht_cnt += FIELD_GET(MT_ETBF_RX_FB_VHT, val); + mib->tx_bf_rx_fb_ht_cnt += FIELD_GET(MT_ETBF_RX_FB_HT, val); + + mib->rx_mpdu_cnt += mt76_rr(dev, MT_MIB_SDR5(0)); + mib->rx_ampdu_cnt += mt76_rr(dev, MT_MIB_SDR22(0)); + mib->rx_ampdu_bytes_cnt += mt76_rr(dev, MT_MIB_SDR23(0)); + mib->rx_ba_cnt += mt76_rr(dev, MT_MIB_SDR31(0)); + for (i = 0, aggr1 = aggr0 + 4; i < 4; i++) { - u32 val, val2; + u32 val2; val = mt76_rr(dev, MT_TX_AGG_CNT(0, i)); val2 = mt76_rr(dev, MT_TX_AGG_CNT2(0, i)); diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h index be9da985d129..3da9261809d3 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h @@ -107,6 +107,24 @@ struct mib_stats { u32 rts_cnt; u32 rts_retries_cnt; u32 ba_miss_cnt; + + u32 tx_bf_ibf_ppdu_cnt; + u32 tx_bf_ebf_ppdu_cnt; + u32 tx_bf_rx_fb_all_cnt; + u32 tx_bf_rx_fb_he_cnt; + u32 tx_bf_rx_fb_vht_cnt; + u32 tx_bf_rx_fb_ht_cnt; + + u32 tx_ampdu_cnt; + u32 tx_mpdu_attempts_cnt; + u32 tx_mpdu_success_cnt; + u32 tx_pkt_ebf_cnt; + u32 tx_pkt_ibf_cnt; + + u32 rx_mpdu_cnt; + u32 rx_ampdu_cnt; + u32 rx_ampdu_bytes_cnt; + u32 rx_ba_cnt; }; struct mt7921_phy { diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/regs.h b/drivers/net/wireless/mediatek/mt76/mt7921/regs.h index 26fb11823762..80f23f1b835a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/regs.h +++ b/drivers/net/wireless/mediatek/mt76/mt7921/regs.h @@ -92,6 +92,20 @@ #define MT_LPON_TCR_SW_MODE GENMASK(1, 0) #define MT_LPON_TCR_SW_WRITE BIT(0) +/* ETBF: band 0(0x24000), band 1(0xa4000) */ +#define MT_WF_ETBF_BASE(_band) ((_band) ? 0xa4000 : 0x24000) +#define MT_WF_ETBF(_band, ofs) (MT_WF_ETBF_BASE(_band) + (ofs)) + +#define MT_ETBF_TX_APP_CNT(_band) MT_WF_ETBF(_band, 0x150) +#define MT_ETBF_TX_IBF_CNT GENMASK(31, 16) +#define MT_ETBF_TX_EBF_CNT GENMASK(15, 0) + +#define MT_ETBF_RX_FB_CNT(_band) MT_WF_ETBF(_band, 0x158) +#define MT_ETBF_RX_FB_ALL GENMASK(31, 24) +#define MT_ETBF_RX_FB_HE GENMASK(23, 16) +#define MT_ETBF_RX_FB_VHT GENMASK(15, 8) +#define MT_ETBF_RX_FB_HT GENMASK(7, 0) + /* MIB: band 0(0x24800), band 1(0xa4800) */ #define MT_WF_MIB_BASE(_band) ((_band) ? 0xa4800 : 0x24800) #define MT_WF_MIB(_band, ofs) (MT_WF_MIB_BASE(_band) + (ofs)) @@ -103,12 +117,26 @@ #define MT_MIB_SDR3(_band) MT_WF_MIB(_band, 0x698) #define MT_MIB_SDR3_FCS_ERR_MASK GENMASK(31, 16) +#define MT_MIB_SDR5(_band) MT_WF_MIB(_band, 0x780) + #define MT_MIB_SDR9(_band) MT_WF_MIB(_band, 0x02c) #define MT_MIB_SDR9_BUSY_MASK GENMASK(23, 0) +#define MT_MIB_SDR12(_band) MT_WF_MIB(_band, 0x558) +#define MT_MIB_SDR14(_band) MT_WF_MIB(_band, 0x564) +#define MT_MIB_SDR15(_band) MT_WF_MIB(_band, 0x568) + #define MT_MIB_SDR16(_band) MT_WF_MIB(_band, 0x048) #define MT_MIB_SDR16_BUSY_MASK GENMASK(23, 0) +#define MT_MIB_SDR22(_band) MT_WF_MIB(_band, 0x770) +#define MT_MIB_SDR23(_band) MT_WF_MIB(_band, 0x774) +#define MT_MIB_SDR31(_band) MT_WF_MIB(_band, 0x55c) + +#define MT_MIB_SDR32(_band) MT_WF_MIB(_band, 0x7a8) +#define MT_MIB_SDR9_IBF_CNT_MASK GENMASK(31, 16) +#define MT_MIB_SDR9_EBF_CNT_MASK GENMASK(15, 0) + #define MT_MIB_SDR34(_band) MT_WF_MIB(_band, 0x090) #define MT_MIB_MU_BF_TX_CNT GENMASK(15, 0) From patchwork Mon Oct 18 12:14:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 12566245 X-Patchwork-Delegate: nbd@nbd.name Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75ACFC433FE for ; Mon, 18 Oct 2021 12:14:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 571DF60FDA for ; Mon, 18 Oct 2021 12:14:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231590AbhJRMQf (ORCPT ); Mon, 18 Oct 2021 08:16:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:32834 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231648AbhJRMQd (ORCPT ); Mon, 18 Oct 2021 08:16:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 03C2661260; Mon, 18 Oct 2021 12:14:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634559262; bh=di/hH35V6U8DC8KDbbG2H1e59cAQL6hq/mjFY/TI8qQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CmlVknqTI/S4l7Iq8wQ7MSmpVeUKrcxsmiPEJn3yBg6BOaYF+GFEeuQNpj86llbke yKMksaIM/p2CKva9GiGf5hT5u2tXV2TtIoyInhGlpvvdRinEKm6MFFvk+5bUNSpLLi kezxLrIacDVgXll4X4pZRP1hajgWjEoo8TxuKyigdDbWL7uglBwoPa9p+oAaryBxjH 79uf/W3EIgJP6brRQHkxLSh9+kmx1QUa+3GLoegDwoYiWzZ7FOWQQ0WmiStipiIlen kuw8F3fsx7g+xRiizpfbhBisW4UfxSNHDol1Y+qqEYiEZXBZftqIXlOe1Fy98001XD 3sYevEI6UcM0A== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com, sean.wang@mediatek.com, greearb@candelatech.com Subject: [PATCH 04/10] mt76: mt7921: introduce stats reporting through ethtool Date: Mon, 18 Oct 2021 14:14:03 +0200 Message-Id: <73cd0a917797bd9db9527981b5617e738e38d0ec.1634558817.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Similar to mt7915 driver, add tx/rx statistics reporting through ethtool. Signed-off-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt7921/main.c | 118 +++++++++++++++++- 1 file changed, 117 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index c51266e40cb4..342ec85e7f1a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -852,13 +852,126 @@ mt7921_get_stats(struct ieee80211_hw *hw, stats->dot11FCSErrorCount = mib->fcs_err_cnt; stats->dot11ACKFailureCount = mib->ack_fail_cnt; - memset(mib, 0, sizeof(*mib)); + memset(mib, 0, offsetof(struct mib_stats, ba_miss_cnt)); mt7921_mutex_release(phy->dev); return 0; } +static const char mt7921_gstrings_stats[][ETH_GSTRING_LEN] = { + /* tx counters */ + "tx_ampdu_cnt", + "tx_mpdu_attempts", + "tx_mpdu_success", + "tx_pkt_ebf_cnt", + "tx_pkt_ibf_cnt", + "tx_ampdu_len:0-1", + "tx_ampdu_len:2-10", + "tx_ampdu_len:11-19", + "tx_ampdu_len:20-28", + "tx_ampdu_len:29-37", + "tx_ampdu_len:38-46", + "tx_ampdu_len:47-55", + "tx_ampdu_len:56-79", + "tx_ampdu_len:80-103", + "tx_ampdu_len:104-127", + "tx_ampdu_len:128-151", + "tx_ampdu_len:152-175", + "tx_ampdu_len:176-199", + "tx_ampdu_len:200-223", + "tx_ampdu_len:224-247", + "ba_miss_count", + "tx_beamformer_ppdu_iBF", + "tx_beamformer_ppdu_eBF", + "tx_beamformer_rx_feedback_all", + "tx_beamformer_rx_feedback_he", + "tx_beamformer_rx_feedback_vht", + "tx_beamformer_rx_feedback_ht", + "tx_msdu_pack_1", + "tx_msdu_pack_2", + "tx_msdu_pack_3", + "tx_msdu_pack_4", + "tx_msdu_pack_5", + "tx_msdu_pack_6", + "tx_msdu_pack_7", + "tx_msdu_pack_8", + /* rx counters */ + "rx_mpdu_cnt", + "rx_ampdu_cnt", + "rx_ampdu_bytes_cnt", + "rx_ba_cnt" +}; + +static void +mt7921_get_et_strings(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + u32 sset, u8 *data) +{ + if (sset != ETH_SS_STATS) + return; + + memcpy(data, *mt7921_gstrings_stats, sizeof(mt7921_gstrings_stats)); +} + +static int +mt7921_get_et_sset_count(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + int sset) +{ + return sset == ETH_SS_STATS ? ARRAY_SIZE(mt7921_gstrings_stats) : 0; +} + +static +void mt7921_get_et_stats(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ethtool_stats *stats, u64 *data) +{ + struct mt7921_phy *phy = mt7921_hw_phy(hw); + struct mt7921_dev *dev = phy->dev; + struct mib_stats *mib = &phy->mib; + int i, ei = 0; + + mt7921_mutex_acquire(dev); + + mt7921_mac_update_mib_stats(phy); + + data[ei++] = mib->tx_ampdu_cnt; + data[ei++] = mib->tx_mpdu_attempts_cnt; + data[ei++] = mib->tx_mpdu_success_cnt; + data[ei++] = mib->tx_pkt_ebf_cnt; + data[ei++] = mib->tx_pkt_ibf_cnt; + + /* Tx ampdu stat */ + for (i = 0; i < 15; i++) + data[ei++] = dev->mt76.aggr_stats[i]; + + data[ei++] = phy->mib.ba_miss_cnt; + + /* Tx Beamformer monitor */ + data[ei++] = mib->tx_bf_ibf_ppdu_cnt; + data[ei++] = mib->tx_bf_ebf_ppdu_cnt; + + /* Tx Beamformer Rx feedback monitor */ + data[ei++] = mib->tx_bf_rx_fb_all_cnt; + data[ei++] = mib->tx_bf_rx_fb_he_cnt; + data[ei++] = mib->tx_bf_rx_fb_vht_cnt; + data[ei++] = mib->tx_bf_rx_fb_ht_cnt; + + /* Tx amsdu info (pack-count histogram) */ + for (i = 0; i < 8; i++) + data[ei++] = mt76_rr(dev, MT_PLE_AMSDU_PACK_MSDU_CNT(i)); + + /* rx counters */ + data[ei++] = mib->rx_mpdu_cnt; + data[ei++] = mib->rx_ampdu_cnt; + data[ei++] = mib->rx_ampdu_bytes_cnt; + data[ei++] = mib->rx_ba_cnt; + + mt7921_mutex_release(dev); + + if (ei != ARRAY_SIZE(mt7921_gstrings_stats)) + dev_err(dev->mt76.dev, "ei: %d SSTATS_LEN: %lu", + ei, ARRAY_SIZE(mt7921_gstrings_stats)); +} + static u64 mt7921_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { @@ -1228,6 +1341,9 @@ const struct ieee80211_ops mt7921_ops = { .release_buffered_frames = mt76_release_buffered_frames, .get_txpower = mt76_get_txpower, .get_stats = mt7921_get_stats, + .get_et_sset_count = mt7921_get_et_sset_count, + .get_et_strings = mt7921_get_et_strings, + .get_et_stats = mt7921_get_et_stats, .get_tsf = mt7921_get_tsf, .set_tsf = mt7921_set_tsf, .get_survey = mt76_get_survey, From patchwork Mon Oct 18 12:14:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 12566247 X-Patchwork-Delegate: nbd@nbd.name Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0D50C4332F for ; Mon, 18 Oct 2021 12:14:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9D8ED61077 for ; Mon, 18 Oct 2021 12:14:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231645AbhJRMQf (ORCPT ); Mon, 18 Oct 2021 08:16:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:32856 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231660AbhJRMQf (ORCPT ); Mon, 18 Oct 2021 08:16:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 666EB6128A; Mon, 18 Oct 2021 12:14:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634559263; bh=5rTcXXl+SuvkV4iycOXmKVSS6svZHps12Ugq9RGkDFU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sk6b4aomZBiqCS+Xw9WSdMIMeFsQj8pJBJnwJmErzyzXBeUAjPDteORnrJs5n/+LC jChwxlOC/HQo7z8EgE/c8fqXFGMvF/tEUqdps8xXydn4c4/L6yIWL3HSWQXPYL+Ue8 zJvqPp7gc5aGqIWwwK9zs7BYJU/UKSYkeoxtbhNE7f+09I49ateZKAySK+/JsYdey7 1drIaw+aSUm5el1K7LLlWFgzDPBTNz70h6Is2b28cz+QMVxx3uZZB6C6azFoz1Gsvn BouVXIvD8l8wqjp/qXCKEd0c7exZnDQ9kKHJGVef3cb6uzbZ0n4GWsKk/LbMKslM+r LsKdSOQnj+MWA== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com, sean.wang@mediatek.com, greearb@candelatech.com Subject: [PATCH 05/10] mt76: mt7921: move tx amsdu stats in mib_stats Date: Mon, 18 Oct 2021 14:14:04 +0200 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Move tx_amsdu histogram stats in mib_stats structure since registers are clear-on-read Signed-off-by: Lorenzo Bianconi --- .../wireless/mediatek/mt76/mt7921/debugfs.c | 27 +++++++++---------- .../net/wireless/mediatek/mt76/mt7921/mac.c | 6 +++++ .../net/wireless/mediatek/mt76/mt7921/main.c | 4 +-- .../wireless/mediatek/mt76/mt7921/mt7921.h | 3 +++ 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c index 71aabb632e05..b7cf4cf4da98 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c @@ -95,30 +95,27 @@ static int mt7921_tx_stats_show(struct seq_file *file, void *data) { struct mt7921_dev *dev = file->private; - int stat[8], i, n; + struct mt7921_phy *phy = &dev->phy; + struct mib_stats *mib = &phy->mib; + int i; mt7921_mutex_acquire(dev); - mt7921_ampdu_stat_read_phy(&dev->phy, file); + mt7921_ampdu_stat_read_phy(phy, file); - /* Tx amsdu info */ seq_puts(file, "Tx MSDU stat:\n"); - for (i = 0, n = 0; i < ARRAY_SIZE(stat); i++) { - stat[i] = mt76_rr(dev, MT_PLE_AMSDU_PACK_MSDU_CNT(i)); - n += stat[i]; - } - - mt7921_mutex_release(dev); - - for (i = 0; i < ARRAY_SIZE(stat); i++) { - seq_printf(file, "AMSDU pack count of %d MSDU in TXD: 0x%x ", - i + 1, stat[i]); - if (n != 0) - seq_printf(file, "(%d%%)\n", stat[i] * 100 / n); + for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) { + seq_printf(file, "AMSDU pack count of %d MSDU in TXD: %8d ", + i + 1, mib->tx_amsdu[i]); + if (mib->tx_amsdu_cnt) + seq_printf(file, "(%3d%%)\n", + mib->tx_amsdu[i] * 100 / mib->tx_amsdu_cnt); else seq_puts(file, "\n"); } + mt7921_mutex_release(dev); + return 0; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c index f9b2b17be454..317fc9f05cb6 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c @@ -1698,6 +1698,12 @@ void mt7921_mac_update_mib_stats(struct mt7921_phy *phy) mib->rx_ampdu_bytes_cnt += mt76_rr(dev, MT_MIB_SDR23(0)); mib->rx_ba_cnt += mt76_rr(dev, MT_MIB_SDR31(0)); + for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) { + val = mt76_rr(dev, MT_PLE_AMSDU_PACK_MSDU_CNT(i)); + mib->tx_amsdu[i] += val; + mib->tx_amsdu_cnt += val; + } + for (i = 0, aggr1 = aggr0 + 4; i < 4; i++) { u32 val2; diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index 342ec85e7f1a..39ec3e62748b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -956,8 +956,8 @@ void mt7921_get_et_stats(struct ieee80211_hw *hw, struct ieee80211_vif *vif, data[ei++] = mib->tx_bf_rx_fb_ht_cnt; /* Tx amsdu info (pack-count histogram) */ - for (i = 0; i < 8; i++) - data[ei++] = mt76_rr(dev, MT_PLE_AMSDU_PACK_MSDU_CNT(i)); + for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) + data[ei++] = mib->tx_amsdu[i]; /* rx counters */ data[ei++] = mib->rx_mpdu_cnt; diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h index 3da9261809d3..b846994e58a7 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h @@ -125,6 +125,9 @@ struct mib_stats { u32 rx_ampdu_cnt; u32 rx_ampdu_bytes_cnt; u32 rx_ba_cnt; + + u32 tx_amsdu[8]; + u32 tx_amsdu_cnt; }; struct mt7921_phy { From patchwork Mon Oct 18 12:14:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 12566249 X-Patchwork-Delegate: nbd@nbd.name Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAC66C433F5 for ; Mon, 18 Oct 2021 12:14:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9641161077 for ; Mon, 18 Oct 2021 12:14:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231615AbhJRMQg (ORCPT ); Mon, 18 Oct 2021 08:16:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:32874 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231648AbhJRMQf (ORCPT ); Mon, 18 Oct 2021 08:16:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CA7B36128E; Mon, 18 Oct 2021 12:14:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634559264; bh=0L63P3k7sRvPBaF3YsZPzvDK6AR2+06BgB+z85eyb+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ap7S043M85kohwRxE7rRJ6IuMYO4F2uPl4kPNTb0gnqd22IcAGwMU4w3q0q3GouOu 1DdWri9X+bOiAaNlclaBB5YUBgF3U4mA7nJXnDxad4gYN5d0AB/iKh6b7SgraZaDrL yQuw3JZKdxw7a1aIsA0apt1E4PpI8r7WIpVKIF5SCtYYzDT6R8BOYOhr6bqM9wP25n 6XmbuVZ4dhvYDmotnKUtH8DkU2VT8z8OQlrX7S4vPSzEphaHoSw+9jHDCCxHbuMKBA Y/t+91QHOBP6N248dEWr1HKl2pRCufwDQuh5dfNMcWCv5/naHuES2dlBb9kfdUy1an 5wXBWDDZ9s9XQ== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com, sean.wang@mediatek.com, greearb@candelatech.com Subject: [PATCH 06/10] mt76: move mt76_ethtool_worker_info in mt76 module Date: Mon, 18 Oct 2021 14:14:05 +0200 Message-Id: <9c16b69d1afe007739dbd18ba06fbdeb694d6f8c.1634558817.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Move mt76_ethtool_worker_info in common code in order to be reused in mt7921 driver. Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mac80211.c | 28 +++++++++++ drivers/net/wireless/mediatek/mt76/mt76.h | 10 ++++ .../net/wireless/mediatek/mt76/mt7915/main.c | 47 +++---------------- 3 files changed, 45 insertions(+), 40 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c index 766681a4f89e..62807dc311c1 100644 --- a/drivers/net/wireless/mediatek/mt76/mac80211.c +++ b/drivers/net/wireless/mediatek/mt76/mac80211.c @@ -1508,3 +1508,31 @@ u16 mt76_calculate_default_rate(struct mt76_phy *phy, int rateidx) return rate->hw_value; } EXPORT_SYMBOL_GPL(mt76_calculate_default_rate); + +void mt76_ethtool_worker(struct mt76_ethtool_worker_info *wi, + struct mt76_sta_stats *stats) +{ + int i, ei = wi->initial_stat_idx; + u64 *data = wi->data; + + wi->sta_count++; + + data[ei++] += stats->tx_mode[MT_PHY_TYPE_CCK]; + data[ei++] += stats->tx_mode[MT_PHY_TYPE_OFDM]; + data[ei++] += stats->tx_mode[MT_PHY_TYPE_HT]; + data[ei++] += stats->tx_mode[MT_PHY_TYPE_HT_GF]; + data[ei++] += stats->tx_mode[MT_PHY_TYPE_VHT]; + data[ei++] += stats->tx_mode[MT_PHY_TYPE_HE_SU]; + data[ei++] += stats->tx_mode[MT_PHY_TYPE_HE_EXT_SU]; + data[ei++] += stats->tx_mode[MT_PHY_TYPE_HE_TB]; + data[ei++] += stats->tx_mode[MT_PHY_TYPE_HE_MU]; + + for (i = 0; i < ARRAY_SIZE(stats->tx_bw); i++) + data[ei++] += stats->tx_bw[i]; + + for (i = 0; i < 12; i++) + data[ei++] += stats->tx_mcs[i]; + + wi->worker_stat_count = ei - wi->initial_stat_idx; +} +EXPORT_SYMBOL_GPL(mt76_ethtool_worker); diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index efb25fe36d4a..0f47d0a726dd 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -780,6 +780,14 @@ struct mt76_sta_stats { u64 tx_mcs[16]; /* mcs idx */ }; +struct mt76_ethtool_worker_info { + u64 *data; + int idx; + int initial_stat_idx; + int worker_stat_count; + int sta_count; +}; + #define CCK_RATE(_idx, _rate) { \ .bitrate = _rate, \ .flags = IEEE80211_RATE_SHORT_PREAMBLE, \ @@ -1235,6 +1243,8 @@ mt76u_bulk_msg(struct mt76_dev *dev, void *data, int len, int *actual_len, return usb_bulk_msg(udev, pipe, data, len, actual_len, timeout); } +void mt76_ethtool_worker(struct mt76_ethtool_worker_info *wi, + struct mt76_sta_stats *stats); int mt76_skb_adjust_pad(struct sk_buff *skb, int pad); int mt76u_vendor_request(struct mt76_dev *dev, u8 req, u8 req_type, u16 val, u16 offset, diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c index b60f5adab6ae..4d5009f6954b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c @@ -1187,45 +1187,15 @@ int mt7915_get_et_sset_count(struct ieee80211_hw *hw, return 0; } -struct mt7915_ethtool_worker_info { - u64 *data; - struct mt7915_vif *mvif; - int initial_stat_idx; - int worker_stat_count; - int sta_count; -}; - static void mt7915_ethtool_worker(void *wi_data, struct ieee80211_sta *sta) { - struct mt7915_ethtool_worker_info *wi = wi_data; + struct mt76_ethtool_worker_info *wi = wi_data; struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; - struct mt76_sta_stats *mstats = &msta->stats; - int ei = wi->initial_stat_idx; - int q; - u64 *data = wi->data; - if (msta->vif != wi->mvif) + if (msta->vif->idx != wi->idx) return; - wi->sta_count++; - - data[ei++] += mstats->tx_mode[MT_PHY_TYPE_CCK]; - data[ei++] += mstats->tx_mode[MT_PHY_TYPE_OFDM]; - data[ei++] += mstats->tx_mode[MT_PHY_TYPE_HT]; - data[ei++] += mstats->tx_mode[MT_PHY_TYPE_HT_GF]; - data[ei++] += mstats->tx_mode[MT_PHY_TYPE_VHT]; - data[ei++] += mstats->tx_mode[MT_PHY_TYPE_HE_SU]; - data[ei++] += mstats->tx_mode[MT_PHY_TYPE_HE_EXT_SU]; - data[ei++] += mstats->tx_mode[MT_PHY_TYPE_HE_TB]; - data[ei++] += mstats->tx_mode[MT_PHY_TYPE_HE_MU]; - - for (q = 0; q < ARRAY_SIZE(mstats->tx_bw); q++) - data[ei++] += mstats->tx_bw[q]; - - for (q = 0; q < 12; q++) - data[ei++] += mstats->tx_mcs[q]; - - wi->worker_stat_count = ei - wi->initial_stat_idx; + mt76_ethtool_worker(wi, &msta->stats); } static @@ -1236,9 +1206,11 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw, struct mt7915_dev *dev = mt7915_hw_dev(hw); struct mt7915_phy *phy = mt7915_hw_phy(hw); struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; - struct mt7915_ethtool_worker_info wi; + struct mt76_ethtool_worker_info wi = { + .data = data, + .idx = mvif->idx, + }; struct mib_stats *mib = &phy->mib; - /* See mt7915_ampdu_stat_read_phy, etc */ bool ext_phy = phy != &dev->phy; int i, n; @@ -1307,12 +1279,7 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw, data[ei++] = mib->rx_ba_cnt; /* Add values for all stations owned by this vif */ - wi.data = data; - wi.mvif = mvif; wi.initial_stat_idx = ei; - wi.worker_stat_count = 0; - wi.sta_count = 0; - ieee80211_iterate_stations_atomic(hw, mt7915_ethtool_worker, &wi); if (wi.sta_count == 0) From patchwork Mon Oct 18 12:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 12566251 X-Patchwork-Delegate: nbd@nbd.name Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BBD28C433FE for ; Mon, 18 Oct 2021 12:14:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A868961077 for ; Mon, 18 Oct 2021 12:14:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231672AbhJRMQh (ORCPT ); Mon, 18 Oct 2021 08:16:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:32898 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231648AbhJRMQh (ORCPT ); Mon, 18 Oct 2021 08:16:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 38E61610A3; Mon, 18 Oct 2021 12:14:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634559266; bh=+G7spr0hpBbQYp1ngah2Y2L550U315sRoRAj5bsiH8Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AZXPmeL5uHgwPaDdzZp22nAql5xjPnyHmJNzzrrYylyeT+opDVQ1QU8JP0C/pLbCO YFkhzc8Vl5gwqOYVdD/Q+eg/nhJkE6xC5afF1RL24i/0k/DBjG3nfAWUhRMbafMNhz ZI4+5OPS0TlLfq+tZBlU/JNHZO1zkKQKQ0PnLveSSAcBQ8z6qqQ0GK9s3TJf6JsrU9 2PKvqJ7AO5hbyOAjEKWHUWopWVPEkHBN2qwHlFD6XNegBlsnxCsoOyN0S0id9jnrkF m0M7kNeK9+U4SBhzlci9ED3V3dZmous4bBjSACK+BxsOce9xoKev+3KsZIZcQn0+/B PJ+q4orM3AqHQ== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com, sean.wang@mediatek.com, greearb@candelatech.com Subject: [PATCH 07/10] mt76: mt7921: add per-vif counters in ethtool Date: Mon, 18 Oct 2021 14:14:06 +0200 Message-Id: <350ad74a2911722f032842bc07dd8bb7d6ccb288.1634558817.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Similar to mt7915 driver, add per-vif tx counters in ethtool. Signed-off-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt7921/main.c | 53 ++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index 39ec3e62748b..6aaf255e87c9 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -900,7 +900,33 @@ static const char mt7921_gstrings_stats[][ETH_GSTRING_LEN] = { "rx_mpdu_cnt", "rx_ampdu_cnt", "rx_ampdu_bytes_cnt", - "rx_ba_cnt" + "rx_ba_cnt", + /* per vif counters */ + "v_tx_mode_cck", + "v_tx_mode_ofdm", + "v_tx_mode_ht", + "v_tx_mode_ht_gf", + "v_tx_mode_vht", + "v_tx_mode_he_su", + "v_tx_mode_he_ext_su", + "v_tx_mode_he_tb", + "v_tx_mode_he_mu", + "v_tx_bw_20", + "v_tx_bw_40", + "v_tx_bw_80", + "v_tx_bw_160", + "v_tx_mcs_0", + "v_tx_mcs_1", + "v_tx_mcs_2", + "v_tx_mcs_3", + "v_tx_mcs_4", + "v_tx_mcs_5", + "v_tx_mcs_6", + "v_tx_mcs_7", + "v_tx_mcs_8", + "v_tx_mcs_9", + "v_tx_mcs_10", + "v_tx_mcs_11", }; static void @@ -920,13 +946,30 @@ mt7921_get_et_sset_count(struct ieee80211_hw *hw, struct ieee80211_vif *vif, return sset == ETH_SS_STATS ? ARRAY_SIZE(mt7921_gstrings_stats) : 0; } +static void +mt7921_ethtool_worker(void *wi_data, struct ieee80211_sta *sta) +{ + struct mt7921_sta *msta = (struct mt7921_sta *)sta->drv_priv; + struct mt76_ethtool_worker_info *wi = wi_data; + + if (msta->vif->mt76.idx != wi->idx) + return; + + mt76_ethtool_worker(wi, &msta->stats); +} + static void mt7921_get_et_stats(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ethtool_stats *stats, u64 *data) { + struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv; struct mt7921_phy *phy = mt7921_hw_phy(hw); struct mt7921_dev *dev = phy->dev; struct mib_stats *mib = &phy->mib; + struct mt76_ethtool_worker_info wi = { + .data = data, + .idx = mvif->mt76.idx, + }; int i, ei = 0; mt7921_mutex_acquire(dev); @@ -965,8 +1008,16 @@ void mt7921_get_et_stats(struct ieee80211_hw *hw, struct ieee80211_vif *vif, data[ei++] = mib->rx_ampdu_bytes_cnt; data[ei++] = mib->rx_ba_cnt; + /* Add values for all stations owned by this vif */ + wi.initial_stat_idx = ei; + ieee80211_iterate_stations_atomic(hw, mt7921_ethtool_worker, &wi); + mt7921_mutex_release(dev); + if (!wi.sta_count) + return; + + ei += wi.worker_stat_count; if (ei != ARRAY_SIZE(mt7921_gstrings_stats)) dev_err(dev->mt76.dev, "ei: %d SSTATS_LEN: %lu", ei, ARRAY_SIZE(mt7921_gstrings_stats)); From patchwork Mon Oct 18 12:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 12566253 X-Patchwork-Delegate: nbd@nbd.name Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B2DAC433EF for ; Mon, 18 Oct 2021 12:14:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E94E61260 for ; Mon, 18 Oct 2021 12:14:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231655AbhJRMQj (ORCPT ); Mon, 18 Oct 2021 08:16:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:32938 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231648AbhJRMQi (ORCPT ); Mon, 18 Oct 2021 08:16:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9B5156128B; Mon, 18 Oct 2021 12:14:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634559267; bh=7QJDuUot3POHKIjINDNsnbEklzQKHSMUq/08vlGIJ7M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lbOicU1gFAgi6FYx+gwjHvJkgSmIhyg4J+dppYK4ZroipmUShep6CZ1yXTjxNYtWU CklIkOfGRHjObspLrcU4BrWooni+r8S1+wVjffZ1U8CvkqgFzEB4BG77wKF0XTlsfm fdXSF5sHPBL7uimEPhNjig/pgD10Ik+A/xO3xtpOsrty/rvShNpFSWyOOK04ZRuVrX ow7JdXQ9HmyNqGRmLegjAitsgizAB+6orOOTpMzFKqEycM14Abp+Q2Z8tuX5Kl5mpd x/SaLYuZWkP/cQCkt2UqSUUo/kcFfcgziwdiM88hPpyQI83nB/HS8s1BtF1T7UxQ8H F0TJUN5FBL89A== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com, sean.wang@mediatek.com, greearb@candelatech.com Subject: [PATCH 08/10] mt76: mt7915: run mt7915_get_et_stats holding mt76 mutex Date: Mon, 18 Oct 2021 14:14:07 +0200 Message-Id: <37148069daf8df7910a3e88dab12731f6fbe5f4a.1634558817.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Since it can run in parallel with mac_work, hold mutex lock in mt7915_get_et_stats. Moreover update mib counters running mt7915_get_et_stats. Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c | 5 +++++ drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 3 +-- drivers/net/wireless/mediatek/mt76/mt7915/main.c | 6 ++++++ drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c index 86c681dd7a62..a0edcc78f66d 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c @@ -209,7 +209,10 @@ mt7915_tx_stats_show(struct seq_file *file, void *data) struct mt7915_dev *dev = phy->dev; int stat[8], i, n; + mutex_lock(&dev->mt76.mutex); + mt7915_ampdu_stat_read_phy(phy, file); + mt7915_mac_update_stats(phy); mt7915_txbf_stat_read_phy(phy, file); /* Tx amsdu info */ @@ -228,6 +231,8 @@ mt7915_tx_stats_show(struct seq_file *file, void *data) seq_puts(file, "\n"); } + mutex_unlock(&dev->mt76.mutex); + return 0; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index edf62e0a7ff0..1fb0420276a1 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -1918,8 +1918,7 @@ void mt7915_mac_reset_work(struct work_struct *work) MT7915_WATCHDOG_TIME); } -static void -mt7915_mac_update_stats(struct mt7915_phy *phy) +void mt7915_mac_update_stats(struct mt7915_phy *phy) { struct mt7915_dev *dev = phy->dev; struct mib_stats *mib = &phy->mib; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c index 4d5009f6954b..13ef56205c98 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c @@ -1219,6 +1219,10 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw, if (!phy) return; + mutex_lock(&dev->mt76.mutex); + + mt7915_mac_update_stats(phy); + data[ei++] = mib->tx_ampdu_cnt; data[ei++] = mib->tx_stop_q_empty_cnt; data[ei++] = mib->tx_mpdu_attempts_cnt; @@ -1282,6 +1286,8 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw, wi.initial_stat_idx = ei; ieee80211_iterate_stations_atomic(hw, mt7915_ethtool_worker, &wi); + mutex_unlock(&dev->mt76.mutex); + if (wi.sta_count == 0) return; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h index 2acede0d5bf2..0a2dd2f18fe5 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -481,6 +481,7 @@ void mt7915_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, void mt7915_mac_work(struct work_struct *work); void mt7915_mac_reset_work(struct work_struct *work); void mt7915_mac_sta_rc_work(struct work_struct *work); +void mt7915_mac_update_stats(struct mt7915_phy *phy); int mt7915_mmio_init(struct mt76_dev *mdev, void __iomem *mem_base, int irq); void mt7915_mac_twt_teardown_flow(struct mt7915_dev *dev, struct mt7915_sta *msta, From patchwork Mon Oct 18 12:14:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 12566255 X-Patchwork-Delegate: nbd@nbd.name Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10C36C433F5 for ; Mon, 18 Oct 2021 12:14:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EE41E60FC3 for ; Mon, 18 Oct 2021 12:14:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231625AbhJRMQk (ORCPT ); Mon, 18 Oct 2021 08:16:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:32960 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231676AbhJRMQk (ORCPT ); Mon, 18 Oct 2021 08:16:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 09F2360FDA; Mon, 18 Oct 2021 12:14:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634559269; bh=SwyXgGDCtRYEix8g35dCtJ5ugEmLWfLLF4/GxiAfUhM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qx1+TnP4QQ+ndx525nJ7XII0GaEX7olzRmZtwgp8m4uy2PZMn6kfXWXvJLD5+EcUs jfIGTc7hSHjwUnfutWpATgnLW4prApaZL8VaqgEJtQnPEpFEnH+/D0RQ3i+57vL6w7 i00OM22k9+nnhDWX+opX1+hwk1Swh9q6qnp5vdMpRPBqi0ldC/2faZ5Nloq9ZeXRmb 5wsxZjyltnmtLFX3Q0xhMAlseBeAR+Cw/C0tZ9J2o38fPL2YuJkbi+zFcs0lUpr2Ib LqAB4e0Cm5tOX2HwrB+Qk9CQxwDkKo2lfop0g63qmaKEln20ct2+hKLK/5MChBXie5 oK/FSIiT4XF8Q== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com, sean.wang@mediatek.com, greearb@candelatech.com Subject: [PATCH 09/10] mt76: mt7915: do not overwrite all mib counters in mt7915_get_stats Date: Mon, 18 Oct 2021 14:14:08 +0200 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Do not overwrite all mib counters in mt7915_get_stats since they are used for ethtool stats. Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt7915/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c index 13ef56205c98..b5b23c824233 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c @@ -816,7 +816,7 @@ mt7915_get_stats(struct ieee80211_hw *hw, stats->dot11FCSErrorCount = mib->fcs_err_cnt; stats->dot11ACKFailureCount = mib->ack_fail_cnt; - memset(mib, 0, sizeof(*mib)); + memset(mib, 0, offsetof(struct mib_stats, ba_miss_cnt)); mutex_unlock(&dev->mt76.mutex); From patchwork Mon Oct 18 12:14:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 12566257 X-Patchwork-Delegate: nbd@nbd.name Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70543C433F5 for ; Mon, 18 Oct 2021 12:14:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5581F60FC3 for ; Mon, 18 Oct 2021 12:14:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231676AbhJRMQr (ORCPT ); Mon, 18 Oct 2021 08:16:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:32982 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231310AbhJRMQl (ORCPT ); Mon, 18 Oct 2021 08:16:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6D3B861077; Mon, 18 Oct 2021 12:14:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634559270; bh=0UBFJji7GBQklDq8DXVF1V1mMl7G4nVBfICOU09jtoQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tn5g1gAEC6IdMZy8yMhQAXvwegMT1yAuNVzSXhb5ZyC2Of5fPScYCR4ekVkyrDiQ2 PfUQnF/viM17n+olukrK4dARHwkFFAC6aZ2S7eE61fkIXZTQo015ShM3kRaamt6STr RbRCLbpEHABxSXi6kpBU64DDo1Vkgm0iFJe1K8yZHMscl6MI9Lowdmum4ERf6oapPz NmINtc0Fri8tY1JpbxJC59gNvT2Gf+hY1rq551fdckCP3OWjv4U4wuzGmTwNKkt+lg Hh6ABNR+HWyz85TSAyQIeFKeCrJPLJBUWidaDUnBHUXJs8UzBwmuw/42tPySm8ek7x sgeUs1UZaoucQ== From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com, sean.wang@mediatek.com, greearb@candelatech.com Subject: [PATCH 10/10] mt76: mt7915: move tx amsdu stats in mib_stats Date: Mon, 18 Oct 2021 14:14:09 +0200 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Move tx_amsdu histogram stats in mib_stats structure since registers are clear-on-read Signed-off-by: Lorenzo Bianconi --- .../wireless/mediatek/mt76/mt7915/debugfs.c | 19 ++++++++----------- .../net/wireless/mediatek/mt76/mt7915/mac.c | 6 ++++++ .../net/wireless/mediatek/mt76/mt7915/main.c | 4 ++-- .../wireless/mediatek/mt76/mt7915/mt7915.h | 3 +++ 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c index a0edcc78f66d..08a80b81a6c5 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c @@ -207,7 +207,8 @@ mt7915_tx_stats_show(struct seq_file *file, void *data) { struct mt7915_phy *phy = file->private; struct mt7915_dev *dev = phy->dev; - int stat[8], i, n; + struct mib_stats *mib = &phy->mib; + int i; mutex_lock(&dev->mt76.mutex); @@ -217,16 +218,12 @@ mt7915_tx_stats_show(struct seq_file *file, void *data) /* Tx amsdu info */ seq_puts(file, "Tx MSDU statistics:\n"); - for (i = 0, n = 0; i < ARRAY_SIZE(stat); i++) { - stat[i] = mt76_rr(dev, MT_PLE_AMSDU_PACK_MSDU_CNT(i)); - n += stat[i]; - } - - for (i = 0; i < ARRAY_SIZE(stat); i++) { - seq_printf(file, "AMSDU pack count of %d MSDU in TXD: 0x%x ", - i + 1, stat[i]); - if (n != 0) - seq_printf(file, "(%d%%)\n", stat[i] * 100 / n); + for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) { + seq_printf(file, "AMSDU pack count of %d MSDU in TXD: %8d ", + i + 1, mib->tx_amsdu[i]); + if (mib->tx_amsdu_cnt) + seq_printf(file, "(%3d%%)\n", + mib->tx_amsdu[i] * 100 / mib->tx_amsdu_cnt); else seq_puts(file, "\n"); } diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index 1fb0420276a1..f6267b77ca97 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -2023,6 +2023,12 @@ void mt7915_mac_update_stats(struct mt7915_phy *phy) mib->tx_bf_fb_cpl_cnt += FIELD_GET(MT_ETBF_TX_FB_CPL, cnt); mib->tx_bf_fb_trig_cnt += FIELD_GET(MT_ETBF_TX_FB_TRI, cnt); + for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) { + cnt = mt76_rr(dev, MT_PLE_AMSDU_PACK_MSDU_CNT(i)); + mib->tx_amsdu[i] += cnt; + mib->tx_amsdu_cnt += cnt; + } + aggr0 = ext_phy ? ARRAY_SIZE(dev->mt76.aggr_stats) / 2 : 0; for (i = 0, aggr1 = aggr0 + 4; i < 4; i++) { u32 val; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c index b5b23c824233..7210a1db2050 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c @@ -1264,8 +1264,8 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw, data[ei++] = mib->tx_su_acked_mpdu_cnt; /* Tx amsdu info (pack-count histogram) */ - for (i = 0; i < 8; i++) - data[ei++] = mt76_rr(dev, MT_PLE_AMSDU_PACK_MSDU_CNT(i)); + for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) + data[ei++] = mib->tx_amsdu[i]; /* rx counters */ data[ei++] = mib->rx_fifo_full_cnt; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h index 0a2dd2f18fe5..207114e2019d 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -171,6 +171,9 @@ struct mib_stats { u32 rx_pfdrop_cnt; u32 rx_vec_queue_overflow_drop_cnt; u32 rx_ba_cnt; + + u32 tx_amsdu[8]; + u32 tx_amsdu_cnt; }; struct mt7915_hif {