netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: sr@denx.de
Cc: netdev@vger.kernel.org, nbd@nbd.name, john@phrozen.org,
	ilya.lipnitskiy@gmail.com, code@reto-schneider.ch,
	reto.schneider@husqvarnagroup.com
Subject: Re: [PATCH net] net: ethernet: mtk_eth_soc: Fix packet statistics support for MT7628/88
Date: Fri, 21 May 2021 14:37:19 -0700 (PDT)	[thread overview]
Message-ID: <20210521.143719.557231591502681397.davem@davemloft.net> (raw)
In-Reply-To: <20210521055715.1844707-1-sr@denx.de>

From: Stefan Roese <sr@denx.de>
Date: Fri, 21 May 2021 07:57:15 +0200

> The MT7628/88 SoC(s) have other (limited) packet counter registers than
> currently supported in the mtk_eth_soc driver. This patch adds support
> for reading these registers, so that the packet statistics are correctly
> updated.
> 
> Signed-off-by: Stefan Roese <sr@denx.de>
> Fixes: 296c9120752b ("net: ethernet: mediatek: Add MT7628/88 SoC support")
> Cc: Felix Fietkau <nbd@nbd.name>
> Cc: John Crispin <john@phrozen.org>
> Cc: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
> Cc: Reto Schneider <code@reto-schneider.ch>
> Cc: Reto Schneider <reto.schneider@husqvarnagroup.com>
> Cc: David S. Miller <davem@davemloft.net>
> ---
>  drivers/net/ethernet/mediatek/mtk_eth_soc.c | 56 ++++++++++++---------
>  drivers/net/ethernet/mediatek/mtk_eth_soc.h |  7 +++
>  2 files changed, 40 insertions(+), 23 deletions(-)
> 
> +		unsigned int base = MTK_GDM1_TX_GBCNT + hw_stats->reg_offset;
> +		u64 stats;
> +
> +		hw_stats->rx_bytes += mtk_r32(mac->hw, base);
> +		stats =  mtk_r32(mac->hw, base + 0x04);
> +		if (stats)
> +			hw_stats->rx_bytes += (stats << 32);
> +		hw_stats->rx_packets += mtk_r32(mac->hw, base + 0x08);
> +		hw_stats->rx_overflow += mtk_r32(mac->hw, base + 0x10);
> +		hw_stats->rx_fcs_errors += mtk_r32(mac->hw, base + 0x14);
> +		hw_stats->rx_short_errors += mtk_r32(mac->hw, base + 0x18);
> +		hw_stats->rx_long_errors += mtk_r32(mac->hw, base + 0x1c);
> +		hw_stats->rx_checksum_errors += mtk_r32(mac->hw, base + 0x20);
> +		hw_stats->rx_flow_control_packets +=
> +			mtk_r32(mac->hw, base + 0x24);
> +		hw_stats->tx_skip += mtk_r32(mac->hw, base + 0x28);
> +		hw_stats->tx_collisions += mtk_r32(mac->hw, base + 0x2c);
> +		hw_stats->tx_bytes += mtk_r32(mac->hw, base + 0x30);
> +		stats =  mtk_r32(mac->hw, base + 0x34);
> +		if (stats)
> +			hw_stats->tx_bytes += (stats << 32);
> +		hw_stats->tx_packets += mtk_r32(mac->hw, base + 0x38);
>  
> +/* Counter / stat register */
> +#define MT7628_SDM_TPCNT	(MT7628_SDM_OFFSET + 0x100)
> +#define MT7628_SDM_TBCNT	(MT7628_SDM_OFFSET + 0x104)
> +#define MT7628_SDM_RPCNT	(MT7628_SDM_OFFSET + 0x108)
> +#define MT7628_SDM_RBCNT	(MT7628_SDM_OFFSET + 0x10c)
> +#define MT7628_SDM_CS_ERR	(MT7628_SDM_OFFSET + 0x110)
> +

The other stats/cpunter regs should be properly defined like this too.

Thank you.

  reply	other threads:[~2021-05-21 21:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-21  5:57 [PATCH net] net: ethernet: mtk_eth_soc: Fix packet statistics support for MT7628/88 Stefan Roese
2021-05-21 21:37 ` David Miller [this message]
2021-05-22  7:51   ` Stefan Roese

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=20210521.143719.557231591502681397.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=code@reto-schneider.ch \
    --cc=ilya.lipnitskiy@gmail.com \
    --cc=john@phrozen.org \
    --cc=nbd@nbd.name \
    --cc=netdev@vger.kernel.org \
    --cc=reto.schneider@husqvarnagroup.com \
    --cc=sr@denx.de \
    /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).