I'm trying to calculate the transmit time for a frame by comparing the TX timestamp with the timestamp of the following ACK frame using a second monitor VAP.
The problem is the following: TX timestamps (both kernel skb timestamp and TSF) reported are not in order, e.g.:
Packet skb time TSF
RX ping 0.439128 0xfc68b245
TX ping-reply 0.437567 0xfc681a2b
RX ACK 0.439651 0xfc68b455
The timestamps of the TX packet are off by some milliseconds. While the skb time is probably set _before_ the packet is enqueued in the driver, the TSF is received from the hardware in the TX processq context and should be correct.
I first looked at the processing of ts_tstamp in the TX stats, which seems to be a 16 bit value, which is put into the 15 bit function ath_extend_tsf() and leads to forward and backward jumps in the sequence of TX TSF values. This issue is fixed by the attached patch.
The second problem is that the ds_txstat.ts_tstamp value returned by HAL (or the hardware) is not the TSF but some other value, which is incremented at a much slower rate (I measured something in the range of 1ms per tick, instead of 1µs for TSF). As there is no documentation regarding the hardware/HAL value returned in that field, and it is not based on TSF, I have no idea how to interpret it.
The attached patch fixes only the first part of the issue, the question about the correct TX TSF remains.