diff options
-rw-r--r-- | Documentation/networking/packet_mmap.txt | 18 | ||||
-rw-r--r-- | include/uapi/linux/if_packet.h | 2 | ||||
-rw-r--r-- | net/packet/af_packet.c | 12 |
3 files changed, 11 insertions, 21 deletions
diff --git a/Documentation/networking/packet_mmap.txt b/Documentation/networking/packet_mmap.txt index 38112d512f47..a6d7cb91069e 100644 --- a/Documentation/networking/packet_mmap.txt +++ b/Documentation/networking/packet_mmap.txt | |||
@@ -1008,14 +1008,9 @@ hardware timestamps to be used. Note: you may need to enable the generation | |||
1008 | of hardware timestamps with SIOCSHWTSTAMP (see related information from | 1008 | of hardware timestamps with SIOCSHWTSTAMP (see related information from |
1009 | Documentation/networking/timestamping.txt). | 1009 | Documentation/networking/timestamping.txt). |
1010 | 1010 | ||
1011 | PACKET_TIMESTAMP accepts the same integer bit field as | 1011 | PACKET_TIMESTAMP accepts the same integer bit field as SO_TIMESTAMPING: |
1012 | SO_TIMESTAMPING. However, only the SOF_TIMESTAMPING_SYS_HARDWARE | 1012 | |
1013 | and SOF_TIMESTAMPING_RAW_HARDWARE values are recognized by | 1013 | int req = SOF_TIMESTAMPING_RAW_HARDWARE; |
1014 | PACKET_TIMESTAMP. SOF_TIMESTAMPING_SYS_HARDWARE takes precedence over | ||
1015 | SOF_TIMESTAMPING_RAW_HARDWARE if both bits are set. | ||
1016 | |||
1017 | int req = 0; | ||
1018 | req |= SOF_TIMESTAMPING_SYS_HARDWARE; | ||
1019 | setsockopt(fd, SOL_PACKET, PACKET_TIMESTAMP, (void *) &req, sizeof(req)) | 1014 | setsockopt(fd, SOL_PACKET, PACKET_TIMESTAMP, (void *) &req, sizeof(req)) |
1020 | 1015 | ||
1021 | For the mmap(2)ed ring buffers, such timestamps are stored in the | 1016 | For the mmap(2)ed ring buffers, such timestamps are stored in the |
@@ -1023,14 +1018,13 @@ tpacket{,2,3}_hdr structure's tp_sec and tp_{n,u}sec members. To determine | |||
1023 | what kind of timestamp has been reported, the tp_status field is binary |'ed | 1018 | what kind of timestamp has been reported, the tp_status field is binary |'ed |
1024 | with the following possible bits ... | 1019 | with the following possible bits ... |
1025 | 1020 | ||
1026 | TP_STATUS_TS_SYS_HARDWARE | ||
1027 | TP_STATUS_TS_RAW_HARDWARE | 1021 | TP_STATUS_TS_RAW_HARDWARE |
1028 | TP_STATUS_TS_SOFTWARE | 1022 | TP_STATUS_TS_SOFTWARE |
1029 | 1023 | ||
1030 | ... that are equivalent to its SOF_TIMESTAMPING_* counterparts. For the | 1024 | ... that are equivalent to its SOF_TIMESTAMPING_* counterparts. For the |
1031 | RX_RING, if none of those 3 are set (i.e. PACKET_TIMESTAMP is not set), | 1025 | RX_RING, if neither is set (i.e. PACKET_TIMESTAMP is not set), then a |
1032 | then this means that a software fallback was invoked *within* PF_PACKET's | 1026 | software fallback was invoked *within* PF_PACKET's processing code (less |
1033 | processing code (less precise). | 1027 | precise). |
1034 | 1028 | ||
1035 | Getting timestamps for the TX_RING works as follows: i) fill the ring frames, | 1029 | Getting timestamps for the TX_RING works as follows: i) fill the ring frames, |
1036 | ii) call sendto() e.g. in blocking mode, iii) wait for status of relevant | 1030 | ii) call sendto() e.g. in blocking mode, iii) wait for status of relevant |
diff --git a/include/uapi/linux/if_packet.h b/include/uapi/linux/if_packet.h index bac27fa05f5b..da2d668b8cf1 100644 --- a/include/uapi/linux/if_packet.h +++ b/include/uapi/linux/if_packet.h | |||
@@ -108,7 +108,7 @@ struct tpacket_auxdata { | |||
108 | 108 | ||
109 | /* Rx and Tx ring - header status */ | 109 | /* Rx and Tx ring - header status */ |
110 | #define TP_STATUS_TS_SOFTWARE (1 << 29) | 110 | #define TP_STATUS_TS_SOFTWARE (1 << 29) |
111 | #define TP_STATUS_TS_SYS_HARDWARE (1 << 30) | 111 | #define TP_STATUS_TS_SYS_HARDWARE (1 << 30) /* deprecated, never set */ |
112 | #define TP_STATUS_TS_RAW_HARDWARE (1 << 31) | 112 | #define TP_STATUS_TS_RAW_HARDWARE (1 << 31) |
113 | 113 | ||
114 | /* Rx ring - feature request bits */ | 114 | /* Rx ring - feature request bits */ |
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 614ca91f785a..8d9f8042705a 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -441,14 +441,10 @@ static __u32 tpacket_get_timestamp(struct sk_buff *skb, struct timespec *ts, | |||
441 | { | 441 | { |
442 | struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb); | 442 | struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb); |
443 | 443 | ||
444 | if (shhwtstamps) { | 444 | if (shhwtstamps && |
445 | if ((flags & SOF_TIMESTAMPING_SYS_HARDWARE) && | 445 | (flags & SOF_TIMESTAMPING_RAW_HARDWARE) && |
446 | ktime_to_timespec_cond(shhwtstamps->syststamp, ts)) | 446 | ktime_to_timespec_cond(shhwtstamps->hwtstamp, ts)) |
447 | return TP_STATUS_TS_SYS_HARDWARE; | 447 | return TP_STATUS_TS_RAW_HARDWARE; |
448 | if ((flags & SOF_TIMESTAMPING_RAW_HARDWARE) && | ||
449 | ktime_to_timespec_cond(shhwtstamps->hwtstamp, ts)) | ||
450 | return TP_STATUS_TS_RAW_HARDWARE; | ||
451 | } | ||
452 | 448 | ||
453 | if (ktime_to_timespec_cond(skb->tstamp, ts)) | 449 | if (ktime_to_timespec_cond(skb->tstamp, ts)) |
454 | return TP_STATUS_TS_SOFTWARE; | 450 | return TP_STATUS_TS_SOFTWARE; |