From patchwork Tue Oct 12 16:36:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 12553123 X-Patchwork-Delegate: kuba@kernel.org 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 36EAFC433F5 for ; Tue, 12 Oct 2021 16:36:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2024F6108F for ; Tue, 12 Oct 2021 16:36:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231540AbhJLQit (ORCPT ); Tue, 12 Oct 2021 12:38:49 -0400 Received: from relmlor1.renesas.com ([210.160.252.171]:49939 "EHLO relmlie5.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231368AbhJLQis (ORCPT ); Tue, 12 Oct 2021 12:38:48 -0400 X-IronPort-AV: E=Sophos;i="5.85,368,1624287600"; d="scan'208";a="96771819" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 13 Oct 2021 01:36:46 +0900 Received: from localhost.localdomain (unknown [10.226.92.46]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id E057440AA558; Wed, 13 Oct 2021 01:36:42 +0900 (JST) From: Biju Das To: "David S. Miller" , Jakub Kicinski Cc: Biju Das , Sergey Shtylyov , Geert Uytterhoeven , Sergey Shtylyov , Adam Ford , Andrew Lunn , Yuusuke Ashizuka , Yoshihiro Shimoda , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Chris Paterson , Biju Das , Prabhakar Mahadev Lad 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 Message-Id: <20211012163613.30030-8-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211012163613.30030-1-biju.das.jz@bp.renesas.com> References: <20211012163613.30030-1-biju.das.jz@bp.renesas.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 Reviewed-by: Sergey Shtylyov --- 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, };