Thread (31 messages) 31 messages, 5 authors, 2020-07-20

Re: [PATCH v1 4/8] net: dsa: hellcreek: Add support for hardware timestamping

From: Kurt Kanzenbach <kurt@linutronix.de>
Date: 2020-07-13 06:35:46
Also in: netdev

On Sat Jul 11 2020, Richard Cochran wrote:
On Fri, Jul 10, 2020 at 01:36:07PM +0200, Kurt Kanzenbach wrote:
quoted
+static void hellcreek_get_rxts(struct hellcreek *hellcreek,
+			       struct hellcreek_port_hwtstamp *ps,
+			       struct sk_buff *skb, struct sk_buff_head *rxq,
+			       int port)
+{
+	struct skb_shared_hwtstamps *shwt;
+	struct sk_buff_head received;
+	unsigned long flags;
+
+	/* The latched timestamp belongs to one of the received frames. */
+	__skb_queue_head_init(&received);
+
+	/* Lock & disable interrupts */
+	spin_lock_irqsave(&rxq->lock, flags);
+
+	/* Add the reception queue "rxq" to the "received" queue an reintialize
+	 * "rxq".  From now on, we deal with "received" not with "rxq"
+	 */
+	skb_queue_splice_tail_init(rxq, &received);
+
+	spin_unlock_irqrestore(&rxq->lock, flags);
+
+	for (; skb; skb = __skb_dequeue(&received)) {
+		unsigned int type;
+		u8 *hdr;
+		u64 ns;
+
+		/* Get nanoseconds from ptp packet */
+		type = SKB_PTP_TYPE(skb);
+		hdr  = parse_ptp_header(skb, type);
+		ns   = hellcreek_get_reserved_field(hdr);
You might consider clearing the reserved field at this point.  Some
user space SW might consider non-zero reserved fields as corrupt!
Indeed. Never thought about it.

Thanks,
Kurt

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help