From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Vincent Mailhol <mailhol.vincent@wanadoo.fr>,
Marc Kleine-Budde <mkl@pengutronix.de>,
linux-can@vger.kernel.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev, Jimmy Assarsson <extja@kvaser.com>,
Nicolas Ferre <nicolas.ferre@microchip.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Ludovic Desroches <ludovic.desroches@microchip.com>,
Chandrasekar Ramakrishnan <rcsekar@samsung.com>,
Maxime Ripard <mripard@kernel.org>, Chen-Yu Tsai <wens@csie.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Appana Durga Kedareswara rao <appana.durga.rao@xilinx.com>,
Naga Sureshkumar Relli <naga.sureshkumar.relli@xilinx.com>,
Michal Simek <michal.simek@xilinx.com>,
Stephane Grosjean <s.grosjean@peak-system.com>
Subject: Re: [PATCH v1 1/2] can: do not increase rx statistics when receiving CAN error frames
Date: Tue, 23 Nov 2021 22:01:04 +0100 [thread overview]
Message-ID: <aafec053-1054-4797-e1f1-e89586fe326f@hartkopp.net> (raw)
In-Reply-To: <20211123115333.624335-2-mailhol.vincent@wanadoo.fr>
On 23.11.21 12:53, Vincent Mailhol wrote:
> CAN error skb is an interface specific to socket CAN. The CAN error
> skb does not correspond to any actual CAN frame sent on the wire. Only
> an error flag and a delimiter are transmitted when an error occurs
> (c.f. ISO 11898-1 section 10.4.4.2 "Error flag").
>
> For this reason, it makes no sense to increment the rx_packets and
> rx_bytes fields of struct net_device_stats because no actual payload
> were transmitted on the wire.
>
(..)
> diff --git a/drivers/net/can/dev/rx-offload.c b/drivers/net/can/dev/rx-offload.c
> index 37b0cc65237b..bb47e9a49240 100644
> --- a/drivers/net/can/dev/rx-offload.c
> +++ b/drivers/net/can/dev/rx-offload.c
> @@ -54,8 +54,10 @@ static int can_rx_offload_napi_poll(struct napi_struct *napi, int quota)
> struct can_frame *cf = (struct can_frame *)skb->data;
>
> work_done++;
> - stats->rx_packets++;
> - stats->rx_bytes += cf->len;
> + if (!(cf->can_id & CAN_ERR_MASK)) {
This looks wrong.
Did you think of CAN_ERR_FLAG ??
> + stats->rx_packets++;
> + stats->rx_bytes += cf->len;
> + }
> netif_receive_skb(skb);
(..)
> diff --git a/drivers/net/can/usb/ucan.c b/drivers/net/can/usb/ucan.c
> index 1679cbe45ded..d582c39fc8d0 100644
> --- a/drivers/net/can/usb/ucan.c
> +++ b/drivers/net/can/usb/ucan.c
> @@ -621,8 +621,10 @@ static void ucan_rx_can_msg(struct ucan_priv *up, struct ucan_message_in *m)
> memcpy(cf->data, m->msg.can_msg.data, cf->len);
>
> /* don't count error frames as real packets */
> - stats->rx_packets++;
> - stats->rx_bytes += cf->len;
> + if (!(cf->can_id & CAN_ERR_FLAG)) {
Ah, here we are :-)
> + stats->rx_packets++;
> + stats->rx_bytes += cf->len;
> + }
next prev parent reply other threads:[~2021-11-23 21:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-23 11:53 [PATCH v1 0/2] fix statistics for CAN RTR and Error frames Vincent Mailhol
2021-11-23 11:53 ` [PATCH v1 1/2] can: do not increase rx statistics when receiving CAN error frames Vincent Mailhol
2021-11-23 21:01 ` Oliver Hartkopp [this message]
2021-11-23 23:21 ` Vincent MAILHOL
2021-11-23 11:53 ` [PATCH v1 2/2] can: do not increase rx_bytes statistics for RTR frames Vincent Mailhol
2021-11-23 18:10 ` Vincent MAILHOL
2021-11-24 17:59 ` Stefan Mätje
2021-11-24 23:55 ` Vincent MAILHOL
2021-11-23 21:10 ` [PATCH v1 0/2] fix statistics for CAN RTR and Error frames Oliver Hartkopp
2021-11-23 23:35 ` Vincent MAILHOL
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=aafec053-1054-4797-e1f1-e89586fe326f@hartkopp.net \
--to=socketcan@hartkopp.net \
--cc=alexandre.belloni@bootlin.com \
--cc=appana.durga.rao@xilinx.com \
--cc=extja@kvaser.com \
--cc=jernej.skrabec@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=ludovic.desroches@microchip.com \
--cc=mailhol.vincent@wanadoo.fr \
--cc=michal.simek@xilinx.com \
--cc=mkl@pengutronix.de \
--cc=mripard@kernel.org \
--cc=naga.sureshkumar.relli@xilinx.com \
--cc=netdev@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=rcsekar@samsung.com \
--cc=s.grosjean@peak-system.com \
--cc=wens@csie.org \
/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
all inboxes | Powered by JetHome®