[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aafec053-1054-4797-e1f1-e89586fe326f@hartkopp.net>
Date: Tue, 23 Nov 2021 22:01:04 +0100
From: Oliver Hartkopp <socketcan@...tkopp.net>
To: Vincent Mailhol <mailhol.vincent@...adoo.fr>,
Marc Kleine-Budde <mkl@...gutronix.de>,
linux-can@...r.kernel.org
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-sunxi@...ts.linux.dev,
Jimmy Assarsson <extja@...ser.com>,
Nicolas Ferre <nicolas.ferre@...rochip.com>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
Ludovic Desroches <ludovic.desroches@...rochip.com>,
Chandrasekar Ramakrishnan <rcsekar@...sung.com>,
Maxime Ripard <mripard@...nel.org>,
Chen-Yu Tsai <wens@...e.org>,
Jernej Skrabec <jernej.skrabec@...il.com>,
Appana Durga Kedareswara rao <appana.durga.rao@...inx.com>,
Naga Sureshkumar Relli <naga.sureshkumar.relli@...inx.com>,
Michal Simek <michal.simek@...inx.com>,
Stephane Grosjean <s.grosjean@...k-system.com>
Subject: Re: [PATCH v1 1/2] can: do not increase rx statistics when receiving
CAN error frames
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;
> + }
Powered by blists - more mailing lists