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

Kurt Kanzenbach
2020-07-13T06:35:46Z

[-- Attachment #1: Type: text/plain, Size: 1346 bytes --]

On Sat Jul 11 2020, Richard Cochran wrote:
> On Fri, Jul 10, 2020 at 01:36:07PM +0200, Kurt Kanzenbach wrote:
>> +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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]