linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Jimmy Assarsson <extja@kvaser.com>
To: Vincent MAILHOL <mailhol.vincent@wanadoo.fr>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Oliver Hartkopp <socketcan@hartkopp.net>,
	linux-kernel@vger.kernel.org, Maxime Ripard <mripard@kernel.org>,
	linux-can@vger.kernel.org,
	Ludovic Desroches <ludovic.desroches@microchip.com>,
	Marc Kleine-Budde <mkl@pengutronix.de>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	netdev@vger.kernel.org, Chen-Yu Tsai <wens@csie.org>,
	Stephane Grosjean <s.grosjean@peak-system.com>,
	linux-sunxi@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	Yasushi SHOJI <yashi@spacecubics.com>
Subject: Re: [PATCH v3 5/5] can: do not increase tx_bytes statistics for RTR frames
Date: Fri, 3 Dec 2021 09:44:51 +0100	[thread overview]
Message-ID: <79c86cf6-26bd-6a84-81a3-577ae7f01c7d@kvaser.com> (raw)
In-Reply-To: <CAMZ6RqJ4WWAZSrk1AqS=TFbyrx7Ys49=fN-GTxkwh62GCS8Rqw@mail.gmail.com>

On 2021-12-03 02:05, Vincent MAILHOL wrote:
> On Fri. 3 Dec. 2021 at 08:35, Jimmy Assarsson <extja@kvaser.com> wrote:
>> On 2021-11-28 13:37, Vincent Mailhol wrote:
>>> 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:tx_bytes should not be increased when
>>> sending RTR frames.
>>>
>>> The function can_get_echo_skb() already returns the correct length,
>>> even for RTR frames (c.f. [1]). However, for historical reasons, the
>>> drivers do not use can_get_echo_skb()'s return value and instead, most
>>> of them store a temporary length (or dlc) in some local structure or
>>> array. Using the return value of can_get_echo_skb() solves the
>>> issue. After doing this, such length/dlc fields become unused and so
>>> this patch does the adequate cleaning when needed.
>>>
>>> This patch fixes all the CAN drivers.
>>>
>>> Finally, can_get_echo_skb() is decorated with the __must_check
>>> attribute in order to force future drivers to correctly use its return
>>> value (else the compiler would emit a warning).
>>>
>>> [1] commit ed3320cec279 ("can: dev: __can_get_echo_skb():
>>> fix real payload length return value for RTR frames")
>>
>> Hi Vincent!
>>
>> Thanks for the patch!
>> I've reviewed and tested the changes affecting kvaser_usb.
>> Looks good to me, only a minor nitpick inline :)

...

>>> diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
>>> index 17fabd3d0613..9f423a5fb63f 100644
>>> --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
>>> +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c

...

>>> @@ -1493,13 +1489,13 @@ kvaser_usb_hydra_frame_to_cmd_std(const struct kvaser_usb_net_priv *priv,
>>>        if (cf->can_id & CAN_RTR_FLAG)
>>>                flags |= KVASER_USB_HYDRA_CF_FLAG_REMOTE_FRAME;
>>>
>>> -     flags |= (cf->can_id & CAN_ERR_FLAG ?
>>> -               KVASER_USB_HYDRA_CF_FLAG_ERROR_FRAME : 0);
>>> +     if (cf->can_id & CAN_ERR_FLAG)
>>> +             flags |= KVASER_USB_HYDRA_CF_FLAG_ERROR_FRAME;
>>
>> This has nothing to do with RTR. Maybe put it in a separate patch?
> 
> Arg... You are right. This should not be here. I saw it in my
> final check, removed it in my tree and forgot to redo a "git
> format-patch".
> 
> This is some leftover of a previous version in which I did more
> heavy changes to kvaser_usb_hydra_frame_to_cmd_std(). This is
> purely cosmetic though. I am not willing to go into a clean up
> crusade of all CAN drivers so I will just leave the ternary
> operator untouched. Free to you to reuse it if you want to do a
> clean up later on.

Sure, I'll save it for later :) If you got more changes, feel free to share
them.

Best regards,
jimmy

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

      reply	other threads:[~2021-12-03  8:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-28 12:37 [PATCH v3 0/5] fix statistics and payload issues for error Vincent Mailhol
2021-11-28 12:37 ` [PATCH v3 1/5] can: do not increase rx statistics when generating a CAN rx error message frame Vincent Mailhol
2021-12-02 23:35   ` Jimmy Assarsson
2021-11-28 12:37 ` [PATCH v3 2/5] can: kvaser_usb: do not increase tx statistics when sending error message frames Vincent Mailhol
2021-12-02 23:35   ` Jimmy Assarsson
2021-12-03  4:02     ` Vincent MAILHOL
2021-12-03  8:45       ` Jimmy Assarsson
2021-11-28 12:37 ` [PATCH v3 3/5] can: do not copy the payload of RTR frames Vincent Mailhol
2021-11-28 12:37 ` [PATCH v3 4/5] can: do not increase rx_bytes statistics for " Vincent Mailhol
2021-12-02 23:35   ` Jimmy Assarsson
2021-11-28 12:37 ` [PATCH v3 5/5] can: do not increase tx_bytes " Vincent Mailhol
2021-12-02 23:35   ` Jimmy Assarsson
2021-12-03  1:05     ` Vincent MAILHOL
2021-12-03  8:44       ` Jimmy Assarsson [this message]

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=79c86cf6-26bd-6a84-81a3-577ae7f01c7d@kvaser.com \
    --to=extja@kvaser.com \
    --cc=alexandre.belloni@bootlin.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=mkl@pengutronix.de \
    --cc=mripard@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=s.grosjean@peak-system.com \
    --cc=socketcan@hartkopp.net \
    --cc=wens@csie.org \
    --cc=yashi@spacecubics.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).