linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: greearb@candelatech.com
Cc: linux-wireless@vger.kernel.org
Subject: Re: [PATCH v4 4/8] mt76 - mt7915: Add tx mu/su counters to mib
Date: Sat, 24 Jul 2021 14:39:49 +0200	[thread overview]
Message-ID: <YPwKFRDvETI3wyr0@lore-desk> (raw)
In-Reply-To: <20210723154627.10078-4-greearb@candelatech.com>

[-- Attachment #1: Type: text/plain, Size: 5396 bytes --]

> From: Ben Greear <greearb@candelatech.com>
> 
> These counters are clear-on-read, so we need to accumulate
> them in the update_stats poll logic, and read the accumulated
> values instead of directly doing register reads when reporting
> to debugfs and ethtool stats.
> 
> Signed-off-by: Ben Greear <greearb@candelatech.com>
> ---
>  .../net/wireless/mediatek/mt76/mt7915/debugfs.c | 17 ++++++++---------
>  drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 13 ++++++++++++-
>  .../net/wireless/mediatek/mt76/mt7915/main.c    | 16 +++++-----------
>  .../net/wireless/mediatek/mt76/mt7915/mt7915.h  |  4 ++++
>  4 files changed, 29 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
> index 1a48b09d0cb7..35248d182728 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
> @@ -152,6 +152,7 @@ mt7915_txbf_stat_read_phy(struct mt7915_phy *phy, struct seq_file *s)
>  		"BW20", "BW40", "BW80", "BW160"
>  	};
>  	int cnt;
> +	struct mib_stats *mib = &phy->mib;

according to the check below this can be a NULL pointer dereference

>  
>  	if (!phy)
>  		return;
> @@ -187,15 +188,13 @@ mt7915_txbf_stat_read_phy(struct mt7915_phy *phy, struct seq_file *s)
>  		   FIELD_GET(MT_ETBF_TX_FB_TRI, cnt));
>  
>  	/* Tx SU & MU counters */
> -	cnt = mt76_rr(dev, MT_MIB_SDR34(ext_phy));
> -	seq_printf(s, "Tx multi-user Beamforming counts: %ld\n",
> -		   FIELD_GET(MT_MIB_MU_BF_TX_CNT, cnt));
> -	cnt = mt76_rr(dev, MT_MIB_DR8(ext_phy));
> -	seq_printf(s, "Tx multi-user MPDU counts: %d\n", cnt);
> -	cnt = mt76_rr(dev, MT_MIB_DR9(ext_phy));
> -	seq_printf(s, "Tx multi-user successful MPDU counts: %d\n", cnt);
> -	cnt = mt76_rr(dev, MT_MIB_DR11(ext_phy));
> -	seq_printf(s, "Tx single-user successful MPDU counts: %d\n", cnt);
> +	seq_printf(s, "Tx multi-user Beamforming counts: %d\n",
> +		   mib->tx_bf_cnt);
> +	seq_printf(s, "Tx multi-user MPDU counts: %d\n", mib->tx_mu_mpdu_cnt);
> +	seq_printf(s, "Tx multi-user successful MPDU counts: %d\n",
> +		   mib->tx_mu_acked_mpdu_cnt);
> +	seq_printf(s, "Tx single-user successful MPDU counts: %d\n",
> +		   mib->tx_su_acked_mpdu_cnt);
>  
>  	seq_puts(s, "\n");
>  }
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> index 6f445999e516..064d754e0565 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> @@ -1890,10 +1890,21 @@ mt7915_mac_update_stats(struct mt7915_phy *phy)
>  	struct mt7915_dev *dev = phy->dev;
>  	struct mib_stats *mib = &phy->mib;
>  	bool ext_phy = phy != &dev->phy;
> -	int i, aggr0, aggr1;
> +	int i, aggr0, aggr1, cnt;
>  
>  	mib->fcs_err_cnt += mt76_get_field(dev, MT_MIB_SDR3(ext_phy),
>  					   MT_MIB_SDR3_FCS_ERR_MASK);
> +	cnt = mt76_rr(dev, MT_MIB_SDR34(ext_phy));
> +	mib->tx_bf_cnt += FIELD_GET(MT_MIB_MU_BF_TX_CNT, cnt);
> +
> +	cnt = mt76_rr(dev, MT_MIB_DR8(ext_phy));
> +	mib->tx_mu_mpdu_cnt += cnt;
> +
> +	cnt = mt76_rr(dev, MT_MIB_DR9(ext_phy));
> +	mib->tx_mu_acked_mpdu_cnt += cnt;
> +
> +	cnt = mt76_rr(dev, MT_MIB_DR11(ext_phy));
> +	mib->tx_su_acked_mpdu_cnt += cnt;
>  
>  	aggr0 = ext_phy ? ARRAY_SIZE(dev->mt76.aggr_stats) / 2 : 0;
>  	for (i = 0, aggr1 = aggr0 + 4; i < 4; i++) {
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c
> index de083008663e..be6444650afe 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c
> @@ -1131,6 +1131,7 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw,
>  	struct mt7915_sta *msta;
>  	struct mt7915_sta_stats *mstats;
>  	bool found_sta = false;
> +	struct mib_stats *mib = &phy->mib;
>  
>  	/* See mt7915_ampdu_stat_read_phy, etc */
>  	bool ext_phy = phy != &dev->phy;
> @@ -1170,17 +1171,10 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw,
>  	data[ei++] = FIELD_GET(MT_ETBF_TX_FB_TRI, cnt);
>  
>  	/* Tx SU & MU counters */
> -	cnt = mt76_rr(dev, MT_MIB_SDR34(ext_phy));
> -	data[ei++] = FIELD_GET(MT_MIB_MU_BF_TX_CNT, cnt);
> -
> -	cnt = mt76_rr(dev, MT_MIB_DR8(ext_phy));
> -	data[ei++] = cnt;
> -
> -	cnt = mt76_rr(dev, MT_MIB_DR9(ext_phy));
> -	data[ei++] = cnt; /* MU MPDU SUccessful */
> -
> -	cnt = mt76_rr(dev, MT_MIB_DR11(ext_phy));
> -	data[ei++] = cnt; /* SU MPDU successful */
> +	data[ei++] = mib->tx_bf_cnt;
> +	data[ei++] = mib->tx_mu_mpdu_cnt;
> +	data[ei++] = mib->tx_mu_acked_mpdu_cnt;
> +	data[ei++] = mib->tx_su_acked_mpdu_cnt;
>  
>  	/* TODO:  External phy too?? */
>  
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
> index a8617ba69a21..26f2befc46dd 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
> @@ -116,6 +116,10 @@ struct mib_stats {
>  	u32 rts_cnt;
>  	u32 rts_retries_cnt;
>  	u32 ba_miss_cnt;
> +	u32 tx_bf_cnt;
> +	u32 tx_mu_mpdu_cnt;
> +	u32 tx_mu_acked_mpdu_cnt;
> +	u32 tx_su_acked_mpdu_cnt;
>  	/* Add more stats here, updated from mac_update_stats */
>  };
>  
> -- 
> 2.20.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2021-07-24 12:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-23 15:46 [PATCH v4 1/8] mt76 - mt7915: Add ethtool stats support greearb
2021-07-23 15:46 ` [PATCH v4 2/8] mt76 - mt7915: Add tx stats gathered from tx-status callbacks greearb
2021-07-23 15:46 ` [PATCH v4 3/8] mt76 - mt7915: Add some per-station tx stats to ethtool greearb
2021-07-24 12:37   ` Lorenzo Bianconi
2021-07-23 15:46 ` [PATCH v4 4/8] mt76 - mt7915: Add tx mu/su counters to mib greearb
2021-07-24 12:39   ` Lorenzo Bianconi [this message]
2021-07-23 15:46 ` [PATCH v4 5/8] mt76 - mt7915: Move more tx-bf stats " greearb
2021-07-24 12:40   ` Lorenzo Bianconi
2021-07-23 15:46 ` [PATCH v4 6/8] mt76 - mt7915: Fix he_mcs capabilities for 160mhz greearb
2021-07-23 15:46 ` [PATCH v4 7/8] mt76 - mt7915: Add more MIB registers greearb
2021-07-23 15:46 ` [PATCH v4 8/8] mt76 - mt7915: Add mib counters to ethtool stats greearb
2021-07-24 12:36 ` [PATCH v4 1/8] mt76 - mt7915: Add ethtool stats support Lorenzo Bianconi
2021-07-31  7:48 ` Kalle Valo
2021-08-02 14:49   ` Ben Greear

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YPwKFRDvETI3wyr0@lore-desk \
    --to=lorenzo@kernel.org \
    --cc=greearb@candelatech.com \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).