* [RFC PATCH] can: dev: update rx state in the can_get_echo_skb()
@ 2012-06-28 9:42 Hui Wang
2012-06-28 10:59 ` Wolfgang Grandegger
2012-06-28 10:59 ` Kurt Van Dijck
0 siblings, 2 replies; 5+ messages in thread
From: Hui Wang @ 2012-06-28 9:42 UTC (permalink / raw)
To: mkl, shawn.guo, wg; +Cc: linux-can
After a loopback packet is routed to rx interface, we forget to update
rx state both in the can_get_echo_skb() and in the controller specific
drivers, as a result, after we sent a loopback packet and executed
ifconfig, following state is outputed:
can0 Link encap:UNSPEC HWaddr 00-00-00-00-<snip>
UP RUNNING NOARP MTU:16 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:10
RX bytes:0 (0.0 B) TX bytes:4 (4.0 B)
We add rx state update in the can_get_echo_skb() to solve this
problem.
Cc: linux-can@vger.kernel.org
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Wolfgang Grandegger <wg@grandegger.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Hui Wang <jason77.wang@gmail.com>
---
I don't know if it is designed like that on purpose, please instruct
me if i am wrong.
I use following commands to let flexcan to work in the loopback mode:
%>ip link set can0 type can bitrate 125000
%>ip link set can0 type can loopback on
%>ip link set can0 up
And send a packet:
%>cantest can0 123#AABBCCDD
When i check net device state, i found tx doesn't equal rx:
%>ifconfig
can0 Link encap:UNSPEC HWaddr 00-00-00-00-<snip>
UP RUNNING NOARP MTU:16 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:10
RX bytes:0 (0.0 B) TX bytes:4 (4.0 B)
From my understanding, i suppose it should be:
can0 Link encap:UNSPEC HWaddr 00-00-00-00-<snip>
UP RUNNING NOARP MTU:16 Metric:1
RX packets:1 errors:0 dropped:0 overruns:0 frame:0
TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:10
RX bytes:4 (4.0 B) TX bytes:4 (4.0 B)
drivers/net/can/dev.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index f03d7a4..6b62f6a 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -340,6 +340,9 @@ unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx)
netif_rx(priv->echo_skb[idx]);
priv->echo_skb[idx] = NULL;
+ dev->stats.rx_bytes += dlc;
+ dev->stats.rx_packets++;
+
return dlc;
}
--
1.7.6
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [RFC PATCH] can: dev: update rx state in the can_get_echo_skb()
2012-06-28 9:42 [RFC PATCH] can: dev: update rx state in the can_get_echo_skb() Hui Wang
@ 2012-06-28 10:59 ` Wolfgang Grandegger
2012-07-02 3:36 ` Hui Wang
2012-06-28 10:59 ` Kurt Van Dijck
1 sibling, 1 reply; 5+ messages in thread
From: Wolfgang Grandegger @ 2012-06-28 10:59 UTC (permalink / raw)
To: Hui Wang; +Cc: mkl, shawn.guo, linux-can
On 06/28/2012 11:42 AM, Hui Wang wrote:
> After a loopback packet is routed to rx interface, we forget to update
> rx state both in the can_get_echo_skb() and in the controller specific
> drivers, as a result, after we sent a loopback packet and executed
> ifconfig, following state is outputed:
> can0 Link encap:UNSPEC HWaddr 00-00-00-00-<snip>
> UP RUNNING NOARP MTU:16 Metric:1
> RX packets:0 errors:0 dropped:0 overruns:0 frame:0
> TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
> collisions:0 txqueuelen:10
> RX bytes:0 (0.0 B) TX bytes:4 (4.0 B)
>
> We add rx state update in the can_get_echo_skb() to solve this
> problem.
Well...
> Cc: linux-can@vger.kernel.org
> Cc: Marc Kleine-Budde <mkl@pengutronix.de>
> Cc: Wolfgang Grandegger <wg@grandegger.com>
> Cc: Shawn Guo <shawn.guo@linaro.org>
> Signed-off-by: Hui Wang <jason77.wang@gmail.com>
> ---
> I don't know if it is designed like that on purpose, please instruct
> me if i am wrong.
>
> I use following commands to let flexcan to work in the loopback mode:
> %>ip link set can0 type can bitrate 125000
> %>ip link set can0 type can loopback on
> %>ip link set can0 up
> And send a packet:
> %>cantest can0 123#AABBCCDD
> When i check net device state, i found tx doesn't equal rx:
> %>ifconfig
> can0 Link encap:UNSPEC HWaddr 00-00-00-00-<snip>
> UP RUNNING NOARP MTU:16 Metric:1
> RX packets:0 errors:0 dropped:0 overruns:0 frame:0
> TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
This means that one message has successfully been sent to the *real* CAN
bus.
> collisions:0 txqueuelen:10
> RX bytes:0 (0.0 B) TX bytes:4 (4.0 B)
>
>>From my understanding, i suppose it should be:
> can0 Link encap:UNSPEC HWaddr 00-00-00-00-<snip>
> UP RUNNING NOARP MTU:16 Metric:1
> RX packets:1 errors:0 dropped:0 overruns:0 frame:0
> TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
> collisions:0 txqueuelen:10
> RX bytes:4 (4.0 B) TX bytes:4 (4.0 B)
Why, you have not received any message from the CAN bus. If you want to
count looped back messages, it should be:
RX packets:1 errors:0 dropped:0 overruns:0 frame:0
TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
Wolfgang.
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [RFC PATCH] can: dev: update rx state in the can_get_echo_skb()
2012-06-28 10:59 ` Wolfgang Grandegger
@ 2012-07-02 3:36 ` Hui Wang
0 siblings, 0 replies; 5+ messages in thread
From: Hui Wang @ 2012-07-02 3:36 UTC (permalink / raw)
To: Wolfgang Grandegger; +Cc: Hui Wang, mkl, shawn.guo, linux-can
Wolfgang Grandegger wrote:
> On 06/28/2012 11:42 AM, Hui Wang wrote:
>
>> After a loopback packet is routed to rx interface, we forget to update
>> rx state both in the can_get_echo_skb() and in the controller specific
>> drivers, as a result, after we sent a loopback packet and executed
>> ifconfig, following state is outputed:
>> can0 Link encap:UNSPEC HWaddr 00-00-00-00-<snip>
>> UP RUNNING NOARP MTU:16 Metric:1
>> RX packets:0 errors:0 dropped:0 overruns:0 frame:0
>> TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
>> collisions:0 txqueuelen:10
>> RX bytes:0 (0.0 B) TX bytes:4 (4.0 B)
>>
>> We add rx state update in the can_get_echo_skb() to solve this
>> problem.
>>
>
> Well...
>
>
>> Cc: linux-can@vger.kernel.org
>> Cc: Marc Kleine-Budde <mkl@pengutronix.de>
>> Cc: Wolfgang Grandegger <wg@grandegger.com>
>> Cc: Shawn Guo <shawn.guo@linaro.org>
>> Signed-off-by: Hui Wang <jason77.wang@gmail.com>
>> ---
>> I don't know if it is designed like that on purpose, please instruct
>> me if i am wrong.
>>
>> I use following commands to let flexcan to work in the loopback mode:
>> %>ip link set can0 type can bitrate 125000
>> %>ip link set can0 type can loopback on
>> %>ip link set can0 up
>> And send a packet:
>> %>cantest can0 123#AABBCCDD
>> When i check net device state, i found tx doesn't equal rx:
>> %>ifconfig
>> can0 Link encap:UNSPEC HWaddr 00-00-00-00-<snip>
>> UP RUNNING NOARP MTU:16 Metric:1
>> RX packets:0 errors:0 dropped:0 overruns:0 frame:0
>> TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
>>
>
> This means that one message has successfully been sent to the *real* CAN
> bus.
>
>
>> collisions:0 txqueuelen:10
>> RX bytes:0 (0.0 B) TX bytes:4 (4.0 B)
>>
>> >From my understanding, i suppose it should be:
>> can0 Link encap:UNSPEC HWaddr 00-00-00-00-<snip>
>> UP RUNNING NOARP MTU:16 Metric:1
>> RX packets:1 errors:0 dropped:0 overruns:0 frame:0
>> TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
>> collisions:0 txqueuelen:10
>> RX bytes:4 (4.0 B) TX bytes:4 (4.0 B)
>>
>
> Why, you have not received any message from the CAN bus. If you want to
> count looped back messages, it should be:
>
>
You mean CAN bus didn't receive a packet, the RX state of CAN0 is 0. It
is a reasonable explanation.
Thanks,
Hui.
> RX packets:1 errors:0 dropped:0 overruns:0 frame:0
> TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
>
> Wolfgang.
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH] can: dev: update rx state in the can_get_echo_skb()
2012-06-28 9:42 [RFC PATCH] can: dev: update rx state in the can_get_echo_skb() Hui Wang
2012-06-28 10:59 ` Wolfgang Grandegger
@ 2012-06-28 10:59 ` Kurt Van Dijck
2012-07-02 3:42 ` Hui Wang
1 sibling, 1 reply; 5+ messages in thread
From: Kurt Van Dijck @ 2012-06-28 10:59 UTC (permalink / raw)
To: Hui Wang; +Cc: mkl, shawn.guo, wg, linux-can
Hi,
A loopback packet enters the rx interface of the CAN subsystem,
but it had never entered the chip's receive path.
IMHO it's bad to alter the chip's statistics the way you propose.
Are you interested in the number of packets/bytes
that you were able to receive on your socket?
How about adding echo statistics in the CAN device stats,
as shown in
$ ip -d -s link show can0
Kind regards,
Kurt
On Thu, Jun 28, 2012 at 05:42:20PM +0800, Hui Wang wrote:
> After a loopback packet is routed to rx interface, we forget to update
> rx state both in the can_get_echo_skb() and in the controller specific
> drivers, as a result, after we sent a loopback packet and executed
> ifconfig, following state is outputed:
> can0 Link encap:UNSPEC HWaddr 00-00-00-00-<snip>
> UP RUNNING NOARP MTU:16 Metric:1
> RX packets:0 errors:0 dropped:0 overruns:0 frame:0
> TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
> collisions:0 txqueuelen:10
> RX bytes:0 (0.0 B) TX bytes:4 (4.0 B)
>
> We add rx state update in the can_get_echo_skb() to solve this
> problem.
>
> Cc: linux-can@vger.kernel.org
> Cc: Marc Kleine-Budde <mkl@pengutronix.de>
> Cc: Wolfgang Grandegger <wg@grandegger.com>
> Cc: Shawn Guo <shawn.guo@linaro.org>
> Signed-off-by: Hui Wang <jason77.wang@gmail.com>
> ---
> I don't know if it is designed like that on purpose, please instruct
> me if i am wrong.
>
> I use following commands to let flexcan to work in the loopback mode:
> %>ip link set can0 type can bitrate 125000
> %>ip link set can0 type can loopback on
> %>ip link set can0 up
> And send a packet:
> %>cantest can0 123#AABBCCDD
> When i check net device state, i found tx doesn't equal rx:
> %>ifconfig
> can0 Link encap:UNSPEC HWaddr 00-00-00-00-<snip>
> UP RUNNING NOARP MTU:16 Metric:1
> RX packets:0 errors:0 dropped:0 overruns:0 frame:0
> TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
> collisions:0 txqueuelen:10
> RX bytes:0 (0.0 B) TX bytes:4 (4.0 B)
>
> From my understanding, i suppose it should be:
> can0 Link encap:UNSPEC HWaddr 00-00-00-00-<snip>
> UP RUNNING NOARP MTU:16 Metric:1
> RX packets:1 errors:0 dropped:0 overruns:0 frame:0
> TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
> collisions:0 txqueuelen:10
> RX bytes:4 (4.0 B) TX bytes:4 (4.0 B)
>
> drivers/net/can/dev.c | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
> index f03d7a4..6b62f6a 100644
> --- a/drivers/net/can/dev.c
> +++ b/drivers/net/can/dev.c
> @@ -340,6 +340,9 @@ unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx)
> netif_rx(priv->echo_skb[idx]);
> priv->echo_skb[idx] = NULL;
>
> + dev->stats.rx_bytes += dlc;
> + dev->stats.rx_packets++;
> +
> return dlc;
> }
>
> --
> 1.7.6
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-can" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Kurt Van Dijck
GRAMMER EiA ELECTRONICS
http://www.eia.be
kurt.van.dijck@eia.be
+32-38708534
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH] can: dev: update rx state in the can_get_echo_skb()
2012-06-28 10:59 ` Kurt Van Dijck
@ 2012-07-02 3:42 ` Hui Wang
0 siblings, 0 replies; 5+ messages in thread
From: Hui Wang @ 2012-07-02 3:42 UTC (permalink / raw)
To: Hui Wang, mkl, shawn.guo, wg, linux-can
Kurt Van Dijck wrote:
> Hi,
>
> A loopback packet enters the rx interface of the CAN subsystem,
> but it had never entered the chip's receive path.
> IMHO it's bad to alter the chip's statistics the way you propose.
>
Your explanation makes sense to me.
> Are you interested in the number of packets/bytes
> that you were able to receive on your socket?
> How about adding echo statistics in the CAN device stats,
> as shown in
> $ ip -d -s link show can0
>
It can work.
Thanks,
Hui.
> Kind regards,
> Kurt
>
> On Thu, Jun 28, 2012 at 05:42:20PM +0800, Hui Wang wrote:
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-07-02 3:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-28 9:42 [RFC PATCH] can: dev: update rx state in the can_get_echo_skb() Hui Wang
2012-06-28 10:59 ` Wolfgang Grandegger
2012-07-02 3:36 ` Hui Wang
2012-06-28 10:59 ` Kurt Van Dijck
2012-07-02 3:42 ` Hui Wang
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).