Skip to contentSkip to conversation

peak_usb: timestamp issue

PATCH Oliver Hartkopp 2 participants 2 messages Nov 21, 2012 CAN network drivers

lore
Share & tools
lore
#0 lore raw

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

drivers/net/can/usb/peak_usb/pcan_usb.c +4 -2
index 86f26a1..4de6bf3 100644
@@ -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);
drivers/net/can/usb/peak_usb/pcan_usb_pro.c +4 -2
index e1626d9..52f3743 100644
@@ -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;
#1 lore raw
Quoted 14 lines · Oliver Hartkopp

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

Quoted 7 lines

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.

Oliver can you prepare a proper patch, which removes the broken time stamping, I'd like to get this into 3.7.

Marc

Signature · 4 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |