Skip to content

Commit d7c0882

Browse files
yangbolu1991davem330
authored andcommitted
net: socket: support hardware timestamp conversion to PHC bound
This patch is to support hardware timestamp conversion to PHC bound. This applies to both RX and TX since their skb handling (for TX, it's skb clone in error queue) all goes through __sock_recv_timestamp. Signed-off-by: Yangbo Lu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d463126 commit d7c0882

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

net/socket.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
#include <linux/sockios.h>
105105
#include <net/busy_poll.h>
106106
#include <linux/errqueue.h>
107+
#include <linux/ptp_clock_kernel.h>
107108

108109
#ifdef CONFIG_NET_RX_BUSY_POLL
109110
unsigned int sysctl_net_busy_read __read_mostly;
@@ -873,12 +874,18 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
873874
empty = 0;
874875
if (shhwtstamps &&
875876
(sk->sk_tsflags & SOF_TIMESTAMPING_RAW_HARDWARE) &&
876-
!skb_is_swtx_tstamp(skb, false_tstamp) &&
877-
ktime_to_timespec64_cond(shhwtstamps->hwtstamp, tss.ts + 2)) {
878-
empty = 0;
879-
if ((sk->sk_tsflags & SOF_TIMESTAMPING_OPT_PKTINFO) &&
880-
!skb_is_err_queue(skb))
881-
put_ts_pktinfo(msg, skb);
877+
!skb_is_swtx_tstamp(skb, false_tstamp)) {
878+
if (sk->sk_tsflags & SOF_TIMESTAMPING_BIND_PHC)
879+
ptp_convert_timestamp(shhwtstamps, sk->sk_bind_phc);
880+
881+
if (ktime_to_timespec64_cond(shhwtstamps->hwtstamp,
882+
tss.ts + 2)) {
883+
empty = 0;
884+
885+
if ((sk->sk_tsflags & SOF_TIMESTAMPING_OPT_PKTINFO) &&
886+
!skb_is_err_queue(skb))
887+
put_ts_pktinfo(msg, skb);
888+
}
882889
}
883890
if (!empty) {
884891
if (sock_flag(sk, SOCK_TSTAMP_NEW))

0 commit comments

Comments
 (0)