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>,
	Sergey Shtylyov <s.shtylyov@omp.ru>,
	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: [PATCH net-next v3 07/14] ravb: Add carrier_counters to struct ravb_hw_info
Date: Tue, 12 Oct 2021 17:36:06 +0100	[thread overview]
Message-ID: <20211012163613.30030-8-biju.das.jz@bp.renesas.com> (raw)
In-Reply-To: <20211012163613.30030-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>
---
v2->v3;
 * No change
V1->V2:
 * No change
RFC->V1:
 * Moved carrier_counters near to tx_counters.
 * removed CXR55 and CXR56 registers as it is rx related registers.
 * Retained Sergey's Rb tag as it is trivial change.
RFC changes:
 * Added Sergey's Rb tag.
---
 drivers/net/ethernet/renesas/ravb.h      | 3 +++
 drivers/net/ethernet/renesas/ravb_main.c | 8 ++++++++
 2 files changed, 11 insertions(+)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 99164318db26..527e865dee81 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -196,6 +196,8 @@ 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,
@@ -1017,6 +1019,7 @@ struct ravb_hw_info {
 	/* hardware features */
 	unsigned internal_delay:1;	/* AVB-DMAC has internal delays */
 	unsigned tx_counters:1;		/* E-MAC has TX counters */
+	unsigned carrier_counters:1;	/* E-MAC has carrier counters */
 	unsigned multi_irqs:1;		/* AVB-DMAC and E-MAC has multiple irqs */
 	unsigned gptp:1;		/* AVB-DMAC has gPTP support */
 	unsigned ccc_gac:1;		/* AVB-DMAC has gPTP support active in config mode */
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 1a5ebc58682d..2221a2565397 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2053,6 +2053,13 @@ 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->rx_packets = stats0->rx_packets;
 	nstats->tx_packets = stats0->tx_packets;
 	nstats->rx_bytes = stats0->rx_bytes;
@@ -2432,6 +2439,7 @@ static const struct ravb_hw_info gbeth_hw_info = {
 	.rx_max_buf_size = SZ_8K,
 	.aligned_tx = 1,
 	.tx_counters = 1,
+	.carrier_counters = 1,
 	.half_duplex = 1,
 };
 
-- 
2.17.1


  parent reply	other threads:[~2021-10-12 16:36 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-12 16:35 [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver Biju Das
2021-10-12 16:36 ` [PATCH net-next v3 01/14] ravb: Use ALIGN macro for max_rx_len Biju Das
2021-10-12 16:36 ` [PATCH net-next v3 02/14] ravb: Add rx_max_buf_size to struct ravb_hw_info Biju Das
2021-10-12 16:36 ` [PATCH net-next v3 03/14] ravb: Fillup ravb_alloc_rx_desc_gbeth() stub Biju Das
2021-10-12 16:36 ` [PATCH net-next v3 04/14] ravb: Fillup ravb_rx_ring_free_gbeth() stub Biju Das
2021-10-12 16:36 ` [PATCH net-next v3 05/14] ravb: Fillup ravb_rx_ring_format_gbeth() stub Biju Das
2021-10-12 16:36 ` [PATCH net-next v3 06/14] ravb: Fillup ravb_rx_gbeth() stub Biju Das
2021-10-12 16:36 ` Biju Das [this message]
2021-10-12 16:36 ` [PATCH net-next v3 08/14] ravb: Add support to retrieve stats for GbEthernet Biju Das
2021-10-12 16:36 ` [PATCH net-next v3 09/14] ravb: Rename "tsrq" variable Biju Das
2021-10-12 16:36 ` [PATCH net-next v3 10/14] ravb: Optimize ravb_emac_init_gbeth function Biju Das
2021-10-12 16:36 ` [PATCH net-next v3 11/14] ravb: Rename "nc_queue" feature bit Biju Das
2021-10-12 16:36 ` [PATCH net-next v3 12/14] ravb: Document PFRI register bit Biju Das
2021-10-12 16:36 ` [PATCH net-next v3 13/14] ravb: Update ravb_emac_init_gbeth() Biju Das
2021-10-12 17:34   ` Sergey Shtylyov
2021-10-12 17:52     ` Biju Das
2021-10-12 18:03       ` Sergei Shtylyov
2021-10-12 18:23         ` Biju Das
2021-10-12 18:25           ` Sergei Shtylyov
2021-10-12 18:55             ` Biju Das
2021-10-13  6:14               ` Biju Das
2021-10-13 15:46               ` Sergey Shtylyov
     [not found]                 ` <20211013085704.4a059444@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
2021-10-13 16:03                   ` Sergey Shtylyov
2021-10-12 16:36 ` [PATCH net-next v3 14/14] ravb: Fix typo AVB->DMAC Biju Das
2021-10-12 18:19 ` [PATCH net-next v3 00/14] Add functional support for Gigabit Ethernet driver Jakub Kicinski
2021-10-12 18:28   ` Biju Das
     [not found]     ` <20211012114125.0a9d71ae@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
2021-10-12 18:53       ` Biju Das
2021-10-12 20:17         ` Jakub Kicinski
2021-10-13  6:41           ` Biju Das
2021-10-13  6:50             ` Biju Das
2021-10-13 16:20 ` patchwork-bot+netdevbpf

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=20211012163613.30030-8-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@omp.ru \
    --cc=s.shtylyov@omprussia.ru \
    --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.