From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Reuben Dowle <Reuben.Dowle@navico.com>
Cc: Kurt Van Dijck <kurt.van.dijck@eia.be>,
netdev@vger.kernel.org, linux-can@vger.kernel.org
Subject: Re: [PATCH] flexcan: Fix CAN_RAW_RECV_OWN_MSGS and CAN_RAW_LOOPBACK
Date: Wed, 02 Nov 2011 21:30:59 +0100 [thread overview]
Message-ID: <4EB1A883.2040605@hartkopp.net> (raw)
In-Reply-To: <70F6AAAFDC054F41B9994A9BCD3DF64E16FAA803@exch01-aklnz.MARINE.NET.INT>
On 02.11.2011 20:46, Reuben Dowle wrote:
>>> flexcan_write(ctrl, ®s->cantxfg[FLEXCAN_TX_BUF_ID].can_ctrl);
>>>
>>> - kfree_skb(skb);
>>> + can_put_echo_skb(skb, dev, 0);
>>>
>>> /* tx_packets is incremented in flexcan_irq */
>>> stats->tx_bytes += cf->can_dlc;
>> Why not move the statistics to the place where the echo_skb is popped?
>> When no frame gets out (due to whatever reason), the statistics may
>> have
>> incremented.
>>
>> Or maybe this needs a seperate patch?
>>
>> The rest looks good.
>>
>> Kurt
>
> I think you are right - incrementing the tx_bytes at this point does not seem right. It makes most sense to increment the bytes and packets at the same time when tx is confirmed by the interrupt. Looking through the various can drivers, there seems to be 2 approaches to this: at91, slcan and flexcan are incrementing tx_bytes when tx is started, and tx_packets in complete irq, whereas vcan, mcp251x, pch, hecc, softing, sja1000, c_can do it in tx complete irq.
>
> So I think this is a slightly different issue to the one I was patching, which affects a couple of drivers. The majority of drivers seem to be doing it the way you suggest, but I am not familiar enough with the linux can layer to say one way or the other. I think if it is done how flexcan is doing it, then you would get tx_bytes always gets incremented, even when the tx is dropped due to bus off.
>
> If we change the behaviour of flexcan, I think at91 and slcan should be changed too, because this should be handled consistently across all drivers I would think.
At least the slcan driver does not support the correct echo of CAN frames on
driver level at all. The slcan driver adapts CAN frames to a serial line CAN
adapter where the feedback of successful transmission is not
guaranteed/checked within the serial data stream. Therefore the interface flag
IFF_ECHO is not set in the slcan driver and the local echo is performed in
af_can.c (as a workaround).
Regards,
Oliver
next prev parent reply other threads:[~2011-11-02 20:31 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-31 22:18 [PATCH] flexcan: Fix CAN_RAW_RECV_OWN_MSGS and CAN_RAW_LOOPBACK Reuben Dowle
2011-10-31 22:31 ` Marc Kleine-Budde
2011-10-31 22:43 ` Reuben Dowle
2011-10-31 22:49 ` Marc Kleine-Budde
2011-11-02 0:25 ` Reuben Dowle
2011-11-02 8:04 ` Kurt Van Dijck
2011-11-02 19:46 ` Reuben Dowle
2011-11-02 20:30 ` Oliver Hartkopp [this message]
2011-11-02 21:31 ` Reuben Dowle
2011-11-03 9:47 ` [PATCH 0/2] clean up tx_bytes accounting Marc Kleine-Budde
2011-11-03 9:47 ` [PATCH 1/2] can: dev: let can_get_echo_skb() return dlc of CAN frame Marc Kleine-Budde
2011-11-03 9:47 ` [PATCH 2/2] flexcan: Fix CAN_RAW_RECV_OWN_MSGS and CAN_RAW_LOOPBACK Marc Kleine-Budde
2011-11-03 9:59 ` Marc Kleine-Budde
2011-11-03 10:03 ` Oliver Hartkopp
2011-11-03 10:17 ` Marc Kleine-Budde
2011-11-03 10:03 ` [PATCH 0/2] clean up tx_bytes accounting Kurt Van Dijck
2011-11-03 10:42 ` Marc Kleine-Budde
2011-11-03 14:27 ` Oliver Hartkopp
2011-11-03 14:37 ` Kurt Van Dijck
2011-11-03 15:03 ` Marc Kleine-Budde
2011-11-03 14:54 ` [PATCH] flexcan: Fix CAN_RAW_RECV_OWN_MSGS and CAN_RAW_LOOPBACK Oliver Hartkopp
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=4EB1A883.2040605@hartkopp.net \
--to=socketcan@hartkopp.net \
--cc=Reuben.Dowle@navico.com \
--cc=kurt.van.dijck@eia.be \
--cc=linux-can@vger.kernel.org \
--cc=netdev@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).