Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rt2x00: use monotonic timestamps for frame dump

rt2x00 uses the deprecated do_gettimeofday() function to get a timestamp
for its debugfs "dump" file interface.

The timestamp is using an unsigned 32-bit value, so we could make it
work until 2106 by using ktime_get_real_ts64(), but it seems better to
use monotonic times, as we normally want for timestamps.

Since this is an interface change, I'm incrementing the
DUMP_HEADER_VERSION number, so user space can figure out whether the
timestamps are monotonic or not. Most likely the tools won't care either
way.

Generally speaking, ABI version numbers and in particular changing them
is a bad idea. However since this is in debugfs, we don't put any
API stability rules on the interface according to
Documentation/filesystems/debugfs.txt, and we can take the easy way
out here; anyone using the frame dump feature can probably work out
the differences here.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>

authored by

Arnd Bergmann and committed by
Kalle Valo
f87eba99 bfa62a52

+5 -4
+4 -3
drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
··· 164 164 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); 165 165 struct sk_buff *skbcopy; 166 166 struct rt2x00dump_hdr *dump_hdr; 167 - struct timeval timestamp; 167 + struct timespec64 timestamp; 168 168 u32 data_len; 169 169 170 170 if (likely(!test_bit(FRAME_DUMP_FILE_OPEN, &intf->frame_dump_flags))) 171 171 return; 172 172 173 - do_gettimeofday(&timestamp); 173 + ktime_get_ts64(&timestamp); 174 174 175 175 if (skb_queue_len(&intf->frame_dump_skbqueue) > 20) { 176 176 rt2x00_dbg(rt2x00dev, "txrx dump queue length exceeded\n"); ··· 200 200 dump_hdr->queue_index = entry->queue->qid; 201 201 dump_hdr->entry_index = entry->entry_idx; 202 202 dump_hdr->timestamp_sec = cpu_to_le32(timestamp.tv_sec); 203 - dump_hdr->timestamp_usec = cpu_to_le32(timestamp.tv_usec); 203 + dump_hdr->timestamp_usec = cpu_to_le32(timestamp.tv_nsec / 204 + NSEC_PER_USEC); 204 205 205 206 if (!(skbdesc->flags & SKBDESC_DESC_IN_SKB)) 206 207 skb_put_data(skbcopy, skbdesc->desc, skbdesc->desc_len);
+1 -1
drivers/net/wireless/ralink/rt2x00/rt2x00dump.h
··· 106 106 */ 107 107 struct rt2x00dump_hdr { 108 108 __le32 version; 109 - #define DUMP_HEADER_VERSION 2 109 + #define DUMP_HEADER_VERSION 3 110 110 111 111 __le32 header_length; 112 112 __le32 desc_length;