All of lore.kernel.org
 help / color / mirror / Atom feed
From: Biju Das <biju.das.jz@bp.renesas.com>
To: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>
Cc: Biju Das <biju.das.jz@bp.renesas.com>,
	Sergei Shtylyov <sergei.shtylyov@gmail.com>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Sergey Shtylyov <s.shtylyov@omprussia.ru>,
	Adam Ford <aford173@gmail.com>, Andrew Lunn <andrew@lunn.ch>,
	Yuusuke Ashizuka <ashiduka@fujitsu.com>,
	Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
	netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	Chris Paterson <Chris.Paterson2@renesas.com>,
	Biju Das <biju.das@bp.renesas.com>,
	Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>
Subject: [RFC 08/12] ravb: Add carrier_counters to struct ravb_hw_info
Date: Tue,  5 Oct 2021 12:06:38 +0100	[thread overview]
Message-ID: <20211005110642.3744-9-biju.das.jz@bp.renesas.com> (raw)
In-Reply-To: <20211005110642.3744-1-biju.das.jz@bp.renesas.com>

RZ/G2L E-MAC supports carrier counters.
Add a carrier_counter hw feature bit to struct ravb_hw_info
to add this feature only for RZ/G2L.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
RFC changes:
 * Added Sergey's Rb tag.
---
 drivers/net/ethernet/renesas/ravb.h      |  5 +++++
 drivers/net/ethernet/renesas/ravb_main.c | 13 +++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 8c7b2569c7dd..899e16c5eb1a 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -196,11 +196,15 @@ enum ravb_reg {
 	MAHR	= 0x05c0,
 	MALR	= 0x05c8,
 	TROCR	= 0x0700,	/* R-Car Gen3 and RZ/G2L only */
+	CXR41	= 0x0708,	/* RZ/G2L only */
+	CXR42	= 0x0710,	/* RZ/G2L only */
 	CEFCR	= 0x0740,
 	FRECR	= 0x0748,
 	TSFRCR	= 0x0750,
 	TLFRCR	= 0x0758,
 	RFCR	= 0x0760,
+	CXR55	= 0x0768,	/* RZ/G2L only */
+	CXR56	= 0x0770,	/* RZ/G2L only */
 	MAFCR	= 0x0778,
 	CSR0    = 0x0800,	/* RZ/G2L only */
 	CSR1    = 0x0804,	/* RZ/G2L only */
@@ -1061,6 +1065,7 @@ struct ravb_hw_info {
 	unsigned nc_queue:1;		/* AVB-DMAC has NC queue */
 	unsigned magic_pkt:1;		/* E-MAC supports magic packet detection */
 	unsigned half_duplex:1;		/* E-MAC supports half duplex mode */
+	unsigned carrier_counters:1;	/* E-MAC has carrier counters */
 };
 
 struct ravb_private {
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 42573eac82b9..c057de81ec58 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2075,6 +2075,18 @@ static struct net_device_stats *ravb_get_stats(struct net_device *ndev)
 		ravb_write(ndev, 0, TROCR);	/* (write clear) */
 	}
 
+	if (info->carrier_counters) {
+		nstats->collisions += ravb_read(ndev, CXR41);
+		ravb_write(ndev, 0, CXR41);	/* (write clear) */
+		nstats->tx_carrier_errors += ravb_read(ndev, CXR42);
+		ravb_write(ndev, 0, CXR42);	/* (write clear) */
+
+		nstats->tx_carrier_errors += ravb_read(ndev, CXR55);
+		ravb_write(ndev, 0, CXR55);	/* (write clear) */
+		nstats->tx_carrier_errors += ravb_read(ndev, CXR56);
+		ravb_write(ndev, 0, CXR56);	/* (write clear) */
+	}
+
 	nstats->rx_packets = stats0->rx_packets;
 	nstats->tx_packets = stats0->tx_packets;
 	nstats->rx_bytes = stats0->rx_bytes;
@@ -2486,6 +2498,7 @@ static const struct ravb_hw_info gbeth_hw_info = {
 	.aligned_tx = 1,
 	.tx_counters = 1,
 	.half_duplex = 1,
+	.carrier_counters = 1,
 };
 
 static const struct of_device_id ravb_match_table[] = {
-- 
2.17.1


  parent reply	other threads:[~2021-10-05 11:07 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-05 11:06 [RFC 00/12] Add functional support for Gigabit Ethernet driver Biju Das
2021-10-05 11:06 ` [RFC 01/12] ravb: Use ALIGN macro for max_rx_len Biju Das
2021-10-05 12:14   ` Sergey Shtylyov
2021-10-05 11:06 ` [RFC 02/12] ravb: Add rx_max_buf_size to struct ravb_hw_info Biju Das
2021-10-05 12:21   ` Sergey Shtylyov
2021-10-05 11:06 ` [RFC 03/12] ravb: Fillup ravb_set_features_gbeth() stub Biju Das
2021-10-05 18:59   ` Sergey Shtylyov
2021-10-06  7:43     ` Biju Das
2021-10-09 17:53       ` Biju Das
2021-10-05 11:06 ` [RFC 04/12] ravb: Fillup ravb_alloc_rx_desc_gbeth() stub Biju Das
2021-10-05 19:14   ` Sergey Shtylyov
2021-10-06  6:50     ` Biju Das
2021-10-05 11:06 ` [RFC 05/12] ravb: Fillup ravb_rx_ring_free_gbeth() stub Biju Das
2021-10-05 19:41   ` Sergei Shtylyov
2021-10-05 11:06 ` [RFC 06/12] ravb: Fillup ravb_rx_ring_format_gbeth() stub Biju Das
2021-10-05 20:34   ` Sergey Shtylyov
2021-10-05 11:06 ` [RFC 07/12] ravb: Fillup ravb_rx_gbeth() stub Biju Das
2021-10-06 19:38   ` Sergey Shtylyov
2021-10-06 20:22     ` Biju Das
2021-10-06 20:32       ` Sergey Shtylyov
2021-10-07  5:49         ` Biju Das
2021-10-07 19:04           ` Sergey Shtylyov
2021-10-07 20:09             ` Biju Das
2021-10-08  6:46               ` Biju Das
2021-10-08 17:59                 ` Sergey Shtylyov
2021-10-08 20:13                   ` Sergey Shtylyov
2021-10-09  8:27                     ` Biju Das
2021-10-09  8:34                       ` Sergei Shtylyov
2021-10-09  9:41                         ` Biju Das
2021-10-05 11:06 ` Biju Das [this message]
2021-10-06 16:41   ` [RFC 08/12] ravb: Add carrier_counters to struct ravb_hw_info Sergey Shtylyov
2021-10-06 17:00     ` Sergey Shtylyov
2021-10-06 17:22       ` Biju Das
2021-10-06 17:21     ` Biju Das
2021-10-05 11:06 ` [RFC 09/12] ravb: Add support to retrieve stats for GbEthernet Biju Das
2021-10-06 17:27   ` Sergey Shtylyov
2021-10-05 11:06 ` [RFC 10/12] ravb: Rename "tsrq" variable Biju Das
2021-10-05 19:19   ` Sergey Shtylyov
2021-10-05 11:06 ` [RFC 11/12] ravb: Optimize ravb_emac_init_gbeth function Biju Das
2021-10-05 19:19   ` Sergey Shtylyov
2021-10-05 11:06 ` [RFC 12/12] ravb: Update/Add comments Biju Das
2021-10-05 19:26   ` Sergey Shtylyov
2021-10-06  6:53     ` Biju Das
2021-10-05 11:54 ` [RFC 00/12] Add functional support for Gigabit Ethernet driver Sergey Shtylyov
2021-10-05 12:04   ` Biju Das

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=20211005110642.3744-9-biju.das.jz@bp.renesas.com \
    --to=biju.das.jz@bp.renesas.com \
    --cc=Chris.Paterson2@renesas.com \
    --cc=aford173@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=ashiduka@fujitsu.com \
    --cc=biju.das@bp.renesas.com \
    --cc=davem@davemloft.net \
    --cc=geert+renesas@glider.be \
    --cc=kuba@kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=s.shtylyov@omprussia.ru \
    --cc=sergei.shtylyov@gmail.com \
    --cc=yoshihiro.shimoda.uh@renesas.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.