can: peak_usb: add peak_usb_netif_rx() new function
authorStephane Grosjean <s.grosjean@peak-system.com>
Fri, 23 Jan 2015 10:31:24 +0000 (11:31 +0100)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Wed, 28 Jan 2015 13:47:06 +0000 (14:47 +0100)
Add a common function that pushes the skb in the network queue with adding
timestamps information, converted from time values read from the
PEAK USB adapters.

Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/usb/peak_usb/pcan_usb_core.c
drivers/net/can/usb/peak_usb/pcan_usb_core.h

index ae8c448fd4d05cb1bdd63c2b5d2c401b702e1a17..7587337a3b4247213fa67cae9da3b6e6282b4d64 100644 (file)
@@ -163,6 +163,21 @@ void peak_usb_get_ts_tv(struct peak_time_ref *time_ref, u32 ts,
        }
 }
 
+/*
+ * post received skb after having set any hw timestamp
+ */
+int peak_usb_netif_rx(struct sk_buff *skb,
+                     struct peak_time_ref *time_ref, u32 ts_low, u32 ts_high)
+{
+       struct skb_shared_hwtstamps *hwts = skb_hwtstamps(skb);
+       struct timeval tv;
+
+       peak_usb_get_ts_tv(time_ref, ts_low, &tv);
+       hwts->hwtstamp = timeval_to_ktime(tv);
+
+       return netif_rx(skb);
+}
+
 /*
  * callback for bulk Rx urb
  */
index e8038b30bab59d1d9b83381a266c1b48555395d7..0e76b84fb7868b78647f30c8cf2b1656cc8962c9 100644 (file)
@@ -145,7 +145,9 @@ void peak_usb_update_ts_now(struct peak_time_ref *time_ref, u32 ts_now);
 void peak_usb_set_ts_now(struct peak_time_ref *time_ref, u32 ts_now);
 void peak_usb_get_ts_tv(struct peak_time_ref *time_ref, u32 ts,
                        struct timeval *tv);
-
+int peak_usb_netif_rx(struct sk_buff *skb,
+                     struct peak_time_ref *time_ref, u32 ts_low, u32 ts_high);
 void peak_usb_async_complete(struct urb *urb);
 void peak_usb_restart_complete(struct peak_usb_device *dev);
+
 #endif