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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'timestamp-for-jens' of https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next into for-6.17/io_uring

Pull networking side timestamp prep patch from Jakub.

* 'timestamp-for-jens' of https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next:
net: timestamp: add helper returning skb's tx tstamp

Jens Axboe 5be5726e cb9ccfb4

+50
+4
include/net/sock.h
··· 2677 2677 void __sock_recv_wifi_status(struct msghdr *msg, struct sock *sk, 2678 2678 struct sk_buff *skb); 2679 2679 2680 + bool skb_has_tx_timestamp(struct sk_buff *skb, const struct sock *sk); 2681 + int skb_get_tx_timestamp(struct sk_buff *skb, struct sock *sk, 2682 + struct timespec64 *ts); 2683 + 2680 2684 static inline void 2681 2685 sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb) 2682 2686 {
+46
net/socket.c
··· 843 843 sizeof(ts_pktinfo), &ts_pktinfo); 844 844 } 845 845 846 + bool skb_has_tx_timestamp(struct sk_buff *skb, const struct sock *sk) 847 + { 848 + const struct sock_exterr_skb *serr = SKB_EXT_ERR(skb); 849 + u32 tsflags = READ_ONCE(sk->sk_tsflags); 850 + 851 + if (serr->ee.ee_errno != ENOMSG || 852 + serr->ee.ee_origin != SO_EE_ORIGIN_TIMESTAMPING) 853 + return false; 854 + 855 + /* software time stamp available and wanted */ 856 + if ((tsflags & SOF_TIMESTAMPING_SOFTWARE) && skb->tstamp) 857 + return true; 858 + /* hardware time stamps available and wanted */ 859 + return (tsflags & SOF_TIMESTAMPING_RAW_HARDWARE) && 860 + skb_hwtstamps(skb)->hwtstamp; 861 + } 862 + 863 + int skb_get_tx_timestamp(struct sk_buff *skb, struct sock *sk, 864 + struct timespec64 *ts) 865 + { 866 + u32 tsflags = READ_ONCE(sk->sk_tsflags); 867 + ktime_t hwtstamp; 868 + int if_index = 0; 869 + 870 + if ((tsflags & SOF_TIMESTAMPING_SOFTWARE) && 871 + ktime_to_timespec64_cond(skb->tstamp, ts)) 872 + return SOF_TIMESTAMPING_TX_SOFTWARE; 873 + 874 + if (!(tsflags & SOF_TIMESTAMPING_RAW_HARDWARE) || 875 + skb_is_swtx_tstamp(skb, false)) 876 + return -ENOENT; 877 + 878 + if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP_NETDEV) 879 + hwtstamp = get_timestamp(sk, skb, &if_index); 880 + else 881 + hwtstamp = skb_hwtstamps(skb)->hwtstamp; 882 + 883 + if (tsflags & SOF_TIMESTAMPING_BIND_PHC) 884 + hwtstamp = ptp_convert_timestamp(&hwtstamp, 885 + READ_ONCE(sk->sk_bind_phc)); 886 + if (!ktime_to_timespec64_cond(hwtstamp, ts)) 887 + return -ENOENT; 888 + 889 + return SOF_TIMESTAMPING_TX_HARDWARE; 890 + } 891 + 846 892 /* 847 893 * called from sock_recv_timestamp() if sock_flag(sk, SOCK_RCVTSTAMP) 848 894 */