Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3516386pxj; Tue, 15 Jun 2021 02:39:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwgfm9Z6DpHbBp9O0hkYCHO2jwHZDLysEaxBJxcngfH3RVaAzwsYGlXvWAptDU/QaXxAVY X-Received: by 2002:a17:907:2156:: with SMTP id rk22mr19558612ejb.464.1623749966938; Tue, 15 Jun 2021 02:39:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623749966; cv=none; d=google.com; s=arc-20160816; b=SajI8kdkkktM0HilaZgoDwHAp4cJKyYWiAE9+6OJlncmSPm9+jcq097hc7Dwm1y7wp dNXL0k11NhAI/XWVwhiXqSOpLf7KyaMCGHq5NfEs0+KwG+fyfv6/leoe4FKkl9u6CEG+ uquzLu0f+S/571jYdoiYByZNDo2adlAoyEymqXVfciqZnF9mqSun3Ztrueok+A+1ghc8 zzFiEbwsRY5B0J/upQXF7QSDX5JT0r4OnkVn024Our22AAfC1x3EIl62E1r4kp9LB9mQ YI88ckWELa8XxiGZpKsyvbmwL1sG7lqsdemLndZxLiUNBsIf76wh24EMbNnM6bR6RDck w1Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=bDQyAo+urE6KtDIKHzcvDrM4seOOcSOgsSzqD1IUoeE=; b=pika/Wf79CMqz+TW/HV+ALq0FjDBBlp41dt/VdiHhbjlT68l0w2+dorz2CuKuu/KOL 9xEoIAy2p1ni6OL2ZSdw9BYyrEA1oxD/5Xw1DtVb7EWrz/i5jx1CmRQYY0CR2rrMI0Ei dlGb4k8irpUdFZuUdJJBYNt1PoOgzx3OzCUXd17BqgP8hFCeMSBOAqfiy/+YxmHn4cB1 Zy1LbHr4aPeC2C+JNHwlluTf3PRYpODEETEcy/psQprdIQnYcSyD32hj0Ke7JHcXggWk yFBeXpTqBS8yoCKrxUDPkFHQeZc59AODjn/j14QeBTwm1pKy+F0lryOcQXw3KjwCr79f Lrag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z23si14381216ejw.466.2021.06.15.02.39.04; Tue, 15 Jun 2021 02:39:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231723AbhFOJjD (ORCPT + 99 others); Tue, 15 Jun 2021 05:39:03 -0400 Received: from inva021.nxp.com ([92.121.34.21]:42246 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231636AbhFOJiw (ORCPT ); Tue, 15 Jun 2021 05:38:52 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 8E7D9202A2D; Tue, 15 Jun 2021 11:36:47 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 79C96202A16; Tue, 15 Jun 2021 11:36:41 +0200 (CEST) Received: from localhost.localdomain (mega.ap.freescale.net [10.192.208.232]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 138CE402B6; Tue, 15 Jun 2021 17:36:32 +0800 (+08) From: Yangbo Lu To: netdev@vger.kernel.org Cc: Yangbo Lu , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, mptcp@lists.linux.dev, Richard Cochran , "David S . Miller" , Jakub Kicinski , Mat Martineau , Matthieu Baerts , Shuah Khan , Michal Kubecek , Florian Fainelli , Andrew Lunn , Rui Sousa , Sebastien Laveze Subject: [net-next, v3, 08/10] net: socket: support hardware timestamp conversion to PHC bound Date: Tue, 15 Jun 2021 17:45:15 +0800 Message-Id: <20210615094517.48752-9-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210615094517.48752-1-yangbo.lu@nxp.com> References: <20210615094517.48752-1-yangbo.lu@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- Changes for v3: - Added this patch. --- net/socket.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/net/socket.c b/net/socket.c index 27e3e7d53f8e..ac07df4feb29 100644 --- a/net/socket.c +++ b/net/socket.c @@ -104,6 +104,7 @@ #include #include #include +#include #ifdef CONFIG_NET_RX_BUSY_POLL unsigned int sysctl_net_busy_read __read_mostly; @@ -825,12 +826,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)) -- 2.25.1