Skip to content

Commit

Permalink
net: socket: support hardware timestamp conversion to PHC bound
Browse files Browse the repository at this point in the history
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 <yangbo.lu@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Yangbo Lu authored and David S. Miller committed Jul 1, 2021
1 parent d463126 commit d7c0882
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions net/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
#include <linux/sockios.h>
#include <net/busy_poll.h>
#include <linux/errqueue.h>
#include <linux/ptp_clock_kernel.h>

#ifdef CONFIG_NET_RX_BUSY_POLL
unsigned int sysctl_net_busy_read __read_mostly;
Expand Down Expand Up @@ -873,12 +874,18 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
empty = 0;
if (shhwtstamps &&
(sk->sk_tsflags & SOF_TIMESTAMPING_RAW_HARDWARE) &&
!skb_is_swtx_tstamp(skb, false_tstamp) &&
ktime_to_timespec64_cond(shhwtstamps->hwtstamp, tss.ts + 2)) {
empty = 0;
if ((sk->sk_tsflags & SOF_TIMESTAMPING_OPT_PKTINFO) &&
!skb_is_err_queue(skb))
put_ts_pktinfo(msg, skb);
!skb_is_swtx_tstamp(skb, false_tstamp)) {
if (sk->sk_tsflags & SOF_TIMESTAMPING_BIND_PHC)
ptp_convert_timestamp(shhwtstamps, sk->sk_bind_phc);

if (ktime_to_timespec64_cond(shhwtstamps->hwtstamp,
tss.ts + 2)) {
empty = 0;

if ((sk->sk_tsflags & SOF_TIMESTAMPING_OPT_PKTINFO) &&
!skb_is_err_queue(skb))
put_ts_pktinfo(msg, skb);
}
}
if (!empty) {
if (sock_flag(sk, SOCK_TSTAMP_NEW))
Expand Down

0 comments on commit d7c0882

Please sign in to comment.