From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Stephane Grosjean <s.grosjean@peak-system.com>
Cc: "linux-can@vger.kernel.org" <linux-can@vger.kernel.org>
Subject: peak_usb: timestamp issue
Date: Wed, 21 Nov 2012 16:34:22 +0100 [thread overview]
Message-ID: <50ACF47E.7010004@hartkopp.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 703 bytes --]
Hi Stephane,
i was working with the PEAK USB adapter today and got the problem of different
timestamps with 'candump -x -ta can0':
Timestamps of received CAN frames looked like my system 'uptime'.
Send CAN frames had the real system time.
The problem is, that you insert the hardware timestamp of the PEAK USB
adapters into skb->tstamp ...
This is wrong. For hardware timestamps (RX/TX) there's a special handling in
the Linux Kernel, see at
linux/Documentation/networking/timestamping.txt
For now i just removed the setting of your HW timestamps on my Linux box (see
attached patch).
Please fix the HW timestamp handling in your driver by supporting the HW
timstamp API correctly.
Tnx,
Oliver
[-- Attachment #2: peak_usb_ts_hack.patch --]
[-- Type: text/x-patch, Size: 2050 bytes --]
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb.c b/drivers/net/can/usb/peak_usb/pcan_usb.c
index 86f26a1..4de6bf3 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb.c
@@ -520,7 +520,8 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,
if (status_len & PCAN_USB_STATUSLEN_TIMESTAMP) {
peak_usb_get_ts_tv(&mc->pdev->time_ref, mc->ts16, &tv);
- skb->tstamp = timeval_to_ktime(tv);
+ /* HACK to disable wrongly introduced hardware timestamp */
+ //skb->tstamp = timeval_to_ktime(tv);
}
netif_rx(skb);
@@ -652,7 +653,8 @@ static int pcan_usb_decode_data(struct pcan_usb_msg_context *mc, u8 status_len)
/* convert timestamp into kernel time */
peak_usb_get_ts_tv(&mc->pdev->time_ref, mc->ts16, &tv);
- skb->tstamp = timeval_to_ktime(tv);
+ /* HACK to disable wrongly introduced hardware timestamp */
+ //skb->tstamp = timeval_to_ktime(tv);
/* push the skb */
netif_rx(skb);
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
index e1626d9..52f3743 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
@@ -549,7 +549,8 @@ static int pcan_usb_pro_handle_canmsg(struct pcan_usb_pro_interface *usb_if,
memcpy(can_frame->data, rx->data, can_frame->can_dlc);
peak_usb_get_ts_tv(&usb_if->time_ref, le32_to_cpu(rx->ts32), &tv);
- skb->tstamp = timeval_to_ktime(tv);
+ /* HACK to disable wrongly introduced hardware timestamp */
+ //skb->tstamp = timeval_to_ktime(tv);
netif_rx(skb);
netdev->stats.rx_packets++;
@@ -664,7 +665,8 @@ static int pcan_usb_pro_handle_error(struct pcan_usb_pro_interface *usb_if,
dev->can.state = new_state;
peak_usb_get_ts_tv(&usb_if->time_ref, le32_to_cpu(er->ts32), &tv);
- skb->tstamp = timeval_to_ktime(tv);
+ /* HACK to disable wrongly introduced hardware timestamp */
+ //skb->tstamp = timeval_to_ktime(tv);
netif_rx(skb);
netdev->stats.rx_packets++;
netdev->stats.rx_bytes += can_frame->can_dlc;
next reply other threads:[~2012-11-21 15:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-21 15:34 Oliver Hartkopp [this message]
2012-11-21 15:58 ` peak_usb: timestamp issue Marc Kleine-Budde
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=50ACF47E.7010004@hartkopp.net \
--to=socketcan@hartkopp.net \
--cc=linux-can@vger.kernel.org \
--cc=s.grosjean@peak-system.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.