* TX timestamping
@ 2014-03-20 16:28 Pavel Kirienko
2014-03-22 19:22 ` Oliver Hartkopp
0 siblings, 1 reply; 4+ messages in thread
From: Pavel Kirienko @ 2014-03-20 16:28 UTC (permalink / raw)
To: linux-can
Hi linux-can,
What are my options to get the hardware TX timestamp of an outgoing
CAN frame? I couldn't find complete manual for that, but here's what I
googled so far:
1. Use generic socket timestamping, as described in the network man
(http://os1a.cs.columbia.edu/lxr/source/Documentation/networking/timestamping.txt?a=x86);
2. Read my own frames back through CAN_RAW_RECV_OWN_MSGS, supposedly
RX timestamps of the loopbacked frames will be the same as their TX
timestamps.
Are these the correct methods?
Thanks in advance,
Pavel.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: TX timestamping
2014-03-20 16:28 TX timestamping Pavel Kirienko
@ 2014-03-22 19:22 ` Oliver Hartkopp
2014-03-30 17:17 ` Pavel Kirienko
0 siblings, 1 reply; 4+ messages in thread
From: Oliver Hartkopp @ 2014-03-22 19:22 UTC (permalink / raw)
To: Pavel Kirienko, linux-can
Hello Pavel,
On 20.03.2014 17:28, Pavel Kirienko wrote:
> Hi linux-can,
>
> What are my options to get the hardware TX timestamp of an outgoing
> CAN frame? I couldn't find complete manual for that, but here's what I
> googled so far:
>
> 1. Use generic socket timestamping, as described in the network man
> (http://os1a.cs.columbia.edu/lxr/source/Documentation/networking/timestamping.txt?a=x86);
>
> 2. Read my own frames back through CAN_RAW_RECV_OWN_MSGS, supposedly
> RX timestamps of the loopbacked frames will be the same as their TX
> timestamps.
>
> Are these the correct methods?
Yes.
With CAN_RAW_RECV_OWN_MSGS you get the echoed frame on a socket which
originally sent the frame.
The timestamps are currently only set at RX time.
http://os1a.cs.columbia.edu/lxr/source/net/core/dev.c?a=x86#2864
http://os1a.cs.columbia.edu/lxr/source/net/core/dev.c?a=x86#1463
As you can see in net_timestamp_check()
http://os1a.cs.columbia.edu/lxr/source/net/core/dev.c?a=x86#1471
the timestamp is only set if it was empty before.
E.g. if you forward a CAN frame with can-gw there's an extra option to not
clear the timestamp when routing the frame (option -t [preserve src_dev rx
timestamp]).
As the sent frames are echoed back you are pretty right that the RX timestamp
and the TX timestamp are the same.
Regards,
Oliver
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: TX timestamping
2014-03-22 19:22 ` Oliver Hartkopp
@ 2014-03-30 17:17 ` Pavel Kirienko
2014-03-30 17:31 ` Pavel Kirienko
0 siblings, 1 reply; 4+ messages in thread
From: Pavel Kirienko @ 2014-03-30 17:17 UTC (permalink / raw)
To: Oliver Hartkopp; +Cc: linux-can
Thanks Oliver!
I'm facing an issue with timestamping (not only TX), I hope someone
could help me with that.
The problem is that I don't receive control message with timestamp
from recvmsg(), although SO_TIMESTAMP is enabled.
Here's how I open the socket and read from it: http://pastebin.com/2iQrQuY3
Problem is at line 78 - recvmsg() returns no control messages.
$ uname -a
Linux spym-pc 3.2.0-60-generic #91-Ubuntu SMP Wed Feb 19 03:54:44 UTC
2014 x86_64 x86_64 x86_64 GNU/Linux
What I'm doing wrong?
Thanks in advance,
Pavel.
On Sat, Mar 22, 2014 at 11:22 PM, Oliver Hartkopp
<socketcan@hartkopp.net> wrote:
> Hello Pavel,
>
> On 20.03.2014 17:28, Pavel Kirienko wrote:
>> Hi linux-can,
>>
>> What are my options to get the hardware TX timestamp of an outgoing
>> CAN frame? I couldn't find complete manual for that, but here's what I
>> googled so far:
>>
>> 1. Use generic socket timestamping, as described in the network man
>> (http://os1a.cs.columbia.edu/lxr/source/Documentation/networking/timestamping.txt?a=x86);
>>
>> 2. Read my own frames back through CAN_RAW_RECV_OWN_MSGS, supposedly
>> RX timestamps of the loopbacked frames will be the same as their TX
>> timestamps.
>>
>> Are these the correct methods?
>
> Yes.
>
> With CAN_RAW_RECV_OWN_MSGS you get the echoed frame on a socket which
> originally sent the frame.
>
> The timestamps are currently only set at RX time.
>
> http://os1a.cs.columbia.edu/lxr/source/net/core/dev.c?a=x86#2864
> http://os1a.cs.columbia.edu/lxr/source/net/core/dev.c?a=x86#1463
>
> As you can see in net_timestamp_check()
>
> http://os1a.cs.columbia.edu/lxr/source/net/core/dev.c?a=x86#1471
>
> the timestamp is only set if it was empty before.
>
> E.g. if you forward a CAN frame with can-gw there's an extra option to not
> clear the timestamp when routing the frame (option -t [preserve src_dev rx
> timestamp]).
>
> As the sent frames are echoed back you are pretty right that the RX timestamp
> and the TX timestamp are the same.
>
> Regards,
> Oliver
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: TX timestamping
2014-03-30 17:17 ` Pavel Kirienko
@ 2014-03-30 17:31 ` Pavel Kirienko
0 siblings, 0 replies; 4+ messages in thread
From: Pavel Kirienko @ 2014-03-30 17:31 UTC (permalink / raw)
To: Oliver Hartkopp; +Cc: linux-can
Whoops sorry, I messed up msghdr initialization. Of course
msg_controllen would be zero since I provided no buffer for the
control message.
Works now.
On Sun, Mar 30, 2014 at 9:17 PM, Pavel Kirienko
<pavel.kirienko.list@gmail.com> wrote:
> Thanks Oliver!
>
> I'm facing an issue with timestamping (not only TX), I hope someone
> could help me with that.
>
> The problem is that I don't receive control message with timestamp
> from recvmsg(), although SO_TIMESTAMP is enabled.
> Here's how I open the socket and read from it: http://pastebin.com/2iQrQuY3
> Problem is at line 78 - recvmsg() returns no control messages.
>
> $ uname -a
> Linux spym-pc 3.2.0-60-generic #91-Ubuntu SMP Wed Feb 19 03:54:44 UTC
> 2014 x86_64 x86_64 x86_64 GNU/Linux
>
> What I'm doing wrong?
>
> Thanks in advance,
> Pavel.
>
> On Sat, Mar 22, 2014 at 11:22 PM, Oliver Hartkopp
> <socketcan@hartkopp.net> wrote:
>> Hello Pavel,
>>
>> On 20.03.2014 17:28, Pavel Kirienko wrote:
>>> Hi linux-can,
>>>
>>> What are my options to get the hardware TX timestamp of an outgoing
>>> CAN frame? I couldn't find complete manual for that, but here's what I
>>> googled so far:
>>>
>>> 1. Use generic socket timestamping, as described in the network man
>>> (http://os1a.cs.columbia.edu/lxr/source/Documentation/networking/timestamping.txt?a=x86);
>>>
>>> 2. Read my own frames back through CAN_RAW_RECV_OWN_MSGS, supposedly
>>> RX timestamps of the loopbacked frames will be the same as their TX
>>> timestamps.
>>>
>>> Are these the correct methods?
>>
>> Yes.
>>
>> With CAN_RAW_RECV_OWN_MSGS you get the echoed frame on a socket which
>> originally sent the frame.
>>
>> The timestamps are currently only set at RX time.
>>
>> http://os1a.cs.columbia.edu/lxr/source/net/core/dev.c?a=x86#2864
>> http://os1a.cs.columbia.edu/lxr/source/net/core/dev.c?a=x86#1463
>>
>> As you can see in net_timestamp_check()
>>
>> http://os1a.cs.columbia.edu/lxr/source/net/core/dev.c?a=x86#1471
>>
>> the timestamp is only set if it was empty before.
>>
>> E.g. if you forward a CAN frame with can-gw there's an extra option to not
>> clear the timestamp when routing the frame (option -t [preserve src_dev rx
>> timestamp]).
>>
>> As the sent frames are echoed back you are pretty right that the RX timestamp
>> and the TX timestamp are the same.
>>
>> Regards,
>> Oliver
>>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-03-30 17:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-20 16:28 TX timestamping Pavel Kirienko
2014-03-22 19:22 ` Oliver Hartkopp
2014-03-30 17:17 ` Pavel Kirienko
2014-03-30 17:31 ` Pavel Kirienko
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).