Subject: Re: Problem with frame time stamping

From: Eric Dumazet <[email-masked]>
Date: Tue, 13 Nov 2007 11:55:35 +0100

Antoine Zen-Ruffinen a écrit :
> This is exactly my problem : The driver of the network card I am using
> (see rt2x00.serialmonkey.com) do the minimum in the hardware interrupt
> (not filling skb->tstamp). Then netif_rx() is called later using a
> tasklet (also not filling skb->tstamp). As it seem to me (maybe I am
> wrong, if so please tell), the elapse time between the actual frame
> arrival and the time where netif_rx() do net_timestamp(skb) is not
> predicable !?
>
> Else, I would like to thank you to spend time helping me.
>
>
>   
A tasklet could process the skb much later than corresponding IRQ, 
depending on various things
(other tasks/softirqs on system with higher priorities). So yes, it is 
not predictable at all.

Usually it doesnt matter, but if your business depends on precise tstamps,
then just do skb->tstamp = ktime_get_real(); in IRQ handler (but it will 
slow it a bit,
depending on how fast is ktime_get_real() on the target machine)
netif_rx() wont overwrite it.

skb = dev_alloc_skb(desc.size + NET_IP_ALIGN);
if (!skb)
    return;
skb->tstamp = ktime_get_real(); /* do it before other copies */
skb_reserve(skb, NET_IP_ALIGN);
skb_put(skb, desc.size);
memcpy(skb->data, entry->data_addr, desc.size);

...