linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Stefan Mätje" <stefan.maetje@esd.eu>
To: linux-can@vger.kernel.org, Marc Kleine-Budde <mkl@pengutronix.de>,
	Wolfgang Grandegger <wg@grandegger.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 4/4] can: esd_402_pci: do not increase rx_bytes statistics for RTR frames
Date: Wed,  1 Dec 2021 23:03:28 +0100	[thread overview]
Message-ID: <20211201220328.3079270-5-stefan.maetje@esd.eu> (raw)
In-Reply-To: <20211201220328.3079270-1-stefan.maetje@esd.eu>

The actual payload length of the CAN Remote Transmission Request (RTR)
frames is always 0, i.e. nothing is transmitted on the wire. However,
those RTR frames still use the DLC to indicate the length of the
requested frame.

As such, net_device_stats:rx_bytes should not be increased for the RTR
frames.

This patch brings the esd_402_pci driver in line with the other CAN
drivers which have been changed after a suggestion of Vincent Mailhol.

Suggested-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: Stefan Mätje <stefan.maetje@esd.eu>
---
 drivers/net/can/esd/esdacc.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/can/esd/esdacc.c b/drivers/net/can/esd/esdacc.c
index f74248662cd6..99c1e1bdd72d 100644
--- a/drivers/net/can/esd/esdacc.c
+++ b/drivers/net/can/esd/esdacc.c
@@ -483,15 +483,16 @@ static void handle_core_msg_rxtxdone(struct acc_core *core,
 		can_frame_set_cc_len(cf, msg->dlc.rx.len & ACC_CAN_DLC_MASK,
 				     priv->can.ctrlmode);
 
-		if (msg->dlc.rx.len & ACC_CAN_RTR_FLAG)
+		if (msg->dlc.rx.len & ACC_CAN_RTR_FLAG) {
 			cf->can_id |= CAN_RTR_FLAG;
-		else
+		} else {
 			memcpy(cf->data, msg->data, cf->len);
+			stats->rx_bytes += cf->len;
+		}
+		stats->rx_packets++;
 
 		skb_hwtstamps(skb)->hwtstamp = acc_ts2ktime(priv->ov, msg->ts);
 
-		stats->rx_packets++;
-		stats->rx_bytes += cf->len;
 		netif_rx(skb);
 	}
 }
-- 
2.25.1


  parent reply	other threads:[~2021-12-01 22:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-01 22:03 [PATCH 0/4] can: esd: add support for esd GmbH PCIe/402 CAN interface Stefan Mätje
2021-12-01 22:03 ` [PATCH 1/4] MAINTAINERS: add Stefan Mätje as maintainer for the esd electronics GmbH CAN drivers Stefan Mätje
2021-12-01 22:03 ` [PATCH 2/4] can: esd: add support for esd GmbH PCIe/402 CAN interface family Stefan Mätje
2022-02-01 17:25   ` [PATCH v6 " Marc Kleine-Budde
2022-09-30 22:15     ` Stefan Mätje
2022-10-05 16:04       ` Marc Kleine-Budde
2021-12-01 22:03 ` [PATCH 3/4] can: esd_402_pci: do not increase rx statistics when generating a CAN rx error message frame Stefan Mätje
2021-12-01 22:03 ` Stefan Mätje [this message]
2021-12-01 22:09 ` [PATCH v6 0/4] can: esd: add support for esd GmbH PCIe/402 CAN interface Stefan Mätje
2022-01-07 13:40   ` Stefan Mätje
2022-01-25 16:25 ` Marc Kleine-Budde
2022-01-27 19:14   ` Stefan Mätje
2022-01-28  8:11     ` Marc Kleine-Budde
2022-02-01 17:27 ` Marc Kleine-Budde
2022-02-02 12:21 ` Marc Kleine-Budde

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=20211201220328.3079270-5-stefan.maetje@esd.eu \
    --to=stefan.maetje@esd.eu \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=wg@grandegger.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 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).